- 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 { Box, Stack, Typography } from "@mui/material";
import { ConfigBox } from "../../../Pages/Monitors/styled";
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";
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();
//redux state
const { user, authToken, isLoading } = useSelector((state) => state.auth);
const [error, setError] = useState("");
// Local state for form data, errors, and file handling
const [localData, setLocalData] = useState({
});
const [localData, setLocalData] = useState({});
const [errors, setErrors] = 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 handleChange = () => {};
const handleBlur = () => {};
const handlePicture = (event) => {
const pic = event.target.files[0];
};
return (
<TabPanel
value="general settings"
@@ -33,33 +50,110 @@ const GeneralSettingsPanel = () => {
},
}}
>
<Stack
component="form"
className="status-general-settings-form"
onSubmit={handleSubmit}
noValidate
spellCheck="false"
gap={theme.spacing(12)}
mt={theme.spacing(6)}
>
<ConfigBox>
<Box>
<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)}>
<Typography component="h2">Access</Typography>
<Typography component="p">
If your status page is ready, you can mark it as published.
</Typography>
<Checkbox
id="published-to-public"
label={`Published and visible to the public`}
isChecked={false}
value={"dd"}
onChange={handleChange}
onBlur={handleBlur}
/>
</Stack>
</Box>
<Checkbox
id="published-to-public"
label={`Published and visible to the public`}
onChange={(e) => handleChange(e)}
onBlur={handleBlur}
/>
</ConfigBox>
</Stack>
</TabPanel>
</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"
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 { useNavigate } from "react-router";
import { useSelector } from "react-redux";
import { Box, Tab, useTheme } from "@mui/material";
import TabContext from "@mui/lab/TabContext";
import TabList from "@mui/lab/TabList";
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.
@@ -19,10 +21,14 @@ const CreateStatus = ({ open = "general settings" }) => {
const handleTabChange = (event, newTab) => {
navigate(`/status/${newTab}`);
};
const { user } = useSelector((state) => state.auth);
const requiredRoles = ["superadmin", "admin"];
let tabList = ["General Settings", "Contents"];
const handlePicture = (event) => {}
const handleSubmit = () => {};
const handleChange = () => {};
const handleBlur = () => {};
return (
<Box