diff --git a/apps/web/app/[language]/homestead/nodes/page.tsx b/apps/web/app/[language]/homestead/nodes/page.tsx index a34b3f4c5..f5bbbbe6b 100644 --- a/apps/web/app/[language]/homestead/nodes/page.tsx +++ b/apps/web/app/[language]/homestead/nodes/page.tsx @@ -18,6 +18,8 @@ import type { Metadata } from 'next'; import { getAlternateUrls } from '@/lib/url'; import { Gw2Accounts } from '@/components/Gw2Api/Gw2Accounts'; import { Scope } from '@gw2me/client'; +import { isDefined } from '@gw2treasures/helper/is'; +import { FlexRow } from '@gw2treasures/ui/components/Layout/FlexRow'; const getItems = cache( async (ids: number[]) => { @@ -37,19 +39,20 @@ const getItems = cache( ); export default async function HomesteadNodesPage() { - // get item ids that unlock some node - const nodeUnlockItemIds = homeNodes.reduce( - (ids, node) => [...ids, ...node.unlock_items], + // collect all the item ids + const itemIds = homeNodes.reduce( + (ids, node) => [...ids, ...node.unlock_items, ...(node.gathered_items ?? [])], [] ); // get items from db that unlock some node - const unlockItems = await getItems(nodeUnlockItemIds); + const items = await getItems(itemIds); // add the item to each node const nodes = homeNodes.map((node) => ({ ...node, - item: unlockItems[node.unlock_items[0]] + item: items[node.unlock_items[0]], + gatheredItems: node.gathered_items?.map((id) => items[id]).filter(isDefined) })); // create data-table @@ -66,6 +69,7 @@ export default async function HomesteadNodesPage() { } sortBy="id" small hidden>{({ id }) => id} {({ item, name }) => item ? : name} + {({ gatheredItems }) => {gatheredItems?.map((item) => )}} } sortBy={({ item }) => item.buyPrice} align="right">{({ item }) => itemTableColumn.buyPrice(item, {})} } align="right">{({ item }) => itemTableColumn.buyPriceTrend(item, {})} } sortBy={({ item }) => item.buyQuantity} align="right" hidden>{({ item }) => itemTableColumn.buyQuantity(item, {})}