"use client"; import * as React from "react"; import { AnimatePresence, motion } from "framer-motion"; import { cn } from "@/lib/utils"; type Toast = { id: number; msg: string; err?: boolean }; type Ctx = (msg: string, err?: boolean) => void; const ToastCtx = React.createContext(() => {}); export const useToast = () => React.useContext(ToastCtx); export function ToastProvider({ children }: { children: React.ReactNode }) { const [items, setItems] = React.useState([]); const push = React.useCallback((msg, err) => { const id = Date.now() + Math.random(); setItems((x) => [...x, { id, msg, err }]); setTimeout(() => setItems((x) => x.filter((t) => t.id !== id)), 3400); }, []); return ( {children}
{items.map((t) => ( {t.msg} ))}
); }