From 2fb633a76bf239e146a90c5cac7a01c54ed43ba6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20S=C3=A1nchez?= Date: Fri, 28 Jun 2024 13:54:45 +0200 Subject: [PATCH] Sort active grants DESC (#127) --- packages/nextjs/app/_components/ActiveGrants.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/nextjs/app/_components/ActiveGrants.tsx b/packages/nextjs/app/_components/ActiveGrants.tsx index 600ff4d4..827d0ec7 100644 --- a/packages/nextjs/app/_components/ActiveGrants.tsx +++ b/packages/nextjs/app/_components/ActiveGrants.tsx @@ -24,6 +24,14 @@ export const ActiveGrants = async () => { return null; } + // Sort by approved date DESC + const sortedActiveGrants = activeGrants.sort((a, b) => { + if (a.approvedAt && b.approvedAt) { + return b.approvedAt - a.approvedAt; + } + return 0; + }); + return (
@@ -42,7 +50,7 @@ export const ActiveGrants = async () => { - {activeGrants.map(grant => ( + {sortedActiveGrants.map(grant => ( ))}