@shopgate/pwa-common-commerce
Version:
Commerce library for the Shopgate Connect PWA.
4 lines • 782 B
JavaScript
import appConfig from'@shopgate/pwa-common/helpers/config';import fetchProductReviews from"../actions/fetchProductReviews";import{REVIEW_PREVIEW_COUNT}from"../constants";import{shouldFetchReviews$}from"../streams";/**
* Review subscriptions.
* @param {Function} subscribe The subscribe function.
*/export default function product(subscribe){if(!appConfig.hasReviews){return;}subscribe(shouldFetchReviews$,function(_ref){var action=_ref.action,dispatch=_ref.dispatch;if(action.productData){var _action$productData2=action.productData,id=_action$productData2.id,baseProductId=_action$productData2.baseProductId;dispatch(fetchProductReviews(baseProductId||id,REVIEW_PREVIEW_COUNT));}if(action.review){dispatch(fetchProductReviews(action.review.productId,REVIEW_PREVIEW_COUNT));}});}