"use client"; /* The green line at the top of Today after something finished elsewhere: a shelf count committed * (?flash=counted&loc=&gaps=, or the older ?counted=1) or a facility just created * (?flash=created). Dismissing it drops the query so a reload does not bring it back. */ import { useRouter, useSearchParams } from "next/navigation"; import { useState } from "react"; import { OK } from "@/components/m"; export function bannerText(q: URLSearchParams): string { const flash = q.get("flash"); if (flash === "created") return "Facility created"; if (flash === "counted" || q.get("counted")) { const loc = (q.get("loc") || "").slice(0, 80).trim(); const gaps = Math.max(0, parseInt(q.get("gaps") || "0", 10) || 0); return `${loc || "Shelf"} counted${gaps > 0 ? ` · ${gaps} ${gaps === 1 ? "gap" : "gaps"}` : ""}`; } return ""; } export default function TodayBanner() { const sp = useSearchParams(); const router = useRouter(); const [gone, setGone] = useState(false); const text = bannerText(new URLSearchParams(sp.toString())); if (!text || gone) return null; return (
{text}
); }