"use client"; import { useEffect, useState } from "react"; import type { Notification } from "@/src/hooks/useUser"; interface ToastProps { notification: Notification | null; } export function Toast({ notification }: ToastProps) { const [visible, setVisible] = useState(false); useEffect(() => { if (notification) { setVisible(true); } else { // dismiss after 250ms to allow exit animation const t = setTimeout(() => setVisible(false), 300); return () => clearTimeout(t); } }, [notification]); if (!visible && !notification) return null; const isSuccess = notification?.type === "success"; return (
{/* icon */} {isSuccess ? "✓" : "⚠"} {notification?.message}
); }