import React, { Component } from 'react' import PropTypes from 'prop-types' import { DEFAULT_ROUTE } from '../../../routes' import Button from '../../button' import Identicon from '../../../components/identicon' import TokenBalance from '../confirm-add-token/token-balance' export default class ConfirmAddSuggestedToken extends Component { static contextTypes = { t: PropTypes.func, } static propTypes = { history: PropTypes.object, clearPendingTokens: PropTypes.func, addToken: PropTypes.func, pendingTokens: PropTypes.object, removeSuggestedTokens: PropTypes.func, } componentDidMount () { const { pendingTokens = {}, history } = this.props if (Object.keys(pendingTokens).length === 0) { history.push(DEFAULT_ROUTE) } } getTokenName (name, symbol) { return typeof name === 'undefined' ? symbol : `${name} (${symbol})` } render () { const { addToken, clearPendingTokens, pendingTokens, removeSuggestedTokens, history } = this.props const pendingTokenKey = Object.keys(pendingTokens)[0] const pendingToken = pendingTokens[pendingTokenKey] return (
{ this.context.t('addSuggestedTokens') }
{ this.context.t('likeToAddTokens') }
{ this.context.t('token') }
{ this.context.t('balance') }
{ Object.entries(pendingTokens) .map(([ address, token ]) => { const { name, symbol, imageUrl } = token return (
{ this.getTokenName(name, symbol) }
) }) }
) } }