/** * Toast Store - Global state for toast notifications */ import { create } from 'zustand'; export type ToastType = 'success' | 'error' | 'warning' | 'info'; export interface Toast { id: string; type: ToastType; message: string; title?: string; duration?: number; } interface ToastState { toasts: Toast[]; addToast: (toast: Omit) => string; removeToast: (id: string) => void; clearToasts: () => void; } let toastId = 0; export const useToastStore = create((set) => ({ toasts: [], addToast: (toast) => { const id = `toast-${++toastId}`; set((state) => ({ toasts: [...state.toasts, { ...toast, id }], })); return id; }, removeToast: (id) => { set((state) => ({ toasts: state.toasts.filter((t) => t.id !== id), })); }, clearToasts: () => { set({ toasts: [] }); }, }));