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

146 lines
3.9 KiB
React
Raw Normal View History

2025-02-02 21:26:48 -08:00
// Components
import { Stack, Typography } from "@mui/material";
import { TabPanel } from "@mui/lab";
import ConfigBox from "../../../../../Components/ConfigBox";
import Checkbox from "../../../../../Components/Inputs/Checkbox";
import TextInput from "../../../../../Components/Inputs/TextInput";
import Select from "../../../../../Components/Inputs/Select";
import ImageField from "../../../../../Components/Inputs/Image";
import ColorPicker from "../../../../../Components/Inputs/ColorPicker";
import Progress from "../Progress";
2025-02-04 14:07:08 -08:00
2025-02-02 21:26:48 -08:00
// Utils
import { useTheme } from "@emotion/react";
import timezones from "../../../../../Utils/timezones.json";
2025-02-04 14:07:08 -08:00
import PropTypes from "prop-types";
2025-03-17 01:16:42 +05:30
import { useTranslation } from "react-i18next";
2025-02-02 21:26:48 -08:00
const TabSettings = ({
2025-02-10 13:49:54 -08:00
isCreate,
2025-02-02 21:26:48 -08:00
tabValue,
form,
handleFormChange,
handleImageChange,
progress,
removeLogo,
errors,
}) => {
// 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}>
<Stack gap={theme.spacing(10)}>
<ConfigBox>
<Stack>
2025-03-17 01:16:42 +05:30
<Typography component="h2">{t("access")}</Typography>
2025-02-02 21:26:48 -08:00
<Typography component="p">
2025-03-17 01:16:42 +05:30
{t("statusPageCreateSettings")}
2025-02-02 21:26:48 -08:00
</Typography>
</Stack>
<Stack gap={theme.spacing(18)}>
<Checkbox
id="publish"
name="isPublished"
2025-03-17 01:16:42 +05:30
label={t("statusPageCreateSettingsCheckboxLabel")}
2025-02-02 21:26:48 -08:00
isChecked={form.isPublished}
onChange={handleFormChange}
/>
</Stack>
</ConfigBox>
<ConfigBox>
<Stack gap={theme.spacing(6)}>
2025-03-17 01:16:42 +05:30
<Typography component="h2">{t("basicInformation")}</Typography>
2025-02-02 21:26:48 -08:00
<Typography component="p">
2025-03-17 01:16:42 +05:30
{t("statusPageCreateBasicInfoDescription")}
2025-02-02 21:26:48 -08:00
</Typography>
</Stack>
<Stack gap={theme.spacing(18)}>
<TextInput
id="companyName"
name="companyName"
type="text"
2025-03-17 01:16:42 +05:30
label={t("companyName")}
2025-02-02 21:26:48 -08:00
value={form.companyName}
onChange={handleFormChange}
helperText={errors["companyName"]}
error={errors["companyName"] ? true : false}
/>
<TextInput
id="url"
name="url"
type="url"
2025-02-10 13:49:54 -08:00
disabled={!isCreate}
2025-03-17 01:16:42 +05:30
label={t("statusPageCreateBasicInfoStatusPageAddress")}
2025-02-02 21:26:48 -08:00
value={form.url}
onChange={handleFormChange}
helperText={errors["url"]}
error={errors["url"] ? true : false}
2025-02-02 21:26:48 -08:00
/>
</Stack>
</ConfigBox>
<ConfigBox>
<Stack gap={theme.spacing(6)}>
2025-03-17 01:16:42 +05:30
<Typography component="h2">{t("timezone")}</Typography>
2025-02-02 21:26:48 -08:00
<Typography component="p">
2025-03-17 01:16:42 +05:30
{t("statusPageCreateSelectTimeZoneDescription")}
2025-02-02 21:26:48 -08:00
</Typography>
</Stack>
<Stack gap={theme.spacing(6)}>
<Select
id="timezone"
name="timezone"
2025-03-17 01:16:42 +05:30
label={t("settingsDisplayTimezone")}
2025-02-02 21:26:48 -08:00
items={timezones}
value={form.timezone}
onChange={handleFormChange}
/>
</Stack>
</ConfigBox>
<ConfigBox>
<Stack gap={theme.spacing(6)}>
2025-03-17 01:16:42 +05:30
<Typography component="h2">{t("settingsAppearance")}</Typography>
2025-02-02 21:26:48 -08:00
<Typography component="p">
2025-03-17 01:16:42 +05:30
{t("statusPageCreateAppearanceDescription")}
2025-02-02 21:26:48 -08:00
</Typography>
</Stack>
<Stack gap={theme.spacing(6)}>
<ImageField
id="logo"
2025-02-04 13:06:42 -08:00
src={form?.logo?.src}
2025-02-02 21:26:48 -08:00
isRound={false}
onChange={handleImageChange}
/>
<Progress
isLoading={progress.isLoading}
progressValue={progress.value}
logo={form.logo}
logoType={form.logo?.type}
removeLogo={removeLogo}
/>
<ColorPicker
id="color"
name="color"
value={form.color}
onChange={handleFormChange}
/>
</Stack>
</ConfigBox>
</Stack>
</TabPanel>
);
};
2025-02-04 14:07:08 -08:00
TabSettings.propTypes = {
2025-02-10 13:50:11 -08:00
isCreate: PropTypes.bool,
2025-02-04 14:07:08 -08:00
tabValue: PropTypes.string,
form: PropTypes.object,
handleFormChange: PropTypes.func,
handleImageChange: PropTypes.func,
progress: PropTypes.object,
removeLogo: PropTypes.func,
errors: PropTypes.object,
};
2025-02-02 21:26:48 -08:00
export default TabSettings;