diff options
author | Alexander Tseung <alextsg@users.noreply.github.com> | 2018-07-12 09:31:50 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-12 09:31:50 +0800 |
commit | 0d4dbbec2abfa8c8015063d6e4a5ff0d34abe7b9 (patch) | |
tree | 10251992448d308123c16a6a01e02d7b422ddad2 /ui/app/components/pages/confirm-send-ether | |
parent | 4521de19e641e4cda27b906c47b46929ddb831ec (diff) | |
parent | 67017711df521e4d9f92cfc756b5468f7704a79c (diff) | |
download | tangerine-wallet-browser-0d4dbbec2abfa8c8015063d6e4a5ff0d34abe7b9.tar tangerine-wallet-browser-0d4dbbec2abfa8c8015063d6e4a5ff0d34abe7b9.tar.gz tangerine-wallet-browser-0d4dbbec2abfa8c8015063d6e4a5ff0d34abe7b9.tar.bz2 tangerine-wallet-browser-0d4dbbec2abfa8c8015063d6e4a5ff0d34abe7b9.tar.lz tangerine-wallet-browser-0d4dbbec2abfa8c8015063d6e4a5ff0d34abe7b9.tar.xz tangerine-wallet-browser-0d4dbbec2abfa8c8015063d6e4a5ff0d34abe7b9.tar.zst tangerine-wallet-browser-0d4dbbec2abfa8c8015063d6e4a5ff0d34abe7b9.zip |
Merge pull request #4691 from MetaMask/i4404-confirm-refactor
Refactor and redesign confirm transaction views
Diffstat (limited to 'ui/app/components/pages/confirm-send-ether')
3 files changed, 85 insertions, 0 deletions
diff --git a/ui/app/components/pages/confirm-send-ether/confirm-send-ether.component.js b/ui/app/components/pages/confirm-send-ether/confirm-send-ether.component.js new file mode 100644 index 000000000..442a478b8 --- /dev/null +++ b/ui/app/components/pages/confirm-send-ether/confirm-send-ether.component.js @@ -0,0 +1,39 @@ +import React, { Component } from 'react' +import PropTypes from 'prop-types' +import ConfirmTransactionBase from '../confirm-transaction-base' +import { SEND_ROUTE } from '../../../routes' + +export default class ConfirmSendEther extends Component { + static contextTypes = { + t: PropTypes.func, + } + + static propTypes = { + editTransaction: PropTypes.func, + history: PropTypes.object, + txParams: PropTypes.object, + } + + handleEdit ({ txData }) { + const { editTransaction, history } = this.props + editTransaction(txData) + history.push(SEND_ROUTE) + } + + shouldHideData () { + const { txParams = {} } = this.props + return !txParams.data + } + + render () { + const hideData = this.shouldHideData() + + return ( + <ConfirmTransactionBase + action={this.context.t('confirm')} + hideData={hideData} + onEdit={confirmTransactionData => this.handleEdit(confirmTransactionData)} + /> + ) + } +} diff --git a/ui/app/components/pages/confirm-send-ether/confirm-send-ether.container.js b/ui/app/components/pages/confirm-send-ether/confirm-send-ether.container.js new file mode 100644 index 000000000..e48ef54a8 --- /dev/null +++ b/ui/app/components/pages/confirm-send-ether/confirm-send-ether.container.js @@ -0,0 +1,45 @@ +import { connect } from 'react-redux' +import { compose } from 'recompose' +import { withRouter } from 'react-router-dom' +import { updateSend } from '../../../actions' +import { clearConfirmTransaction } from '../../../ducks/confirm-transaction.duck' +import ConfirmSendEther from './confirm-send-ether.component' + +const mapStateToProps = state => { + const { confirmTransaction: { txData: { txParams } = {} } } = state + + return { + txParams, + } +} + +const mapDispatchToProps = dispatch => { + return { + editTransaction: txData => { + const { id, txParams } = txData + const { + gas: gasLimit, + gasPrice, + to, + value: amount, + } = txParams + + dispatch(updateSend({ + gasLimit, + gasPrice, + gasTotal: null, + to, + amount, + errors: { to: null, amount: null }, + editingTransactionId: id && id.toString(), + })) + + dispatch(clearConfirmTransaction()) + }, + } +} + +export default compose( + withRouter, + connect(mapStateToProps, mapDispatchToProps) +)(ConfirmSendEther) diff --git a/ui/app/components/pages/confirm-send-ether/index.js b/ui/app/components/pages/confirm-send-ether/index.js new file mode 100644 index 000000000..2d5767c39 --- /dev/null +++ b/ui/app/components/pages/confirm-send-ether/index.js @@ -0,0 +1 @@ +export { default } from './confirm-send-ether.container' |