import classnames from 'classnames'; import PropTypes from 'prop-types'; import React, { Component } from 'react'; import Button from '../../../components/ui/button'; export default class SelectHardware extends Component { static contextTypes = { t: PropTypes.func, }; static propTypes = { connectToHardwareWallet: PropTypes.func.isRequired, browserSupported: PropTypes.bool.isRequired, useLedgerLive: PropTypes.bool.isRequired, }; state = { selectedDevice: null, }; connect = () => { if (this.state.selectedDevice) { this.props.connectToHardwareWallet(this.state.selectedDevice); } return null; }; renderConnectToTrezorButton() { return ( ); } renderConnectToLedgerButton() { return ( ); } renderButtons() { return ( <>
{this.renderConnectToLedgerButton()} {this.renderConnectToTrezorButton()}
); } renderContinueButton() { return ( ); } renderUnsupportedBrowser() { return (

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

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

); } renderHeader() { return (

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

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

); } renderTutorialsteps() { switch (this.state.selectedDevice) { case 'ledger': return this.renderLedgerTutorialSteps(); case 'trezor': return this.renderTrezorTutorialSteps(); default: return ''; } } renderLedgerTutorialSteps() { const steps = []; if (this.props.useLedgerLive) { steps.push({ title: this.context.t('step1LedgerWallet'), message: this.context.t('step1LedgerWalletMsg', [ {this.context.t('ledgerLiveApp')} , ]), }); } steps.push({ asset: 'plug-in-wallet', dimensions: { width: '225px', height: '75px' }, title: this.context.t('step2LedgerWallet'), message: this.context.t('step2LedgerWalletMsg', [ {this.context.t('hardwareWalletSupportLinkConversion')} , ]), }); return (
{steps.map((step, index) => (

{step.title}

{step.message}

{step.asset && ( )}
))}
); } renderTrezorTutorialSteps() { const steps = [ { asset: 'plug-in-wallet', dimensions: { width: '225px', height: '75px' }, title: this.context.t('step1TrezorWallet'), message: this.context.t('step1TrezorWalletMsg', [ {this.context.t('hardwareWalletSupportLinkConversion')} , ]), }, ]; return (
{steps.map((step, index) => (

{step.title}

{step.message}

{step.asset && ( )}
))}
); } renderConnectScreen() { return (
{this.renderHeader()} {this.renderButtons()} {this.state.selectedDevice && this.renderTutorialsteps()} {this.renderContinueButton()}
); } render() { if (this.props.browserSupported) { return this.renderConnectScreen(); } return this.renderUnsupportedBrowser(); } }