MCPcopy
hub / github.com/d3george/slash-admin / processItem

Function processItem

src/routes/sections/dashboard/backend.tsx:49–86  ·  view source on GitHub ↗
(item: MenuTree)

Source from the content-addressed store, hash-verified

47 const routes: RouteObject[] = [];
48
49 const processItem = (item: MenuTree) => {
50 // if group, process children
51 if (item.type === PermissionType.GROUP) {
52 for (const child of item.children || []) {
53 processItem(child);
54 }
55 }
56
57 // if catalogue, process children
58 if (item.type === PermissionType.CATALOGUE) {
59 const children = item.children || [];
60 if (children.length > 0) {
61 const firstChild = children[0];
62 if (firstChild.path) {
63 routes.push({
64 path: getRoutePath(item.path, parent?.path),
65 children: [
66 {
67 index: true,
68 element: <Navigate to={getRoutePath(firstChild.path, item.path)} replace />,
69 },
70 ...convertToRoute(children, item),
71 ],
72 });
73 }
74 }
75 }
76
77 // if menu, create route
78 if (item.type === PermissionType.MENU) {
79 const props = generateProps(item);
80
81 routes.push({
82 path: getRoutePath(item.path, parent?.path),
83 element: Component(item.component, props),
84 });
85 }
86 };
87
88 for (const item of items) {
89 processItem(item);

Callers 1

convertToRouteFunction · 0.85

Calls 4

ComponentFunction · 0.90
getRoutePathFunction · 0.85
convertToRouteFunction · 0.85
generatePropsFunction · 0.85

Tested by

no test coverage detected