"use client"; /* The approvals queue. * * Oldest first, deliberately. The queue's job is to surface the person who has been waiting * longest, and a newest-first list quietly buries them — which is the failure mode this whole * flow exists to fix. * * A request the manager is the wearer of can reach this queue now. Whoever a request names is who * decides it, and the server has been allowed to let that be the wearer themselves in the one case * the owner named. The server owns that decision and this screen never re-tests it. What the screen * owns is the honesty: an approval somebody gives themselves is set apart from the ones they are * giving on other people's behalf, says whose uniform it is, and says what the record will call it * afterwards — so it is never something that happens to a manager mid-scroll and has to be * explained to an auditor months later. * * This queue also reaches people who manage nobody — the linen room re-addresses a request that * arrived without an approver, or somebody's last report is moved away while their own request is * still waiting. The server takes their self-approval too (lib/staffops.ts decideRequest dropped * the reports test), so the copy below no longer tells them the bar will refuse: for a while it * did, and the bar approved. The only difference `me.isManager` makes here is the wording. */ import { MBody, MRule, MTop } from "@/components/m"; import { EdgeRow, GROUND, INK, Kicker, N600, N700, SecondaryBar } from "@/components/staffui"; import ManagerNav from "./ManagerNav"; import { useStaff } from "@/lib/staffclient"; import { daysBetween, facilityDate, facilityToday } from "@/lib/compute"; import type { QueueRow } from "@/lib/managerdata"; /* Calendar days on the ward, not elapsed 24-hour blocks. * * Dividing the milliseconds understated every overnight wait: a request raised at 18:00 on Monday * still read "today" at 09:00 on Tuesday and only became "since yesterday" that evening, by which * point it had spanned two working days. This queue exists to surface the person who has been * waiting longest, so the label counts the way they do, in the facility's own zone. */ function waited(iso: string, tz: string) { const raised = facilityDate(iso, tz); if (!raised) return ""; // the row's meta line filters empties out const days = daysBetween(raised, facilityToday(tz)); if (days <= 0) return "today"; if (days === 1) return "since yesterday"; return `waiting ${days} days`; } /** The heading over a group, in the ward-round style: a band the list hangs off. */ function Band({ children }: { children: React.ReactNode }) { return (
{me.isManager ? ( <> {mine.length === 1 ? "These garments are for you. You may approve them yourself, and it is recorded as a manager’s approval you gave yourself" : "These are for you. You may approve them yourself, and each one is recorded as a manager’s approval you gave yourself"} {" — the request says so on its own history, and so does the record anybody reads afterwards."} > ) : ( /* The server takes a self-approval from anybody the request is addressed to — the reports test was dropped (lib/staffops.ts decideRequest) — so this can't go on promising a refusal that never comes. */ <> {mine.length === 1 ? "These garments are for you. Nobody reports to you at the moment, but this one was addressed to you, so it is yours to decide — and it is recorded as an approval you gave yourself" : "These are for you. Nobody reports to you at the moment, but they were addressed to you, so they are yours to decide — and each one is recorded as an approval you gave yourself"} {" — the request says so on its own history, and so does the record anybody reads afterwards."} > )}
Nothing reaches the linen room until you approve it.{" "} {mine.length === 0 ? "Anything you raise yourself goes to your own manager instead." : mine.length === 1 ? "One of these is your own, and it is yours to decide — the record will show you were the one who approved it." : "Some of these are your own, and they are yours to decide — the record will show you were the one who approved them."}
> )} {!me.isManager && (Nothing reaches the linen room until you approve it.
)}