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 { ETH_GAS_PRICE_FETCH_WARNING_KEY, GAS_PRICE_FETCH_FAILURE_ERROR_KEY, GAS_PRICE_EXCESSIVE_ERROR_KEY, UNSENDABLE_ASSET_ERROR_KEY, } from '../../../helpers/constants/error-keys'; 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'; export default class SendContent extends Component { static contextTypes = { t: PropTypes.func, }; static propTypes = { isAssetSendable: PropTypes.bool, showAddToAddressBookModal: PropTypes.func, showHexData: PropTypes.bool, contact: PropTypes.object, isOwnedAccount: PropTypes.bool, warning: PropTypes.string, error: PropTypes.string, gasIsExcessive: PropTypes.bool.isRequired, isEthGasPrice: PropTypes.bool, noGasPrice: PropTypes.bool, }; render() { const { warning, error, gasIsExcessive, isEthGasPrice, noGasPrice, isAssetSendable, } = this.props; let gasError; if (gasIsExcessive) gasError = GAS_PRICE_EXCESSIVE_ERROR_KEY; else if (noGasPrice) gasError = GAS_PRICE_FETCH_FAILURE_ERROR_KEY; return (
{gasError && this.renderError(gasError)} {isEthGasPrice && this.renderWarning(ETH_GAS_PRICE_FETCH_WARNING_KEY)} {isAssetSendable === false && this.renderError(UNSENDABLE_ASSET_ERROR_KEY)} {error && this.renderError(error)} {warning && this.renderWarning()} {this.maybeRenderAddContact()} {this.props.showHexData && }
); } maybeRenderAddContact() { const { t } = this.context; const { isOwnedAccount, showAddToAddressBookModal, contact = {}, } = this.props; if (isOwnedAccount || contact.name) { return null; } return ( {t('newAccountDetectedDialogMessage')} ); } renderWarning(gasWarning = '') { const { t } = this.context; const { warning } = this.props; return ( {gasWarning === '' ? t(warning) : t(gasWarning)} ); } renderError(error) { const { t } = this.context; return ( {t(error)} ); } }