"use client"; import Link from "next/link"; import { useSnap } from "@/lib/client"; import { Meter, Tag } from "@/components/portal"; import { printCreditSlip } from "@/components/dialogs"; import { allowanceRouteOf, approvalRemaining, ccOf, initialRemaining, initialSets, openApproval, setsForFte, type CapCheck, type StaffRec } from "@/lib/compute"; import { dayMonth } from "./lib"; import styles from "./counter.module.css"; const Mono = ({ children }: { children: React.ReactNode }) => {children}; /* Who is at the counter: details, their route and signed form, and the six-set meters. */ export default function PersonPanel({ st, held, onChange }: { st: StaffRec; held: CapCheck; onChange: () => void }) { const { s } = useSnap(); const cc = ccOf(s, st); const cut = st.uniformStyle === "Women's" ? "Women’s cut" : st.uniformStyle === "Men's" ? "Men’s cut" : ""; const details: React.ReactNode[] = []; if (st.group) details.push(st.group); if (st.dept) details.push(st.dept); if (cc) details.push({cc}); if (cut) details.push(cut); if (st.top || st.pants) details.push(usual {st.top || "–"} / {st.pants || "–"}); const route = allowanceRouteOf(s, st); const ap = openApproval(s, st.id); const apRem = approvalRemaining(s, st.id); const signed = ap ? ` · manager signed ${ap.sets} on ${dayMonth(ap.date)}, ${apRem} left` : " · nothing signed"; let sentence: React.ReactNode; if (route === "fte") { const n = setsForFte(st.fte); sentence = <>FTE table{st.fte ? <> · {st.fte}{n !== null ? ` proposes ${n} sets` : ""} : " · no FTE recorded"}{signed}; } else if (route === "kit") { const sets = initialSets(s, st); const left = initialRemaining(s, st) ?? 0; sentence = <>Starting kit{sets !== null ? ` · ${sets} sets` : ""}{left > 0 ? ` · ${left} garments still to issue` : ""}{ap ? signed : ""}; } else { sentence = <>Manager approval{signed}; } return (
{st.first} {st.last} {st.num} {st.selfEmail && Staff app} {st.inactive && Inactive}
{details.length > 0 && (
{details.map((d, i) => {i > 0 ? " · " : ""}{d})}
)}
{sentence} {ap && }
{held.other > 0 && +{held.other} outside a set}
Open record
); }