From d742cce0f7a183ac34e800b3f5c5a0891e247eaa Mon Sep 17 00:00:00 2001 From: Shivank Kacker Date: Thu, 1 Feb 2024 22:56:12 +0530 Subject: [PATCH] fix --- src/app/admin/tests/[testsuite_id]/page.tsx | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/app/admin/tests/[testsuite_id]/page.tsx b/src/app/admin/tests/[testsuite_id]/page.tsx index 454fc5d5..f94a2176 100644 --- a/src/app/admin/tests/[testsuite_id]/page.tsx +++ b/src/app/admin/tests/[testsuite_id]/page.tsx @@ -6,8 +6,6 @@ import { Button, CheckBox, Input, TextArea } from "@/components/ui/interactive"; import { Document, DocumentType, Project } from "@/types/project"; import { API } from "@/utils/api"; import { - QueryFunction, - useInfiniteQuery, useMutation, useQuery, } from "@tanstack/react-query"; @@ -22,6 +20,7 @@ import { TestResult, TestRunStatus, } from "@/types/test"; +import { useInfiQuery } from "@/utils/hooks/useInfiQuery"; export default function Page({ params }: { params: { testsuite_id: string } }) { const router = useRouter(); @@ -108,7 +107,7 @@ export default function Page({ params }: { params: { testsuite_id: string } }) { offset: number | null; }; - const fetchData: QueryFunction = async ({ pageParam = 0 }) => { + const fetchData = async ({ pageParam = 0 }) => { const offset = pageParam ? pageParam : 0; const res = await API.tests.runs.list(testsuite_id, { ordering: "-created_at", @@ -123,12 +122,9 @@ export default function Page({ params }: { params: { testsuite_id: string } }) { }; const { data, fetchNextPage, hasNextPage, isFetching, isLoading, refetch } = - useInfiniteQuery({ + useInfiQuery({ queryKey: ["testruns"], - queryFn: fetchData, - getNextPageParam: (lastPage, pages) => { - return lastPage.results.length > 0 ? lastPage.offset : null; - }, + queryFn: fetchData }); useEffect(() => {