// @flow import React from 'react'; import translate from 'translations'; import TokenRow from './TokenRow'; import AddCustomTokenForm from './AddCustomTokenForm'; import type { TokenBalance } from 'selectors/wallet'; import type { Token } from 'config/data'; type Props = { tokens: TokenBalance[], onAddCustomToken: (token: Token) => any, onRemoveCustomToken: (symbol: string) => any }; export default class TokenBalances extends React.Component { props: Props; state = { showAllTokens: false, showCustomTokenForm: false }; render() { const { tokens } = this.props; return (
{translate('sidebar_TokenBal')}
{tokens .filter(token => !token.balance.eq(0) || token.custom || this.state.showAllTokens) .map(token => )}
{!this.state.showAllTokens ? 'Show All Tokens' : 'Hide Tokens'}{' '} {translate('SEND_custom')} {this.state.showCustomTokenForm && }
); } toggleShowAllTokens = () => { this.setState(state => { return { showAllTokens: !state.showAllTokens }; }); }; toggleShowCustomTokenForm = () => { this.setState(state => { return { showCustomTokenForm: !state.showCustomTokenForm }; }); }; addCustomToken = (token: Token) => { this.props.onAddCustomToken(token); this.setState({ showCustomTokenForm: false }); }; }