diff --git a/centrifuge-app/src/components/Charts/AssetPerformanceChart.tsx b/centrifuge-app/src/components/Charts/AssetPerformanceChart.tsx index bf3e75c2b2..19e0a70428 100644 --- a/centrifuge-app/src/components/Charts/AssetPerformanceChart.tsx +++ b/centrifuge-app/src/components/Charts/AssetPerformanceChart.tsx @@ -226,18 +226,18 @@ function AssetPerformanceChart({ pool, poolId, loanId }: Props) { {payload.map(({ value }, index) => ( <> - {'Value'} + Value {payload[0].payload.historicPV ? formatBalance( payload[0].payload.historicPV, - isNonCash ? 'USD' : pool.currency.symbol, + isNonCash ? pool.currency.symbol : 'USD', 2 ) : payload[0].payload.futurePV ? `~${formatBalance( payload[0].payload.futurePV, - isNonCash ? 'USD' : pool.currency.symbol, + isNonCash ? pool.currency.symbol : 'USD', 2 )}` : '-'} @@ -249,13 +249,13 @@ function AssetPerformanceChart({ pool, poolId, loanId }: Props) { {payload[0].payload.historicPrice ? formatBalance( payload[0].payload.historicPrice, - isNonCash ? 'USD' : pool.currency.symbol, + isNonCash ? pool.currency.symbol : 'USD', 6 ) : payload[0].payload.futurePrice ? `~${formatBalance( payload[0].payload.futurePrice, - isNonCash ? 'USD' : pool.currency.symbol, + isNonCash ? pool.currency.symbol : 'USD', 6 )}` : '-'} diff --git a/centrifuge-app/src/components/LoanList.tsx b/centrifuge-app/src/components/LoanList.tsx index 3eeb751b54..51834894bf 100644 --- a/centrifuge-app/src/components/LoanList.tsx +++ b/centrifuge-app/src/components/LoanList.tsx @@ -68,8 +68,9 @@ export function LoanList({ loans }: Props) { const attr = templateMetadata.attributes![key] return { align: 'left', - header: attr.label, + header: , cell: (l: Row) => , + sortKey: attr.label, } }) || [] @@ -232,7 +233,7 @@ export function LoanList({ loans }: Props) { : [ { align: 'left', - header: , + header: , cell: (l: Row) => formatPercentage(l.portfolioPercentage ?? 0, true, undefined, 1), sortKey: 'portfolioSortKey', }, @@ -364,8 +365,7 @@ export function AssetName({ loan }: { loan: Pick ) } - -function getAmount(l: Row, format?: boolean) { +export function getAmount(l: Row, format?: boolean) { const pool = usePool(l.poolId) switch (l.status) { case 'Closed': diff --git a/centrifuge-app/src/pages/Pool/Assets/index.tsx b/centrifuge-app/src/pages/Pool/Assets/index.tsx index fa2e856a17..5336140979 100644 --- a/centrifuge-app/src/pages/Pool/Assets/index.tsx +++ b/centrifuge-app/src/pages/Pool/Assets/index.tsx @@ -1,12 +1,12 @@ import { CurrencyBalance, Loan } from '@centrifuge/centrifuge-js' import { Box, IconChevronRight, IconPlus, Shelf, Text } from '@centrifuge/fabric' import * as React from 'react' -import { useNavigate, useParams } from 'react-router' +import { useParams } from 'react-router' import styled from 'styled-components' import { RouterTextLink } from '../../../../src/components/TextLink' import { useBasePath } from '../../../../src/utils/useBasePath' import { LoadBoundary } from '../../../components/LoadBoundary' -import { LoanList } from '../../../components/LoanList' +import { LoanList, getAmount } from '../../../components/LoanList' import { PageSummary } from '../../../components/PageSummary' import { RouterLinkButton } from '../../../components/RouterLinkButton' import { Tooltips } from '../../../components/Tooltips' @@ -37,7 +37,6 @@ export function PoolDetailAssetsTab() { export function PoolDetailAssets() { const { pid: poolId } = useParams<{ pid: string }>() - const navigate = useNavigate() if (!poolId) throw new Error('Pool not found') @@ -49,8 +48,6 @@ export function PoolDetailAssets() { (loan) => 'valuationMethod' in loan.pricing && loan.pricing.valuationMethod === 'cash' ) - console.log(pool) - if (!pool) return null if (!loans?.length) { @@ -66,24 +63,8 @@ export function PoolDetailAssets() { return pricing && typeof pricing.valuationMethod === 'string' } - const getAmount = (loan: Loan) => { - switch (loan.status) { - case 'Closed': - return loan.totalRepaid - - case 'Active': - return loan.presentValue ?? (loan.outstandingDebt.isZero() ? loan.totalRepaid : loan.outstandingDebt) - - case 'Created': - return 0 - - default: - return pool.reserve.total - } - } - const totalAssets = loans.reduce((sum, loan) => { - const amount = new CurrencyBalance(getAmount(loan as Loan), pool.currency.decimals).toDecimal() + const amount = new CurrencyBalance(getAmount(loan as any), pool.currency.decimals).toDecimal() return sum.add(amount) }, Dec(0)) @@ -117,7 +98,7 @@ export function PoolDetailAssets() { ...(!isTinlakePool && cashLoans.length ? [ { - label: , + label: , value: , heading: false, },