import type { Metadata } from "next"; import { db, auditLogs, users, eq, desc } from "@epicure/db"; export const metadata: Metadata = {}; const PAGE_SIZE = 50; interface PageProps { searchParams: Promise<{ page?: string }>; } export default async function AdminAuditLogsPage({ searchParams }: PageProps) { const { page: pageParam } = await searchParams; const page = Math.max(1, parseInt(pageParam ?? "1", 10)); const offset = (page - 1) * PAGE_SIZE; const rows = await db .select({ id: auditLogs.id, action: auditLogs.action, targetType: auditLogs.targetType, targetId: auditLogs.targetId, metadata: auditLogs.metadata, createdAt: auditLogs.createdAt, actorName: users.name, actorEmail: users.email, }) .from(auditLogs) .leftJoin(users, eq(auditLogs.userId, users.id)) .orderBy(desc(auditLogs.createdAt)) .limit(PAGE_SIZE) .offset(offset); return (

Audit Logs

Admin actions recorded for accountability. Page {page}.

{rows.length === 0 ? ( ) : ( rows.map((row) => ( )) )}
Actor Action Target Metadata Timestamp
No audit log entries yet.
{row.actorName ?? "System"}
{row.actorEmail && (
{row.actorEmail}
)}
{row.action} {row.targetType ? ( {row.targetType} {row.targetId ? `: ${row.targetId.slice(0, 8)}…` : ""} ) : ( "—" )} {row.metadata ?? "—"} {row.createdAt.toLocaleString()}
{page > 1 && ( Previous )} {rows.length === PAGE_SIZE && ( Next )}
); }