From 30000ad01840b46e40bfb694e8a88a8e4367d3ca Mon Sep 17 00:00:00 2001 From: rithviknishad Date: Wed, 16 Oct 2024 15:43:07 +0530 Subject: [PATCH] fix reverse reflection not happening properly --- src/CAREUI/misc/PaginatedList.tsx | 3 ++- src/Components/Facility/DischargedPatientsList.tsx | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/CAREUI/misc/PaginatedList.tsx b/src/CAREUI/misc/PaginatedList.tsx index 6bc0c08f843..3b68b23bd30 100644 --- a/src/CAREUI/misc/PaginatedList.tsx +++ b/src/CAREUI/misc/PaginatedList.tsx @@ -33,6 +33,7 @@ function useContextualized() { interface Props extends QueryOptions> { route: QueryRoute>; perPage?: number; + initialPage?: number; onPageChange?: (page: number) => void; queryCB?: ( query: ReturnType>>, @@ -50,7 +51,7 @@ export default function PaginatedList({ queryCB, ...queryOptions }: Props) { - const [currentPage, _setPage] = useState(1); + const [currentPage, _setPage] = useState(queryOptions.initialPage ?? 1); const setPage = (page: number) => { _setPage(page); diff --git a/src/Components/Facility/DischargedPatientsList.tsx b/src/Components/Facility/DischargedPatientsList.tsx index 1f789a158c8..47e5cd5a68d 100644 --- a/src/Components/Facility/DischargedPatientsList.tsx +++ b/src/Components/Facility/DischargedPatientsList.tsx @@ -436,6 +436,7 @@ const DischargedPatientsList = ({ pathParams={{ facility_external_id }} query={{ ordering: "-modified_date", ...qParams }} queryCB={(query) => setCount(query.data?.count || 0)} + initialPage={qParams.page} onPageChange={updatePage} > {() => (