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

106 lines
2.5 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 = ({ isAdmin, 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);
if (!isAdmin) {
return null;
}
2025-05-09 13:28:44 -07:00
return (
<>
<ConfigBox>
<Box>
2025-05-27 09:10:32 -07:00
<Typography
component="h1"
variant="h2"
>
2025-06-24 14:30:14 +08:00
{t("settingsPage.demoMonitorsSettings.title")}
</Typography>
<Typography sx={HEADER_SX}>
{t("settingsPage.demoMonitorsSettings.description")}
2025-05-27 09:10:32 -07:00
</Typography>
2025-05-09 13:28:44 -07:00
</Box>
<Box>
<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) }}
>
2025-06-24 14:30:14 +08:00
{t("settingsPage.demoMonitorsSettings.buttonAddMonitors")}
2025-05-09 13:28:44 -07:00
</Button>
</Box>
</ConfigBox>
<ConfigBox>
<Box>
2025-05-27 09:10:32 -07:00
<Typography
component="h1"
variant="h2"
>
2025-06-24 14:30:14 +08:00
{t("settingsPage.systemResetSettings.title")}
2025-05-27 09:10:32 -07:00
</Typography>
2025-05-09 13:28:44 -07:00
<Typography sx={{ mt: theme.spacing(2) }}>
2025-06-24 14:30:14 +08:00
{t("settingsPage.systemResetSettings.description")}
2025-05-09 13:28:44 -07:00
</Typography>
</Box>
<Box>
<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) }}
>
2025-06-24 14:30:14 +08:00
{t("settingsPage.systemResetSettings.buttonRemoveAllMonitors")}
2025-05-09 13:28:44 -07:00
</Button>
</Box>
<Dialog
open={isOpen}
theme={theme}
2025-06-24 14:30:14 +08:00
title={t("settingsPage.systemResetSettings.dialogTitle")}
2025-05-09 13:28:44 -07:00
onCancel={() => setIsOpen(false)}
2025-06-24 14:30:14 +08:00
confirmationButtonLabel={t("settingsPage.systemResetSettings.dialogConfirm")}
2025-05-09 13:28:44 -07:00
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 = {
isAdmin: PropTypes.bool,
2025-05-09 13:28:44 -07:00
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;