@shopgate/engage 7.12.3 → 7.12.4-beta.2

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.
@@ -1,6 +1,6 @@
1
- import{produce}from'immer';import{FETCH_CUSTOMER_CONTACTS,FETCH_CUSTOMER_CONTACTS_SUCCESS,FETCH_CUSTOMER_CONTACTS_ERROR,FETCH_CUSTOMER,FETCH_CUSTOMER_SUCCESS,FETCH_CUSTOMER_ERROR}from"../constants/actions";var initialState={customer:{isFetching:false,data:null},contacts:{isFetching:false,items:[]}};/**
1
+ import{produce}from'immer';import{SUCCESS_LOGOUT}from'@shopgate/pwa-common/constants/ActionTypes';import{FETCH_CUSTOMER_CONTACTS,FETCH_CUSTOMER_CONTACTS_SUCCESS,FETCH_CUSTOMER_CONTACTS_ERROR,FETCH_CUSTOMER,FETCH_CUSTOMER_SUCCESS,FETCH_CUSTOMER_ERROR}from"../constants/actions";var initialState={customer:{isFetching:false,data:null},contacts:{isFetching:false,items:[]}};/**
2
2
  * The reducer for all checkout related state.
3
3
  * @param {Object} state The application state.
4
4
  * @param {Object} action The redux action.
5
5
  * @returns {Object}
6
- */export default function checkoutReducer(){var state=arguments.length>0&&arguments[0]!==undefined?arguments[0]:initialState;var action=arguments.length>1?arguments[1]:undefined;/* eslint-disable no-param-reassign */var producer=produce(function(draft){switch(action.type){case FETCH_CUSTOMER_CONTACTS:{draft.contacts.isFetching=true;break;}case FETCH_CUSTOMER_CONTACTS_ERROR:{draft.contacts.isFetching=false;break;}case FETCH_CUSTOMER_CONTACTS_SUCCESS:{draft.contacts.isFetching=false;draft.contacts.items=action.contacts;break;}case FETCH_CUSTOMER:{draft.customer.isFetching=true;break;}case FETCH_CUSTOMER_ERROR:{draft.customer.isFetching=false;break;}case FETCH_CUSTOMER_SUCCESS:{draft.customer.isFetching=false;draft.customer.data=action.customer;break;}default:break;}});/* eslint-enable no-param-reassign */return producer(state);}
6
+ */export default function checkoutReducer(){var state=arguments.length>0&&arguments[0]!==undefined?arguments[0]:initialState;var action=arguments.length>1?arguments[1]:undefined;/* eslint-disable no-param-reassign */var producer=produce(function(draft){switch(action.type){case FETCH_CUSTOMER_CONTACTS:{draft.contacts.isFetching=true;break;}case FETCH_CUSTOMER_CONTACTS_ERROR:{draft.contacts.isFetching=false;break;}case FETCH_CUSTOMER_CONTACTS_SUCCESS:{draft.contacts.isFetching=false;draft.contacts.items=action.contacts;break;}case FETCH_CUSTOMER:{draft.customer.isFetching=true;break;}case FETCH_CUSTOMER_ERROR:{draft.customer.isFetching=false;break;}case FETCH_CUSTOMER_SUCCESS:{draft.customer.isFetching=false;draft.customer.data=action.customer;break;}case SUCCESS_LOGOUT:{draft.customer=initialState.customer;draft.contacts=initialState.contacts;break;}default:break;}});/* eslint-enable no-param-reassign */return producer(state);}
@@ -1,4 +1,6 @@
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 PipelineRequest from'@shopgate/pwa-core/classes/PipelineRequest';import{FETCH_FULFILLMENT_SLOTS_ERROR,FETCH_FULFILLMENT_SLOTS_SUCCESS}from"../constants/ActionTypes";/**
2
- * @param {Object} params params.
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 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";/**
2
+ * Fetches fulfillment slots of a location
3
+ * @param {Object} params Function params
4
+ * @param {string} params.locationCode A location code
3
5
  * @returns {Function} A redux thunk.
4
- */function fetchFulfillmentSlots(_ref){var locationCode=_ref.locationCode;return(/*#__PURE__*/function(){var _ref2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(dispatch){var request,_ref3,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:_ref3=_context.sent;fulfillmentSlots=_ref3.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);};}());}export default fetchFulfillmentSlots;
6
+ */function fetchFulfillmentSlots(_ref){var locationCode=_ref.locationCode;return(/*#__PURE__*/function(){var _ref2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(dispatch){var request,_ref3,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:_ref3=_context.sent;fulfillmentSlots=_ref3.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);
@@ -1,5 +1,6 @@
1
- import{logger}from'@shopgate/pwa-core/helpers';import PipelineRequest from'@shopgate/pwa-core/classes/PipelineRequest';import{requestInventories,receiveInventories,errorInventories}from"../action-creators";import{SHOPGATE_STOREFRONT_GET_INVENTORIES}from"../constants";import{getPreferredLocation}from"../selectors";/**
2
- * @param {string} productCodes The product IDs to fetch inventories for.
3
- * @param {string} [locationCode] locationCode.
1
+ import{logger}from'@shopgate/pwa-core/helpers';import PipelineRequest from'@shopgate/pwa-core/classes/PipelineRequest';import{mutable}from'@shopgate/pwa-common/helpers/redux';import{requestInventories,receiveInventories,errorInventories}from"../action-creators";import{SHOPGATE_STOREFRONT_GET_INVENTORIES}from"../constants";import{getPreferredLocation}from"../selectors";/**
2
+ * Fetches location inventory for a list of products.
3
+ * @param {string[]} productCodes The product IDs to fetch inventories for.
4
+ * @param {string} [locationCode] A location code
4
5
  * @returns {Function} A redux thunk.
5
- */function fetchInventories(productCodes){var locationCode=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;return function(dispatch,getState){var _getPreferredLocation;if(!productCodes||!productCodes.length){return;}var state=getState();var locationFilter=locationCode||((_getPreferredLocation=getPreferredLocation(state))===null||_getPreferredLocation===void 0?void 0:_getPreferredLocation.code);if(!locationFilter){return;}var filters={products:productCodes.map(function(productCode){return{productCode:productCode,locationCode:locationFilter};})};dispatch(requestInventories(productCodes,filters.locationCodes));var request=new PipelineRequest(SHOPGATE_STOREFRONT_GET_INVENTORIES).setInput(filters).dispatch();request.then(function(result){dispatch(receiveInventories(result.productInventories));})["catch"](function(error){logger.error(error);dispatch(errorInventories(productCodes,error));});return request;};}export default fetchInventories;
6
+ */function fetchInventories(productCodes){var locationCode=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;return function(dispatch,getState){var _getPreferredLocation;if(!productCodes||!productCodes.length){return undefined;}var state=getState();var locationFilter=locationCode||((_getPreferredLocation=getPreferredLocation(state))===null||_getPreferredLocation===void 0?void 0:_getPreferredLocation.code);if(!locationFilter){return undefined;}var filters={products:productCodes.map(function(productCode){return{productCode:productCode,locationCode:locationFilter};})};dispatch(requestInventories(productCodes,filters.locationCodes));var request=new PipelineRequest(SHOPGATE_STOREFRONT_GET_INVENTORIES).setInput(filters).dispatch();request.then(function(result){dispatch(receiveInventories(result.productInventories));})["catch"](function(error){logger.error(error);dispatch(errorInventories(productCodes,error));});return request;};}/** @mixes {MutableFunction} */export default mutable(fetchInventories);
@@ -1,4 +1,19 @@
1
- import{logger}from'@shopgate/pwa-core/helpers';import PipelineRequest from'@shopgate/pwa-core/classes/PipelineRequest';import{requestLocations,receiveLocations,errorLocations}from"../action-creators";import{SHOPGATE_STOREFRONT_GET_LOCATIONS}from"../constants";/**
2
- * @param {Object} params params.
1
+ import{logger}from'@shopgate/pwa-core/helpers';import PipelineRequest from'@shopgate/pwa-core/classes/PipelineRequest';import{mutable}from'@shopgate/pwa-common/helpers/redux';import{requestLocations,receiveLocations,errorLocations}from"../action-creators";import{SHOPGATE_STOREFRONT_GET_LOCATIONS}from"../constants";/**
2
+ * Returns a list of locations based on search options & defaults. Including geographical radial
3
+ * distance & other merchant configurations
4
+ * @param {Object} params Function params
5
+ * @param {string} [params.postalCode] A postal code
6
+ * @param {string} [params.countryCode] Indicates to which country the postal code belongs.
7
+ * Is required if the postalCode parameter is set
8
+ * @param {Object} [params.geolocation] A geolocation object
9
+ * @param {string} params.geolocation.longitude Longitude to search by coordinates. Works only in
10
+ * combination with radius and latitude.
11
+ * @param {string} params.geolocation.latitude Latitude to search by coordinates. Works only in
12
+ * combination with radius and longitude.
13
+ * @param {number} [params.radius] Used only with geolocation.longitude & geolocation.latitude.
14
+ * @param {string[]} [params.codes] Search by location codes. This cannot be combined with
15
+ * coordinate search or a postal code search
16
+ * @param {boolean} [params.enableInLocationFinder=false] When set to `true` only locations are
17
+ * returned which are enabled for the location finder.
3
18
  * @returns {Function} A redux thunk.
4
- */function fetchLocations(params){return function(dispatch){dispatch(requestLocations(params));var filters={countryCode:params.countryCode};if(params.geolocation){filters.longitude=params.geolocation.longitude;filters.latitude=params.geolocation.latitude;}if(params.postalCode){filters.postalCode=params.postalCode;}if(params.enableInLocationFinder){filters.enableInLocationFinder=params.enableInLocationFinder;}if(params.radius){filters.radius=params.radius;}if(params.codes){filters.codes=params.codes;}var request=new PipelineRequest(SHOPGATE_STOREFRONT_GET_LOCATIONS).setInput(filters).dispatch();request.then(function(result){dispatch(receiveLocations(filters,result.locations));})["catch"](function(error){logger.error(error);dispatch(errorLocations(params,error));});return request;};}export default fetchLocations;
19
+ */function fetchLocations(params){return function(dispatch){dispatch(requestLocations(params));var filters={countryCode:params.countryCode};if(params.geolocation){filters.longitude=params.geolocation.longitude;filters.latitude=params.geolocation.latitude;}if(params.postalCode){filters.postalCode=params.postalCode;}if(params.enableInLocationFinder){filters.enableInLocationFinder=params.enableInLocationFinder;}if(params.radius){filters.radius=params.radius;}if(params.codes){filters.codes=params.codes;}var request=new PipelineRequest(SHOPGATE_STOREFRONT_GET_LOCATIONS).setInput(filters).dispatch();request.then(function(result){dispatch(receiveLocations(filters,result.locations));})["catch"](function(error){logger.error(error);dispatch(errorLocations(params,error));});return request;};}/** @mixes {MutableFunction} */export default mutable(fetchLocations);
@@ -1,5 +1,7 @@
1
- import{logger}from'@shopgate/pwa-core/helpers';import PipelineRequest from'@shopgate/pwa-core/classes/PipelineRequest';import{requestProductInventories,receiveProductInventories,errorProductInventories}from"../action-creators";import{SHOPGATE_STOREFRONT_GET_PRODUCT_INVENTORIES}from"../constants";/**
1
+ import{logger}from'@shopgate/pwa-core/helpers';import PipelineRequest from'@shopgate/pwa-core/classes/PipelineRequest';import{mutable}from'@shopgate/pwa-common/helpers/redux';import{requestProductInventories,receiveProductInventories,errorProductInventories}from"../action-creators";import{SHOPGATE_STOREFRONT_GET_PRODUCT_INVENTORIES}from"../constants";/**
2
+ * Fetches inventories for a product
2
3
  * @param {string} productCode The product ID to fetch inventories for.
3
4
  * @param {Object} [params={}] Optional params for the inventories request.
5
+ * @param {string[]} params.locationCodes A list of location codes.
4
6
  * @returns {Function} A redux thunk.
5
- */function fetchProductInventories(productCode){var params=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};return function(dispatch){var filters={locationCodes:params.locationCodes,productCode:productCode};dispatch(requestProductInventories(productCode,filters.locationCodes));var request=new PipelineRequest(SHOPGATE_STOREFRONT_GET_PRODUCT_INVENTORIES).setInput(filters).dispatch();request.then(function(result){dispatch(receiveProductInventories(productCode,filters.locationCodes,result.inventories));})["catch"](function(error){logger.error(error);dispatch(errorProductInventories(productCode,error.code));});return request;};}export default fetchProductInventories;
7
+ */function fetchProductInventories(productCode){var params=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};return function(dispatch){var filters={locationCodes:params.locationCodes,productCode:productCode};dispatch(requestProductInventories(productCode,filters.locationCodes));var request=new PipelineRequest(SHOPGATE_STOREFRONT_GET_PRODUCT_INVENTORIES).setInput(filters).dispatch();request.then(function(result){dispatch(receiveProductInventories(productCode,filters.locationCodes,result.inventories));})["catch"](function(error){logger.error(error);dispatch(errorProductInventories(productCode,error.code));});return request;};}/** @mixes {MutableFunction} */export default mutable(fetchProductInventories);
@@ -1,5 +1,12 @@
1
- function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}function _objectWithoutProperties(source,excluded){if(source==null)return{};var target=_objectWithoutPropertiesLoose(source,excluded);var key,i;if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++){key=sourceSymbolKeys[i];if(excluded.indexOf(key)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(source,key))continue;target[key]=source[key];}}return target;}function _objectWithoutPropertiesLoose(source,excluded){if(source==null)return{};var target={};var sourceKeys=Object.keys(source);var key,i;for(i=0;i<sourceKeys.length;i++){key=sourceKeys[i];if(excluded.indexOf(key)>=0)continue;target[key]=source[key];}return target;}import PipelineRequest from'@shopgate/pwa-core/classes/PipelineRequest';import{requestProductLocations,receiveProductLocations,errorProductLocations}from"../action-creators";import{SHOPGATE_STOREFRONT_GET_PRODUCT_LOCATIONS}from"../constants";/**
1
+ function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}function _objectWithoutProperties(source,excluded){if(source==null)return{};var target=_objectWithoutPropertiesLoose(source,excluded);var key,i;if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++){key=sourceSymbolKeys[i];if(excluded.indexOf(key)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(source,key))continue;target[key]=source[key];}}return target;}function _objectWithoutPropertiesLoose(source,excluded){if(source==null)return{};var target={};var sourceKeys=Object.keys(source);var key,i;for(i=0;i<sourceKeys.length;i++){key=sourceKeys[i];if(excluded.indexOf(key)>=0)continue;target[key]=source[key];}return target;}import PipelineRequest from'@shopgate/pwa-core/classes/PipelineRequest';import{mutable}from'@shopgate/pwa-common/helpers/redux';import{requestProductLocations,receiveProductLocations,errorProductLocations}from"../action-creators";import{SHOPGATE_STOREFRONT_GET_PRODUCT_LOCATIONS}from"../constants";/**
2
+ * Returns a list of locations and item availability for a given product
2
3
  * @param {string} productCode The product ID to fetch locations for.
3
4
  * @param {Object} [params={}] Optional params for the location request.
5
+ * @param {string} [params.postalCode] A postal code
6
+ * @param {Object} [params.geolocation] A geolocation object
7
+ * @param {string} params.geolocation.longitude Longitude to search by coordinates. Works only in
8
+ * combination with latitude.
9
+ * @param {string} params.geolocation.latitude Latitude to search by coordinates. Works only in
10
+ * combination with longitude.
4
11
  * @returns {Function} A redux thunk.
5
- */function fetchProductLocations(productCode){var params=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};return function(dispatch){var postalCode=params.postalCode,geolocation=params.geolocation,restParams=_objectWithoutProperties(params,["postalCode","geolocation"]);var filters=_extends({productCode:productCode},restParams);if(geolocation){filters.longitude=params.geolocation.longitude;filters.latitude=params.geolocation.latitude;}if(postalCode){filters.postalCode=params.postalCode;}dispatch(requestProductLocations(productCode,filters));var request=new PipelineRequest(SHOPGATE_STOREFRONT_GET_PRODUCT_LOCATIONS).setInput(filters).dispatch();request.then(function(result){dispatch(receiveProductLocations(productCode,filters,result.locations));})["catch"](function(error){dispatch(errorProductLocations(productCode,error.code));});return request;};}export default fetchProductLocations;
12
+ */function fetchProductLocations(productCode){var params=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};return function(dispatch){var postalCode=params.postalCode,geolocation=params.geolocation,restParams=_objectWithoutProperties(params,["postalCode","geolocation"]);var filters=_extends({productCode:productCode},restParams);if(geolocation){filters.longitude=params.geolocation.longitude;filters.latitude=params.geolocation.latitude;}if(postalCode){filters.postalCode=params.postalCode;}dispatch(requestProductLocations(productCode,filters));var request=new PipelineRequest(SHOPGATE_STOREFRONT_GET_PRODUCT_LOCATIONS).setInput(filters).dispatch();request.then(function(result){dispatch(receiveProductLocations(productCode,filters,result.locations));})["catch"](function(error){dispatch(errorProductLocations(productCode,error.code));});return request;};}/** @mixes {MutableFunction} */export default mutable(fetchProductLocations);
@@ -1,4 +1,4 @@
1
- import{SET_LOCATIONS_PENDING}from"../constants/ActionTypes";export{default as fetchLocations}from"./fetchLocations";export{default as fetchProductLocations}from"./fetchProductLocations";export{default as submitReservation}from"./submitReservation";export{default as setUserSearchGeolocation}from"./setUserSearchGeolocation";export{default as setUserGeolocation}from"./setUserGeolocation";/**
1
+ import{SET_LOCATIONS_PENDING}from"../constants/ActionTypes";export{default as fetchFulfillmentSlots}from"./fetchFulfillmentSlots";export{default as fetchInventories}from"./fetchInventories";export{default as fetchLocations}from"./fetchLocations";export{default as fetchProductInventories}from"./fetchProductInventories";export{default as fetchProductLocations}from"./fetchProductLocations";export{default as submitReservation}from"./submitReservation";export{default as setUserSearchGeolocation}from"./setUserSearchGeolocation";export{default as setUserGeolocation}from"./setUserGeolocation";/**
2
2
  * Sets pending state of locations
3
3
  * @param {boolean} value Value
4
4
  * @returns {Object}
@@ -1,5 +1,5 @@
1
- import{logger}from'@shopgate/pwa-core/helpers';import PipelineRequest from'@shopgate/pwa-core/classes/PipelineRequest';import{submitReservationRequest,submitReservationSuccess,submitReservationError}from"../action-creators";import{SHOPGATE_STOREFRONT_CREATE_ORDER}from"../constants";import createOrder from"../helpers/createOrder";/**
1
+ import{logger}from'@shopgate/pwa-core/helpers';import PipelineRequest from'@shopgate/pwa-core/classes/PipelineRequest';import{mutable}from'@shopgate/pwa-common/helpers/redux';import{submitReservationRequest,submitReservationSuccess,submitReservationError}from"../action-creators";import{SHOPGATE_STOREFRONT_CREATE_ORDER}from"../constants";import createOrder from"../helpers/createOrder";/**
2
2
  * @param {Object} values The user order.
3
3
  * @param {Object} product The current product
4
4
  * @returns {Function} A redux thunk.
5
- */function submitReservation(values,product){return function(dispatch,getState){dispatch(submitReservationRequest(values));var order=createOrder(values,product,getState);var request=new PipelineRequest(SHOPGATE_STOREFRONT_CREATE_ORDER).setInput({orders:[order]}).dispatch();request.then(function(result){if(result.errors&&result.errors.length>0){logger.error(result.errors);dispatch(submitReservationError(result.errors));return result;}dispatch(submitReservationSuccess(result.orderNumbers));return result;})["catch"](function(error){logger.error(error);dispatch(submitReservationError([error]));return error;});return request;};}export default submitReservation;
5
+ */function submitReservation(values,product){return function(dispatch,getState){dispatch(submitReservationRequest(values));var order=createOrder(values,product,getState);var request=new PipelineRequest(SHOPGATE_STOREFRONT_CREATE_ORDER).setInput({orders:[order]}).dispatch();request.then(function(result){if(result.errors&&result.errors.length>0){logger.error(result.errors);dispatch(submitReservationError(result.errors));return result;}dispatch(submitReservationSuccess(result.orderNumbers));return result;})["catch"](function(error){logger.error(error);dispatch(submitReservationError([error]));return error;});return request;};}/** @mixes {MutableFunction} */export default mutable(submitReservation);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopgate/engage",
3
- "version": "7.12.3",
3
+ "version": "7.12.4-beta.2",
4
4
  "description": "Shopgate's ENGAGE library.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Shopgate <support@shopgate.com>",
@@ -16,12 +16,12 @@
16
16
  ],
17
17
  "dependencies": {
18
18
  "@shopgate/native-modules": "1.0.0-beta.18",
19
- "@shopgate/pwa-common": "7.12.3",
20
- "@shopgate/pwa-common-commerce": "7.12.3",
21
- "@shopgate/pwa-core": "7.12.3",
22
- "@shopgate/pwa-ui-ios": "7.12.3",
23
- "@shopgate/pwa-ui-material": "7.12.3",
24
- "@shopgate/pwa-ui-shared": "7.12.3",
19
+ "@shopgate/pwa-common": "7.12.4-beta.2",
20
+ "@shopgate/pwa-common-commerce": "7.12.4-beta.2",
21
+ "@shopgate/pwa-core": "7.12.4-beta.2",
22
+ "@shopgate/pwa-ui-ios": "7.12.4-beta.2",
23
+ "@shopgate/pwa-ui-material": "7.12.4-beta.2",
24
+ "@shopgate/pwa-ui-shared": "7.12.4-beta.2",
25
25
  "@stripe/react-stripe-js": "^1.1.2",
26
26
  "@stripe/stripe-js": "^1.3.1",
27
27
  "@virtuous/conductor": "~2.5.0",
@@ -0,0 +1,12 @@
1
+ function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import React from'react';import{connect}from'react-redux';import withProductListEntry from"./withProductListEntry";import{getProduct}from"../selectors/product";/**
2
+ * Injects the product from the ProductListEntryContext into the wrapped component. The product
3
+ * property name can be configured via the HOC options.
4
+ * @param {Function} WrappedComponent The react component to wrap.
5
+ * @param {Object} [options={}] Options for the HOC.
6
+ * @param {string} [options.prop="product"] An optional prop name to inject the
7
+ * product into the wrapped component.
8
+ * @returns {Function}
9
+ */export default function withProductListEntryProduct(WrappedComponent){var options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var injectedProp=options.prop||'product';/**
10
+ * @return {Function} The extended component props.
11
+ */var makeMapStateToProps=function makeMapStateToProps(){return function(state,props){var _props$product,_props$productListEnt;var propProductId=props===null||props===void 0?void 0:(_props$product=props.product)===null||_props$product===void 0?void 0:_props$product.id;var productListEntryProductId=props===null||props===void 0?void 0:(_props$productListEnt=props.productListEntry)===null||_props$productListEnt===void 0?void 0:_props$productListEnt.productId;// Only select a new product from Redux when the current props don't contain a product yet
12
+ var selectNewProduct=typeof propProductId==='undefined'||propProductId!==productListEntryProductId;return _defineProperty({},injectedProp,selectNewProduct?getProduct(state,{productId:productListEntryProductId}):props.product);};};var connector=connect(makeMapStateToProps);return function(props){var Connected=withProductListEntry(connector(WrappedComponent));return React.createElement(Connected,props);};}
package/product/index.js CHANGED
@@ -7,7 +7,7 @@ export*from'@shopgate/pwa-common-commerce/product/helpers';export*from"./helpers
7
7
  export*from'@shopgate/pwa-common-commerce/product/selectors/options';export*from'@shopgate/pwa-common-commerce/product/selectors/page';export*from'@shopgate/pwa-common-commerce/product/selectors/price';export*from'@shopgate/pwa-common-commerce/product/selectors/product';export*from'@shopgate/pwa-common-commerce/product/selectors/relations';export*from'@shopgate/pwa-common-commerce/product/selectors/variants';export*from"./selectors/media";export{getProductIsFetching,makeGetProductProperties,makeGetProductEffectivityDates,makeGetProductCharacteristics,makeGetProductFeaturedMedia,makeIsProductActive,makeIsBaseProductActive}from"./selectors/product";export*from"./selectors/price";export*from"./selectors/variants";export*from"./selectors/relations";// STREAMS
8
8
  export*from'@shopgate/pwa-common-commerce/product/streams';// COMPONENTS
9
9
  export{default as ProductProperties}from"./components/ProductProperties/ProductProperties";export{default as MapPriceHint}from"./components/MapPriceHint";export{default as OrderQuantityHint}from"./components/OrderQuantityHint";export{default as ProductImage}from"./components/ProductImage";export{default as MediaSlider}from"./components/MediaSlider";export{default as QuantityPicker}from"./components/QuantityPicker";export{default as EffectivityDates}from"./components/EffectivityDates";export{Availability}from"./components/Availability";export{default as PriceDifference}from"./components/PriceDifference";export{FeaturedMedia,MediaImage}from"./components/Media";export{VariantSwatch}from"./components/Swatch";export{Swatches}from"./components/Swatches";export{RelationsSlider}from"./components/RelationsSlider";export{default as ProductCard}from"./components/ProductCard";export{default as ProductGridPrice}from"./components/ProductGridPrice";export{default as ProductCharacteristics}from"./components/ProductCharacteristics";export{default as Description}from"./components/Description";export{VariantAvailability}from"./components/ProductVariants";export{PriceInfo}from"./components/PriceInfo";export{ProductName}from"./components/ProductName";export{default as ProductBadges}from"./components/ProductBadges";export{default as ProductDiscountBadge}from"./components/ProductDiscountBadge";export{ProductUnitQuantityPicker,UnitQuantityPicker,CartUnitQuantityPicker}from"./components/UnitQuantityPicker";// HOCs
10
- export{default as withPriceCalculation}from"./hocs/withPriceCalculation";export{default as withProductStock}from"./hocs/withProductStock";export{default as withProduct}from"./hocs/withProduct";export{default as withProductListType}from"./hocs/withProductListType";export{default as withProductListEntry}from"./hocs/withProductListEntry";// HOOKs
10
+ export{default as withPriceCalculation}from"./hocs/withPriceCalculation";export{default as withProductStock}from"./hocs/withProductStock";export{default as withProduct}from"./hocs/withProduct";export{default as withProductListType}from"./hocs/withProductListType";export{default as withProductListEntry}from"./hocs/withProductListEntry";export{default as withProductListEntryProduct}from"./hocs/withProductListEntryProduct";// HOOKs
11
11
  export{useLoadProductImage}from"./hooks/useLoadProductImage";export{default as useProductListType}from"./hooks/useProductListType";export{default as useProductListEntry}from"./hooks/useProductListEntry";// CONTEXTS
12
12
  export{ProductContext,VariantContext}from"./components/context";export{default as ProductListTypeContext}from"./providers/ProductListType/context";export{default as ProductListEntryContext}from"./providers/ProductListEntry/context";// PROVIDERS
13
13
  export{default as ProductListTypeProvider}from"./providers/ProductListType";export{default as ProductListEntryProvider}from"./providers/ProductListEntry";// TYPES
@@ -9,4 +9,5 @@ import React from'react';/* eslint-disable max-len */ /**
9
9
  * @property {ProductListTypeContextSubType} [subType=null] Optional sub type of the active
10
10
  * ProductListTypeContext. Depending on its usage it can make a statement about in which context
11
11
  * the product list is used e.g. "widgets".
12
- */export{};export default React.createContext({type:null,subType:null});
12
+ * @property {Object} [meta=null] Optional meta information that can be used by child components
13
+ */export{};export default React.createContext({type:null,subType:null,meta:null});
@@ -10,5 +10,6 @@ import React,{useMemo}from'react';import PropTypes from'prop-types';import Conte
10
10
  * @param {string} param.type Type of the context e.g. "productSlider" or "productGrid".
11
11
  * @param {string} param.subType Optional sub type of the context. Depending on its usage it can
12
12
  * make a statement about in which context the product list is used e.g. "widgets".
13
+ * @param {Object} param.meta Optional meta information that can be used by child components
13
14
  * @returns {JSX}
14
- */function ProductListTypeProvider(_ref){var children=_ref.children,type=_ref.type,subType=_ref.subType;var value=useMemo(function(){return{type:type,subType:subType};},[subType,type]);return React.createElement(Context.Provider,{value:value},children);}ProductListTypeProvider.defaultProps={children:null,subType:null};export default ProductListTypeProvider;
15
+ */function ProductListTypeProvider(_ref){var children=_ref.children,type=_ref.type,subType=_ref.subType,meta=_ref.meta;var value=useMemo(function(){return{type:type,subType:subType,meta:meta};},[meta,subType,type]);return React.createElement(Context.Provider,{value:value},children);}ProductListTypeProvider.defaultProps={children:null,subType:null,meta:null};export default ProductListTypeProvider;