From f4ec292b314c1dc250cc65d2600297e95f9f14d8 Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Fri, 21 Mar 2025 16:24:27 -0700 Subject: [PATCH] handle jwt errors --- src/Hooks/useSubscribeToDepinMonitors.js | 1 + src/Pages/Maintenance/index.jsx | 19 ++++++++++++++++++- src/Pages/Settings/index.jsx | 11 +++++++++-- src/Utils/NetworkService.js | 22 +++++++++++++--------- 4 files changed, 41 insertions(+), 12 deletions(-) diff --git a/src/Hooks/useSubscribeToDepinMonitors.js b/src/Hooks/useSubscribeToDepinMonitors.js index 3bc098afa..918ead6bc 100644 --- a/src/Hooks/useSubscribeToDepinMonitors.js +++ b/src/Hooks/useSubscribeToDepinMonitors.js @@ -78,6 +78,7 @@ const useSubscribeToDepinMonitors = (page, rowsPerPage) => { }, onError: () => { setIsLoading(false); + setNetworkError(true); }, }); diff --git a/src/Pages/Maintenance/index.jsx b/src/Pages/Maintenance/index.jsx index adc76ebf2..41337da2a 100644 --- a/src/Pages/Maintenance/index.jsx +++ b/src/Pages/Maintenance/index.jsx @@ -10,6 +10,8 @@ import Breadcrumbs from "../../Components/Breadcrumbs"; import { useNavigate } from "react-router-dom"; import { useIsAdmin } from "../../Hooks/useIsAdmin"; import { useTranslation } from "react-i18next"; +import { Typography } from "@mui/material"; +import GenericFallback from "../../Components/GenericFallback"; const Maintenance = () => { const theme = useTheme(); @@ -22,6 +24,7 @@ const Maintenance = () => { const [page, setPage] = useState(0); const [sort, setSort] = useState({}); const [updateTrigger, setUpdateTrigger] = useState(false); + const [networkError, setNetworkError] = useState(false); const handleActionMenuDelete = () => { setUpdateTrigger((prev) => !prev); @@ -38,12 +41,26 @@ const Maintenance = () => { setMaintenanceWindows(maintenanceWindows); setMaintenanceWindowCount(maintenanceWindowCount); } catch (error) { - console.log(error); + setNetworkError(true); } }; fetchMaintenanceWindows(); }, [page, rowsPerPage, updateTrigger]); + if (networkError) { + return ( + + + {t("networkError")} + + {t("checkConnection")} + + ); + } if (maintenanceWindows.length === 0) { return ( { }); } else { if (action.payload) { + console.log(action.payload); // dispatch errors createToast({ body: action.payload.msg, @@ -298,7 +299,14 @@ const Settings = () => { {t("settingsWalletDescription")} - + { )} - {t("settingsAbout")} diff --git a/src/Utils/NetworkService.js b/src/Utils/NetworkService.js index 58e887f6e..2e4736c45 100644 --- a/src/Utils/NetworkService.js +++ b/src/Utils/NetworkService.js @@ -669,7 +669,7 @@ class NetworkService { }); } - /** + /** * ************************************ * Test a notification integration * ************************************ @@ -681,14 +681,18 @@ class NetworkService { * @returns {Promise} The response from the axios POST request. */ async testNotification(config) { - return this.axiosInstance.post('/notifications/test-webhook', { - platform: config.platform, - ...config.payload - }, { - headers: { - "Content-Type": "application/json", - }, - }); + return this.axiosInstance.post( + "/notifications/test-webhook", + { + platform: config.platform, + ...config.payload, + }, + { + headers: { + "Content-Type": "application/json", + }, + } + ); } /**