From c753f32dff9e55ce1c96c57b0934645f30166051 Mon Sep 17 00:00:00 2001 From: Shyam prakash Date: Sun, 26 Nov 2023 12:05:10 +0530 Subject: [PATCH] Sorted daily rounds by Measured At instead of Created at --- src/CAREUI/misc/PaginatedList.tsx | 8 +++++++- src/Components/Facility/Consultations/DailyRoundsList.tsx | 6 ++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/CAREUI/misc/PaginatedList.tsx b/src/CAREUI/misc/PaginatedList.tsx index 02ee0e3d90e..e8fa5162c53 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; + sortFunc?: (item1: any, item2: any) => number; children: ( ctx: PaginatedListContext, query: ReturnType>> @@ -42,6 +43,7 @@ interface Props extends QueryOptions> { export default function PaginatedList({ children, route, + sortFunc, perPage = DEFAULT_PER_PAGE_LIMIT, ...queryOptions }: Props) { @@ -55,7 +57,11 @@ export default function PaginatedList({ }, }); - const items = query.data?.results ?? []; + const items = query.data?.results + ? sortFunc + ? query.data?.results.sort(sortFunc) + : query.data?.results + : []; return ( { query={{ rounds_type: showAutomatedRounds ? "" : "NORMAL,VENTILATOR,ICU", }} + sortFunc={(item1, item2) => { + const takenAt1 = item1.taken_at; + const takenAt2 = item2.taken_at; + return Number(new Date(takenAt2)) - Number(new Date(takenAt1)); + }} > {(_) => (
@@ -52,6 +57,7 @@ export const DailyRoundsList = (props: any) => { /> ); } + console.log(items); return (