Files
lux_fiscal/frontend/src/features/menu/ModuleRoute.tsx
T
lauadminandClaude Opus 5.5 8fffdc3ce6 Add main menu page with role-based modules (#7)
- `/` is now the main menu; orders/receipts page moved to `/receipts`
- Module registry (features/menu/modules.ts) drives both the menu tiles
  and route guards (ModuleRoute); admin sees every module
- Menu: module search with Ctrl+K, profile with logout, responsive grid,
  palette matching the login page
- «← Головне меню» link on receipts and cash registers pages;
  «Каси» moved from the receipts toolbar into the menu

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-25 17:11:57 +03:00

12 lines
519 B
TypeScript

import { Navigate, Outlet } from 'react-router-dom'
import { useAuth } from '@/features/auth/useAuth'
import { canAccess, getModule } from '@/features/menu/modules'
/** Пускает в модуль только роли из реестра; остальных возвращает в главное меню. */
export function ModuleRoute({ moduleId }: { moduleId: string }) {
const { user } = useAuth()
if (!canAccess(user, getModule(moduleId).roles)) return <Navigate to="/" replace />
return <Outlet />
}