2015-11-06 12:09:31 +01:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
import React from 'react';
|
|
|
|
import GlobalNotification from '../../../global_notification';
|
|
|
|
|
2015-11-11 16:27:50 +01:00
|
|
|
import Hero from './components/pr_hero';
|
|
|
|
|
|
|
|
import UserStore from '../../../../stores/user_store';
|
|
|
|
import UserActions from '../../../../actions/user_actions';
|
|
|
|
|
2015-11-06 12:09:31 +01:00
|
|
|
import { getSubdomain } from '../../../../utils/general_utils';
|
2015-11-11 16:27:50 +01:00
|
|
|
import { getCookie } from '../../../../utils/fetch_api_utils';
|
2015-11-06 12:09:31 +01:00
|
|
|
|
|
|
|
|
2015-11-11 16:27:50 +01:00
|
|
|
let PRApp = React.createClass({
|
2015-11-06 12:09:31 +01:00
|
|
|
propTypes: {
|
|
|
|
children: React.PropTypes.oneOfType([
|
|
|
|
React.PropTypes.arrayOf(React.PropTypes.element),
|
|
|
|
React.PropTypes.element
|
|
|
|
]),
|
|
|
|
history: React.PropTypes.object,
|
|
|
|
routes: React.PropTypes.arrayOf(React.PropTypes.object)
|
|
|
|
},
|
|
|
|
|
2015-11-11 16:27:50 +01:00
|
|
|
getInitialState() {
|
|
|
|
return UserStore.getState();
|
|
|
|
},
|
|
|
|
|
|
|
|
componentDidMount() {
|
|
|
|
UserStore.listen(this.onChange);
|
|
|
|
UserActions.fetchCurrentUser();
|
|
|
|
},
|
|
|
|
|
|
|
|
componentWillUnmount() {
|
|
|
|
UserStore.unlisten(this.onChange);
|
|
|
|
},
|
|
|
|
|
|
|
|
onChange(state) {
|
|
|
|
this.setState(state);
|
|
|
|
},
|
|
|
|
|
2015-11-06 12:09:31 +01:00
|
|
|
render() {
|
2015-11-11 16:27:50 +01:00
|
|
|
const { history, children } = this.props;
|
|
|
|
const { currentUser } = this.state;
|
2015-11-06 12:09:31 +01:00
|
|
|
let subdomain = getSubdomain();
|
2015-11-11 16:27:50 +01:00
|
|
|
let header;
|
|
|
|
|
|
|
|
if (currentUser && currentUser.email && history.isActive(`/pieces/${getCookie(currentUser.email)}`)) {
|
|
|
|
header = <Hero />;
|
|
|
|
}
|
2015-11-06 12:09:31 +01:00
|
|
|
|
|
|
|
return (
|
2015-11-11 16:27:50 +01:00
|
|
|
<div>
|
|
|
|
{header}
|
|
|
|
<div className={'container ascribe-prize-app client--' + subdomain}>
|
|
|
|
{children}
|
|
|
|
<GlobalNotification />
|
|
|
|
<div id="modal" className="container"></div>
|
|
|
|
</div>
|
2015-11-06 12:09:31 +01:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-11-11 16:27:50 +01:00
|
|
|
export default PRApp;
|