test notifications
This commit is contained in:
1 parent
cb5d8c3468
commit
36d13d556e
3 files changed
+23
-3
No files matched your search
@@ -48,7 +48,11 @@ export const HeaderControls = ({
|
|||||||
loading={isPosting || isPatching}
|
loading={isPosting || isPatching}
|
||||||
startIcon={<Mail size={20} strokeWidth={1.5} />}
|
startIcon={<Mail size={20} strokeWidth={1.5} />}
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
await post(`/monitors/${monitor._id}/notifications/test`, {});
|
const res = await post(
|
||||||
|
`/monitors/${monitor._id}/notifications/test`,
|
||||||
|
{}
|
||||||
|
);
|
||||||
|
console.log(res);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{t("sendTestNotifications")}
|
{t("sendTestNotifications")}
|
||||||
|
|||||||
@@ -2,7 +2,14 @@ import { toast, type ToastOptions } from "react-toastify";
|
|||||||
export const useToast = () => {
|
export const useToast = () => {
|
||||||
const showToast = (message: string, options?: ToastOptions) => {
|
const showToast = (message: string, options?: ToastOptions) => {
|
||||||
toast.dismiss();
|
toast.dismiss();
|
||||||
toast(message, options);
|
const baseStyle: React.CSSProperties = {
|
||||||
|
whiteSpace: "pre-line",
|
||||||
|
wordBreak: "break-word",
|
||||||
|
};
|
||||||
|
toast(message, {
|
||||||
|
...options,
|
||||||
|
style: { ...baseStyle, ...(options?.style || {}) },
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const toastSuccess = (msg: string, opts?: ToastOptions) =>
|
const toastSuccess = (msg: string, opts?: ToastOptions) =>
|
||||||
|
|||||||
@@ -310,8 +310,17 @@ class MonitorController {
|
|||||||
monitorId,
|
monitorId,
|
||||||
teamId
|
teamId
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const msg = results
|
||||||
|
.map(
|
||||||
|
(r) =>
|
||||||
|
`${r.channelName} (${r.channelType}): ${
|
||||||
|
r.sent ? "Success" : "Failed"
|
||||||
|
}`
|
||||||
|
)
|
||||||
|
.join("\n");
|
||||||
return res.status(200).json({
|
return res.status(200).json({
|
||||||
message: "Notification test sent successfully",
|
message: msg,
|
||||||
data: results,
|
data: results,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Reference in new issue
Block a user