From 0887bdf96863cf452e89b768174d385ee802675e Mon Sep 17 00:00:00 2001 From: Iain Collins Date: Sun, 8 Sep 2024 01:48:44 +0100 Subject: [PATCH] Improve the main commodity listing view --- package.json | 2 +- pages/commodities.js | 21 +++++++++++++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index eb23430..dcceff9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ardent-www", - "version": "0.44.2", + "version": "0.45.0", "description": "Ardent Industry", "main": "index.js", "scripts": { diff --git a/pages/commodities.js b/pages/commodities.js index b9f4e77..598953c 100644 --- a/pages/commodities.js +++ b/pages/commodities.js @@ -9,6 +9,7 @@ import animateTableEffect from 'lib/animate-table-effect' export default () => { const router = useRouter() const [commodities, setCommodities] = useState() + const [categories, setCategories] = useState() const onRowClick = (record, index, event) => { router.push(`/commodity/${record.commodityName}`) @@ -18,7 +19,10 @@ export default () => { useEffect(() => { (async () => { - setCommodities(await getCommodities()) + const commodities = await getCommodities() + const categories = [ ...new Set(commodities.map((c) => c.category).sort()) ] + setCommodities(commodities) + setCategories(categories) })() }, []) @@ -27,9 +31,16 @@ export default () => { - {commodities && + {commodities && categories &&
-

Commodities

+

Trade Commodities

+

+ Find the best trade prices for any commodity in the galaxy. +

+ + {categories.map(category => + <> +

{category}

{ } ]} - data={commodities} + data={commodities.filter(c => c.category == category)} rowKey='name' onRow={(record, index) => ({ onClick: onRowClick.bind(null, record, index) })} /> + + )} } )