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.
110 lines
2.9 KiB
110 lines
2.9 KiB
4 years ago
|
import React, { Component } from 'react';
|
||
|
import PropTypes from 'prop-types';
|
||
|
import PageContainerContent from '../../../components/ui/page-container/page-container-content.component';
|
||
|
import Dialog from '../../../components/ui/dialog';
|
||
4 years ago
|
import {
|
||
|
ETH_GAS_PRICE_FETCH_WARNING_KEY,
|
||
|
GAS_PRICE_FETCH_FAILURE_ERROR_KEY,
|
||
|
GAS_PRICE_EXCESSIVE_ERROR_KEY,
|
||
|
} from '../../../helpers/constants/error-keys';
|
||
4 years ago
|
import SendAmountRow from './send-amount-row';
|
||
|
import SendGasRow from './send-gas-row';
|
||
|
import SendHexDataRow from './send-hex-data-row';
|
||
|
import SendAssetRow from './send-asset-row';
|
||
7 years ago
|
|
||
|
export default class SendContent extends Component {
|
||
5 years ago
|
static contextTypes = {
|
||
|
t: PropTypes.func,
|
||
4 years ago
|
};
|
||
5 years ago
|
|
||
7 years ago
|
static propTypes = {
|
||
|
updateGas: PropTypes.func,
|
||
5 years ago
|
showAddToAddressBookModal: PropTypes.func,
|
||
6 years ago
|
showHexData: PropTypes.bool,
|
||
5 years ago
|
contact: PropTypes.object,
|
||
|
isOwnedAccount: PropTypes.bool,
|
||
4 years ago
|
warning: PropTypes.string,
|
||
4 years ago
|
error: PropTypes.string,
|
||
4 years ago
|
gasIsExcessive: PropTypes.bool.isRequired,
|
||
4 years ago
|
isEthGasPrice: PropTypes.bool,
|
||
|
noGasPrice: PropTypes.bool,
|
||
4 years ago
|
};
|
||
7 years ago
|
|
||
4 years ago
|
updateGas = (updateData) => this.props.updateGas(updateData);
|
||
6 years ago
|
|
||
4 years ago
|
render() {
|
||
4 years ago
|
const {
|
||
|
warning,
|
||
|
error,
|
||
|
gasIsExcessive,
|
||
|
isEthGasPrice,
|
||
|
noGasPrice,
|
||
|
} = this.props;
|
||
|
|
||
|
let gasError;
|
||
|
if (gasIsExcessive) gasError = GAS_PRICE_EXCESSIVE_ERROR_KEY;
|
||
|
else if (noGasPrice) gasError = GAS_PRICE_FETCH_FAILURE_ERROR_KEY;
|
||
|
|
||
7 years ago
|
return (
|
||
|
<PageContainerContent>
|
||
7 years ago
|
<div className="send-v2__form">
|
||
4 years ago
|
{gasError && this.renderError(gasError)}
|
||
|
{isEthGasPrice && this.renderWarning(ETH_GAS_PRICE_FETCH_WARNING_KEY)}
|
||
4 years ago
|
{error && this.renderError()}
|
||
4 years ago
|
{warning && this.renderWarning()}
|
||
|
{this.maybeRenderAddContact()}
|
||
6 years ago
|
<SendAssetRow />
|
||
6 years ago
|
<SendAmountRow updateGas={this.updateGas} />
|
||
7 years ago
|
<SendGasRow />
|
||
4 years ago
|
{this.props.showHexData && (
|
||
|
<SendHexDataRow updateGas={this.updateGas} />
|
||
|
)}
|
||
7 years ago
|
</div>
|
||
|
</PageContainerContent>
|
||
4 years ago
|
);
|
||
7 years ago
|
}
|
||
|
|
||
4 years ago
|
maybeRenderAddContact() {
|
||
4 years ago
|
const { t } = this.context;
|
||
4 years ago
|
const {
|
||
|
isOwnedAccount,
|
||
|
showAddToAddressBookModal,
|
||
|
contact = {},
|
||
4 years ago
|
} = this.props;
|
||
5 years ago
|
|
||
|
if (isOwnedAccount || contact.name) {
|
||
4 years ago
|
return null;
|
||
5 years ago
|
}
|
||
|
|
||
|
return (
|
||
|
<Dialog
|
||
|
type="message"
|
||
|
className="send__dialog"
|
||
|
onClick={showAddToAddressBookModal}
|
||
|
>
|
||
|
{t('newAccountDetectedDialogMessage')}
|
||
|
</Dialog>
|
||
4 years ago
|
);
|
||
5 years ago
|
}
|
||
4 years ago
|
|
||
4 years ago
|
renderWarning(gasWarning = '') {
|
||
4 years ago
|
const { t } = this.context;
|
||
|
const { warning } = this.props;
|
||
4 years ago
|
return (
|
||
4 years ago
|
<Dialog type="warning" className="send__error-dialog">
|
||
4 years ago
|
{gasWarning === '' ? t(warning) : t(gasWarning)}
|
||
4 years ago
|
</Dialog>
|
||
4 years ago
|
);
|
||
4 years ago
|
}
|
||
4 years ago
|
|
||
4 years ago
|
renderError(gasError = '') {
|
||
4 years ago
|
const { t } = this.context;
|
||
|
const { error } = this.props;
|
||
|
return (
|
||
|
<Dialog type="error" className="send__error-dialog">
|
||
4 years ago
|
{gasError === '' ? t(error) : t(gasError)}
|
||
4 years ago
|
</Dialog>
|
||
|
);
|
||
|
}
|
||
7 years ago
|
}
|