1
0
mirror of https://github.com/devfake/flox.git synced 2024-11-14 22:22:39 +01:00
flox/client/app/app.js
2016-02-25 10:41:31 +01:00

49 lines
1.1 KiB
JavaScript

import React from 'react';
import {render} from 'react-dom';
import {Router, Route, browserHistory, IndexRoute} from 'react-router';
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 {
constructor() {
super();
this.state = {
logged: true
};
this.checkLogin();
}
render() {
return (
<div>
<Header logged={this.state.logged} />
{React.cloneElement(this.props.children, {logged: this.state.logged})}
<Footer />
</div>
);
}
checkLogin() {
Api.checkLogin().then((value) => {
this.setState({
logged: value.logged
})
});
}
}
render((
<Router history={browserHistory} onUpdate={() => window.scrollTo(0, 0)}>
<Route component={Flox} path={config.uri}>
<IndexRoute component={Home} />
<Route path=":category" component={Category} />
</Route>
</Router>
), document.querySelector('.flox'));