2015-07-10 16:43:35 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
import React from 'react';
|
2016-01-19 15:00:50 +01:00
|
|
|
|
2015-08-11 14:47:28 +02:00
|
|
|
import Hero from './components/prize_hero';
|
2016-01-19 15:00:50 +01:00
|
|
|
|
|
|
|
import AppBase from '../../../app_base';
|
2015-11-05 16:45:12 +01:00
|
|
|
import Header from '../../../header';
|
2015-07-10 16:43:35 +02:00
|
|
|
|
2015-11-05 16:45:12 +01:00
|
|
|
import { getSubdomain } from '../../../../utils/general_utils';
|
2015-09-29 14:58:56 +02:00
|
|
|
|
|
|
|
|
2015-07-10 16:43:35 +02:00
|
|
|
let PrizeApp = React.createClass({
|
2015-10-01 11:16:38 +02:00
|
|
|
propTypes: {
|
2016-01-19 15:00:50 +01:00
|
|
|
history: React.PropTypes.object.isRequired,
|
|
|
|
routes: React.PropTypes.arrayOf(React.PropTypes.object).isRequired,
|
|
|
|
|
2015-10-01 11:16:38 +02:00
|
|
|
children: React.PropTypes.oneOfType([
|
|
|
|
React.PropTypes.arrayOf(React.PropTypes.element),
|
|
|
|
React.PropTypes.element
|
2016-01-19 15:00:50 +01:00
|
|
|
])
|
2015-10-01 11:16:38 +02:00
|
|
|
},
|
2015-07-13 16:34:26 +02:00
|
|
|
|
2015-07-10 16:43:35 +02:00
|
|
|
render() {
|
2016-01-19 15:00:50 +01:00
|
|
|
const { children, history, routes } = this.props;
|
|
|
|
const subdomain = getSubdomain();
|
2015-08-27 14:34:15 +02:00
|
|
|
|
2015-10-09 15:19:24 +02:00
|
|
|
// The second element of routes is always the active component object, where we can
|
|
|
|
// extract the path.
|
|
|
|
let path = routes[1] ? routes[1].path : null;
|
|
|
|
|
2016-01-19 15:00:50 +01:00
|
|
|
let header = null;
|
2015-10-09 15:19:24 +02:00
|
|
|
// if the path of the current activeRoute is not defined, then this is the IndexRoute
|
|
|
|
if (!path || history.isActive('/login') || history.isActive('/signup')) {
|
2016-01-19 15:00:50 +01:00
|
|
|
header = (<Hero />);
|
2015-07-14 18:55:34 +02:00
|
|
|
} else {
|
2016-01-19 15:00:50 +01:00
|
|
|
header = (<Header routes={routes} />);
|
2015-07-13 16:34:26 +02:00
|
|
|
}
|
|
|
|
|
2015-07-10 16:43:35 +02:00
|
|
|
return (
|
2016-01-19 15:04:46 +01:00
|
|
|
<div className="ascribe-prize-app">
|
2015-07-13 16:34:26 +02:00
|
|
|
{header}
|
2016-01-19 15:04:46 +01:00
|
|
|
<div className="container ascribe-body">
|
|
|
|
{/* Routes are injected here */}
|
2016-01-19 15:00:50 +01:00
|
|
|
{children}
|
2016-01-19 15:04:46 +01:00
|
|
|
</div>
|
2015-07-10 16:43:35 +02:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2016-01-19 15:00:50 +01:00
|
|
|
export default AppBase(PrizeApp);
|