deep subcategory solution

This commit is contained in:
egradanin
2019-01-16 21:00:14 +01:00
parent ae446d5333
commit 2945ca8b70
7 changed files with 75 additions and 73 deletions

View File

@@ -0,0 +1,30 @@
import React from "react";
import Select from "react-select";
import { subcategorywrapper } from "utils/subcategorywrapper";
import { hoc } from "utils/helpers";
class DeepCategoryWrapper extends React.Component {
handleOptionChange = selectedOption => {
const { depth, onSubCategoryChanged } = this.props;
onSubCategoryChanged({ selectedOption, depth });
};
render() {
const { options, depth, childrenComponents } = this.props;
const {
subcategory: { [depth]: deepSubCategory }
} = this.props;
return (
<div>
<Select
value={deepSubCategory || null}
onChange={this.handleOptionChange}
options={options}
/>
{hoc(deepSubCategory && deepSubCategory.value, childrenComponents)}
</div>
);
}
}
export default subcategorywrapper(DeepCategoryWrapper);