"use client"; import React, { useEffect, useState } from "react"; import { useParams } from "next/navigation"; import { Navbar } from "@/components/layout/Navbar"; import { Footer } from "@/components/layout/Footer"; import { apiFetch, ApiError } from "@/lib/api"; import { formatDate } from "@/lib/date"; import { ListChecks } from "lucide-react"; type Claim = { status: "offered" | "expired"; eventId: string; eventTitle: string; eventStart: string; optionName: string; variantName: string | null; lineName?: string; quantity: number; requested: number; expiresAt: string; name?: string; }; /** Landing page for a waitlist offer link — shows what's held, then goes to registration. */ export default function WaitlistClaimPage() { const params = useParams<{ token: string }>(); const token = params?.token; const [claim, setClaim] = useState(null); const [error, setError] = useState(null); useEffect(() => { if (!token) return; apiFetch(`/api/waitlist/claim/${encodeURIComponent(token)}`) .then(setClaim) .catch(e => setError(e instanceof ApiError ? e.message : "Couldn't load this offer.")); }, [token]); return (

Your waitlist place

{error &&
{error}
} {!claim && !error &&
Loading…
} {claim && (
{claim.eventTitle}
{formatDate(new Date(claim.eventStart))}
{claim.status === "offered" ? ( <>

{claim.name ? `Hi ${claim.name}, ` : ""}{claim.quantity} × {claim.lineName || `${claim.optionName}${claim.variantName ? ` (${claim.variantName})` : ""}`} {claim.quantity === 1 ? "is" : "are"} being held for you until {new Date(claim.expiresAt).toLocaleString()}. {claim.quantity < claim.requested && ` You asked for ${claim.requested}; this is what came free.`}

Claim and register ) : (

This offer has expired, and the place has been offered to the next person on the waitlist.

)}
)}
); }