@shopgate/engage
Version:
Shopgate's ENGAGE library.
8 lines • 1.23 kB
JavaScript
import{connect}from'react-redux';import _fetchCategory from'@shopgate/pwa-common-commerce/category/actions/getCategory';import{getCategory}from'@shopgate/pwa-common-commerce/category/selectors';import{makeGetSubcategoriesByCategoryId,makeGetAreChildCategoriesFetching}from"./selectors";/**
* Creates the mapStateToProps connector function.
* @returns {Function}
*/var makeMapStateToProps=function makeMapStateToProps(){var getSubcategoriesByCategoryId=makeGetSubcategoriesByCategoryId();var getAreChildCategoriesFetching=makeGetAreChildCategoriesFetching();return function(state,_ref){var categoryId=_ref.categoryId;return{category:getCategory(state,{categoryId:categoryId}),subcategories:getSubcategoriesByCategoryId(state,{categoryId:categoryId}),subcategoriesFetching:getAreChildCategoriesFetching(state,{categoryId:categoryId})};};};/**
* Maps the contents of the state to the component props.
* @param {Function} dispatch The redux dispatch function.
* @return {Object} The extended component props.
*/var mapDispatchToProps=function mapDispatchToProps(dispatch){return{fetchCategory:function fetchCategory(id){return dispatch(_fetchCategory(id));}};};export default connect(makeMapStateToProps,mapDispatchToProps);