2015-06-05 11:06:36 +02:00
|
|
|
'use strict';
|
|
|
|
|
2015-05-13 16:26:12 +02:00
|
|
|
import React from 'react';
|
2015-10-02 11:03:42 +02:00
|
|
|
|
2016-01-11 12:54:15 +01:00
|
|
|
import UserActions from '../actions/user_actions';
|
|
|
|
import UserStore from '../stores/user_store';
|
|
|
|
|
|
|
|
import WhitelabelActions from '../actions/whitelabel_actions';
|
|
|
|
import WhitelabelStore from '../stores/whitelabel_store';
|
|
|
|
|
2016-01-11 14:00:09 +01:00
|
|
|
import AppRouteWrapper from './app_route_wrapper';
|
2016-01-11 12:54:15 +01:00
|
|
|
import Header from './header';
|
|
|
|
import Footer from './footer';
|
2015-06-08 18:14:25 +02:00
|
|
|
import GlobalNotification from './global_notification';
|
2015-05-15 15:38:25 +02:00
|
|
|
|
2016-01-11 12:54:15 +01:00
|
|
|
import { mergeOptions } from '../utils/general_utils';
|
|
|
|
|
2015-05-18 18:00:12 +02:00
|
|
|
|
2015-05-20 12:00:16 +02:00
|
|
|
let AscribeApp = React.createClass({
|
2015-09-30 17:09:46 +02:00
|
|
|
propTypes: {
|
|
|
|
children: React.PropTypes.oneOfType([
|
|
|
|
React.PropTypes.arrayOf(React.PropTypes.element),
|
|
|
|
React.PropTypes.element
|
2015-10-01 14:00:56 +02:00
|
|
|
]),
|
|
|
|
routes: React.PropTypes.arrayOf(React.PropTypes.object)
|
2015-09-30 17:09:46 +02:00
|
|
|
},
|
|
|
|
|
2016-01-11 12:54:15 +01:00
|
|
|
getInitialState() {
|
|
|
|
return mergeOptions(
|
|
|
|
UserStore.getState(),
|
|
|
|
WhitelabelStore.getState()
|
|
|
|
);
|
|
|
|
},
|
|
|
|
|
|
|
|
componentDidMount() {
|
|
|
|
UserStore.listen(this.onChange);
|
|
|
|
WhitelabelStore.listen(this.onChange);
|
|
|
|
|
|
|
|
UserActions.fetchCurrentUser();
|
|
|
|
WhitelabelActions.fetchWhitelabel();
|
|
|
|
},
|
|
|
|
|
|
|
|
componentWillUnmount() {
|
|
|
|
UserStore.unlisten(this.onChange);
|
|
|
|
WhitelabelActions.unlisten(this.onChange);
|
|
|
|
},
|
|
|
|
|
|
|
|
onChange(state) {
|
|
|
|
this.setState(state);
|
|
|
|
},
|
|
|
|
|
2015-05-18 18:00:12 +02:00
|
|
|
render() {
|
2016-01-11 12:54:15 +01:00
|
|
|
const { children, routes } = this.props;
|
|
|
|
const { currentUser, whitelabel } = this.state;
|
|
|
|
|
2015-05-18 18:00:12 +02:00
|
|
|
return (
|
2015-07-13 14:29:20 +02:00
|
|
|
<div className="container ascribe-default-app">
|
2016-01-11 18:41:07 +01:00
|
|
|
<Header
|
|
|
|
currentUser={currentUser}
|
|
|
|
routes={routes}
|
|
|
|
whitelabel={whitelabel} />
|
2016-01-11 14:00:09 +01:00
|
|
|
<AppRouteWrapper
|
|
|
|
currentUser={currentUser}
|
|
|
|
whitelabel={whitelabel}>
|
2016-01-11 12:54:15 +01:00
|
|
|
{/* Routes are injected here */}
|
2016-01-11 14:00:09 +01:00
|
|
|
{children}
|
|
|
|
</AppRouteWrapper>
|
2015-07-02 15:41:17 +02:00
|
|
|
<Footer />
|
2015-06-08 18:14:25 +02:00
|
|
|
<GlobalNotification />
|
|
|
|
<div id="modal" className="container"></div>
|
2015-06-05 11:06:36 +02:00
|
|
|
</div>
|
2015-05-18 18:00:12 +02:00
|
|
|
);
|
|
|
|
}
|
2015-05-20 12:00:16 +02:00
|
|
|
});
|
2015-05-13 16:26:12 +02:00
|
|
|
|
2015-05-18 09:31:22 +02:00
|
|
|
export default AscribeApp;
|