import { useState } from "react"; import { REGISTRATION_OPENS_AT } from "@/lib/opening"; import { useRegistrationOpen } from "@/lib/useRegistrationOpen"; import { client } from "@/utils/orpc"; function pad(n: number): string { return String(n).padStart(2, "0"); } interface UnitBoxProps { value: string; label: string; } function UnitBox({ value, label }: UnitBoxProps) { return (
{value}
{label}
); } // Reminder opt-in form — sits at the very bottom of the banner function ReminderForm() { const [email, setEmail] = useState(""); const [status, setStatus] = useState< "idle" | "loading" | "subscribed" | "already_subscribed" | "error" >("idle"); const [errorMessage, setErrorMessage] = useState(""); async function handleSubmit(e: React.FormEvent) { e.preventDefault(); if (!email || status === "loading") return; setStatus("loading"); try { const result = await client.subscribeReminder({ email }); if (!result.ok && result.reason === "already_open") { setStatus("idle"); return; } setStatus("subscribed"); } catch (err) { setErrorMessage(err instanceof Error ? err.message : "Er ging iets mis."); setStatus("error"); } } const reminderTime = REGISTRATION_OPENS_AT.toLocaleTimeString("nl-BE", { hour: "2-digit", minute: "2-digit", }); return (
{/* Hairline divider */}
{status === "subscribed" || status === "already_subscribed" ? (
{/* Checkmark glyph */}

Herinnering ingepland voor {reminderTime}

) : (

Herinnering ontvangen?

{/* Fused pill input + button */}
setEmail(e.target.value)} disabled={status === "loading"} className="min-w-0 flex-1 bg-transparent px-4 py-2.5 text-sm text-white outline-none disabled:opacity-50" style={{ fontFamily: "'Intro', sans-serif", fontSize: "0.8rem", letterSpacing: "0.02em", }} /> {/* Vertical separator */}
{status === "error" && (

{errorMessage}

)}
)}
); } /** * Shown in place of the registration form while registration is not yet open. */ export function CountdownBanner() { const { isOpen, days, hours, minutes, seconds } = useRegistrationOpen(); // Once open the parent component will unmount this — but render nothing just in case if (isOpen) return null; const openDate = REGISTRATION_OPENS_AT.toLocaleDateString("nl-BE", { weekday: "long", day: "numeric", month: "long", year: "numeric", }); const openTime = REGISTRATION_OPENS_AT.toLocaleTimeString("nl-BE", { hour: "2-digit", minute: "2-digit", }); return (

Inschrijvingen openen op

{openDate} om {openTime}

{/* Countdown — single row forced via grid, scales down on small screens */}
: : :

Kom snel terug! Zodra de inschrijvingen openen kun je je hier registreren als toeschouwer of als artiest.

{/* Email reminder opt-in — always last */}
); }