Plan phase 3S, step S.7. - tables.qr_token (migration 0021): a random token per active table; services/table_qr.py (tokens, rotate, the snapshot's `qr` with the tokens' sha256 only, the code's link from the cloud's apps_url); setting connect_menu.table_ordering (read-only by default). - /api/connect/qr (connect_menu.manage): the codes, ordering on/off, a new code per table or for all; table and QR changes push the menu at once (MENU_PATHS). - Pull: a QR order with a table id goes onto the table's open order or a new one (services/qr_orders.py): items at the cloud's prices, kitchen tickets, KDS, order_updated (the waiters' phones and the counter), a `qr_order` message to the order's waiters or the table's zone waiters; audit QR_ORDER (a repeated pull adds nothing); the cloud is told "accepted" (the guest's page: in the kitchen). No usable table or no open day → the counter gets it as before. Waiter app: the message's look. - Manager: Online → Table QR codes (/online/qr): ordering switch, the menu link, a QR card per table (print all), new code per table / for all. - Heartbeat: apps_url kept in the license state. - Tests: tests/test_qr_table.py (5); e2e qr_table.mjs (a real cloud and venue: table 5's code → two dishes on table 5's order, KDS, live event, the guest's page; a forged code refused; a new code kills the old one), in run-all. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
134 lines
6.9 KiB
JavaScript
134 lines
6.9 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.
|
|
// 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, Truck, StickyNote, Percent, Plug, BadgeCheck, MonitorSmartphone, LogIn, ShieldCheck, QrCode,
|
|
} from 'lucide-react'
|
|
|
|
const DASH = 'core.dashboard.access'
|
|
|
|
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' },
|
|
{ to: '/online/fees', icon: Truck, label: 'nav.deliveryFees', module: 'connect_orders', perm: 'connect_orders.fees' },
|
|
{ to: '/online/qr', icon: QrCode, label: 'nav.qrCodes', module: 'connect_menu', perm: 'connect_menu.manage' },
|
|
],
|
|
},
|
|
{
|
|
section: 'nav.sections.financial',
|
|
items: [
|
|
{
|
|
group: 'crm', icon: BookUser, label: 'nav.crm',
|
|
children: [
|
|
{ to: '/crm/contacts', icon: BookUser, label: 'nav.contacts', module: 'expenses', perm: DASH },
|
|
{ to: '/crm/customers', icon: Users, label: 'nav.customers', module: 'crm', perm: DASH },
|
|
],
|
|
},
|
|
{
|
|
group: 'financials', icon: Receipt, label: 'nav.finance',
|
|
children: [
|
|
{ to: '/financials/expenses', icon: Receipt, label: 'nav.expenses', module: 'expenses', perm: DASH },
|
|
{ to: '/financials/tabs', icon: CreditCard, label: 'nav.tabs', module: 'tabs', perm: DASH },
|
|
],
|
|
},
|
|
],
|
|
},
|
|
{
|
|
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/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: 'catalog.menu.manage' },
|
|
{ to: '/notes', icon: StickyNote, label: 'nav.notes', module: 'notes', perm: DASH },
|
|
],
|
|
},
|
|
{
|
|
group: 'inventory', icon: Boxes, label: 'nav.inventory',
|
|
children: [
|
|
{ to: '/inventory/throwaways', icon: Trash2, label: 'nav.waste', module: 'inventory', perm: DASH },
|
|
{ to: '/inventory/stock', icon: Boxes, label: 'nav.stock', module: 'inventory', perm: DASH, 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
|
|
return !page.perm || permissions.has(page.perm)
|
|
}
|