@shopgate/engage
Version:
Shopgate's ENGAGE library.
6 lines • 2.14 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 PipelineRequest from'@shopgate/pwa-core/classes/PipelineRequest';import{mutable}from'@shopgate/pwa-common/helpers/redux';import{FETCH_FULFILLMENT_SLOTS_ERROR,FETCH_FULFILLMENT_SLOTS_SUCCESS}from"../constants";/**
* Fetches fulfillment slots of a location
* @param {Object} params Function params
* @param {string} params.locationCode A location code
* @returns {Function} A redux thunk.
*/function fetchFulfillmentSlots(_ref){var locationCode=_ref.locationCode;return(/*#__PURE__*/function(){var _ref2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(dispatch){var request,_ref4,fulfillmentSlots;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:request=new PipelineRequest('shopgate.storefront.getFulfillmentSlots').setInput({locationCode:locationCode}).dispatch();_context.prev=1;_context.next=4;return request;case 4:_ref4=_context.sent;fulfillmentSlots=_ref4.fulfillmentSlots;dispatch({type:FETCH_FULFILLMENT_SLOTS_SUCCESS,locationCode:locationCode,fulfillmentSlots:fulfillmentSlots});_context.next=12;break;case 9:_context.prev=9;_context.t0=_context["catch"](1);dispatch({type:FETCH_FULFILLMENT_SLOTS_ERROR,locationCode:locationCode});case 12:return _context.abrupt("return",request);case 13:case"end":return _context.stop();}},_callee,null,[[1,9]]);}));return function(_x){return _ref2.apply(this,arguments);};}());}/** @mixes {MutableFunction} */export default mutable(fetchFulfillmentSlots);