Skip to content

Commit

Permalink
Improve the main commodity listing view
Browse files Browse the repository at this point in the history
  • Loading branch information
iaincollins committed Sep 8, 2024
1 parent a61c762 commit 0887bdf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ardent-www",
"version": "0.44.2",
"version": "0.45.0",
"description": "Ardent Industry",
"main": "index.js",
"scripts": {
Expand Down
21 changes: 17 additions & 4 deletions pages/commodities.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`)
Expand All @@ -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)
})()
}, [])

Expand All @@ -27,9 +31,16 @@ export default () => {
<Head>
<link rel='canonical' href='https://ardent-industry.com/commodities' />
</Head>
{commodities &&
{commodities && categories &&
<div className='fx__fade-in'>
<h2 style={{ marginBottom: '-.1rem' }}>Commodities</h2>
<h2>Trade Commodities</h2>
<p class='clear' style={{ fontSize: '1.1rem'}}>
Find the best trade prices for any commodity in the galaxy.
</p>

{categories.map(category =>
<>
<h3 style={{ marginBottom: '-.1rem' }}>{category}</h3>
<Table
className='data-table data-table--striped data-table--interactive data-table--animated'
columns={[
Expand Down Expand Up @@ -91,12 +102,14 @@ export default () => {
</div>
}
]}
data={commodities}
data={commodities.filter(c => c.category == category)}
rowKey='name'
onRow={(record, index) => ({
onClick: onRowClick.bind(null, record, index)
})}
/>
</>
)}
</div>}
</Layout>
)
Expand Down

0 comments on commit 0887bdf

Please sign in to comment.