import { useState, useEffect } from 'react'; import { Bell, BellOff, Check, CheckCheck, Trash2, Volume2, VolumeX, Monitor, AlertTriangle, AlertCircle, Info, Settings, ShieldCheck, ShieldX } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { Switch } from '@/components/ui/switch'; import { Popover, PopoverContent, PopoverTrigger, } from '@/components/ui/popover'; import { Tabs, TabsContent, TabsList, TabsTrigger, } from '@/components/ui/tabs'; import { ScrollArea } from '@/components/ui/scroll-area'; import { useNotifications, NotificationSeverity, requestNotificationPermission, getNotificationPermission } from '@/contexts/NotificationContext'; import { cn } from '@/lib/utils'; const severityConfig: Record = { critical: { icon: AlertTriangle, color: 'text-destructive' }, warning: { icon: AlertCircle, color: 'text-orange-400' }, info: { icon: Info, color: 'text-primary' }, }; const NotificationPermissionStatus = () => { const [permission, setPermission] = useState('default'); useEffect(() => { setPermission(getNotificationPermission()); }, []); if (permission === 'unsupported') { return (
Browser understøtter ikke notifikationer
); } if (permission === 'denied') { return (
Notifikationer blokeret - tillad i browser-indstillinger
); } if (permission === 'granted') { return (
Notifikationer aktiveret
); } return null; }; const NotificationCenter = () => { const { notifications, unreadCount, settings, markAsRead, markAllAsRead, clearAll, updateSettings, addNotification } = useNotifications(); const [activeTab, setActiveTab] = useState('notifications'); const sendTestNotification = (severity: NotificationSeverity) => { const testAlerts: Record = { critical: { title: 'KRITISK: Ransomware Detekteret', message: 'Mistænkelig krypteringsaktivitet opdaget på endpoint WKS-2847. Øjeblikkelig handling påkrævet.', }, warning: { title: 'Advarsel: Brute Force Forsøg', message: 'Flere mislykkede login-forsøg fra IP 192.168.1.105 på admin-konto.', }, info: { title: 'System Opdatering', message: 'Sikkerhedspatch KB5034441 er tilgængelig til installation.', }, }; const alert = testAlerts[severity]; addNotification({ title: alert.title, message: alert.message, severity, source: 'Test', }); }; const formatTime = (timestamp: number) => { const diff = Date.now() - timestamp; const minutes = Math.floor(diff / 60000); const hours = Math.floor(diff / 3600000); const days = Math.floor(diff / 86400000); if (minutes < 1) return 'Lige nu'; if (minutes < 60) return `${minutes}m siden`; if (hours < 24) return `${hours}t siden`; return `${days}d siden`; }; return (
Notifikationer Indstillinger
{notifications.length > 0 && (
)} {notifications.length === 0 ? (

Ingen notifikationer

) : (
{notifications.map((notification) => { const config = severityConfig[notification.severity]; const Icon = config.icon; return (
markAsRead(notification.id)} >

{notification.title}

{!notification.read && ( )}

{notification.message}

{formatTime(notification.timestamp)}

); })}
)}
{settings.soundEnabled ? : } Lyd
updateSettings({ soundEnabled: v })} />
Desktop notifikationer
{ if (v) { const permission = await requestNotificationPermission(); if (permission === 'granted') { updateSettings({ desktopEnabled: true }); } } else { updateSettings({ desktopEnabled: false }); } }} />
Kun kritiske
updateSettings({ criticalOnly: v })} />

Test notifikationer

); }; export default NotificationCenter;