fix: surface notification test failures cleanly instead of as 500s
Server-side, return 200 with success: false and a friendly message when sendTestNotification reports failure (the underlying call already swallows the error); reserve real 500s for unexpected exceptions. Client-side, teach usePost to honour the response body's success flag so success:false flips the toast to error without throwing through axios. Also tidy the toast container: drop icons, no wrapping, single-line ellipsis with a sensible max-width that hugs short messages.
This commit is contained in:
1 parent
127ee5508a
commit
a4f69daae7
4 files changed
+21
-11
No files matched your search
@@ -57,7 +57,11 @@ export const usePost = <B = any, R = any>() => {
|
||||
...config?.headers,
|
||||
},
|
||||
});
|
||||
toastSuccess(res.data?.msg || "Operation successful");
|
||||
if (res.data?.success === false) {
|
||||
toastError(res.data?.msg || "Operation failed");
|
||||
} else {
|
||||
toastSuccess(res.data?.msg || "Operation successful");
|
||||
}
|
||||
|
||||
return res.data;
|
||||
} catch (err: any) {
|
||||
|
||||
@@ -4,8 +4,9 @@ export const useToast = () => {
|
||||
const showToast = (message: string, options?: ToastOptions) => {
|
||||
toast.dismiss();
|
||||
const baseStyle: React.CSSProperties = {
|
||||
whiteSpace: "pre-line",
|
||||
wordBreak: "break-word",
|
||||
whiteSpace: "nowrap",
|
||||
overflow: "hidden",
|
||||
textOverflow: "ellipsis",
|
||||
};
|
||||
toast(message, {
|
||||
...options,
|
||||
|
||||
Reference in new issue
Block a user