@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,7 +1,16 @@
|
|
|
1
|
-
import{SUCCESS_HANDLE_SCANNER}from"../constants"
|
|
1
|
+
import { SUCCESS_HANDLE_SCANNER } from "../constants";
|
|
2
|
+
|
|
3
|
+
/**
|
|
2
4
|
* Creates the dispatched SUCCESS_HANDLE_SCANNER action object.
|
|
3
5
|
* @param {string} scope scan scope
|
|
4
6
|
* @param {string} format data format EAN_13, QR_CODE
|
|
5
7
|
* @param {Object} payload scan result
|
|
6
8
|
* @returns {Object}
|
|
7
|
-
*/
|
|
9
|
+
*/
|
|
10
|
+
const successHandleScanner = (scope, format, payload) => ({
|
|
11
|
+
type: SUCCESS_HANDLE_SCANNER,
|
|
12
|
+
scope,
|
|
13
|
+
format,
|
|
14
|
+
payload
|
|
15
|
+
});
|
|
16
|
+
export default successHandleScanner;
|
|
@@ -1,7 +1,27 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { mutable } from '@shopgate/pwa-common/helpers/redux';
|
|
2
|
+
import handleSearch from "./handleSearch";
|
|
3
|
+
import handleNoResults from "./handleNoResults";
|
|
4
|
+
import successHandleScanner from "../action-creators/successHandleScanner";
|
|
5
|
+
|
|
6
|
+
/**
|
|
2
7
|
* Handle bar code
|
|
3
8
|
* @param {ScannerEvent} event Scanner event that emitted.
|
|
4
9
|
* @param {string} format Format of the scanned code.
|
|
5
10
|
* @param {string} payload Barcode payload.
|
|
6
11
|
* @return {Function} A redux thunk.
|
|
7
|
-
*/
|
|
12
|
+
*/
|
|
13
|
+
const handleBarCode = event => async dispatch => {
|
|
14
|
+
const {
|
|
15
|
+
scope,
|
|
16
|
+
format,
|
|
17
|
+
payload
|
|
18
|
+
} = event;
|
|
19
|
+
if (await dispatch(handleSearch(payload))) {
|
|
20
|
+
dispatch(successHandleScanner(scope, format, payload));
|
|
21
|
+
} else {
|
|
22
|
+
dispatch(handleNoResults(event, 'scanner.noResult.barCode'));
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/** @mixes {MutableFunction} */
|
|
27
|
+
export default mutable(handleBarCode);
|
|
@@ -1,8 +1,29 @@
|
|
|
1
|
-
import
|
|
1
|
+
import showModal from '@shopgate/pwa-common/actions/modal/showModal';
|
|
2
|
+
import { mutable } from '@shopgate/pwa-common/helpers/redux';
|
|
3
|
+
import Scanner from '@shopgate/pwa-core/classes/Scanner';
|
|
4
|
+
import errorHandleScanner from "../action-creators/errorHandleScanner";
|
|
5
|
+
|
|
6
|
+
/**
|
|
2
7
|
* Handle no results
|
|
3
8
|
* @param {string} event.scope Scanner scope.
|
|
4
9
|
* @param {string} event.format Format of the scanned code.
|
|
5
10
|
* @param {string} event.payload Barcode payload.
|
|
6
11
|
* @param {string} message The message to display.
|
|
7
12
|
* @return {Function} A redux thunk.
|
|
8
|
-
*/
|
|
13
|
+
*/
|
|
14
|
+
const handleNoResult = ({
|
|
15
|
+
scope,
|
|
16
|
+
format,
|
|
17
|
+
payload
|
|
18
|
+
}, message) => async dispatch => {
|
|
19
|
+
dispatch(errorHandleScanner(scope, format, payload));
|
|
20
|
+
dispatch(showModal({
|
|
21
|
+
dismiss: null,
|
|
22
|
+
confirm: 'modal.ok',
|
|
23
|
+
title: 'modal.title_error',
|
|
24
|
+
message
|
|
25
|
+
})).then(confirmed => confirmed && Scanner.start());
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/** @mixes {MutableFunction} */
|
|
29
|
+
export default mutable(handleNoResult);
|
|
@@ -1,13 +1,123 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { historyPop, historyReplace, historyPush } from '@shopgate/engage/core/actions';
|
|
2
|
+
import { fetchPageConfig } from '@shopgate/engage/page/actions';
|
|
3
|
+
import { makeGetUnifiedCMSPageData } from '@shopgate/engage/page/selectors';
|
|
4
|
+
import { fetchProductsById } from '@shopgate/engage/product';
|
|
5
|
+
import { getProductById } from '@shopgate/engage/product/selectors/product';
|
|
6
|
+
import { fetchCategory } from '@shopgate/engage/category/actions';
|
|
7
|
+
import { getCategory } from '@shopgate/engage/category/selectors';
|
|
8
|
+
import { isHTTPS, mutable } from '@shopgate/engage/core/helpers';
|
|
9
|
+
import successHandleScanner from "../action-creators/successHandleScanner";
|
|
10
|
+
import { QR_CODE_TYPE_CATEGORY, QR_CODE_TYPE_COUPON, QR_CODE_TYPE_HOMEPAGE, QR_CODE_TYPE_PAGE, QR_CODE_TYPE_PRODUCT, QR_CODE_TYPE_PRODUCT_WITH_COUPON, QR_CODE_TYPE_SEARCH } from "../constants";
|
|
11
|
+
import { parse2dsQrCode } from "../helpers";
|
|
12
|
+
import handleSearch from "./handleSearch";
|
|
13
|
+
import handleNoResults from "./handleNoResults";
|
|
14
|
+
|
|
15
|
+
/**
|
|
2
16
|
* Handle qr code
|
|
3
17
|
* @param {string} event.scope Scanner scope.
|
|
4
18
|
* @param {string} event.format Format of the scanned code.
|
|
5
19
|
* @param {string} event.payload Barcode payload.
|
|
6
20
|
* @return {Function} A redux thunk.
|
|
7
|
-
*/
|
|
21
|
+
*/
|
|
22
|
+
const handleQrCode = ({
|
|
23
|
+
scope,
|
|
24
|
+
format,
|
|
25
|
+
payload
|
|
26
|
+
}) => async (dispatch, getState) => {
|
|
27
|
+
const {
|
|
28
|
+
type,
|
|
29
|
+
link,
|
|
30
|
+
data
|
|
31
|
+
} = parse2dsQrCode(payload) || {};
|
|
32
|
+
|
|
33
|
+
/**
|
|
8
34
|
* Helper function to handle no scan results
|
|
9
35
|
* @return {Function}
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
36
|
+
*/
|
|
37
|
+
const notFound = () => dispatch(handleNoResults({
|
|
38
|
+
scope,
|
|
39
|
+
format,
|
|
40
|
+
payload
|
|
41
|
+
}, 'scanner.noResult.qrCode'));
|
|
42
|
+
switch (type) {
|
|
43
|
+
case QR_CODE_TYPE_HOMEPAGE:
|
|
44
|
+
dispatch(successHandleScanner(scope, format, payload));
|
|
45
|
+
dispatch(historyReplace({
|
|
46
|
+
pathname: link
|
|
47
|
+
}));
|
|
48
|
+
break;
|
|
49
|
+
case QR_CODE_TYPE_SEARCH:
|
|
50
|
+
if (await dispatch(handleSearch(data.searchPhrase || ''))) {
|
|
51
|
+
dispatch(successHandleScanner(scope, format, payload));
|
|
52
|
+
} else {
|
|
53
|
+
notFound();
|
|
54
|
+
}
|
|
55
|
+
break;
|
|
56
|
+
case QR_CODE_TYPE_COUPON:
|
|
57
|
+
dispatch(successHandleScanner(scope, format, payload));
|
|
58
|
+
dispatch(historyReplace({
|
|
59
|
+
pathname: link
|
|
60
|
+
}));
|
|
61
|
+
dispatch(historyPop());
|
|
62
|
+
break;
|
|
63
|
+
case QR_CODE_TYPE_PRODUCT:
|
|
64
|
+
case QR_CODE_TYPE_PRODUCT_WITH_COUPON:
|
|
65
|
+
// Force to fetch missing products
|
|
66
|
+
await dispatch(fetchProductsById([data.productId]));
|
|
67
|
+
|
|
68
|
+
// Check from a store
|
|
69
|
+
if (!getProductById(getState(), data)) {
|
|
70
|
+
notFound();
|
|
71
|
+
} else {
|
|
72
|
+
dispatch(successHandleScanner(scope, format, payload));
|
|
73
|
+
dispatch(historyReplace({
|
|
74
|
+
pathname: link
|
|
75
|
+
}));
|
|
76
|
+
}
|
|
77
|
+
break;
|
|
78
|
+
case QR_CODE_TYPE_CATEGORY:
|
|
79
|
+
await dispatch(fetchCategory(data.categoryId));
|
|
80
|
+
if (!getCategory(getState(), data)) {
|
|
81
|
+
notFound();
|
|
82
|
+
} else {
|
|
83
|
+
dispatch(successHandleScanner(scope, format, payload));
|
|
84
|
+
dispatch(historyReplace({
|
|
85
|
+
pathname: link
|
|
86
|
+
}));
|
|
87
|
+
}
|
|
88
|
+
break;
|
|
89
|
+
case QR_CODE_TYPE_PAGE:
|
|
90
|
+
// Force to fetch missing products
|
|
91
|
+
await dispatch(fetchPageConfig(data.pageId));
|
|
92
|
+
if (!makeGetUnifiedCMSPageData({
|
|
93
|
+
slug: data.pageId
|
|
94
|
+
})(getState())) {
|
|
95
|
+
notFound();
|
|
96
|
+
} else {
|
|
97
|
+
dispatch(successHandleScanner(scope, format, payload));
|
|
98
|
+
dispatch(historyReplace({
|
|
99
|
+
pathname: link
|
|
100
|
+
}));
|
|
101
|
+
}
|
|
102
|
+
break;
|
|
103
|
+
default:
|
|
104
|
+
{
|
|
105
|
+
if (isHTTPS(payload)) {
|
|
106
|
+
dispatch(successHandleScanner(scope, format, payload));
|
|
107
|
+
// Open external link in in-app browser
|
|
108
|
+
dispatch(historyPush({
|
|
109
|
+
pathname: payload
|
|
110
|
+
}));
|
|
111
|
+
// Remove the scanner screen from the history
|
|
112
|
+
dispatch(historyPop());
|
|
113
|
+
} else {
|
|
114
|
+
notFound();
|
|
115
|
+
}
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return null;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
/** @mixes {MutableFunction} */
|
|
123
|
+
export default mutable(handleQrCode);
|
|
@@ -1,6 +1,37 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { historyReplace } from '@shopgate/pwa-common/actions/router';
|
|
2
|
+
import { mutable } from '@shopgate/pwa-common/helpers/redux';
|
|
3
|
+
import fetchProductsByQuery from '@shopgate/pwa-common-commerce/product/actions/fetchProductsByQuery';
|
|
4
|
+
import { getProductRoute } from '@shopgate/pwa-common-commerce/product/helpers';
|
|
5
|
+
import { getSearchRoute } from '@shopgate/pwa-common-commerce/search/helpers';
|
|
6
|
+
|
|
7
|
+
/**
|
|
2
8
|
* Handle product search. The thunk will return false if nothing was found or true if it processed
|
|
3
9
|
* the action as it should.
|
|
4
10
|
* @param {string} searchPhrase The search phrase.
|
|
5
11
|
* @return {Function} A redux thunk.
|
|
6
|
-
*/
|
|
12
|
+
*/
|
|
13
|
+
const handleSearch = searchPhrase => async dispatch => {
|
|
14
|
+
const {
|
|
15
|
+
products = []
|
|
16
|
+
} = await dispatch(fetchProductsByQuery(2, searchPhrase));
|
|
17
|
+
|
|
18
|
+
// Redirect to product when only one was found and to search for more. Abort on no results.
|
|
19
|
+
if (!products.length) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
if (products.length === 1) {
|
|
23
|
+
const [first] = products;
|
|
24
|
+
const productId = typeof first === 'string' ? first : first.id;
|
|
25
|
+
dispatch(historyReplace({
|
|
26
|
+
pathname: getProductRoute(productId)
|
|
27
|
+
}));
|
|
28
|
+
} else {
|
|
29
|
+
dispatch(historyReplace({
|
|
30
|
+
pathname: getSearchRoute(searchPhrase)
|
|
31
|
+
}));
|
|
32
|
+
}
|
|
33
|
+
return true;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/** @mixes {MutableFunction} */
|
|
37
|
+
export default mutable(handleSearch);
|
|
@@ -1 +1,22 @@
|
|
|
1
|
-
import{BEFORE,AFTER}from'@shopgate/pwa-common/constants/Portals';
|
|
1
|
+
import { BEFORE, AFTER } from '@shopgate/pwa-common/constants/Portals';
|
|
2
|
+
const SCANNER = 'scanner';
|
|
3
|
+
const ICON = 'icon';
|
|
4
|
+
const CAMERA = 'camera';
|
|
5
|
+
const BAR = 'bar';
|
|
6
|
+
const FLASH = 'flash';
|
|
7
|
+
const INSTRUCTIONS = 'instructions';
|
|
8
|
+
export const SCANNER_ICON_BEFORE = `${SCANNER}.${ICON}.${BEFORE}`;
|
|
9
|
+
export const SCANNER_ICON = `${SCANNER}.${ICON}`;
|
|
10
|
+
export const SCANNER_ICON_AFTER = `${SCANNER}.${ICON}.${AFTER}`;
|
|
11
|
+
export const SCANNER_CAMERA_BEFORE = `${SCANNER}.${CAMERA}.${BEFORE}`;
|
|
12
|
+
export const SCANNER_CAMERA = `${SCANNER}.${CAMERA}`;
|
|
13
|
+
export const SCANNER_CAMERA_AFTER = `${SCANNER}.${CAMERA}.${AFTER}`;
|
|
14
|
+
export const SCANNER_BAR_BEFORE = `${SCANNER}.${BAR}.${BEFORE}`;
|
|
15
|
+
export const SCANNER_BAR = `${SCANNER}.${BAR}`;
|
|
16
|
+
export const SCANNER_BAR_AFTER = `${SCANNER}.${BAR}.${AFTER}`;
|
|
17
|
+
export const SCANNER_FLASH_BEFORE = `${SCANNER}.${FLASH}.${BEFORE}`;
|
|
18
|
+
export const SCANNER_FLASH = `${SCANNER}.${FLASH}`;
|
|
19
|
+
export const SCANNER_FLASH_AFTER = `${SCANNER}.${FLASH}.${AFTER}`;
|
|
20
|
+
export const SCANNER_INSTRUCTIONS_BEFORE = `${SCANNER}.${INSTRUCTIONS}.${BEFORE}`;
|
|
21
|
+
export const SCANNER_INSTRUCTIONS = `${SCANNER}.${INSTRUCTIONS}`;
|
|
22
|
+
export const SCANNER_INSTRUCTIONS_AFTER = `${SCANNER}.${INSTRUCTIONS}.${AFTER}`;
|
|
@@ -1 +1,17 @@
|
|
|
1
|
-
export
|
|
1
|
+
export const START_SCANNER = 'START_SCANNER';
|
|
2
|
+
export const SCANNER_STARTED = 'SCANNER_STARTED';
|
|
3
|
+
export const SCANNER_CANCELLED = 'SCANNER_CANCELLED';
|
|
4
|
+
export const SCANNER_FINISHED = 'SCANNER_FINISHED';
|
|
5
|
+
export const SUCCESS_HANDLE_SCANNER = 'SUCCESS_HANDLE_SCANNER';
|
|
6
|
+
export const ERROR_HANDLE_SCANNER = 'ERROR_HANDLE_SCANNER';
|
|
7
|
+
export const SCANNER_PATH = '/scanner';
|
|
8
|
+
export const QR_CODE_TYPE_COUPON = '2';
|
|
9
|
+
export const QR_CODE_TYPE_HOMEPAGE = '5';
|
|
10
|
+
export const QR_CODE_TYPE_PRODUCT = '7';
|
|
11
|
+
export const QR_CODE_TYPE_PRODUCT_WITH_COUPON = '9';
|
|
12
|
+
export const QR_CODE_TYPE_CATEGORY = 'e';
|
|
13
|
+
export const QR_CODE_TYPE_SEARCH = 'b';
|
|
14
|
+
export const QR_CODE_TYPE_PAGE = '1';
|
|
15
|
+
export const QR_CODE_HOST_2DS = '2d.is';
|
|
16
|
+
export const SCANNER_FORMATS_BARCODE = ['UPC_E', 'CODE_39', 'EAN_13', 'EAN_8', 'CODE_93', 'CODE_128', 'PDF_417', 'ITF', 'DATA_MATRIX'];
|
|
17
|
+
export const SCANNER_FORMATS_QR_CODE = ['QR_CODE'];
|
package/scanner/helpers/index.js
CHANGED
|
@@ -1,17 +1,127 @@
|
|
|
1
|
-
|
|
1
|
+
import "core-js/modules/web.url.js";
|
|
2
|
+
import "core-js/modules/web.url.to-json.js";
|
|
3
|
+
import "core-js/modules/web.url-search-params.js";
|
|
4
|
+
import { SCANNER_SCOPE_DEFAULT, SCANNER_TYPE_BARCODE } from '@shopgate/pwa-core/constants/Scanner';
|
|
5
|
+
import { getCategoryRoute } from '@shopgate/pwa-common-commerce/category';
|
|
6
|
+
import { getProductRoute } from '@shopgate/pwa-common-commerce/product';
|
|
7
|
+
import { getSearchRoute } from '@shopgate/pwa-common-commerce/search';
|
|
8
|
+
import { QR_CODE_TYPE_HOMEPAGE, QR_CODE_TYPE_PRODUCT, QR_CODE_TYPE_PRODUCT_WITH_COUPON, QR_CODE_TYPE_COUPON, QR_CODE_TYPE_CATEGORY, QR_CODE_TYPE_SEARCH, QR_CODE_TYPE_PAGE, QR_CODE_HOST_2DS, SCANNER_PATH } from "../constants";
|
|
9
|
+
|
|
10
|
+
/**
|
|
2
11
|
* Set of parsers of different types
|
|
3
|
-
*/
|
|
12
|
+
*/
|
|
13
|
+
const typeParsers = {
|
|
14
|
+
[QR_CODE_TYPE_HOMEPAGE]: () => ({
|
|
15
|
+
link: '/'
|
|
16
|
+
}),
|
|
17
|
+
[QR_CODE_TYPE_PRODUCT]: url => {
|
|
18
|
+
const [,,, paramTwo] = url.pathname.split('/');
|
|
19
|
+
const decodedParamTwo = decodeURIComponent(decodeURIComponent(paramTwo));
|
|
20
|
+
return {
|
|
21
|
+
link: getProductRoute(decodedParamTwo),
|
|
22
|
+
data: {
|
|
23
|
+
productId: decodedParamTwo
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
},
|
|
27
|
+
[QR_CODE_TYPE_PRODUCT_WITH_COUPON]: url => {
|
|
28
|
+
const [,,, paramTwo, paramThree] = url.pathname.split('/');
|
|
29
|
+
const decodedParamTwo = decodeURIComponent(decodeURIComponent(paramTwo));
|
|
30
|
+
const decodedParamThree = decodeURIComponent(decodeURIComponent(paramThree));
|
|
31
|
+
return {
|
|
32
|
+
link: `/cart_add_product/${encodeURIComponent(decodedParamTwo)}/${encodeURIComponent(decodedParamThree)}`,
|
|
33
|
+
data: {
|
|
34
|
+
productId: decodedParamTwo,
|
|
35
|
+
couponCode: decodedParamThree
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
},
|
|
39
|
+
[QR_CODE_TYPE_COUPON]: url => {
|
|
40
|
+
const [,, paramOne] = url.pathname.split('/');
|
|
41
|
+
return {
|
|
42
|
+
link: `/cart_add_coupon/${paramOne}`,
|
|
43
|
+
data: {
|
|
44
|
+
couponCode: paramOne
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
},
|
|
48
|
+
[QR_CODE_TYPE_CATEGORY]: url => {
|
|
49
|
+
const [,,, paramTwo] = url.pathname.split('/');
|
|
50
|
+
const decodedParamTwo = decodeURIComponent(decodeURIComponent(paramTwo));
|
|
51
|
+
return {
|
|
52
|
+
link: getCategoryRoute(decodedParamTwo),
|
|
53
|
+
data: {
|
|
54
|
+
categoryId: decodedParamTwo
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
},
|
|
58
|
+
[QR_CODE_TYPE_SEARCH]: url => {
|
|
59
|
+
const [,,, paramTwo] = url.pathname.split('/');
|
|
60
|
+
const decodedParamTwo = decodeURIComponent(decodeURIComponent(paramTwo));
|
|
61
|
+
return {
|
|
62
|
+
link: getSearchRoute(decodedParamTwo),
|
|
63
|
+
data: {
|
|
64
|
+
searchPhrase: decodedParamTwo
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
},
|
|
68
|
+
[QR_CODE_TYPE_PAGE]: url => {
|
|
69
|
+
const [,,, paramTwo] = url.pathname.split('/');
|
|
70
|
+
const decodedParamTwo = decodeURIComponent(decodeURIComponent(paramTwo));
|
|
71
|
+
return {
|
|
72
|
+
link: `/page/${decodedParamTwo}`,
|
|
73
|
+
data: {
|
|
74
|
+
pageId: decodedParamTwo
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
/**
|
|
4
81
|
* Check if links is 2ds.
|
|
5
82
|
* @param {string} code The string from the QR Code
|
|
6
83
|
* @returns {boolean}
|
|
7
|
-
*/
|
|
84
|
+
*/
|
|
85
|
+
export const is2dsQrCode = code => {
|
|
86
|
+
try {
|
|
87
|
+
return new URL(code).host === QR_CODE_HOST_2DS;
|
|
88
|
+
} catch (e) {
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
/**
|
|
8
94
|
* Parses 2ds QR Codes.
|
|
9
95
|
* Generates a deeplink which can be used to open pages.
|
|
10
96
|
* @param {string} code The string from the QR Code.
|
|
11
97
|
* @returns {?{type, link, data}} The parsed type, link, data
|
|
12
|
-
*/
|
|
98
|
+
*/
|
|
99
|
+
export const parse2dsQrCode = code => {
|
|
100
|
+
if (!is2dsQrCode(code)) {
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
const url = new URL(code);
|
|
104
|
+
const [, type] = url.pathname.split('/');
|
|
105
|
+
let link = '/';
|
|
106
|
+
let data = {};
|
|
107
|
+
const typeParser = typeParsers[type];
|
|
108
|
+
if (typeParser) {
|
|
109
|
+
({
|
|
110
|
+
link,
|
|
111
|
+
data = {}
|
|
112
|
+
} = typeParser(url));
|
|
113
|
+
}
|
|
114
|
+
return {
|
|
115
|
+
type,
|
|
116
|
+
link,
|
|
117
|
+
data
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
/**
|
|
13
122
|
* Create a link to the scanner route.
|
|
14
123
|
* @param {string} [scope=SCANNER_SCOPE_DEFAULT] The scanner scope to use for the scanner page
|
|
15
124
|
* @param {string} [type=SCANNER_TYPE_BARCODE] The scanner type to use on the scanner page
|
|
16
125
|
* @returns {string}
|
|
17
|
-
*/
|
|
126
|
+
*/
|
|
127
|
+
export const getScannerRoute = (scope = SCANNER_SCOPE_DEFAULT, type = SCANNER_TYPE_BARCODE) => `${SCANNER_PATH}?scope=${scope}&type=${type}`;
|
package/scanner/index.js
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
// ACTION-CREATORS
|
|
2
|
-
export{default as startScanner}from"./action-creators/startScanner";
|
|
3
|
-
export{default as
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
export { default as startScanner } from "./action-creators/startScanner";
|
|
3
|
+
export { default as successHandleScanner } from "./action-creators/successHandleScanner";
|
|
4
|
+
export { default as errorHandleScanner } from "./action-creators/errorHandleScanner";
|
|
5
|
+
|
|
6
|
+
// ACTIONS
|
|
7
|
+
export { default as handleBarCode } from "./actions/handleBarCode";
|
|
8
|
+
export { default as handleQrCode } from "./actions/handleQrCode";
|
|
9
|
+
export { default as handleSearch } from "./actions/handleSearch";
|
|
10
|
+
export { default as handleNoResults } from "./actions/handleNoResults";
|
|
11
|
+
|
|
12
|
+
// CONSTANTS
|
|
13
|
+
export * from "./constants";
|
|
14
|
+
export * from "./constants/Portals";
|
|
15
|
+
|
|
16
|
+
// HELPERS
|
|
17
|
+
export * from "./helpers";
|
|
18
|
+
|
|
19
|
+
// STREAMS
|
|
20
|
+
export * from "./streams";
|
package/scanner/streams/index.js
CHANGED
|
@@ -1 +1,36 @@
|
|
|
1
|
-
import{main$}from'@shopgate/pwa-common/streams/main';
|
|
1
|
+
import { main$ } from '@shopgate/pwa-common/streams/main';
|
|
2
|
+
import { routeDidEnter$ } from '@shopgate/pwa-common/streams/router';
|
|
3
|
+
import { START_SCANNER, SCANNER_STARTED, SCANNER_CANCELLED, SCANNER_FINISHED, SCANNER_PATH, SCANNER_FORMATS_BARCODE, SCANNER_FORMATS_QR_CODE } from "../constants";
|
|
4
|
+
|
|
5
|
+
/** @type {Observable} */
|
|
6
|
+
export const scannerDidEnter$ = routeDidEnter$.filter(({
|
|
7
|
+
action
|
|
8
|
+
}) => action.route.pathname === SCANNER_PATH);
|
|
9
|
+
export const startScanner$ = main$.filter(({
|
|
10
|
+
action
|
|
11
|
+
}) => action.type === START_SCANNER);
|
|
12
|
+
|
|
13
|
+
/** @type {Observable} */
|
|
14
|
+
export const scannerStarted$ = main$.filter(({
|
|
15
|
+
action
|
|
16
|
+
}) => action.type === SCANNER_STARTED);
|
|
17
|
+
|
|
18
|
+
/** @type {Observable} */
|
|
19
|
+
export const scannerCancelled$ = main$.filter(({
|
|
20
|
+
action
|
|
21
|
+
}) => action.type === SCANNER_CANCELLED);
|
|
22
|
+
|
|
23
|
+
/** @type {Observable} */
|
|
24
|
+
export const scannerFinished$ = main$.filter(({
|
|
25
|
+
action
|
|
26
|
+
}) => action.type === SCANNER_FINISHED);
|
|
27
|
+
|
|
28
|
+
/** @type {Observable} */
|
|
29
|
+
export const scannerFinishedBarCode$ = scannerFinished$.filter(({
|
|
30
|
+
action
|
|
31
|
+
}) => SCANNER_FORMATS_BARCODE.includes(action.format));
|
|
32
|
+
|
|
33
|
+
/** @type {Observable} */
|
|
34
|
+
export const scannerFinishedQrCode$ = scannerFinished$.filter(({
|
|
35
|
+
action
|
|
36
|
+
}) => SCANNER_FORMATS_QR_CODE.includes(action.format));
|
|
@@ -1,10 +1,80 @@
|
|
|
1
|
-
import Scanner from
|
|
2
|
-
|
|
1
|
+
import Scanner from '@shopgate/pwa-core/classes/Scanner';
|
|
2
|
+
import ScannerEventListener from '@shopgate/pwa-core/classes/ScannerEventListener';
|
|
3
|
+
import { SCANNER_SCOPE_DEFAULT } from '@shopgate/pwa-core/constants/Scanner';
|
|
4
|
+
import { appDidStart$ } from '@shopgate/pwa-common/streams';
|
|
5
|
+
import scannerFinished from "../action-creators/scannerFinished";
|
|
6
|
+
import handleBarCode from "../actions/handleBarCode";
|
|
7
|
+
import handleQrCode from "../actions/handleQrCode";
|
|
8
|
+
import { SCANNER_FORMATS_BARCODE, SCANNER_FORMATS_QR_CODE } from "../constants";
|
|
9
|
+
import { startScanner$, scannerFinishedBarCode$, scannerFinishedQrCode$ } from "../streams";
|
|
10
|
+
|
|
11
|
+
// Scanner payload formats which are handled by the subscriptions.
|
|
12
|
+
export const handledFormats = [...SCANNER_FORMATS_BARCODE, ...SCANNER_FORMATS_QR_CODE];
|
|
13
|
+
|
|
14
|
+
/**
|
|
3
15
|
* Scanner subscriptions.
|
|
4
16
|
* @param {Function} subscribe The subscribe function.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
subscribe(
|
|
9
|
-
|
|
10
|
-
|
|
17
|
+
*/
|
|
18
|
+
export default subscribe => {
|
|
19
|
+
// Register global listener to convert to stream
|
|
20
|
+
subscribe(appDidStart$, ({
|
|
21
|
+
dispatch
|
|
22
|
+
}) => {
|
|
23
|
+
Scanner.addListener(new ScannerEventListener('Scanner listener', null, null, handledFormats).setHandler(({
|
|
24
|
+
scope,
|
|
25
|
+
payload: {
|
|
26
|
+
format,
|
|
27
|
+
code: payload
|
|
28
|
+
} = {}
|
|
29
|
+
}) => {
|
|
30
|
+
dispatch(scannerFinished(scope, format, payload));
|
|
31
|
+
}));
|
|
32
|
+
});
|
|
33
|
+
subscribe(startScanner$, () => {
|
|
34
|
+
Scanner.start();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
// Default scope stream
|
|
38
|
+
const scannerFinishedBarCodeDefault$ = scannerFinishedBarCode$.filter(({
|
|
39
|
+
action
|
|
40
|
+
}) => action.scope === SCANNER_SCOPE_DEFAULT);
|
|
41
|
+
|
|
42
|
+
// Default scope bar code handler
|
|
43
|
+
subscribe(scannerFinishedBarCodeDefault$, ({
|
|
44
|
+
dispatch,
|
|
45
|
+
action
|
|
46
|
+
}) => {
|
|
47
|
+
const {
|
|
48
|
+
scope,
|
|
49
|
+
format,
|
|
50
|
+
payload
|
|
51
|
+
} = action;
|
|
52
|
+
dispatch(handleBarCode({
|
|
53
|
+
scope,
|
|
54
|
+
format,
|
|
55
|
+
payload
|
|
56
|
+
}));
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
// Default scope qr code stream
|
|
60
|
+
const scannerFinishedQrCodeDefault$ = scannerFinishedQrCode$.filter(({
|
|
61
|
+
action
|
|
62
|
+
}) => action.scope === SCANNER_SCOPE_DEFAULT);
|
|
63
|
+
|
|
64
|
+
// Default scope qr code handler
|
|
65
|
+
subscribe(scannerFinishedQrCodeDefault$, ({
|
|
66
|
+
dispatch,
|
|
67
|
+
action
|
|
68
|
+
}) => {
|
|
69
|
+
const {
|
|
70
|
+
scope,
|
|
71
|
+
format,
|
|
72
|
+
payload
|
|
73
|
+
} = action;
|
|
74
|
+
dispatch(handleQrCode({
|
|
75
|
+
scope,
|
|
76
|
+
format,
|
|
77
|
+
payload
|
|
78
|
+
}));
|
|
79
|
+
});
|
|
80
|
+
};
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
import{ERROR_SEARCH_RESULTS}from"../constants"
|
|
1
|
+
import { ERROR_SEARCH_RESULTS } from "../constants";
|
|
2
|
+
|
|
3
|
+
/**
|
|
2
4
|
* Creates the dispatched ERROR_SEARCH_RESULTS action object.
|
|
3
5
|
* @param {string} searchPhrase The search phrase.
|
|
4
6
|
* @param {number} offset The result offset.
|
|
5
7
|
* @return {Object} The ERROR_SEARCH_RESULTS action.
|
|
6
|
-
*/
|
|
8
|
+
*/
|
|
9
|
+
const errorSearchResults = (searchPhrase, offset) => ({
|
|
10
|
+
type: ERROR_SEARCH_RESULTS,
|
|
11
|
+
searchPhrase,
|
|
12
|
+
offset
|
|
13
|
+
});
|
|
14
|
+
export default errorSearchResults;
|