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.
129 lines
3.7 KiB
129 lines
3.7 KiB
4 years ago
|
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 { PageContainerFooter } from '../../../ui/page-container';
|
||
|
import { ConfirmPageContainerSummary, ConfirmPageContainerWarning } from '.';
|
||
4 years ago
|
|
||
7 years ago
|
export default class ConfirmPageContainerContent extends Component {
|
||
|
static propTypes = {
|
||
|
action: PropTypes.string,
|
||
|
dataComponent: PropTypes.node,
|
||
6 years ago
|
detailsComponent: PropTypes.node,
|
||
|
errorKey: PropTypes.string,
|
||
|
errorMessage: PropTypes.string,
|
||
|
hideSubtitle: PropTypes.bool,
|
||
7 years ago
|
identiconAddress: PropTypes.string,
|
||
|
nonce: PropTypes.string,
|
||
6 years ago
|
assetImage: PropTypes.string,
|
||
6 years ago
|
subtitleComponent: PropTypes.node,
|
||
6 years ago
|
title: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
||
6 years ago
|
titleComponent: PropTypes.node,
|
||
7 years ago
|
warning: PropTypes.string,
|
||
4 years ago
|
origin: PropTypes.string.isRequired,
|
||
4 years ago
|
ethGasPriceWarning: PropTypes.string,
|
||
4 years ago
|
// Footer
|
||
|
onCancelAll: PropTypes.func,
|
||
|
onCancel: PropTypes.func,
|
||
|
cancelText: PropTypes.string,
|
||
|
onSubmit: PropTypes.func,
|
||
|
submitText: PropTypes.string,
|
||
|
disabled: PropTypes.bool,
|
||
|
unapprovedTxCount: PropTypes.number,
|
||
|
rejectNText: PropTypes.string,
|
||
4 years ago
|
};
|
||
7 years ago
|
|
||
4 years ago
|
renderContent() {
|
||
4 years ago
|
const { detailsComponent, dataComponent } = this.props;
|
||
7 years ago
|
|
||
|
if (detailsComponent && dataComponent) {
|
||
4 years ago
|
return this.renderTabs();
|
||
7 years ago
|
}
|
||
4 years ago
|
return detailsComponent || dataComponent;
|
||
7 years ago
|
}
|
||
|
|
||
4 years ago
|
renderTabs() {
|
||
4 years ago
|
const { detailsComponent, dataComponent } = this.props;
|
||
7 years ago
|
|
||
|
return (
|
||
|
<Tabs>
|
||
5 years ago
|
<Tab className="confirm-page-container-content__tab" name="Details">
|
||
4 years ago
|
{detailsComponent}
|
||
7 years ago
|
</Tab>
|
||
5 years ago
|
<Tab className="confirm-page-container-content__tab" name="Data">
|
||
4 years ago
|
{dataComponent}
|
||
7 years ago
|
</Tab>
|
||
|
</Tabs>
|
||
4 years ago
|
);
|
||
7 years ago
|
}
|
||
|
|
||
4 years ago
|
render() {
|
||
7 years ago
|
const {
|
||
|
action,
|
||
6 years ago
|
errorKey,
|
||
|
errorMessage,
|
||
7 years ago
|
title,
|
||
6 years ago
|
titleComponent,
|
||
|
subtitleComponent,
|
||
7 years ago
|
hideSubtitle,
|
||
|
identiconAddress,
|
||
|
nonce,
|
||
6 years ago
|
assetImage,
|
||
7 years ago
|
detailsComponent,
|
||
|
dataComponent,
|
||
|
warning,
|
||
4 years ago
|
onCancelAll,
|
||
|
onCancel,
|
||
|
cancelText,
|
||
|
onSubmit,
|
||
|
submitText,
|
||
|
disabled,
|
||
|
unapprovedTxCount,
|
||
|
rejectNText,
|
||
4 years ago
|
origin,
|
||
4 years ago
|
ethGasPriceWarning,
|
||
4 years ago
|
} = this.props;
|
||
7 years ago
|
|
||
|
return (
|
||
|
<div className="confirm-page-container-content">
|
||
4 years ago
|
{warning && <ConfirmPageContainerWarning warning={warning} />}
|
||
4 years ago
|
{ethGasPriceWarning && (
|
||
|
<ConfirmPageContainerWarning warning={ethGasPriceWarning} />
|
||
|
)}
|
||
4 years ago
|
<ConfirmPageContainerSummary
|
||
|
className={classnames({
|
||
|
'confirm-page-container-summary--border':
|
||
|
!detailsComponent || !dataComponent,
|
||
|
})}
|
||
|
action={action}
|
||
|
title={title}
|
||
|
titleComponent={titleComponent}
|
||
|
subtitleComponent={subtitleComponent}
|
||
|
hideSubtitle={hideSubtitle}
|
||
|
identiconAddress={identiconAddress}
|
||
|
nonce={nonce}
|
||
|
assetImage={assetImage}
|
||
4 years ago
|
origin={origin}
|
||
4 years ago
|
/>
|
||
4 years ago
|
{this.renderContent()}
|
||
|
{(errorKey || errorMessage) && (
|
||
|
<div className="confirm-page-container-content__error-container">
|
||
|
<ErrorMessage errorMessage={errorMessage} errorKey={errorKey} />
|
||
|
</div>
|
||
|
)}
|
||
4 years ago
|
<PageContainerFooter
|
||
|
onCancel={onCancel}
|
||
|
cancelText={cancelText}
|
||
|
onSubmit={onSubmit}
|
||
|
submitText={submitText}
|
||
|
submitButtonType="confirm"
|
||
|
disabled={disabled}
|
||
|
>
|
||
4 years ago
|
{unapprovedTxCount > 1 && <a onClick={onCancelAll}>{rejectNText}</a>}
|
||
4 years ago
|
</PageContainerFooter>
|
||
7 years ago
|
</div>
|
||
4 years ago
|
);
|
||
7 years ago
|
}
|
||
|
}
|