aboutsummaryrefslogtreecommitdiffstats
path: root/mascara/src/app/first-time/index.js
blob: a2cb8d71cd648d8c4795518e93080bed40a5f7c4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import React, {Component, PropTypes} from 'react'
import CreatePasswordScreen from './create-password-screen'

export default class FirstTimeFlow extends Component {

  static propTypes = {
    screenType: PropTypes.string
  };

  static defaultProps = {
    screenType: FirstTimeFlow.CREATE_PASSWORD
  };

  static SCREEN_TYPE = {
    CREATE_PASSWORD: 'create_password',
    UNIQUE_IMAGE: 'unique_image',
    TERM_OF_USE: 'term_of_use',
    BACK_UP_PHRASE: 'back_up_phrase',
    CONFIRM_BACK_UP_PHRASE: 'confirm_back_up_phrase',
    BUY_ETHER: 'buy_ether'
  };

  static getScreenType = ({isInitialized, noActiveNotices, seedWords}) => {
    const {SCREEN_TYPE} = FirstTimeFlow

    if (!isInitialized) {
      return SCREEN_TYPE.CREATE_PASSWORD
    }

    if (!noActiveNotices) {
      return SCREEN_TYPE.TERM_OF_USE
    }

    if (seedWords) {
      return SCREEN_TYPE.BACK_UP_PHRASE
    }
  };

  renderScreen() {
    const {SCREEN_TYPE} = FirstTimeFlow

    switch (this.props.screenType) {
      case SCREEN_TYPE.CREATE_PASSWORD:
        return <CreatePasswordScreen />
      default:
        return <noscript />
    }
  }

  render() {
    return <div>{this.renderScreen()}</div>
  }

}