aboutsummaryrefslogtreecommitdiffstats
path: root/mascara/src/app/first-time/index.js
diff options
context:
space:
mode:
authorAlexander Tseung <alextsg@gmail.com>2018-03-29 04:21:53 +0800
committerAlexander Tseung <alextsg@gmail.com>2018-03-29 04:23:50 +0800
commit58f52b2b8de9efd43896e23ab0ac9972f45bb278 (patch)
treecb1cca580f1ea1986eeb82b3271a5f013b3e6498 /mascara/src/app/first-time/index.js
parent6f367a5a6b4fb8918405f233293dc3f4840b4a3d (diff)
downloadtangerine-wallet-browser-58f52b2b8de9efd43896e23ab0ac9972f45bb278.tar.gz
tangerine-wallet-browser-58f52b2b8de9efd43896e23ab0ac9972f45bb278.tar.zst
tangerine-wallet-browser-58f52b2b8de9efd43896e23ab0ac9972f45bb278.zip
Fix merge conflicts. Refactor onboarding flow.
Diffstat (limited to 'mascara/src/app/first-time/index.js')
-rw-r--r--mascara/src/app/first-time/index.js86
1 files changed, 63 insertions, 23 deletions
diff --git a/mascara/src/app/first-time/index.js b/mascara/src/app/first-time/index.js
index b3494dec2..ea56a2f6e 100644
--- a/mascara/src/app/first-time/index.js
+++ b/mascara/src/app/first-time/index.js
@@ -1,6 +1,8 @@
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import {connect} from 'react-redux'
+import { withRouter, Switch, Route, Redirect } from 'react-router-dom'
+import { compose } from 'recompose'
import CreatePasswordScreen from './create-password-screen'
import UniqueImageScreen from './unique-image-screen'
import NoticeScreen from './notice-screen'
@@ -12,6 +14,13 @@ import {
unMarkPasswordForgotten,
showModal,
} from '../../../../ui/app/actions'
+import {
+ DEFAULT_ROUTE,
+ WELCOME_ROUTE,
+ INITIALIZE_ROUTE,
+ INITIALIZE_IMPORT_ACCOUNT_ROUTE,
+ INITIALIZE_IMPORT_WITH_SEED_PHRASE_ROUTE,
+} from '../../../../ui/app/routes'
class FirstTimeFlow extends Component {
@@ -20,7 +29,10 @@ class FirstTimeFlow extends Component {
seedWords: PropTypes.string,
address: PropTypes.string,
noActiveNotices: PropTypes.bool,
- goToBuyEtherView: PropTypes.func.isRequired,
+ goToBuyEtherView: PropTypes.func,
+ isUnlocked: PropTypes.bool,
+ history: PropTypes.object,
+ welcomeScreenSeen: PropTypes.bool,
};
static defaultProps = {
@@ -47,6 +59,14 @@ class FirstTimeFlow extends Component {
}
}
+ componentDidMount () {
+ const { isInitialized, isUnlocked, history } = this.props
+
+ if (isInitialized || isUnlocked) {
+ history.push(DEFAULT_ROUTE)
+ }
+ }
+
setScreenType (screenType) {
this.setState({ screenType })
}
@@ -141,34 +161,54 @@ class FirstTimeFlow extends Component {
}
render () {
- return (
- <div className="first-time-flow">
- {this.renderScreen()}
- </div>
- )
+ return this.props.welcomeScreenSeen
+ ? (
+ <div className="first-time-flow">
+ <Switch>
+ <Route exact path={INITIALIZE_IMPORT_ACCOUNT_ROUTE} component={ImportAccountScreen} />
+ <Route
+ exact
+ path={INITIALIZE_IMPORT_WITH_SEED_PHRASE_ROUTE}
+ component={ImportSeedPhraseScreen}
+ />
+ <Route exact path={INITIALIZE_ROUTE} component={CreatePasswordScreen} />
+ </Switch>
+ </div>
+ )
+ : <Redirect to={WELCOME_ROUTE } />
}
-
}
-export default connect(
- ({
- metamask: {
- isInitialized,
- seedWords,
- noActiveNotices,
- selectedAddress,
- forgottenPassword,
- }
- }) => ({
+const mapStateToProps = ({ metamask }) => {
+ const {
+ isInitialized,
+ seedWords,
+ noActiveNotices,
+ selectedAddress,
+ forgottenPassword,
+ isMascara,
+ isUnlocked,
+ welcomeScreenSeen,
+ } = metamask
+
+ return {
+ isMascara,
isInitialized,
seedWords,
noActiveNotices,
address: selectedAddress,
forgottenPassword,
- }),
- dispatch => ({
- leaveImportSeedScreenState: () => dispatch(unMarkPasswordForgotten()),
- openBuyEtherModal: () => dispatch(showModal({ name: 'DEPOSIT_ETHER'})),
- })
-)(FirstTimeFlow)
+ isUnlocked,
+ welcomeScreenSeen,
+ }
+}
+const mapDispatchToProps = dispatch => ({
+ leaveImportSeedScreenState: () => dispatch(unMarkPasswordForgotten()),
+ openBuyEtherModal: () => dispatch(showModal({ name: 'DEPOSIT_ETHER'})),
+})
+
+export default compose(
+ withRouter,
+ connect(mapStateToProps, mapDispatchToProps)
+)(FirstTimeFlow)