1
0
mirror of https://github.com/yldio/copilot.git synced 2024-11-15 07:40:07 +02:00
copilot/frontend/src/containers/app.js

82 lines
1.6 KiB
JavaScript
Raw Normal View History

2016-10-20 04:14:26 +03:00
const React = require('react');
const ReactRedux = require('react-redux');
const ReactRouter = require('react-router');
2016-12-13 16:35:39 +02:00
const Styled = require('styled-components');
2016-10-20 04:14:26 +03:00
2016-12-05 22:28:10 +02:00
const actions = require('@state/actions');
2016-12-13 16:35:39 +02:00
const Article = require('@components/article');
const Base = require('@ui/components/base');
const Footer = require('@components/footer');
const Header = require('@containers/header');
2016-12-05 22:28:10 +02:00
const Home = require('@containers/home');
const NotFound = require('@containers/not-found');
2016-10-20 04:14:26 +03:00
const {
updateRouter
} = actions;
const {
connect
} = ReactRedux;
const {
Miss,
Match
} = ReactRouter;
2016-12-13 16:35:39 +02:00
const {
injectGlobal
} = Styled;
2016-10-20 04:14:26 +03:00
const App = connect()(React.createClass({
2016-12-14 00:09:04 +02:00
displayName: 'App',
2016-10-25 22:15:33 +03:00
propTypes: {
children: React.PropTypes.node,
dispatch: React.PropTypes.func,
router: React.PropTypes.object
},
2016-10-20 04:14:26 +03:00
componentWillMount: function() {
const {
router,
dispatch
} = this.props;
// ugly hack needed because of a limitation of react-router api
// that doens't pass it's instance to matched routes
2016-10-20 22:42:39 +03:00
// wait for react-router-redux@5
2016-10-20 04:14:26 +03:00
dispatch(updateRouter(router));
2016-12-13 16:35:39 +02:00
injectGlobal`
${Base.global}
`;
2016-10-20 04:14:26 +03:00
},
render: function() {
const {
children
} = this.props;
if (!Array.isArray(children)) {
return children;
}
return (
2016-12-13 16:35:39 +02:00
<Base>
2016-10-20 04:14:26 +03:00
{children}
2016-12-13 16:35:39 +02:00
</Base>
2016-10-20 04:14:26 +03:00
);
}
}));
module.exports = (props) => {
return (
<App {...props}>
2016-12-13 16:35:39 +02:00
<Header />
<Article>
2016-12-15 16:10:36 +02:00
<Match component={Home} pattern='/:org?/:section?' />
2016-12-14 00:09:04 +02:00
<Miss component={NotFound} />
2016-12-13 16:35:39 +02:00
</Article>
<Footer />
2016-10-20 04:14:26 +03:00
</App>
);
};