import { useEffect, useState } from 'react'; interface ToastProps { message: string; type?: 'success' | 'error' | 'info' | 'warning'; duration?: number; onClose?: () => void; } export function Toast({ message, type = 'info', duration = 5000, onClose }: ToastProps) { const [isVisible, setIsVisible] = useState(true); useEffect(() => { const timer = setTimeout(() => { setIsVisible(false); setTimeout(() => { if (onClose) onClose(); }, 300); // Wait for fade out animation }, duration); return () => clearTimeout(timer); }, [duration, onClose]); const bgColor = { success: 'bg-green-600', error: 'bg-red-600', info: 'bg-blue-600', warning: 'bg-yellow-600', }[type]; return (

{message}

); } interface ToastContainerProps { toasts: Array<{ id: string; message: string; type?: 'success' | 'error' | 'info' | 'warning' }>; onRemove: (id: string) => void; } export function ToastContainer({ toasts, onRemove }: ToastContainerProps) { return (
{toasts.map((toast) => ( onRemove(toast.id)} /> ))}
); }