// Toast Context and Provider const { useState, useCallback, createContext, useContext } = React; const ToastContext = createContext(); function ToastProvider({ children }) { const [toasts, setToasts] = useState([]); const addToast = useCallback((message, type = 'info') => { const id = Date.now(); setToasts(prev => [...prev, { id, message, type }]); setTimeout(() => setToasts(prev => prev.filter(t => t.id !== id)), 4000); }, []); return ( {children}
{toasts.map(toast => (
{toast.type === 'success' ? '✓' : toast.type === 'error' ? '✕' : 'ℹ'} {toast.message}
))}
); } const useToast = () => useContext(ToastContext); // Export to global scope window.ToastContext = ToastContext; window.ToastProvider = ToastProvider; window.useToast = useToast;