import { useState, useRef, useEffect } from 'react'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faBell, faTriangleExclamation, faXmark, faCheck } from '@fortawesome/pro-duotone-svg-icons'; import { Badge } from '@/components/base/badges/badges'; import { usePerformanceAlerts } from '@/hooks/use-performance-alerts'; import { cx } from '@/utils/cx'; export const NotificationBell = () => { const { alerts, dismiss, dismissAll } = usePerformanceAlerts(); const [open, setOpen] = useState(false); const panelRef = useRef(null); // Close on outside click useEffect(() => { if (!open) return; const handler = (e: MouseEvent) => { if (panelRef.current && !panelRef.current.contains(e.target as Node)) { setOpen(false); } }; document.addEventListener('mousedown', handler); return () => document.removeEventListener('mousedown', handler); }, [open]); return (
{open && (
{/* Header */}
Notifications {alerts.length > 0 && ( {alerts.length} )}
{alerts.length > 0 && ( )}
{/* Alert list */}
{alerts.length === 0 ? (

No active alerts

) : ( alerts.map(alert => (

{alert.agent}

{alert.type}

{alert.value}
)) )}
)}
); };