import type { Metadata } from "next"; import Link from "next/link"; import { EventRow } from "@/components/market/event-row"; import { Empty, Page, PageHeader } from "@/components/ui/section"; import { api } from "@/lib/api"; import { cx, EVENT_TYPE_LABEL } from "@/lib/format"; import type { MarketEvent } from "@/lib/types"; export const metadata: Metadata = { title: "Events", description: "Canonical market events: halts, filings, price moves, volatility, market opens and source incidents.", alternates: { canonical: "/events" } }; export const dynamic = "force-dynamic"; const TYPES = ["PRICE_CHANGE", "SESSION_HIGH", "SESSION_LOW", "VOLATILITY_SPIKE", "TRADING_HALT", "TRADING_RESUME", "FILING_PUBLISHED", "MARKET_OPEN", "MARKET_CLOSE", "SOURCE_DIVERGENCE", "SOURCE_FAILURE", "SCHEMA_DRIFT", "DOCUMENT_CHANGED"]; const SEVS = ["INFO", "NOTICE", "WARNING", "CRITICAL"]; export default async function EventsPage({ searchParams }: { searchParams: Promise> }) { const sp = await searchParams; const type = typeof sp.type === "string" ? sp.type : ""; const severity = typeof sp.severity === "string" ? sp.severity : ""; const instrument = typeof sp.instrument === "string" ? sp.instrument : ""; const country = typeof sp.country === "string" ? sp.country : ""; const before = typeof sp.before === "string" ? sp.before : ""; const q = new URLSearchParams({ limit: "100" }); if (type) q.set("type", type); if (severity) q.set("severity", severity); if (instrument) q.set("instrument", instrument); if (country) q.set("country", country); if (before) q.set("before", before); const events = await api(`/v1/events?${q}`); const link = (patch: Record) => { const u = new URLSearchParams(); for (const [k, v] of Object.entries({ type, severity, instrument, country, ...patch })) if (v) u.set(k, v); const s = u.toString(); return s ? `/events?${s}` : "/events"; }; const last = events[events.length - 1]; const lastTs = last ? (typeof last.timestamp === "number" ? new Date(last.timestamp).toISOString() : String(last.timestamp).replace(" ", "T")) : null; return ( Watch live →} />
All types {TYPES.map((t) => ( {EVENT_TYPE_LABEL[t] ?? t} ))}
Severity: any {SEVS.map((s) => ( {s.toLowerCase()} ))} {(instrument || country) && ( filtered by {instrument ? `instrument ${instrument}` : `country ${country}`} ·{" "} clear )}
{events.length ? (
    {events.map((e) => ( ))}
) : ( No events match these filters. )} {events.length >= 100 && lastTs && (
Older →
)}
); }