@shopgate/pwa-common-commerce
Version:
Commerce library for the Shopgate Connect PWA.
8 lines • 1.91 kB
JavaScript
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";/**
* Handle no results
* @param {string} event.scope Scanner scope.
* @param {string} event.format Format of the scanned code.
* @param {string} event.payload Barcode payload.
* @param {string} message The message to display.
* @return {Function} A redux thunk.
*/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);