'use client'; import { useEffect, useState } from 'react'; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/components/ui/table'; import { documentNumberingService } from '@/lib/services/document-numbering.service'; import { format } from 'date-fns'; import { NumberingAuditLog } from '@/types/dto/numbering.dto'; export function AuditLogsTable() { const [logs, setLogs] = useState([]); const [loading, setLoading] = useState(true); useEffect(() => { async function fetchLogs() { try { const data = await documentNumberingService.getMetrics(); // Using metrics endpoint for now as it contains logs if (data && data.audit) { setLogs(data.audit); } } catch (_error) { // Failed to fetch audit logs - empty state shown } finally { setLoading(false); } } fetchLogs(); }, []); if (loading) return
Loading logs...
; return (
Time Operation Number User Status {logs.length === 0 ? ( No logs found. ) : ( logs.map((log) => ( {format(new Date(log.createdAt), 'yyyy-MM-dd HH:mm:ss')} {log.operation} {log.documentNumber} {log.createdBy || 'System'} {log.status} )) )}
); }