Files
xenia-pos-local/manager_dashboard/src/shell/nav.js
T
bonaminandClaude Opus 5.5 6f4ab23582 feat(manager): design pass 1 — every page on <Page>, shared toolbars, fees under Online orders, QR codes under Tables, day stats reworked
From the owner's page-by-page review (2026-11-20):
- every page root is <Page> (scrolls, fills 1080p, 16:9 centred on
  ultrawides); not yet: products, management/tables, stock (next pass)
- /dashboard: more padding in cards (p-card), quieter secondary text,
  11px uppercase labels everywhere (text-overline)
- day stats: xl dialog, "● Day running · Opened …" as text, the six
  figures in equal boxes, "On tabs" in the payments bar, shared Tabs
- /tables: Segmented List / Map / QR codes (?view=; /online/qr redirects),
  filter chips + zones multi-select at one height, the card itself opens
  the table (button removed), cards ~20% wider
- /online-orders: shared Tabs with Settings (= the old /online/fees page,
  which redirects to ?tab=settings); orders fill the width
- contacts, customers, expenses: PageHeader + Toolbar + SearchInput +
  multi-select Dropdowns (kinds; statuses, categories); table cells
  vertically centred; the Spent tip opens on hover
- filterCards / filterContacts / filterExpenses take several values
  (unit tests added)
- docs/DESIGN.md: the design language (CS-20 in the pack README)
- tests/e2e/manager_layout.mjs: the page rule at 1920x1080 and 3440x1440;
  manager.mjs and manager_look.mjs follow the moved pages

Verified: manager build + lint (0 errors), unit tests (manager 99, ui 24,
i18n 31, api 25, access 8), i18n guard, manager_layout.mjs all passed,
manager.mjs 228 checks all passed. Not checked: the waiter app and the
terminal by eye (they only get the muted ink-2 token).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 11:23:30 +02:00

139 lines
7.4 KiB
JavaScript

// 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/<key>/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)
}