use url in hook

This commit is contained in:
Alex Holliday
2025-02-10 13:46:26 -08:00
parent 01d1f8e173
commit 55321ffc3c
3 changed files with 10 additions and 7 deletions

View File

@@ -3,7 +3,7 @@ import { networkService } from "../../../../main";
import { useSelector } from "react-redux";
import { createToast } from "../../../../Utils/toastUtils";
const useCreateStatusPage = (isCreate) => {
const useCreateStatusPage = (isCreate, url) => {
const { authToken, user } = useSelector((state) => state.auth);
const [isLoading, setIsLoading] = useState(false);
@@ -11,7 +11,7 @@ const useCreateStatusPage = (isCreate) => {
const createStatusPage = async ({ form }) => {
setIsLoading(true);
try {
await networkService.createStatusPage({ authToken, user, form, isCreate });
await networkService.createStatusPage({ authToken, user, form, isCreate, url });
return true;
} catch (error) {
setNetworkError(true);

View File

@@ -4,7 +4,7 @@ import { networkService } from "../../../../main";
import { createToast } from "../../../../Utils/toastUtils";
import { useNavigate } from "react-router-dom";
const useStatusPageDelete = (fetchStatusPage, url = "/status/public") => {
const useStatusPageDelete = (fetchStatusPage, url) => {
const [isLoading, setIsLoading] = useState(false);
const navigate = useNavigate();
const { authToken } = useSelector((state) => state.auth);

View File

@@ -5,7 +5,7 @@ import { createToast } from "../../../../Utils/toastUtils";
import { useTheme } from "@emotion/react";
import { useMonitorUtils } from "../../../../Hooks/useMonitorUtils";
const useStatusPageFetch = (isCreate = false) => {
const useStatusPageFetch = (isCreate = false, url) => {
const [isLoading, setIsLoading] = useState(true);
const [networkError, setNetworkError] = useState(false);
const [statusPage, setStatusPage] = useState(undefined);
@@ -15,10 +15,13 @@ const useStatusPageFetch = (isCreate = false) => {
const { getMonitorWithPercentage } = useMonitorUtils();
const fetchStatusPage = useCallback(async () => {
try {
const response = await networkService.getStatusPage({ authToken });
const response = await networkService.getStatusPageByUrl({
authToken,
url,
type: "uptime",
});
if (!response?.data?.data) return;
const { statusPage, monitors } = response.data.data;
setStatusPage(statusPage);
const monitorsWithPercentage = monitors.map((monitor) =>
@@ -37,7 +40,7 @@ const useStatusPageFetch = (isCreate = false) => {
} finally {
setIsLoading(false);
}
}, [authToken, theme, getMonitorWithPercentage]);
}, [authToken, theme, getMonitorWithPercentage, url]);
useEffect(() => {
if (isCreate === true) {