diff options
author | Chi Kei Chan <chikeichan@gmail.com> | 2017-10-26 10:46:42 +0800 |
---|---|---|
committer | Chi Kei Chan <chikeichan@gmail.com> | 2017-10-26 10:46:42 +0800 |
commit | db5326dfc288015a4d9f792653a71fd4d7abca33 (patch) | |
tree | cb93f52f999816d07a6146274093aaebdb7ed8d3 /mascara/src/app/first-time/import-seed-phrase-screen.js | |
parent | a9a841ba01f6bffa29a3e0491e3a88f6aff72ac7 (diff) | |
parent | b2e440e4ffba6db29cf8a928a41534c1f204d485 (diff) | |
download | tangerine-wallet-browser-db5326dfc288015a4d9f792653a71fd4d7abca33.tar.gz tangerine-wallet-browser-db5326dfc288015a4d9f792653a71fd4d7abca33.tar.zst tangerine-wallet-browser-db5326dfc288015a4d9f792653a71fd4d7abca33.zip |
Merge branch 'NewUI-flat' into uat
Diffstat (limited to 'mascara/src/app/first-time/import-seed-phrase-screen.js')
-rw-r--r-- | mascara/src/app/first-time/import-seed-phrase-screen.js | 109 |
1 files changed, 109 insertions, 0 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 new file mode 100644 index 000000000..d9a9dc835 --- /dev/null +++ b/mascara/src/app/first-time/import-seed-phrase-screen.js @@ -0,0 +1,109 @@ +import React, {Component, PropTypes} from 'react' +import {connect} from 'react-redux' +import LoadingScreen from './loading-screen' +import {createNewVaultAndRestore, hideWarning, displayWarning} from '../../../../ui/app/actions' + +class ImportSeedPhraseScreen extends Component { + static propTypes = { + warning: PropTypes.string, + back: PropTypes.func.isRequired, + next: PropTypes.func.isRequired, + createNewVaultAndRestore: PropTypes.func.isRequired, + hideWarning: PropTypes.func.isRequired, + isLoading: PropTypes.bool.isRequired, + displayWarning: PropTypes.func, + }; + + state = { + seedPhrase: '', + password: '', + confirmPassword: '', + } + + onClick = () => { + const { password, seedPhrase, confirmPassword } = this.state + const { createNewVaultAndRestore, next, displayWarning } = this.props + + if (seedPhrase.split(' ').length !== 12) { + this.warning = 'Seed Phrases are 12 words long' + displayWarning(this.warning) + return + } + + if (password.length < 8) { + this.warning = 'Passwords require a mimimum length of 8' + displayWarning(this.warning) + return + } + + if (password !== confirmPassword) { + this.warning = 'Confirmed password does not match' + displayWarning(this.warning) + return + } + this.warning = null + createNewVaultAndRestore(password, seedPhrase) + .then(next) + } + + render () { + return this.props.isLoading + ? <LoadingScreen loadingMessage="Creating your new account" /> + : ( + <div className="import-account"> + <a + className="import-account__back-button" + onClick={e => { + e.preventDefault() + this.props.back() + }} + href="#" + > + {`< Back`} + </a> + <div className="import-account__title"> + Import an Account with Seed Phrase + </div> + <div className="import-account__selector-label"> + Enter your secret twelve word phrase here to restore your vault. + </div> + <textarea + 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" + placeholder="New Password (min 8 characters)" + onChange={e => this.setState({password: e.target.value})} + /> + <input + className="first-time-flow__input create-password__confirm-input" + type="password" + placeholder="Confirm Password" + onChange={e => this.setState({confirmPassword: e.target.value})} + /> + <button + className="first-time-flow__button" + onClick={this.onClick} + > + Import + </button> + </div> + ) + } +} + +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) |