From a7069acf2e93e9eae543bb84dfdda1f5e10b3e19 Mon Sep 17 00:00:00 2001 From: Dan Date: Sat, 21 Oct 2017 00:06:42 -0230 Subject: Disable send-v2 next button if in error --- ui/app/send-v2.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'ui/app/send-v2.js') diff --git a/ui/app/send-v2.js b/ui/app/send-v2.js index a9473541c..4986edf5f 100644 --- a/ui/app/send-v2.js +++ b/ui/app/send-v2.js @@ -382,7 +382,14 @@ SendTransactionScreen.prototype.renderForm = function () { } SendTransactionScreen.prototype.renderFooter = function () { - const { goHome, clearSend } = this.props + const { + goHome, + clearSend, + errors: { amount: amountError, to: toError } + } = this.props + + const noErrors = amountError === null && toError === null + const errorClass = noErrors ? '' : '__disabled' return h('div.send-v2__footer', [ h('button.send-v2__cancel-btn', { @@ -391,8 +398,8 @@ SendTransactionScreen.prototype.renderFooter = function () { goHome() }, }, 'Cancel'), - h('button.send-v2__next-btn', { - onClick: event => this.onSubmit(event), + h(`button.send-v2__next-btn${errorClass}`, { + onClick: event => noErrors && this.onSubmit(event), }, 'Next'), ]) } -- cgit v1.2.3 From e737a9565a6b78639b74511d026339c1b54bca1a Mon Sep 17 00:00:00 2001 From: Dan Date: Sun, 22 Oct 2017 17:44:03 -0230 Subject: Improve customize gas modal error handling --- ui/app/send-v2.js | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) (limited to 'ui/app/send-v2.js') diff --git a/ui/app/send-v2.js b/ui/app/send-v2.js index 4986edf5f..16e4d7801 100644 --- a/ui/app/send-v2.js +++ b/ui/app/send-v2.js @@ -19,6 +19,9 @@ const { conversionGreaterThan, addCurrencies, } = require('./conversion-util') +const { + isBalanceSufficient, +} = require('./components/send/send-utils.js') const { isValidAddress } = require('./util') module.exports = SendTransactionScreen @@ -237,28 +240,16 @@ SendTransactionScreen.prototype.validateAmount = function (value) { let amountError = null - const totalAmount = addCurrencies(amount, gasTotal, { - aBase: 16, - bBase: 16, - toNumericBase: 'hex', + const sufficientBalance = isBalanceSufficient({ + amount, + gasTotal, + balance, + primaryCurrency, + selectedToken, + amountConversionRate, + conversionRate, }) - const sufficientBalance = conversionGreaterThan( - { - value: balance, - fromNumericBase: 'hex', - fromCurrency: primaryCurrency, - conversionRate, - }, - { - value: totalAmount, - fromNumericBase: 'hex', - conversionRate: amountConversionRate, - fromCurrency: selectedToken || primaryCurrency, - conversionRate: amountConversionRate, - }, - ) - const amountLessThanZero = conversionGreaterThan( { value: 0, fromNumericBase: 'dec' }, { value: amount, fromNumericBase: 'hex' }, @@ -387,7 +378,7 @@ SendTransactionScreen.prototype.renderFooter = function () { clearSend, errors: { amount: amountError, to: toError } } = this.props - + const noErrors = amountError === null && toError === null const errorClass = noErrors ? '' : '__disabled' -- cgit v1.2.3 From e058efd6a890598164baa9b337f710fc66ca22c5 Mon Sep 17 00:00:00 2001 From: Dan Date: Mon, 23 Oct 2017 22:02:30 -0230 Subject: Use classnames library and disabled attribute on 'Next' button in send-v2 --- ui/app/send-v2.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'ui/app/send-v2.js') diff --git a/ui/app/send-v2.js b/ui/app/send-v2.js index 16e4d7801..0086faa1f 100644 --- a/ui/app/send-v2.js +++ b/ui/app/send-v2.js @@ -2,6 +2,7 @@ const { inherits } = require('util') const PersistentForm = require('../lib/persistent-form') const h = require('react-hyperscript') const connect = require('react-redux').connect +const classnames = require('classnames') const Identicon = require('./components/identicon') const FromDropdown = require('./components/send/from-dropdown') @@ -380,7 +381,6 @@ SendTransactionScreen.prototype.renderFooter = function () { } = this.props const noErrors = amountError === null && toError === null - const errorClass = noErrors ? '' : '__disabled' return h('div.send-v2__footer', [ h('button.send-v2__cancel-btn', { @@ -389,8 +389,13 @@ SendTransactionScreen.prototype.renderFooter = function () { goHome() }, }, 'Cancel'), - h(`button.send-v2__next-btn${errorClass}`, { - onClick: event => noErrors && this.onSubmit(event), + h(`button`, { + className: classnames({ + 'send-v2__next-btn': noErrors, + 'send-v2__next-btn__disabled': !noErrors, + }), + disabled: !noErrors, + onClick: event => this.onSubmit(event), }, 'Next'), ]) } -- cgit v1.2.3