import Link from "next/link";
import { DEMO_FACILITY, DEMO_RESET_MINUTES } from "@/lib/demo";
import { CtaBand, SiteNav } from "@/components/site";
import { switches } from "@/lib/switches";
/* Rendered per request, unlike the rest of the site: the demo switch lives in the database now
* and can be flipped from the console, and a page cached for a day would keep offering "Enter as
* Admin" long after the entry endpoint had started answering 404. */
export const dynamic = "force-dynamic";
export const metadata = {
title: "Try the working demo",
description: "Open a stocked, fictional hospital linen room and use ThreadCount as an Admin or an Issuer. The same screens run an aged-care home’s store or a clinic’s cupboard. No sign-up.",
alternates: { canonical: "/demo" },
};
const CARDS = [
{ as: "admin", role: "Admin", who: "Alex Demo · Uniform Coordinator", body: "The coordinator’s view. Settings, the catalogue and prices, the staff register, suppliers, reorder levels, every report and the month-end pack." },
{ as: "issuer", role: "Issuer", who: "Sam Demo · Linen Room Assistant", body: "The counter view. Issue stock, record a manager’s approval, run a stocktake, receive a delivery and work through the pickup call list." },
];
export default async function DemoPage({ searchParams }: { searchParams: Promise<{ signedin?: string }> }) {
const sp = await searchParams;
/* The same switch the entry endpoint honours (app/api/auth/demo/route.ts), read here too.
*
* With the demo out of service that endpoint answers a bare JSON 404, so a page that still
* offers "Enter as Admin" walks somebody weighing the product onto a white screen of raw JSON
* with no nav and no way back. Sign-ups are handled the same way — /auth hides the create-account
* form when sign-ups are closed rather than letting the button fail — and the demo has to go
* quiet at the same moment its endpoint does. */
const { demoOpen } = await switches();
return (
<>
{demoOpen ? "It is a made-up hospital, but everything in it is real: a stocked shelf, staff on the register, orders still open with the supplier, people waiting on a pickup, and three months of issues behind it. It could as easily be an aged-care home or a day surgery — the shelf, the counter and the screens are the same. Pick a role and have a look around. Nothing to sign up for." : `${DEMO_FACILITY} is a made-up hospital anyone can walk into, and it has been taken out of service for a while. Nothing is wrong with ThreadCount itself, and a facility of your own is unaffected.`}
{sp.signedin === "1" &&