full upgrade
This commit is contained in:
@@ -139,10 +139,27 @@ interface ToastContextType {
|
||||
|
||||
const ToastContext = createContext<ToastContextType | undefined>(undefined);
|
||||
|
||||
// No-op fallback for SSR or when outside provider
|
||||
const noopToast: ToastContextType = {
|
||||
addToast: () => {},
|
||||
showToast: () => {},
|
||||
showSuccess: () => {},
|
||||
showError: () => {},
|
||||
showWarning: () => {},
|
||||
showInfo: () => {},
|
||||
showEmailSent: () => {},
|
||||
showEmailError: () => {},
|
||||
showProjectSaved: () => {},
|
||||
showProjectDeleted: () => {},
|
||||
showImportSuccess: () => {},
|
||||
showImportError: () => {},
|
||||
};
|
||||
|
||||
export const useToast = () => {
|
||||
const context = useContext(ToastContext);
|
||||
// Return no-op fallback during SSR or if used outside provider
|
||||
if (!context) {
|
||||
throw new Error('useToast must be used within a ToastProvider');
|
||||
return noopToast;
|
||||
}
|
||||
return context;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user