1
0
mirror of https://github.com/devfake/flox.git synced 2024-11-15 14:42:31 +01:00
flox/client/app/sites/category.js

56 lines
1.1 KiB
JavaScript
Raw Normal View History

2015-07-27 20:49:37 +02:00
import React from 'react';
import Box from '../partials/box';
import Api from '../api';
class Category extends React.Component {
state = {
category: {},
2015-07-28 20:50:39 +02:00
items: [],
2015-07-30 14:07:13 +02:00
currentLoaded: config.loadingItems,
moreLoaded: false,
moreToLoad: true
2015-07-27 20:49:37 +02:00
}
componentWillReceiveProps(nextProps) {
this.setState({
category: {},
2015-07-28 20:56:53 +02:00
items: [],
currentLoaded: config.loadingItems
2015-07-27 20:49:37 +02:00
});
this.loadCategoryItems(nextProps);
}
constructor(props) {
super(props);
this.loadCategoryItems(props);
}
// todo: fix icon load.
render() {
return (
2015-07-28 20:50:39 +02:00
2015-07-27 20:49:37 +02:00
<div>
2015-07-30 14:07:13 +02:00
{this.state.items.length
? <Box items={this.state.items} category={this.state.category} type="category" currentLoaded={this.state.currentLoaded} />
: <i className="icon-content-load"></i>}
2015-07-27 20:49:37 +02:00
</div>
2015-07-28 20:50:39 +02:00
2015-07-27 20:49:37 +02:00
);
}
loadCategoryItems(props) {
setTimeout(() => {
Api.categoryItems(props.params.category).then((value) => {
this.setState({
category: value.category,
items: value.items
});
});
}, 200);
}
}
export default Category;