diff --git a/Client/src/Components/Dialog/index.jsx b/Client/src/Components/Dialog/index.jsx
new file mode 100644
index 000000000..a4b3e282d
--- /dev/null
+++ b/Client/src/Components/Dialog/index.jsx
@@ -0,0 +1,80 @@
+import LoadingButton from "@mui/lab/LoadingButton";
+import { Button, Modal, Stack, Typography } from "@mui/material";
+import PropTypes from "prop-types";
+const Dialog = ({ arialabelledby, ariadescribedby,
+ open, onClose, bdy1, yBtnLbl, yBtnOnClick, nBtnLbl, nBtnOnClick, theme, isLoading, bdy2 }) => {
+ return
+
+
+ {bdy1}
+
+ {bdy2 &&
+ {bdy2}
+ }
+
+
+
+ {yBtnLbl}
+
+
+
+
+}
+
+Dialog.prototypes = {
+ arialabelledby: PropTypes.string.isRequired,
+ ariadescribedby: PropTypes.string.isRequired,
+ open: PropTypes.bool.isRequired,
+ onClose: PropTypes.func.isRequired,
+ bdy1: PropTypes.string.isRequired,
+ nBtnLbl: PropTypes.string.isRequired,
+ nBtnOnClick: PropTypes.func.isRequired,
+ yBtnLbl: PropTypes.string.isRequired,
+ yBtnOnClick: PropTypes.func.isRequired,
+ theme: PropTypes.object.isRequired,
+ isLoading: PropTypes.bool.isRequired,
+ bdy2: PropTypes.string
+}
+
+export default Dialog
\ No newline at end of file
diff --git a/Client/src/Pages/Settings/index.jsx b/Client/src/Pages/Settings/index.jsx
index 9aba1c792..cb2e3e6d1 100644
--- a/Client/src/Pages/Settings/index.jsx
+++ b/Client/src/Pages/Settings/index.jsx
@@ -22,6 +22,7 @@ import { ConfigBox } from "./styled";
import { networkService } from "../../main";
import { settingsValidation } from "../../Validation/validation";
import { useNavigate } from "react-router";
+import Dialog from "../../Components/Dialog"
const SECONDS_PER_DAY = 86400;
@@ -37,6 +38,7 @@ const Settings = ({ isAdmin }) => {
ttl: checkTTL ? (checkTTL / SECONDS_PER_DAY).toString() : 0,
});
const [errors, setErrors] = useState({});
+ const [isOpen, setIsOpen] = useState({delMntrs: false, delSts: false});
const dispatch = useDispatch();
const navigate = useNavigate();
@@ -118,6 +120,8 @@ const Settings = ({ isAdmin }) => {
} catch (error) {
logger.error(error);
createToast({ body: "Failed to clear stats" });
+ } finally {
+ setIsOpen({delMntrs: false, delSts:false})
}
};
@@ -146,6 +150,8 @@ const Settings = ({ isAdmin }) => {
} catch (error) {
logger.error(error);
createToast({ Body: "Failed to delete all monitors" });
+ } finally {
+ setIsOpen({ delMntrs: false, delSts: false })
}
};
@@ -202,17 +208,30 @@ const Settings = ({ isAdmin }) => {
/>
Clear all stats. This is irreversible.
- setIsOpen({delSts: true, delMntrs: false})}
sx={{ mt: theme.spacing(4) }}
>
Clear all stats
-
+
+
)}
{isAdmin && (
@@ -242,13 +261,26 @@ const Settings = ({ isAdmin }) => {
variant="contained"
color="error"
loading={isLoading || authIsLoading || checksIsLoading}
- onClick={handleDeleteAllMonitors}
+ onClick={()=>setIsOpen({delMntrs: true, delSts: false})}
sx={{ mt: theme.spacing(4) }}
>
Remove all monitors
+
)}
{isAdmin && (