diff --git a/src/components/Dashboard/common/DashboardSidebar.jsx b/src/components/Dashboard/common/DashboardSidebar.jsx index 235ad34..abf82fe 100644 --- a/src/components/Dashboard/common/DashboardSidebar.jsx +++ b/src/components/Dashboard/common/DashboardSidebar.jsx @@ -38,18 +38,35 @@ const DashboardSidebar = ({ if (onCollapse) onCollapse(newCollapsed) } - // Add onClick to each item - const _items = items.map((item) => { - if (item?.type == 'divider') { - return item - } - return { - key: item.key, - icon: item.icon, - label: item.label, - onClick: () => navigate(item.path) - } - }) + // Recursive function to map items and their children + const mapItemsRecursively = (items) => { + return items.map((item) => { + if (item?.type === 'divider') { + return item + } + + const mappedItem = { + key: item.key, + icon: item.icon, + label: item.label + } + + // Add onClick for items with paths (leaf nodes) + if (item.path) { + mappedItem.onClick = () => navigate(item.path) + } + + // Recursively map children if they exist + if (item?.children && Array.isArray(item.children)) { + mappedItem.children = mapItemsRecursively(item.children) + } + + return mappedItem + }) + } + + // Map items recursively + const _items = mapItemsRecursively(items) if (isMobile) { return (