/* @flow */ import React from 'react'; import BigNumber from 'bignumber.js'; import type { Props as BaseProps } from './index'; import type { Coin } from '~/js/reducers/LocalStorageReducer'; type Props = { // coin: $PropertyType<$ElementType, 'coin'>, coin: Coin, summary: $ElementType, balance: string, network: string, fiat: $ElementType, onToggle: $ElementType } const SummaryDetails = (props: Props): ?React$Element => { if (!props.summary.details) { return (
); } const selectedCoin = props.coin; const fiatRate = props.fiat.find(f => f.network === selectedCoin.network); let balanceColumn = null; let rateColumn = null; if (fiatRate) { const accountBalance = new BigNumber(props.balance); const fiatValue = new BigNumber(fiatRate.value); const fiat = accountBalance.times(fiatValue).toFixed(2); balanceColumn = (
Balance
${ fiat }
{ props.balance } { selectedCoin.symbol }
); rateColumn = (
Rate
${ fiatValue.toFixed(2) }
1.00 { selectedCoin.symbol }
); } else { balanceColumn = (
Balance
{ props.balance } { selectedCoin.symbol }
); } return (
{ balanceColumn } { rateColumn }
); }; export default SummaryDetails;