mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-30 04:08:11 +00:00
feat(overview): resolve dashboard layout from permissions, not role keys
role-dashboards.config.ts's ROLE_LAYOUTS was a hand-typed table of ~40 raw role/position keys (including edr_freight_app/xxx ad-hoc sub-positions), matched against the user's held keys client-side. Replaced with resolveOverviewLayout(), which just picks the highest-priority key out of whatever GET /overview/layouts returns — the same 'server filters by permission, frontend renders what comes back' shape Reports already uses, so the frontend no longer needs to know any individual permission key. Hard cutover: no fallback to the old key table. Positions not covered by the previous commit's grants (the ad-hoc department sub-positions) will render the executive layout until granted a layout permission.
This commit is contained in:
@@ -11,6 +11,15 @@ export function useOverview(range: OverviewRange = "30d") {
|
||||
});
|
||||
}
|
||||
|
||||
/** Layouts the caller may render — server-filtered by permission, same shape as useReports' catalog. */
|
||||
export function useOverviewLayouts() {
|
||||
return useQuery({
|
||||
queryKey: QUERY_KEYS.OVERVIEW.layouts(),
|
||||
queryFn: () => overviewService.getLayouts(),
|
||||
staleTime: 5 * 60 * 1000,
|
||||
});
|
||||
}
|
||||
|
||||
export function useOverviewBookingsTab(range: OverviewRange, enabled: boolean) {
|
||||
return useQuery({
|
||||
queryKey: QUERY_KEYS.OVERVIEW.bookingsTab(range),
|
||||
|
||||
Reference in New Issue
Block a user