Updated UseEffect

This commit is contained in:
singh-kanwarpreet committed 2025-07-30 18:30:04 +05:30
1 parent e04ac77ddd
commit d4ecb26ffe
1 file changed
+7 -3
@@ -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) => {