import React, { useState, useEffect, useRef } from 'react'; import type { NotificationPanelProps } from '../types/ui.types'; interface Notification { id: string; icon: string; title: string; timestamp: string; } const initialNotifications: Notification[] = [ { id: 'n1', icon: '💾', title: 'Projekt automatisch gespeichert', timestamp: 'vor 2 Min.' }, { id: 'n2', icon: '🔄', title: 'Neue Version verfügbar', timestamp: 'vor 15 Min.' }, { id: 'n3', icon: '👤', title: 'Benutzer ist beigetreten', timestamp: 'vor 1 Std.' }, ]; const NotificationPanel: React.FC = ({ open, onClose }) => { const [notifications, setNotifications] = useState(initialNotifications); const [allRead, setAllRead] = useState(false); const ref = useRef(null); useEffect(() => { if (!open) return; const handleClickOutside = (e: MouseEvent) => { if (ref.current && !ref.current.contains(e.target as Node)) { onClose(); } }; document.addEventListener('mousedown', handleClickOutside); return () => document.removeEventListener('mousedown', handleClickOutside); }, [open, onClose]); if (!open) return null; const handleDismiss = (id: string) => { setNotifications((prev) => prev.filter((n) => n.id !== id)); }; const handleMarkAllRead = () => { setAllRead(true); }; return (

Benachrichtigungen

{notifications.length === 0 ? (

Keine Benachrichtigungen

) : ( notifications.map((n) => (
{n.icon}
{n.title} {n.timestamp}
)) )}
{notifications.length > 0 && ( )}
); }; export default NotificationPanel;