1
0
mirror of https://github.com/ascribe/onion.git synced 2025-01-26 17:51:04 +01:00
onion/js/components/whitelabel/prize/simple_prize/prize_app.js

53 lines
1.5 KiB
JavaScript
Raw Normal View History

'use strict';
import React from 'react';
import Hero from './components/prize_hero';
import AppBase from '../../../app_base';
import Header from '../../../header';
import { getSubdomain } from '../../../../utils/general_utils';
let PrizeApp = React.createClass({
propTypes: {
history: React.PropTypes.object.isRequired,
routes: React.PropTypes.arrayOf(React.PropTypes.object).isRequired,
children: React.PropTypes.oneOfType([
React.PropTypes.arrayOf(React.PropTypes.element),
React.PropTypes.element
])
},
2015-07-13 16:34:26 +02:00
render() {
const { children, history, routes } = this.props;
const subdomain = getSubdomain();
// 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;
let header = null;
// if the path of the current activeRoute is not defined, then this is the IndexRoute
if (!path || history.isActive('/login') || history.isActive('/signup')) {
header = (<Hero />);
2015-07-14 18:55:34 +02:00
} else {
header = (<Header routes={routes} />);
2015-07-13 16:34:26 +02:00
}
return (
<div className="ascribe-prize-app">
2015-07-13 16:34:26 +02:00
{header}
<div className="container ascribe-body">
{/* Routes are injected here */}
{children}
</div>
</div>
);
}
});
export default AppBase(PrizeApp);