add url to request, add missing dependency
This commit is contained in:
1 parent
5c5d1b88e6
commit
bd2fae913a
2 files changed
+5
-4
No files matched your search
@@ -4,15 +4,14 @@ import { networkService } from "../../../../main";
|
|||||||
import { createToast } from "../../../../Utils/toastUtils";
|
import { createToast } from "../../../../Utils/toastUtils";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
|
|
||||||
const useStatusPageDelete = (fetchStatusPage) => {
|
const useStatusPageDelete = (fetchStatusPage, url = "/status/public") => {
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { authToken } = useSelector((state) => state.auth);
|
const { authToken } = useSelector((state) => state.auth);
|
||||||
|
|
||||||
const deleteStatusPage = async () => {
|
const deleteStatusPage = async () => {
|
||||||
try {
|
try {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
await networkService.deleteStatusPage({ authToken });
|
await networkService.deleteStatusPage({ authToken, url });
|
||||||
fetchStatusPage?.();
|
fetchStatusPage?.();
|
||||||
return true;
|
return true;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -18,11 +18,13 @@ const useStatusPageFetch = (isCreate = false) => {
|
|||||||
const response = await networkService.getStatusPage({ authToken });
|
const response = await networkService.getStatusPage({ authToken });
|
||||||
if (!response?.data?.data) return;
|
if (!response?.data?.data) return;
|
||||||
const { statusPage, monitors } = response.data.data;
|
const { statusPage, monitors } = response.data.data;
|
||||||
|
|
||||||
setStatusPage(statusPage);
|
setStatusPage(statusPage);
|
||||||
|
|
||||||
const monitorsWithPercentage = monitors.map((monitor) =>
|
const monitorsWithPercentage = monitors.map((monitor) =>
|
||||||
getMonitorWithPercentage(monitor, theme)
|
getMonitorWithPercentage(monitor, theme)
|
||||||
);
|
);
|
||||||
|
|
||||||
setMonitors(monitorsWithPercentage);
|
setMonitors(monitorsWithPercentage);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// If there is a 404, status page is not found
|
// If there is a 404, status page is not found
|
||||||
@@ -35,7 +37,7 @@ const useStatusPageFetch = (isCreate = false) => {
|
|||||||
} finally {
|
} finally {
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
}
|
}
|
||||||
}, [authToken, theme]);
|
}, [authToken, theme, getMonitorWithPercentage]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isCreate === true) {
|
if (isCreate === true) {
|
||||||
|
|||||||
Reference in new issue
Block a user