Skip to content

Commit

Permalink
make all TransactionSummaryScreenProps consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigoncalves committed Feb 7, 2024
1 parent 61cff1a commit 29e7ffe
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 26 deletions.
28 changes: 16 additions & 12 deletions src/screens/activity/ActivityRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,15 @@ export const ActivityBasicRow = ({
const usdBalance = roundBalance(price, 2)

const txSummary: TransactionSummaryScreenProps = useMemo(() => {
const feeUsd = roundBalance(Number(fee.usdValue), 2)
const totalUsd = Number(price) + Number(fee.usdValue)
const tokenUsd = usdBalance.toFixed(2)
const feeUsd = Number(fee.usdValue).toFixed(2)
const totalUsd = (Number(tokenUsd) + Number(feeUsd)).toFixed(2)
const isAmountSmall = !usdBalance && !!price

const totalToken =
symbol === fee.symbol
? Number(value) + Number(fee.tokenValue)
: Number(value)

return {
transaction: {
Expand All @@ -92,21 +99,18 @@ export const ActivityBasicRow = ({
balance: value,
},
usdValue: {
symbol: usdBalance || !price ? '$' : '<',
symbol: isAmountSmall ? '<' : '$',
symbolType: 'usd',
balance: price ? usdBalance.toFixed(2) || '0.01' : '0.00',
balance: isAmountSmall ? '0.01' : tokenUsd,
},
totalToken:
symbol === fee.symbol
? Number(value) + Number(fee.tokenValue)
: Number(value),
totalUsd: roundBalance(totalUsd, 2).toFixed(2),
status,
fee: {
tokenValue: fee.tokenValue,
symbol: fee.symbol || symbol,
usdValue: feeUsd.toFixed(2),
tokenValue: fee.tokenValue,
usdValue: feeUsd,
},
totalToken,
totalUsd: totalUsd,
status,
amIReceiver,
from,
to,
Expand Down
13 changes: 6 additions & 7 deletions src/ux/requestsModal/ReviewBitcoinTransactionContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export const ReviewBitcoinTransactionContainer = ({
const feeUsd = convertToUSD(miningFee)
const isAmountSmall = !Number(amountToPayUsd) && !!Number(amountToPay)

const totalBtc = Number(amountToPay) + Number(miningFee)
return {
transaction: {
tokenValue: {
Expand All @@ -93,20 +94,18 @@ export const ReviewBitcoinTransactionContainer = ({
symbol: TokenSymbol.BTC,
},
usdValue: {
balance: isAmountSmall ? '0.01' : amountToPayUsd,
symbolType: 'usd',
symbol: isAmountSmall ? '<' : '$',
symbolType: 'usd',
balance: isAmountSmall ? '0.01' : amountToPayUsd,
},
fee: {
symbol: TokenSymbol.BTC,
tokenValue: miningFee,
usdValue: feeUsd,
symbol: TokenSymbol.BTC,
},
totalToken: totalBtc,
totalUsd: formatTokenValues(Number(amountToPayUsd) + Number(feeUsd)),
time: 'approx 1 min',
total: {
tokenValue: amountToPay,
usdValue: formatTokenValues(Number(amountToPayUsd) + Number(feeUsd)),
},
to: addressToPay,
},
buttons: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,16 +206,15 @@ export const ReviewTransactionContainer = ({
Alert.alert(t('transaction_summary_insufficient_funds'))
}

// get usd values
const tokenUsd = convertTokenToUSD(Number(value), tokenQuote)
const feeUsd = convertTokenToUSD(Number(feeValue), feeQuote)
// usd values
const tokenUsd = convertTokenToUSD(Number(value), tokenQuote).toFixed(2)
const feeUsd = convertTokenToUSD(Number(feeValue), feeQuote).toFixed(2)
const totalUsd = (Number(tokenUsd) + Number(feeUsd)).toFixed(2)
const isAmountSmall = !Number(tokenUsd) && !!Number(value)

const totalToken =
symbol === feeSymbol ? Number(value) + Number(feeValue) : Number(value)

const totalUsd = (Number(tokenUsd) + Number(feeUsd)).toFixed(2)

return {
transaction: {
tokenValue: {
Expand All @@ -229,9 +228,9 @@ export const ReviewTransactionContainer = ({
balance: isAmountSmall ? '0.01' : tokenUsd,
},
fee: {
tokenValue: rbtcFeeValue ?? feeValue,
usdValue: formatTokenValues(feeUsd),
symbol: feeSymbol,
tokenValue: rbtcFeeValue ?? feeValue,
usdValue: feeUsd,
},
totalToken,
totalUsd,
Expand Down

0 comments on commit 29e7ffe

Please sign in to comment.