2017-03-23 16:27:59 +09:00
|
|
|
import { Components, registerComponent } from 'meteor/vulcan:core';
|
2017-05-19 14:42:43 -06:00
|
|
|
import React, { PureComponent } from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2017-01-25 13:58:02 +09:00
|
|
|
|
2017-05-19 14:42:43 -06:00
|
|
|
class CategoriesNode extends PureComponent {
|
2017-01-25 13:58:02 +09:00
|
|
|
|
|
|
|
renderCategory(category) {
|
|
|
|
return (
|
|
|
|
<Components.Category category={category} key={category._id} openModal={this.props.openModal} />
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
renderChildren(children) {
|
|
|
|
return (
|
|
|
|
<div className="categories-children">
|
|
|
|
{children.map(category => <CategoriesNode category={category} key={category._id} />)}
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
|
|
|
|
const category = this.props.category;
|
|
|
|
const children = this.props.category.childrenResults;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="categories-node">
|
|
|
|
{this.renderCategory(category)}
|
|
|
|
{children ? this.renderChildren(children) : null}
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
CategoriesNode.propTypes = {
|
2017-05-19 14:42:43 -06:00
|
|
|
category: PropTypes.object.isRequired, // the current category
|
2017-01-25 13:58:02 +09:00
|
|
|
};
|
|
|
|
|
|
|
|
registerComponent('CategoriesNode', CategoriesNode);
|