2015-07-27 20:49:37 +02:00
|
|
|
import React from 'react';
|
2016-02-23 13:09:50 +01:00
|
|
|
import {render} from 'react-dom';
|
|
|
|
import {Router, Route, browserHistory, IndexRoute} from 'react-router';
|
|
|
|
|
2015-07-27 20:49:37 +02:00
|
|
|
import Api from './api';
|
|
|
|
import Home from './sites/home';
|
|
|
|
import Category from './sites/category';
|
2016-02-25 11:25:19 +01:00
|
|
|
import Admin from './sites/admin';
|
2015-07-27 20:49:37 +02:00
|
|
|
import Header from './partials/header';
|
|
|
|
import Footer from './partials/footer';
|
|
|
|
|
|
|
|
class Flox extends React.Component {
|
2016-02-24 20:15:50 +01:00
|
|
|
|
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
|
|
|
|
this.state = {
|
2016-02-25 10:41:31 +01:00
|
|
|
logged: true
|
2016-02-24 20:15:50 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
this.checkLogin();
|
|
|
|
}
|
|
|
|
|
2015-07-27 20:49:37 +02:00
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<div>
|
2016-02-24 20:15:50 +01:00
|
|
|
<Header logged={this.state.logged} />
|
2016-02-25 10:41:31 +01:00
|
|
|
{React.cloneElement(this.props.children, {logged: this.state.logged})}
|
2015-07-27 20:49:37 +02:00
|
|
|
<Footer />
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
2016-02-24 20:15:50 +01:00
|
|
|
|
|
|
|
checkLogin() {
|
|
|
|
Api.checkLogin().then((value) => {
|
|
|
|
this.setState({
|
2016-02-25 10:41:31 +01:00
|
|
|
logged: value.logged
|
2016-02-24 20:15:50 +01:00
|
|
|
})
|
|
|
|
});
|
|
|
|
}
|
2015-07-27 20:49:37 +02:00
|
|
|
}
|
|
|
|
|
2016-02-23 13:09:50 +01:00
|
|
|
render((
|
2016-02-23 13:54:52 +01:00
|
|
|
<Router history={browserHistory} onUpdate={() => window.scrollTo(0, 0)}>
|
2016-02-23 13:09:50 +01:00
|
|
|
<Route component={Flox} path={config.uri}>
|
|
|
|
<IndexRoute component={Home} />
|
2016-02-25 11:25:19 +01:00
|
|
|
<Route path="admin" component={Admin} />
|
2016-02-23 13:09:50 +01:00
|
|
|
<Route path=":category" component={Category} />
|
|
|
|
</Route>
|
|
|
|
</Router>
|
|
|
|
), document.querySelector('.flox'));
|