From 73cfb4cff3ba14ae10b220176f90a59ac1dbc5ec Mon Sep 17 00:00:00 2001 From: Topvennie Date: Sun, 11 Aug 2024 11:55:40 +0200 Subject: [PATCH] vinvoor: reverse scan order --- vinvoor/src/scans/ScansTableBody.tsx | 6 +++++- vinvoor/src/types/scans.ts | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/vinvoor/src/scans/ScansTableBody.tsx b/vinvoor/src/scans/ScansTableBody.tsx index 588a07d..3f1b4c7 100644 --- a/vinvoor/src/scans/ScansTableBody.tsx +++ b/vinvoor/src/scans/ScansTableBody.tsx @@ -17,7 +17,11 @@ export const ScansTableBody: FC = ({ scans, cards }) => { const [scanCards, setScanCards] = useState([]); useEffect(() => { - setScanCards(mergeScansCards(scans, cards)); + const mergedScansCards = mergeScansCards(scans, cards); + mergedScansCards.sort( + (a, b) => b.scanTime.getTime() - a.scanTime.getTime() + ); + setScanCards(mergedScansCards); }, [scans, cards]); return ( diff --git a/vinvoor/src/types/scans.ts b/vinvoor/src/types/scans.ts index 4622993..c7fdc8e 100644 --- a/vinvoor/src/types/scans.ts +++ b/vinvoor/src/types/scans.ts @@ -27,7 +27,7 @@ export const convertScanJSON = (scansJSON: ScanJSON[]): Scan[] => export const mergeScansCards = ( scans: readonly Scan[], cards: readonly Card[] -): readonly ScanCard[] => +): ScanCard[] => scans.map((scan) => ({ scanTime: scan.scanTime, card: cards.find((card) => card.serial === scan.cardSerial),