Changes based on review
This commit is contained in:
1 parent
56ddb374d0
commit
b191cf36a7
1 file changed
+8
-14
@@ -3,6 +3,7 @@ import { useSelector, useDispatch } from "react-redux";
|
|||||||
import { useTheme } from "@emotion/react";
|
import { useTheme } from "@emotion/react";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { createToast } from "../../../Utils/toastUtils";
|
import { createToast } from "../../../Utils/toastUtils";
|
||||||
|
import { logger } from "../../../Utils/Logger";
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
IconButton,
|
IconButton,
|
||||||
@@ -47,24 +48,20 @@ const ActionsMenu = ({ monitor, isAdmin, updateCallback }) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handlePause = async (event) => {
|
const handlePause = async () => {
|
||||||
try {
|
try {
|
||||||
const action = await dispatch(
|
const action = await dispatch(
|
||||||
pauseUptimeMonitor({ authToken, monitorId: monitor._id })
|
pauseUptimeMonitor({ authToken, monitorId: monitor._id })
|
||||||
);
|
);
|
||||||
if (pauseUptimeMonitor.fulfilled.match(action)) {
|
if (pauseUptimeMonitor.fulfilled.match(action)) {
|
||||||
updateCallback();
|
updateCallback();
|
||||||
//window.location.reload();
|
const state = action?.payload?.data.isActive === false ? "paused" : "resumed";
|
||||||
if (action.payload?.isActive === false){
|
createToast({ body: `Monitor ${state} successfully.` });
|
||||||
createToast({ body: "Monitor paused successfully." });
|
|
||||||
}else{
|
|
||||||
createToast({ body: "Monitor resumed successfully." });
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
throw new Error(action.error.message);
|
throw new Error(action?.error?.message ?? "Failed to pause monitor.");
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error pausing monitor:", monitor._id, error);
|
logger.error("Error pausing monitor:", monitor._id, error);
|
||||||
createToast({ body: "Failed to pause monitor." });
|
createToast({ body: "Failed to pause monitor." });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -187,11 +184,8 @@ const ActionsMenu = ({ monitor, isAdmin, updateCallback }) => {
|
|||||||
handlePause(e);
|
handlePause(e);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{monitor?.isActive ? (
|
{monitor?.isActive === true ? "Pause" : "Resume"}
|
||||||
"Pause"
|
|
||||||
) : (
|
|
||||||
"Resume"
|
|
||||||
)}
|
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
)}
|
)}
|
||||||
{isAdmin && (
|
{isAdmin && (
|
||||||
|
|||||||
Reference in new issue
Block a user