import { Fragment, useEffect } from 'react'; import { Transition } from '@headlessui/react'; import { CheckCircleIcon, XCircleIcon, InformationCircleIcon, XMarkIcon } from '@heroicons/react/24/outline'; export interface Toast { id: string; type: 'success' | 'error' | 'info'; title: string; message?: string; } interface ToastNotificationProps { toast: Toast; onClose: (id: string) => void; } export default function ToastNotification({ toast, onClose }: ToastNotificationProps) { useEffect(() => { const timer = setTimeout(() => { onClose(toast.id); }, 5000); return () => clearTimeout(timer); }, [toast.id, onClose]); const styles = { success: { bg: 'bg-emerald-50 dark:bg-emerald-900/20', border: 'border-emerald-200 dark:border-emerald-900/30', icon: 'text-emerald-600 dark:text-emerald-400', title: 'text-emerald-900 dark:text-emerald-300', IconComponent: CheckCircleIcon }, error: { bg: 'bg-red-50 dark:bg-red-900/20', border: 'border-red-200 dark:border-red-900/30', icon: 'text-red-600 dark:text-red-400', title: 'text-red-900 dark:text-red-300', IconComponent: XCircleIcon }, info: { bg: 'bg-blue-50 dark:bg-blue-900/20', border: 'border-blue-200 dark:border-blue-900/30', icon: 'text-blue-600 dark:text-blue-400', title: 'text-blue-900 dark:text-blue-300', IconComponent: InformationCircleIcon } }; const style = styles[toast.type]; const Icon = style.IconComponent; return (

{toast.title}

{toast.message && (

{toast.message}

)}
); }