mirror of
https://github.com/vale981/Vulcan
synced 2025-03-10 12:36:39 -04:00
40 lines
970 B
React
40 lines
970 B
React
![]() |
import { Components, registerComponent } from 'meteor/nova:lib';
|
||
|
import React, { PropTypes, Component } from 'react';
|
||
|
|
||
|
class CategoriesNode extends Component {
|
||
|
|
||
|
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 = {
|
||
|
category: React.PropTypes.object.isRequired, // the current category
|
||
|
};
|
||
|
|
||
|
registerComponent('CategoriesNode', CategoriesNode);
|