import { AdminGuard } from '@kit/admin/components/admin-guard'; import { createModuleBuilderApi } from '@kit/module-builder/api'; import { formatDateTime } from '@kit/shared/dates'; import { getSupabaseServerAdminClient } from '@kit/supabase/server-admin-client'; import { Badge } from '@kit/ui/badge'; import { Button } from '@kit/ui/button'; import { PageBody, PageHeader } from '@kit/ui/page'; interface SearchParams { action?: string; table?: string; page?: string; } interface AdminAuditPageProps { searchParams: Promise; } const ACTION_LABELS: Record = { insert: 'Erstellen', update: 'Ändern', delete: 'Löschen', lock: 'Sperren', }; const ACTION_COLORS: Record< string, 'default' | 'secondary' | 'destructive' | 'outline' > = { insert: 'default', update: 'secondary', delete: 'destructive', lock: 'outline', }; async function AuditPage(props: AdminAuditPageProps) { const searchParams = await props.searchParams; const client = getSupabaseServerAdminClient(); const api = createModuleBuilderApi(client); const page = searchParams.page ? parseInt(searchParams.page, 10) : 1; const result = await api.audit.query({ action: searchParams.action || undefined, tableName: searchParams.table || undefined, page, pageSize: 50, }); const totalPages = Math.ceil(result.total / result.pageSize); return (
{/* Filters */} {/* Results table */}
{result.data.length === 0 ? ( ) : ( result.data.map((entry) => ( )) )}
Zeitpunkt Aktion Tabelle Datensatz-ID Benutzer-ID
Keine Einträge gefunden.
{formatDateTime(entry.created_at)} {ACTION_LABELS[entry.action as string] ?? String(entry.action)} {String(entry.table_name)} {String(entry.record_id).slice(0, 8)}... {String(entry.user_id).slice(0, 8)}...
{/* Pagination */} {totalPages > 1 && (

Seite {page} von {totalPages} ({result.total} Einträge)

{page > 1 && ( )} {page < totalPages && ( )}
)}
); } function AuditFilters({ currentAction, currentTable, }: { currentAction?: string; currentTable?: string; }) { return (
); } function PaginationLink({ page, action, table, label, }: { page: number; action?: string; table?: string; label: string; }) { const params = new URLSearchParams(); params.set('page', String(page)); if (action) params.set('action', action); if (table) params.set('table', table); return ( ); } export default AdminGuard(AuditPage);