1
0
mirror of https://github.com/ascribe/onion.git synced 2024-06-30 13:41:57 +02:00
onion/js/components/whitelabel/prize/portfolioreview/pr_app.js

74 lines
2.4 KiB
JavaScript
Raw Normal View History

'use strict';
import React from 'react';
2016-02-05 10:38:59 +01:00
import classNames from 'classnames';
import EventActions from '../../../../actions/event_actions';
import UserStore from '../../../../stores/user_store';
import UserActions from '../../../../actions/user_actions';
2016-02-05 10:38:59 +01:00
import Hero from './components/pr_hero';
2016-02-05 10:38:59 +01:00
import AppBase from '../../../app_base';
import AppRouteWrapper from '../../../app_route_wrapper';
2016-02-05 10:38:59 +01:00
import Footer from '../../../footer';
import Header from '../../../header';
2016-02-05 10:38:59 +01:00
import { getSubdomain } from '../../../../utils/general_utils';
import { getCookie } from '../../../../utils/fetch_api_utils';
let PRApp = React.createClass({
propTypes: {
2016-02-05 10:38:59 +01:00
activeRoute: React.PropTypes.object.isRequired,
children: React.PropTypes.element.isRequired,
2016-01-12 15:05:00 +01:00
history: React.PropTypes.object.isRequired,
routes: React.PropTypes.arrayOf(React.PropTypes.object).isRequired,
2016-02-05 10:38:59 +01:00
// Provided from AppBase
currentUser: React.PropTypes.object,
whitelabel: React.PropTypes.object
},
render() {
2016-02-05 10:38:59 +01:00
const { activeRoute, children, currentUser, history, routes, whitelabel } = this.props;
const subdomain = getSubdomain();
2016-02-05 10:38:59 +01:00
const path = activeRoute && activeRoute.path;
2015-12-08 15:21:20 +01:00
let style = {};
let header;
if (currentUser && currentUser.email && history.isActive(`/pieces/${getCookie(currentUser.email)}`)) {
header = (<Hero currentUser={currentUser} />);
2015-12-08 15:21:20 +01:00
style = { paddingTop: '0 !important' };
2016-02-05 10:38:59 +01:00
} else if (currentUser && (currentUser.is_admin || currentUser.is_jury || currentUser.is_judge)) {
header = (
<Header
currentUser={currentUser}
routes={routes}
whitelabel={whitelabel}
/>
);
2015-12-08 15:21:20 +01:00
} else {
style = { paddingTop: '0 !important' };
}
return (
2016-02-05 10:38:59 +01:00
<div
style={style}
className={classNames('ascribe-app', 'ascribe-prize-app', `route--${(path ? path.split('/')[0] : 'landing')}`)}>
{header}
2016-02-05 10:38:59 +01:00
<AppRouteWrapper
currentUser={currentUser}
whitelabel={whitelabel}>
{/* Routes are injected here */}
{children}
</AppRouteWrapper>
<Footer activeRoute={activeRoute} />
</div>
);
}
});
2016-02-05 10:38:59 +01:00
export default AppBase(PRApp);