'use client'; import { ArrowUpRight } from 'lucide-react'; import Link from 'next/link'; import { useEffect, useState } from 'react'; import { CountryChip, EventTypeBadge, ImportanceMeter } from '@/components/ui/badges'; import { LiveAgo } from '@/components/ui/live'; import { Sheet } from '@/components/ui/sheet'; import { clientApi } from '@/lib/client-api'; import { routes } from '@/lib/site'; import type { EventDetail, EventSource } from '@/lib/types'; import { useEventDrawer } from './event-drawer-context'; import { EventEvidence } from './event-evidence'; /** Right-side (≥ lg) / bottom (< lg) drawer: the event, its evidence and links to the permanent pages. */ export function EventDrawer() { const { event, close } = useEventDrawer(); const [detail, setDetail] = useState<{ id: string; sources: EventSource[]; loaded: boolean } | null>(null); useEffect(() => { if (!event) return; const ctrl = new AbortController(); setDetail({ id: event.id, sources: event.sources ?? [], loaded: false }); clientApi .event(event.id, ctrl.signal) .then((d: EventDetail) => setDetail({ id: event.id, sources: d.sources ?? [], loaded: true })) .catch(() => setDetail((s) => (s ? { ...s, loaded: true } : s))); return () => ctrl.abort(); }, [event]); return ( : undefined} title={event?.title} footer={ event ? (
Open event page {event.company.display_name} {event.source_url && ( Source ↗ )}
) : undefined } > {event && (
{event.company.display_name} {event.company.canonical_domain}
{event.summary &&

{event.summary}

} {detail && detail.id === event.id && !detail.loaded &&

Loading full source list…

}
)}
); }