"use client"; /* The call list — longest wait first, because that’s the one somebody is annoyed about. */ import { useMemo, useState } from "react"; import { useSnap } from "@/lib/client"; import { daysBetween, itemMap, label, staffMap, staffName } from "@/lib/compute"; import { INK, MBody, MEmpty, MError, MNav, MRow, MRule, MSection, MTop } from "@/components/m"; export default function MPickups() { const { s, mutate, busy } = useSnap(); const [err, setErr] = useState(""); const rows = useMemo(() => { const staffById = staffMap(s); const byId = itemMap(s); return s.pickups .filter((p) => !p.pickedUp) .map((p) => ({ ...p, who: staffById[p.staffId], phone: staffById[p.staffId]?.phone || "", days: daysBetween(p.received, s.today), what: p.lines.map((l) => `${label(byId[l.itemId])} · ${l.size}${l.qty > 1 ? ` ×${l.qty}` : ""}`).join(", "), })) .sort((a, b) => b.days - a.days); }, [s]); const act = async (op: string, id: string) => { const r = await mutate(op, { id }); if (!r.ok) setErr(r.error); }; return ( <> setErr("")} /> {rows.length === 0 ? ( ) : ( <> {rows.map((p) => (
10 ? "#fff" : "var(--color-bg)", borderBottom: "1px solid var(--color-divider)", display: "flex", gap: 12 }}>
))} )}
); }