import { TFetchCCRates } from 'actions/rates'; import { Identicon } from 'components/ui'; import { NetworkConfig } from 'config/data'; import { Ether } from 'libs/units'; import { IWallet } from 'libs/wallet'; import React from 'react'; import translate from 'translations'; import { formatNumber } from 'utils/formatters'; import './AccountInfo.scss'; interface Props { balance: Ether; wallet: IWallet; network: NetworkConfig; fetchCCRates: TFetchCCRates; } interface State { showLongBalance: boolean; address: string; } export default class AccountInfo extends React.Component { public state = { showLongBalance: false, address: '' }; public componentDidMount() { this.props.fetchCCRates(); this.props.wallet.getAddress().then(address => { this.setState({ address }); }); } // TODO: don't use any; public toggleShowLongBalance = (e: any) => { e.preventDefault(); this.setState(state => { return { showLongBalance: !state.showLongBalance }; }); }; public render() { const { network, balance } = this.props; const { blockExplorer, tokenExplorer } = network; const { address } = this.state; return (
{translate('sidebar_AccountAddr')}
{address}
{translate('sidebar_AccountBal')}
  • {this.state.showLongBalance ? balance ? balance.toString() : '???' : balance ? formatNumber(balance.amount) : '???'} {` ${network.name}`}
{(!!blockExplorer || !!tokenExplorer) && (
{translate('sidebar_TransHistory')}
)}
); } }