import React, { Component } from 'react' import PropTypes from 'prop-types' import classnames from 'classnames' import { checkExistingAddresses } from '../../../helpers/utils/util' import TokenListPlaceholder from './token-list-placeholder' export default class InfoBox extends Component { static contextTypes = { t: PropTypes.func, } static propTypes = { tokens: PropTypes.array, results: PropTypes.array, selectedTokens: PropTypes.object, onToggleToken: PropTypes.func, } render () { const { results = [], selectedTokens = {}, onToggleToken, tokens = [] } = this.props return results.length === 0 ? : (
{ this.context.t('searchResults') }
{ Array(6).fill(undefined) .map((_, i) => { const { logo, symbol, name, address } = results[i] || {} const tokenAlreadyAdded = checkExistingAddresses(address, tokens) return Boolean(logo || symbol || name) && (
!tokenAlreadyAdded && onToggleToken(results[i])} key={i} >
{ `${name} (${symbol})` }
) }) }
) } }