Split floats→safe_count, reports→cash_summary, add history cap
Adds three new granular capabilities: - history: gates /history page and GET /api/cashup/history - cash_summary: gates /summary page and GET /api/reports/cash-summary - safe_count: gates /safe page and safe_cash float routes Updates legacy-token fallback to include all seven non-settings caps. Route guards and nav items updated to use the split caps. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
be670f724d
commit
4754231f6f
7 changed files with 33 additions and 20 deletions
|
|
@ -12,7 +12,13 @@ import { can, type User, type CashupCap } from './types'
|
|||
|
||||
function AppRoutes({ user }: { user: User }) {
|
||||
// Landing route: first section the user can actually reach.
|
||||
const home = can(user, 'count') ? '/daily' : '/history'
|
||||
const home =
|
||||
can(user, 'count') ? '/daily' :
|
||||
can(user, 'history') ? '/history' :
|
||||
can(user, 'reports') ? '/report' :
|
||||
can(user, 'cash_summary') ? '/summary' :
|
||||
can(user, 'floats') ? '/floats' :
|
||||
can(user, 'safe_count') ? '/safe' : '/daily'
|
||||
|
||||
// Redirect to home if the user lacks the capability for a route.
|
||||
const guard = (cap: CashupCap, el: React.ReactNode) =>
|
||||
|
|
@ -22,13 +28,13 @@ function AppRoutes({ user }: { user: User }) {
|
|||
<Layout user={user}>
|
||||
<Routes>
|
||||
<Route path="/" element={<Navigate to={home} replace />} />
|
||||
<Route path="/daily" element={guard('count', <DailyCashUp user={user} />)} />
|
||||
<Route path="/history" element={<History user={user} />} />
|
||||
<Route path="/report" element={guard('reports', <MultiDayReport />)} />
|
||||
<Route path="/floats/*" element={guard('floats', <FloatManagement />)} />
|
||||
<Route path="/safe/*" element={guard('floats', <SafeCount />)} />
|
||||
<Route path="/summary" element={guard('reports', <CashSummary />)} />
|
||||
<Route path="/settings" element={guard('settings', <SettingsPage user={user} />)} />
|
||||
<Route path="/daily" element={guard('count', <DailyCashUp user={user} />)} />
|
||||
<Route path="/history" element={guard('history', <History user={user} />)} />
|
||||
<Route path="/report" element={guard('reports', <MultiDayReport />)} />
|
||||
<Route path="/floats/*" element={guard('floats', <FloatManagement />)} />
|
||||
<Route path="/safe/*" element={guard('safe_count', <SafeCount />)} />
|
||||
<Route path="/summary" element={guard('cash_summary', <CashSummary />)} />
|
||||
<Route path="/settings" element={guard('settings', <SettingsPage user={user} />)} />
|
||||
<Route path="*" element={<Navigate to={home} replace />} />
|
||||
</Routes>
|
||||
</Layout>
|
||||
|
|
|
|||
|
|
@ -12,11 +12,11 @@ interface Props {
|
|||
// `cap` gates the nav item's visibility; undefined = always shown (app access is enough).
|
||||
const navItems: { to: string; label: string; icon: typeof Banknote; cap?: CashupCap }[] = [
|
||||
{ to: '/daily', label: 'Daily Cash Up', icon: Banknote, cap: 'count' },
|
||||
{ to: '/history', label: 'History', icon: ClipboardList },
|
||||
{ to: '/history', label: 'History', icon: ClipboardList, cap: 'history' },
|
||||
{ to: '/report', label: 'Weekly Report', icon: BarChart2, cap: 'reports' },
|
||||
{ to: '/floats', label: 'Float Management', icon: Wallet, cap: 'floats' },
|
||||
{ to: '/safe', label: 'Safe Count', icon: Vault, cap: 'floats' },
|
||||
{ to: '/summary', label: 'Cash Summary', icon: FileText, cap: 'reports' },
|
||||
{ to: '/safe', label: 'Safe Count', icon: Vault, cap: 'safe_count' },
|
||||
{ to: '/summary', label: 'Cash Summary', icon: FileText, cap: 'cash_summary' },
|
||||
{ to: '/settings',label: 'Settings', icon: Settings, cap: 'settings' },
|
||||
]
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
export type CashupCap = 'count' | 'finalise' | 'reports' | 'floats' | 'settings'
|
||||
export type CashupCap = 'count' | 'finalise' | 'history' | 'reports' | 'cash_summary' | 'floats' | 'safe_count' | 'settings'
|
||||
|
||||
export interface User {
|
||||
email: string
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue