import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { NETWORK_TO_NAME_MAP } from '../../../../../shared/constants/network'; import Button from '../../../ui/button'; export default class DepositEtherModal extends Component { static contextTypes = { t: PropTypes.func, metricsEvent: PropTypes.func.isRequired, }; static propTypes = { chainId: PropTypes.string.isRequired, isTestnet: PropTypes.bool.isRequired, isMainnet: PropTypes.bool.isRequired, toWyre: PropTypes.func.isRequired, address: PropTypes.string.isRequired, toFaucet: PropTypes.func.isRequired, hideWarning: PropTypes.func.isRequired, hideModal: PropTypes.func.isRequired, showAccountDetailModal: PropTypes.func.isRequired, }; goToAccountDetailsModal = () => { this.props.hideWarning(); this.props.hideModal(); this.props.showAccountDetailModal(); }; renderRow({ logo, title, text, buttonLabel, onButtonClick, hide, className, hideButton, hideTitle, onBackClick, showBackButton, }) { if (hide) { return null; } return (
{onBackClick && showBackButton && (
)}
{logo}
{!hideTitle && (
{title}
)}
{text}
{!hideButton && (
)}
); } render() { const { chainId, toWyre, address, toFaucet, isTestnet, isMainnet, } = this.props; const networkName = NETWORK_TO_NAME_MAP[chainId]; return (
{this.context.t('depositEther')}
{this.context.t('needEtherInWallet')}
{ this.props.hideWarning(); this.props.hideModal(); }} />
{this.renderRow({ logo: (
), title: this.context.t('buyWithWyre'), text: this.context.t('buyWithWyreDescription'), buttonLabel: this.context.t('continueToWyre'), onButtonClick: () => { this.context.metricsEvent({ eventOpts: { category: 'Accounts', action: 'Deposit Ether', name: 'Click buy Ether via Wyre', }, }); toWyre(address); }, hide: !isMainnet, })} {this.renderRow({ logo: ( ), title: this.context.t('directDepositEther'), text: this.context.t('directDepositEtherExplainer'), buttonLabel: this.context.t('viewAccount'), onButtonClick: () => this.goToAccountDetailsModal(), })} {networkName && this.renderRow({ logo: , title: this.context.t('testFaucet'), text: this.context.t('getEtherFromFaucet', [networkName]), buttonLabel: this.context.t('getEther'), onButtonClick: () => toFaucet(chainId), hide: !isTestnet, })}
); } }