UNPKG

codalware-auth

Version:

Complete authentication system with enterprise security, attack protection, team workspaces, waitlist, billing, UI components, 2FA, and account recovery - production-ready in 5 minutes. Enhanced CLI with verification, rollback, and App Router scaffolding.

32 lines (26 loc) 897 B
import { useEffect, useState, useCallback } from 'react'; export interface AuditLog { id: string; action: string; details: any; createdAt: string; ipAddress?: string; } export const useAuditLogs = (limit: number = 50) => { const [logs,setLogs] = useState<AuditLog[]>([]); const [loading,setLoading] = useState(true); const [error,setError] = useState<string|null>(null); const load = useCallback(async () => { setLoading(true); setError(null); try { const res = await fetch(`/api/user/audit?limit=${limit}`); if(!res.ok) throw new Error('Failed to load audit logs'); const data = await res.json(); setLogs(data.logs || []); } catch(e:any){ setError(e.message); } finally { setLoading(false); } },[limit]); useEffect(()=>{ load(); },[load]); return { logs, loading, error, reload: load }; };