From ac2c7c13ea74f672821c8e5c2da90ff94b855d6a Mon Sep 17 00:00:00 2001 From: George Lima Date: Tue, 19 Feb 2019 13:06:34 -0300 Subject: [PATCH] feat(transactions): add fee to transactions lists --- app/components/transaction-daily.js | 5 +-- app/components/transaction-details.js | 52 ++++++++++----------------- app/components/transaction-item.js | 19 ++++------ app/components/wallet-address.js | 25 ++++--------- app/containers/dashboard.js | 3 +- app/containers/transactions.js | 1 + app/views/transactions.js | 1 + 7 files changed, 39 insertions(+), 67 deletions(-) diff --git a/app/components/transaction-daily.js b/app/components/transaction-daily.js index b2d13dd..b063351 100644 --- a/app/components/transaction-daily.js +++ b/app/components/transaction-daily.js @@ -39,16 +39,17 @@ export const TransactionDailyComponent = ({ transactionsDate, transactions, zecP {transactions.map(({ - date, type, address, amount, transactionId, + date, type, address, amount, transactionId, fees, }) => ( ))} diff --git a/app/components/transaction-details.js b/app/components/transaction-details.js index 777109c..f552313 100644 --- a/app/components/transaction-details.js +++ b/app/components/transaction-details.js @@ -21,7 +21,6 @@ import { ColumnComponent } from './column'; import { appTheme } from '../theme'; import { formatNumber } from '../utils/format-number'; -import { truncateAddress } from '../utils/truncate-address'; import { openExternal } from '../utils/open-external'; const Wrapper = styled.div` @@ -127,8 +126,8 @@ type Props = { zecPrice: number, date: string, transactionId: string, - from: string, - to: string, + address: string, + fees: number | string, handleClose: () => void, theme: AppTheme, }; @@ -139,35 +138,25 @@ const Component = ({ zecPrice, date, transactionId, - from, - to, + address, + fees, handleClose, theme, }: Props) => { const isReceived = type === 'receive'; - const receivedIcon = theme.mode === DARK - ? ReceivedIconDark - : ReceivedIconLight; - const sentIcon = theme.mode === DARK - ? SentIconDark - : SentIconLight; + const receivedIcon = theme.mode === DARK ? ReceivedIconDark : ReceivedIconLight; + const sentIcon = theme.mode === DARK ? SentIconDark : SentIconLight; return ( - + - + @@ -207,7 +200,7 @@ const Component = ({ diff --git a/app/components/transaction-item.js b/app/components/transaction-item.js index 2052120..9c51ed9 100644 --- a/app/components/transaction-item.js +++ b/app/components/transaction-item.js @@ -71,6 +71,7 @@ export type Transaction = { date: string, address: string, amount: number, + fees: number | string, zecPrice: number, transactionId: string, theme: AppTheme, @@ -81,6 +82,7 @@ const Component = ({ date, address, amount, + fees, zecPrice, transactionId, theme, @@ -97,12 +99,8 @@ const Component = ({ }); const transactionAddress = truncateAddress(address); - const receivedIcon = theme.mode === DARK - ? ReceivedIconDark - : ReceivedIconLight; - const sentIcon = theme.mode === DARK - ? SentIconDark - : SentIconLight; + const receivedIcon = theme.mode === DARK ? ReceivedIconDark : ReceivedIconLight; + const sentIcon = theme.mode === DARK ? SentIconDark : SentIconLight; return ( @@ -141,8 +136,8 @@ const Component = ({ { const { address, theme } = this.props; const { showQRCode, showCopiedTooltip } = this.state; - const qrCodeIcon = theme.mode === DARK - ? ScanIconDark - : ScanIconLight; + const qrCodeIcon = theme.mode === DARK ? ScanIconDark : ScanIconLight; - const copyIcon = theme.mode === DARK - ? CopyIconDark - : CopyIconLight; + const copyIcon = theme.mode === DARK ? CopyIconDark : CopyIconLight; return ( @@ -155,27 +151,18 @@ class Component extends PureComponent { onClick={this.toggleMoreInfo} onDoubleClick={this.showMoreInfo} /> - + {}}> {!showCopiedTooltip ? null : ( )} - + - + {!showQRCode ? null : ( diff --git a/app/containers/dashboard.js b/app/containers/dashboard.js index e2477a6..27c8c9f 100644 --- a/app/containers/dashboard.js +++ b/app/containers/dashboard.js @@ -50,11 +50,12 @@ const mapDispatchToProps = (dispatch: Dispatch) => ({ const formattedTransactions: Array = flow([ arr => arr.map(transaction => ({ - transactionId: transaction.txid, + transactionId: transaction.txid || 'N/A', type: transaction.category, date: new Date(transaction.time * 1000).toISOString(), address: transaction.address, amount: Math.abs(transaction.amount), + fees: transaction.fee ? new BigNumber(transaction.fee).abs().toFormat(4) : 'N/A', })), arr => groupBy(arr, obj => dateFns.format(obj.date, 'MMM DD, YYYY')), obj => Object.keys(obj).map(day => ({ diff --git a/app/containers/transactions.js b/app/containers/transactions.js index a6d3a78..5fefe14 100644 --- a/app/containers/transactions.js +++ b/app/containers/transactions.js @@ -70,6 +70,7 @@ const mapDispatchToProps = (dispatch: Dispatch): MapDispatchToProps => ({ date: new Date(transaction.time * 1000).toISOString(), address: transaction.address, amount: new BigNumber(transaction.amount).absoluteValue().toNumber(), + fees: transaction.fee ? new BigNumber(transaction.fee).abs().toFormat(4) : 'N/A', })), ); diff --git a/app/views/transactions.js b/app/views/transactions.js index 0c61066..3034951 100644 --- a/app/views/transactions.js +++ b/app/views/transactions.js @@ -111,6 +111,7 @@ export class TransactionsView extends PureComponent {