useFetchChecksTeam Hook
This commit is contained in:
1 parent
bebbe5896d
commit
37406484fc
2 files changed
+16
-36
No files matched your search
@@ -2,10 +2,8 @@ import { useState, useEffect } from "react";
|
|||||||
import { networkService } from "../main";
|
import { networkService } from "../main";
|
||||||
import { createToast } from "../Utils/toastUtils";
|
import { createToast } from "../Utils/toastUtils";
|
||||||
|
|
||||||
const useFetchChecks = ({
|
const useFetchChecksTeam = ({
|
||||||
teamId,
|
teamId,
|
||||||
monitorId,
|
|
||||||
type,
|
|
||||||
status,
|
status,
|
||||||
sortOrder,
|
sortOrder,
|
||||||
limit,
|
limit,
|
||||||
@@ -21,40 +19,24 @@ const useFetchChecks = ({
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchChecks = async () => {
|
const fetchChecks = async () => {
|
||||||
if (!type && !teamId) {
|
if (!teamId) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const method = monitorId
|
const config = {
|
||||||
? networkService.getChecksByMonitor
|
status,
|
||||||
: networkService.getChecksByTeam;
|
teamId,
|
||||||
|
sortOrder,
|
||||||
const config = monitorId
|
limit,
|
||||||
? {
|
dateRange,
|
||||||
monitorId,
|
filter,
|
||||||
type,
|
page,
|
||||||
status,
|
rowsPerPage,
|
||||||
sortOrder,
|
};
|
||||||
limit,
|
|
||||||
dateRange,
|
|
||||||
filter,
|
|
||||||
page,
|
|
||||||
rowsPerPage,
|
|
||||||
}
|
|
||||||
: {
|
|
||||||
status,
|
|
||||||
teamId,
|
|
||||||
sortOrder,
|
|
||||||
limit,
|
|
||||||
dateRange,
|
|
||||||
filter,
|
|
||||||
page,
|
|
||||||
rowsPerPage,
|
|
||||||
};
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
const res = await method(config);
|
const res = await networkService.getChecksByTeam(config);
|
||||||
setChecks(res.data.data.checks);
|
setChecks(res.data.data.checks);
|
||||||
setChecksCount(res.data.data.checksCount);
|
setChecksCount(res.data.data.checksCount);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -67,9 +49,7 @@ const useFetchChecks = ({
|
|||||||
|
|
||||||
fetchChecks();
|
fetchChecks();
|
||||||
}, [
|
}, [
|
||||||
monitorId,
|
|
||||||
teamId,
|
teamId,
|
||||||
type,
|
|
||||||
status,
|
status,
|
||||||
sortOrder,
|
sortOrder,
|
||||||
limit,
|
limit,
|
||||||
@@ -82,4 +62,4 @@ const useFetchChecks = ({
|
|||||||
return [checks, checksCount, isLoading, networkError];
|
return [checks, checksCount, isLoading, networkError];
|
||||||
};
|
};
|
||||||
|
|
||||||
export { useFetchChecks };
|
export { useFetchChecksTeam };
|
||||||
@@ -13,7 +13,7 @@ import { useSelector } from "react-redux";
|
|||||||
import { useState, useEffect } from "react";
|
import { useState, useEffect } from "react";
|
||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { useFetchChecks } from "../../../../Hooks/checkHooks";
|
import { useFetchChecksTeam } from "../../../../Hooks/checkHooksTeam";
|
||||||
|
|
||||||
const IncidentTable = ({
|
const IncidentTable = ({
|
||||||
shouldRender,
|
shouldRender,
|
||||||
@@ -34,7 +34,7 @@ const IncidentTable = ({
|
|||||||
const selectedMonitorDetails = monitors?.[selectedMonitor];
|
const selectedMonitorDetails = monitors?.[selectedMonitor];
|
||||||
const selectedMonitorType = selectedMonitorDetails?.type;
|
const selectedMonitorType = selectedMonitorDetails?.type;
|
||||||
|
|
||||||
const [checks, checksCount, isLoading, networkError] = useFetchChecks({
|
const [checks, checksCount, isLoading, networkError] = useFetchChecksTeam({
|
||||||
status: false,
|
status: false,
|
||||||
monitorId,
|
monitorId,
|
||||||
teamId,
|
teamId,
|
||||||
|
|||||||
Reference in new issue
Block a user