"use client"; import { useEffect, useState } from "react"; import { notificationManager, AppNotification, } from "@/lib/utils/notifications"; export default function NotificationToast() { const [notifications, setNotifications] = useState([]); useEffect(() => { const handleNotificationsChange = (newNotifications: AppNotification[]) => { setNotifications(newNotifications); }; notificationManager.addListener(handleNotificationsChange); setNotifications(notificationManager.getNotifications()); return () => { notificationManager.removeListener(handleNotificationsChange); }; }, []); const getIcon = (type: string) => { switch (type) { case "success": return ( ); case "error": return ( ); case "warning": return ( ); case "info": return ( ); default: return null; } }; const getTypeClasses = (type: string) => { switch (type) { case "success": return "bg-green-50 border-green-200 text-green-800"; case "error": return "bg-red-50 border-red-200 text-red-800"; case "warning": return "bg-yellow-50 border-yellow-200 text-yellow-800"; case "info": return "bg-blue-50 border-blue-200 text-blue-800"; default: return "bg-gray-50 border-gray-200 text-gray-800"; } }; if (notifications.length === 0) { return null; } return (
{notifications.map((notification) => (
{getIcon(notification.type)}

{notification.title}

{notification.message}

))}
); }