@shopgate/pwa-common-commerce 7.24.5 → 7.24.7-beta.1
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shopgate/pwa-common-commerce",
|
|
3
|
-
"version": "7.24.
|
|
3
|
+
"version": "7.24.7-beta.1",
|
|
4
4
|
"description": "Commerce library for the Shopgate Connect PWA.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Shopgate <support@shopgate.com>",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"reselect": "^4.1.8"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@shopgate/pwa-common": "7.24.
|
|
23
|
-
"@shopgate/pwa-core": "7.24.
|
|
22
|
+
"@shopgate/pwa-common": "7.24.7-beta.1",
|
|
23
|
+
"@shopgate/pwa-core": "7.24.7-beta.1",
|
|
24
24
|
"lodash": "^4.17.4",
|
|
25
25
|
"react": "~16.14.0",
|
|
26
26
|
"react-dom": "~16.14.0"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import _regeneratorRuntime from"@babel/runtime/regenerator";function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}import{historyPop,historyReplace}from'@shopgate/
|
|
1
|
+
import _regeneratorRuntime from"@babel/runtime/regenerator";function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}import{historyPop,historyReplace,historyPush}from'@shopgate/engage/core/actions';import{fetchPageConfig}from'@shopgate/engage/page/actions';import{getPageConfigById}from'@shopgate/engage/page/selectors';import{fetchProductsById}from'@shopgate/engage/product';import{getProductById}from'@shopgate/engage/product/selectors/product';import{fetchCategory}from'@shopgate/engage/category/actions';import{getCategory}from'@shopgate/engage/category/selectors';import{isHTTPS,mutable}from'@shopgate/engage/core/helpers';import successHandleScanner from"../action-creators/successHandleScanner";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";import{parse2dsQrCode}from"../helpers";import handleSearch from"./handleSearch";import handleNoResults from"./handleNoResults";/**
|
|
2
2
|
* Handle qr code
|
|
3
3
|
* @param {string} event.scope Scanner scope.
|
|
4
4
|
* @param {string} event.format Format of the scanned code.
|
|
@@ -7,5 +7,7 @@ import _regeneratorRuntime from"@babel/runtime/regenerator";function asyncGenera
|
|
|
7
7
|
*/var handleQrCode=function handleQrCode(_ref){var scope=_ref.scope,format=_ref.format,payload=_ref.payload;return(/*#__PURE__*/function(){var _ref2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(dispatch,getState){var _ref3,type,link,data,notFound;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:_ref3=parse2dsQrCode(payload)||{},type=_ref3.type,link=_ref3.link,data=_ref3.data;/**
|
|
8
8
|
* Helper function to handle no scan results
|
|
9
9
|
* @return {Function}
|
|
10
|
-
*/notFound=function notFound(){return dispatch(handleNoResults({scope:scope,format:format,payload:payload},'scanner.noResult.qrCode'));};_context.t0=type;_context.next=_context.t0===QR_CODE_TYPE_HOMEPAGE?5:_context.t0===QR_CODE_TYPE_SEARCH?8:_context.t0===QR_CODE_TYPE_COUPON?16:_context.t0===QR_CODE_TYPE_PRODUCT?20:_context.t0===QR_CODE_TYPE_PRODUCT_WITH_COUPON?20:_context.t0===QR_CODE_TYPE_CATEGORY?24:_context.t0===QR_CODE_TYPE_PAGE?28:32;break;case 5:dispatch(successHandleScanner(scope,format,payload));dispatch(historyReplace({pathname:link}));return _context.abrupt("break",
|
|
11
|
-
if(!getProductById(getState(),data)){notFound();}else{dispatch(successHandleScanner(scope,format,payload));dispatch(historyReplace({pathname:link}));}return _context.abrupt("break",
|
|
10
|
+
*/notFound=function notFound(){return dispatch(handleNoResults({scope:scope,format:format,payload:payload},'scanner.noResult.qrCode'));};_context.t0=type;_context.next=_context.t0===QR_CODE_TYPE_HOMEPAGE?5:_context.t0===QR_CODE_TYPE_SEARCH?8:_context.t0===QR_CODE_TYPE_COUPON?16:_context.t0===QR_CODE_TYPE_PRODUCT?20:_context.t0===QR_CODE_TYPE_PRODUCT_WITH_COUPON?20:_context.t0===QR_CODE_TYPE_CATEGORY?24:_context.t0===QR_CODE_TYPE_PAGE?28:32;break;case 5:dispatch(successHandleScanner(scope,format,payload));dispatch(historyReplace({pathname:link}));return _context.abrupt("break",34);case 8:_context.next=10;return dispatch(handleSearch(data.searchPhrase||''));case 10:if(!_context.sent){_context.next=14;break;}dispatch(successHandleScanner(scope,format,payload));_context.next=15;break;case 14:notFound();case 15:return _context.abrupt("break",34);case 16:dispatch(successHandleScanner(scope,format,payload));dispatch(historyReplace({pathname:link}));dispatch(historyPop());return _context.abrupt("break",34);case 20:_context.next=22;return dispatch(fetchProductsById([data.productId]));case 22:// Check from a store
|
|
11
|
+
if(!getProductById(getState(),data)){notFound();}else{dispatch(successHandleScanner(scope,format,payload));dispatch(historyReplace({pathname:link}));}return _context.abrupt("break",34);case 24:_context.next=26;return dispatch(fetchCategory(data.categoryId));case 26:if(!getCategory(getState(),data)){notFound();}else{dispatch(successHandleScanner(scope,format,payload));dispatch(historyReplace({pathname:link}));}return _context.abrupt("break",34);case 28:_context.next=30;return dispatch(fetchPageConfig(data.pageId));case 30:if(!getPageConfigById(getState(),data)){notFound();}else{dispatch(successHandleScanner(scope,format,payload));dispatch(historyReplace({pathname:link}));}return _context.abrupt("break",34);case 32:if(isHTTPS(payload)){dispatch(successHandleScanner(scope,format,payload));// Open external link in in-app browser
|
|
12
|
+
dispatch(historyPush({pathname:payload}));// Remove the scanner screen from the history
|
|
13
|
+
dispatch(historyPop());}else{notFound();}return _context.abrupt("break",34);case 34:return _context.abrupt("return",null);case 35:case"end":return _context.stop();}},_callee);}));return function(_x,_x2){return _ref2.apply(this,arguments);};}());};/** @mixes {MutableFunction} */export default mutable(handleQrCode);
|