UNPKG

@shopgate/pwa-common-commerce

Version:

Commerce library for the Shopgate Connect PWA.

13 lines 1.82 kB
import{main$}from'@shopgate/pwa-common/streams/main';import{routeWillEnter$,routeWillLeave$}from'@shopgate/pwa-common/streams/router';import{ITEM_PATH,RECEIVE_PRODUCT,RECEIVE_PRODUCT_CACHED}from'@shopgate/pwa-common-commerce/product/constants';import{REQUEST_SUBMIT_REVIEW,RECEIVE_SUBMIT_REVIEW,ERROR_SUBMIT_REVIEW,RESET_SUBMIT_REVIEW}from"../constants";export var reviewsWillEnter$=routeWillEnter$.filter(function(_ref){var action=_ref.action;return action.route.pattern==="".concat(ITEM_PATH,"/:productId/reviews");});export var reviewsWillLeave$=routeWillLeave$.filter(function(_ref2){var action=_ref2.action;return action.route.pattern==="".concat(ITEM_PATH,"/:productId/reviews");});/** * Gets triggered when the user tried to submit a review. * @type {Observable} */export var requestReviewSubmit$=main$.filter(function(_ref3){var action=_ref3.action;return action.type===REQUEST_SUBMIT_REVIEW;});/** * Gets triggered when the user tried to submit a review. * @type {Observable} */export var responseReviewSubmit$=main$.filter(function(_ref4){var action=_ref4.action;return[RECEIVE_SUBMIT_REVIEW,ERROR_SUBMIT_REVIEW,RESET_SUBMIT_REVIEW].includes(action.type);});/** * Gets triggered when the user submit was successful. * @type {Observable} */export var successReviewSubmit$=main$.filter(function(_ref5){var action=_ref5.action;return action.type===RECEIVE_SUBMIT_REVIEW;});/** * Gets triggered when the user submit was not successful. * @type {Observable} */export var errorReviewSubmit$=main$.filter(function(_ref6){var action=_ref6.action;return[ERROR_SUBMIT_REVIEW,RESET_SUBMIT_REVIEW].includes(action.type);});export var shouldFetchReviews$=main$.filter(function(_ref7){var action=_ref7.action;return action.type===RECEIVE_PRODUCT||action.type===RECEIVE_PRODUCT_CACHED;}).merge(successReviewSubmit$);