Skip to content
This repository has been archived by the owner on Nov 10, 2023. It is now read-only.

Fix transaction description value #377

Merged
merged 2 commits into from
Dec 18, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -40,8 +41,7 @@ type Props = {
}

type TransferDescProps = {
value: string,
symbol: string,
amount: string,
recipient: string,
}

Expand All @@ -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>
Expand Down Expand Up @@ -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 (
Expand All @@ -108,9 +106,7 @@ const CustomDescription = ({
<Bold>
Send
{' '}
{value}
{' '}
ETH
{amount}
{' '}
to:
</Bold>
Expand Down Expand Up @@ -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>
)
Expand Down