Files
Checkmate/client/src/Pages/StatusPage/Create/Components/Tabs/Content.jsx
T

100 lines
2.4 KiB
React
Raw Normal View History

2025-02-03 15:12:00 -08:00
// Components
import { Stack, Typography } from "@mui/material";
2025-02-02 21:26:48 -08:00
import { TabPanel } from "@mui/lab";
2025-02-03 15:12:00 -08:00
import MonitorList from "../MonitorList";
import Search from "../../../../../Components/Inputs/Search";
import Checkbox from "../../../../../Components/Inputs/Checkbox";
// Utils
import { useState } from "react";
import { useTheme } from "@emotion/react";
2025-03-17 01:16:42 +05:30
import { useTranslation } from "react-i18next";
import ConfigStack from "./ConfigStack";
2025-02-03 15:12:00 -08:00
const Content = ({
tabValue,
form,
monitors,
handleFormChange,
errors,
selectedMonitors,
setSelectedMonitors,
}) => {
// Local state
const [search, setSearch] = useState("");
// Handlers
const handleMonitorsChange = (selectedMonitors) => {
handleFormChange({
target: { name: "monitors", value: selectedMonitors.map((monitor) => monitor._id) },
});
setSelectedMonitors(selectedMonitors);
};
// Utils
const theme = useTheme();
2025-03-17 01:16:42 +05:30
const { t } = useTranslation();
2025-02-02 21:26:48 -08:00
return (
<TabPanel value={tabValue}>
2025-02-03 15:12:00 -08:00
<Stack gap={theme.spacing(10)}>
<ConfigStack
2025-03-17 01:16:42 +05:30
title={t("statusPageCreateTabsContent")}
description={t("statusPageCreateTabsContentDescription")}
>
2025-02-03 15:12:00 -08:00
<Stack>
<Stack
direction="row"
justifyContent="space-between"
>
<Search
options={monitors}
multiple={true}
filteredBy="name"
value={selectedMonitors}
inputValue={search}
handleInputChange={setSearch}
handleChange={handleMonitorsChange}
/>
</Stack>
<Typography
component="span"
className="input-error"
color={theme.palette.error.main}
sx={{
opacity: 0.8,
}}
>
{errors["monitors"]}
</Typography>
<MonitorList
selectedMonitors={selectedMonitors}
setSelectedMonitors={handleMonitorsChange}
/>
</Stack>
</ConfigStack>
<ConfigStack
2025-03-17 01:16:42 +05:30
title={t("features")}
description={t("statusPageCreateTabsContentFeaturesDescription")}
>
<Stack>
2025-02-03 15:12:00 -08:00
<Checkbox
id="showCharts"
name="showCharts"
2025-03-17 01:16:42 +05:30
label={t("showCharts")}
2025-02-03 15:12:00 -08:00
isChecked={form.showCharts}
onChange={handleFormChange}
/>
<Checkbox
id="showUptimePercentage"
name="showUptimePercentage"
2025-03-17 01:16:42 +05:30
label={t("showUptimePercentage")}
2025-02-03 15:12:00 -08:00
isChecked={form.showUptimePercentage}
onChange={handleFormChange}
/>
</Stack>
</ConfigStack>
2025-02-02 21:26:48 -08:00
</Stack>
</TabPanel>
);
};
export default Content;