import { create } from "zustand"; import { Button } from "./button"; type ToastKind = "success" | "error" | "info"; interface ToastMessage { id: string; title: string; kind: ToastKind; } const useToastStore = create<{ items: ToastMessage[]; push: (title: string, kind?: ToastKind) => void; remove: (id: string) => void; }>((set) => ({ items: [], push: (title, kind = "info") => { const id = crypto.randomUUID(); set((state) => ({ items: [...state.items, { id, title, kind }] })); window.setTimeout(() => set((state) => ({ items: state.items.filter((item) => item.id !== id) })), 3200); }, remove: (id) => set((state) => ({ items: state.items.filter((item) => item.id !== id) })), })); export const toast = { success: (title: string) => useToastStore.getState().push(title, "success"), error: (title: string) => useToastStore.getState().push(title, "error"), info: (title: string) => useToastStore.getState().push(title, "info"), }; export function Toaster() { const { items, remove } = useToastStore(); return (