aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/components/send/currency-display.js
diff options
context:
space:
mode:
authorDan <danjm.com@gmail.com>2017-10-18 04:13:20 +0800
committerChi Kei Chan <chikeichan@gmail.com>2017-10-19 11:21:46 +0800
commit60eda592b5979ac1fdbfb6d5b3418a4924abc14d (patch)
treec688881be17265045f5b0afa61c1802669643388 /ui/app/components/send/currency-display.js
parentf81226fbe9f98d5a6c408e289fa0ea61a467e7dc (diff)
downloadtangerine-wallet-browser-60eda592b5979ac1fdbfb6d5b3418a4924abc14d.tar.gz
tangerine-wallet-browser-60eda592b5979ac1fdbfb6d5b3418a4924abc14d.tar.zst
tangerine-wallet-browser-60eda592b5979ac1fdbfb6d5b3418a4924abc14d.zip
Handling to and amount errors.
Diffstat (limited to 'ui/app/components/send/currency-display.js')
-rw-r--r--ui/app/components/send/currency-display.js23
1 files changed, 15 insertions, 8 deletions
diff --git a/ui/app/components/send/currency-display.js b/ui/app/components/send/currency-display.js
index d56c119f1..f7fbb2379 100644
--- a/ui/app/components/send/currency-display.js
+++ b/ui/app/components/send/currency-display.js
@@ -28,16 +28,12 @@ function resetCaretIfPastEnd (value, event) {
}
}
-CurrencyDisplay.prototype.handleChangeInHexWei = function (value) {
- const { handleChange } = this.props
-
- const valueInHexWei = conversionUtil(value, {
+function toHexWei (value) {
+ return conversionUtil(value, {
fromNumericBase: 'dec',
toNumericBase: 'hex',
toDenomination: 'WEI',
})
-
- handleChange(valueInHexWei)
}
CurrencyDisplay.prototype.render = function () {
@@ -51,7 +47,10 @@ CurrencyDisplay.prototype.render = function () {
convertedPrefix = '',
placeholder = '0',
readOnly = false,
+ inError = false,
value: initValue,
+ handleChange,
+ validate,
} = this.props
const { value } = this.state
@@ -73,6 +72,9 @@ CurrencyDisplay.prototype.render = function () {
return h('div', {
className,
+ style: {
+ borderColor: inError ? 'red' : null,
+ },
}, [
h('div.currency-display__primary-row', [
@@ -100,8 +102,13 @@ CurrencyDisplay.prototype.render = function () {
this.setState({ value: newValue })
}
},
- onBlur: event => !readOnly && this.handleChangeInHexWei(event.target.value.split(' ')[0]),
- onKeyUp: event => !readOnly && resetCaretIfPastEnd(value || initValueToRender, event),
+ onBlur: event => !readOnly && handleChange(toHexWei(event.target.value.split(' ')[0])),
+ onKeyUp: event => {
+ if (!readOnly) {
+ validate(toHexWei(value || initValueToRender))
+ resetCaretIfPastEnd(value || initValueToRender, event)
+ }
+ },
onClick: event => !readOnly && resetCaretIfPastEnd(value || initValueToRender, event),
}),