Files
Checkmate/client/src/Pages/Settings/SettingsDemoMonitors.jsx
T

90 lines
2.3 KiB
React
Raw Normal View History

2025-05-09 13:28:44 -07:00
import Box from "@mui/material/Box";
import Typography from "@mui/material/Typography";
import Button from "@mui/material/Button";
import ConfigBox from "../../Components/ConfigBox";
// Utils
import { useTheme } from "@emotion/react";
import { PropTypes } from "prop-types";
import { useTranslation } from "react-i18next";
import Dialog from "../../Components/Dialog";
import { useState } from "react";
2025-05-09 14:54:28 -07:00
const SettingsDemoMonitors = ({ HEADER_SX, handleChange, isLoading }) => {
2025-05-09 13:28:44 -07:00
const { t } = useTranslation();
const theme = useTheme();
// Local state
const [isOpen, setIsOpen] = useState(false);
return (
<>
<ConfigBox>
<Box>
<Typography component="h1">{t("settingsDemoMonitors")}</Typography>
2025-05-09 14:54:28 -07:00
<Typography sx={HEADER_SX}>{t("settingsDemoMonitorsDescription")}</Typography>
2025-05-09 13:28:44 -07:00
</Box>
<Box>
<Typography>{t("settingsAddDemoMonitors")}</Typography>
<Button
variant="contained"
color="accent"
2025-05-09 14:54:28 -07:00
loading={isLoading}
2025-05-09 13:28:44 -07:00
onClick={() => {
const syntheticEvent = {
target: {
name: "demo",
},
};
handleChange(syntheticEvent);
}}
sx={{ mt: theme.spacing(4) }}
>
{t("settingsAddDemoMonitorsButton")}
</Button>
</Box>
</ConfigBox>
<ConfigBox>
<Box>
<Typography component="h1">{t("settingsSystemReset")}</Typography>
<Typography sx={{ mt: theme.spacing(2) }}>
{t("settingsSystemResetDescription")}
</Typography>
</Box>
<Box>
<Typography>{t("settingsRemoveAllMonitors")}</Typography>
<Button
variant="contained"
color="error"
2025-05-09 14:54:28 -07:00
loading={isLoading}
2025-05-09 13:28:44 -07:00
onClick={() => setIsOpen(true)}
sx={{ mt: theme.spacing(4) }}
>
{t("settingsRemoveAllMonitorsButton")}
</Button>
</Box>
<Dialog
open={isOpen}
theme={theme}
title={t("settingsRemoveAllMonitorsDialogTitle")}
onCancel={() => setIsOpen(false)}
confirmationButtonLabel={t("settingsRemoveAllMonitorsDialogConfirm")}
onConfirm={() => {
const syntheticEvent = {
target: {
name: "deleteMonitors",
},
};
handleChange(syntheticEvent);
setIsOpen(false);
}}
2025-05-09 14:54:28 -07:00
isLoading={isLoading}
2025-05-09 13:28:44 -07:00
/>
</ConfigBox>
</>
);
};
SettingsDemoMonitors.propTypes = {
handleChange: PropTypes.func,
2025-05-09 14:54:28 -07:00
HEADER_SX: PropTypes.object,
2025-05-09 13:28:44 -07:00
};
export default SettingsDemoMonitors;