2024-11-26 16:10:55 -05:00
|
|
|
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";
|
2024-11-26 16:10:55 -05:00
|
|
|
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"
|
2024-11-26 16:10:55 -05:00
|
|
|
|
|
|
|
|
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-26 16:10:55 -05:00
|
|
|
|
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-26 16:10:55 -05:00
|
|
|
|
2024-11-27 21:24:52 -05:00
|
|
|
|
|
|
|
|
const handleSubmit = () => {};
|
2024-11-26 16:10:55 -05:00
|
|
|
|
|
|
|
|
const handleBlur = () => {};
|
2024-11-27 21:24:52 -05:00
|
|
|
|
|
|
|
|
const handlePicture = (event) => {
|
|
|
|
|
const pic = event.target.files[0];
|
|
|
|
|
};
|
|
|
|
|
|
2024-11-26 16:10:55 -05:00
|
|
|
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>
|
2024-11-26 16:10:55 -05:00
|
|
|
<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" },
|
|
|
|
|
]}
|
|
|
|
|
/>
|
2024-11-26 16:10:55 -05:00
|
|
|
</Stack>
|
2024-11-27 21:24:52 -05:00
|
|
|
</ConfigBox>
|
|
|
|
|
</Stack>
|
|
|
|
|
</TabPanel>
|
2024-11-26 16:10:55 -05:00
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default GeneralSettingsPanel;
|