summaryrefslogtreecommitdiffstats
path: root/web/react/components/signup_team_complete.jsx
blob: 6c7fd57b34a8ab1c12d5f055215b6891af799f1c (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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.

import WelcomePage from './team_signup_welcome_page.jsx';
import TeamDisplayNamePage from './team_signup_display_name_page.jsx';
import TeamURLPage from './team_signup_url_page.jsx';
import SendInivtesPage from './team_signup_send_invites_page.jsx';
import UsernamePage from './team_signup_username_page.jsx';
import PasswordPage from './team_signup_password_page.jsx';
import BrowserStore from '../stores/browser_store.jsx';

export default class SignupTeamComplete extends React.Component {
    constructor(props) {
        super(props);

        this.updateParent = this.updateParent.bind(this);

        var initialState = BrowserStore.getGlobalItem(props.hash);

        if (!initialState) {
            initialState = {};
            initialState.wizard = 'welcome';
            initialState.team = {};
            initialState.team.email = this.props.email;
            initialState.team.allowed_domains = '';
            initialState.invites = [];
            initialState.invites.push('');
            initialState.invites.push('');
            initialState.invites.push('');
            initialState.user = {};
            initialState.hash = this.props.hash;
            initialState.data = this.props.data;
        }

        this.state = initialState;
    }
    updateParent(state, skipSet) {
        BrowserStore.setGlobalItem(this.props.hash, state);

        if (!skipSet) {
            this.setState(state);
        }
    }
    render() {
        if (this.state.wizard === 'welcome') {
            return (
                <WelcomePage
                    state={this.state}
                    updateParent={this.updateParent}
                />
            );
        }

        if (this.state.wizard === 'team_display_name') {
            return (
                <TeamDisplayNamePage
                    state={this.state}
                    updateParent={this.updateParent}
                />
            );
        }

        if (this.state.wizard === 'team_url') {
            return (
                <TeamURLPage
                    state={this.state}
                    updateParent={this.updateParent}
                />
            );
        }

        if (this.state.wizard === 'send_invites') {
            return (
                <SendInivtesPage
                    state={this.state}
                    updateParent={this.updateParent}
                />
            );
        }

        if (this.state.wizard === 'username') {
            return (
                <UsernamePage
                    state={this.state}
                    updateParent={this.updateParent}
                />
            );
        }

        if (this.state.wizard === 'password') {
            return (
                <PasswordPage
                    state={this.state}
                    updateParent={this.updateParent}
                />
            );
        }

        return (<div>You've already completed the signup process for this invitation or this invitation has expired.</div>);
    }
}

SignupTeamComplete.defaultProps = {
    hash: '',
    email: '',
    data: ''
};
SignupTeamComplete.propTypes = {
    hash: React.PropTypes.string,
    email: React.PropTypes.string,
    data: React.PropTypes.string
};