summaryrefslogtreecommitdiff
path: root/ui/app/components/wizard/register_stage.js
blob: 36fe21b46117f7a05e56e57fba75b50e89e84998 (plain)
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import React from 'react'
import {Button, ButtonGroup, ButtonToolbar,
        Glyphicon, Tabs, Tab} from 'react-bootstrap'

import App from 'app'
import Provider from 'models/provider'
import Login from 'components/login'
import Center from 'components/center'

import StageLayout from './stage_layout'

export default class RegisterStage extends React.Component {

  static get defaultProps() {return{
    provider: null
  }}

  constructor(props) {
    super(props)
    this.state = {
      activeTab:   'signup',   // either 'login' or 'signup'
      error: null       // error message
    }
    // this.add      = this.add.bind(this)
    // this.remove   = this.remove.bind(this)
    // this.select   = this.select.bind(this)
    this.selectTab = this.selectTab.bind(this)
    this.previous = this.previous.bind(this)
    this.cancel = this.cancel.bind(this)
    this.login = this.login.bind(this)
  }

  previous() {
    App.show('wizard', {
      stage: 'provider',
      initialProvider: this.props.provider
    })
  }

  cancel() {
    App.start()
  }

  login(account) {
    App.show('main', {initialAccount: account})
  }

  selectTab(key) {
    this.setState({
      activeTab: key
    })
  }

  render() {
    let buttons = (
      <div>
        <ButtonToolbar className="pull-left">
          <Button onClick={this.cancel}>
            Cancel
          </Button>
        </ButtonToolbar>
        <ButtonToolbar className="pull-right">
          <Button onClick={this.previous}>
            <Glyphicon glyph="chevron-left" />
            Previous
          </Button>
        </ButtonToolbar>
      </div>
    )
    return(
      <StageLayout title={this.props.provider.domain} buttons={buttons}>
        <Tabs activeKey={this.state.activeTab} onSelect={this.selectTab} animation={false} id="login-tabs">
          <Tab eventKey="signup" title="Sign up">
            <div className="vspacer" />
            <Center direction="horizontal" width={400}>
              <Login mode="signup" domain={this.props.provider.domain} onLogin={this.login} />
            </Center>
          </Tab>
          <Tab eventKey="login" title="Log In">
            <div className="vspacer" />
            <Center direction="horizontal" width={400}>
              <Login domain={this.props.provider.domain} onLogin={this.login} />
            </Center>
          </Tab>
        </Tabs>
      </StageLayout>
    )
  }
}