mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-09-30 12:43:13 +00:00
- SH-336: add the dispatcher-scope picker (All / My WOs / individual) for Scheduler/Admin via a new viewAllDispatchersOnDashboard role gate, a static 'My WOs' label for Dispatcher, and hide the dispatcher tables (and skip their queries) when the viewer cannot see all dispatchers. Scope drives dispatcherId on stats, workload, performance, and regions (SH-347 contract). - SH-352: add the Status Distribution module with its empty state and status drill-down. - SH-347: show Assigned/Completed counts and colour the completion rate (green >=90, amber 70-89, red <70) on Dispatcher Performance. - SH-348: drill a region bar into the board region filter; hold the unconfirmed 'Unmapped/Other' bucket off the chart. - SH-349: label Vendor Insights as all-time, company-wide. - Make the drilldown-filters effect fire only on URL change; add a deterministic clock to the status-drilldown test; add the dashboard visual regression spec and baselines.
31 lines
1.1 KiB
TypeScript
31 lines
1.1 KiB
TypeScript
export function getPrimaryUserRole(
|
|
userRoles: string | null | undefined,
|
|
fallback = "User",
|
|
): string {
|
|
return userRoles?.split(",")[0]?.trim() || fallback;
|
|
}
|
|
|
|
export function isAdminUser(userRoles: string | null | undefined): boolean {
|
|
if (!userRoles) {
|
|
return false;
|
|
}
|
|
return userRoles
|
|
.split(",")
|
|
.map((role) => role.trim().toLowerCase())
|
|
.includes("admin");
|
|
}
|
|
|
|
/**
|
|
* SH-336's `viewAllDispatchersOnDashboard` permission. The codebase has no
|
|
* permission model, so it is derived from role: Admin and Scheduler may pick any
|
|
* dispatcher (or the whole company) on the Dashboard; a Dispatcher may not and
|
|
* is locked to their own work orders. Unknown roles default to the restrictive
|
|
* (Dispatcher) behaviour so no one accidentally gains a company-wide view.
|
|
*/
|
|
export function canViewAllDispatchersOnDashboard(userRoles: string | null | undefined): boolean {
|
|
if (!userRoles) {
|
|
return false;
|
|
}
|
|
const roles = userRoles.split(",").map((role) => role.trim().toLowerCase());
|
|
return roles.includes("admin") || roles.includes("scheduler");
|
|
}
|