import { TFetchCCRates } from 'actions/rates'; import { Identicon, UnitDisplay } from 'components/ui'; import { NetworkConfig } from 'config/data'; import { IWallet, Balance } from 'libs/wallet'; import React from 'react'; import translate from 'translations'; import './AccountInfo.scss'; import Spinner from 'components/ui/Spinner'; interface Props { balance: Balance; 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 async setAddressFromWallet() { const address = await this.props.wallet.getAddressString(); if (address !== this.state.address) { this.setState({ address }); } } public componentDidMount() { this.props.fetchCCRates(); this.setAddressFromWallet(); } public componentDidUpdate() { this.setAddressFromWallet(); } // 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, showLongBalance } = this.state; return (
{translate('sidebar_AccountAddr')}
{address}
{translate('sidebar_AccountBal')}
  • {balance.isPending ? ( ) : ( )} {!balance.isPending ? ( balance.wei ? ( {network.name} ) : null ) : null}
{(!!blockExplorer || !!tokenExplorer) && (
{translate('sidebar_TransHistory')}
)}
); } }