import React, { Component } from 'react' import PropTypes from 'prop-types' import { ASSET_ROUTE, ADD_TOKEN_ROUTE } from '../../helpers/constants/routes' import Button from '../../components/ui/button' import Identicon from '../../components/ui/identicon' import TokenBalance from '../../components/ui/token-balance' export default class ConfirmAddToken extends Component { static contextTypes = { t: PropTypes.func, } static propTypes = { history: PropTypes.object, clearPendingTokens: PropTypes.func, addTokens: PropTypes.func, mostRecentOverviewPage: PropTypes.string.isRequired, pendingTokens: PropTypes.object, } componentDidMount() { const { mostRecentOverviewPage, pendingTokens = {}, history } = this.props if (Object.keys(pendingTokens).length === 0) { history.push(mostRecentOverviewPage) } } getTokenName(name, symbol) { return typeof name === 'undefined' ? symbol : `${name} (${symbol})` } render() { const { history, addTokens, clearPendingTokens, mostRecentOverviewPage, pendingTokens, } = this.props return (
{this.context.t('addTokens')}
{this.context.t('likeToAddTokens')}
{this.context.t('token')}
{this.context.t('balance')}
{Object.entries(pendingTokens).map(([address, token]) => { const { name, symbol } = token return (
{this.getTokenName(name, symbol)}
) })}
) } }