import { sql } from "@/db"; import { PageTitle } from "@/components/admin-ui"; export default async function Audit({ searchParams }: { searchParams: Promise> }) { const sp = await searchParams; const page = Math.max(1, Number(sp.page ?? 1) || 1); const q = sp.q || null; const rows = await sql`SELECT * FROM audit_log WHERE (${q}::text IS NULL OR action ILIKE '%' || ${q ?? ""} || '%' OR actor_label ILIKE '%' || ${q ?? ""} || '%' OR entity_id ILIKE '%' || ${q ?? ""} || '%') ORDER BY at DESC LIMIT 100 OFFSET ${(page - 1) * 100}`; return (
{rows.map((a) => )}
WhenActorIPActionEntityBeforeAfter
{new Date(a.at).toLocaleString("en-CA")}{a.actor_label}{a.ip ?? ""}{a.action}{a.entity_type} {a.entity_id ?? ""}{a.before ? JSON.stringify(a.before) : ""}{a.after ? JSON.stringify(a.after) : ""}

{page > 1 && ← Newer}{rows.length === 100 && Older →}

); }