"use client"; import { useState } from "react"; /* The reveal control: a button, a reason, a confirmation. On success the page reloads and the * server renders the contacts through the reveal role — the values never travel in this response. */ export default function Reveal({ facilityId, minutes }: { facilityId: string; minutes: number }) { const [open, setOpen] = useState(false); const [reason, setReason] = useState(""); const [err, setErr] = useState(""); const [busy, setBusy] = useState(false); async function submit(e: React.FormEvent) { e.preventDefault(); setBusy(true); setErr(""); try { const r = await fetch("/api/ops/reveal", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ facilityId, reason }) }); const j = await r.json().catch(() => ({})); if (!r.ok) { setErr(j.error || "That didn’t work."); return; } window.location.reload(); } catch { setErr("No connection — check the network and try again."); } finally { setBusy(false); } } if (!open) { return ; } return (