From 2fd563a6b5db798162fc54c8784f0b2393ecc43e Mon Sep 17 00:00:00 2001 From: katty barroso Date: Mon, 20 Jan 2025 12:06:46 +0100 Subject: [PATCH] Fix warning and filter order only if it has date --- .../src/components/Report/Orders.tsx | 2 +- centrifuge-js/src/modules/pools.ts | 60 ++++++++++--------- 2 files changed, 32 insertions(+), 30 deletions(-) diff --git a/centrifuge-app/src/components/Report/Orders.tsx b/centrifuge-app/src/components/Report/Orders.tsx index c9158fba7..024655488 100644 --- a/centrifuge-app/src/components/Report/Orders.tsx +++ b/centrifuge-app/src/components/Report/Orders.tsx @@ -22,7 +22,7 @@ const Orders = ({ pool }: { pool: Pool }) => { const oldestTimestamp = Math.min(...dateStrings.map((date) => new Date(date).getTime())) const oldestDate = new Date(oldestTimestamp).toISOString().split('T')[0] setStartDate(oldestDate) - }, []) + }, [setStartDate, orders]) const columnsConfig = [ { diff --git a/centrifuge-js/src/modules/pools.ts b/centrifuge-js/src/modules/pools.ts index 785aedd4b..8ef311b6f 100644 --- a/centrifuge-js/src/modules/pools.ts +++ b/centrifuge-js/src/modules/pools.ts @@ -3986,35 +3986,37 @@ export function getPoolsModule(inst: Centrifuge) { return $query.pipe( combineLatestWith(getPoolCurrency([poolId])), map(([data, poolCurrency]) => { - return data?.epoches?.nodes.map((order) => { - const index = order.epochStates.nodes.length > 1 ? order.epochStates.nodes.length - 1 : 0 - const snapshotIndex = order.poolSnapshots.nodes.length > 1 ? order.poolSnapshots.nodes.length - 1 : 0 - return { - epochId: order.id, - closedAt: order.closedAt, - paidFees: order.sumPoolFeesPaidAmount - ? new CurrencyBalance(order.sumPoolFeesPaidAmount, poolCurrency.decimals) - : null, - tokenPrice: order.epochStates.nodes[index].tokenPrice - ? new Price(order.epochStates.nodes[index].tokenPrice) - : null, - sumOutstandingInvestOrders: order.epochStates.nodes[index].sumOutstandingInvestOrders - ? new CurrencyBalance(order.epochStates.nodes[index].sumOutstandingInvestOrders, poolCurrency.decimals) - : null, - sumFulfilledInvestOrders: order.epochStates.nodes[index].sumFulfilledInvestOrders - ? new CurrencyBalance(order.epochStates.nodes[index].sumFulfilledInvestOrders, poolCurrency.decimals) - : null, - sumOutstandingRedeemOrders: order.epochStates.nodes[index].sumOutstandingRedeemOrders - ? new CurrencyBalance(order.epochStates.nodes[index].sumOutstandingRedeemOrders, poolCurrency.decimals) - : null, - sumFulfilledRedeemOrders: order.epochStates.nodes[index].sumFulfilledRedeemOrders - ? new CurrencyBalance(order.epochStates.nodes[index].sumFulfilledRedeemOrders, poolCurrency.decimals) - : null, - netAssetValue: order.poolSnapshots.nodes.length - ? new CurrencyBalance(order.poolSnapshots.nodes[snapshotIndex].netAssetValue, poolCurrency.decimals) - : null, - } - }) + return data?.epoches?.nodes + .map((order) => { + const index = order.epochStates.nodes.length > 1 ? order.epochStates.nodes.length - 1 : 0 + const snapshotIndex = order.poolSnapshots.nodes.length > 1 ? order.poolSnapshots.nodes.length - 1 : 0 + return { + epochId: order.id, + closedAt: order.closedAt, + paidFees: order.sumPoolFeesPaidAmount + ? new CurrencyBalance(order.sumPoolFeesPaidAmount, poolCurrency.decimals) + : null, + tokenPrice: order.epochStates.nodes[index].tokenPrice + ? new Price(order.epochStates.nodes[index].tokenPrice) + : null, + sumOutstandingInvestOrders: order.epochStates.nodes[index].sumOutstandingInvestOrders + ? new CurrencyBalance(order.epochStates.nodes[index].sumOutstandingInvestOrders, poolCurrency.decimals) + : null, + sumFulfilledInvestOrders: order.epochStates.nodes[index].sumFulfilledInvestOrders + ? new CurrencyBalance(order.epochStates.nodes[index].sumFulfilledInvestOrders, poolCurrency.decimals) + : null, + sumOutstandingRedeemOrders: order.epochStates.nodes[index].sumOutstandingRedeemOrders + ? new CurrencyBalance(order.epochStates.nodes[index].sumOutstandingRedeemOrders, poolCurrency.decimals) + : null, + sumFulfilledRedeemOrders: order.epochStates.nodes[index].sumFulfilledRedeemOrders + ? new CurrencyBalance(order.epochStates.nodes[index].sumFulfilledRedeemOrders, poolCurrency.decimals) + : null, + netAssetValue: order.poolSnapshots.nodes.length + ? new CurrencyBalance(order.poolSnapshots.nodes[snapshotIndex].netAssetValue, poolCurrency.decimals) + : null, + } + }) + .filter((order) => order.closedAt) }) ) }