The shop at parity with the old build. Supervisor screen (department chips, CO headline, numbers, Change orders
on hold, station grid with clocks and CO tags, boards) and Stall screen (station picker, hero, My packets,
Submitted). Shop steps on the packet page: assign with station, welder picker and stamp; pull back; Start, Pause,
Resume; Submit with a PIN signature and the missing steps as links; review with Send to Q.C., Return to station
and Skip Q.C. route; a lead's read-only review. Weld map (pdf.js viewer with pan, pinch, zoom, full screen; marks
with leader lines; weld sheet; weld record with field CAS; carried marks). Heat map (heat table placed, dragged,
sized, removed; legacy amber tags; borrowed heat map read-only). Checklist tab with templates from settings.
VOID stamps on voided pages. Change orders: CO-n labels, supervisor verify with signature, approval copies the
heat table to the new sheet and the BOM merge keeps the shop's values. Server clock of record with VISUAL ticket
hours beside it. Presence per packet over SSE. Migration 0006 (bfx, bfy, carried_from, checklist_templates).
New endpoints /api/shop/board, /api/shop/stations, /api/shop/stall, /api/departments/{code}/people.
Tests: policy oracle for every shop action, role and status; clock arithmetic; concurrent inserts; CO apply;
frontend geometry, heat table, clock, checklist, weld sheet, screens; seven Playwright scenarios. Docs updated.
Co-Authored-By: Claude Fable 5.1 <[email protected]>
34 lines
1.6 KiB
TypeScript
34 lines
1.6 KiB
TypeScript
import type { ReactNode } from "react";
|
|
import { Navigate, useParams } from "react-router";
|
|
import { homePath, isScreen, orderScreens, type Screen } from "../auth/roles";
|
|
import { useAuth } from "../auth/useAuth";
|
|
import { AdminPage } from "./admin/AdminPage";
|
|
import { ClericalHome } from "./clerical/ClericalHome";
|
|
import { PlaceholderScreen } from "./PlaceholderScreen";
|
|
import { StallHome } from "./stall/StallHome";
|
|
import { SupervisorHome } from "./supervisor/SupervisorHome";
|
|
import { WarehouseHome } from "./warehouse/WarehouseHome";
|
|
|
|
/** A page under a screen, like /clerical/projects/7. Users without the screen go to their first screen. */
|
|
export function RequireScreen({ screen, children }: { screen: Screen; children: ReactNode }) {
|
|
const { me } = useAuth();
|
|
if (!me) return null;
|
|
if (!orderScreens(me.screens).includes(screen)) return <Navigate to={homePath(me.screens)} replace />;
|
|
return <>{children}</>;
|
|
}
|
|
|
|
/** /:screen. An unknown screen, or one the user does not have, goes to the user's first screen. */
|
|
export function ScreenRoute() {
|
|
const { screen } = useParams();
|
|
const { me } = useAuth();
|
|
if (!me) return null;
|
|
const allowed = orderScreens(me.screens);
|
|
if (!isScreen(screen) || !allowed.includes(screen)) return <Navigate to={homePath(me.screens)} replace />;
|
|
if (screen === "admin") return <AdminPage />;
|
|
if (screen === "clerical") return <ClericalHome />;
|
|
if (screen === "warehouse") return <WarehouseHome />;
|
|
if (screen === "supervisor") return <SupervisorHome />;
|
|
if (screen === "stall") return <StallHome />;
|
|
return <PlaceholderScreen key={screen} screen={screen} />;
|
|
}
|