diff --git a/client/src/components/AppSidebar.tsx b/client/src/components/AppSidebar.tsx index 83b69a2..a68e1b7 100644 --- a/client/src/components/AppSidebar.tsx +++ b/client/src/components/AppSidebar.tsx @@ -1,12 +1,10 @@ // AppSidebar.tsx — Sidebar partagée avec navigation hiérarchique en accordéon // Structure mise à jour : // ├── ITINOVA (bleu) -// │ ├── Établissements (bleu foncé) -// │ │ ├── Renouvellement PC → / -// │ │ ├── CAPEX - Construction → /budget2027 -// │ │ └── CAPEX - Synthèse → /dsi-capex -// │ └── DSI (bleu foncé) -// │ └── OPEX (Charges) → /dsi-opex +// │ ├── Renouvellement PC → / +// │ ├── CAPEX - Construction → /budget2027 +// │ ├── CAPEX - Synthèse → /dsi-capex +// │ └── OPEX (Charges) → /dsi-opex // ├── SANTINOVA (vert) // ├── SOINS ET SANTÉ (violet) // ├── ST EXUPÉRY (orange) @@ -105,19 +103,12 @@ interface NavLeaf { path: string; } -interface NavSubMenu { - id: string; - label: string; - icon: React.ElementType; - children: NavLeaf[]; -} - interface NavSection { id: string; label: string; icon: React.ElementType; - path?: string; // si section sans sous-menu (feuille directe) - children?: NavSubMenu[]; // sous-menus + path?: string; // si section feuille directe + children?: NavLeaf[]; // items directs (sans sous-menu intermédiaire) } const NAV_SECTIONS: NavSection[] = [ @@ -126,24 +117,10 @@ const NAV_SECTIONS: NavSection[] = [ label: 'ITINOVA', icon: Building2, children: [ - { - id: 'etablissements', - label: 'Établissements', - icon: Layers, - children: [ - { id: 'renouvellement-pc', label: 'Renouvellement PC', icon: Monitor, path: '/' }, - { id: 'budget2027', label: 'CAPEX - Construction', icon: FileText, path: '/budget2027' }, - { id: 'dsi-capex', label: 'CAPEX - Synthèse', icon: TableProperties, path: '/dsi-capex' }, - ], - }, - { - id: 'dsi', - label: 'DSI', - icon: BarChart3, - children: [ - { id: 'dsi-opex', label: 'OPEX (Charges)', icon: TrendingDown, path: '/dsi-opex' }, - ], - }, + { id: 'renouvellement-pc', label: 'Renouvellement PC', icon: Monitor, path: '/' }, + { id: 'budget2027', label: 'CAPEX - Construction', icon: FileText, path: '/budget2027' }, + { id: 'dsi-capex', label: 'CAPEX - Synthèse', icon: TableProperties, path: '/dsi-capex' }, + { id: 'dsi-opex', label: 'OPEX (Charges)', icon: TrendingDown, path: '/dsi-opex' }, ], }, { @@ -175,24 +152,13 @@ function isLeafActive(path: string, currentPath: string): boolean { function sectionHasActive(section: NavSection, currentPath: string): boolean { if (section.path) return isLeafActive(section.path, currentPath); - return section.children?.some(sub => - sub.children.some(leaf => isLeafActive(leaf.path, currentPath)) - ) ?? false; -} - -function subMenuHasActive(sub: NavSubMenu, currentPath: string): boolean { - return sub.children.some(leaf => isLeafActive(leaf.path, currentPath)); + return section.children?.some(leaf => isLeafActive(leaf.path!, currentPath)) ?? false; } function getInitialOpenSections(currentPath: string): Set { const open = new Set(); for (const section of NAV_SECTIONS) { - if (sectionHasActive(section, currentPath)) { - open.add(section.id); - section.children?.forEach(sub => { - if (subMenuHasActive(sub, currentPath)) open.add(sub.id); - }); - } + if (sectionHasActive(section, currentPath)) open.add(section.id); } return open; } @@ -299,7 +265,7 @@ export function AppSidebar({ collapsed = false, onToggle }: AppSidebarProps) { ); } - // Section avec sous-menus (accordéon) + // Section avec items directs (un seul niveau d'accordéon) return (
{/* Bouton section principale */} @@ -326,59 +292,26 @@ export function AppSidebar({ collapsed = false, onToggle }: AppSidebarProps) { )} - {/* Sous-menus — accordéon */} + {/* Items directs — un seul niveau */} {!collapsed && isOpen && (
- {section.children.map(sub => { - const subActive = subMenuHasActive(sub, location); - const subOpen = openMenus.has(sub.id); - const SubIcon = sub.icon; - + {section.children.map(leaf => { + const leafActive = isLeafActive(leaf.path!, location); + const LeafIcon = leaf.icon; return ( -
- {/* Bouton sous-menu */} - - - {/* Items feuilles */} - {subOpen && ( -
- {sub.children.map(leaf => { - const leafActive = isLeafActive(leaf.path, location); - const LeafIcon = leaf.icon; - return ( - - ); - })} -
- )} -
+ ); })}