import { notFound } from "next/navigation"; import { requireOperator } from "@/lib/ops/session"; import { facility } from "@/lib/ops/projections"; import { revealedContacts, REVEAL_MINUTES } from "@/lib/ops/reveal"; import Reveal from "./Reveal"; import Plan from "./Plan"; import Danger from "./Danger"; /* One facility: configuration, counts, activity. Contacts are masked — the ops_ro role cannot read * them, and the projection never asks. They appear only while this operator holds an unexpired * reveal grant, read through the separate reveal role (lib/ops/reveal.ts). * Nothing about a wearer is reachable from here at any level. */ export const dynamic = "force-dynamic"; const dl: React.CSSProperties = { display: "grid", gridTemplateColumns: "auto 1fr", gap: "8px 16px", fontSize: 13, margin: 0 }; const dt: React.CSSProperties = { color: "var(--color-neutral-600)" }; const dd: React.CSSProperties = { margin: 0, fontWeight: 600, fontVariantNumeric: "tabular-nums" }; const masked: React.CSSProperties = { fontFamily: "ui-monospace, Menlo, monospace", letterSpacing: "0.02em", color: "var(--color-neutral-700)" }; export default async function OpsFacility({ params }: { params: Promise<{ id: string }> }) { const op = await requireOperator(); const { id } = await params; const f = await facility(id); if (!f) notFound(); const rv = f.isDemo ? null : await revealedContacts(op.id, id); const fmt = (d: Date) => d.toLocaleDateString("en-AU", { day: "numeric", month: "short", year: "numeric" }); const hm = (d: Date) => d.toLocaleTimeString("en-AU", { timeZone: "Australia/Brisbane", hour: "2-digit", minute: "2-digit" }); const n = (x: number) => x.toLocaleString(); const c = f.counts; return ( <>
Facility{f.isDemo ? " · demo" : ""}

{f.name}

Created {fmt(f.createdAt)} · {f.timezone} · rev {n(f.rev)} · {f.backupAgeDays === null ? "never exported" : `last export ${f.backupAgeDays} days ago`}
All facilities
Contacts{rv ? `revealed until ${hm(rv.expiresAt)}` : "masked"}
{rv ? ( <>
Coordinator
{rv.coordinator || "—"}
Email
{rv.coordinatorEmail || "—"}
Phone
{rv.coordinatorPhone || "—"}
{`Revealed ${hm(rv.at)} for ${REVEAL_MINUTES} minutes, in the trail and emailed. Reason: ${rv.reason}`}
) : ( <>
Coordinator
•••••
Email
•••@•••
Phone
•• •••• ••••
The console’s database role cannot read these. Revealing them is a separate act: it asks for a reason, lasts thirty minutes, is written to the operator trail and emails you a copy. Nothing about a wearer can be revealed at any level.
{!f.isDemo && } )}
Configuration
Ceiling
{f.config.capSets} sets held at any time
Starting kit
{f.config.initialSets} sets
Staff groups
{f.config.groups} named · {f.config.fteGroups} on the FTE table · {f.config.kitGroups} on the starting kit
Reorder default
{f.config.defaultReorder}
GL account
{f.config.glAccountSet ? "set" : "not set"}
Journal line
{f.config.journalDesc}
Barcode lookup
{f.config.barcodeLookup ? "on" : "off"}
Slip organisation
{f.config.slipOrgSet ? "set" : "not set"}
Single sign-on
{`${f.config.sso}${f.config.ssoStaff ? " · staff too" : ""}`}
Countsno records readable
{/* Whole phrases, not `{value} word`: React separates adjacent text and expressions with comment nodes, so "1 admin" would render as "1 admin" and never match a grep. */}
Coordinators
{`${n(c.users)} · ${c.admins} admin · ${c.usersWith2fa} with 2FA${c.inactiveUsers ? ` · ${c.inactiveUsers} inactive` : ""}`}
Staff register
{`${n(c.staff)} · ${n(c.activeStaff)} active`}
Staff accounts
{`${n(c.staffAccounts)} · ${n(c.accountsSeen7d)} seen this week`}
Catalogue
{n(c.items)}
Issues
{n(c.issues)}
Orders
{n(c.orders)}
Requests
{n(c.requests)}
Events, 24h
{n(c.events24h)}
{!f.isDemo && ( <>
Planthe billing desk · every act in the trail
Danger zonecannot be undone
)} ); }