From 409de455f2bfbf3aff64beed7026f928213536b5 Mon Sep 17 00:00:00 2001 From: Team 1280 Programming Laptop <59985235+Team1280Programming@users.noreply.github.com> Date: Mon, 19 Feb 2024 13:50:37 -0800 Subject: [PATCH] feat: sort documents by latest date on the Page component (#22) Co-authored-by: Team1280Programming --- src/app/document/page.tsx | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/app/document/page.tsx b/src/app/document/page.tsx index b5583aa..b4a9362 100644 --- a/src/app/document/page.tsx +++ b/src/app/document/page.tsx @@ -19,19 +19,30 @@ const DocumentCardWrapper = ({ return } +const getDocumentDate = (id: string) => { + const dates = documents[id].manifest.dates + return dates[dates.length - 1] +} + const Page = () => { + const sortedDocuments = Object.entries(documents).sort((a, b) => { + const docTimestampA = getDocumentDate(a[0]) + const docTimestampB = getDocumentDate(b[0]) + return docTimestampB - docTimestampA + }) + return (

Documents

- {Object.keys(documents).map((documentShortName) => { + {sortedDocuments.map((entry) => { return ( - + )