diff --git a/resources/js/components/sgc-workspace-shell.tsx b/resources/js/components/sgc-workspace-shell.tsx index 6c0c495..46a2fdb 100644 --- a/resources/js/components/sgc-workspace-shell.tsx +++ b/resources/js/components/sgc-workspace-shell.tsx @@ -7,7 +7,7 @@ import { Search, X, } from 'lucide-react'; -import { Fragment, useEffect, useRef, useState } from 'react'; +import { useEffect, useRef, useState } from 'react'; import type { ReactNode } from 'react'; import { Button } from '@/components/ui/button'; import { @@ -29,7 +29,10 @@ import { activeProcurementEntry, procurementNavigation, } from '@/lib/procurement-navigation'; -import type { CommonFinanceNavigation } from '@/lib/procurement-navigation'; +import type { + CommonFinanceNavigation, + ProcurementEntry, +} from '@/lib/procurement-navigation'; import { roleLabels } from '@/types/procurement'; import type { WorkContextState } from '@/types/work-context'; import { WorkContextChange } from '@/components/work-context-change'; @@ -40,6 +43,17 @@ import { searchProcurementMenu, } from '@/lib/procurement-menu-search'; +/** Agrupa entradas consecutivas pela secção, mantendo a ordem do menu. */ +function menuSections(entries: ProcurementEntry[]) { + const sections: { label?: string; entries: ProcurementEntry[] }[] = []; + for (const entry of entries) { + const last = sections[sections.length - 1]; + if (last && last.label === entry.section) last.entries.push(entry); + else sections.push({ label: entry.section, entries: [entry] }); + } + return sections; +} + export function SgcWorkspaceShell({ children }: { children: ReactNode }) { const page = usePage(); const user = page.props.auth?.user; @@ -252,14 +266,14 @@ export function SgcWorkspaceShell({ children }: { children: ReactNode }) {