"use client";
/* 1B — My kit.
*
* The linen room's record of what this person holds, shown to the person it is about, and a way
* to say it is wrong. "This isn't right" is deliberately blunt and deliberately last: the record
* is usually correct, and a dispute button placed first would invite one before anybody had read
* the list.
*
* The bar is a screen-level one, drawn on ALL THREE segments rather than only on Holding. A wrong
* recorded *size* is one of the commonest things anybody queries, and that is read on My sizes —
* where the screen literally says "tell them below", a promise only kept while the bar is there.
*/
import { useState } from "react";
import { useRouter } from "next/navigation";
import { MBody, MEmpty, MError, MRow, MRule, MTop } from "@/components/m";
import { INK, N600, SecondaryBar, Segments, SlipCard } from "@/components/staffui";
import StaffNav from "@/components/staffnav";
import { useDraft, useStaff } from "@/lib/staffclient";
import { fmtDate } from "@/lib/compute";
type Held = { itemId: string; item: string; size: string; si: number; qty: number; last: string };
/* One row per garment and size with its quantity — the slip as it was signed, not one repeated row
* per garment. The grouping is done in kitData(); the screen only draws it. */
type Slip = { id: string; date: string; lines: { item: string; size: string; qty: number }[]; signed: boolean };
type Data = { held: Held[]; total: number; handedBackThisYear: number; fyFrom: string; sizes: { top: string; pants: string }; slips?: Slip[] };
export default function KitScreen({ data }: { data: Data }) {
const { mutate, busy } = useStaff();
const router = useRouter();
const [tab, setTab] = useState<"holding" | "sizes" | "slips">("holding");
const [disputing, setDisputing] = useState(false);
// Kept across a dropped send and a screen change: ward wifi drops mid-sentence, and the one thing
// worse than a complaint that did not send is a complaint that did not send and is gone.
const draft = useDraft("dispute");
const [err, setErr] = useState("");
const [sent, setSent] = useState(false);
const slips = data.slips || [];
return (
<>
{tab === "holding" && (
{data.held.length === 0 ? (
) : (
data.held.map((h) => (
))
)}
{/* A row, not the paragraph this used to be: it is one figure about their own record,
and it reads as one line beside the garments it belongs with. */}
)}
{tab === "sizes" && (
The linen room records these. Tell them below if they are wrong.
{/* Swapping a size is a request like any other, so it goes to the request screen rather
than living as its own flow. This is the door it is reached by. */}
)}
{tab === "slips" && (
slips.length === 0 ? (
) : (
slips.map((sl) => (
{/* A slip with no signature stored is not a broken screen, and saying so is kinder
than an empty space where a signature obviously belongs. */}
{!sl.signed && (
Handed over at the counter · no signature on file
)}
))
)
)}
{sent && (
Sent. The linen room will look at your record and come back to you.