import { useEffect, useState } from 'react' import { X, CheckCircle, XCircle, AlertTriangle, Info } from 'lucide-react' import { clsx } from 'clsx' import { useToastStore, type Toast as ToastType } from '@/store/toast' const icons = { success: CheckCircle, error: XCircle, warning: AlertTriangle, info: Info, } const styles = { success: 'bg-green-500/20 border-green-500/50 text-green-400', error: 'bg-red-500/20 border-red-500/50 text-red-400', warning: 'bg-yellow-500/20 border-yellow-500/50 text-yellow-400', info: 'bg-blue-500/20 border-blue-500/50 text-blue-400', } const iconStyles = { success: 'text-green-500', error: 'text-red-500', warning: 'text-yellow-500', info: 'text-blue-500', } interface ToastItemProps { toast: ToastType onRemove: (id: string) => void } function ToastItem({ toast, onRemove }: ToastItemProps) { const [isVisible, setIsVisible] = useState(false) const [isLeaving, setIsLeaving] = useState(false) const Icon = icons[toast.type] useEffect(() => { // Trigger enter animation requestAnimationFrame(() => setIsVisible(true)) }, []) const handleRemove = () => { setIsLeaving(true) setTimeout(() => onRemove(toast.id), 200) } return (
{toast.message}