visual-notebook / frontend /src /components /ErrorToast.tsx
Sid-WC121
initial
c21180c
Raw History Blame Contribute Delete
1.37 kB
import React, { useEffect } from 'react';
import { useUIStore } from '../store/ui';
export function ErrorToast() {
const { errors, removeError } = useUIStore();
useEffect(() => {
if (errors.length > 0) {
const timer = setTimeout(() => removeError(0), 5000);
return () => clearTimeout(timer);
}
}, [errors, removeError]);
if (errors.length === 0) return null;
return (
<div className="fixed bottom-4 right-4 z-50 flex flex-col gap-2">
{errors.map((error, i) => (
<div
key={i}
className="bg-red-50 border border-red-200 text-red-700 px-4 py-3 rounded-lg shadow-lg flex items-center gap-2 max-w-sm"
>
<svg className="w-4 h-4 flex-shrink-0" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
<span className="text-sm">{error}</span>
<button onClick={() => removeError(i)} className="text-red-400 hover:text-red-600 ml-auto">
<svg className="w-3 h-3" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M6 18L18 6M6 6l12 12" />
</svg>
</button>
</div>
))}
</div>
);
}