import React, { Component } from 'react'; import PropTypes from 'prop-types'; import classnames from 'classnames'; import { Tabs, Tab } from '../../../ui/tabs'; import ErrorMessage from '../../../ui/error-message'; import ActionableMessage from '../../../ui/actionable-message/actionable-message'; import { PageContainerFooter } from '../../../ui/page-container'; import { ConfirmPageContainerSummary, ConfirmPageContainerWarning } from '.'; export default class ConfirmPageContainerContent extends Component { static contextTypes = { t: PropTypes.func.isRequired, }; static propTypes = { action: PropTypes.string, dataComponent: PropTypes.node, detailsComponent: PropTypes.node, errorKey: PropTypes.string, errorMessage: PropTypes.string, hasSimulationError: PropTypes.bool, hideSubtitle: PropTypes.bool, identiconAddress: PropTypes.string, nonce: PropTypes.string, subtitleComponent: PropTypes.node, title: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), titleComponent: PropTypes.node, warning: PropTypes.string, origin: PropTypes.string.isRequired, ethGasPriceWarning: PropTypes.string, // Footer onCancelAll: PropTypes.func, onCancel: PropTypes.func, cancelText: PropTypes.string, onSubmit: PropTypes.func, onConfirmAnyways: PropTypes.func, submitText: PropTypes.string, disabled: PropTypes.bool, hideConfirmAnyways: PropTypes.bool, unapprovedTxCount: PropTypes.number, rejectNText: PropTypes.string, hideTitle: PropTypes.boolean, }; renderContent() { const { detailsComponent, dataComponent } = this.props; if (detailsComponent && dataComponent) { return this.renderTabs(); } return detailsComponent || dataComponent; } renderTabs() { const { t } = this.context; const { detailsComponent, dataComponent } = this.props; return ( {detailsComponent} {dataComponent} ); } render() { const { action, errorKey, errorMessage, hasSimulationError, title, titleComponent, subtitleComponent, hideSubtitle, identiconAddress, nonce, detailsComponent, dataComponent, warning, onCancelAll, onCancel, cancelText, onSubmit, submitText, disabled, unapprovedTxCount, rejectNText, origin, ethGasPriceWarning, hideTitle, onConfirmAnyways, hideConfirmAnyways, } = this.props; const primaryAction = hideConfirmAnyways ? null : { label: this.context.t('tryAnywayOption'), onClick: onConfirmAnyways, }; return (
{warning ? : null} {ethGasPriceWarning && ( )} {hasSimulationError && (
)} {this.renderContent()} {(errorKey || errorMessage) && !hasSimulationError && (
)} {unapprovedTxCount > 1 ? ( {rejectNText} ) : null}
); } }