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 {
|
try {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
const res = await networkService.pauseMonitorById({ monitorId });
|
const res = await networkService.pauseMonitorById({ monitorId });
|
||||||
|
const updatedMonitor = res.data.data;
|
||||||
createToast({
|
createToast({
|
||||||
body: res.data.data.isActive
|
body: updatedMonitor.isActive
|
||||||
? "Monitor resumed successfully"
|
? "Monitor resumed successfully"
|
||||||
: "Monitor paused successfully",
|
: "Monitor paused successfully",
|
||||||
});
|
});
|
||||||
triggerUpdate();
|
if (triggerUpdate) {
|
||||||
|
triggerUpdate();
|
||||||
|
}
|
||||||
|
return updatedMonitor;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setError(error);
|
setError(error);
|
||||||
|
return null;
|
||||||
} finally {
|
} finally {
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -284,8 +284,10 @@ const UptimeCreate = ({ isClone = false }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handlePause = async () => {
|
const handlePause = async () => {
|
||||||
await pauseMonitor({ monitorId, triggerUpdate });
|
const updatedMonitor = await pauseMonitor({ monitorId });
|
||||||
setMonitor((prev) => ({ ...prev, isActive: !prev.isActive }));
|
if (updatedMonitor) {
|
||||||
|
setMonitor((prev) => ({ ...prev, isActive: updatedMonitor.isActive }));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleRemove = async (event) => {
|
const handleRemove = async (event) => {
|
||||||
@@ -425,7 +427,8 @@ const UptimeCreate = ({ isClone = false }) => {
|
|||||||
<Button
|
<Button
|
||||||
variant="contained"
|
variant="contained"
|
||||||
color="secondary"
|
color="secondary"
|
||||||
loading={isBusy}
|
loading={isPausing}
|
||||||
|
disabled={isBusy}
|
||||||
startIcon={
|
startIcon={
|
||||||
monitor?.isActive ? (
|
monitor?.isActive ? (
|
||||||
<Icon
|
<Icon
|
||||||
|
|||||||
Reference in new issue
Block a user