2021-02-04 19:15:23 +01:00
|
|
|
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';
|
|
|
|
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';
|
2018-04-11 16:21:54 +02:00
|
|
|
|
|
|
|
export default class SendContent extends Component {
|
2019-07-31 21:56:44 +02:00
|
|
|
static contextTypes = {
|
|
|
|
t: PropTypes.func,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2019-07-31 21:56:44 +02:00
|
|
|
|
2018-05-23 18:43:25 +02:00
|
|
|
static propTypes = {
|
|
|
|
updateGas: PropTypes.func,
|
2019-07-31 21:56:44 +02:00
|
|
|
showAddToAddressBookModal: PropTypes.func,
|
2018-08-16 09:43:13 +02:00
|
|
|
showHexData: PropTypes.bool,
|
2019-08-14 01:13:05 +02:00
|
|
|
contact: PropTypes.object,
|
|
|
|
isOwnedAccount: PropTypes.bool,
|
2020-08-28 17:27:07 +02:00
|
|
|
warning: PropTypes.string,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2018-05-23 18:43:25 +02:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
updateGas = (updateData) => this.props.updateGas(updateData);
|
2018-09-27 15:46:24 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
render() {
|
2021-02-04 19:15:23 +01:00
|
|
|
const { warning } = this.props;
|
2018-04-11 16:21:54 +02:00
|
|
|
return (
|
|
|
|
<PageContainerContent>
|
2018-04-30 18:09:05 +02:00
|
|
|
<div className="send-v2__form">
|
2020-11-03 00:41:28 +01:00
|
|
|
{warning && this.renderWarning()}
|
|
|
|
{this.maybeRenderAddContact()}
|
2019-04-17 21:15:13 +02:00
|
|
|
<SendAssetRow />
|
2018-09-27 15:46:24 +02:00
|
|
|
<SendAmountRow updateGas={this.updateGas} />
|
2018-04-11 16:21:54 +02:00
|
|
|
<SendGasRow />
|
2020-11-03 00:41:28 +01:00
|
|
|
{this.props.showHexData && (
|
|
|
|
<SendHexDataRow updateGas={this.updateGas} />
|
|
|
|
)}
|
2018-04-11 16:21:54 +02:00
|
|
|
</div>
|
|
|
|
</PageContainerContent>
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2018-04-11 16:21:54 +02:00
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
maybeRenderAddContact() {
|
2021-02-04 19:15:23 +01:00
|
|
|
const { t } = this.context;
|
2020-11-03 00:41:28 +01:00
|
|
|
const {
|
|
|
|
isOwnedAccount,
|
|
|
|
showAddToAddressBookModal,
|
|
|
|
contact = {},
|
2021-02-04 19:15:23 +01:00
|
|
|
} = this.props;
|
2019-07-31 21:56:44 +02:00
|
|
|
|
|
|
|
if (isOwnedAccount || contact.name) {
|
2021-02-04 19:15:23 +01:00
|
|
|
return null;
|
2019-07-31 21:56:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Dialog
|
|
|
|
type="message"
|
|
|
|
className="send__dialog"
|
|
|
|
onClick={showAddToAddressBookModal}
|
|
|
|
>
|
|
|
|
{t('newAccountDetectedDialogMessage')}
|
|
|
|
</Dialog>
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2019-07-31 21:56:44 +02:00
|
|
|
}
|
2020-08-28 17:27:07 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
renderWarning() {
|
2021-02-04 19:15:23 +01:00
|
|
|
const { t } = this.context;
|
|
|
|
const { warning } = this.props;
|
2020-08-28 17:27:07 +02:00
|
|
|
|
|
|
|
return (
|
2020-11-03 00:41:28 +01:00
|
|
|
<Dialog type="warning" className="send__error-dialog">
|
2020-08-28 17:27:07 +02:00
|
|
|
{t(warning)}
|
|
|
|
</Dialog>
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2020-08-28 17:27:07 +02:00
|
|
|
}
|
2018-04-11 16:21:54 +02:00
|
|
|
}
|