import React, { useEffect } from "react" export type ToastKind = "success" | "error" export type ToastState = { kind: ToastKind message: string } | null type Props = { toast: ToastState onClose: () => void } /** * Fixed-position notification that auto-dismisses (errors linger longer). * Render it unconditionally and drive it through `toast` state. */ export default function Toast({ toast, onClose }: Props) { useEffect(() => { if (!toast) return const duration = toast.kind === "error" ? 5000 : 2500 const t = setTimeout(() => onClose(), duration) return () => clearTimeout(t) }, [toast, onClose]) if (!toast) return null const isSuccess = toast.kind === "success" return (
{toast.message}
) }