diff --git a/client/src/Hooks/checkHooks.js b/client/src/Hooks/checkHooksTeam.js similarity index 62% rename from client/src/Hooks/checkHooks.js rename to client/src/Hooks/checkHooksTeam.js index dac2be671..fedd88d52 100644 --- a/client/src/Hooks/checkHooks.js +++ b/client/src/Hooks/checkHooksTeam.js @@ -2,10 +2,8 @@ import { useState, useEffect } from "react"; import { networkService } from "../main"; import { createToast } from "../Utils/toastUtils"; -const useFetchChecks = ({ +const useFetchChecksTeam = ({ teamId, - monitorId, - type, status, sortOrder, limit, @@ -21,40 +19,24 @@ const useFetchChecks = ({ useEffect(() => { const fetchChecks = async () => { - if (!type && !teamId) { + if (!teamId) { return; } - const method = monitorId - ? networkService.getChecksByMonitor - : networkService.getChecksByTeam; - - const config = monitorId - ? { - monitorId, - type, - status, - sortOrder, - limit, - dateRange, - filter, - page, - rowsPerPage, - } - : { - status, - teamId, - sortOrder, - limit, - dateRange, - filter, - page, - rowsPerPage, - }; + const config = { + status, + teamId, + sortOrder, + limit, + dateRange, + filter, + page, + rowsPerPage, + }; try { setIsLoading(true); - const res = await method(config); + const res = await networkService.getChecksByTeam(config); setChecks(res.data.data.checks); setChecksCount(res.data.data.checksCount); } catch (error) { @@ -67,9 +49,7 @@ const useFetchChecks = ({ fetchChecks(); }, [ - monitorId, teamId, - type, status, sortOrder, limit, @@ -82,4 +62,4 @@ const useFetchChecks = ({ return [checks, checksCount, isLoading, networkError]; }; -export { useFetchChecks }; +export { useFetchChecksTeam }; diff --git a/client/src/Pages/Incidents/Components/IncidentTable/index.jsx b/client/src/Pages/Incidents/Components/IncidentTable/index.jsx index cf6fbb49d..98f0c3d8f 100644 --- a/client/src/Pages/Incidents/Components/IncidentTable/index.jsx +++ b/client/src/Pages/Incidents/Components/IncidentTable/index.jsx @@ -13,7 +13,7 @@ import { useSelector } from "react-redux"; import { useState, useEffect } from "react"; import PropTypes from "prop-types"; import { useTranslation } from "react-i18next"; -import { useFetchChecks } from "../../../../Hooks/checkHooks"; +import { useFetchChecksTeam } from "../../../../Hooks/checkHooksTeam"; const IncidentTable = ({ shouldRender, @@ -34,7 +34,7 @@ const IncidentTable = ({ const selectedMonitorDetails = monitors?.[selectedMonitor]; const selectedMonitorType = selectedMonitorDetails?.type; - const [checks, checksCount, isLoading, networkError] = useFetchChecks({ + const [checks, checksCount, isLoading, networkError] = useFetchChecksTeam({ status: false, monitorId, teamId,