// The manager's navigation (plan step 2.6a): ONE definition read by the sidebar, the page // titles and the route guards, so an item a user can't see is also a route they can't open. // // Every page names // module the backend module its API belongs to (local_backend/modules//manifest.py); // if the module is off or not licensed, the item is hidden and the route shows // "this feature is turned off" // perm the permission key it needs. Same rules as before platform v2: the old // permission names map to keys (core/access/legacy.py); pages that had no // permission need core.dashboard.access (what their APIs check, require_manager). // Finer keys (pricing.manage, expenses.manage…) replace these when phase 6 // converts those routers. // anyPerm instead of perm: any one of these keys is enough (the media library) // label a key in the i18n `manager` namespace import { LayoutDashboard, LayoutGrid, ShoppingBag, BookUser, Users, Receipt, CreditCard, Package, TableProperties, UserCog, CalendarDays, Trash2, Boxes, BarChart2, TrendingUp, Users2, ShoppingCart, Tag, Activity, Printer, ConciergeBell, FileText, AppWindow, Settings, CookingPot, StickyNote, Percent, Plug, BadgeCheck, MonitorSmartphone, LogIn, ShieldCheck, Images, Tv, } from 'lucide-react' const DASH = 'core.dashboard.access' // The media library: whoever manages something that shows pictures (routers/media.py MANAGE) const MEDIA = ['catalog.menu.manage', 'customer_display.manage', 'signage.manage', 'menu_tablet.manage'] export const NAV = [ { section: 'nav.sections.operation', items: [ { to: '/dashboard', icon: LayoutDashboard, label: 'nav.dashboard', module: 'core', perm: DASH }, { to: '/tables', icon: LayoutGrid, label: 'nav.tables', module: 'ordering', perm: DASH }, { to: '/online-orders', icon: ShoppingBag, label: 'nav.onlineOrders', module: 'connect_orders', perm: DASH, badge: 'onlineOrders' }, // 2026-11-20: delivery fees are Online orders → Settings, the QR codes a view of Tables ], }, { section: 'nav.sections.financial', items: [ { group: 'crm', icon: BookUser, label: 'nav.crm', children: [ { to: '/crm/contacts', icon: BookUser, label: 'nav.contacts', module: 'expenses', perm: 'expenses.manage' }, { to: '/crm/customers', icon: Users, label: 'nav.customers', module: 'crm', perm: 'crm.manage' }, ], }, { group: 'financials', icon: Receipt, label: 'nav.finance', children: [ { to: '/financials/expenses', icon: Receipt, label: 'nav.expenses', module: 'expenses', perm: 'expenses.manage' }, { to: '/financials/tabs', icon: CreditCard, label: 'nav.tabs', module: 'tabs', perm: 'tabs.manage' }, ], }, ], }, { section: 'nav.sections.headquarters', items: [ { group: 'management', icon: Package, label: 'nav.management', children: [ { to: '/management/products', icon: Package, label: 'nav.products', module: 'catalog', perm: 'catalog.menu.manage' }, { to: '/management/media', icon: Images, label: 'nav.media', module: 'core', anyPerm: MEDIA }, { to: '/management/signage', icon: Tv, label: 'nav.signage', module: 'signage', perm: 'signage.manage' }, { to: '/management/tables', icon: TableProperties, label: 'nav.tablesConfig', module: 'catalog', perm: 'catalog.tables.manage' }, { to: '/management/staff', icon: UserCog, label: 'nav.staff', module: 'core', perm: 'core.staff.manage' }, { to: '/management/sessions', icon: LogIn, label: 'nav.sessions', module: 'core', perm: 'core.staff.manage' }, { to: '/management/approvals', icon: ShieldCheck, label: 'nav.approvals', module: 'core', perm: 'core.staff.manage' }, { to: '/management/schedule', icon: CalendarDays, label: 'nav.schedule', module: 'staff_planning', perm: 'core.staff.manage' }, { to: '/management/prep-zones', icon: CookingPot, label: 'nav.prepZones', module: 'catalog', perm: 'catalog.menu.manage' }, { to: '/management/pricing', icon: Percent, label: 'nav.pricing', module: 'pricing', perm: 'pricing.manage' }, { to: '/notes', icon: StickyNote, label: 'nav.notes', module: 'notes', perm: 'notes.use' }, ], }, { group: 'inventory', icon: Boxes, label: 'nav.inventory', children: [ { to: '/inventory/throwaways', icon: Trash2, label: 'nav.waste', module: 'inventory', perm: 'inventory.manage' }, { to: '/inventory/stock', icon: Boxes, label: 'nav.stock', module: 'inventory', perm: 'inventory.manage', placeholder: true }, ], }, ], }, { section: 'nav.sections.overwatch', items: [ { group: 'reports', icon: BarChart2, label: 'nav.reports', children: [ { to: '/reports/today', icon: Activity, label: 'nav.reportsToday', module: 'reports', perm: 'reports.view' }, { to: '/reports/store', icon: TrendingUp, label: 'nav.reportsStore', module: 'reports', perm: 'reports.view' }, { to: '/reports/staff', icon: Users2, label: 'nav.reportsStaff', module: 'reports', perm: 'reports.view' }, { to: '/reports/products', icon: ShoppingCart, label: 'nav.reportsProducts', module: 'reports', perm: 'reports.view' }, { to: '/reports/prep-zones', icon: ConciergeBell, label: 'nav.reportsPrepZones', module: 'reports', perm: 'reports.view' }, { to: '/reports/expenses', icon: FileText, label: 'nav.reportsExpenses', module: 'reports', perm: 'reports.view' }, { to: '/reports/technical', icon: Printer, label: 'nav.reportsTechnical', module: 'reports', perm: 'reports.view' }, { to: '/reports/misc', icon: Tag, label: 'nav.reportsMisc', module: 'reports', perm: 'reports.view' }, ], }, ], }, ] export const NAV_BOTTOM = [ { to: '/apps', icon: AppWindow, label: 'nav.apps', module: 'core', perm: DASH }, { to: '/integrations', icon: Plug, label: 'nav.integrations', module: 'core', perm: DASH }, { to: '/devices', icon: MonitorSmartphone, label: 'nav.devices', module: 'core', perm: 'core.devices.manage' }, { to: '/license', icon: BadgeCheck, label: 'nav.license', module: 'core', perm: DASH }, { to: '/settings', icon: Settings, label: 'nav.settings', module: 'core', perm: 'core.settings.manage' }, ] // Pages that aren't in the sidebar but still have a title and a guard const EXTRA = [ { to: '/apps/phone', label: 'nav.phone', parent: 'nav.integrations', module: 'caller_id', perm: DASH }, { prefix: '/orders/', label: 'nav.order', module: 'ordering', perm: DASH }, ] /** Every page: { to | prefix, label, parent (group label) , module, perm } */ export const PAGES = [ ...NAV.flatMap(s => s.items.flatMap(item => (item.children ? item.children.map(c => ({ ...c, parent: item.label })) : [item]))), ...NAV_BOTTOM, ...EXTRA, ] /** The page entry for a path (exact first, then prefix pages like /orders/:id). */ export function pageFor(pathname) { return PAGES.find(p => p.to === pathname) || PAGES.find(p => p.prefix && pathname.startsWith(p.prefix)) || null } /** Can this user see this page? modules / permissions are the Sets from useAccess(). */ export function canSee(page, { modules, permissions }) { if (!page) return true if (page.module && !modules.has(page.module)) return false if (page.anyPerm) return page.anyPerm.some(k => permissions.has(k)) return !page.perm || permissions.has(page.perm) }