modify dispatch action to handle editing
This commit is contained in:
1 parent
6b15a5814d
commit
b1029c9cec
1 file changed
+8
-3
@@ -179,12 +179,17 @@ const CreateInfrastructureMonitor = () => {
|
|||||||
thresholds,
|
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") {
|
if (action.meta.requestStatus === "fulfilled") {
|
||||||
createToast({ body: "Infrastructure monitor created successfully!" });
|
createToast({
|
||||||
|
body: isCreate ? "Infrastructure monitor created successfully!" : "Infrastructure monitor updated successfully!",
|
||||||
|
});
|
||||||
navigate("/infrastructure");
|
navigate("/infrastructure");
|
||||||
} else {
|
} else {
|
||||||
createToast({ body: "Failed to create monitor." });
|
createToast({ body: "Failed to save monitor." });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user