From cbe73f34c1f4b0374b1f6525d3d131e24161e84a Mon Sep 17 00:00:00 2001 From: Skorpios Date: Thu, 20 Mar 2025 08:29:14 -0700 Subject: [PATCH] Updated toast notifications to match our theme. --- .../Hooks/useNotification.js | 17 +++++++++++++---- src/locales/gb.json | 16 ++++++++++++---- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/Components/NotificationIntegrationModal/Hooks/useNotification.js b/src/Components/NotificationIntegrationModal/Hooks/useNotification.js index 08343760b..3547873e8 100644 --- a/src/Components/NotificationIntegrationModal/Hooks/useNotification.js +++ b/src/Components/NotificationIntegrationModal/Hooks/useNotification.js @@ -1,7 +1,7 @@ import { useState } from 'react'; -import { toast } from 'react-toastify'; import { useTranslation } from "react-i18next"; import { networkService } from '../../../Utils/NetworkService'; +import { createToast } from '../../../Utils/toastUtils'; // Define constants for notification types to avoid magic values const NOTIFICATION_TYPES = { @@ -84,7 +84,10 @@ const useNotifications = () => { // If validation fails, show error and return if (isValid === false) { - toast.error(errorMessage); + createToast({ + body: errorMessage, + variant: "error" + }); setLoading(false); return; } @@ -96,13 +99,19 @@ const useNotifications = () => { }); if (response.data.success === true) { - toast.success(t('notifications.testSuccess')); + createToast({ + body: t('notifications.testSuccess'), + variant: "info" + }); } else { throw new Error(response.data.msg || t('notifications.testFailed')); } } catch (error) { const errorMsg = error.response?.data?.msg || error.message || t('notifications.networkError'); - toast.error(`${t('notifications.testFailed')}: ${errorMsg}`); + createToast({ + body: `${t('notifications.testFailed')}: ${errorMsg}`, + variant: "error" + }); setError(errorMsg); } finally { setLoading(false); diff --git a/src/locales/gb.json b/src/locales/gb.json index 73ece5bc3..b80d4a608 100644 --- a/src/locales/gb.json +++ b/src/locales/gb.json @@ -147,17 +147,23 @@ "enableNotifications": "Enable {{platform}} notifications", "testNotification": "Test notification", "addOrEditNotifications": "Add or edit notifications", + "testSuccess": "Test notification sent successfully!", + "testFailed": "Failed to send test notification", + "unsupportedType": "Unsupported notification type", + "networkError": "Network error occurred", "slack": { "label": "Slack", "description": "To enable Slack notifications, create a Slack app and enable incoming webhooks. After that, simply provide the webhook URL here.", "webhookLabel": "Webhook URL", - "webhookPlaceholder": "https://hooks.slack.com/services/..." + "webhookPlaceholder": "https://hooks.slack.com/services/...", + "webhookRequired": "Slack webhook URL is required" }, "discord": { "label": "Discord", "description": "To send data to a Discord channel from Checkmate via Discord notifications using webhooks, you can use Discord's incoming Webhooks feature.", "webhookLabel": "Discord Webhook URL", - "webhookPlaceholder": "https://discord.com/api/webhooks/..." + "webhookPlaceholder": "https://discord.com/api/webhooks/...", + "webhookRequired": "Discord webhook URL is required" }, "telegram": { "label": "Telegram", @@ -165,13 +171,15 @@ "tokenLabel": "Your bot token", "tokenPlaceholder": "123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11", "chatIdLabel": "Your Chat ID", - "chatIdPlaceholder": "-1001234567890" + "chatIdPlaceholder": "-1001234567890", + "fieldsRequired": "Telegram token and chat ID are required" }, "webhook": { "label": "Webhooks", "description": "You can set up a custom webhook to receive notifications when incidents occur.", "urlLabel": "Webhook URL", - "urlPlaceholder": "https://your-server.com/webhook" + "urlPlaceholder": "https://your-server.com/webhook", + "urlRequired": "Webhook URL is required" }, "testNotificationDevelop": "Test notification 2", "integrationButton": "Notification Integration"