modify dispatch action to handle editing

This commit is contained in:
Vishnu Sreekumaran Nair committed 2025-03-14 22:16:57 -04:00
1 parent 6b15a5814d
commit b1029c9cec
1 file changed
+8 -3
+8 -3
View File
@@ -179,12 +179,17 @@ const CreateInfrastructureMonitor = () => {
thresholds,
};
const action = await dispatch(createInfrastructureMonitor({ monitor: form }));
// Handle create or update
const action = isCreate
? await dispatch(createInfrastructureMonitor({ monitor: form }))
: await dispatch(updateInfrastructureMonitor({ monitorId, monitor: form }));
if (action.meta.requestStatus === "fulfilled") {
createToast({ body: "Infrastructure monitor created successfully!" });
createToast({
body: isCreate ? "Infrastructure monitor created successfully!" : "Infrastructure monitor updated successfully!",
});
navigate("/infrastructure");
} else {
createToast({ body: "Failed to create monitor." });
createToast({ body: "Failed to save monitor." });
}
};