'use client'; import { useEffect, useState } from 'react'; import { X, CheckCircle, AlertCircle, Info, AlertTriangle } from 'lucide-react'; import type { Toast as ToastType } from '@/store/toast-store'; import { useToastStore } from '@/store/toast-store'; interface ToastProps { toast: ToastType; } const iconMap = { success: CheckCircle, error: AlertCircle, warning: AlertTriangle, info: Info, }; const colorMap = { success: 'bg-success text-success-foreground border-success', error: 'bg-destructive text-destructive-foreground border-destructive', warning: 'bg-warning text-warning-foreground border-warning', info: 'bg-info text-info-foreground border-info', }; export function Toast({ toast }: ToastProps) { const { removeToast } = useToastStore(); const [isExiting, setIsExiting] = useState(false); const Icon = iconMap[toast.type]; const handleClose = () => { setIsExiting(true); setTimeout(() => { removeToast(toast.id); }, 300); // Match animation duration }; return (
{toast.message}