From 330c7d9f2f8150067a7ad13e9bda9b65104913af Mon Sep 17 00:00:00 2001 From: rithviknishad Date: Wed, 18 Oct 2023 08:21:34 +0530 Subject: [PATCH] PaginatedList: fix `offset` not included in qParams --- src/CAREUI/misc/PaginatedList.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/CAREUI/misc/PaginatedList.tsx b/src/CAREUI/misc/PaginatedList.tsx index 3b699177d9e..899febdaaf3 100644 --- a/src/CAREUI/misc/PaginatedList.tsx +++ b/src/CAREUI/misc/PaginatedList.tsx @@ -42,11 +42,15 @@ export default function PaginatedList({ perPage = DEFAULT_PER_PAGE_LIMIT, ...queryOptions }: Props) { + const [currentPage, setPage] = useState(1); const query = useQuery(route, { ...queryOptions, - query: { ...queryOptions.query, limit: perPage }, + query: { + ...queryOptions.query, + limit: perPage, + offset: (currentPage - 1) * perPage, + }, }); - const [currentPage, setPage] = useState(1); const items = query.data?.results ?? [];