// @flow import './index.scss'; 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; const shownTokens = tokens.filter( token => !token.balance.eq(0) || token.custom || this.state.showAllTokens ); return (
{translate('sidebar_TokenBal')}
{shownTokens.map(token => )}
{' '}
{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 }); }; }