- WIP Replace Field with TextInput , HttpAdornment seems not working
This commit is contained in:
1 parent
df36f873ae
commit
5df7ddbe0f
1 file changed
+36
-38
@@ -3,11 +3,9 @@ import { Button, Box, Stack, Typography } from "@mui/material";
|
|||||||
import { ConfigBox } from "../../../Pages/Settings/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 TabPanel from "@mui/lab/TabPanel";
|
import TabPanel from "@mui/lab/TabPanel";
|
||||||
import Field from "../../Inputs/Field";
|
import TextInput from "../../Inputs/TextInput";
|
||||||
import ImageField from "../../Inputs/Image";
|
import ImageField from "../../Inputs/Image";
|
||||||
import { setMode, setTimezone } from "../../../Features/UI/uiSlice";
|
|
||||||
import timezones from "../../../Utils/timezones.json";
|
import timezones from "../../../Utils/timezones.json";
|
||||||
import Select from "../../Inputs/Select"
|
import Select from "../../Inputs/Select"
|
||||||
import { logoImageValidation, publicPageGeneralSettingsValidation } from "../../../Validation/validation"
|
import { logoImageValidation, publicPageGeneralSettingsValidation } from "../../../Validation/validation"
|
||||||
@@ -15,10 +13,10 @@ import { buildErrors } from "../../../Validation/error";
|
|||||||
import { formatBytes } from "../../../Utils/fileUtils";
|
import { formatBytes } from "../../../Utils/fileUtils";
|
||||||
import ProgressUpload from "../../ProgressBars";
|
import ProgressUpload from "../../ProgressBars";
|
||||||
import ImageIcon from "@mui/icons-material/Image";
|
import ImageIcon from "@mui/icons-material/Image";
|
||||||
|
import { HttpAdornment } from "../../Inputs/TextInput/Adornments";
|
||||||
|
|
||||||
const GeneralSettingsPanel = () => {
|
const GeneralSettingsPanel = () => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const dispatch = useDispatch();
|
|
||||||
const [errors, setErrors] = useState({});
|
const [errors, setErrors] = useState({});
|
||||||
const [logo, setLogo] = useState();
|
const [logo, setLogo] = useState();
|
||||||
const [progress, setProgress] = useState({ value: 0, isLoading: false });
|
const [progress, setProgress] = useState({ value: 0, isLoading: false });
|
||||||
@@ -170,7 +168,7 @@ const GeneralSettingsPanel = () => {
|
|||||||
</Stack>
|
</Stack>
|
||||||
</Box>
|
</Box>
|
||||||
<Stack gap={theme.spacing(6)}>
|
<Stack gap={theme.spacing(6)}>
|
||||||
<Field
|
<TextInput
|
||||||
id="companyName"
|
id="companyName"
|
||||||
type="text"
|
type="text"
|
||||||
label="Company name"
|
label="Company name"
|
||||||
@@ -179,20 +177,19 @@ const GeneralSettingsPanel = () => {
|
|||||||
onBlur={handleBlur}
|
onBlur={handleBlur}
|
||||||
error={errors["companyName"]}
|
error={errors["companyName"]}
|
||||||
/>
|
/>
|
||||||
<Field
|
<TextInput
|
||||||
id="url"
|
id="url"
|
||||||
type="url"
|
type="url"
|
||||||
label="SubURL"
|
label="SubURL"
|
||||||
placeholder={""}
|
|
||||||
value={localData.url}
|
value={localData.url}
|
||||||
prefix={"http://uptimegenie.com/"}
|
startAdornment={<HttpAdornment https={true} />}
|
||||||
|
//prefix={"http://uptimegenie.com/"}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
onBlur={handleBlur}
|
onBlur={handleBlur}
|
||||||
error={errors["url"]}
|
error={errors["url"]}
|
||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
</ConfigBox>
|
</ConfigBox>
|
||||||
|
|
||||||
<ConfigBox>
|
<ConfigBox>
|
||||||
<Box>
|
<Box>
|
||||||
<Stack gap={theme.spacing(6)}>
|
<Stack gap={theme.spacing(6)}>
|
||||||
@@ -212,10 +209,9 @@ const GeneralSettingsPanel = () => {
|
|||||||
items={timezones}
|
items={timezones}
|
||||||
error={errors["display-timezone"]}
|
error={errors["display-timezone"]}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<ImageField
|
<ImageField
|
||||||
id="logo"
|
id="logo"
|
||||||
src={localData.logo?.src??logo?.src}
|
src={localData.logo?.src ?? logo?.src}
|
||||||
loading={progress.isLoading && progress.value !== 100}
|
loading={progress.isLoading && progress.value !== 100}
|
||||||
onChange={handleLogo}
|
onChange={handleLogo}
|
||||||
/>
|
/>
|
||||||
@@ -231,34 +227,36 @@ const GeneralSettingsPanel = () => {
|
|||||||
) : (
|
) : (
|
||||||
""
|
""
|
||||||
)}
|
)}
|
||||||
<Stack
|
{logo?.src && (
|
||||||
direction="row"
|
<Stack
|
||||||
mt={theme.spacing(10)}
|
direction="row"
|
||||||
gap={theme.spacing(5)}
|
mt={theme.spacing(10)}
|
||||||
justifyContent="flex-end"
|
gap={theme.spacing(5)}
|
||||||
>
|
justifyContent="flex-end"
|
||||||
<Button
|
|
||||||
variant="text"
|
|
||||||
color="info"
|
|
||||||
onClick={removeLogo}
|
|
||||||
>
|
>
|
||||||
Remove
|
<Button
|
||||||
</Button>
|
variant="text"
|
||||||
<Button
|
color="info"
|
||||||
variant="contained"
|
onClick={removeLogo}
|
||||||
color="primary"
|
>
|
||||||
onClick={handleUpdateLogo}
|
Remove
|
||||||
disabled={
|
</Button>
|
||||||
(Object.keys(errors).length !== 0 && errors?.logo) ||
|
<Button
|
||||||
progress.value !== 100
|
variant="contained"
|
||||||
? true
|
color="primary"
|
||||||
: false
|
onClick={handleUpdateLogo}
|
||||||
}
|
disabled={
|
||||||
>
|
(Object.keys(errors).length !== 0 && errors?.logo) ||
|
||||||
Update
|
progress.value !== 100
|
||||||
</Button>
|
? true
|
||||||
</Stack>
|
: false
|
||||||
<Field
|
}
|
||||||
|
>
|
||||||
|
Update
|
||||||
|
</Button>
|
||||||
|
</Stack>
|
||||||
|
)}
|
||||||
|
<TextInput
|
||||||
id="color"
|
id="color"
|
||||||
label="Color"
|
label="Color"
|
||||||
value={localData.color}
|
value={localData.color}
|
||||||
|
|||||||
Reference in new issue
Block a user