refactor public status page
This commit is contained in:
1 parent
cc8d4bc98c
commit
dc3fc7628a
15 files changed
+605
-53
No files matched your search
@@ -47,19 +47,6 @@ const Content = ({
|
||||
direction="row"
|
||||
justifyContent="space-between"
|
||||
>
|
||||
{/* <Typography
|
||||
component="p"
|
||||
alignSelf={"center"}
|
||||
>
|
||||
{" "}
|
||||
Servers list{" "}
|
||||
</Typography>
|
||||
<Button
|
||||
variant="contained"
|
||||
color="accent"
|
||||
>
|
||||
Add new
|
||||
</Button> */}
|
||||
<Search
|
||||
options={monitors}
|
||||
multiple={true}
|
||||
|
||||
@@ -11,6 +11,7 @@ import Progress from "../Progress";
|
||||
// Utils
|
||||
import { useTheme } from "@emotion/react";
|
||||
import timezones from "../../../../../Utils/timezones.json";
|
||||
import { memo } from "react";
|
||||
|
||||
const TabSettings = ({
|
||||
tabValue,
|
||||
@@ -101,7 +102,7 @@ const TabSettings = ({
|
||||
<Stack gap={theme.spacing(6)}>
|
||||
<ImageField
|
||||
id="logo"
|
||||
src={form.logo?.src}
|
||||
src={form?.logo?.src}
|
||||
isRound={false}
|
||||
onChange={handleImageChange}
|
||||
/>
|
||||
|
||||
@@ -6,6 +6,7 @@ import Content from "./Content";
|
||||
|
||||
// Utils
|
||||
import PropTypes from "prop-types";
|
||||
|
||||
const Tabs = ({
|
||||
form,
|
||||
errors,
|
||||
@@ -70,7 +71,7 @@ Tabs.propTypes = {
|
||||
setSelectedMonitors: PropTypes.func,
|
||||
handleFormChange: PropTypes.func,
|
||||
handleImageChange: PropTypes.func,
|
||||
progress: PropTypes.number,
|
||||
progress: PropTypes.object,
|
||||
removeLogo: PropTypes.func,
|
||||
tab: PropTypes.number,
|
||||
setTab: PropTypes.func,
|
||||
|
||||
@@ -5,14 +5,13 @@ import GenericFallback from "../../../Components/GenericFallback";
|
||||
import SkeletonLayout from "./Components/Skeleton";
|
||||
//Utils
|
||||
import { useTheme } from "@emotion/react";
|
||||
import { useState, useRef } from "react";
|
||||
import { useState, useRef, useCallback } from "react";
|
||||
import { statusPageValidation } from "../../../Validation/validation";
|
||||
import { buildErrors } from "../../../Validation/error";
|
||||
import { useSelector } from "react-redux";
|
||||
import { useMonitorsFetch } from "./Hooks/useMonitorsFetch";
|
||||
import { useCreateStatusPage } from "./Hooks/useCreateStatusPage";
|
||||
import { createToast } from "../../../Utils/toastUtils";
|
||||
|
||||
import { useNavigate } from "react-router-dom";
|
||||
//Constants
|
||||
const TAB_LIST = ["General settings", "Contents"];
|
||||
|
||||
@@ -22,8 +21,6 @@ const ERROR_TAB_MAPPING = [
|
||||
];
|
||||
|
||||
const CreateStatusPage = () => {
|
||||
//Redux state
|
||||
const { authToken, user } = useSelector((state) => state.auth);
|
||||
//Local state
|
||||
const [tab, setTab] = useState(0);
|
||||
const [progress, setProgress] = useState({ value: 0, isLoading: false });
|
||||
@@ -31,7 +28,7 @@ const CreateStatusPage = () => {
|
||||
isPublished: false,
|
||||
companyName: "",
|
||||
url: "/status/public",
|
||||
logo: null,
|
||||
logo: undefined,
|
||||
timezone: "America/Toronto",
|
||||
color: "#4169E1",
|
||||
monitors: [],
|
||||
@@ -40,7 +37,6 @@ const CreateStatusPage = () => {
|
||||
});
|
||||
const [errors, setErrors] = useState({});
|
||||
const [selectedMonitors, setSelectedMonitors] = useState([]);
|
||||
|
||||
// Refs
|
||||
const intervalRef = useRef(null);
|
||||
|
||||
@@ -49,6 +45,7 @@ const CreateStatusPage = () => {
|
||||
const [monitors, isLoading, networkError] = useMonitorsFetch();
|
||||
const [createStatusPage, createSatusIsLoading, createStatusPageNetworkError] =
|
||||
useCreateStatusPage();
|
||||
const navigate = useNavigate();
|
||||
|
||||
// Handlers
|
||||
const handleFormChange = (e) => {
|
||||
@@ -78,7 +75,7 @@ const CreateStatusPage = () => {
|
||||
}));
|
||||
};
|
||||
|
||||
const handleImageChange = (event) => {
|
||||
const handleImageChange = useCallback((event) => {
|
||||
const img = event.target?.files?.[0];
|
||||
const newLogo = {
|
||||
src: URL.createObjectURL(img),
|
||||
@@ -100,7 +97,7 @@ const CreateStatusPage = () => {
|
||||
return { ...prev, value: prev.value + buffer };
|
||||
});
|
||||
}, 120);
|
||||
};
|
||||
}, []);
|
||||
|
||||
const removeLogo = () => {
|
||||
setForm((prev) => ({
|
||||
@@ -125,6 +122,7 @@ const CreateStatusPage = () => {
|
||||
const success = await createStatusPage({ form });
|
||||
if (success) {
|
||||
createToast({ body: "Status page created successfully" });
|
||||
navigate("/status");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user