/** * Toast Notification Component */ import React, { useEffect } from 'react'; export interface ToastProps { message: string; type?: 'success' | 'error' | 'info'; isVisible: boolean; onClose: () => void; duration?: number; } const Toast: React.FC = ({ message, type = 'success', isVisible, onClose, duration = 3000, }) => { useEffect(() => { if (isVisible && duration > 0) { const timer = setTimeout(() => { onClose(); }, duration); return () => clearTimeout(timer); } }, [isVisible, duration, onClose]); if (!isVisible) return null; const typeStyles = { success: 'bg-green-50 border-green-200 text-green-800', error: 'bg-red-50 border-red-200 text-red-800', info: 'bg-blue-50 border-blue-200 text-blue-800', }; const iconStyles = { success: 'text-green-600', error: 'text-red-600', info: 'text-blue-600', }; return (
{type === 'success' && ( )} {type === 'error' && ( )} {type === 'info' && ( )}
{message}
); }; export default Toast;