@shopgate/pwa-common-commerce 7.30.0-alpha.7 → 7.30.0-alpha.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cart/action-creators/addCouponsToCart.js +9 -2
- package/cart/action-creators/addProductsToCart.js +9 -2
- package/cart/action-creators/deleteCouponsFromCart.js +9 -2
- package/cart/action-creators/deleteProductsFromCart.js +9 -2
- package/cart/action-creators/errorAddCouponsToCart.js +10 -2
- package/cart/action-creators/errorAddProductsToCart.js +10 -2
- package/cart/action-creators/errorCart.js +8 -2
- package/cart/action-creators/errorDeleteCouponsFromCart.js +10 -2
- package/cart/action-creators/errorDeleteProductsFromCart.js +10 -2
- package/cart/action-creators/errorUpdateProductsInCart.js +10 -2
- package/cart/action-creators/receiveCart.js +9 -2
- package/cart/action-creators/requestCart.js +8 -2
- package/cart/action-creators/setCartProductPendingCount.js +9 -2
- package/cart/action-creators/setCouponFieldError.js +9 -2
- package/cart/action-creators/setCouponFieldValue.js +9 -2
- package/cart/action-creators/setFulfillmentSlot.js +9 -2
- package/cart/action-creators/successAddCouponsToCart.js +10 -2
- package/cart/action-creators/successAddProductsToCart.js +8 -2
- package/cart/action-creators/successDeleteCouponsFromCart.js +8 -2
- package/cart/action-creators/successDeleteProductsFromCart.js +8 -2
- package/cart/action-creators/successUpdateProductsInCart.js +8 -2
- package/cart/action-creators/updateProductsInCart.js +9 -2
- package/cart/actions/addCouponsToCart.js +52 -8
- package/cart/actions/addProductsToCart.js +80 -11
- package/cart/actions/deleteCouponsFromCart.js +39 -6
- package/cart/actions/deleteProductsFromCart.js +38 -6
- package/cart/actions/fetchCart.js +52 -8
- package/cart/actions/updateProductsInCart.js +44 -6
- package/cart/constants/PipelineErrors.js +6 -1
- package/cart/constants/Pipelines.js +6 -1
- package/cart/constants/Portals.js +85 -1
- package/cart/constants/index.js +39 -2
- package/cart/helpers/config.js +47 -2
- package/cart/helpers/createPipelineErrorList.js +30 -4
- package/cart/helpers/fulfillmentSlots.js +37 -4
- package/cart/helpers/index.js +14 -3
- package/cart/helpers/quantity.js +23 -4
- package/cart/helpers/shipping.js +57 -2
- package/cart/helpers/tax.js +26 -2
- package/cart/index.js +25 -5
- package/cart/mock.js +130 -1
- package/cart/reducers/couponField.js +30 -2
- package/cart/reducers/data.js +98 -6
- package/cart/reducers/index.js +7 -1
- package/cart/selectors/index.js +181 -31
- package/cart/selectors/spec.js +189 -2
- package/cart/streams/index.js +176 -29
- package/cart/subscriptions/index.js +307 -30
- package/category/action-creators/errorCategory.js +10 -2
- package/category/action-creators/errorCategoryChildren.js +9 -2
- package/category/action-creators/errorRootCategories.js +8 -2
- package/category/action-creators/receiveCategory.js +12 -2
- package/category/action-creators/receiveCategoryChildren.js +10 -2
- package/category/action-creators/receiveRootCategories.js +9 -2
- package/category/action-creators/requestCategory.js +9 -2
- package/category/action-creators/requestCategoryChildren.js +9 -2
- package/category/action-creators/requestRootCategories.js +8 -2
- package/category/actions/fetchCategory.js +47 -5
- package/category/actions/fetchCategoryChildren.js +30 -2
- package/category/actions/fetchCategoryOrRootCategories.js +16 -2
- package/category/actions/fetchCategoryProducts.js +36 -2
- package/category/actions/fetchRootCategories.js +31 -2
- package/category/actions/getCategory.js +10 -2
- package/category/constants/Pipelines.js +3 -1
- package/category/constants/Portals.js +56 -3
- package/category/constants/index.js +17 -2
- package/category/helpers/index.js +27 -3
- package/category/index.js +19 -5
- package/category/mock.js +176 -1
- package/category/reducers/categoriesById.js +65 -3
- package/category/reducers/childrenByCategoryId.js +55 -4
- package/category/reducers/helpers/handleCategoryCollection.js +24 -3
- package/category/reducers/helpers/handleReceivedCategories.js +3 -1
- package/category/reducers/index.js +12 -2
- package/category/reducers/rootCategories.js +31 -2
- package/category/selectors/index.js +115 -16
- package/category/streams/index.js +82 -4
- package/category/subscriptions/index.js +96 -3
- package/checkout/action-creators/successCheckout.js +9 -2
- package/checkout/actions/fetchCheckoutUrl.js +28 -3
- package/checkout/constants/Pipelines.js +1 -1
- package/checkout/constants/index.js +3 -2
- package/checkout/index.js +11 -4
- package/checkout/selectors/index.js +7 -2
- package/checkout/streams/index.js +8 -2
- package/checkout/subscriptions/index.js +35 -6
- package/favorites/action-creators/index.js +206 -24
- package/favorites/actions/addFavorites.js +41 -3
- package/favorites/actions/addFavoritesList.js +27 -2
- package/favorites/actions/fetchFavoriteIds.js +49 -5
- package/favorites/actions/fetchFavorites.js +60 -5
- package/favorites/actions/fetchFavoritesList.js +47 -3
- package/favorites/actions/fetchFavoritesListsWithItems.js +32 -3
- package/favorites/actions/getFavorites.js +6 -2
- package/favorites/actions/removeFavorites.js +32 -3
- package/favorites/actions/removeFavoritesList.js +24 -2
- package/favorites/actions/toggleFavorites.js +68 -10
- package/favorites/actions/updateFavorites.js +39 -3
- package/favorites/actions/updateFavoritesList.js +26 -2
- package/favorites/constants/Pipelines.js +9 -1
- package/favorites/constants/Portals.js +32 -4
- package/favorites/constants/index.js +37 -5
- package/favorites/index.js +14 -4
- package/favorites/mock.js +89 -4
- package/favorites/reducers/index.js +7 -1
- package/favorites/reducers/lists.js +74 -2
- package/favorites/reducers/products.js +231 -24
- package/favorites/selectors/index.js +188 -24
- package/favorites/streams/index.js +135 -23
- package/favorites/streams/spec.js +517 -8
- package/favorites/subscriptions/index.js +260 -25
- package/favorites/subscriptions/spec.js +701 -28
- package/filter/action-creators/errorFilters.js +9 -2
- package/filter/action-creators/index.js +4 -1
- package/filter/action-creators/receiveFilters.js +10 -2
- package/filter/action-creators/requestFilters.js +9 -2
- package/filter/action-creators/updateFilters.js +8 -2
- package/filter/actions/fetchFilters.js +46 -3
- package/filter/actions/getFilters.js +6 -2
- package/filter/actions/helpers/buildFilterParams.js +34 -2
- package/filter/actions/helpers/buildRequestFilters.js +35 -2
- package/filter/actions/helpers/processFilters.js +10 -2
- package/filter/actions/helpers/processParams.js +26 -2
- package/filter/constants/Pipelines.js +1 -1
- package/filter/constants/Portals.js +39 -3
- package/filter/constants/index.js +8 -1
- package/filter/index.js +12 -4
- package/filter/reducers/helpers/enrichFilters.js +11 -3
- package/filter/reducers/index.js +5 -1
- package/filter/reducers/resultsByHash.js +43 -3
- package/filter/selectors/index.js +47 -6
- package/filter/streams/index.js +30 -1
- package/filter/subscriptions/index.js +34 -2
- package/market/constants/Portals.js +22 -4
- package/market/constants/index.js +2 -1
- package/market/helpers/showReturnPolicy.js +3 -1
- package/market/helpers/showTaxDisclaimer.js +3 -1
- package/market/index.js +6 -2
- package/orders/constants.js +2 -1
- package/package.json +3 -3
- package/product/action-creators/deleteProductsByIds.js +10 -2
- package/product/action-creators/errorProduct.js +10 -2
- package/product/action-creators/errorProductDescription.js +10 -2
- package/product/action-creators/errorProductImages.js +10 -2
- package/product/action-creators/errorProductMedia.js +10 -2
- package/product/action-creators/errorProductOptions.js +10 -2
- package/product/action-creators/errorProductProperties.js +10 -2
- package/product/action-creators/errorProductRelations.js +9 -2
- package/product/action-creators/errorProductShipping.js +10 -2
- package/product/action-creators/errorProductVariants.js +10 -2
- package/product/action-creators/errorProducts.js +9 -2
- package/product/action-creators/expireProductById.js +10 -2
- package/product/action-creators/expireProductData.js +11 -2
- package/product/action-creators/expireProductsByHash.js +9 -2
- package/product/action-creators/productNotAvailable.js +10 -2
- package/product/action-creators/provideProduct.js +9 -2
- package/product/action-creators/receiveProduct.js +10 -2
- package/product/action-creators/receiveProductCached.js +9 -2
- package/product/action-creators/receiveProductDescription.js +10 -2
- package/product/action-creators/receiveProductImages.js +10 -2
- package/product/action-creators/receiveProductMedia.js +10 -2
- package/product/action-creators/receiveProductOptions.js +10 -2
- package/product/action-creators/receiveProductProperties.js +10 -2
- package/product/action-creators/receiveProductRelations.js +12 -2
- package/product/action-creators/receiveProductShipping.js +10 -2
- package/product/action-creators/receiveProductVariants.js +10 -2
- package/product/action-creators/receiveProducts.js +16 -2
- package/product/action-creators/receiveProductsCached.js +9 -2
- package/product/action-creators/refreshExpiredPDPData.js +8 -2
- package/product/action-creators/requestProduct.js +10 -2
- package/product/action-creators/requestProductDescription.js +9 -2
- package/product/action-creators/requestProductImages.js +9 -2
- package/product/action-creators/requestProductMedia.js +9 -2
- package/product/action-creators/requestProductOptions.js +9 -2
- package/product/action-creators/requestProductProperties.js +9 -2
- package/product/action-creators/requestProductRelations.js +10 -2
- package/product/action-creators/requestProductShipping.js +9 -2
- package/product/action-creators/requestProductVariants.js +9 -2
- package/product/action-creators/requestProducts.js +9 -2
- package/product/action-creators/setProductId.js +9 -2
- package/product/action-creators/setProductQuantity.js +9 -2
- package/product/action-creators/setProductVariantId.js +9 -2
- package/product/actions/changeSortOrder.js +21 -2
- package/product/actions/fetchHighlightProducts.js +18 -2
- package/product/actions/fetchLiveshoppingProducts.js +14 -2
- package/product/actions/fetchProduct.js +52 -3
- package/product/actions/fetchProductDescription.js +30 -2
- package/product/actions/fetchProductImages.js +31 -2
- package/product/actions/fetchProductMedia.js +35 -2
- package/product/actions/fetchProductOptions.js +31 -2
- package/product/actions/fetchProductProperties.js +30 -2
- package/product/actions/fetchProductRelations.js +63 -2
- package/product/actions/fetchProductShipping.js +31 -2
- package/product/actions/fetchProductVariants.js +31 -2
- package/product/actions/fetchProducts.js +189 -17
- package/product/actions/fetchProductsById.js +68 -8
- package/product/actions/fetchProductsByQuery.js +102 -18
- package/product/actions/getHighlightProducts.js +6 -2
- package/product/actions/getLiveshoppingProducts.js +6 -2
- package/product/actions/getProduct.js +6 -2
- package/product/actions/getProductDescription.js +6 -2
- package/product/actions/getProductImages.js +6 -2
- package/product/actions/getProductOptions.js +6 -2
- package/product/actions/getProductProperties.js +6 -2
- package/product/actions/getProductRelations.js +6 -2
- package/product/actions/getProductShipping.js +6 -2
- package/product/actions/getProductVariants.js +6 -2
- package/product/actions/getProducts.js +6 -2
- package/product/actions/getProductsById.js +6 -2
- package/product/actions/getProductsByQuery.js +6 -2
- package/product/actions/processProductFlags.js +35 -3
- package/product/actions/updateMetadata.js +17 -2
- package/product/collections/ProductImageFormats.js +48 -8
- package/product/collections/index.js +1 -1
- package/product/constants/Pipelines.js +12 -1
- package/product/constants/Portals.js +200 -33
- package/product/constants/index.js +90 -18
- package/product/helpers/index.js +61 -8
- package/product/index.js +36 -6
- package/product/mock.js +1002 -2
- package/product/reducers/descriptionsByProductId.js +54 -5
- package/product/reducers/helpers/formatOptions.js +17 -2
- package/product/reducers/helpers/handleProductCollection.js +19 -2
- package/product/reducers/imagesByProductId.js +51 -4
- package/product/reducers/index.js +23 -1
- package/product/reducers/mediaByProductId.js +55 -3
- package/product/reducers/optionsByProductId.js +41 -2
- package/product/reducers/productRelationsByHash.js +43 -2
- package/product/reducers/productsById.js +122 -7
- package/product/reducers/propertiesByProductId.js +48 -2
- package/product/reducers/resultsByHash.js +125 -9
- package/product/reducers/shippingByProductId.js +37 -2
- package/product/reducers/variantsByProductId.js +56 -2
- package/product/selectors/options.js +90 -13
- package/product/selectors/page.js +62 -13
- package/product/selectors/price.js +81 -18
- package/product/selectors/product.js +549 -59
- package/product/selectors/product.mock.js +327 -12
- package/product/selectors/relations.js +35 -5
- package/product/selectors/variants.js +91 -15
- package/product/streams/index.js +167 -13
- package/product/subscriptions/index.js +210 -4
- package/reviews/action-creators/errorProductReviews.js +9 -2
- package/reviews/action-creators/errorReviews.js +9 -2
- package/reviews/action-creators/errorSubmitReview.js +9 -2
- package/reviews/action-creators/errorUserReview.js +9 -2
- package/reviews/action-creators/flushUserReview.js +8 -2
- package/reviews/action-creators/receiveProductReviews.js +11 -2
- package/reviews/action-creators/receiveReviews.js +12 -2
- package/reviews/action-creators/receiveSubmitReview.js +9 -2
- package/reviews/action-creators/receiveUserReview.js +10 -2
- package/reviews/action-creators/requestProductReviews.js +10 -2
- package/reviews/action-creators/requestReviews.js +9 -2
- package/reviews/action-creators/requestSubmitReview.js +9 -2
- package/reviews/action-creators/requestUserReview.js +9 -2
- package/reviews/action-creators/resetSubmittedReview.js +9 -2
- package/reviews/action-creators/spec.js +40 -1
- package/reviews/actions/fetchProductReviews.js +37 -2
- package/reviews/actions/fetchReviews.js +38 -2
- package/reviews/actions/fetchUserReview.js +31 -2
- package/reviews/actions/flushUserReview.js +5 -1
- package/reviews/actions/getProductReviews.js +6 -2
- package/reviews/actions/getUserReview.js +6 -2
- package/reviews/actions/spec.js +241 -4
- package/reviews/actions/submitReview.js +63 -3
- package/reviews/constants/Pipelines.js +4 -1
- package/reviews/constants/Portals.js +4 -1
- package/reviews/constants/index.js +26 -7
- package/reviews/index.js +15 -4
- package/reviews/mock.js +172 -11
- package/reviews/reducers/index.js +11 -1
- package/reviews/reducers/mock.js +14 -2
- package/reviews/reducers/reviewsByHash.js +52 -6
- package/reviews/reducers/reviewsById.js +27 -2
- package/reviews/reducers/reviewsByProductId.js +47 -2
- package/reviews/reducers/spec.js +211 -2
- package/reviews/reducers/userReviewsByProductId.js +68 -2
- package/reviews/selectors/index.js +123 -19
- package/reviews/selectors/mock.js +100 -1
- package/reviews/selectors/spec.js +100 -1
- package/reviews/streams/index.js +37 -5
- package/reviews/streams/spec.js +25 -1
- package/reviews/subscriptions/index.js +27 -2
- package/scanner/action-creators/errorHandleScanner.js +11 -2
- package/scanner/action-creators/scannerFinished.js +11 -2
- package/scanner/action-creators/startScanner.js +8 -2
- package/scanner/action-creators/successHandleScanner.js +11 -2
- package/scanner/actions/handleBarCode.js +22 -2
- package/scanner/actions/handleNoResults.js +23 -2
- package/scanner/actions/handleQrCode.js +116 -6
- package/scanner/actions/handleSearch.js +33 -2
- package/scanner/constants/Portals.js +22 -1
- package/scanner/constants/index.js +17 -1
- package/scanner/helpers/index.js +115 -5
- package/scanner/index.js +19 -5
- package/scanner/streams/index.js +36 -1
- package/scanner/subscriptions/index.js +78 -8
- package/search/action-creators/errorSearchResults.js +10 -2
- package/search/action-creators/receiveSearchResults.js +11 -2
- package/search/action-creators/receiveSearchSuggestions.js +10 -2
- package/search/action-creators/requestSearchResults.js +10 -2
- package/search/action-creators/requestSearchSuggestions.js +9 -2
- package/search/actions/fetchSearchResults.js +66 -8
- package/search/actions/fetchSearchSuggestions.js +36 -2
- package/search/constants/Pipelines.js +1 -1
- package/search/constants/Portals.js +9 -2
- package/search/constants/index.js +10 -2
- package/search/helpers/index.js +5 -2
- package/search/helpers/removeHighlightingPlaceholders.js +4 -1
- package/search/helpers/spec.js +19 -1
- package/search/index.js +17 -5
- package/search/reducers/index.js +38 -2
- package/search/selectors/index.js +23 -4
- package/search/streams/index.js +51 -3
- package/search/subscriptions/index.js +132 -5
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
import{ADD_COUPONS_TO_CART}from"../constants"
|
|
1
|
+
import { ADD_COUPONS_TO_CART } from "../constants";
|
|
2
|
+
|
|
3
|
+
/**
|
|
2
4
|
* Creates the dispatched ADD_COUPONS_TO_CART action object.
|
|
3
5
|
* @param {Array} couponIds The coupon ids.
|
|
4
6
|
* @returns {Object} The dispatched action object.
|
|
5
|
-
*/
|
|
7
|
+
*/
|
|
8
|
+
const addCouponsToCart = couponIds => ({
|
|
9
|
+
type: ADD_COUPONS_TO_CART,
|
|
10
|
+
couponIds
|
|
11
|
+
});
|
|
12
|
+
export default addCouponsToCart;
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
import{ADD_PRODUCTS_TO_CART}from"../constants"
|
|
1
|
+
import { ADD_PRODUCTS_TO_CART } from "../constants";
|
|
2
|
+
|
|
3
|
+
/**
|
|
2
4
|
* Creates the dispatched ADD_PRODUCTS_TO_CART action object.
|
|
3
5
|
* @param {Array} products The products to be added.
|
|
4
6
|
* @returns {Object} The dispatched action object.
|
|
5
|
-
*/
|
|
7
|
+
*/
|
|
8
|
+
const addProductsToCart = products => ({
|
|
9
|
+
type: ADD_PRODUCTS_TO_CART,
|
|
10
|
+
products
|
|
11
|
+
});
|
|
12
|
+
export default addProductsToCart;
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
import{DELETE_COUPONS_FROM_CART}from"../constants"
|
|
1
|
+
import { DELETE_COUPONS_FROM_CART } from "../constants";
|
|
2
|
+
|
|
3
|
+
/**
|
|
2
4
|
* Creates the dispatched DELETE_COUPONS_FROM_CART action object.
|
|
3
5
|
* @param {Array} couponIds The coupon ids.
|
|
4
6
|
* @returns {Object} The dispatched action object.
|
|
5
|
-
*/
|
|
7
|
+
*/
|
|
8
|
+
const deleteCouponsFromCart = couponIds => ({
|
|
9
|
+
type: DELETE_COUPONS_FROM_CART,
|
|
10
|
+
couponIds
|
|
11
|
+
});
|
|
12
|
+
export default deleteCouponsFromCart;
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
import{DELETE_PRODUCTS_FROM_CART}from"../constants"
|
|
1
|
+
import { DELETE_PRODUCTS_FROM_CART } from "../constants";
|
|
2
|
+
|
|
3
|
+
/**
|
|
2
4
|
* Creates the dispatched DELETE_PRODUCTS_FROM_CART action object.
|
|
3
5
|
* @param {Array} cartItemIds The cart items to be deleted.
|
|
4
6
|
* @returns {Object} The dispatched action object.
|
|
5
|
-
*/
|
|
7
|
+
*/
|
|
8
|
+
const deleteProductsFromCart = cartItemIds => ({
|
|
9
|
+
type: DELETE_PRODUCTS_FROM_CART,
|
|
10
|
+
cartItemIds
|
|
11
|
+
});
|
|
12
|
+
export default deleteProductsFromCart;
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
import{ERROR_ADD_COUPONS_TO_CART}from"../constants"
|
|
1
|
+
import { ERROR_ADD_COUPONS_TO_CART } from "../constants";
|
|
2
|
+
|
|
3
|
+
/**
|
|
2
4
|
* Creates the dispatched ERROR_ADD_COUPONS_TO_CART action object.
|
|
3
5
|
* @param {Array} couponsIds The coupon ids from the failed ADD_COUPONS_TO_CART action.
|
|
4
6
|
* @param {PipelineErrorElement[]} [errors] A list of errors messages for the coupons.
|
|
5
7
|
* @returns {Object} The dispatched action object.
|
|
6
|
-
*/
|
|
8
|
+
*/
|
|
9
|
+
const errorAddCouponsToCart = (couponsIds, errors = []) => ({
|
|
10
|
+
type: ERROR_ADD_COUPONS_TO_CART,
|
|
11
|
+
couponsIds,
|
|
12
|
+
errors
|
|
13
|
+
});
|
|
14
|
+
export default errorAddCouponsToCart;
|
|
@@ -1,7 +1,15 @@
|
|
|
1
|
-
import{ERROR_ADD_PRODUCTS_TO_CART}from"../constants"
|
|
1
|
+
import { ERROR_ADD_PRODUCTS_TO_CART } from "../constants";
|
|
2
|
+
|
|
3
|
+
/**
|
|
2
4
|
* Creates the dispatched ERROR_ADD_PRODUCTS_TO_CART action object.
|
|
3
5
|
* @param {Array} products The products that where supposed to be added within
|
|
4
6
|
* an ADD_PRODUCTS_TO_CART action.
|
|
5
7
|
* @param {PipelineErrorElement[]} [errors] A list of errors messages for the products.
|
|
6
8
|
* @returns {Object} The dispatched action object.
|
|
7
|
-
*/
|
|
9
|
+
*/
|
|
10
|
+
const errorAddProductsToCart = (products, errors = []) => ({
|
|
11
|
+
type: ERROR_ADD_PRODUCTS_TO_CART,
|
|
12
|
+
products,
|
|
13
|
+
errors
|
|
14
|
+
});
|
|
15
|
+
export default errorAddProductsToCart;
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import{ERROR_CART}from"../constants"
|
|
1
|
+
import { ERROR_CART } from "../constants";
|
|
2
|
+
|
|
3
|
+
/**
|
|
2
4
|
* Creates the dispatched ERROR_CART action object.
|
|
3
5
|
* @return {Object} The ERROR_CART action.
|
|
4
|
-
*/
|
|
6
|
+
*/
|
|
7
|
+
const errorCart = () => ({
|
|
8
|
+
type: ERROR_CART
|
|
9
|
+
});
|
|
10
|
+
export default errorCart;
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
import{ERROR_DELETE_COUPONS_FROM_CART}from"../constants"
|
|
1
|
+
import { ERROR_DELETE_COUPONS_FROM_CART } from "../constants";
|
|
2
|
+
|
|
3
|
+
/**
|
|
2
4
|
* Creates the dispatched ERROR_DELETE_COUPONS_FROM_CART action object.
|
|
3
5
|
* @param {string[]} couponIds The coupon ids from the failed DELETE_COUPONS_FROM_CART action.
|
|
4
6
|
* @param {PipelineErrorElement[]} [errors] A list of errors messages for the coupons.
|
|
5
7
|
* @returns {Object} The dispatched action object.
|
|
6
|
-
*/
|
|
8
|
+
*/
|
|
9
|
+
const errorDeleteCouponsFromCart = (couponIds, errors = []) => ({
|
|
10
|
+
type: ERROR_DELETE_COUPONS_FROM_CART,
|
|
11
|
+
couponIds,
|
|
12
|
+
errors
|
|
13
|
+
});
|
|
14
|
+
export default errorDeleteCouponsFromCart;
|
|
@@ -1,7 +1,15 @@
|
|
|
1
|
-
import{ERROR_DELETE_PRODUCTS_FROM_CART}from"../constants"
|
|
1
|
+
import { ERROR_DELETE_PRODUCTS_FROM_CART } from "../constants";
|
|
2
|
+
|
|
3
|
+
/**
|
|
2
4
|
* Creates the dispatched ERROR_DELETE_PRODUCTS_FROM_CART action object.
|
|
3
5
|
* @param {Array} products The products that where supposed to be deleted within
|
|
4
6
|
* an DELETE_PRODUCTS_FROM_CART action.
|
|
5
7
|
* @param {PipelineErrorElement[]} [errors] A list of errors messages for the products.
|
|
6
8
|
* @returns {Object} The dispatched action object.
|
|
7
|
-
*/
|
|
9
|
+
*/
|
|
10
|
+
const errorDeleteProductsFromCart = (products, errors = []) => ({
|
|
11
|
+
type: ERROR_DELETE_PRODUCTS_FROM_CART,
|
|
12
|
+
products,
|
|
13
|
+
errors
|
|
14
|
+
});
|
|
15
|
+
export default errorDeleteProductsFromCart;
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
import{ERROR_UPDATE_PRODUCTS_IN_CART}from"../constants"
|
|
1
|
+
import { ERROR_UPDATE_PRODUCTS_IN_CART } from "../constants";
|
|
2
|
+
|
|
3
|
+
/**
|
|
2
4
|
* Creates the dispatched ERROR_UPDATE_PRODUCTS_IN_CART action object.
|
|
3
5
|
* @param {Array} updateData The update data from the failed UPDATE_PRODUCTS_IN_CART action.
|
|
4
6
|
* @param {PipelineErrorElement[]} [errors] A list of errors messages for the products.
|
|
5
7
|
* @returns {Object} The dispatched action object.
|
|
6
|
-
*/
|
|
8
|
+
*/
|
|
9
|
+
const errorUpdateProductsInCart = (updateData, errors = []) => ({
|
|
10
|
+
type: ERROR_UPDATE_PRODUCTS_IN_CART,
|
|
11
|
+
updateData,
|
|
12
|
+
errors
|
|
13
|
+
});
|
|
14
|
+
export default errorUpdateProductsInCart;
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
import{RECEIVE_CART}from"../constants"
|
|
1
|
+
import { RECEIVE_CART } from "../constants";
|
|
2
|
+
|
|
3
|
+
/**
|
|
2
4
|
* Creates the dispatched RECEIVE_CART action object
|
|
3
5
|
* @param {Object} cart The cart data
|
|
4
6
|
* @return {Object} The RECEIVE_CART action.
|
|
5
|
-
*/
|
|
7
|
+
*/
|
|
8
|
+
const receiveCart = cart => ({
|
|
9
|
+
type: RECEIVE_CART,
|
|
10
|
+
cart
|
|
11
|
+
});
|
|
12
|
+
export default receiveCart;
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import{REQUEST_CART}from"../constants"
|
|
1
|
+
import { REQUEST_CART } from "../constants";
|
|
2
|
+
|
|
3
|
+
/**
|
|
2
4
|
* Creates the dispatched REQUEST_CART action object.
|
|
3
5
|
* @return {Object} The REQUEST_CART action.
|
|
4
|
-
*/
|
|
6
|
+
*/
|
|
7
|
+
const requestCart = () => ({
|
|
8
|
+
type: REQUEST_CART
|
|
9
|
+
});
|
|
10
|
+
export default requestCart;
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
import{SET_CART_PENDING_PRODUCT_COUNT}from"../constants"
|
|
1
|
+
import { SET_CART_PENDING_PRODUCT_COUNT } from "../constants";
|
|
2
|
+
|
|
3
|
+
/**
|
|
2
4
|
* Creates the dispatched SET_CART_PENDING_PRODUCT_COUNT object.
|
|
3
5
|
* @param {number} count The cart product count.
|
|
4
6
|
* @return {Object} The SET_CART_PENDING_PRODUCT_COUNT action.
|
|
5
|
-
*/
|
|
7
|
+
*/
|
|
8
|
+
const setCartProductPendingCount = count => ({
|
|
9
|
+
type: SET_CART_PENDING_PRODUCT_COUNT,
|
|
10
|
+
count
|
|
11
|
+
});
|
|
12
|
+
export default setCartProductPendingCount;
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
import{SET_COUPON_FIELD_ERROR}from"../constants"
|
|
1
|
+
import { SET_COUPON_FIELD_ERROR } from "../constants";
|
|
2
|
+
|
|
3
|
+
/**
|
|
2
4
|
* Creates the dispatched SET_COUPON_FIELD_ERROR action object.
|
|
3
5
|
* @param {string} message The error message
|
|
4
6
|
* @returns {Object} The dispatched action object.
|
|
5
|
-
*/
|
|
7
|
+
*/
|
|
8
|
+
const setCouponFieldError = (message = '') => ({
|
|
9
|
+
type: SET_COUPON_FIELD_ERROR,
|
|
10
|
+
message
|
|
11
|
+
});
|
|
12
|
+
export default setCouponFieldError;
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
import{SET_COUPON_FIELD_VALUE}from"../constants"
|
|
1
|
+
import { SET_COUPON_FIELD_VALUE } from "../constants";
|
|
2
|
+
|
|
3
|
+
/**
|
|
2
4
|
* Creates the dispatched SET_COUPON_FIELD_VALUE action object.
|
|
3
5
|
* @param {string} value Value
|
|
4
6
|
* @returns {Object} The dispatched action object.
|
|
5
|
-
*/
|
|
7
|
+
*/
|
|
8
|
+
const setCouponFieldValue = (value = '') => ({
|
|
9
|
+
type: SET_COUPON_FIELD_VALUE,
|
|
10
|
+
value
|
|
11
|
+
});
|
|
12
|
+
export default setCouponFieldValue;
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
import{SET_FULFILLMENT_SLOT}from"../constants"
|
|
1
|
+
import { SET_FULFILLMENT_SLOT } from "../constants";
|
|
2
|
+
|
|
3
|
+
/**
|
|
2
4
|
* Creates the dispatched DELETE_COUPONS_FROM_CART action object.
|
|
3
5
|
* @param {Object} fulfillmentSlot Fulfillment slot.
|
|
4
6
|
* @returns {Object} The dispatched action object.
|
|
5
|
-
*/
|
|
7
|
+
*/
|
|
8
|
+
const setFulfillmentSlot = fulfillmentSlot => ({
|
|
9
|
+
type: SET_FULFILLMENT_SLOT,
|
|
10
|
+
fulfillmentSlot
|
|
11
|
+
});
|
|
12
|
+
export default setFulfillmentSlot;
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
import{SUCCESS_ADD_COUPONS_TO_CART}from"../constants"
|
|
1
|
+
import { SUCCESS_ADD_COUPONS_TO_CART } from "../constants";
|
|
2
|
+
|
|
3
|
+
/**
|
|
2
4
|
* Creates the dispatched SUCCESS_ADD_COUPONS_TO_CART action object.
|
|
3
5
|
* @param {Array} couponsIds The coupon ids from the successful ADD_COUPONS_TO_CART action.
|
|
4
6
|
* @param {boolean} [userInteracted=true] Was the action dispatched due to a user interaction
|
|
5
7
|
* @returns {Object} The dispatched action object.
|
|
6
|
-
*/
|
|
8
|
+
*/
|
|
9
|
+
const successAddCouponsToCart = (couponsIds, userInteracted = true) => ({
|
|
10
|
+
type: SUCCESS_ADD_COUPONS_TO_CART,
|
|
11
|
+
couponsIds,
|
|
12
|
+
userInteracted
|
|
13
|
+
});
|
|
14
|
+
export default successAddCouponsToCart;
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import{SUCCESS_ADD_PRODUCTS_TO_CART}from"../constants"
|
|
1
|
+
import { SUCCESS_ADD_PRODUCTS_TO_CART } from "../constants";
|
|
2
|
+
|
|
3
|
+
/**
|
|
2
4
|
* Creates the dispatched SUCCESS_ADD_PRODUCTS_TO_CART action object.
|
|
3
5
|
* @returns {Object} The dispatched action object.
|
|
4
|
-
*/
|
|
6
|
+
*/
|
|
7
|
+
const successAddProductsToCart = () => ({
|
|
8
|
+
type: SUCCESS_ADD_PRODUCTS_TO_CART
|
|
9
|
+
});
|
|
10
|
+
export default successAddProductsToCart;
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import{SUCCESS_DELETE_COUPONS_FROM_CART}from"../constants"
|
|
1
|
+
import { SUCCESS_DELETE_COUPONS_FROM_CART } from "../constants";
|
|
2
|
+
|
|
3
|
+
/**
|
|
2
4
|
* Creates the dispatched SUCCESS_DELETE_COUPONS_FROM_CART action object.
|
|
3
5
|
* @returns {Object} The dispatched action object.
|
|
4
|
-
*/
|
|
6
|
+
*/
|
|
7
|
+
const successDeleteCouponsFromCart = () => ({
|
|
8
|
+
type: SUCCESS_DELETE_COUPONS_FROM_CART
|
|
9
|
+
});
|
|
10
|
+
export default successDeleteCouponsFromCart;
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import{SUCCESS_DELETE_PRODUCTS_FROM_CART}from"../constants"
|
|
1
|
+
import { SUCCESS_DELETE_PRODUCTS_FROM_CART } from "../constants";
|
|
2
|
+
|
|
3
|
+
/**
|
|
2
4
|
* Creates the dispatched SUCCESS_DELETE_PRODUCTS_FROM_CART action object.
|
|
3
5
|
* @returns {Object} The dispatched action object.
|
|
4
|
-
*/
|
|
6
|
+
*/
|
|
7
|
+
const successDeleteProductsFromCart = () => ({
|
|
8
|
+
type: SUCCESS_DELETE_PRODUCTS_FROM_CART
|
|
9
|
+
});
|
|
10
|
+
export default successDeleteProductsFromCart;
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import{SUCCESS_UPDATE_PRODUCTS_IN_CART}from"../constants"
|
|
1
|
+
import { SUCCESS_UPDATE_PRODUCTS_IN_CART } from "../constants";
|
|
2
|
+
|
|
3
|
+
/**
|
|
2
4
|
* Creates the dispatched SUCCESS_UPDATE_PRODUCTS_IN_CART action object.
|
|
3
5
|
* @returns {Object} The dispatched action object.
|
|
4
|
-
*/
|
|
6
|
+
*/
|
|
7
|
+
const successUpdateProductsInCart = () => ({
|
|
8
|
+
type: SUCCESS_UPDATE_PRODUCTS_IN_CART
|
|
9
|
+
});
|
|
10
|
+
export default successUpdateProductsInCart;
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
import{UPDATE_PRODUCTS_IN_CART}from"../constants"
|
|
1
|
+
import { UPDATE_PRODUCTS_IN_CART } from "../constants";
|
|
2
|
+
|
|
3
|
+
/**
|
|
2
4
|
* Creates the dispatched UPDATE_PRODUCTS_IN_CART action object.
|
|
3
5
|
* @param {Array} updateData The update data.
|
|
4
6
|
* @returns {Object} The dispatched action object.
|
|
5
|
-
*/
|
|
7
|
+
*/
|
|
8
|
+
const updateProductsInCart = updateData => ({
|
|
9
|
+
type: UPDATE_PRODUCTS_IN_CART,
|
|
10
|
+
updateData
|
|
11
|
+
});
|
|
12
|
+
export default updateProductsInCart;
|
|
@@ -1,12 +1,56 @@
|
|
|
1
|
-
|
|
1
|
+
import { PipelineRequest, PROCESS_SEQUENTIAL } from '@shopgate/pwa-core';
|
|
2
|
+
import { mutable } from '@shopgate/pwa-common/helpers/redux';
|
|
3
|
+
import { errorBehavior } from '@shopgate/engage/core';
|
|
4
|
+
import { SHOPGATE_CART_ADD_COUPONS } from "../constants/Pipelines";
|
|
5
|
+
import createPipelineErrorList from "../helpers/createPipelineErrorList";
|
|
6
|
+
import { ECART } from "../constants/PipelineErrors";
|
|
7
|
+
import addCoupons from "../action-creators/addCouponsToCart";
|
|
8
|
+
import errorAddCouponsToCart from "../action-creators/errorAddCouponsToCart";
|
|
9
|
+
import successAddCouponsToCart from "../action-creators/successAddCouponsToCart";
|
|
10
|
+
import { messagesHaveErrors } from "../helpers";
|
|
11
|
+
import setCouponFieldError from "../action-creators/setCouponFieldError";
|
|
12
|
+
import { MESSAGE_TYPE_ERROR } from "../constants";
|
|
13
|
+
|
|
14
|
+
/**
|
|
2
15
|
* Adds coupons to the cart. Returns a Promise because a component waits for this action to finish.
|
|
3
16
|
* @param {string[]} couponIds The IDs of the coupons that shall be added to the cart.
|
|
4
17
|
* @param {boolean} [userInteracted=true] Was the action dispatched due to a user interaction
|
|
5
18
|
* @return {Function} A redux thunk.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
19
|
+
*/
|
|
20
|
+
function addCouponsToCart(couponIds, userInteracted = true) {
|
|
21
|
+
return dispatch => {
|
|
22
|
+
dispatch(addCoupons(couponIds));
|
|
23
|
+
const request = new PipelineRequest(SHOPGATE_CART_ADD_COUPONS).setInput({
|
|
24
|
+
couponCodes: couponIds
|
|
25
|
+
}).setResponseProcessed(PROCESS_SEQUENTIAL).setRetries(0).setErrorBlacklist(ECART).setResponseBehavior({
|
|
26
|
+
error: userInteracted ? errorBehavior.dispatchAction(message => setCouponFieldError(message)) : errorBehavior.toast()
|
|
27
|
+
}).dispatch();
|
|
28
|
+
request.then(result => {
|
|
29
|
+
/**
|
|
30
|
+
* @deprecated: The property "messages" is not supposed to be part of the pipeline response.
|
|
31
|
+
* Specification demands errors to be returned as response object with an "error" property.
|
|
32
|
+
* This code snippet needs to be removed after fixing the `@shopgate/legacy-cart` extension.
|
|
33
|
+
*/
|
|
34
|
+
if (result.messages && messagesHaveErrors(result.messages)) {
|
|
35
|
+
// Simulate a pipeline response error with a proper ECART error.
|
|
36
|
+
const errors = result.messages.filter(msg => msg.type === MESSAGE_TYPE_ERROR);
|
|
37
|
+
const error = {
|
|
38
|
+
...errors[0],
|
|
39
|
+
code: ECART,
|
|
40
|
+
message: '',
|
|
41
|
+
// Irrelevant in this case
|
|
42
|
+
errors
|
|
43
|
+
};
|
|
44
|
+
dispatch(errorAddCouponsToCart(couponIds, createPipelineErrorList(SHOPGATE_CART_ADD_COUPONS, error)));
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
dispatch(successAddCouponsToCart(couponIds, userInteracted));
|
|
48
|
+
}).catch(error => {
|
|
49
|
+
dispatch(errorAddCouponsToCart(couponIds, createPipelineErrorList(SHOPGATE_CART_ADD_COUPONS, error)));
|
|
50
|
+
});
|
|
51
|
+
return request;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** @mixes {MutableFunction} */
|
|
56
|
+
export default mutable(addCouponsToCart);
|
|
@@ -1,14 +1,83 @@
|
|
|
1
|
-
import
|
|
1
|
+
import PipelineRequest from '@shopgate/pwa-core/classes/PipelineRequest';
|
|
2
|
+
import { PROCESS_SEQUENTIAL } from '@shopgate/pwa-core/constants/ProcessTypes';
|
|
3
|
+
import { mutable } from '@shopgate/pwa-common/helpers/redux';
|
|
4
|
+
import { SHOPGATE_CART_ADD_PRODUCTS } from "../constants/Pipelines";
|
|
5
|
+
import createPipelineErrorList from "../helpers/createPipelineErrorList";
|
|
6
|
+
import { ECART } from "../constants/PipelineErrors";
|
|
7
|
+
import addProductsToCart from "../action-creators/addProductsToCart";
|
|
8
|
+
import successAddProductsToCart from "../action-creators/successAddProductsToCart";
|
|
9
|
+
import errorAddProductsToCart from "../action-creators/errorAddProductsToCart";
|
|
10
|
+
import setCartProductPendingCount from "../action-creators/setCartProductPendingCount";
|
|
11
|
+
import { getProductPendingCount, getAddToCartMetadata, getCartItems } from "../selectors";
|
|
12
|
+
import { getProduct } from "../../product/selectors/product";
|
|
13
|
+
import { messagesHaveErrors, createErrorMessageList } from "../helpers";
|
|
14
|
+
import { getDisplayedProductQuantity } from "../helpers/quantity";
|
|
15
|
+
import { handleFulfillmentSlots } from "../helpers/fulfillmentSlots";
|
|
16
|
+
|
|
17
|
+
/**
|
|
2
18
|
* Adds products to the cart.
|
|
3
19
|
* @param {Array} data The options for the products to be added.
|
|
4
20
|
* @return {Function} A redux thunk.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
21
|
+
*/
|
|
22
|
+
function addToCart(data) {
|
|
23
|
+
return async (dispatch, getState) => {
|
|
24
|
+
const state = getState();
|
|
25
|
+
const preCartItems = getCartItems(state);
|
|
26
|
+
const pendingProductCount = getProductPendingCount(state);
|
|
27
|
+
let quantity = 0;
|
|
28
|
+
let products = data.map(product => {
|
|
29
|
+
const productData = getProduct(state, {
|
|
30
|
+
productId: product.productId
|
|
31
|
+
}) || {};
|
|
32
|
+
|
|
33
|
+
// Count quantity for pending count.
|
|
34
|
+
quantity += getDisplayedProductQuantity({
|
|
35
|
+
...product,
|
|
36
|
+
product: productData
|
|
37
|
+
}, preCartItems);
|
|
38
|
+
|
|
39
|
+
// Restructure into a productId and a variantId (only productId if not adding a variant)
|
|
40
|
+
const productId = productData.baseProductId || product.productId;
|
|
41
|
+
const variantId = productData.baseProductId ? productData.id : undefined;
|
|
42
|
+
const metadata = getAddToCartMetadata(state, {
|
|
43
|
+
productId,
|
|
44
|
+
variantId
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
// Return the current product if it already had metadata, otherwise add some, if any available
|
|
48
|
+
return product.metadata && product || {
|
|
49
|
+
...product,
|
|
50
|
+
...(metadata && {
|
|
51
|
+
metadata
|
|
52
|
+
})
|
|
53
|
+
};
|
|
54
|
+
});
|
|
55
|
+
products = await handleFulfillmentSlots(state, products);
|
|
56
|
+
|
|
57
|
+
// Dispatch pipeline request.
|
|
58
|
+
dispatch(addProductsToCart(products));
|
|
59
|
+
dispatch(setCartProductPendingCount(pendingProductCount + quantity));
|
|
60
|
+
const request = new PipelineRequest(SHOPGATE_CART_ADD_PRODUCTS).setInput({
|
|
61
|
+
products
|
|
62
|
+
}).setResponseProcessed(PROCESS_SEQUENTIAL).setRetries(0).setErrorBlacklist(ECART).dispatch();
|
|
63
|
+
request.then(result => {
|
|
64
|
+
if (result.messages && messagesHaveErrors(result.messages)) {
|
|
65
|
+
/**
|
|
66
|
+
* @deprecated: The property "messages" is not supposed to be part of the
|
|
67
|
+
* pipeline response. Specification demands errors to be returned as response
|
|
68
|
+
* object with an "error" property. This code snippet needs to be removed after
|
|
69
|
+
* fixing the `@shopgate/legacy-cart` extension.
|
|
70
|
+
*/
|
|
71
|
+
dispatch(errorAddProductsToCart(products, createErrorMessageList(SHOPGATE_CART_ADD_PRODUCTS, result.messages)));
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
dispatch(successAddProductsToCart());
|
|
75
|
+
}).catch(error => {
|
|
76
|
+
dispatch(errorAddProductsToCart(products, createPipelineErrorList(SHOPGATE_CART_ADD_PRODUCTS, error)));
|
|
77
|
+
});
|
|
78
|
+
return request;
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** @mixes {MutableFunction} */
|
|
83
|
+
export default mutable(addToCart);
|
|
@@ -1,9 +1,42 @@
|
|
|
1
|
-
import PipelineRequest from'@shopgate/pwa-core/classes/PipelineRequest';
|
|
1
|
+
import PipelineRequest from '@shopgate/pwa-core/classes/PipelineRequest';
|
|
2
|
+
import { PROCESS_SEQUENTIAL } from '@shopgate/pwa-core/constants/ProcessTypes';
|
|
3
|
+
import { mutable } from '@shopgate/pwa-common/helpers/redux';
|
|
4
|
+
import { SHOPGATE_CART_DELETE_COUPONS } from "../constants/Pipelines";
|
|
5
|
+
import createPipelineErrorList from "../helpers/createPipelineErrorList";
|
|
6
|
+
import { ECART } from "../constants/PipelineErrors";
|
|
7
|
+
import deleteCoupons from "../action-creators/deleteCouponsFromCart";
|
|
8
|
+
import errorDeleteCouponsFromCart from "../action-creators/errorDeleteCouponsFromCart";
|
|
9
|
+
import successDeleteCouponsFromCart from "../action-creators/successDeleteCouponsFromCart";
|
|
10
|
+
import { messagesHaveErrors, createErrorMessageList } from "../helpers";
|
|
11
|
+
|
|
12
|
+
/**
|
|
2
13
|
* Deletes coupons from the cart.
|
|
3
14
|
* @param {string[]} couponIds The IDs of the coupons that shall be deleted from the cart.
|
|
4
15
|
* @return {Function} A redux thunk.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
16
|
+
*/
|
|
17
|
+
function deleteCouponsFromCart(couponIds) {
|
|
18
|
+
return dispatch => {
|
|
19
|
+
dispatch(deleteCoupons(couponIds));
|
|
20
|
+
const request = new PipelineRequest(SHOPGATE_CART_DELETE_COUPONS).setInput({
|
|
21
|
+
couponCodes: couponIds
|
|
22
|
+
}).setResponseProcessed(PROCESS_SEQUENTIAL).setErrorBlacklist(ECART).dispatch();
|
|
23
|
+
request.then(result => {
|
|
24
|
+
/**
|
|
25
|
+
* @deprecated: The property "messages" is not supposed to be part of the pipeline response.
|
|
26
|
+
* Specification demands errors to be returned as response object with an "error" property.
|
|
27
|
+
* This code snippet needs to be removed after fixing the `@shopgate/legacy-cart` extension.
|
|
28
|
+
*/
|
|
29
|
+
if (result.messages && messagesHaveErrors(result.messages)) {
|
|
30
|
+
dispatch(errorDeleteCouponsFromCart(couponIds, createErrorMessageList(SHOPGATE_CART_DELETE_COUPONS, result.messages)));
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
dispatch(successDeleteCouponsFromCart());
|
|
34
|
+
}).catch(error => {
|
|
35
|
+
dispatch(errorDeleteCouponsFromCart(couponIds, createPipelineErrorList(SHOPGATE_CART_DELETE_COUPONS, error)));
|
|
36
|
+
});
|
|
37
|
+
return request;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** @mixes {MutableFunction} */
|
|
42
|
+
export default mutable(deleteCouponsFromCart);
|
|
@@ -1,9 +1,41 @@
|
|
|
1
|
-
import PipelineRequest from'@shopgate/pwa-core/classes/PipelineRequest';
|
|
1
|
+
import PipelineRequest from '@shopgate/pwa-core/classes/PipelineRequest';
|
|
2
|
+
import { PROCESS_SEQUENTIAL } from '@shopgate/pwa-core/constants/ProcessTypes';
|
|
3
|
+
import { mutable } from '@shopgate/pwa-common/helpers/redux';
|
|
4
|
+
import { SHOPGATE_CART_DELETE_PRODUCTS } from "../constants/Pipelines";
|
|
5
|
+
import createPipelineErrorList from "../helpers/createPipelineErrorList";
|
|
6
|
+
import { ECART } from "../constants/PipelineErrors";
|
|
7
|
+
import deleteProducts from "../action-creators/deleteProductsFromCart";
|
|
8
|
+
import successDeleteProductsFromCart from "../action-creators/successDeleteProductsFromCart";
|
|
9
|
+
import errorDeleteProductsFromCart from "../action-creators/errorDeleteProductsFromCart";
|
|
10
|
+
import { messagesHaveErrors, createErrorMessageList } from "../helpers";
|
|
11
|
+
|
|
12
|
+
/**
|
|
2
13
|
* Deletes products from the cart.
|
|
3
14
|
* @param {Array} cartItemIds The IDs of the items to remove from the cart.
|
|
4
15
|
* @return {Function} A redux thunk.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
16
|
+
*/
|
|
17
|
+
function deleteProductsFromCart(cartItemIds) {
|
|
18
|
+
return dispatch => {
|
|
19
|
+
dispatch(deleteProducts(cartItemIds));
|
|
20
|
+
const request = new PipelineRequest(SHOPGATE_CART_DELETE_PRODUCTS).setInput({
|
|
21
|
+
cartItemIds
|
|
22
|
+
}).setResponseProcessed(PROCESS_SEQUENTIAL).setErrorBlacklist(ECART).dispatch();
|
|
23
|
+
request.then(result => {
|
|
24
|
+
/**
|
|
25
|
+
* @deprecated: The property "messages" is not supposed to be part of the pipeline response.
|
|
26
|
+
* Specification demands errors to be returned as response object with an "error" property.
|
|
27
|
+
* This code snippet needs to be removed after fixing the `@shopgate/legacy-cart` extension.
|
|
28
|
+
*/
|
|
29
|
+
if (result.messages && messagesHaveErrors(result.messages)) {
|
|
30
|
+
dispatch(errorDeleteProductsFromCart(cartItemIds, createErrorMessageList(SHOPGATE_CART_DELETE_PRODUCTS, result.messages)));
|
|
31
|
+
}
|
|
32
|
+
dispatch(successDeleteProductsFromCart());
|
|
33
|
+
}).catch(error => {
|
|
34
|
+
dispatch(errorDeleteProductsFromCart(cartItemIds, createPipelineErrorList(SHOPGATE_CART_DELETE_PRODUCTS, error)));
|
|
35
|
+
});
|
|
36
|
+
return request;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** @mixes {MutableFunction} */
|
|
41
|
+
export default mutable(deleteProductsFromCart);
|