1
0
mirror of https://github.com/ascribe/onion.git synced 2025-01-08 20:55:59 +01:00
onion/js/components/whitelabel/wallet/wallet_app.js
Brett Sun d1dba86b1a Convert currentUser to be passed down through context and withCurrentUser HOC
Similar to what react-router did with their router and withRouter HOC.
2016-06-07 14:56:35 +02:00

59 lines
2.2 KiB
JavaScript

import React from 'react';
import withRouter from 'react-router/es6/withRouter';
import classNames from 'classnames';
import AppBase from '../../app_base';
import AppRouteWrapper from '../../app_route_wrapper';
import Header from '../../header';
import { getSubdomain } from '../../../utils/general_utils';
let WalletApp = React.createClass({
propTypes: {
activeRoute: React.PropTypes.object.isRequired,
children: React.PropTypes.element.isRequired,
router: React.PropTypes.object.isRequired,
routes: React.PropTypes.arrayOf(React.PropTypes.object).isRequired,
// Provided from AppBase
whitelabel: React.PropTypes.object
},
render() {
const { activeRoute, children, router, routes, whitelabel } = this.props;
const subdomain = getSubdomain();
const path = activeRoute && activeRoute.path;
const Footer = activeRoute && activeRoute.footer;
let header = null;
// if the path of the current activeRoute is not defined, then this is the IndexRoute
if ((!path || router.isActive('/login') || router.isActive('/signup') || router.isActive('/contract_notifications'))
&& (['cyland', 'ikonotv', 'lumenus', '23vivi', 'polline', 'artcity', 'demo', 'liquidgallery']).includes(subdomain)) {
header = (<div className="hero"/>);
} else {
header = (
<Header
routes={routes}
whitelabel={whitelabel} />
);
}
// In react-router 1.0, Routes have no 'name' property anymore. To keep functionality however,
// we split the path by the first occurring slash and take the first splitter.
return (
<div className={classNames('ascribe-app', 'ascribe-wallet-app', `route--${(path ? path.split('/')[0] : 'landing')}`)}>
{header}
<AppRouteWrapper
whitelabel={whitelabel}>
{/* Routes are injected here */}
{children}
</AppRouteWrapper>
{Footer ? <Footer /> : null}
</div>
);
}
});
export default AppBase(withRouter(WalletApp));