Fix: One source of truth
This commit is contained in:
1 parent
6101fe1bfa
commit
dd259fea89
2 files changed
+13
-5
No files matched your search
@@ -412,14 +412,19 @@ export const usePauseMonitor = () => {
|
||||
try {
|
||||
setIsLoading(true);
|
||||
const res = await networkService.pauseMonitorById({ monitorId });
|
||||
const updatedMonitor = res.data.data;
|
||||
createToast({
|
||||
body: res.data.data.isActive
|
||||
body: updatedMonitor.isActive
|
||||
? "Monitor resumed successfully"
|
||||
: "Monitor paused successfully",
|
||||
});
|
||||
triggerUpdate();
|
||||
if (triggerUpdate) {
|
||||
triggerUpdate();
|
||||
}
|
||||
return updatedMonitor;
|
||||
} catch (error) {
|
||||
setError(error);
|
||||
return null;
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
|
||||
@@ -284,8 +284,10 @@ const UptimeCreate = ({ isClone = false }) => {
|
||||
};
|
||||
|
||||
const handlePause = async () => {
|
||||
await pauseMonitor({ monitorId, triggerUpdate });
|
||||
setMonitor((prev) => ({ ...prev, isActive: !prev.isActive }));
|
||||
const updatedMonitor = await pauseMonitor({ monitorId });
|
||||
if (updatedMonitor) {
|
||||
setMonitor((prev) => ({ ...prev, isActive: updatedMonitor.isActive }));
|
||||
}
|
||||
};
|
||||
|
||||
const handleRemove = async (event) => {
|
||||
@@ -425,7 +427,8 @@ const UptimeCreate = ({ isClone = false }) => {
|
||||
<Button
|
||||
variant="contained"
|
||||
color="secondary"
|
||||
loading={isBusy}
|
||||
loading={isPausing}
|
||||
disabled={isBusy}
|
||||
startIcon={
|
||||
monitor?.isActive ? (
|
||||
<Icon
|
||||
|
||||
Reference in new issue
Block a user