"use client"; import { useMemo, useState } from "react"; import { useDerived, useSnap } from "@/lib/client"; import { QueueGroup, QueueRow } from "@/components/portal"; import { ErrorLine } from "@/components/ui"; import { openSlip } from "@/components/dialogs"; import { collectRows, collectionSlip } from "@/lib/today"; import { Lines } from "./Lines"; export default function CollectGroup() { const { s, mutate } = useSnap(); const { byId, staffById } = useDerived(); const [err, setErr] = useState(""); const rows = useMemo(() => collectRows(s, byId, staffById), [s, byId, staffById]); // Two people can work this list at once; a refusal has to be said, or the second click reads as // the first one not having taken. async function act(op: string, payload: unknown) { setErr(""); const r = await mutate(op, payload); if (!r.ok) setErr(r.error); } return ( {err &&
} {rows.map((r) => ( {r.phone} : r.phone) : undefined} meta={<> · {r.p.orderCode}{r.p.contacted ? " · contacted" : ""}} actions={<> {!r.p.contacted && } } /> ))}
); }