From 3e4e671277944019477eaa6bd570b6fd05903a69 Mon Sep 17 00:00:00 2001 From: slowbackspace Date: Tue, 12 Mar 2019 11:47:14 +0100 Subject: [PATCH] react intl support for balance in account menu --- .../components/AccountMenu/index.js | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/src/views/Wallet/components/LeftNavigation/components/AccountMenu/index.js b/src/views/Wallet/components/LeftNavigation/components/AccountMenu/index.js index c576e61e..9d4dac40 100644 --- a/src/views/Wallet/components/LeftNavigation/components/AccountMenu/index.js +++ b/src/views/Wallet/components/LeftNavigation/components/AccountMenu/index.js @@ -8,7 +8,7 @@ import styled, { css } from 'styled-components'; import * as stateUtils from 'reducers/utils'; import Tooltip from 'components/Tooltip'; import ICONS from 'config/icons'; -import { FormattedMessage } from 'react-intl'; +import { FormattedMessage, FormattedNumber } from 'react-intl'; import { toFiatCurrency } from 'utils/fiatConverter'; import { NavLink } from 'react-router-dom'; @@ -112,6 +112,9 @@ const AccountMenu = (props: Props) => { const url: string = location.pathname.replace(/account+\/([0-9]*)/, `account/${i}`); let balance: ?string = null; + const fiatRates = props.fiat.find(f => f.network === network.shortcut); + const { localCurrency } = props.wallet; + let fiat = ''; if (account.balance !== '') { const pending = stateUtils.getAccountPendingTx(props.pending, account); const pendingAmount: BigNumber = stateUtils.getPendingAmount(pending, network.symbol); @@ -120,13 +123,9 @@ const AccountMenu = (props: Props) => { .toString(10); balance = `${availableBalance} ${network.symbol}`; - const fiatRates = props.fiat.find(f => f.network === network.shortcut); if (fiatRates) { - const { localCurrency } = props.wallet; - const fiat = toFiatCurrency(availableBalance, localCurrency, fiatRates.rates); - balance = `${availableBalance} ${ - network.symbol - } / ${localCurrency.toUpperCase()} ${fiat}`; + fiat = toFiatCurrency(availableBalance, localCurrency, fiatRates.rates); + balance = `${availableBalance} ${network.symbol} / `; } } @@ -142,7 +141,20 @@ const AccountMenu = (props: Props) => { {...l10nCommonMessages.TR_ACCOUNT_HASH} values={{ number: account.index + 1 }} /> - {balance && {balance}} + {balance && ( + + {balance} + {fiatRates && ( + + )} + + )} {!balance && (