You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
173 lines
5.1 KiB
173 lines
5.1 KiB
4 years ago
|
import PropTypes from 'prop-types';
|
||
|
import React, { Component } from 'react';
|
||
4 years ago
|
import { NETWORK_TO_NAME_MAP } from '../../../../../shared/constants/network';
|
||
4 years ago
|
import Button from '../../../ui/button';
|
||
5 years ago
|
|
||
|
export default class DepositEtherModal extends Component {
|
||
|
static contextTypes = {
|
||
|
t: PropTypes.func,
|
||
5 years ago
|
metricsEvent: PropTypes.func.isRequired,
|
||
4 years ago
|
};
|
||
5 years ago
|
|
||
|
static propTypes = {
|
||
4 years ago
|
chainId: PropTypes.string.isRequired,
|
||
4 years ago
|
isTestnet: PropTypes.bool.isRequired,
|
||
|
isMainnet: PropTypes.bool.isRequired,
|
||
5 years ago
|
toWyre: PropTypes.func.isRequired,
|
||
|
address: PropTypes.string.isRequired,
|
||
|
toFaucet: PropTypes.func.isRequired,
|
||
|
hideWarning: PropTypes.func.isRequired,
|
||
|
hideModal: PropTypes.func.isRequired,
|
||
|
showAccountDetailModal: PropTypes.func.isRequired,
|
||
4 years ago
|
};
|
||
5 years ago
|
|
||
|
goToAccountDetailsModal = () => {
|
||
4 years ago
|
this.props.hideWarning();
|
||
|
this.props.hideModal();
|
||
|
this.props.showAccountDetailModal();
|
||
|
};
|
||
5 years ago
|
|
||
4 years ago
|
renderRow({
|
||
5 years ago
|
logo,
|
||
|
title,
|
||
|
text,
|
||
|
buttonLabel,
|
||
|
onButtonClick,
|
||
|
hide,
|
||
|
className,
|
||
|
hideButton,
|
||
|
hideTitle,
|
||
|
onBackClick,
|
||
|
showBackButton,
|
||
|
}) {
|
||
|
if (hide) {
|
||
4 years ago
|
return null;
|
||
5 years ago
|
}
|
||
|
|
||
|
return (
|
||
|
<div className={className || 'deposit-ether-modal__buy-row'}>
|
||
|
{onBackClick && showBackButton && (
|
||
4 years ago
|
<div
|
||
|
className="deposit-ether-modal__buy-row__back"
|
||
|
onClick={onBackClick}
|
||
|
>
|
||
5 years ago
|
<i className="fa fa-arrow-left cursor-pointer" />
|
||
|
</div>
|
||
|
)}
|
||
4 years ago
|
<div className="deposit-ether-modal__buy-row__logo-container">
|
||
|
{logo}
|
||
|
</div>
|
||
5 years ago
|
<div className="deposit-ether-modal__buy-row__description">
|
||
|
{!hideTitle && (
|
||
4 years ago
|
<div className="deposit-ether-modal__buy-row__description__title">
|
||
|
{title}
|
||
|
</div>
|
||
5 years ago
|
)}
|
||
4 years ago
|
<div className="deposit-ether-modal__buy-row__description__text">
|
||
|
{text}
|
||
|
</div>
|
||
5 years ago
|
</div>
|
||
|
{!hideButton && (
|
||
|
<div className="deposit-ether-modal__buy-row__button">
|
||
|
<Button
|
||
|
type="secondary"
|
||
|
className="deposit-ether-modal__deposit-button"
|
||
|
large
|
||
|
onClick={onButtonClick}
|
||
|
>
|
||
|
{buttonLabel}
|
||
|
</Button>
|
||
|
</div>
|
||
|
)}
|
||
|
</div>
|
||
4 years ago
|
);
|
||
5 years ago
|
}
|
||
|
|
||
4 years ago
|
render() {
|
||
4 years ago
|
const {
|
||
4 years ago
|
chainId,
|
||
4 years ago
|
toWyre,
|
||
|
address,
|
||
|
toFaucet,
|
||
|
isTestnet,
|
||
|
isMainnet,
|
||
|
} = this.props;
|
||
4 years ago
|
const networkName = NETWORK_TO_NAME_MAP[chainId];
|
||
5 years ago
|
|
||
|
return (
|
||
4 years ago
|
<div className="page-container page-container--full-width page-container--full-height">
|
||
5 years ago
|
<div className="page-container__header">
|
||
|
<div className="page-container__title">
|
||
|
{this.context.t('depositEther')}
|
||
|
</div>
|
||
|
<div className="page-container__subtitle">
|
||
|
{this.context.t('needEtherInWallet')}
|
||
|
</div>
|
||
|
<div
|
||
|
className="page-container__header-close"
|
||
|
onClick={() => {
|
||
4 years ago
|
this.props.hideWarning();
|
||
|
this.props.hideModal();
|
||
5 years ago
|
}}
|
||
|
/>
|
||
|
</div>
|
||
|
<div className="page-container__content">
|
||
|
<div className="deposit-ether-modal__buy-rows">
|
||
|
{this.renderRow({
|
||
|
logo: (
|
||
|
<div
|
||
|
className="deposit-ether-modal__logo"
|
||
|
style={{
|
||
|
backgroundImage: "url('./images/wyre.svg')",
|
||
|
height: '40px',
|
||
|
}}
|
||
|
/>
|
||
|
),
|
||
|
title: this.context.t('buyWithWyre'),
|
||
|
text: this.context.t('buyWithWyreDescription'),
|
||
|
buttonLabel: this.context.t('continueToWyre'),
|
||
5 years ago
|
onButtonClick: () => {
|
||
|
this.context.metricsEvent({
|
||
|
eventOpts: {
|
||
|
category: 'Accounts',
|
||
|
action: 'Deposit Ether',
|
||
|
name: 'Click buy Ether via Wyre',
|
||
|
},
|
||
4 years ago
|
});
|
||
|
toWyre(address);
|
||
5 years ago
|
},
|
||
4 years ago
|
hide: !isMainnet,
|
||
5 years ago
|
})}
|
||
|
{this.renderRow({
|
||
|
logo: (
|
||
4 years ago
|
<img
|
||
|
alt=""
|
||
5 years ago
|
className="deposit-ether-modal__logo"
|
||
4 years ago
|
src="./images/deposit-eth.svg"
|
||
5 years ago
|
style={{
|
||
4 years ago
|
height: '75px',
|
||
|
width: '75px',
|
||
5 years ago
|
}}
|
||
|
/>
|
||
|
),
|
||
4 years ago
|
title: this.context.t('directDepositEther'),
|
||
|
text: this.context.t('directDepositEtherExplainer'),
|
||
|
buttonLabel: this.context.t('viewAccount'),
|
||
|
onButtonClick: () => this.goToAccountDetailsModal(),
|
||
|
})}
|
||
4 years ago
|
{networkName &&
|
||
|
this.renderRow({
|
||
|
logo: <i className="fa fa-tint fa-2x" />,
|
||
|
title: this.context.t('testFaucet'),
|
||
|
text: this.context.t('getEtherFromFaucet', [networkName]),
|
||
|
buttonLabel: this.context.t('getEther'),
|
||
|
onButtonClick: () => toFaucet(chainId),
|
||
|
hide: !isTestnet,
|
||
|
})}
|
||
5 years ago
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
4 years ago
|
);
|
||
5 years ago
|
}
|
||
|
}
|