@shopgate/engage
Version:
Shopgate's ENGAGE library.
9 lines • 1.55 kB
JavaScript
function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import{connect}from'react-redux';import{makeGetProductMedia,makeGetProductFeaturedMedia,ITEM_PATH,MEDIA_TYPE_IMAGE,MEDIA_TYPE_VIDEO}from'@shopgate/engage/product';import{historyPush}from'@shopgate/pwa-common/actions/router';import{bin2hex}from'@shopgate/pwa-common/helpers/data';/**
* Creates the mapStateToProps connector function.
* @returns {Function}
*/var makeMapStateToProps=function makeMapStateToProps(){var getProductMedia=makeGetProductMedia();var getProductFeaturedMedia=makeGetProductFeaturedMedia();var types=[MEDIA_TYPE_VIDEO,MEDIA_TYPE_IMAGE];return function(state,props){return{media:getProductMedia(state,_extends({},props,{types:props.types||types})),featuredMedia:getProductFeaturedMedia(state,props)};};};/**
* Connects the dispatch function to a callable function in the props.
* @param {Function} dispatch The redux dispatch function.
* @param {Object} props The component props.
* @return {Object} The extended component props.
*/var mapDispatchToProps=function mapDispatchToProps(dispatch,props){return{navigate:function navigate(currentSlide){return dispatch(historyPush({pathname:"".concat(ITEM_PATH,"/").concat(bin2hex(props.productId),"/gallery/").concat(currentSlide)}));}};};export default connect(makeMapStateToProps,mapDispatchToProps);