From 1f2e83e11e9664e254c0bc99592995e6b0a4d7e3 Mon Sep 17 00:00:00 2001 From: Matchu Date: Tue, 24 Nov 2020 14:58:11 -0800 Subject: [PATCH] sort trades by user activity (will refine later) I think a plain sort by last update is too game-y, so I have some ideas how to make this a bit more random but still usefully sorted --- src/app/ItemTradesPage.js | 87 +++++++++++++++++++++++---------------- 1 file changed, 52 insertions(+), 35 deletions(-) diff --git a/src/app/ItemTradesPage.js b/src/app/ItemTradesPage.js index 07eae83..766cb2b 100644 --- a/src/app/ItemTradesPage.js +++ b/src/app/ItemTradesPage.js @@ -143,6 +143,11 @@ function ItemTradesTable({ md: "18ex", }; + const trades = [...(data?.item?.trades || [])].sort( + (a, b) => + new Date(b.user.lastTradeActivity) - new Date(a.user.lastTradeActivity) + ); + return ( - List - - {userHeading} - {/* A small wording tweak to fit better on the xsmall screens! */} Last active Active at + + {userHeading} + {shouldShowCompareColumn && ( Compare )} + List {loading && ( <> - - - - - + + + + + )} {!loading && - data.item.trades.length > 0 && - data.item.trades.map((trade) => ( + trades.length > 0 && + trades.map((trade) => ( ))} - {!loading && data.item.trades.length === 0 && ( + {!loading && trades.length === 0 && ( - - - {listName} - - - - {username} - {new Intl.DateTimeFormat("en", { month: "short", year: "numeric", }).format(new Date(lastTradeActivity))} + + {username} + {shouldShowCompareColumn && ( )} + + + {listName} + + ); } -function ItemTradesTableRowSkeleton() { +function ItemTradesTableRowSkeleton({ shouldShowCompareColumn }) { return ( @@ -310,9 +325,11 @@ function ItemTradesTableRowSkeleton() { X - - X - + {shouldShowCompareColumn && ( + + X + + )} ); }