import React, { useEffect, useState } from 'react'; import { X, CheckCircle2, AlertCircle, Info, Sparkles } from 'lucide-react'; export type ToastType = 'success' | 'error' | 'info' | 'milestone'; export interface Toast { id: string; type: ToastType; title: string; message?: string; duration?: number; icon?: React.ReactNode; } interface ToastNotificationProps { toast: Toast; onClose: (id: string) => void; } export const ToastNotification: React.FC = ({ toast, onClose }) => { const [isExiting, setIsExiting] = useState(false); useEffect(() => { const duration = toast.duration || 5000; const timer = setTimeout(() => { setIsExiting(true); setTimeout(() => onClose(toast.id), 300); // Wait for animation }, duration); return () => clearTimeout(timer); }, [toast.id, toast.duration, onClose]); const getIcon = () => { if (toast.icon) return toast.icon; switch (toast.type) { case 'success': return ; case 'error': return ; case 'milestone': return ; case 'info': default: return ; } }; const getStyles = () => { switch (toast.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 'milestone': return 'bg-gradient-to-r from-purple-50 to-pink-50 border-purple-200 text-purple-800'; case 'info': default: return 'bg-blue-50 border-blue-200 text-blue-800'; } }; return (
{/* Icon */}
{getIcon()}
{/* Content */}

{toast.title}

{toast.message && (

{toast.message}

)}
{/* Close Button */}
{/* Progress Bar */} {toast.type === 'milestone' && (
)}
); };