Skip to content

Commit

Permalink
Add feedback qa
Browse files Browse the repository at this point in the history
  • Loading branch information
kattylucy committed Oct 30, 2024
1 parent b6a0400 commit 45c5c19
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 32 deletions.
10 changes: 5 additions & 5 deletions centrifuge-app/src/components/Charts/AssetPerformanceChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -226,18 +226,18 @@ function AssetPerformanceChart({ pool, poolId, loanId }: Props) {
{payload.map(({ value }, index) => (
<>
<Shelf justifyContent="space-between" pl="4px" key={index}>
<Text variant="body3">{'Value'}</Text>
<Text variant="body3">Value</Text>
<Text variant="body3">
{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
)}`
: '-'}
Expand All @@ -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
)}`
: '-'}
Expand Down
8 changes: 4 additions & 4 deletions centrifuge-app/src/components/LoanList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@ export function LoanList({ loans }: Props) {
const attr = templateMetadata.attributes![key]
return {
align: 'left',
header: attr.label,
header: <SortableTableHeader label={attr.label} />,
cell: (l: Row) => <AssetMetadataField name={key} attribute={attr} loan={l} />,
sortKey: attr.label,
}
}) || []

Expand Down Expand Up @@ -232,7 +233,7 @@ export function LoanList({ loans }: Props) {
: [
{
align: 'left',
header: <SortableTableHeader label="Portfolio" />,
header: <SortableTableHeader label="Portfolio %" />,
cell: (l: Row) => formatPercentage(l.portfolioPercentage ?? 0, true, undefined, 1),
sortKey: 'portfolioSortKey',
},
Expand Down Expand Up @@ -364,8 +365,7 @@ export function AssetName({ loan }: { loan: Pick<Row, 'id' | 'poolId' | 'asset'
</Shelf>
)
}

function getAmount(l: Row, format?: boolean) {
export function getAmount(l: Row, format?: boolean) {
const pool = usePool(l.poolId)

Check failure on line 369 in centrifuge-app/src/components/LoanList.tsx

View workflow job for this annotation

GitHub Actions / build-app

React Hook "usePool" is called in function "getAmount" that is neither a React function component nor a custom React Hook function. React component names must start with an uppercase letter. React Hook names must start with the word "use"

Check failure on line 369 in centrifuge-app/src/components/LoanList.tsx

View workflow job for this annotation

GitHub Actions / ff-prod / build-app

React Hook "usePool" is called in function "getAmount" that is neither a React function component nor a custom React Hook function. React component names must start with an uppercase letter. React Hook names must start with the word "use"
switch (l.status) {
case 'Closed':
Expand Down
27 changes: 4 additions & 23 deletions centrifuge-app/src/pages/Pool/Assets/index.tsx
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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')

Expand All @@ -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) {
Expand All @@ -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))
Expand Down Expand Up @@ -117,7 +98,7 @@ export function PoolDetailAssets() {
...(!isTinlakePool && cashLoans.length
? [
{
label: <Tooltips label={`Offchain cash (${pool.currency.symbol})`} type="offchainCash" />,
label: <Tooltips label={`Offchain cash (USD)`} type="offchainCash" />,
value: <OffchainMenu value={formatBalance(offchainReserve)} loans={cashLoans} />,
heading: false,
},
Expand Down

0 comments on commit 45c5c19

Please sign in to comment.