import { requireOperator } from "@/lib/ops/session"; import { overview } from "@/lib/ops/projections"; import { version } from "@/lib/ops/version"; /* Overview: is everything up, how many facilities, who needs attention. Counts and dates only — * nothing on this screen names a person or reads a record. */ export const dynamic = "force-dynamic"; const tile: React.CSSProperties = { background: "var(--color-bg)", padding: 16 }; const figure: React.CSSProperties = { fontSize: 30, fontWeight: 800, lineHeight: 1, fontVariantNumeric: "tabular-nums" }; const label: React.CSSProperties = { fontSize: 11, fontWeight: 700, letterSpacing: "0.09em", textTransform: "uppercase", color: "var(--color-neutral-600)", marginTop: 6 }; const note: React.CSSProperties = { fontSize: 12, color: "var(--color-neutral-700)", marginTop: 2 }; export default async function OpsOverview() { await requireOperator(); const o = await overview(); const v = version(); const stale = !!(v.deployed && v.running && v.deployed.sha !== v.running); const fmtAt = (d: Date) => d.toLocaleString("en-AU", { timeZone: "Australia/Brisbane", dateStyle: "medium", timeStyle: "short" }); const attention = [ ...o.overdueBackups.map((f) => ({ tone: "warn", who: f.name, what: f.backupAgeDays === null ? "has never exported a backup" : `has not exported a backup in ${f.backupAgeDays} days`, meta: `${f.issues.toLocaleString()} issues on record`, href: `/ops/facilities/${f.id}` })), ...o.neverIssued.map((f) => ({ tone: "dormant", who: f.name, what: "has never issued", meta: `signed up ${f.createdAt.toLocaleDateString("en-AU", { day: "numeric", month: "short" })} · ${f.staff} staff · ${f.items} items`, href: `/ops/facilities/${f.id}` })), ...o.unconfiguredList.map((f) => ({ tone: "dormant", who: f.name, what: "has no staff groups named", meta: "everyone is on manager approval until a group goes on a route", href: `/ops/facilities/${f.id}` })), ]; const drift = o.migrations.applied !== o.migrations.inRepo; return ( <>
Overview

Everything, at a glance

{o.facilities} facilities · {o.live} live · migrations {o.migrations.applied}/{o.migrations.inRepo}{drift ? " — DRIFT" : ""}
{o.facilities}
Facilities
{o.demo} demo, excluded below
{o.live}
Live
have issued at least once
{o.dormant + o.unconfigured}
Not yet live
{o.unconfigured} never set up
{o.signupsThisMonth}
Signups this month
{o.reachedFirstIssue} reached first issue
Needs attention{attention.length} {attention.length === 1 ? "item" : "items"}
{attention.length === 0 ? (
Nothing. Every live facility has a recent backup and every signup has issued.
) : ( )}
Platform
Migrations
{o.migrations.applied} applied / {o.migrations.inRepo} in repo{drift ? " — drift" : ""}
Enquiries
{o.enquiriesUnhandled} unhandled
Demo facility
{o.demoRebuiltAgoMin === null ? "none" : `rebuilt ${o.demoRebuiltAgoMin} min ago`}
{/* Whole phrases (see the facility page): React puts comment nodes between adjacent expressions. */}
Deployed
{v.deployed ? `${v.deployed.sha} · ${fmtAt(v.deployed.at)}${v.deployed.from ? ` · was ${v.deployed.from}` : ""}` : "not recorded — the deploy script predates the release file"}
Running
{`${v.running || "release unknown"}${stale ? " — STALE: built but never restarted" : ""} · up ${v.uptimeMin} min · node ${v.node}`}
); }