From 35884f6fb63c3dd7c82bdd043722c051c0188597 Mon Sep 17 00:00:00 2001 From: Iain Collins Date: Wed, 9 Oct 2024 13:50:53 +0100 Subject: [PATCH] Improve system imports/exports Highlight (and sort by) category, number of importers/exporters and filter out where import demand is zero. --- lib/system-exports.js | 1 + lib/system-imports.js | 2 ++ package.json | 2 +- pages/system/[system-name]/index.js | 33 +++++++++++++++++++++++++---- 4 files changed, 33 insertions(+), 5 deletions(-) diff --git a/lib/system-exports.js b/lib/system-exports.js index 0357fde..ae240a5 100644 --- a/lib/system-exports.js +++ b/lib/system-exports.js @@ -43,4 +43,5 @@ module.exports = async (systemName) => { return Object.values(exportOrdersGroupedByCommodity) .sort((a, b) => a.name.localeCompare(b.name)) + .sort((a, b) => a.category.localeCompare(b.category)) } diff --git a/lib/system-imports.js b/lib/system-imports.js index bbe82c8..148d16e 100644 --- a/lib/system-imports.js +++ b/lib/system-imports.js @@ -49,5 +49,7 @@ module.exports = async (systemName) => { }) return Object.values(importOrdersGroupedByCommodity) + .filter(c => c.totalDemand) .sort((a, b) => a.name.localeCompare(b.name)) + .sort((a, b) => a.category.localeCompare(b.category)) } diff --git a/package.json b/package.json index 441b018..d48483f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ardent-www", - "version": "0.69.0", + "version": "0.70.0", "description": "Ardent Industry", "main": "index.js", "scripts": { diff --git a/pages/system/[system-name]/index.js b/pages/system/[system-name]/index.js index f2f1e7f..55e51b5 100644 --- a/pages/system/[system-name]/index.js +++ b/pages/system/[system-name]/index.js @@ -419,7 +419,10 @@ export default () => { render: (v, r) => <> {v}
- {r.importOrders.length === 1 ? '1 importer ' : `${r.importOrders.length} importers`} +
+ {r.importOrders.length === 1 ? '1 importer ' : `${r.importOrders.length} importers`} +
+ {r.category} {r?.consumer === true && | Consumer}
@@ -440,6 +443,16 @@ export default () => { }, + { + title: 'Importers', + dataIndex: 'importOrders', + key: 'importOrders', + align: 'center', + width: 100, + className: 'is-hidden-mobile', + render: (v) => {v.length === 1 ? '1 ' : `${v.length}`} + }, + { title: 'Updated', dataIndex: 'updatedAt', @@ -454,7 +467,7 @@ export default () => { dataIndex: 'totalDemand', key: 'totalDemand', align: 'right', - width: 150, + width: 200, className: 'is-hidden-mobile no-wrap', render: (v) => <>{v > 0 ? `${v.toLocaleString()} T` : {NO_DEMAND_TEXT}} }, @@ -519,7 +532,10 @@ export default () => { render: (v, r) => <> {v}
- {r.exportOrders.length === 1 ? '1 exporter ' : `${r.exportOrders.length} exporters`} +
+ {r.exportOrders.length === 1 ? '1 exporter ' : `${r.exportOrders.length} exporters`} +
+ {r.category} {r?.producer === true && | Producer} {r?.rare === true && | Rare}
@@ -541,6 +557,15 @@ export default () => {
}, + { + title: 'Exporters', + dataIndex: 'exportOrders', + key: 'exportOrders', + align: 'center', + width: 100, + className: 'is-hidden-mobile', + render: (v) => {v.length === 1 ? '1 ' : `${v.length}`} + }, { title: 'Updated', dataIndex: 'updatedAt', @@ -555,7 +580,7 @@ export default () => { dataIndex: 'totalStock', key: 'totalStock', align: 'right', - width: 150, + width: 200, className: 'is-hidden-mobile no-wrap', render: (v) => <>{v.toLocaleString()} T },