init
This commit is contained in:
28
worklenz-frontend/src/app/routes/reporting-routes.tsx
Normal file
28
worklenz-frontend/src/app/routes/reporting-routes.tsx
Normal file
@@ -0,0 +1,28 @@
|
||||
import { RouteObject } from 'react-router-dom';
|
||||
import ReportingLayout from '@/layouts/ReportingLayout';
|
||||
import { ReportingMenuItems, reportingsItems } from '@/lib/reporting/reporting-constants';
|
||||
|
||||
// function to flatten nested menu items
|
||||
const flattenItems = (items: ReportingMenuItems[]): ReportingMenuItems[] => {
|
||||
return items.reduce<ReportingMenuItems[]>((acc, item) => {
|
||||
if (item.children) {
|
||||
return [...acc, ...flattenItems(item.children)];
|
||||
}
|
||||
return [...acc, item];
|
||||
}, []);
|
||||
};
|
||||
|
||||
const flattenedItems = flattenItems(reportingsItems);
|
||||
|
||||
const reportingRoutes: RouteObject[] = [
|
||||
{
|
||||
path: 'worklenz/reporting',
|
||||
element: <ReportingLayout />,
|
||||
children: flattenedItems.map(item => ({
|
||||
path: item.endpoint,
|
||||
element: item.element,
|
||||
})),
|
||||
},
|
||||
];
|
||||
|
||||
export default reportingRoutes;
|
||||
Reference in New Issue
Block a user