import PropTypes from 'prop-types'; import React, { Component } from 'react'; import Select from 'react-select'; import getAccountLink from '../../../../lib/account-link'; import Button from '../../../components/ui/button'; class AccountList extends Component { getHdPaths() { return [ { label: `Ledger Live`, value: `m/44'/60'/0'/0/0`, }, { label: `Legacy (MEW / MyCrypto)`, value: `m/44'/60'/0'`, }, ]; } goToNextPage = () => { // If we have < 5 accounts, it's restricted by BIP-44 if (this.props.accounts.length === 5) { this.props.getPage(this.props.device, 1, this.props.selectedPath); } else { this.props.onAccountRestriction(); } }; goToPreviousPage = () => { this.props.getPage(this.props.device, -1, this.props.selectedPath); }; renderHdPathSelector() { const { onPathChange, selectedPath } = this.props; const options = this.getHdPaths(); return (

{this.context.t('selectHdPath')}

{this.context.t('selectPathHelp')}

this.props.onAccountChange(e.target.value)} checked={ this.props.selectedAccount === account.index.toString() } />
))} ); } renderPagination() { return (
); } renderButtons() { const disabled = this.props.selectedAccount === null; const buttonProps = {}; if (disabled) { buttonProps.disabled = true; } return (
); } renderForgetDevice() { return (
{this.context.t('forgetDevice')}
); } render() { return (
{this.renderHeader()} {this.renderAccounts()} {this.renderPagination()} {this.renderButtons()} {this.renderForgetDevice()}
); } } AccountList.propTypes = { onPathChange: PropTypes.func.isRequired, selectedPath: PropTypes.string.isRequired, device: PropTypes.string.isRequired, accounts: PropTypes.array.isRequired, onAccountChange: PropTypes.func.isRequired, onForgetDevice: PropTypes.func.isRequired, getPage: PropTypes.func.isRequired, network: PropTypes.string, selectedAccount: PropTypes.string, onUnlockAccount: PropTypes.func, onCancel: PropTypes.func, onAccountRestriction: PropTypes.func, }; AccountList.contextTypes = { t: PropTypes.func, }; export default AccountList;