import { useEffect } from 'react' export interface ToastMsg { id: number kind: 'success' | 'error' text: string } export function Toast({ toast, onClose }: { toast: ToastMsg | null; onClose: () => void }) { useEffect(() => { if (!toast) return const t = setTimeout(onClose, toast.kind === 'error' ? 6000 : 4000) return () => clearTimeout(t) }, [toast, onClose]) if (!toast) return null return (
{toast.text}
) }