diff --git a/client/src/App.tsx b/client/src/App.tsx index 6fff55eca..5a1a36455 100644 --- a/client/src/App.tsx +++ b/client/src/App.tsx @@ -33,11 +33,14 @@ function App() { body: { backgroundColor: theme.palette.background.default, }, - ".Toastify__progress-bar, .Toastify__progress-bar--bg": { + ".Toastify__progress-bar": { height: 2, bottom: 0, top: "auto", }, + ".Toastify__progress-bar--bg": { + display: "none", + }, }} /> @@ -53,9 +56,15 @@ function App() { "--toastify-color-progress-dark": theme.palette.primary.main, "--toastify-toast-min-height": "40px", "--toastify-toast-padding": "8px 12px", + "--toastify-toast-width": "auto", } as CSSProperties } - toastStyle={{ minHeight: 40, padding: "8px 12px" }} + toastStyle={{ + minHeight: 40, + padding: "8px 12px", + width: "auto", + maxWidth: "min(560px, calc(100vw - 32px))", + }} progressStyle={{ height: 2 }} /> diff --git a/client/src/Hooks/UseApi.ts b/client/src/Hooks/UseApi.ts index 84fd1b547..543a9f165 100644 --- a/client/src/Hooks/UseApi.ts +++ b/client/src/Hooks/UseApi.ts @@ -57,7 +57,11 @@ export const usePost = () => { ...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) { diff --git a/client/src/Hooks/UseToast.ts b/client/src/Hooks/UseToast.ts index 8823aa675..72e7b18c9 100644 --- a/client/src/Hooks/UseToast.ts +++ b/client/src/Hooks/UseToast.ts @@ -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, diff --git a/server/src/controllers/notificationController.ts b/server/src/controllers/notificationController.ts index 0a49cbdb1..301c15446 100644 --- a/server/src/controllers/notificationController.ts +++ b/server/src/controllers/notificationController.ts @@ -37,13 +37,9 @@ class NotificationController implements INotificationController { const notification = testNotificationBodyValidation.parse(req.body); const success = await this.notificationsService.sendTestNotification(notification); - if (!success) { - throw new AppError({ message: "Sending notification failed", status: 500 }); - } - return res.status(200).json({ - success: true, - msg: "Notification sent successfully", + success, + msg: success ? "Notification sent successfully" : "Notification could not be sent — check the destination details.", details: { service: SERVICE_NAME }, }); } catch (error) {