import { pool } from "../db/client"; import { Checkout } from "./checkout"; export const dynamic = "force-dynamic"; type EventRow = { id: string; name: string; description: string; venue: string; starts_at: Date; price_cents: number; capacity: number; sold: string; }; export default async function EventPage() { const result = await pool.query(` SELECT e.*, COALESCE(SUM(CASE WHEN o.status = 'paid' THEN o.quantity ELSE 0 END), 0)::text AS sold FROM events e LEFT JOIN orders o ON o.event_id = e.id GROUP BY e.id ORDER BY e.starts_at LIMIT 1 `); const event = result.rows[0]; if (!event) return
The workshop is being prepared. Refresh in a moment.
; const date = new Intl.DateTimeFormat("en", { dateStyle: "full", timeStyle: "short", timeZone: "America/New_York" }).format(event.starts_at); const seatsLeft = event.capacity - Number(event.sold); const stripeReady = Boolean(process.env.STRIPE_SECRET_KEY && process.env.STRIPE_WEBHOOK_SECRET); return (

One afternoon workshop

{event.name}

{event.description}

When
{date}
Where
{event.venue}
Seats left
{seatsLeft} of {event.capacity}

Rendered from PostgreSQL on the server.

); }