import { useState, useEffect } from 'react'; import { X, CheckCircle, AlertCircle, Info, AlertTriangle } from 'lucide-react'; export default function NotificationSystem({ theme }) { const [notifications, setNotifications] = useState([]); useEffect(() => { // Слушаем события уведомлений const handleNotification = (event) => { const { type, title, message } = event.detail; addNotification(type, title, message); }; window.addEventListener('notification', handleNotification); return () => window.removeEventListener('notification', handleNotification); }, []); const addNotification = (type, title, message) => { const id = Date.now(); const notification = { id, type, title, message }; setNotifications(prev => [...prev, notification]); // Автоматически удаляем через 5 секунд setTimeout(() => { removeNotification(id); }, 5000); }; const removeNotification = (id) => { setNotifications(prev => prev.filter(n => n.id !== id)); }; const getIcon = (type) => { switch (type) { case 'success': return ; case 'error': return ; case 'warning': return ; case 'info': default: return ; } }; const getColors = (type) => { switch (type) { case 'success': return 'bg-green-600 border-green-500'; case 'error': return 'bg-red-600 border-red-500'; case 'warning': return 'bg-yellow-600 border-yellow-500'; case 'info': default: return 'bg-blue-600 border-blue-500'; } }; return (
{notifications.map((notification) => (
{getIcon(notification.type)}

{notification.title}

{notification.message}

))}
); } // Вспомогательная функция для отправки уведомлений export const notify = (type, title, message) => { window.dispatchEvent(new CustomEvent('notification', { detail: { type, title, message } })); };