import { useState, useEffect } from 'react';
import { CheckCircle, XCircle, Info, AlertTriangle, X } from 'lucide-react';
export type ToastType = 'success' | 'error' | 'info' | 'warning';
export interface ToastProps {
id: string;
message: string;
type: ToastType;
duration?: number;
onClose: (id: string) => void;
}
const Toast = ({ id, message, type, duration = 3000, onClose }: ToastProps) => {
const [isVisible, setIsVisible] = useState(false);
useEffect(() => {
// Exciting entrance
requestAnimationFrame(() => setIsVisible(true));
if (duration > 0) {
const timer = setTimeout(() => {
setIsVisible(false);
setTimeout(() => onClose(id), 300); // Wait for transition
}, duration);
return () => clearTimeout(timer);
}
}, [duration, id, onClose]);
const getIcon = () => {
switch (type) {
case 'success': return
{message}