Skip to content

Commit

Permalink
Fix warning and filter order only if it has date
Browse files Browse the repository at this point in the history
  • Loading branch information
kattylucy committed Jan 20, 2025
1 parent 5683512 commit 2fd563a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 30 deletions.
2 changes: 1 addition & 1 deletion centrifuge-app/src/components/Report/Orders.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
{
Expand Down
60 changes: 31 additions & 29 deletions centrifuge-js/src/modules/pools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
)
}
Expand Down

0 comments on commit 2fd563a

Please sign in to comment.