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.
190 lines
5.4 KiB
190 lines
5.4 KiB
4 years ago
|
import React, { Component } from 'react';
|
||
|
import PropTypes from 'prop-types';
|
||
|
import SenderToRecipient from '../../ui/sender-to-recipient';
|
||
|
import { PageContainerFooter } from '../../ui/page-container';
|
||
4 years ago
|
import {
|
||
|
ConfirmPageContainerHeader,
|
||
|
ConfirmPageContainerContent,
|
||
|
ConfirmPageContainerNavigation,
|
||
4 years ago
|
} from '.';
|
||
7 years ago
|
|
||
|
export default class ConfirmPageContainer extends Component {
|
||
|
static contextTypes = {
|
||
|
t: PropTypes.func,
|
||
4 years ago
|
};
|
||
7 years ago
|
|
||
|
static propTypes = {
|
||
|
// Header
|
||
|
action: PropTypes.string,
|
||
7 years ago
|
hideSubtitle: PropTypes.bool,
|
||
|
onEdit: PropTypes.func,
|
||
|
showEdit: PropTypes.bool,
|
||
6 years ago
|
subtitleComponent: PropTypes.node,
|
||
7 years ago
|
title: PropTypes.string,
|
||
6 years ago
|
titleComponent: PropTypes.node,
|
||
5 years ago
|
hideSenderToRecipient: PropTypes.bool,
|
||
|
showAccountInHeader: PropTypes.bool,
|
||
7 years ago
|
// Sender to Recipient
|
||
|
fromAddress: PropTypes.string,
|
||
|
fromName: PropTypes.string,
|
||
|
toAddress: PropTypes.string,
|
||
|
toName: PropTypes.string,
|
||
5 years ago
|
toEns: PropTypes.string,
|
||
5 years ago
|
toNickname: PropTypes.string,
|
||
7 years ago
|
// Content
|
||
|
contentComponent: PropTypes.node,
|
||
7 years ago
|
errorKey: PropTypes.string,
|
||
|
errorMessage: PropTypes.string,
|
||
7 years ago
|
dataComponent: PropTypes.node,
|
||
7 years ago
|
detailsComponent: PropTypes.node,
|
||
7 years ago
|
identiconAddress: PropTypes.string,
|
||
|
nonce: PropTypes.string,
|
||
6 years ago
|
assetImage: PropTypes.string,
|
||
7 years ago
|
warning: PropTypes.string,
|
||
6 years ago
|
unapprovedTxCount: PropTypes.number,
|
||
4 years ago
|
origin: PropTypes.string.isRequired,
|
||
4 years ago
|
ethGasPriceWarning: PropTypes.string,
|
||
6 years ago
|
// Navigation
|
||
|
totalTx: PropTypes.number,
|
||
|
positionOfCurrentTx: PropTypes.number,
|
||
|
nextTxId: PropTypes.string,
|
||
|
prevTxId: PropTypes.string,
|
||
|
showNavigation: PropTypes.bool,
|
||
|
onNextTx: PropTypes.func,
|
||
|
firstTx: PropTypes.string,
|
||
|
lastTx: PropTypes.string,
|
||
|
ofText: PropTypes.string,
|
||
|
requestsWaitingText: PropTypes.string,
|
||
7 years ago
|
// Footer
|
||
6 years ago
|
onCancelAll: PropTypes.func,
|
||
7 years ago
|
onCancel: PropTypes.func,
|
||
|
onSubmit: PropTypes.func,
|
||
6 years ago
|
disabled: PropTypes.bool,
|
||
4 years ago
|
};
|
||
7 years ago
|
|
||
4 years ago
|
render() {
|
||
7 years ago
|
const {
|
||
|
showEdit,
|
||
|
onEdit,
|
||
|
fromName,
|
||
|
fromAddress,
|
||
|
toName,
|
||
5 years ago
|
toEns,
|
||
5 years ago
|
toNickname,
|
||
7 years ago
|
toAddress,
|
||
6 years ago
|
disabled,
|
||
7 years ago
|
errorKey,
|
||
7 years ago
|
errorMessage,
|
||
|
contentComponent,
|
||
|
action,
|
||
|
title,
|
||
|
titleComponent,
|
||
6 years ago
|
subtitleComponent,
|
||
7 years ago
|
hideSubtitle,
|
||
|
detailsComponent,
|
||
|
dataComponent,
|
||
6 years ago
|
onCancelAll,
|
||
7 years ago
|
onCancel,
|
||
|
onSubmit,
|
||
|
identiconAddress,
|
||
|
nonce,
|
||
6 years ago
|
unapprovedTxCount,
|
||
6 years ago
|
assetImage,
|
||
7 years ago
|
warning,
|
||
6 years ago
|
totalTx,
|
||
|
positionOfCurrentTx,
|
||
|
nextTxId,
|
||
|
prevTxId,
|
||
|
showNavigation,
|
||
|
onNextTx,
|
||
|
firstTx,
|
||
|
lastTx,
|
||
|
ofText,
|
||
|
requestsWaitingText,
|
||
5 years ago
|
hideSenderToRecipient,
|
||
|
showAccountInHeader,
|
||
4 years ago
|
origin,
|
||
4 years ago
|
ethGasPriceWarning,
|
||
4 years ago
|
} = this.props;
|
||
4 years ago
|
const renderAssetImage = contentComponent || !identiconAddress;
|
||
7 years ago
|
|
||
|
return (
|
||
|
<div className="page-container">
|
||
6 years ago
|
<ConfirmPageContainerNavigation
|
||
5 years ago
|
totalTx={totalTx}
|
||
|
positionOfCurrentTx={positionOfCurrentTx}
|
||
|
nextTxId={nextTxId}
|
||
|
prevTxId={prevTxId}
|
||
|
showNavigation={showNavigation}
|
||
|
onNextTx={(txId) => onNextTx(txId)}
|
||
|
firstTx={firstTx}
|
||
|
lastTx={lastTx}
|
||
|
ofText={ofText}
|
||
|
requestsWaitingText={requestsWaitingText}
|
||
6 years ago
|
/>
|
||
7 years ago
|
<ConfirmPageContainerHeader
|
||
|
showEdit={showEdit}
|
||
|
onEdit={() => onEdit()}
|
||
5 years ago
|
showAccountInHeader={showAccountInHeader}
|
||
|
accountAddress={fromAddress}
|
||
7 years ago
|
>
|
||
4 years ago
|
{hideSenderToRecipient ? null : (
|
||
|
<SenderToRecipient
|
||
|
senderName={fromName}
|
||
|
senderAddress={fromAddress}
|
||
|
recipientName={toName}
|
||
|
recipientAddress={toAddress}
|
||
|
recipientEns={toEns}
|
||
|
recipientNickname={toNickname}
|
||
|
assetImage={renderAssetImage ? assetImage : undefined}
|
||
7 years ago
|
/>
|
||
4 years ago
|
)}
|
||
|
</ConfirmPageContainerHeader>
|
||
|
{contentComponent || (
|
||
|
<ConfirmPageContainerContent
|
||
|
action={action}
|
||
|
title={title}
|
||
|
titleComponent={titleComponent}
|
||
|
subtitleComponent={subtitleComponent}
|
||
|
hideSubtitle={hideSubtitle}
|
||
|
detailsComponent={detailsComponent}
|
||
|
dataComponent={dataComponent}
|
||
|
errorMessage={errorMessage}
|
||
|
errorKey={errorKey}
|
||
|
identiconAddress={identiconAddress}
|
||
|
nonce={nonce}
|
||
|
assetImage={assetImage}
|
||
|
warning={warning}
|
||
|
onCancelAll={onCancelAll}
|
||
|
onCancel={onCancel}
|
||
|
cancelText={this.context.t('reject')}
|
||
|
onSubmit={onSubmit}
|
||
|
submitText={this.context.t('confirm')}
|
||
|
disabled={disabled}
|
||
|
unapprovedTxCount={unapprovedTxCount}
|
||
|
rejectNText={this.context.t('rejectTxsN', [unapprovedTxCount])}
|
||
4 years ago
|
origin={origin}
|
||
4 years ago
|
ethGasPriceWarning={ethGasPriceWarning}
|
||
4 years ago
|
/>
|
||
|
)}
|
||
|
{contentComponent && (
|
||
|
<PageContainerFooter
|
||
|
onCancel={onCancel}
|
||
|
cancelText={this.context.t('reject')}
|
||
|
onSubmit={onSubmit}
|
||
|
submitText={this.context.t('confirm')}
|
||
|
submitButtonType="confirm"
|
||
|
disabled={disabled}
|
||
|
>
|
||
|
{unapprovedTxCount > 1 && (
|
||
|
<a onClick={onCancelAll}>
|
||
|
{this.context.t('rejectTxsN', [unapprovedTxCount])}
|
||
|
</a>
|
||
|
)}
|
||
|
</PageContainerFooter>
|
||
|
)}
|
||
7 years ago
|
</div>
|
||
4 years ago
|
);
|
||
7 years ago
|
}
|
||
|
}
|