"use client"; /* Signed in — onboarding screen 05. A beat of confirmation before the app: which linen room you are now in, and the two figures that decide what the morning looks like. */ import { Suspense, useMemo } from "react"; import Link from "next/link"; import { useSearchParams } from "next/navigation"; import { useDerived, useSnap } from "@/lib/client"; import { daysBetween, locTree, onhand, reorderAt, touched } from "@/lib/compute"; function SignedInInner() { const { s } = useSnap(); const { L, variants } = useDerived(); const isNew = useSearchParams().get("new") === "1"; const d = useMemo(() => { const counted = variants.filter((v) => touched(s, L, v.key)); const low = counted.filter((v) => onhand(s, L, v.key) <= reorderAt(s, v.key)).length; const lastCount = s.stocktakes.find((t) => t.mode !== "preloved"); return { lines: counted.length, low, since: lastCount ? daysBetween(lastCount.date, s.today) : null, locations: locTree(s).length, }; }, [s, L, variants]); const row: React.CSSProperties = { display: "flex", alignItems: "baseline", gap: 12, padding: "14px 0", borderBottom: "1px solid var(--color-divider)" }; const lab: React.CSSProperties = { flex: 1, fontSize: 14.5, color: "var(--color-neutral-800)" }; // Figures get the big numeral; "Never counted" is a sentence and was being set at the same size, // where it ran nearly the width of the row and read as the loudest thing on the screen. const val = (hot?: boolean, text?: boolean): React.CSSProperties => ({ fontFamily: "var(--font-heading)", fontWeight: 800, fontSize: text ? 14.5 : 19, fontVariantNumeric: "tabular-nums", color: hot ? "var(--color-accent-700)" : "var(--color-text)" }); const overdue = d.since !== null && d.since > 30; return ( <>
{isNew ? "Facility created" : "Signed in"}

{s.settings.facility}

{isNew ? (

Your linen room is set up and you are its first administrator. There is nothing in it yet — the catalogue, staff register and cost centres come in from CSV on the desktop at threadcount.tech, and take about an afternoon.

) : ( <>
{s.settings.location || "Linen Room"}
Lines on the shelf{d.lines}
Below par 0)}>{d.low}
Since the last count {d.since === null ? "Never counted" : `${d.since} day${d.since === 1 ? "" : "s"}`}
{d.locations === 0 && (

No shelves set up yet, so there is nothing to count against. Add them in Settings on the desktop, then place each size on one from Inventory.

)} )}
Start the day ); } export default function MSignedIn() { return ; }