@shopgate/pwa-common-commerce 7.5.0-beta.1 → 7.5.0-beta.5
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.5.0-beta.
|
|
3
|
+
"version": "7.5.0-beta.5",
|
|
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": "^3.0.1"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@shopgate/pwa-common": "7.5.0-beta.
|
|
23
|
-
"@shopgate/pwa-core": "7.5.0-beta.
|
|
22
|
+
"@shopgate/pwa-common": "7.5.0-beta.5",
|
|
23
|
+
"@shopgate/pwa-core": "7.5.0-beta.5",
|
|
24
24
|
"lodash": "^4.17.4",
|
|
25
25
|
"react": "~16.12.0",
|
|
26
26
|
"react-dom": "~16.12.0"
|
|
@@ -198,7 +198,7 @@ var _product$baseProductI=product.baseProductId,baseProductId=_product$baseProdu
|
|
|
198
198
|
* @return {Array|null}
|
|
199
199
|
*/export var getProductImages=createSelector(getProductImagesState,getProductId,getBaseProductId,function(images,productId,baseProductId){var _ref4=images[productId]||{},productImages=_ref4.images,isFetching=_ref4.isFetching;if(isFetching){return null;}// If the product doesn't have images after fetching
|
|
200
200
|
if(baseProductId&&(!Array.isArray(productImages)||!productImages.length)){// ...check the base product.
|
|
201
|
-
var _ref5=images[baseProductId]||{},baseProductImages=_ref5.images;if(!Array.isArray(baseProductImages)||!baseProductImages.length){return null;}return baseProductImages;}return productImages||null;});/**
|
|
201
|
+
var _ref5=images[baseProductId]||{},baseProductImages=_ref5.images;if(!Array.isArray(baseProductImages)||!baseProductImages.length){return null;}return baseProductImages;}return productImages||null;});export var getFeaturedImage=createSelector(getProduct,getBaseProduct,function(product,baseProduct){var productImage=null;var baseProductImage=null;if(Array.isArray(product===null||product===void 0?void 0:product.featuredMedia)){productImage=product.featuredMedia.type==='image'?product.featuredMedia.url:null;}if(Array.isArray(baseProduct===null||baseProduct===void 0?void 0:baseProduct.featuredMedia)){baseProductImage=baseProduct.featuredMedia.type==='image'?baseProduct.featuredMedia.url:null;}return productImage||baseProductImage||(product===null||product===void 0?void 0:product.featuredImageBaseUrl)||(product===null||product===void 0?void 0:product.featuredImageUrl);});/**
|
|
202
202
|
* Retrieves the product variant data.
|
|
203
203
|
* @param {Object} state The current application state.
|
|
204
204
|
* @param {Object} props The component props.
|
|
@@ -1,7 +1,7 @@
|
|
|
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 handleSearch from"./handleSearch";import handleNoResults from"./handleNoResults";import successHandleScanner from"../action-creators/successHandleScanner";/**
|
|
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{mutable}from'@shopgate/pwa-common/helpers/redux';import handleSearch from"./handleSearch";import handleNoResults from"./handleNoResults";import successHandleScanner from"../action-creators/successHandleScanner";/**
|
|
2
2
|
* Handle bar code
|
|
3
3
|
* @param {ScannerEvent} event Scanner event that emitted.
|
|
4
4
|
* @param {string} format Format of the scanned code.
|
|
5
5
|
* @param {string} payload Barcode payload.
|
|
6
6
|
* @return {Function} A redux thunk.
|
|
7
|
-
*/
|
|
7
|
+
*/var handleBarCode=function handleBarCode(event){return(/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(dispatch){var scope,format,payload;return _regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:scope=event.scope,format=event.format,payload=event.payload;_context.next=3;return dispatch(handleSearch(payload));case 3:if(!_context.sent){_context.next=7;break;}dispatch(successHandleScanner(scope,format,payload));_context.next=8;break;case 7:dispatch(handleNoResults(event,'scanner.noResult.barCode'));case 8:case"end":return _context.stop();}}},_callee);}));return function(_x){return _ref.apply(this,arguments);};}());};/** @mixes {MutableFunction} */export default mutable(handleBarCode);
|
|
@@ -1,8 +1,8 @@
|
|
|
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 showModal from'@shopgate/pwa-common/actions/modal/showModal';import Scanner from'@shopgate/pwa-core/classes/Scanner';import errorHandleScanner from"../action-creators/errorHandleScanner";/**
|
|
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 showModal from'@shopgate/pwa-common/actions/modal/showModal';import{mutable}from'@shopgate/pwa-common/helpers/redux';import Scanner from'@shopgate/pwa-core/classes/Scanner';import errorHandleScanner from"../action-creators/errorHandleScanner";/**
|
|
2
2
|
* Handle no results
|
|
3
3
|
* @param {string} event.scope Scanner scope.
|
|
4
4
|
* @param {string} event.format Format of the scanned code.
|
|
5
5
|
* @param {string} event.payload Barcode payload.
|
|
6
6
|
* @param {string} message The message to display.
|
|
7
7
|
* @return {Function} A redux thunk.
|
|
8
|
-
*/
|
|
8
|
+
*/var handleNoResult=function handleNoResult(_ref,message){var scope=_ref.scope,format=_ref.format,payload=_ref.payload;return(/*#__PURE__*/function(){var _ref2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(dispatch){return _regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:dispatch(errorHandleScanner(scope,format,payload));dispatch(showModal({dismiss:null,confirm:'modal.ok',title:'modal.title_error',message:message})).then(function(confirmed){return confirmed&&Scanner.start();});case 2:case"end":return _context.stop();}}},_callee);}));return function(_x){return _ref2.apply(this,arguments);};}());};/** @mixes {MutableFunction} */export default mutable(handleNoResult);
|
|
@@ -1,11 +1,11 @@
|
|
|
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/pwa-common/actions/router';import{fetchPageConfig}from'@shopgate/pwa-common/actions/page';import{getPageConfigById}from'@shopgate/pwa-common/selectors/page';import{fetchProductsById,getProductById}from'@shopgate/pwa-common-commerce/product';import{fetchCategory,getCategory}from'@shopgate/pwa-common-commerce/category';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";/**
|
|
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/pwa-common/actions/router';import{fetchPageConfig}from'@shopgate/pwa-common/actions/page';import{getPageConfigById}from'@shopgate/pwa-common/selectors/page';import{mutable}from'@shopgate/pwa-common/helpers/redux';import{fetchProductsById,getProductById}from'@shopgate/pwa-common-commerce/product';import{fetchCategory,getCategory}from'@shopgate/pwa-common-commerce/category';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.
|
|
5
5
|
* @param {string} event.payload Barcode payload.
|
|
6
6
|
* @return {Function} A redux thunk.
|
|
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
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",33);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",33);case 16:dispatch(successHandleScanner(scope,format,payload));dispatch(historyReplace({pathname:link}));dispatch(historyPop());return _context.abrupt("break",33);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",33);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",33);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",33);case 32:notFound();case 33:return _context.abrupt("return",null);case 34:case"end":return _context.stop();}}},_callee);}));return function(_x,_x2){return _ref2.apply(this,arguments);};}());});
|
|
11
|
+
if(!getProductById(getState(),data)){notFound();}else{dispatch(successHandleScanner(scope,format,payload));dispatch(historyReplace({pathname:link}));}return _context.abrupt("break",33);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",33);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",33);case 32:notFound();case 33:return _context.abrupt("return",null);case 34:case"end":return _context.stop();}}},_callee);}));return function(_x,_x2){return _ref2.apply(this,arguments);};}());};/** @mixes {MutableFunction} */export default mutable(handleQrCode);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import _regeneratorRuntime from"@babel/runtime/regenerator";function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance");}function _iterableToArrayLimit(arr,i){var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[Symbol.iterator](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}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{historyReplace}from'@shopgate/pwa-common/actions/router';import fetchProductsByQuery from'@shopgate/pwa-common-commerce/product/actions/fetchProductsByQuery';import{getProductRoute}from'@shopgate/pwa-common-commerce/product/helpers';import{getSearchRoute}from'@shopgate/pwa-common-commerce/search/helpers';/**
|
|
1
|
+
import _regeneratorRuntime from"@babel/runtime/regenerator";function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance");}function _iterableToArrayLimit(arr,i){var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[Symbol.iterator](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}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{historyReplace}from'@shopgate/pwa-common/actions/router';import{mutable}from'@shopgate/pwa-common/helpers/redux';import fetchProductsByQuery from'@shopgate/pwa-common-commerce/product/actions/fetchProductsByQuery';import{getProductRoute}from'@shopgate/pwa-common-commerce/product/helpers';import{getSearchRoute}from'@shopgate/pwa-common-commerce/search/helpers';/**
|
|
2
2
|
* Handle product search. The thunk will return false if nothing was found or true if it processed
|
|
3
3
|
* the action as it should.
|
|
4
4
|
* @param {string} searchPhrase The search phrase.
|
|
5
5
|
* @return {Function} A redux thunk.
|
|
6
|
-
*/
|
|
6
|
+
*/var handleSearch=function handleSearch(searchPhrase){return(/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(dispatch){var _ref2,_ref2$products,products,_products,first,productId;return _regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:_context.next=2;return dispatch(fetchProductsByQuery(2,searchPhrase));case 2:_ref2=_context.sent;_ref2$products=_ref2.products;products=_ref2$products===void 0?[]:_ref2$products;if(products.length){_context.next=7;break;}return _context.abrupt("return",false);case 7:if(products.length===1){_products=_slicedToArray(products,1),first=_products[0];productId=typeof first==='string'?first:first.id;dispatch(historyReplace({pathname:getProductRoute(productId)}));}else{dispatch(historyReplace({pathname:getSearchRoute(searchPhrase)}));}return _context.abrupt("return",true);case 9:case"end":return _context.stop();}}},_callee);}));return function(_x){return _ref.apply(this,arguments);};}());};/** @mixes {MutableFunction} */export default mutable(handleSearch);
|