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),