mirror of
https://github.com/ascribe/onion.git
synced 2024-12-23 01:39:36 +01:00
74 lines
1.9 KiB
JavaScript
74 lines
1.9 KiB
JavaScript
'use strict';
|
|
|
|
import React from 'react';
|
|
|
|
import UserActions from '../actions/user_actions';
|
|
import UserStore from '../stores/user_store';
|
|
|
|
import WhitelabelActions from '../actions/whitelabel_actions';
|
|
import WhitelabelStore from '../stores/whitelabel_store';
|
|
|
|
import AppRouteWrapper from './app_route_wrapper';
|
|
import Header from './header';
|
|
import Footer from './footer';
|
|
import GlobalNotification from './global_notification';
|
|
|
|
import { mergeOptions } from '../utils/general_utils';
|
|
|
|
|
|
let AscribeApp = React.createClass({
|
|
propTypes: {
|
|
children: React.PropTypes.oneOfType([
|
|
React.PropTypes.arrayOf(React.PropTypes.element),
|
|
React.PropTypes.element
|
|
]),
|
|
routes: React.PropTypes.arrayOf(React.PropTypes.object)
|
|
},
|
|
|
|
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);
|
|
},
|
|
|
|
render() {
|
|
const { children, routes } = this.props;
|
|
const { currentUser, whitelabel } = this.state;
|
|
|
|
return (
|
|
<div className="container ascribe-default-app">
|
|
<Header routes={routes} />
|
|
<AppRouteWrapper
|
|
currentUser={currentUser}
|
|
whitelabel={whitelabel}>
|
|
{/* Routes are injected here */}
|
|
{children}
|
|
</AppRouteWrapper>
|
|
<Footer />
|
|
<GlobalNotification />
|
|
<div id="modal" className="container"></div>
|
|
</div>
|
|
);
|
|
}
|
|
});
|
|
|
|
export default AscribeApp;
|