1
0
mirror of https://github.com/ascribe/onion.git synced 2025-01-21 02:01:56 +01:00
onion/js/components/whitelabel/prize/portfolioreview/pr_app.js

76 lines
2.1 KiB
JavaScript
Raw Normal View History

'use strict';
import React from 'react';
import GlobalNotification from '../../../global_notification';
import Hero from './components/pr_hero';
2015-12-08 15:21:20 +01:00
import Header from '../../../header';
import UserStore from '../../../../stores/user_store';
import UserActions from '../../../../actions/user_actions';
import { getSubdomain } from '../../../../utils/general_utils';
import { getCookie } from '../../../../utils/fetch_api_utils';
let PRApp = React.createClass({
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)
},
getInitialState() {
return UserStore.getState();
},
componentDidMount() {
UserStore.listen(this.onChange);
UserActions.fetchCurrentUser();
},
componentWillUnmount() {
UserStore.unlisten(this.onChange);
},
onChange(state) {
this.setState(state);
},
render() {
const { history, children, routes } = this.props;
const { currentUser } = this.state;
2015-12-08 15:21:20 +01:00
let style = {};
let subdomain = getSubdomain();
let header;
2015-12-08 15:21:20 +01:00
if (currentUser && currentUser.email && history.isActive(`/pieces/${getCookie(currentUser.email)}`)) {
header = <Hero />;
2015-12-08 15:21:20 +01:00
style = { paddingTop: '0 !important' };
} else if(currentUser && (currentUser.is_admin || currentUser.is_jury || currentUser.is_judge)) {
2015-12-08 16:43:45 +01:00
header = <Header routes={routes} />;
2015-12-08 15:21:20 +01:00
} else {
style = { paddingTop: '0 !important' };
}
return (
<div>
{header}
2015-12-08 15:21:20 +01:00
<div
style={style}
className={'container ascribe-prize-app client--' + subdomain}>
{children}
<GlobalNotification />
<div id="modal" className="container"></div>
</div>
</div>
);
}
});
export default PRApp;