My JS application needs to display data in a specific order.
The process:
Users select sectors first, resulting in sector data based on their choices like,
const selectedSectors = [{sectorName: "Sector One", sectorId: 5}, {sectorName: "Sector Two", sectorId: 24}]
We already have department and job title data, and we retrieve matching records using the code below,
// code block here
The above code produces the following result,
Current Output:
// output goes here
The output aligns with expectations. However, I need to include the data along with the corresponding Sectors
.
So based on sector selection by the user, the respective departments and job titles should be displayed.
The expected structure is as follows,
Expected Output:
// expected output structure
Based on the provided data, it's evident that sector ID 5 has two departments (Production and Design/Engineering), while sector ID 24 has two different departments (Consulting and Administration).
// additional code snippet
I can filter and group job titles based on DepartmentID but struggle with grouping departments by sector ID.
Hint: The selectedSectors
and departments
variables contain the sectorId
.
Any assistance in achieving the expected outcome is greatly appreciated. Thank you!