feat(manager): shell navigation from modules + permission keys; profile menu language

Platform-v2 step 2.6a:
- shell/nav.js: one nav definition (module + key per page) read by the sidebar,
  the page titles and a RouteGuard around the layout outlet (and /kds): a module
  that's off hides its items and its routes say "turned off"; a missing key
  hides the item and the route says "no access". Same keys as before (v1
  permission names mapped), plus the module check
- labels/breadcrumbs are keys in a new i18n namespace `manager` (en + el)
- removed the browser-only feature toggles (usePhase2Features, Settings ->
  Λειτουργίες, F-033), PermissionGuard and usePermissions
- profile menu: language, saved to the profile (PATCH /api/auth/me) and
  bootstrap reloaded
- e2e manager.mjs: module off/on, no-key user, language switch live + saved

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-13 21:48:08 +02:00
co-authored by Claude Opus 5.5
parent 78c8824356
commit df57fd1552
15 changed files with 454 additions and 545 deletions
+127
View File
@@ -0,0 +1,127 @@
// 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, StickyNote, Percent,
} 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' },
],
},
{
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/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: '/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.apps', module: 'caller_id', perm: DASH },
{ to: '/kds', label: 'nav.kds', module: 'kds', 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)
}