'use client' import { useState, useEffect, useCallback } from 'react' import { StatRow, type DashboardData } from '../widget-primitives' import { useNavigateToPanel } from '@/lib/navigation' interface PostureInfo { score: number level: string } const postureBadge: Record = { hardened: { label: 'Hardened', className: 'bg-green-500/15 text-green-400' }, secure: { label: 'Secure', className: 'bg-green-500/10 text-green-300' }, 'needs-attention': { label: 'Needs Attention', className: 'bg-yellow-500/15 text-yellow-400' }, 'at-risk': { label: 'At Risk', className: 'bg-red-500/15 text-red-400' }, } export function SecurityAuditWidget({ data }: { data: DashboardData }) { const { dbStats } = data const navigateToPanel = useNavigateToPanel() const [posture, setPosture] = useState(null) const fetchPosture = useCallback(async () => { try { const res = await fetch('/api/security-audit?timeframe=day') if (res.ok) { const json = await res.json() if (json.posture) setPosture(json.posture) } } catch { // Silent } }, []) useEffect(() => { fetchPosture() }, [fetchPosture]) const badge = posture ? postureBadge[posture.level] || postureBadge['secure'] : null return (

Security + Audit

{posture && badge && ( {posture.score} - {badge.label} )}
0 : false} /> 0} />
) }