Fix: One source of truth

This commit is contained in:
Br0wnHammer
2026-01-21 02:02:16 +05:30
parent 6101fe1bfa
commit dd259fea89
2 changed files with 13 additions and 5 deletions
+7 -2
View File
@@ -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);
}
+6 -3
View File
@@ -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