From d4ecb26ffe8b2de2f77f7e099a8379b4cf512266 Mon Sep 17 00:00:00 2001 From: singh-kanwarpreet Date: Wed, 30 Jul 2025 18:30:04 +0530 Subject: [PATCH] Updated UseEffect --- client/src/Pages/Infrastructure/Create/index.jsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/client/src/Pages/Infrastructure/Create/index.jsx b/client/src/Pages/Infrastructure/Create/index.jsx index 3159a3529..9b8f4f767 100644 --- a/client/src/Pages/Infrastructure/Create/index.jsx +++ b/client/src/Pages/Infrastructure/Create/index.jsx @@ -93,8 +93,8 @@ const CreateInfrastructureMonitor = () => { // Populate form fields if editing useEffect(() => { - if (!isCreate || globalSettingsLoading) return; - const globalThresholds = globalSettings?.data?.settings?.globalThresholds || {}; + if (monitor == undefined && (!isCreate || globalSettingsLoading)) return; + const globalThresholds = globalSettings?.data?.settings?.globalThresholds; // Define default empty string for all thresholds const defaultThresholds = { @@ -106,6 +106,10 @@ const CreateInfrastructureMonitor = () => { setInfrastructureMonitor((prev) => ({ ...prev, + url: monitor != undefined ? monitor.url.replace(/^https?:\/\//, "") : "", + name: monitor != undefined ? monitor.name || "" : "", + notifications: monitor != undefined ? monitor.notifications : [], + interval: monitor != undefined ? monitor.interval / MS_PER_MINUTE : 0.25, cpu: globalThresholds.cpu != null, usage_cpu: globalThresholds.cpu != null @@ -130,7 +134,7 @@ const CreateInfrastructureMonitor = () => { ? globalThresholds.temperature.toString() : defaultThresholds.temperature, })); - }, [isCreate, globalSettings]); + }, [isCreate, globalSettings, monitor, globalSettingsLoading]); // Handlers const onSubmit = async (event) => {