aboutsummaryrefslogtreecommitdiffstats
path: root/mascara
diff options
context:
space:
mode:
authortmashuang <tmashuang@gmail.com>2017-10-24 23:40:07 +0800
committertmashuang <tmashuang@gmail.com>2017-10-24 23:40:07 +0800
commit099078d13b7f8c3c9c4ca1e4d9e775f480b0ad8d (patch)
treeb2d91f3094a096bee2e74c4306f5d71f1415f2a6 /mascara
parent91b23246cd18345e6fb6cba5262ccd2af8876f44 (diff)
downloadtangerine-wallet-browser-099078d13b7f8c3c9c4ca1e4d9e775f480b0ad8d.tar
tangerine-wallet-browser-099078d13b7f8c3c9c4ca1e4d9e775f480b0ad8d.tar.gz
tangerine-wallet-browser-099078d13b7f8c3c9c4ca1e4d9e775f480b0ad8d.tar.bz2
tangerine-wallet-browser-099078d13b7f8c3c9c4ca1e4d9e775f480b0ad8d.tar.lz
tangerine-wallet-browser-099078d13b7f8c3c9c4ca1e4d9e775f480b0ad8d.tar.xz
tangerine-wallet-browser-099078d13b7f8c3c9c4ca1e4d9e775f480b0ad8d.tar.zst
tangerine-wallet-browser-099078d13b7f8c3c9c4ca1e4d9e775f480b0ad8d.zip
Add error messages when importing an account
Diffstat (limited to 'mascara')
-rw-r--r--mascara/src/app/first-time/import-seed-phrase-screen.js38
1 files changed, 22 insertions, 16 deletions
diff --git a/mascara/src/app/first-time/import-seed-phrase-screen.js b/mascara/src/app/first-time/import-seed-phrase-screen.js
index d2eed61b7..d9a9dc835 100644
--- a/mascara/src/app/first-time/import-seed-phrase-screen.js
+++ b/mascara/src/app/first-time/import-seed-phrase-screen.js
@@ -1,7 +1,7 @@
import React, {Component, PropTypes} from 'react'
import {connect} from 'react-redux'
import LoadingScreen from './loading-screen'
-import {createNewVaultAndRestore, hideWarning} from '../../../../ui/app/actions'
+import {createNewVaultAndRestore, hideWarning, displayWarning} from '../../../../ui/app/actions'
class ImportSeedPhraseScreen extends Component {
static propTypes = {
@@ -11,6 +11,7 @@ class ImportSeedPhraseScreen extends Component {
createNewVaultAndRestore: PropTypes.func.isRequired,
hideWarning: PropTypes.func.isRequired,
isLoading: PropTypes.bool.isRequired,
+ displayWarning: PropTypes.func,
};
state = {
@@ -20,29 +21,29 @@ class ImportSeedPhraseScreen extends Component {
}
onClick = () => {
- const { password, seedPhrase } = this.state
- const { createNewVaultAndRestore, next } = this.props
-
- createNewVaultAndRestore(password, seedPhrase)
- .then(next)
- }
-
- isValid () {
- const { seedPhrase, password, confirmPassword } = this.state
+ const { password, seedPhrase, confirmPassword } = this.state
+ const { createNewVaultAndRestore, next, displayWarning } = this.props
if (seedPhrase.split(' ').length !== 12) {
- return false
+ this.warning = 'Seed Phrases are 12 words long'
+ displayWarning(this.warning)
+ return
}
if (password.length < 8) {
- return false
+ this.warning = 'Passwords require a mimimum length of 8'
+ displayWarning(this.warning)
+ return
}
if (password !== confirmPassword) {
- return false
+ this.warning = 'Confirmed password does not match'
+ displayWarning(this.warning)
+ return
}
-
- return true
+ this.warning = null
+ createNewVaultAndRestore(password, seedPhrase)
+ .then(next)
}
render () {
@@ -70,6 +71,11 @@ class ImportSeedPhraseScreen extends Component {
className="import-account__secret-phrase"
onChange={e => this.setState({seedPhrase: e.target.value})}
/>
+ <span
+ className="error"
+ >
+ {this.props.warning}
+ </span>
<input
className="first-time-flow__input"
type="password"
@@ -85,7 +91,6 @@ class ImportSeedPhraseScreen extends Component {
<button
className="first-time-flow__button"
onClick={this.onClick}
- disabled={!this.isValid()}
>
Import
</button>
@@ -98,6 +103,7 @@ export default connect(
({ appState: { isLoading, warning } }) => ({ isLoading, warning }),
dispatch => ({
createNewVaultAndRestore: (pw, seed) => dispatch(createNewVaultAndRestore(pw, seed)),
+ displayWarning: (warning) => dispatch(displayWarning(warning)),
hideWarning: () => dispatch(hideWarning()),
})
)(ImportSeedPhraseScreen)