Merge pull request #1814 from bluewave-labs/fix/config-depin

fix: config depin
This commit is contained in:
Alexander Holliday authored and GitHub committed 2025-02-24 16:04:00 -08:00
commit 121730466e
4 files changed
+12 -55

No files matched your search

@@ -1,46 +0,0 @@
import { useEffect, useState, useCallback } from "react";
import { networkService } from "../../../../main";
import { useSelector } from "react-redux";
import { createToast } from "../../../../Utils/toastUtils";
const useDUStatusPageFetch = (isCreate = false, url) => {
const [isLoading, setIsLoading] = useState(true);
const [networkError, setNetworkError] = useState(false);
const [statusPage, setStatusPage] = useState(undefined);
const { authToken } = useSelector((state) => state.auth);
const fetchStatusPage = useCallback(async () => {
try {
const response = await networkService.getStatusPageByUrl({
authToken,
url,
type: "distributed",
});
if (!response?.data?.data) return;
const statusPage = response.data.data;
setStatusPage(statusPage);
} catch (error) {
// If there is a 404, status page is not found
if (error?.response?.status === 404) {
setStatusPage(undefined);
return;
}
createToast({ body: error.message });
setNetworkError(true);
} finally {
setIsLoading(false);
}
}, [authToken, url]);
useEffect(() => {
if (isCreate === true) {
return;
}
fetchStatusPage();
}, [isCreate, fetchStatusPage]);
return [statusPage, isLoading, networkError, fetchStatusPage];
};
export { useDUStatusPageFetch };
@@ -13,13 +13,13 @@ import MonitorList from "../../StatusPage/Create/Components/MonitorList";
import { useTheme } from "@emotion/react";
import { useState, useEffect } from "react";
import { useParams } from "react-router-dom";
import { useDUStatusPageFetch } from "./Hooks/useDUStatusPageFetch";
import { useCreateStatusPage } from "../../StatusPage/Create/Hooks/useCreateStatusPage";
import { statusPageValidation } from "../../../Validation/validation";
import { buildErrors } from "../../../Validation/error";
import { createToast } from "../../../Utils/toastUtils";
import { useNavigate } from "react-router-dom";
import { useMonitorsFetch } from "../../StatusPage/Create/Hooks/useMonitorsFetch";
import { useDUStatusPageFetchByUrl } from "../Status/Hooks/useDUStatusPageFetchByUrl";
const CreateStatus = () => {
const theme = useTheme();
@@ -29,10 +29,12 @@ const CreateStatus = () => {
const [createStatusPage, isLoading, networkError] = useCreateStatusPage(isCreate);
const [statusPage, statusPageIsLoading, statusPageNetworkError] = useDUStatusPageFetch(
isCreate,
url
);
const [statusPageIsLoading, statusPageNetworkError, statusPage, _, isPublished] =
useDUStatusPageFetchByUrl({
url,
timeFrame: 30,
isCreate,
});
const [monitors, monitorsIsLoading, monitorsNetworkError] = useMonitorsFetch();
@@ -5,7 +5,7 @@ import { useSelector } from "react-redux";
import { useTheme } from "@emotion/react";
import { useMonitorUtils } from "../../../../Hooks/useMonitorUtils";
const useStatusPageFetchByUrl = ({ url, timeFrame }) => {
const useDUStatusPageFetchByUrl = ({ url, timeFrame, isCreate = false }) => {
const [isLoading, setIsLoading] = useState(true);
const [networkError, setNetworkError] = useState(false);
const [statusPage, setStatusPage] = useState(undefined);
@@ -16,6 +16,7 @@ const useStatusPageFetchByUrl = ({ url, timeFrame }) => {
const { getMonitorWithPercentage } = useMonitorUtils();
useEffect(() => {
if (isCreate) return;
const fetchStatusPageByUrl = async () => {
try {
const response = await networkService.getDistributedStatusPageByUrl({
@@ -54,4 +55,4 @@ const useStatusPageFetchByUrl = ({ url, timeFrame }) => {
return [isLoading, networkError, statusPage, monitorId, isPublished];
};
export { useStatusPageFetchByUrl };
export { useDUStatusPageFetchByUrl };
@@ -24,7 +24,7 @@ import { useTheme } from "@mui/material/styles";
import { useState, useRef } from "react";
import { useParams } from "react-router-dom";
import { useSubscribeToDetails } from "../../DistributedUptime/Details/Hooks/useSubscribeToDetails";
import { useStatusPageFetchByUrl } from "./Hooks/useStatusPageFetchByUrl";
import { useDUStatusPageFetchByUrl } from "./Hooks/useDUStatusPageFetchByUrl";
import { useStatusPageDelete } from "../../StatusPage/Status/Hooks/useStatusPageDelete";
import TimeFrameHeader from "./Components/TimeframeHeader";
import SubHeader from "../../../Components/Subheader";
@@ -53,7 +53,7 @@ const DistributedUptimeStatus = () => {
statusPage,
monitorId,
isPublished,
] = useStatusPageFetchByUrl({
] = useDUStatusPageFetchByUrl({
url,
timeFrame,
});