Fix: updateTrigger val

This commit is contained in:
Br0wnHammer committed 2026-01-21 18:47:38 +05:30
1 parent dd259fea89
commit b34dbec3cf
2 files changed
+11 -19

No files matched your search

+2 -7
View File
@@ -412,19 +412,14 @@ 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: updatedMonitor.isActive body: res.data.data.isActive
? "Monitor resumed successfully" ? "Monitor resumed successfully"
: "Monitor paused successfully", : "Monitor paused successfully",
}); });
if (triggerUpdate) { triggerUpdate();
triggerUpdate();
}
return updatedMonitor;
} catch (error) { } catch (error) {
setError(error); setError(error);
return null;
} finally { } finally {
setIsLoading(false); setIsLoading(false);
} }
+9 -12
View File
@@ -80,13 +80,13 @@ const UptimeCreate = ({ isClone = false }) => {
const [isFetchingMonitor] = useFetchMonitorById({ const [isFetchingMonitor] = useFetchMonitorById({
monitorId, monitorId,
setMonitor, setMonitor,
updateTrigger: true, updateTrigger,
}); });
// Fetch games // Fetch games
const [isFetchingGames] = useFetchMonitorGames({ const [isFetchingGames] = useFetchMonitorGames({
setGames, setGames,
triggerUpdate: true, updateTrigger,
}); });
// Combine the loading states // Combine the loading states
@@ -283,13 +283,6 @@ const UptimeCreate = ({ isClone = false }) => {
})); }));
}; };
const handlePause = async () => {
const updatedMonitor = await pauseMonitor({ monitorId });
if (updatedMonitor) {
setMonitor((prev) => ({ ...prev, isActive: updatedMonitor.isActive }));
}
};
const handleRemove = async (event) => { const handleRemove = async (event) => {
event.preventDefault(); event.preventDefault();
const TEMP_MONITOR = { id: monitor.id }; const TEMP_MONITOR = { id: monitor.id };
@@ -427,8 +420,7 @@ const UptimeCreate = ({ isClone = false }) => {
<Button <Button
variant="contained" variant="contained"
color="secondary" color="secondary"
loading={isPausing} loading={isBusy}
disabled={isBusy}
startIcon={ startIcon={
monitor?.isActive ? ( monitor?.isActive ? (
<Icon <Icon
@@ -442,7 +434,12 @@ const UptimeCreate = ({ isClone = false }) => {
/> />
) )
} }
onClick={handlePause} onClick={() => {
pauseMonitor({
monitorId: monitor?.id,
triggerUpdate,
});
}}
> >
{monitor?.isActive ? t("pause") : t("resume")} {monitor?.isActive ? t("pause") : t("resume")}
</Button> </Button>