"use client"; /* Issuing rules: the ceiling, the starting kit and the count-reason threshold, then the staff groups * on their three routes. capCheck() and allowance() in lib/compute.ts still decide; this screen * only edits the figures and lists they read. */ import { useSnap } from "@/lib/client"; import { allowance, setsOnStart } from "@/lib/compute"; import { InlineNumber, Msg, SectionHead, useSaver, useSettingsFields } from "./common"; import RouteBoard from "./RouteBoard"; export default function IssuingRules() { const { s, isAdmin } = useSnap(); const saver = useSaver(); const { val, setField } = useSettingsFields(saver); /* Read off the boxes, so the route lines describe what leaving now would put in force. An empty box saves nothing, so the stored figure stands for it. */ const typed = (k: "initialSets" | "capSets") => { const t = val(k).trim(); return t === "" ? s.settings[k] : Number(t); }; const shape = allowance({ held: 0, kit: true, startingSets: typed("initialSets"), capSets: typed("capSets") }); const ceiling = shape.max, kitStart = shape.start ?? 0; const kitOverCeiling = setsOnStart(typed("initialSets")) > ceiling; return ( <>