// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
//import $ from 'jquery';
//import Client from 'utils/web_client.jsx';
import * as GlobalActions from 'action_creators/global_actions.jsx';
import LocalizationStore from 'stores/localization_store.jsx';
import {IntlProvider} from 'react-intl';
import React from 'react';
import FastClick from 'fastclick';
import {browserHistory} from 'react-router';
import UserStore from 'stores/user_store.jsx';
export default class Root extends React.Component {
constructor(props) {
super(props);
this.state = {
locale: 'en',
translations: null
};
this.localizationChanged = this.localizationChanged.bind(this);
this.redirectIfNecessary = this.redirectIfNecessary.bind(this);
}
localizationChanged() {
this.setState({locale: LocalizationStore.getLocale(), translations: LocalizationStore.getTranslations()});
}
redirectIfNecessary(props) {
if (props.location.pathname === '/') {
if (UserStore.getNoAccounts()) {
browserHistory.push('/signup_user_complete');
} else if (UserStore.getCurrentUser()) {
browserHistory.push('/select_team');
} else {
browserHistory.push('/login');
}
}
}
componentWillReceiveProps(newProps) {
this.redirectIfNecessary(newProps);
}
componentWillMount() {
// Setup localization listener
LocalizationStore.addChangeListener(this.localizationChanged);
// Ya....
/*eslint-disable */
if (window.mm_config.SegmentDeveloperKey != null && window.mm_config.SegmentDeveloperKey !== "") {
!function(){var analytics=global.window.analytics=global.window.analytics||[];if(!analytics.initialize)if(analytics.invoked)window.console&&console.error&&console.error("Segment snippet included twice.");else{analytics.invoked=!0;analytics.methods=["trackSubmit","trackClick","trackLink","trackForm","pageview","identify","group","track","ready","alias","page","once","off","on"];analytics.factory=function(t){return function(){var e=Array.prototype.slice.call(arguments);e.unshift(t);analytics.push(e);return analytics}};for(var t=0;t;
}
return (
{this.props.children}
);
}
}
Root.defaultProps = {
};
Root.propTypes = {
children: React.PropTypes.object
};