import React, { PureComponent } from 'react' import PropTypes from 'prop-types' import AccountListItem from '../send/account-list-item/account-list-item.component' export default class AccountDropdownMini extends PureComponent { static propTypes = { accounts: PropTypes.array.isRequired, closeDropdown: PropTypes.func, disabled: PropTypes.bool, dropdownOpen: PropTypes.bool, onSelect: PropTypes.func, openDropdown: PropTypes.func, selectedAccount: PropTypes.object.isRequired, } static defaultProps = { closeDropdown: () => {}, disabled: false, dropdownOpen: false, onSelect: () => {}, openDropdown: () => {}, } getListItemIcon (currentAccount, selectedAccount) { return currentAccount.address === selectedAccount.address && ( ) } renderDropdown () { const { accounts, selectedAccount, closeDropdown, onSelect } = this.props return (
{ accounts.map(account => ( { onSelect(account) closeDropdown() }} icon={this.getListItemIcon(account, selectedAccount)} /> )) }
) } render () { const { disabled, selectedAccount, openDropdown, dropdownOpen } = this.props return (
!disabled && openDropdown()} displayBalance={false} displayAddress={false} icon={ !disabled && } /> { !disabled && dropdownOpen && this.renderDropdown() }
) } }