From 97a73a385a4a44dea750ee6725d26639f8d2209b Mon Sep 17 00:00:00 2001 From: Owaise Imdad Date: Wed, 21 May 2025 23:59:22 +0530 Subject: [PATCH] Added the status color to monitor utils. --- client/src/Hooks/useMonitorUtils.js | 13 ++++++++++++- client/src/Pages/Uptime/Configure/index.jsx | 9 +-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/client/src/Hooks/useMonitorUtils.js b/client/src/Hooks/useMonitorUtils.js index fc1966b69..f187f7250 100644 --- a/client/src/Hooks/useMonitorUtils.js +++ b/client/src/Hooks/useMonitorUtils.js @@ -1,6 +1,8 @@ import { useCallback } from "react"; +import { useTheme } from "@mui/material"; const useMonitorUtils = () => { + const getMonitorWithPercentage = useCallback((monitor, theme) => { let uptimePercentage = ""; let percentageColor = ""; @@ -36,7 +38,16 @@ const useMonitorUtils = () => { return monitor?.status == true ? "up" : "down"; }, []); - return { getMonitorWithPercentage, determineState }; + const theme = useTheme(); + + const statusColor = { + up: theme.palette.success.lowContrast, + down: theme.palette.error.lowContrast, + paused: theme.palette.warning.lowContrast, + pending: theme.palette.warning.lowContrast, + }; + + return { getMonitorWithPercentage, determineState, statusColor }; }; export { useMonitorUtils }; diff --git a/client/src/Pages/Uptime/Configure/index.jsx b/client/src/Pages/Uptime/Configure/index.jsx index f6c08ce60..ad68c1032 100644 --- a/client/src/Pages/Uptime/Configure/index.jsx +++ b/client/src/Pages/Uptime/Configure/index.jsx @@ -214,14 +214,7 @@ const Configure = () => { setIsNotificationModalOpen(false); }; - const statusColor = { - up: theme.palette.success.main, - down: theme.palette.error.main, - paused: theme.palette.error.main, - pending: theme.palette.warning.main, - }; - - const { determineState } = useMonitorUtils(); + const { determineState, statusColor } = useMonitorUtils(); const { t } = useTranslation();