// Who sees the screens outside the role switcher, and the PM screen. The server decides on every request; this only // hides what cannot work. import { orderScreens, parseRole, type Screen } from "../auth/roles"; /** The Project Management screen: PS-ProjectMgmt and Admin only (change C10). */ export function canPm(roles: readonly string[]): boolean { return roles.some((r) => r === "pm" || r === "admin"); } /** The stamp check: Admin, Q.C. and every Clerical level (change C9). */ export function canStampCheck(roles: readonly string[]): boolean { return roles.some((r) => r === "admin" || r === "qc" || r.startsWith("qc_") || r === "clerical" || r.startsWith("clerical_")); } /** The department checklists: a department supervisor (a lead is not enough) or Admin (change C8). */ export function canChecklists(roles: readonly string[]): boolean { return roles.some((r) => { if (r === "admin") return true; const p = parseRole(r); return p.shop && p.level === "supervisor"; }); } export const PM_WHO = "It is for Project Management and Admin."; /** The screens the shell offers: the session's list, with PM only for PS-ProjectMgmt and Admin (change C10). */ export function shellScreens(screens: readonly string[], roles: readonly string[]): Screen[] { return orderScreens(screens).filter((s) => s !== "pm" || canPm(roles)); }