import React, { useEffect } from 'react'; import { motion } from 'framer-motion'; import { XIcon, CheckCircleIcon, WarningCircleIcon, TrophyIcon, TerminalIcon, } from '@phosphor-icons/react'; import { Link } from 'react-router-dom'; const Toast = ({ id, title, message, duration = 3000, type, removeToast, icon, links, }) => { useEffect(() => { const timer = setTimeout(() => { removeToast(id); }, duration); return () => clearTimeout(timer); }, [id, duration, removeToast]); const getIcon = () => { if (icon) return icon; switch (type) { case 'error': return ; case 'gold': return ; case 'techno': return ; default: return ; } }; const getAccentColor = () => { switch (type) { case 'error': return 'bg-red-500'; case 'gold': return 'bg-amber-400'; case 'techno': return 'bg-emerald-400'; default: return 'bg-emerald-500'; } }; const getBorderColor = () => { switch (type) { case 'error': return 'border-red-500/50'; case 'gold': return 'border-amber-400/50'; case 'techno': return 'border-emerald-400/50'; default: return 'border-emerald-500/50'; } }; const getGlowColor = () => { switch (type) { case 'error': return 'shadow-red-500/10'; case 'gold': return 'shadow-amber-400/10'; case 'techno': return 'shadow-emerald-400/10'; default: return 'shadow-emerald-500/10'; } }; return ( {/* Dynamic Timer Bar */}
{getIcon()}

{title}

{message}

{links && links.length > 0 && (
{links.map((link, index) => { const btnClass = 'text-[9px] font-black uppercase tracking-widest px-3 py-1.5 bg-white/5 border border-white/10 text-white hover:bg-white hover:text-black transition-all rounded-sm'; if (link.to) return ( removeToast(id)} > {link.label} ); if (link.href) return ( removeToast(id)} > {link.label} ); if (link.onClick) return ( ); return null; })}
)}
{/* Glossy Overlay */}
); }; export default Toast;