'use client'; import AdminShell from '@/components/AdminShell'; import { api } from '@/lib/api'; import { formatDateTime } from '@/lib/utils'; import { useEffect, useState } from 'react'; import { ScrollText, RefreshCw, ChevronLeft, ChevronRight } from 'lucide-react'; const ACTION_COLORS: Record = { ban: 'bg-red-100 text-red-700', suspend: 'bg-orange-100 text-orange-700', activate: 'bg-green-100 text-green-700', delete: 'bg-red-100 text-red-700', admin_create_user: 'bg-blue-100 text-blue-700', admin_import_content: 'bg-blue-100 text-blue-700', waitlist_update: 'bg-purple-100 text-purple-700', reset_feed_impressions: 'bg-yellow-100 text-yellow-700', }; function actionColor(action: string) { return ACTION_COLORS[action] || 'bg-gray-100 text-gray-600'; } export default function AuditLogPage() { const [entries, setEntries] = useState([]); const [total, setTotal] = useState(0); const [loading, setLoading] = useState(true); const [page, setPage] = useState(0); const limit = 50; const fetchLog = (p = page) => { setLoading(true); api.getAuditLog({ limit, offset: p * limit }) .then((data) => { setEntries(data.entries || []); setTotal(data.total || 0); }) .catch(() => {}) .finally(() => setLoading(false)); }; useEffect(() => { fetchLog(page); }, [page]); const totalPages = Math.max(1, Math.ceil(total / limit)); return (

Admin Audit Log

Every admin action is recorded here

{loading ? (
{Array.from({ length: 8 }).map((_, i) => (
))}
) : entries.length === 0 ? (
No audit log entries found.
) : (
{entries.map((e) => ( ))}
When Admin Action Target Details
{e.created_at ? formatDateTime(e.created_at) : '—'} {e.actor_handle ? `@${e.actor_handle}` : e.actor_id ? e.actor_id.slice(0, 8) + '…' : '—'} {e.action?.replace(/_/g, ' ')} {e.target_type && {e.target_type}} {e.target_id && {String(e.target_id).slice(0, 8)}…} {e.details || '—'}
)} {/* Pagination */} {totalPages > 1 && (

Page {page + 1} of {totalPages} ({total} entries)

)}
); }