'use client'; import { useEffect, useState } from 'react'; import { getAuditLog, type AuditAction } from '@/lib/api'; const PAGE_SIZE = 50; export function AuditLog() { const [rows, setRows] = useState([]); const [total, setTotal] = useState(0); const [offset, setOffset] = useState(0); const [error, setError] = useState(null); const [loading, setLoading] = useState(true); useEffect(() => { setLoading(true); getAuditLog(PAGE_SIZE, offset) .then(({ actions, total }) => { setRows(actions); setTotal(total); }) .catch((e) => setError(String(e.message))) .finally(() => setLoading(false)); }, [offset]); if (error) return

Error: {error}

; return (

Audit log

{total} entries
{['Time', 'Admin', 'Action', 'Target'].map((h) => ( ))} {loading ? ( ) : rows.length === 0 ? ( ) : ( rows.map((a) => ( )) )}
{h}
Loading…
No actions logged yet.
{a.createdAt.slice(0, 19).replace('T', ' ')} {a.adminId.slice(0, 8)}… {a.action} {a.targetType && ( {a.targetType}: )} {a.targetId?.slice(0, 12) ?? '—'}
{total > PAGE_SIZE && (
{offset + 1}–{Math.min(offset + PAGE_SIZE, total)} of {total}
)}
); }