Files
Checkmate/Client/src/Components/TabPanels/Status/GeneralSettingsPanel.jsx
T

166 lines
4.1 KiB
React
Raw Normal View History

import { useState, useRef } from "react";
import { Box, Stack, Typography } from "@mui/material";
2024-11-27 21:24:52 -05:00
import { ConfigBox } from "../../../Pages/Settings/styled";
import Checkbox from "../../Inputs/Checkbox";
import { useTheme } from "@emotion/react";
import { useDispatch, useSelector } from "react-redux";
import TabPanel from "@mui/lab/TabPanel";
2024-11-27 21:24:52 -05:00
import Field from "../../Inputs/Field";
import ImageField from "../../Inputs/Image";
import { setMode, setTimezone } from "../../../Features/UI/uiSlice";
import timezones from "../../../Utils/timezones.json";
import Select from "../../Inputs/Select"
const GeneralSettingsPanel = () => {
const theme = useTheme();
const dispatch = useDispatch();
const [errors, setErrors] = useState({});
2024-11-28 10:43:45 -05:00
const [file, setFile] = useState();
// Local state for form data, errors, and file handling
const [localData, setLocalData] = useState({
companyName: "",
url: "",
timezone: "America/Toronto",
color: "#4169E1",
theme: "light",
//which fields matching below?
publish: false,
file: null
});
2024-11-27 21:24:52 -05:00
const handleChange = (event, appendedId) => {
event.preventDefault();
const { value, id } = event.target;
let name = appendedId ?? idMap[id] ?? id;
setLocalData((prev) => ({
...prev,
[name]: value,
}));
}
2024-11-27 21:24:52 -05:00
const handleSubmit = () => {};
const handleBlur = () => {};
2024-11-27 21:24:52 -05:00
const handlePicture = (event) => {
const pic = event.target.files[0];
};
return (
<TabPanel
value="general settings"
sx={{
"& h1, & p, & input": {
color: theme.palette.text.tertiary,
},
}}
>
2024-11-27 21:24:52 -05:00
<Stack
component="form"
className="status-general-settings-form"
onSubmit={handleSubmit}
noValidate
spellCheck="false"
gap={theme.spacing(12)}
mt={theme.spacing(6)}
>
<ConfigBox>
<Box>
<Stack gap={theme.spacing(6)}>
<Typography component="h2">Access</Typography>
<Typography component="p">
If your status page is ready, you can mark it as published.
</Typography>
</Stack>
</Box>
<Stack gap={theme.spacing(6)}>
<Checkbox
id="published-to-public"
label={`Published and visible to the public`}
2024-11-28 10:43:45 -05:00
isChecked={localData.publish}
value={localData.publish}
2024-11-27 21:24:52 -05:00
onChange={handleChange}
onBlur={handleBlur}
/>
</Stack>
</ConfigBox>
<ConfigBox>
<Box>
<Stack gap={theme.spacing(6)}>
<Typography component="h2">Basic Information</Typography>
<Typography component="p">
Define company name and the subdomain that your status page points to.
</Typography>
</Stack>
</Box>
<Stack gap={theme.spacing(6)}>
<Field
id="company-name"
type="text"
label="Company name"
2024-11-28 10:43:45 -05:00
value={localData.companyName}
2024-11-27 21:24:52 -05:00
/>
<Field
id="suburl"
type="url"
label="suburl"
placeholder={""}
value={localData.url}
prefix={"http://uptimegenie.com/"}
onChange={handleChange}
/>
</Stack>
</ConfigBox>
<ConfigBox>
<Box>
<Stack gap={theme.spacing(6)}>
<Typography component="h2">Appearance</Typography>
<Typography component="p">
Define the default look and feel of your public status page.
</Typography>
</Stack>
</Box>
<Stack gap={theme.spacing(6)}>
2024-11-27 21:24:52 -05:00
<Select
id="display-timezone"
label="Display timezone"
value={localData.timezone}
onChange={(e) => {
dispatch(setTimezone({ timezone: e.target.value }));
}}
items={timezones}
/>
<ImageField
id="update-logo-picture"
src={localData.src}
loading={true}
onChange={handlePicture}
/>
<Field
id="color"
label="Color"
value={localData.color}
/>
<Select
id="theme"
label="Theme"
2024-11-28 10:43:45 -05:00
value={localData.theme}
2024-11-27 21:24:52 -05:00
onChange={(e) => {
dispatch(setMode(e.target.value));
}}
items={[
{ _id: "light", name: "Light" },
{ _id: "dark", name: "Dark" },
]}
/>
</Stack>
2024-11-27 21:24:52 -05:00
</ConfigBox>
</Stack>
</TabPanel>
);
};
export default GeneralSettingsPanel;