TypeScript 61.9%
HTML 37.2%
SQL 0.7%
1import Link from 'next/link';2import { requireAdmin } from '@/lib/admin/auth';3import { eventsLog } from '@/lib/admin/queries';4import { AdminShell, fmtTs, n } from '@/components/admin/shell';5import { Table, th, td } from '@/components/ui/primitives';67export default async function EventsPage({ searchParams }: { searchParams: Promise<{ type?: string }> }) {8 await requireAdmin();9 const sp = await searchParams;10 const { rows, types } = await eventsLog({ type: sp.type || undefined });11 return (12 <AdminShell current="/admin/events" title="Domain events" subtitle="page_crawled, listing_created, sale_detected, entity_matched, valuation_updated, index_updated… (last 200)" actions={<div className="flex flex-wrap gap-1 text-xs"><Link href="/admin/events" className={`rounded-md border px-2 py-1 ${!sp.type ? 'border-accent bg-accent text-accent-fg' : 'border-border hover:bg-inset'}`}>all</Link>{types.map((t) => <Link key={String(t.type)} href={`/admin/events?type=${String(t.type)}`} className={`rounded-md border px-2 py-1 ${sp.type === t.type ? 'border-accent bg-accent text-accent-fg' : 'border-border hover:bg-inset'}`}>{String(t.type)} <span className="text-subtle">{n(t.n)}</span></Link>)}</div>}>13 <div className="card">14 <Table>15 <thead><tr><th className={th}>When</th><th className={th}>Type</th><th className={th}>Entity</th><th className={th}>Payload</th></tr></thead>16 <tbody>17 {rows.length === 0 ? <tr><td className={td} colSpan={4}><span className="text-subtle">No events recorded yet.</span></td></tr> : null}18 {rows.map((r) => (19 <tr key={String(r.id)} className="align-top">20 <td className={td}>{fmtTs(r.created_at)}</td>21 <td className={`${td} font-mono text-[11px]`}>{String(r.type)}</td>22 <td className={`${td} font-mono text-[11px]`}>{String(r.entity_type ?? '')} {String(r.entity_id ?? '')}</td>23 <td className={`${td} max-w-[520px] whitespace-normal font-mono text-[10px] text-muted`}>{JSON.stringify(r.payload)}</td>24 </tr>25 ))}26 </tbody>27 </Table>28 </div>29 </AdminShell>30 );31}32