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';
|
|
|
|
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 = {
|
|
|
|
logged: false
|
|
|
|
};
|
|
|
|
|
|
|
|
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-23 13:09:50 +01:00
|
|
|
{this.props.children}
|
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({
|
|
|
|
logged: value
|
|
|
|
})
|
|
|
|
});
|
|
|
|
}
|
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} />
|
|
|
|
<Route path=":category" component={Category} />
|
|
|
|
</Route>
|
|
|
|
</Router>
|
|
|
|
), document.querySelector('.flox'));
|