mirror of
https://github.com/bluewave-labs/Checkmate.git
synced 2026-05-18 23:48:43 -05:00
Fix: One source of truth
This commit is contained in:
@@ -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