@shopgate/pwa-common-commerce 7.30.0-alpha.7 → 7.30.0-alpha.9
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 +700 -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 +4 -4
- 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{ERROR_FILTERS}from"../constants"
|
|
1
|
+
import { ERROR_FILTERS } from "../constants";
|
|
2
|
+
|
|
3
|
+
/**
|
|
2
4
|
* Creates the dispatched ERROR_FILTERS action object
|
|
3
5
|
* @param {string} hash The product list hash.
|
|
4
6
|
* @return {Object} The ERROR_PRODUCT action.
|
|
5
|
-
*/
|
|
7
|
+
*/
|
|
8
|
+
const errorFilters = hash => ({
|
|
9
|
+
type: ERROR_FILTERS,
|
|
10
|
+
hash
|
|
11
|
+
});
|
|
12
|
+
export default errorFilters;
|
|
@@ -1 +1,4 @@
|
|
|
1
|
-
export{default as requestFilters}
|
|
1
|
+
export { default as requestFilters } from "./requestFilters";
|
|
2
|
+
export { default as receiveFilters } from "./receiveFilters";
|
|
3
|
+
export { default as errorFilters } from "./errorFilters";
|
|
4
|
+
export * from "./updateFilters";
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
import{RECEIVE_FILTERS}from"../constants"
|
|
1
|
+
import { RECEIVE_FILTERS } from "../constants";
|
|
2
|
+
|
|
3
|
+
/**
|
|
2
4
|
* Creates the dispatched RECEIVE_FILTERS action object.
|
|
3
5
|
* @param {string} hash The product list hash.
|
|
4
6
|
* @param {Object} filters The available filters.
|
|
5
7
|
* @return {Object} The RECEIVE_PRODUCT action.
|
|
6
|
-
*/
|
|
8
|
+
*/
|
|
9
|
+
const receiveFilters = (hash, filters) => ({
|
|
10
|
+
type: RECEIVE_FILTERS,
|
|
11
|
+
hash,
|
|
12
|
+
filters
|
|
13
|
+
});
|
|
14
|
+
export default receiveFilters;
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
import{REQUEST_FILTERS}from"../constants"
|
|
1
|
+
import { REQUEST_FILTERS } from "../constants";
|
|
2
|
+
|
|
3
|
+
/**
|
|
2
4
|
* Creates the dispatched REQUEST_FILTERS action object.
|
|
3
5
|
* @param {string} hash The product list hash.
|
|
4
6
|
* @return {Object} The REQUEST_PRODUCT action.
|
|
5
|
-
*/
|
|
7
|
+
*/
|
|
8
|
+
const requestFilters = hash => ({
|
|
9
|
+
type: REQUEST_FILTERS,
|
|
10
|
+
hash
|
|
11
|
+
});
|
|
12
|
+
export default requestFilters;
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import{UPDATE_FILTERS}from"../constants"
|
|
1
|
+
import { UPDATE_FILTERS } from "../constants";
|
|
2
|
+
|
|
3
|
+
/**
|
|
2
4
|
* @param {Object} filters The set filters.
|
|
3
5
|
* @return {Object}
|
|
4
|
-
*/
|
|
6
|
+
*/
|
|
7
|
+
export const updateFilters = filters => ({
|
|
8
|
+
type: UPDATE_FILTERS,
|
|
9
|
+
filters
|
|
10
|
+
});
|
|
@@ -1,7 +1,50 @@
|
|
|
1
|
-
|
|
1
|
+
import PipelineRequest from '@shopgate/pwa-core/classes/PipelineRequest';
|
|
2
|
+
import { logger } from '@shopgate/pwa-core/helpers';
|
|
3
|
+
import { generateResultHash, shouldFetchFilters } from '@shopgate/pwa-common/helpers/redux';
|
|
4
|
+
import { SHOPGATE_CATALOG_GET_FILTERS } from "../constants/Pipelines";
|
|
5
|
+
import requestFilters from "../action-creators/requestFilters";
|
|
6
|
+
import receiveFilters from "../action-creators/receiveFilters";
|
|
7
|
+
import errorFilters from "../action-creators/errorFilters";
|
|
8
|
+
import { getFilterResults } from "../selectors";
|
|
9
|
+
import buildFilterParams from "./helpers/buildFilterParams";
|
|
10
|
+
import processParams from "./helpers/processParams";
|
|
11
|
+
|
|
12
|
+
/**
|
|
2
13
|
* Retrieves the available filters for a list of products.
|
|
3
14
|
* @param {Object} options The options for the getProducts request.
|
|
4
15
|
* @param {Object} [options.filters = null] Filters object for the request
|
|
5
16
|
* @returns {Function} A redux thunk
|
|
6
|
-
*/
|
|
7
|
-
|
|
17
|
+
*/
|
|
18
|
+
function fetchFilters({
|
|
19
|
+
filters = null
|
|
20
|
+
} = {}) {
|
|
21
|
+
return (dispatch, getState) => {
|
|
22
|
+
const state = getState();
|
|
23
|
+
const params = buildFilterParams(state, filters);
|
|
24
|
+
const hash = generateResultHash({
|
|
25
|
+
pipeline: SHOPGATE_CATALOG_GET_FILTERS,
|
|
26
|
+
...params
|
|
27
|
+
}, false, false);
|
|
28
|
+
const result = getFilterResults(state)[hash];
|
|
29
|
+
if (!shouldFetchFilters(result)) {
|
|
30
|
+
return Promise.resolve(null);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// We need to process the params to handle edge cases in the pipeline params.
|
|
34
|
+
const requestParams = processParams(params);
|
|
35
|
+
if (Object.keys(requestParams).length === 0) {
|
|
36
|
+
const error = `Attempt to call ${SHOPGATE_CATALOG_GET_FILTERS} pipeline without parameters - aborted`;
|
|
37
|
+
logger.error(error);
|
|
38
|
+
return Promise.reject(new Error(error));
|
|
39
|
+
}
|
|
40
|
+
dispatch(requestFilters(hash));
|
|
41
|
+
const request = new PipelineRequest(SHOPGATE_CATALOG_GET_FILTERS).setInput(requestParams).dispatch();
|
|
42
|
+
request.then(response => {
|
|
43
|
+
dispatch(receiveFilters(hash, response.filters));
|
|
44
|
+
}).catch(() => {
|
|
45
|
+
dispatch(errorFilters(hash));
|
|
46
|
+
});
|
|
47
|
+
return request;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
export default fetchFilters;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import fetchFilters from"./fetchFilters"
|
|
1
|
+
import fetchFilters from "./fetchFilters";
|
|
2
|
+
|
|
3
|
+
/**
|
|
2
4
|
* Retrieves the available filters for a list of products.
|
|
3
5
|
* @returns {Function} A redux thunk
|
|
4
6
|
* @deprecated
|
|
5
|
-
*/
|
|
7
|
+
*/
|
|
8
|
+
const getFilters = fetchFilters;
|
|
9
|
+
export default getFilters;
|
|
@@ -1,6 +1,38 @@
|
|
|
1
|
-
|
|
1
|
+
import { getCurrentRoute } from '@shopgate/pwa-common/selectors/router';
|
|
2
|
+
import { CATEGORY_ALL_PATTERN, CATEGORY_ALL_FILTER_PATTERN } from '@shopgate/pwa-common-commerce/category/constants';
|
|
3
|
+
import { hex2bin } from '@shopgate/pwa-common/helpers/data';
|
|
4
|
+
import buildRequestFilters from "./buildRequestFilters";
|
|
5
|
+
|
|
6
|
+
/**
|
|
2
7
|
* Creates the filter params.
|
|
3
8
|
* @param {Object} state The application state.
|
|
4
9
|
* @param {Object} [filters] Optional filters to be sent with the request
|
|
5
10
|
* @return {Object}
|
|
6
|
-
*/
|
|
11
|
+
*/
|
|
12
|
+
const buildFilterParams = (state, filters) => {
|
|
13
|
+
const {
|
|
14
|
+
params,
|
|
15
|
+
query,
|
|
16
|
+
pattern
|
|
17
|
+
} = getCurrentRoute(state);
|
|
18
|
+
let filterParams = {
|
|
19
|
+
...(params.categoryId && {
|
|
20
|
+
categoryId: hex2bin(params.categoryId)
|
|
21
|
+
}),
|
|
22
|
+
...(query.s && {
|
|
23
|
+
searchPhrase: query.s
|
|
24
|
+
})
|
|
25
|
+
};
|
|
26
|
+
if ([CATEGORY_ALL_PATTERN, CATEGORY_ALL_FILTER_PATTERN].includes(pattern)) {
|
|
27
|
+
filterParams = {
|
|
28
|
+
searchPhrase: '*'
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
...filterParams,
|
|
33
|
+
...(filters ? {
|
|
34
|
+
filters: buildRequestFilters(filters)
|
|
35
|
+
} : null)
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
export default buildFilterParams;
|
|
@@ -1,6 +1,39 @@
|
|
|
1
|
-
|
|
1
|
+
import "core-js/modules/es.array.reduce.js";
|
|
2
|
+
import { FILTER_TYPE_SINGLE_SELECT, FILTER_TYPE_MULTISELECT, FILTER_TYPE_RANGE } from '@shopgate/pwa-common-commerce/filter/constants';
|
|
3
|
+
|
|
4
|
+
/**
|
|
2
5
|
* Converts an active filters object from the current route state
|
|
3
6
|
* to one that can be used within a pipeline request.
|
|
4
7
|
* @param {Object} activeFilters The selected filters.
|
|
5
8
|
* @return {Object|undefined}
|
|
6
|
-
*/
|
|
9
|
+
*/
|
|
10
|
+
const buildRequestFilters = activeFilters => {
|
|
11
|
+
let filters;
|
|
12
|
+
if (activeFilters) {
|
|
13
|
+
filters = Object.keys(activeFilters).reduce((result, id) => {
|
|
14
|
+
const filter = activeFilters[id];
|
|
15
|
+
const converted = {
|
|
16
|
+
label: filter.label,
|
|
17
|
+
type: filter.type,
|
|
18
|
+
...(filter.source && {
|
|
19
|
+
source: filter.source
|
|
20
|
+
})
|
|
21
|
+
};
|
|
22
|
+
if (filter.type === FILTER_TYPE_RANGE) {
|
|
23
|
+
const [minimum, maximum] = filter.value;
|
|
24
|
+
converted.minimum = minimum;
|
|
25
|
+
converted.maximum = maximum;
|
|
26
|
+
} else if (filter.type === FILTER_TYPE_MULTISELECT) {
|
|
27
|
+
converted.values = filter.value.map(entry => entry.id);
|
|
28
|
+
} else if (filter.type === FILTER_TYPE_SINGLE_SELECT) {
|
|
29
|
+
converted.value = filter.value[0].id;
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
...result,
|
|
33
|
+
[id]: converted
|
|
34
|
+
};
|
|
35
|
+
}, {});
|
|
36
|
+
}
|
|
37
|
+
return filters;
|
|
38
|
+
};
|
|
39
|
+
export default buildRequestFilters;
|
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
2
|
* Removes the display_amount filter from the filters list.
|
|
3
3
|
* @param {Object} filters The filters.
|
|
4
4
|
* @returns {Object} The processed filters.
|
|
5
|
-
*/
|
|
5
|
+
*/
|
|
6
|
+
const processFilters = filters => {
|
|
7
|
+
const newFilters = {
|
|
8
|
+
...filters
|
|
9
|
+
};
|
|
10
|
+
delete newFilters.display_amount;
|
|
11
|
+
return newFilters;
|
|
12
|
+
};
|
|
13
|
+
export default processFilters;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import processFilters from "./processFilters";
|
|
2
|
+
import buildRequestFilters from "./buildRequestFilters";
|
|
3
|
+
|
|
4
|
+
/**
|
|
2
5
|
* Process the pipeline params to be compatible with the current API specifications.
|
|
3
6
|
* Currently the categoryId field cannot be used in combination with the filter field. In order to
|
|
4
7
|
* use them together the categoryId field has to be extracted into the filter field.
|
|
@@ -6,4 +9,25 @@ function _extends(){_extends=Object.assign||function(target){for(var i=1;i<argum
|
|
|
6
9
|
* @param {Object} params The request params.
|
|
7
10
|
* @param {Object} [filters=null] The current active filters.
|
|
8
11
|
* @returns {Object} A set of compatible params.
|
|
9
|
-
*/
|
|
12
|
+
*/
|
|
13
|
+
const processParams = (params, filters = null) => {
|
|
14
|
+
const processedFilters = processFilters(buildRequestFilters(filters));
|
|
15
|
+
let newParams = {
|
|
16
|
+
...params,
|
|
17
|
+
...(processedFilters && Object.keys(processedFilters).length && {
|
|
18
|
+
filters: processedFilters
|
|
19
|
+
})
|
|
20
|
+
};
|
|
21
|
+
if (params.categoryId && processedFilters && Object.keys(processedFilters).length) {
|
|
22
|
+
newParams = {
|
|
23
|
+
...params,
|
|
24
|
+
filters: {
|
|
25
|
+
categoryId: params.categoryId,
|
|
26
|
+
...processedFilters
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
delete newParams.categoryId;
|
|
30
|
+
}
|
|
31
|
+
return newParams;
|
|
32
|
+
};
|
|
33
|
+
export default processParams;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export const SHOPGATE_CATALOG_GET_FILTERS = 'shopgate.catalog.getFilters';
|
|
@@ -1,4 +1,40 @@
|
|
|
1
1
|
// FEATURES
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
const FILTER = 'filter';
|
|
3
|
+
|
|
4
|
+
// CONTENTS
|
|
5
|
+
const PRICE_RANGE = 'price-range';
|
|
6
|
+
const SORT = 'sort-options';
|
|
7
|
+
const SELECTOR = 'selector';
|
|
8
|
+
const APPLY_BUTTON = 'apply-button';
|
|
9
|
+
const RESET_BUTTON = 'reset-button';
|
|
10
|
+
const PAGE_CONTENT = 'page-content';
|
|
11
|
+
|
|
12
|
+
// POSITIONS
|
|
13
|
+
const BEFORE = 'before';
|
|
14
|
+
const AFTER = 'after';
|
|
15
|
+
|
|
16
|
+
/** @deprecated Use PORTAL_FILTER_PRICE_RANGE instead */
|
|
17
|
+
export const FILTER_PRICE_RANGE = `${FILTER}.${PRICE_RANGE}`;
|
|
18
|
+
/** @deprecated Use PORTAL_FILTER_PRICE_RANGE_BEFORE instead */
|
|
19
|
+
export const FILTER_PRICE_RANGE_BEFORE = `${FILTER}.${PRICE_RANGE}.${BEFORE}`;
|
|
20
|
+
/** @deprecated Use PORTAL_FILTER_PRICE_RANGE_AFTER instead */
|
|
21
|
+
export const FILTER_PRICE_RANGE_AFTER = `${FILTER}.${PRICE_RANGE}.${AFTER}`;
|
|
22
|
+
|
|
23
|
+
/** @deprecated Use PORTAL_FILTER_SORT_OPTIONS instead */
|
|
24
|
+
export const FILTER_SORT_OPTIONS = `${FILTER}.${SORT}`;
|
|
25
|
+
export const PORTAL_FILTER_PRICE_RANGE = FILTER_PRICE_RANGE;
|
|
26
|
+
export const PORTAL_FILTER_PRICE_RANGE_BEFORE = FILTER_PRICE_RANGE_BEFORE;
|
|
27
|
+
export const PORTAL_FILTER_PRICE_RANGE_AFTER = FILTER_PRICE_RANGE_AFTER;
|
|
28
|
+
export const PORTAL_FILTER_SORT_OPTIONS = FILTER_SORT_OPTIONS;
|
|
29
|
+
export const PORTAL_FILTER_SELECTOR = `${FILTER}.${SELECTOR}`;
|
|
30
|
+
export const PORTAL_FILTER_SELECTOR_BEFORE = `${FILTER}.${SELECTOR}.${BEFORE}`;
|
|
31
|
+
export const PORTAL_FILTER_SELECTOR_AFTER = `${FILTER}.${SELECTOR}.${AFTER}`;
|
|
32
|
+
export const PORTAL_FILTER_APPLY_BUTTON = `${FILTER}.${APPLY_BUTTON}`;
|
|
33
|
+
export const PORTAL_FILTER_APPLY_BUTTON_BEFORE = `${FILTER}.${APPLY_BUTTON}.${BEFORE}`;
|
|
34
|
+
export const PORTAL_FILTER_APPLY_BUTTON_AFTER = `${FILTER}.${APPLY_BUTTON}.${AFTER}`;
|
|
35
|
+
export const PORTAL_FILTER_RESET_BUTTON = `${FILTER}.${RESET_BUTTON}`;
|
|
36
|
+
export const PORTAL_FILTER_RESET_BUTTON_BEFORE = `${FILTER}.${RESET_BUTTON}.${BEFORE}`;
|
|
37
|
+
export const PORTAL_FILTER_RESET_BUTTON_AFTER = `${FILTER}.${RESET_BUTTON}.${AFTER}`;
|
|
38
|
+
export const PORTAL_FILTER_PAGE_CONTENT = `${FILTER}.${PAGE_CONTENT}`;
|
|
39
|
+
export const PORTAL_FILTER_PAGE_CONTENT_BEFORE = `${FILTER}.${PAGE_CONTENT}.${BEFORE}`;
|
|
40
|
+
export const PORTAL_FILTER_PAGE_CONTENT_AFTER = `${FILTER}.${PAGE_CONTENT}.${AFTER}`;
|
|
@@ -1 +1,8 @@
|
|
|
1
|
-
export
|
|
1
|
+
export const FILTER_PATH = '/filter';
|
|
2
|
+
export const REQUEST_FILTERS = 'REQUEST_FILTERS';
|
|
3
|
+
export const RECEIVE_FILTERS = 'RECEIVE_FILTERS';
|
|
4
|
+
export const ERROR_FILTERS = 'ERROR_FILTERS';
|
|
5
|
+
export const UPDATE_FILTERS = 'UPDATE_FILTERS';
|
|
6
|
+
export const FILTER_TYPE_SINGLE_SELECT = 'single_select';
|
|
7
|
+
export const FILTER_TYPE_MULTISELECT = 'multiselect';
|
|
8
|
+
export const FILTER_TYPE_RANGE = 'range';
|
package/filter/index.js
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
// ACTIONS
|
|
2
|
-
export{default as fetchFilters}from"./actions/fetchFilters"
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export*from"./
|
|
2
|
+
export { default as fetchFilters } from "./actions/fetchFilters";
|
|
3
|
+
|
|
4
|
+
// CONSTANTS
|
|
5
|
+
export * from "./constants/index";
|
|
6
|
+
export * from "./constants/Pipelines";
|
|
7
|
+
export * from "./constants/Portals";
|
|
8
|
+
|
|
9
|
+
// SELECTORS
|
|
10
|
+
export * from "./selectors";
|
|
11
|
+
|
|
12
|
+
// STREAMS
|
|
13
|
+
export * from "./streams";
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
import kebabCase from 'lodash/kebabCase';
|
|
2
|
+
import { FILTER_PATH } from "../../constants";
|
|
3
|
+
|
|
4
|
+
/**
|
|
2
5
|
* Enriches a filter object with additional properties.
|
|
3
6
|
* @param {Array} filters The filters collection.
|
|
4
7
|
* @return {Array} The new collection of enriched filters.
|
|
5
|
-
*/
|
|
6
|
-
|
|
8
|
+
*/
|
|
9
|
+
const enrichFilters = filters => filters.map(filter => ({
|
|
10
|
+
...filter,
|
|
11
|
+
// The route url of this filter.
|
|
12
|
+
url: `${FILTER_PATH}/${kebabCase(filter.id)}`
|
|
13
|
+
}));
|
|
14
|
+
export default enrichFilters;
|
package/filter/reducers/index.js
CHANGED
|
@@ -1 +1,5 @@
|
|
|
1
|
-
import{combineReducers}from'redux';
|
|
1
|
+
import { combineReducers } from 'redux';
|
|
2
|
+
import resultsByHash from "./resultsByHash";
|
|
3
|
+
export default combineReducers({
|
|
4
|
+
resultsByHash
|
|
5
|
+
});
|
|
@@ -1,6 +1,46 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { REQUEST_FILTERS, RECEIVE_FILTERS, ERROR_FILTERS } from '@shopgate/pwa-common-commerce/filter/constants';
|
|
2
|
+
// TODO: Remove dependency to product
|
|
3
|
+
import { PRODUCT_LIFETIME } from '@shopgate/pwa-common-commerce/product/constants';
|
|
4
|
+
import enrichFilters from "./helpers/enrichFilters";
|
|
5
|
+
|
|
6
|
+
/**
|
|
3
7
|
* @param {Object} [state={}] The current state.
|
|
4
8
|
* @param {Object} action The current redux action.
|
|
5
9
|
* @return {Object} The new state.
|
|
6
|
-
*/
|
|
10
|
+
*/
|
|
11
|
+
export default function resultsByHash(state = {}, action) {
|
|
12
|
+
switch (action.type) {
|
|
13
|
+
case REQUEST_FILTERS:
|
|
14
|
+
{
|
|
15
|
+
return {
|
|
16
|
+
...state,
|
|
17
|
+
[action.hash]: {
|
|
18
|
+
filters: null,
|
|
19
|
+
isFetching: true,
|
|
20
|
+
expires: 0
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
case RECEIVE_FILTERS:
|
|
25
|
+
{
|
|
26
|
+
return {
|
|
27
|
+
...state,
|
|
28
|
+
[action.hash]: {
|
|
29
|
+
filters: enrichFilters(action.filters),
|
|
30
|
+
isFetching: false,
|
|
31
|
+
expires: Date.now() + PRODUCT_LIFETIME
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
case ERROR_FILTERS:
|
|
36
|
+
return {
|
|
37
|
+
...state,
|
|
38
|
+
[action.hash]: {
|
|
39
|
+
...state[action.hash],
|
|
40
|
+
isFetching: false
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
default:
|
|
44
|
+
return state;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -1,21 +1,62 @@
|
|
|
1
|
-
|
|
1
|
+
import { createSelector } from 'reselect';
|
|
2
|
+
import { hex2bin } from '@shopgate/pwa-common/helpers/data';
|
|
3
|
+
import { generateResultHash } from '@shopgate/pwa-common/helpers/redux';
|
|
4
|
+
import { getCurrentState } from '@shopgate/pwa-common/selectors/router';
|
|
5
|
+
import * as pipelines from "../constants/Pipelines";
|
|
6
|
+
import buildRequestFilters from "../actions/helpers/buildRequestFilters";
|
|
7
|
+
|
|
8
|
+
/**
|
|
2
9
|
* Gets the filters reducer.
|
|
3
10
|
* @param {Object} state The application state.
|
|
4
11
|
* @return {Object}
|
|
5
|
-
*/
|
|
12
|
+
*/
|
|
13
|
+
export const getFilters = state => state.filter;
|
|
14
|
+
|
|
15
|
+
/**
|
|
6
16
|
* Gets the filter results.
|
|
7
17
|
* @param {Object} state The current application state.
|
|
8
18
|
* @return {Object}
|
|
9
|
-
*/
|
|
19
|
+
*/
|
|
20
|
+
export const getFilterResults = createSelector(getFilters, filter => filter.resultsByHash);
|
|
21
|
+
|
|
22
|
+
/**
|
|
10
23
|
* Gets filters by a result hash.
|
|
11
24
|
* @param {Object} state The current application state.
|
|
12
25
|
* @param {Object} props The props.
|
|
13
26
|
* @return {Object}
|
|
14
|
-
*/
|
|
27
|
+
*/
|
|
28
|
+
export const getFiltersByHash = createSelector(getFilterResults, (state, props) => props.categoryId, (state, props) => props.searchPhrase, (state, props) => props.filters, (results, categoryId, searchPhrase, filters) => {
|
|
29
|
+
const hash = generateResultHash({
|
|
30
|
+
pipeline: pipelines.SHOPGATE_CATALOG_GET_FILTERS,
|
|
31
|
+
...(categoryId && {
|
|
32
|
+
categoryId: hex2bin(categoryId)
|
|
33
|
+
}),
|
|
34
|
+
...(searchPhrase && {
|
|
35
|
+
searchPhrase
|
|
36
|
+
}),
|
|
37
|
+
...(filters && {
|
|
38
|
+
filters: buildRequestFilters(filters)
|
|
39
|
+
})
|
|
40
|
+
}, false, false);
|
|
41
|
+
return results[hash] && results[hash].filters || null;
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
/**
|
|
15
45
|
* Gets the currently active filters.
|
|
16
46
|
* @returns {Object|null}
|
|
17
|
-
*/
|
|
47
|
+
*/
|
|
48
|
+
export const getActiveFilters = createSelector(getCurrentState, ({
|
|
49
|
+
filters
|
|
50
|
+
}) => {
|
|
51
|
+
if (!filters) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
return filters;
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
/**
|
|
18
58
|
* Checks if currently filters are active.
|
|
19
59
|
* @param {Object} state The application state.
|
|
20
60
|
* @returns {boolean}
|
|
21
|
-
*/
|
|
61
|
+
*/
|
|
62
|
+
export const hasActiveFilters = createSelector(getActiveFilters, activeFilters => activeFilters !== null && !!Object.keys(activeFilters).length);
|
package/filter/streams/index.js
CHANGED
|
@@ -1 +1,30 @@
|
|
|
1
|
-
import{main$}from'@shopgate/pwa-common/streams/main';
|
|
1
|
+
import { main$ } from '@shopgate/pwa-common/streams/main';
|
|
2
|
+
import { ACTION_PUSH, ACTION_POP } from '@virtuous/conductor';
|
|
3
|
+
import { routeWillEnter$, routeDidEnter$, routeWillLeave$, routeDidLeave$ } from '@shopgate/pwa-common/streams';
|
|
4
|
+
import { CATEGORY_PATH, CATEGORY_ALL_PATTERN, CATEGORY_ALL_FILTER_PATTERN } from "../../category/constants";
|
|
5
|
+
import { SEARCH_PATH } from "../../search/constants";
|
|
6
|
+
import { FILTER_PATH, UPDATE_FILTERS } from "../constants";
|
|
7
|
+
export const filterWillEnter$ = routeWillEnter$.filter(({
|
|
8
|
+
action
|
|
9
|
+
}) => action.route.pattern === `${CATEGORY_PATH}/:categoryId${FILTER_PATH}` || action.route.pattern === CATEGORY_ALL_FILTER_PATTERN || action.route.pattern === `${SEARCH_PATH}${FILTER_PATH}`);
|
|
10
|
+
export const filterDidEnter$ = routeDidEnter$.filter(({
|
|
11
|
+
action
|
|
12
|
+
}) => action.route.pattern === `${CATEGORY_PATH}/:categoryId${FILTER_PATH}` || action.route.pattern === CATEGORY_ALL_FILTER_PATTERN || action.route.pattern === `${SEARCH_PATH}${FILTER_PATH}`);
|
|
13
|
+
export const filterWillLeave$ = routeWillLeave$.filter(({
|
|
14
|
+
action
|
|
15
|
+
}) => action.route.pattern === `${CATEGORY_PATH}/:categoryId${FILTER_PATH}` || action.route.pattern === CATEGORY_ALL_FILTER_PATTERN || action.route.pattern === `${SEARCH_PATH}${FILTER_PATH}`);
|
|
16
|
+
export const filterDidLeave$ = routeDidLeave$.filter(({
|
|
17
|
+
action
|
|
18
|
+
}) => action.route.pattern === `${CATEGORY_PATH}/:categoryId${FILTER_PATH}` || action.route.pattern === CATEGORY_ALL_FILTER_PATTERN || action.route.pattern === `${SEARCH_PATH}${FILTER_PATH}`);
|
|
19
|
+
export const filterableRoutesWillEnter$ = routeWillEnter$.filter(({
|
|
20
|
+
action
|
|
21
|
+
}) => action.historyAction === ACTION_PUSH && (action.route.pattern === `${CATEGORY_PATH}/:categoryId` || action.route.pattern === CATEGORY_ALL_PATTERN || action.route.pattern === SEARCH_PATH));
|
|
22
|
+
export const filterableRoutesWillReenter$ = routeWillEnter$.filter(({
|
|
23
|
+
action
|
|
24
|
+
}) => action.historyAction === ACTION_POP && (action.route.pattern === `${CATEGORY_PATH}/:categoryId` || action.route.pattern === CATEGORY_ALL_PATTERN || action.route.pattern === SEARCH_PATH));
|
|
25
|
+
export const filterableRoutesWillLeave$ = routeWillLeave$.filter(({
|
|
26
|
+
action
|
|
27
|
+
}) => action.historyAction === ACTION_POP && (action.route.pattern === `${CATEGORY_PATH}/:categoryId` || action.route.pattern === CATEGORY_ALL_PATTERN || action.route.pattern === SEARCH_PATH));
|
|
28
|
+
export const filtersDidUpdate$ = main$.filter(({
|
|
29
|
+
action
|
|
30
|
+
}) => action.type === UPDATE_FILTERS);
|
|
@@ -1,4 +1,36 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { router } from '@shopgate/pwa-common/helpers/router';
|
|
2
|
+
import { hex2bin } from '@shopgate/pwa-common/helpers/data';
|
|
3
|
+
import { buildFilterParamsForFetchFiltersRequest } from '@shopgate/engage/filter/helpers';
|
|
4
|
+
import { CATEGORY_ALL_FILTER_PATTERN } from "../../category/constants";
|
|
5
|
+
import fetchCategory from "../../category/actions/fetchCategory";
|
|
6
|
+
import { getShowAllProductsFilters } from "../../category/helpers";
|
|
7
|
+
import fetchFilters from "../actions/fetchFilters";
|
|
8
|
+
import { filterDidEnter$ } from "../streams";
|
|
9
|
+
|
|
10
|
+
/**
|
|
2
11
|
* Filters subscriptions.
|
|
3
12
|
* @param {Function} subscribe The subscribe function.
|
|
4
|
-
*/
|
|
13
|
+
*/
|
|
14
|
+
export default function filters(subscribe) {
|
|
15
|
+
subscribe(filterDidEnter$, async ({
|
|
16
|
+
dispatch,
|
|
17
|
+
action
|
|
18
|
+
}) => {
|
|
19
|
+
let {
|
|
20
|
+
filters: routeFilters
|
|
21
|
+
} = action?.route?.state || {};
|
|
22
|
+
if (action?.route?.pattern === CATEGORY_ALL_FILTER_PATTERN) {
|
|
23
|
+
if (!routeFilters) {
|
|
24
|
+
const category = await dispatch(fetchCategory(hex2bin(action.route.params.categoryId)));
|
|
25
|
+
routeFilters = getShowAllProductsFilters(category);
|
|
26
|
+
router.update(action.route.id, {
|
|
27
|
+
filters: routeFilters,
|
|
28
|
+
categoryName: category.name
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
dispatch(fetchFilters({
|
|
33
|
+
filters: buildFilterParamsForFetchFiltersRequest(routeFilters)
|
|
34
|
+
}));
|
|
35
|
+
});
|
|
36
|
+
}
|
|
@@ -3,7 +3,25 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the Apache 2.0 license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// FEATURES
|
|
9
|
+
const NAV_MENU = 'nav-menu';
|
|
10
|
+
|
|
11
|
+
// CONTENTS
|
|
12
|
+
const SHIPPING = 'shipping';
|
|
13
|
+
const PAYMENT = 'payment';
|
|
14
|
+
const RETURN_POLICY = 'return-policy';
|
|
15
|
+
|
|
16
|
+
// POSITIONS
|
|
17
|
+
const BEFORE = 'before';
|
|
18
|
+
const AFTER = 'after';
|
|
19
|
+
export const NAV_MENU_SHIPPING_BEFORE = `${NAV_MENU}.${SHIPPING}.${BEFORE}`;
|
|
20
|
+
export const NAV_MENU_SHIPPING = `${NAV_MENU}.${SHIPPING}`;
|
|
21
|
+
export const NAV_MENU_SHIPPING_AFTER = `${NAV_MENU}.${SHIPPING}.${AFTER}`;
|
|
22
|
+
export const NAV_MENU_PAYMENT_BEFORE = `${NAV_MENU}.${PAYMENT}.${BEFORE}`;
|
|
23
|
+
export const NAV_MENU_PAYMENT = `${NAV_MENU}.${PAYMENT}`;
|
|
24
|
+
export const NAV_MENU_PAYMENT_AFTER = `${NAV_MENU}.${PAYMENT}.${AFTER}`;
|
|
25
|
+
export const NAV_MENU_RETURN_POLICY_BEFORE = `${NAV_MENU}.${RETURN_POLICY}.${BEFORE}`;
|
|
26
|
+
export const NAV_MENU_RETURN_POLICY = `${NAV_MENU}.${RETURN_POLICY}`;
|
|
27
|
+
export const NAV_MENU_RETURN_POLICY_AFTER = `${NAV_MENU}.${RETURN_POLICY}.${AFTER}`;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export const MARKET_AUSTRIA = 'AT';
|
|
2
|
+
export const MARKET_GERMANY = 'DE';
|