Merge pull request #1814 from bluewave-labs/fix/config-depin
fix: config depin
This commit is contained in:
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 { useTheme } from "@emotion/react";
|
||||||
import { useState, useEffect } from "react";
|
import { useState, useEffect } from "react";
|
||||||
import { useParams } from "react-router-dom";
|
import { useParams } from "react-router-dom";
|
||||||
import { useDUStatusPageFetch } from "./Hooks/useDUStatusPageFetch";
|
|
||||||
import { useCreateStatusPage } from "../../StatusPage/Create/Hooks/useCreateStatusPage";
|
import { useCreateStatusPage } from "../../StatusPage/Create/Hooks/useCreateStatusPage";
|
||||||
import { statusPageValidation } from "../../../Validation/validation";
|
import { statusPageValidation } from "../../../Validation/validation";
|
||||||
import { buildErrors } from "../../../Validation/error";
|
import { buildErrors } from "../../../Validation/error";
|
||||||
import { createToast } from "../../../Utils/toastUtils";
|
import { createToast } from "../../../Utils/toastUtils";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { useMonitorsFetch } from "../../StatusPage/Create/Hooks/useMonitorsFetch";
|
import { useMonitorsFetch } from "../../StatusPage/Create/Hooks/useMonitorsFetch";
|
||||||
|
import { useDUStatusPageFetchByUrl } from "../Status/Hooks/useDUStatusPageFetchByUrl";
|
||||||
|
|
||||||
const CreateStatus = () => {
|
const CreateStatus = () => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
@@ -29,10 +29,12 @@ const CreateStatus = () => {
|
|||||||
|
|
||||||
const [createStatusPage, isLoading, networkError] = useCreateStatusPage(isCreate);
|
const [createStatusPage, isLoading, networkError] = useCreateStatusPage(isCreate);
|
||||||
|
|
||||||
const [statusPage, statusPageIsLoading, statusPageNetworkError] = useDUStatusPageFetch(
|
const [statusPageIsLoading, statusPageNetworkError, statusPage, _, isPublished] =
|
||||||
isCreate,
|
useDUStatusPageFetchByUrl({
|
||||||
url
|
url,
|
||||||
);
|
timeFrame: 30,
|
||||||
|
isCreate,
|
||||||
|
});
|
||||||
|
|
||||||
const [monitors, monitorsIsLoading, monitorsNetworkError] = useMonitorsFetch();
|
const [monitors, monitorsIsLoading, monitorsNetworkError] = useMonitorsFetch();
|
||||||
|
|
||||||
|
|||||||
+3
-2
@@ -5,7 +5,7 @@ import { useSelector } from "react-redux";
|
|||||||
import { useTheme } from "@emotion/react";
|
import { useTheme } from "@emotion/react";
|
||||||
import { useMonitorUtils } from "../../../../Hooks/useMonitorUtils";
|
import { useMonitorUtils } from "../../../../Hooks/useMonitorUtils";
|
||||||
|
|
||||||
const useStatusPageFetchByUrl = ({ url, timeFrame }) => {
|
const useDUStatusPageFetchByUrl = ({ url, timeFrame, isCreate = false }) => {
|
||||||
const [isLoading, setIsLoading] = useState(true);
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
const [networkError, setNetworkError] = useState(false);
|
const [networkError, setNetworkError] = useState(false);
|
||||||
const [statusPage, setStatusPage] = useState(undefined);
|
const [statusPage, setStatusPage] = useState(undefined);
|
||||||
@@ -16,6 +16,7 @@ const useStatusPageFetchByUrl = ({ url, timeFrame }) => {
|
|||||||
const { getMonitorWithPercentage } = useMonitorUtils();
|
const { getMonitorWithPercentage } = useMonitorUtils();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (isCreate) return;
|
||||||
const fetchStatusPageByUrl = async () => {
|
const fetchStatusPageByUrl = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await networkService.getDistributedStatusPageByUrl({
|
const response = await networkService.getDistributedStatusPageByUrl({
|
||||||
@@ -54,4 +55,4 @@ const useStatusPageFetchByUrl = ({ url, timeFrame }) => {
|
|||||||
return [isLoading, networkError, statusPage, monitorId, isPublished];
|
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 { useState, useRef } from "react";
|
||||||
import { useParams } from "react-router-dom";
|
import { useParams } from "react-router-dom";
|
||||||
import { useSubscribeToDetails } from "../../DistributedUptime/Details/Hooks/useSubscribeToDetails";
|
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 { useStatusPageDelete } from "../../StatusPage/Status/Hooks/useStatusPageDelete";
|
||||||
import TimeFrameHeader from "./Components/TimeframeHeader";
|
import TimeFrameHeader from "./Components/TimeframeHeader";
|
||||||
import SubHeader from "../../../Components/Subheader";
|
import SubHeader from "../../../Components/Subheader";
|
||||||
@@ -53,7 +53,7 @@ const DistributedUptimeStatus = () => {
|
|||||||
statusPage,
|
statusPage,
|
||||||
monitorId,
|
monitorId,
|
||||||
isPublished,
|
isPublished,
|
||||||
] = useStatusPageFetchByUrl({
|
] = useDUStatusPageFetchByUrl({
|
||||||
url,
|
url,
|
||||||
timeFrame,
|
timeFrame,
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in new issue
Block a user