"use client"; import Link from "next/link"; import { useMemo } from "react"; import { useDerived, useSnap } from "@/lib/client"; import { Panel } from "@/components/portal"; import { atReorderVariants } from "@/lib/portalcounts"; import { runsOutRows } from "@/lib/today"; const MAX_ROWS = 6; const ACCENT = "var(--color-accent-700)"; export default function RunsOutPanel() { const { s, isAdmin } = useSnap(); const { L, byId } = useDerived(); const rows = useMemo(() => runsOutRows(s, L, byId), [s, L, byId]); const atReorder = useMemo(() => atReorderVariants(s, L).length, [s, L]); if (rows.length === 0) return null; return ( {atReorder} line{atReorder === 1 ? "" : "s"} at reorder {isAdmin ? Open the order list : Open stock} } >
{rows.slice(0, MAX_ROWS).map((r) => ( ))}
GarmentOn handCover
{r.name}
{r.size} · {r.out ? `reorder at ${r.ro}` : `lead ${r.leadDays} days`}
{r.oh} {r.out ? "out" : r.coverDays === null ? "—" : `${r.coverDays} day${r.coverDays === 1 ? "" : "s"}`}
); }