2017-05-24 12:19:23 +00:00
|
|
|
import PropTypes from 'prop-types';
|
2017-06-05 05:01:29 +00:00
|
|
|
import withRedux from 'next-redux-wrapper';
|
2017-05-24 12:19:23 +00:00
|
|
|
|
2017-06-19 14:35:54 +00:00
|
|
|
import { initStore } from 'modules/store.js';
|
2017-06-09 05:28:21 +00:00
|
|
|
import withSession from 'helpers/with-session';
|
2017-06-09 03:26:33 +00:00
|
|
|
|
2017-06-09 05:28:21 +00:00
|
|
|
import Auth from 'containers/Auth';
|
|
|
|
import App from 'containers/App';
|
2017-05-24 01:07:56 +00:00
|
|
|
|
|
|
|
const Restricted = (Component) => {
|
|
|
|
const checkAuth = (props) => {
|
2017-06-09 03:26:33 +00:00
|
|
|
return props.isLoggedIn ? <Component {...props} /> : <Auth/>
|
2017-05-24 01:07:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return withSession(checkAuth);
|
|
|
|
}
|
|
|
|
|
2017-05-25 08:11:47 +00:00
|
|
|
const Index = Restricted(({session}) => (
|
|
|
|
<div>
|
2017-05-26 14:06:01 +00:00
|
|
|
<App session={session} />
|
2017-05-25 08:11:47 +00:00
|
|
|
</div>
|
2017-05-24 01:07:56 +00:00
|
|
|
)
|
2017-05-25 08:11:47 +00:00
|
|
|
)
|
2017-05-24 01:07:56 +00:00
|
|
|
|
2017-05-24 12:19:23 +00:00
|
|
|
Index.propTypes = {
|
|
|
|
session: PropTypes.object.isRequired
|
|
|
|
};
|
2017-05-24 01:07:56 +00:00
|
|
|
|
2017-06-05 05:01:29 +00:00
|
|
|
export default withRedux(initStore)(Index);
|