From 79e05c04ef798bd609e188da3ca8e1c0457c74f9 Mon Sep 17 00:00:00 2001 From: JP Angelle Date: Mon, 11 Sep 2023 13:01:19 -0500 Subject: [PATCH] use loan specific transaction types --- .../src/pages/Loan/HoldingsValues.tsx | 21 +++++++------------ .../src/pages/Loan/TransactionTable.tsx | 14 +++++++++---- centrifuge-app/src/pages/Loan/index.tsx | 10 ++++++++- 3 files changed, 27 insertions(+), 18 deletions(-) diff --git a/centrifuge-app/src/pages/Loan/HoldingsValues.tsx b/centrifuge-app/src/pages/Loan/HoldingsValues.tsx index 774be83f52..6007b2f30d 100644 --- a/centrifuge-app/src/pages/Loan/HoldingsValues.tsx +++ b/centrifuge-app/src/pages/Loan/HoldingsValues.tsx @@ -10,7 +10,7 @@ type Props = { } export function HoldingsValues({ loan: { pricing }, pool, transactions }: Props) { - const currentHolding = + const netCash = transactions?.reduce((sum, trx) => { if (trx.type === 'REPAID') { sum = new CurrencyBalance( @@ -33,7 +33,7 @@ export function HoldingsValues({ loan: { pricing }, pool, transactions }: Props) return sum }, new CurrencyBalance(0, 27)) || new CurrencyBalance(0, 27) - const currentTotalFace = + const currentFace = transactions?.reduce((sum, trx) => { if (trx.type === 'BORROWED') { sum = new CurrencyBalance(sum.add(trx.amount || new CurrencyBalance(0, 27)), 27) @@ -47,26 +47,21 @@ export function HoldingsValues({ loan: { pricing }, pool, transactions }: Props) return ( <> { +export const TransactionTable = ({ transactions, currency, loanType }: Props) => { const assetTransactions = useMemo(() => { const sortedTransactions = transactions.sort((a, b) => { if (a.timestamp > b.timestamp) { @@ -52,6 +53,13 @@ export const TransactionTable = ({ transactions, currency }: Props) => { return 'default' } + const getStatusText = (type: BorrowerTransactionType) => { + if (loanType === 'external' && type === 'BORROWED') return 'Purchase' + if (loanType === 'external' && type === 'REPAID') return 'Sale' + + return `${type[0]}${type.slice(1).toLowerCase()}` + } + return ( { align: 'left', header: 'Type', cell: (row: { type: BorrowerTransactionType }) => ( - {`${row.type[0]}${row.type - .slice(1) - .toLowerCase()}`} + {getStatusText(row.type)} ), flex: '3', }, diff --git a/centrifuge-app/src/pages/Loan/index.tsx b/centrifuge-app/src/pages/Loan/index.tsx index 25c7753427..d1ddf69d0a 100644 --- a/centrifuge-app/src/pages/Loan/index.tsx +++ b/centrifuge-app/src/pages/Loan/index.tsx @@ -275,7 +275,15 @@ const Loan: React.FC<{ setShowOraclePricing?: () => void }> = ({ setShowOraclePr } > - + ) : null}