summaryrefslogtreecommitdiffstats
path: root/webapp/components/signup_team_complete/components/signup_team_complete.jsx
blob: 00fdafe5f9f0021a17648cfcc3d6fdbb7824b14d (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
// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.

import BrowserStore from 'stores/browser_store.jsx';

import {FormattedMessage} from 'react-intl';

import React from 'react';
import {Link, browserHistory} from 'react-router';

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

        this.updateParent = this.updateParent.bind(this);
    }
    componentWillMount() {
        const data = JSON.parse(this.props.location.query.d);
        this.hash = this.props.location.query.h;

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

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

        this.setState(initialState);
    }
    componentDidMount() {
        browserHistory.push('/signup_team_complete/welcome');
    }
    updateParent(state, skipSet) {
        BrowserStore.setGlobalItem(this.hash, state);

        if (!skipSet) {
            this.setState(state);
            browserHistory.push('/signup_team_complete/' + state.wizard);
        }
    }
    render() {
        return (
            <div>
                <div className='signup-header'>
                    <Link to='/'>
                        <span className='fa fa-chevron-left'/>
                        <FormattedMessage id='web.header.back'/>
                    </Link>
                </div>
                <div className='col-sm-12'>
                    <div className='signup-team__container'>
                        <div id='signup-team-complete'>
                            {React.cloneElement(this.props.children, {
                                state: this.state,
                                updateParent: this.updateParent
                            })}
                        </div>
                    </div>
                </div>
            </div>
        );
    }
}

SignupTeamComplete.defaultProps = {
};

SignupTeamComplete.propTypes = {
    location: React.PropTypes.object,
    children: React.PropTypes.node
};