Fix transaction description value (#377)

* Fix transaction description value

* Remove duplicated symbols
This commit is contained in:
Germán Martínez 2019-12-18 11:19:25 +01:00 committed by GitHub
parent 2dafa88337
commit 87b883ae77
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 14 deletions

View File

@ -1,6 +1,7 @@
// @flow
import React, { useState } from 'react'
import { withStyles } from '@material-ui/core/styles'
import { getTxAmount } from '~/routes/safe/components/Transactions/TxsTable/columns'
import { type Transaction } from '~/routes/safe/store/models/transaction'
import Bold from '~/components/layout/Bold'
import EtherscanLink from '~/components/EtherscanLink'
@ -40,8 +41,7 @@ type Props = {
}
type TransferDescProps = {
value: string,
symbol: string,
amount: string,
recipient: string,
}
@ -52,20 +52,18 @@ type DescriptionDescProps = {
}
type CustomDescProps = {
value: string,
amount: string,
recipient: string,
data: String,
classes: Object,
}
const TransferDescription = ({ value = '', symbol, recipient }: TransferDescProps) => (
const TransferDescription = ({ amount = '', recipient }: TransferDescProps) => (
<Block data-testid={TRANSACTIONS_DESC_SEND_TEST_ID}>
<Bold>
Send
{' '}
{value}
{' '}
{symbol}
{amount}
{' '}
to:
</Bold>
@ -99,7 +97,7 @@ const SettingsDescription = ({ removedOwner, addedOwner, newThreshold }: Descrip
)
const CustomDescription = ({
data, value = 0, recipient, classes,
data, amount = 0, recipient, classes,
}: CustomDescProps) => {
const [showTxData, setShowTxData] = useState(false)
return (
@ -108,9 +106,7 @@ const CustomDescription = ({
<Bold>
Send
{' '}
{value}
{' '}
ETH
{amount}
{' '}
to:
</Bold>
@ -156,18 +152,27 @@ const CustomDescription = ({
const TxDescription = ({ tx, classes }: Props) => {
const {
recipient, value, modifySettingsTx, removedOwner, addedOwner, newThreshold, cancellationTx, customTx, creationTx, data,
recipient,
modifySettingsTx,
removedOwner,
addedOwner,
newThreshold,
cancellationTx,
customTx,
creationTx,
data,
} = getTxData(tx)
const amount = getTxAmount(tx)
return (
<Block className={classes.txDataContainer}>
{modifySettingsTx && (
<SettingsDescription removedOwner={removedOwner} newThreshold={newThreshold} addedOwner={addedOwner} />
)}
{customTx && (
<CustomDescription data={data} value={value} recipient={recipient} classes={classes} />
<CustomDescription data={data} amount={amount} recipient={recipient} classes={classes} />
)}
{!cancellationTx && !modifySettingsTx && !customTx && !creationTx && (
<TransferDescription value={value} symbol={tx.symbol} recipient={recipient} />
<TransferDescription amount={amount} recipient={recipient} />
)}
</Block>
)