- WIP general setting panel

This commit is contained in:
Shemy Gan committed 2024-12-06 09:59:36 -05:00
1 parent 4345d6988b
commit 5adffd8c1e
2 files changed
+138 -38

No files matched your search

@@ -1,29 +1,46 @@
import { useState, useRef } from "react"; import { useState, useRef } from "react";
import { Box, Stack, Typography } from "@mui/material"; import { Box, Stack, Typography } from "@mui/material";
import { ConfigBox } from "../../../Pages/Monitors/styled"; import { ConfigBox } from "../../../Pages/Settings/styled";
import Checkbox from "../../Inputs/Checkbox"; import Checkbox from "../../Inputs/Checkbox";
import { useTheme } from "@emotion/react"; import { useTheme } from "@emotion/react";
import { useDispatch, useSelector } from "react-redux"; import { useDispatch, useSelector } from "react-redux";
import TabPanel from "@mui/lab/TabPanel"; import TabPanel from "@mui/lab/TabPanel";
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 GeneralSettingsPanel = () => {
const theme = useTheme(); const theme = useTheme();
const dispatch = useDispatch(); const dispatch = useDispatch();
const [error, setError] = useState("");
//redux state
const { user, authToken, isLoading } = useSelector((state) => state.auth);
// Local state for form data, errors, and file handling // Local state for form data, errors, and file handling
const [localData, setLocalData] = useState({ const [localData, setLocalData] = useState({});
});
const [errors, setErrors] = useState({}); const [errors, setErrors] = useState({});
const [file, setFile] = useState(); const [file, setFile] = useState();
const { timezone } = useSelector((state) => state.ui);
const { mode } = useSelector((state) => state.ui);
const handleChange = (event, appendedId) => {
event.preventDefault();
const { value, id } = event.target;
let name = appendedId ?? idMap[id] ?? id;
setLocalData((prev) => ({
...prev,
[name]: value,
}));
}
const handleSubmit = () => {}; const handleSubmit = () => {};
const handleChange = () => {};
const handleBlur = () => {}; const handleBlur = () => {};
const handlePicture = (event) => {
const pic = event.target.files[0];
};
return ( return (
<TabPanel <TabPanel
value="general settings" value="general settings"
@@ -33,33 +50,110 @@ const GeneralSettingsPanel = () => {
}, },
}} }}
> >
<Stack <Stack
component="form" component="form"
className="status-general-settings-form" className="status-general-settings-form"
onSubmit={handleSubmit} onSubmit={handleSubmit}
noValidate noValidate
spellCheck="false" spellCheck="false"
gap={theme.spacing(12)} gap={theme.spacing(12)}
mt={theme.spacing(6)} mt={theme.spacing(6)}
> >
<ConfigBox> <ConfigBox>
<Box> <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)}> <Stack gap={theme.spacing(6)}>
<Typography component="h2">Access</Typography> <Checkbox
<Typography component="p"> id="published-to-public"
If your status page is ready, you can mark it as published. label={`Published and visible to the public`}
</Typography> isChecked={false}
value={"dd"}
onChange={handleChange}
onBlur={handleBlur}
/>
</Stack> </Stack>
</Box> </ConfigBox>
<Checkbox
id="published-to-public" <ConfigBox>
label={`Published and visible to the public`} <Box>
onChange={(e) => handleChange(e)} <Stack gap={theme.spacing(6)}>
onBlur={handleBlur} <Typography component="h2">Basic Information</Typography>
/> <Typography component="p">
</ConfigBox> Define company name and the subdomain that your status page points to.
</Stack> </Typography>
</TabPanel> </Stack>
</Box>
<Stack gap={theme.spacing(6)}>
<Field
id="company-name"
type="text"
label="Company name"
value={localData.name}
/>
<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)}>
<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"
value={localData.mode}
onChange={(e) => {
dispatch(setMode(e.target.value));
}}
items={[
{ _id: "light", name: "Light" },
{ _id: "dark", name: "Dark" },
]}
/>
</Stack>
</ConfigBox>
</Stack>
</TabPanel>
); );
}; };
+10 -4
View File
@@ -1,10 +1,12 @@
import PropTypes from "prop-types"; import PropTypes from "prop-types";
import { useNavigate } from "react-router"; import { useNavigate } from "react-router";
import { useSelector } from "react-redux";
import { Box, Tab, useTheme } from "@mui/material"; import { Box, Tab, useTheme } from "@mui/material";
import TabContext from "@mui/lab/TabContext"; import TabContext from "@mui/lab/TabContext";
import TabList from "@mui/lab/TabList"; import TabList from "@mui/lab/TabList";
import GeneralSettingsPanel from "../../../Components/TabPanels/Status/GeneralSettingsPanel"; import GeneralSettingsPanel from "../../../Components/TabPanels/Status/GeneralSettingsPanel";
import ImageField from "../../../Components/Inputs/Image";
import Checkbox from "../../../Components/Inputs/Checkbox";
/** /**
* CreateStatus page renders a page with tabs for general settings and contents. * CreateStatus page renders a page with tabs for general settings and contents.
@@ -19,10 +21,14 @@ const CreateStatus = ({ open = "general settings" }) => {
const handleTabChange = (event, newTab) => { const handleTabChange = (event, newTab) => {
navigate(`/status/${newTab}`); navigate(`/status/${newTab}`);
}; };
const { user } = useSelector((state) => state.auth);
const requiredRoles = ["superadmin", "admin"];
let tabList = ["General Settings", "Contents"]; let tabList = ["General Settings", "Contents"];
const handlePicture = (event) => {}
const handleSubmit = () => {};
const handleChange = () => {};
const handleBlur = () => {};
return ( return (
<Box <Box