[Uptime]: Moved hook, removed duplicate imports, teporarily disabled formatAndSet function due to rerenders
This commit is contained in:
1 parent
d3493a0af6
commit
89f5be2cc9
1 file changed
+14
-15
@@ -22,22 +22,20 @@ import PulseDot from "../../../Components/Animated/PulseDot";
|
|||||||
import SkeletonLayout from "./skeleton";
|
import SkeletonLayout from "./skeleton";
|
||||||
|
|
||||||
// Utils
|
// Utils
|
||||||
import { useParams } from "react-router";
|
|
||||||
import { useTheme } from "@emotion/react";
|
import { useTheme } from "@emotion/react";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { monitorValidation } from "../../../Validation/validation";
|
import { monitorValidation } from "../../../Validation/validation";
|
||||||
import { createToast } from "../../../Utils/toastUtils";
|
import { createToast } from "../../../Utils/toastUtils";
|
||||||
import { useTranslation } from "react-i18next";
|
|
||||||
import {
|
import {
|
||||||
PauseOutlined as PauseOutlinedIcon,
|
PauseOutlined as PauseOutlinedIcon,
|
||||||
PlayArrowOutlined as PlayArrowOutlinedIcon,
|
PlayArrowOutlined as PlayArrowOutlinedIcon,
|
||||||
} from "@mui/icons-material";
|
} from "@mui/icons-material";
|
||||||
import { useMonitorUtils } from "../../../Hooks/useMonitorUtils";
|
import { useMonitorUtils } from "../../../Hooks/useMonitorUtils";
|
||||||
import { useGetNotificationsByTeamId } from "../../../Hooks/useNotifications";
|
import { useGetNotificationsByTeamId } from "../../../Hooks/useNotifications";
|
||||||
import { useCreateMonitor, useFetchMonitorById } from "../../../Hooks/monitorHooks";
|
|
||||||
import { useParams } from "react-router-dom";
|
import { useParams } from "react-router-dom";
|
||||||
import {
|
import {
|
||||||
|
useCreateMonitor,
|
||||||
useDeleteMonitor,
|
useDeleteMonitor,
|
||||||
useUpdateMonitor,
|
useUpdateMonitor,
|
||||||
usePauseMonitor,
|
usePauseMonitor,
|
||||||
@@ -85,6 +83,10 @@ const UptimeCreate = () => {
|
|||||||
const triggerUpdate = () => {
|
const triggerUpdate = () => {
|
||||||
setUpdateTrigger(!updateTrigger);
|
setUpdateTrigger(!updateTrigger);
|
||||||
};
|
};
|
||||||
|
// const formatAndSet = (monitor) => {
|
||||||
|
// monitor.interval = monitor.interval / MS_PER_MINUTE;
|
||||||
|
// setMonitor(monitor);
|
||||||
|
// };
|
||||||
|
|
||||||
// Hooks
|
// Hooks
|
||||||
const [notifications, notificationsAreLoading, notificationsError] =
|
const [notifications, notificationsAreLoading, notificationsError] =
|
||||||
@@ -93,7 +95,7 @@ const UptimeCreate = () => {
|
|||||||
// Network
|
// Network
|
||||||
const [isLoading] = useFetchMonitorById({
|
const [isLoading] = useFetchMonitorById({
|
||||||
monitorId,
|
monitorId,
|
||||||
setMonitor: formatAndSet,
|
setMonitor, // : formatAndSet,
|
||||||
updateTrigger: true,
|
updateTrigger: true,
|
||||||
});
|
});
|
||||||
const [createMonitor, isCreating] = useCreateMonitor();
|
const [createMonitor, isCreating] = useCreateMonitor();
|
||||||
@@ -155,10 +157,6 @@ const UptimeCreate = () => {
|
|||||||
namePlaceholder: t("monitorType.port.namePlaceholder"),
|
namePlaceholder: t("monitorType.port.namePlaceholder"),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
const formatAndSet = (monitor) => {
|
|
||||||
monitor.interval = monitor.interval / MS_PER_MINUTE;
|
|
||||||
setMonitor(monitor);
|
|
||||||
};
|
|
||||||
|
|
||||||
// Handlers
|
// Handlers
|
||||||
const onSubmit = async (event) => {
|
const onSubmit = async (event) => {
|
||||||
@@ -269,9 +267,6 @@ const UptimeCreate = () => {
|
|||||||
const parsedUrl = parseUrl(monitor?.url);
|
const parsedUrl = parseUrl(monitor?.url);
|
||||||
const protocol = parsedUrl?.protocol?.replace(":", "") || "";
|
const protocol = parsedUrl?.protocol?.replace(":", "") || "";
|
||||||
|
|
||||||
if (Object.keys(monitor).length === 0) {
|
|
||||||
return <SkeletonLayout />;
|
|
||||||
}
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isCreate) {
|
if (!isCreate) {
|
||||||
if (monitor.matchMethod) {
|
if (monitor.matchMethod) {
|
||||||
@@ -280,7 +275,11 @@ const UptimeCreate = () => {
|
|||||||
setUseAdvancedMatching(false);
|
setUseAdvancedMatching(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [monitor]);
|
}, [monitor, isCreate]);
|
||||||
|
|
||||||
|
if (Object.keys(monitor).length === 0) {
|
||||||
|
return <SkeletonLayout />;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack gap={theme.spacing(10)}>
|
<Stack gap={theme.spacing(10)}>
|
||||||
@@ -365,12 +364,12 @@ const UptimeCreate = () => {
|
|||||||
"&:before": {
|
"&:before": {
|
||||||
position: "absolute",
|
position: "absolute",
|
||||||
content: `""`,
|
content: `""`,
|
||||||
width: 4,
|
width: theme.spacing(2),
|
||||||
height: 4,
|
height: theme.spacing(2),
|
||||||
borderRadius: "50%",
|
borderRadius: "50%",
|
||||||
backgroundColor: theme.palette.primary.contrastTextTertiary,
|
backgroundColor: theme.palette.primary.contrastTextTertiary,
|
||||||
opacity: 0.8,
|
opacity: 0.8,
|
||||||
left: -10,
|
left: theme.spacing(-5),
|
||||||
top: "50%",
|
top: "50%",
|
||||||
transform: "translateY(-50%)",
|
transform: "translateY(-50%)",
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in new issue
Block a user