Fix: Uptime UseChecks Hook

This commit is contained in:
Br0wnHammer committed 2025-03-11 03:23:04 +05:30
1 parent 480056a3ed
commit 5958d4b81c
2 files changed
+8 -2

No files matched your search

@@ -2,18 +2,21 @@ import { useState } from "react";
import { useEffect } from "react";
import { networkService } from "../../../../main";
import { createToast } from "../../../../Utils/toastUtils";
export const useChecksFetch = ({ monitorId, dateRange, page, rowsPerPage }) => {
export const useChecksFetch = ({ monitorId, monitorType, dateRange, page, rowsPerPage }) => {
const [checks, setChecks] = useState(undefined);
const [checksCount, setChecksCount] = useState(undefined);
const [isLoading, setIsLoading] = useState(false);
const [networkError, setNetworkError] = useState(false);
useEffect(() => {
if (!monitorType) return;
const fetchChecks = async () => {
try {
setIsLoading(true);
const res = await networkService.getChecksByMonitor({
monitorId: monitorId,
type: monitorType,
sortOrder: "desc",
limit: null,
dateRange: dateRange,
@@ -31,7 +34,7 @@ export const useChecksFetch = ({ monitorId, dateRange, page, rowsPerPage }) => {
}
};
fetchChecks();
}, [monitorId, dateRange, page, rowsPerPage]);
}, [monitorId, monitorType, dateRange, page, rowsPerPage]);
return [checks, checksCount, isLoading, networkError];
};
+3
View File
@@ -59,8 +59,11 @@ const UptimeDetails = () => {
uiTimezone,
});
const monitorType = monitor?.type;
const [checks, checksCount, checksAreLoading, checksNetworkError] = useChecksFetch({
monitorId,
monitorType,
dateRange,
page,
rowsPerPage,