"use client"; import { AnimatePresence, motion } from "framer-motion"; import { useEffect, useState } from "react"; import { Button } from "@/components/ui"; import { springGentle } from "@/lib/motion"; import { toastBus, type Toast } from "@/lib/toast"; /** * Global toast host: undo for reversible destructive actions, share fallbacks. * Sits above the tab bar on phones and near the bottom on desktop. */ export function Toaster() { const [toasts, setToasts] = useState([]); useEffect( () => toastBus.subscribe((toast) => { setToasts((current) => [...current.slice(-2), toast]); window.setTimeout( () => setToasts((current) => current.filter((entry) => entry.id !== toast.id)), toast.durationMs ?? 5000, ); }), [], ); const dismiss = (id: number) => setToasts((current) => current.filter((entry) => entry.id !== id)); return (
{toasts.map((toast) => (

{toast.message}

{toast.actionLabel ? ( ) : ( )}
))}
); }