@shopgate/engage 7.29.1-beta.2 → 7.29.1-beta.3
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/cart/cart.context.js +18 -1
- package/cart/cart.hooks.js +5 -3
- package/cart/cart.types.js +35 -1
- package/cart/components/CartItem/CartItem.js +3 -1
- package/cart/components/CartItem/CartItemCoupon.connector.js +8 -2
- package/cart/components/CartItem/CartItemCoupon.js +26 -18
- package/cart/components/CartItem/CartItemCoupon.types.js +15 -0
- package/cart/components/CartItem/CartItemCouponLayout.js +9 -3
- package/cart/components/CartItem/CartItemCouponPrice.js +8 -2
- package/cart/components/CartItem/CartItemProduct.js +0 -1
- package/cart/components/CartItem/CartItemProductLayoutWide.js +0 -1
- package/cart/components/CartItem/CartItemProductLayoutWide.style.js +1 -1
- package/cart/components/CartItem/CartItemProductLayoutWideFulfillmentLabel.js +1 -2
- package/cart/components/CartItem/CartItemProductLayoutWideFulfillmentLabel.style.js +1 -1
- package/cart/components/CartItem/CartItemProductLayoutWideOrderDetails.js +1 -1
- package/cart/components/CartItem/CartItemProductLayoutWideRemoveItem.js +1 -2
- package/cart/components/CartItem/CartItemProductOrderDetails.js +1 -1
- package/cart/components/CartItem/CartItemProductPriceCaption.js +1 -1
- package/cart/components/CartItem/CartItemProductPriceList.js +4 -1
- package/cart/components/CartItem/CartItemProductPriceListPromotion.js +3 -1
- package/cart/components/CartItem/CartItemProductProvider.connector.js +15 -3
- package/cart/components/CartItem/CartItemProductProvider.js +10 -4
- package/cart/components/CartItem/CartItemProductProvider.types.js +27 -1
- package/cart/components/CartItem/CartItemProvider.js +12 -3
- package/cart/components/CartItem/CartItemQuantityPicker.js +25 -24
- package/cart/components/CartItem/CartItemSubstitution.js +3 -1
- package/cart/components/CartItems/CartItemCard.js +8 -3
- package/cart/components/CartItems/CartItemCardReservation.js +4 -3
- package/cart/components/CartItems/CartItemCardReservationAccordion.js +5 -4
- package/cart/components/CartItems/CartItemCardReservationLabel.js +4 -4
- package/cart/components/CartItems/CartItemGroup.js +7 -3
- package/cart/components/CartItems/CartItemGroupReservation.js +4 -3
- package/cart/components/CartItems/CartItemGroupReservationLabel.js +4 -4
- package/cart/components/CartItems/CartItems.js +13 -3
- package/cart/components/CartItems/CartItemsHeaderWide.js +10 -3
- package/cart/components/CartItems/CartItemsHeaderWide.style.js +1 -1
- package/cart/components/CartSummaryWide/CartSummaryWideCheckoutButton.js +3 -2
- package/cart/components/CartSummaryWide/CartSummaryWideCheckoutButton.style.js +1 -1
- package/cart/components/PaymentBar/PaymentBarCheckoutButton.js +1 -1
- package/cart/components/PaymentBar/PaymentBarDiscounts.js +6 -2
- package/cart/components/PaymentBar/PaymentBarGrandTotal.js +8 -3
- package/cart/components/PaymentBar/PaymentBarReserveButton.js +5 -4
- package/cart/components/PaymentBar/PaymentBarShippingCost.js +8 -3
- package/cart/components/PaymentBar/PaymentBarSubTotal.js +9 -3
- package/cart/components/PaymentBar/PaymentBarTax.js +7 -3
- package/cart/index.js +2 -1
- package/checkout/paymentMethods/stripe/StripeProvider.js +6 -3
- package/checkout/providers/CheckoutProvider.js +41 -10
- package/components/SideNavigation/SideNavigation.js +7 -3
- package/components/SideNavigation/SideNavigationCategories.js +9 -4
- package/components/SideNavigation/SideNavigationCategories.style.js +1 -1
- package/components/SideNavigation/SideNavigationCategoriesItem.js +10 -3
- package/components/SideNavigation/SideNavigationCategoriesItem.style.js +1 -1
- package/components/SideNavigation/SideNavigationCategoriesItemChildren.js +6 -3
- package/components/SideNavigation/SideNavigationContent.js +5 -2
- package/components/SideNavigation/SideNavigationContent.style.js +1 -1
- package/components/SideNavigation/SideNavigationItem.js +14 -4
- package/components/SideNavigation/SideNavigationLinksLegal.js +5 -4
- package/components/SideNavigation/SideNavigationLinksQuicklinks.js +4 -3
- package/components/SideNavigation/SideNavigationNestedItem.js +8 -2
- package/components/SideNavigation/SideNavigationProvider.js +12 -3
- package/core/config/config.types.js +15 -0
- package/core/hooks/useAsyncMemo.js +1 -1
- package/i18n/countries.hooks.js +5 -5
- package/locations/action-creators/setUserSearchCountryCode.js +11 -4
- package/locations/action-creators/setUserSearchPostalCode.js +11 -4
- package/locations/components/Cart/CartChangeFulfillmentMethod.connector.js +4 -1
- package/locations/components/Cart/CartChangeFulfillmentMethod.js +10 -7
- package/locations/components/Cart/CartChangeFulfillmentMethod.types.js +10 -0
- package/locations/components/Cart/CartContextMenuChangeFulfillment.js +9 -4
- package/locations/components/Cart/CartContextMenuItemChangeLocation.js +7 -6
- package/locations/components/Cart/CartItemProductChangeLocation.connector.js +5 -2
- package/locations/components/Cart/CartItemProductChangeLocation.js +12 -9
- package/locations/components/Cart/CartItemProductChangeLocation.types.js +9 -0
- package/locations/components/ChangeLocationButton/ChangeLocationButton.js +6 -3
- package/locations/components/FulfillmentPath/FulfillmentPathItem.js +6 -4
- package/locations/components/FulfillmentSelector/FulfillmentSelector.connector.js +20 -6
- package/locations/components/FulfillmentSelector/FulfillmentSelector.context.js +2 -1
- package/locations/components/FulfillmentSelector/FulfillmentSelector.hooks.js +3 -2
- package/locations/components/FulfillmentSelector/FulfillmentSelector.js +8 -17
- package/locations/components/FulfillmentSelector/FulfillmentSelector.style.js +1 -1
- package/locations/components/FulfillmentSelector/FulfillmentSelector.types.js +57 -1
- package/locations/components/FulfillmentSelector/FulfillmentSelectorAddToCart.js +5 -8
- package/locations/components/FulfillmentSelector/FulfillmentSelectorBOPIS.js +3 -3
- package/locations/components/FulfillmentSelector/FulfillmentSelectorDirectShip.js +2 -3
- package/locations/components/FulfillmentSelector/FulfillmentSelectorHeader.js +3 -3
- package/locations/components/FulfillmentSelector/FulfillmentSelectorHeader.style.js +1 -1
- package/locations/components/FulfillmentSelector/FulfillmentSelectorItem.js +9 -5
- package/locations/components/FulfillmentSelector/FulfillmentSelectorItem.style.js +1 -1
- package/locations/components/ReserveForm/ReserveForm.js +6 -5
- package/locations/components/ReserveForm/ReserveForm.style.js +1 -1
- package/locations/components/ReserveForm/ReserveFormPhone.connector.js +6 -2
- package/locations/components/ReserveForm/ReserveFormPhone.js +8 -3
- package/locations/components/ReserveForm/ReserveFormPhone.types.js +11 -0
- package/locations/components/StoreFinder/Store.context.js +3 -1
- package/locations/components/StoreFinder/StoreFinderLocation.js +1 -1
- package/locations/components/StoreList/Store.context.js +3 -1
- package/locations/index.js +1 -1
- package/locations/locations.context.js +32 -1
- package/locations/locations.types.js +130 -1
- package/locations/providers/FulfillmentProvider.connector.js +7 -3
- package/locations/providers/FulfillmentProvider.js +38 -27
- package/locations/providers/FulfillmentProvider.types.js +42 -1
- package/locations/providers/StoreFinderProvider.js +1 -1
- package/locations/reducers/index.js +3 -1
- package/locations/reducers/userFormInput.js +7 -7
- package/locations/selectors/index.js +1 -1
- package/package.json +7 -7
- package/page/widgets/Video/Video.js +1 -1
- package/product/product.types.js +32 -0
- package/registration/hooks/index.js +1 -1
- package/registration/providers/RegistrationProvider.js +12 -2
- package/types.js +0 -0
|
@@ -1,50 +1,61 @@
|
|
|
1
|
-
import _regeneratorRuntime from"@babel/runtime/regenerator";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 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);});};}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;}import React,{useState,useMemo,useRef,useEffect,useCallback}from'react';import{logger,i18n,UIEvents}from"../../core";import{withCurrentProduct}from"../../core/hocs/withCurrentProduct";import{FulfillmentContext}from"../locations.context";import{FulfillmentPathSelector}from"../components/FulfillmentPathSelector";import{STAGE_SELECT_STORE,STAGE_RESERVE_FORM,STAGE_RESPONSE_SUCCESS,STAGE_RESPONSE_ERROR,STAGE_FULFILLMENT_METHOD,QUICK_RESERVE,MULTI_LINE_RESERVE,DIRECT_SHIP,ROPIS,BOPIS}from"../constants";import connect from"./FulfillmentProvider.connector"
|
|
1
|
+
import _regeneratorRuntime from"@babel/runtime/regenerator";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 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);});};}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;}import React,{useState,useMemo,useRef,useEffect,useCallback}from'react';import PropTypes from'prop-types';import{logger,i18n,UIEvents}from"../../core";import{withCurrentProduct}from"../../core/hocs/withCurrentProduct";import{FulfillmentContext}from"../locations.context";import{FulfillmentPathSelector}from"../components/FulfillmentPathSelector";import{STAGE_SELECT_STORE,STAGE_RESERVE_FORM,STAGE_RESPONSE_SUCCESS,STAGE_RESPONSE_ERROR,STAGE_FULFILLMENT_METHOD,QUICK_RESERVE,MULTI_LINE_RESERVE,DIRECT_SHIP,ROPIS,BOPIS}from"../constants";import connect from"./FulfillmentProvider.connector";/**
|
|
2
|
+
* @typedef {import('./FulfillmentProvider.types').OwnProps} OwnProps
|
|
3
|
+
* @typedef {import('./FulfillmentProvider.types').StateProps} StateProps
|
|
4
|
+
* @typedef {import('./FulfillmentProvider.types').DispatchProps} DispatchProps
|
|
5
|
+
* @typedef {import('../locations.types').SheetOpenParams} SheetOpenParams
|
|
6
|
+
* @typedef {import('../locations.types').SheetStage} SheetStage
|
|
7
|
+
* @typedef {import('../locations.types').Location} Location
|
|
8
|
+
* @typedef {import('../locations.types').ReservationFormValues} ReservationFormValues
|
|
9
|
+
* @typedef {import('../locations.types').FulfillmentPath} FulfillmentPath
|
|
10
|
+
*/ /**
|
|
11
|
+
* @typedef {OwnProps & StateProps & DispatchProps} Props
|
|
12
|
+
*/export var EVENT_SET_OPEN='FulfillmentProvider.setOpen';var callback=null;/**
|
|
2
13
|
* Provides the fulfillment context.
|
|
3
|
-
* @param {
|
|
4
|
-
* @returns {JSX}
|
|
5
|
-
*/function FulfillmentProvider(props){var children=props.children,locations=props.locations,propsBaseProduct=props.baseProduct,propsProduct=props.product,productLocation=props.location,inventory=props.inventory,userInput=props.userInput,defaultFulfillmentMethod=props.fulfillmentMethod,defaultFulfillmentPath=props.fulfillmentPath,fulfillmentPaths=props.fulfillmentPaths,fulfillmentMethods=props.fulfillmentMethods,enabledFulfillmentMethods=props.enabledFulfillmentMethods,shopSettings=props.shopSettings,selectLocation=props.selectLocation,submitReservation=props.submitReservation,storeFormInput=props.storeFormInput,updateProductsInCart=props.updateProductsInCart,isFetching=props.isFetching,_props$noInventory=props.noInventory,noInventory=_props$noInventory===void 0?false:_props$noInventory,_props$open=props.open,open=_props$open===void 0?false:_props$open,_props$noLocationSele=props.noLocationSelection,noLocationSelection=_props$noLocationSele===void 0?false:_props$noLocationSele,_props$isStoreFinder=props.isStoreFinder,isStoreFinder=_props$isStoreFinder===void 0?false:_props$isStoreFinder,_props$isCart=props.isCart,isCart=_props$isCart===void 0?false:_props$isCart,defaultIsInitialized=props.isInitialized,updatePreferredLocation=props.updatePreferredLocation,_props$restrictMultiL=props.restrictMultiLocationOrders,restrictMultiLocationOrders=_props$restrictMultiL===void 0?false:_props$restrictMultiL,_props$cartProducts=props.cartProducts,cartProducts=_props$cartProducts===void 0?[]:_props$cartProducts,showModal=props.showModal,_props$fulfillmentSch=props.fulfillmentSchedulingEnabled,fulfillmentSchedulingEnabled=_props$fulfillmentSch===void 0?null:_props$fulfillmentSch,_props$activeFulfillm=props.activeFulfillmentSlot,activeFulfillmentSlot=_props$activeFulfillm===void 0?null:_props$activeFulfillm,_props$activeFulfillm2=props.activeFulfillmentSlotLocationCode,activeFulfillmentSlotLocationCode=_props$activeFulfillm2===void 0?null:_props$activeFulfillm2;var _useState=useState(defaultFulfillmentPath||null),_useState2=_slicedToArray(_useState,2),fulfillmentPath=_useState2[0],setFulfillmentPath=_useState2[1];var _useState3=useState(props.changeOnly),_useState4=_slicedToArray(_useState3,2),changeOnly=_useState4[0],setChangeOnly=_useState4[1];var _useState5=useState(open),_useState6=_slicedToArray(_useState5,2),isOpen=_useState6[0],setIsOpen=_useState6[1];var _useState7=useState(props.stage||null),_useState8=_slicedToArray(_useState7,2),stage=_useState8[0],setStage=_useState8[1];var _useState9=useState(null),_useState10=_slicedToArray(_useState9,2),fulfillmentMethod=_useState10[0],setFulfillmentMethod=_useState10[1];var _useState11=useState(null),_useState12=_slicedToArray(_useState11,2),orderNumbers=_useState12[0],setOrderNumbers=_useState12[1];var _useState13=useState(null),_useState14=_slicedToArray(_useState13,2),errors=_useState14[0],setErrors=_useState14[1];var _useState15=useState(propsProduct),_useState16=_slicedToArray(_useState15,2),product=_useState16[0],setProduct=_useState16[1];var _useState17=useState(false),_useState18=_slicedToArray(_useState17,2),isChangeFulfillment=_useState18[0],setIsChangeFulfillment=_useState18[1];var _useState19=useState(null),_useState20=_slicedToArray(_useState19,2),cartItem=_useState20[0],setCartItem=_useState20[1];var _useState21=useState(productLocation),_useState22=_slicedToArray(_useState21,2),storeFinderLocation=_useState22[0],setStoreFinderLocation=_useState22[1];var _useState23=useState(!isFetching),_useState24=_slicedToArray(_useState23,2),isLoading=_useState24[0],setIsLoading=_useState24[1];var isInitialized=useRef(defaultIsInitialized);useEffect(function(){if(defaultFulfillmentMethod){setFulfillmentMethod(defaultFulfillmentMethod);}},[defaultFulfillmentMethod]);var title=useMemo(function(){if(props.title!==null){return i18n.text(props.title);}switch(stage){default:case STAGE_SELECT_STORE:return i18n.text('locations.headline');case STAGE_RESERVE_FORM:return i18n.text('locations.place_reservation');case STAGE_RESPONSE_SUCCESS:return i18n.text('locations.success_heading');case STAGE_RESPONSE_ERROR:return i18n.text('locations.error_heading');case STAGE_FULFILLMENT_METHOD:return i18n.text('locations.change_fulfillment_method');}},[props.title,stage]);/** Effects for updating a state based on new props */useEffect(function(){return setIsOpen(open);},[open]);useEffect(function(){return setProduct(propsProduct);},[propsProduct]);useEffect(function(){// eslint-disable-next-line require-jsdoc
|
|
14
|
+
* @param {Props} props The component props.
|
|
15
|
+
* @returns {JSX.Element} The rendered component.
|
|
16
|
+
*/var FulfillmentProvider=function FulfillmentProvider(props){var children=props.children,locations=props.locations,propsBaseProduct=props.baseProduct,propsProduct=props.product,productLocation=props.location,inventory=props.inventory,userInput=props.userInput,defaultFulfillmentMethod=props.fulfillmentMethod,defaultFulfillmentPath=props.fulfillmentPath,fulfillmentPaths=props.fulfillmentPaths,fulfillmentMethods=props.fulfillmentMethods,enabledFulfillmentMethods=props.enabledFulfillmentMethods,shopSettings=props.shopSettings,selectLocation=props.selectLocation,submitReservation=props.submitReservation,storeFormInput=props.storeFormInput,updateProductsInCart=props.updateProductsInCart,isFetching=props.isFetching,_props$noInventory=props.noInventory,noInventory=_props$noInventory===void 0?false:_props$noInventory,_props$open=props.open,open=_props$open===void 0?false:_props$open,_props$noLocationSele=props.noLocationSelection,noLocationSelection=_props$noLocationSele===void 0?false:_props$noLocationSele,_props$isStoreFinder=props.isStoreFinder,isStoreFinder=_props$isStoreFinder===void 0?false:_props$isStoreFinder,_props$isCart=props.isCart,isCart=_props$isCart===void 0?false:_props$isCart,defaultIsInitialized=props.isInitialized,updatePreferredLocation=props.updatePreferredLocation,_props$restrictMultiL=props.restrictMultiLocationOrders,restrictMultiLocationOrders=_props$restrictMultiL===void 0?false:_props$restrictMultiL,_props$cartProducts=props.cartProducts,cartProducts=_props$cartProducts===void 0?[]:_props$cartProducts,showModal=props.showModal,_props$fulfillmentSch=props.fulfillmentSchedulingEnabled,fulfillmentSchedulingEnabled=_props$fulfillmentSch===void 0?null:_props$fulfillmentSch,_props$activeFulfillm=props.activeFulfillmentSlot,activeFulfillmentSlot=_props$activeFulfillm===void 0?null:_props$activeFulfillm,_props$activeFulfillm2=props.activeFulfillmentSlotLocationCode,activeFulfillmentSlotLocationCode=_props$activeFulfillm2===void 0?null:_props$activeFulfillm2;var _useState=useState(defaultFulfillmentPath||null),_useState2=_slicedToArray(_useState,2),fulfillmentPath=_useState2[0],setFulfillmentPath=_useState2[1];var _useState3=useState(props.changeOnly),_useState4=_slicedToArray(_useState3,2),changeOnly=_useState4[0],setChangeOnly=_useState4[1];var _useState5=useState(open),_useState6=_slicedToArray(_useState5,2),isOpen=_useState6[0],setIsOpen=_useState6[1];var _useState7=useState(props.stage||null),_useState8=_slicedToArray(_useState7,2),stage=_useState8[0],setStage=_useState8[1];var _useState9=useState(null),_useState10=_slicedToArray(_useState9,2),fulfillmentMethod=_useState10[0],setFulfillmentMethod=_useState10[1];var _useState11=useState(null),_useState12=_slicedToArray(_useState11,2),orderNumbers=_useState12[0],setOrderNumbers=_useState12[1];var _useState13=useState(null),_useState14=_slicedToArray(_useState13,2),errors=_useState14[0],setErrors=_useState14[1];var _useState15=useState(propsProduct),_useState16=_slicedToArray(_useState15,2),product=_useState16[0],setProduct=_useState16[1];var _useState17=useState(false),_useState18=_slicedToArray(_useState17,2),isChangeFulfillment=_useState18[0],setIsChangeFulfillment=_useState18[1];var _useState19=useState(null),_useState20=_slicedToArray(_useState19,2),cartItem=_useState20[0],setCartItem=_useState20[1];var _useState21=useState(productLocation),_useState22=_slicedToArray(_useState21,2),storeFinderLocation=_useState22[0],setStoreFinderLocation=_useState22[1];var _useState23=useState(!isFetching),_useState24=_slicedToArray(_useState23,2),isLoading=_useState24[0],setIsLoading=_useState24[1];var isInitialized=useRef(defaultIsInitialized);useEffect(function(){if(defaultFulfillmentMethod){setFulfillmentMethod(defaultFulfillmentMethod);}},[defaultFulfillmentMethod]);var title=useMemo(function(){if(props.title!==null){return i18n.text(props.title);}switch(stage){default:case STAGE_SELECT_STORE:return i18n.text('locations.headline');case STAGE_RESERVE_FORM:return i18n.text('locations.place_reservation');case STAGE_RESPONSE_SUCCESS:return i18n.text('locations.success_heading');case STAGE_RESPONSE_ERROR:return i18n.text('locations.error_heading');case STAGE_FULFILLMENT_METHOD:return i18n.text('locations.change_fulfillment_method');}},[props.title,stage]);/** Effects for updating a state based on new props */useEffect(function(){return setIsOpen(open);},[open]);useEffect(function(){return setProduct(propsProduct);},[propsProduct]);useEffect(function(){// eslint-disable-next-line require-jsdoc
|
|
6
17
|
var exec=/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(){return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:if(!(updatePreferredLocation&&productLocation&&!isInitialized.current)){_context.next=4;break;}isInitialized.current=true;_context.next=4;return selectLocation({location:productLocation,skipLocationSync:true});case 4:case"end":return _context.stop();}},_callee);}));return function exec(){return _ref.apply(this,arguments);};}();exec();},[productLocation,selectLocation,updatePreferredLocation]);useEffect(function(){setIsLoading(isFetching);},[isFetching]);/**
|
|
7
18
|
* Checks whether the given stage is currently set.
|
|
8
|
-
* @param {
|
|
19
|
+
* @param {SheetStage} inputStage The stage to check for.
|
|
9
20
|
* @returns {boolean}
|
|
10
|
-
*/function isStage(inputStage){return inputStage===stage;}
|
|
21
|
+
*/var isStage=function isStage(inputStage){return inputStage===stage;};/**
|
|
11
22
|
* Handles opening of the sheet.
|
|
12
|
-
* @param {
|
|
13
|
-
*/function handleOpen(params){setIsOpen(true);setStage(function(prevState){return params.stage||prevState;});setChangeOnly(function(prevState){return params.changeOnly||prevState;});setFulfillmentPath(function(prevState){return params.fulfillmentPath||prevState;});callback=params.callback||null;}
|
|
14
|
-
*
|
|
15
|
-
* @param {
|
|
16
|
-
* @param {string}
|
|
17
|
-
|
|
23
|
+
* @param {SheetOpenParams} params The sheet open parameters.
|
|
24
|
+
*/var handleOpen=function handleOpen(params){setIsOpen(true);setStage(function(prevState){return params.stage||prevState;});setChangeOnly(function(prevState){return params.changeOnly||prevState;});setFulfillmentPath(function(prevState){return params.fulfillmentPath||prevState;});callback=params.callback||null;};/**
|
|
25
|
+
* Handles the closing of the sheet.
|
|
26
|
+
* @param {Location|null} location - The selected location or null if no location is selected.
|
|
27
|
+
* @param {string|null} productId - The product ID or null if no product is provided.
|
|
28
|
+
* @returns {void}
|
|
29
|
+
*/var handleClose=function handleClose(){var location=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;var productId=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;var orderSuccess=true;if(isStage(STAGE_RESPONSE_ERROR)){orderSuccess=errors===null;}if(isStage(STAGE_RESERVE_FORM)){orderSuccess=null;}if(props.onClose){props.onClose(location,productId,orderSuccess);}else if(callback){callback(location,productId,orderSuccess);callback=null;}setIsOpen(false);setStage(null);setOrderNumbers(null);setErrors(null);setIsChangeFulfillment(false);setFulfillmentMethod(null);};useEffect(function(){UIEvents.addListener(EVENT_SET_OPEN,handleOpen);return function(){UIEvents.removeListener(EVENT_SET_OPEN,handleOpen);};},[]);/**
|
|
18
30
|
* Handles the sending of the reservation.
|
|
19
|
-
* @param {
|
|
31
|
+
* @param {ReservationFormValues} values The reservation form values.
|
|
20
32
|
*/function sendReservation(_x){return _sendReservation.apply(this,arguments);}/**
|
|
21
|
-
* @param {
|
|
33
|
+
* @param {Location} location The selected location.
|
|
22
34
|
* @returns {boolean}
|
|
23
35
|
*/function _sendReservation(){_sendReservation=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(values){var response;return _regeneratorRuntime.wrap(function _callee3$(_context3){while(1)switch(_context3.prev=_context3.next){case 0:_context3.prev=0;_context3.next=3;return submitReservation(values,product);case 3:response=_context3.sent;if(response.errors&&response.errors.length>0){setStage(STAGE_RESPONSE_ERROR);setOrderNumbers(null);setErrors(response.errors);}setStage(STAGE_RESPONSE_SUCCESS);setOrderNumbers(response.orderNumbers);setErrors(null);_context3.next=16;break;case 10:_context3.prev=10;_context3.t0=_context3["catch"](0);logger.error(_context3.t0);setStage(STAGE_RESPONSE_ERROR);setOrderNumbers(null);setErrors([_context3.t0.message]);case 16:// Store the user's form in the user data.
|
|
24
36
|
storeFormInput(values);case 17:case"end":return _context3.stop();}},_callee3,null,[[0,10]]);}));return _sendReservation.apply(this,arguments);}var confirmSelection=/*#__PURE__*/function(){var _ref2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(location){var code,name,ropeCartProducts,cartHasDifferentCodes,confirmed,updateData;return _regeneratorRuntime.wrap(function _callee2$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:code=location.code,name=location.name;ropeCartProducts=cartProducts.filter(function(cartProduct){var _cartProduct$fulfillm;return[ROPIS,BOPIS].includes(cartProduct===null||cartProduct===void 0?void 0:(_cartProduct$fulfillm=cartProduct.fulfillment)===null||_cartProduct$fulfillm===void 0?void 0:_cartProduct$fulfillm.method);});if(!(!restrictMultiLocationOrders||ropeCartProducts.length===0)){_context2.next=4;break;}return _context2.abrupt("return",true);case 4:if(!(isCart&&ropeCartProducts.length===1)){_context2.next=6;break;}return _context2.abrupt("return",true);case 6:cartHasDifferentCodes=!!ropeCartProducts.map(function(_ref3){var _fulfillment$location;var fulfillment=_ref3.fulfillment;return fulfillment===null||fulfillment===void 0?void 0:(_fulfillment$location=fulfillment.location)===null||_fulfillment$location===void 0?void 0:_fulfillment$location.code;}).filter(Boolean).filter(function(cartProductCode){return cartProductCode!==code;}).length;if(!(ropeCartProducts.length>=1&&!cartHasDifferentCodes)){_context2.next=9;break;}return _context2.abrupt("return",true);case 9:_context2.next=11;return showModal({title:'locations.multi_location_modal.title',message:'locations.multi_location_modal.message',confirm:'locations.multi_location_modal.change_store',dismiss:'common.cancel'});case 11:confirmed=_context2.sent;if(!(confirmed&&ropeCartProducts.length)){_context2.next=18;break;}updateData=ropeCartProducts.map(function(_ref4){var cartItemId=_ref4.id,fulfillment=_ref4.fulfillment;return{cartItemId:cartItemId,fulfillment:{method:fulfillment===null||fulfillment===void 0?void 0:fulfillment.method,location:{code:code,name:name||''}}};});setIsLoading(true);_context2.next=17;return updateProductsInCart(updateData);case 17:setIsLoading(false);case 18:return _context2.abrupt("return",confirmed);case 19:case"end":return _context2.stop();}},_callee2);}));return function confirmSelection(_x2){return _ref2.apply(this,arguments);};}();/**
|
|
25
37
|
* Handles multiline reservation.
|
|
26
|
-
* @param {
|
|
27
|
-
*/function handleMultilineReservation(location){if(product===null||location.code===null){return;}var fulfillment=_extends({method:fulfillmentMethod,location:{code:location.code,name:location.name||''}},fulfillmentSchedulingEnabled&&activeFulfillmentSlotLocationCode===location.code&&(activeFulfillmentSlot===null||activeFulfillmentSlot===void 0?void 0:activeFulfillmentSlot.id)?{slotId:activeFulfillmentSlot.id}:null);if(isChangeFulfillment&&cartItem){updateProductsInCart([{quantity:cartItem.quantity,cartItemId:cartItem.id,fulfillment:fulfillment}]);}handleClose(location,product.id);}
|
|
38
|
+
* @param {Location} location The selected location.
|
|
39
|
+
* */var handleMultilineReservation=function handleMultilineReservation(location){if(product===null||location.code===null){return;}var fulfillment=_extends({method:fulfillmentMethod,location:{code:location.code,name:location.name||''}},fulfillmentSchedulingEnabled&&activeFulfillmentSlotLocationCode===location.code&&(activeFulfillmentSlot===null||activeFulfillmentSlot===void 0?void 0:activeFulfillmentSlot.id)?{slotId:activeFulfillmentSlot.id}:null);if(isChangeFulfillment&&cartItem){updateProductsInCart([{quantity:cartItem.quantity,cartItemId:cartItem.id,fulfillment:fulfillment}]);}handleClose(location,product.id);};/**
|
|
28
40
|
* Handles quick reservation.
|
|
29
41
|
*/function handleQuickReservation(){setStage(STAGE_RESERVE_FORM);}/**
|
|
30
42
|
* Handles the selection of a store location from the sheet.
|
|
31
|
-
* @param {
|
|
43
|
+
* @param {Location} location The selected location.
|
|
44
|
+
* @returns {Promise<void>}
|
|
32
45
|
*/function handleSelectLocation(_x3){return _handleSelectLocation.apply(this,arguments);}/**
|
|
33
46
|
* @param {string} method The selected fulfillment method.
|
|
34
47
|
* @param {Object} item The cart item to change.
|
|
35
48
|
*/function _handleSelectLocation(){_handleSelectLocation=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(location){var selectionConfirmed,handleReservationMethod;return _regeneratorRuntime.wrap(function _callee4$(_context4){while(1)switch(_context4.prev=_context4.next){case 0:if(!isLoading){_context4.next=2;break;}return _context4.abrupt("return");case 2:if(!updatePreferredLocation){_context4.next=9;break;}_context4.next=5;return confirmSelection(location);case 5:selectionConfirmed=_context4.sent;if(!selectionConfirmed){_context4.next=9;break;}_context4.next=9;return selectLocation({location:{code:location.code,name:location.name}});case 9:if(!changeOnly){_context4.next=12;break;}if(selectionConfirmed){handleClose(location,product&&product.id);}return _context4.abrupt("return");case 12:/**
|
|
36
49
|
* Select the reservation method strategy.
|
|
37
|
-
* @param {string} method The reservation method.
|
|
38
|
-
* @param {
|
|
50
|
+
* @param {string|FulfillmentPath} method The reservation method.
|
|
51
|
+
* @param {Location} storeLocation The selected store location.
|
|
39
52
|
*/handleReservationMethod=function handleReservationMethod(method,storeLocation){if(!method){return;}if(method===QUICK_RESERVE){handleQuickReservation();}if(method===MULTI_LINE_RESERVE){handleMultilineReservation(storeLocation);}};// No fulfillment path selected yet.
|
|
40
|
-
if(!(fulfillmentPath===null)){_context4.next=16;break;}if(fulfillmentPaths.length>1){
|
|
53
|
+
if(!(fulfillmentPath===null)){_context4.next=16;break;}if(fulfillmentPaths.length>1){/**
|
|
54
|
+
* @param {FulfillmentPath} method - The selected fulfillment path.
|
|
55
|
+
*/FulfillmentPathSelector.open(function(method){if(!method){return;}handleReservationMethod(method,location);});}else if(fulfillmentPaths.length===1){handleReservationMethod(fulfillmentPaths[0],location);}return _context4.abrupt("return");case 16:if(!(fulfillmentPath===MULTI_LINE_RESERVE&&fulfillmentPaths.includes(MULTI_LINE_RESERVE))){_context4.next=19;break;}handleMultilineReservation(location);return _context4.abrupt("return");case 19:if(fulfillmentPath===QUICK_RESERVE){handleQuickReservation();}case 20:case"end":return _context4.stop();}},_callee4);}));return _handleSelectLocation.apply(this,arguments);}var handleChangeFulfillmentMethod=function handleChangeFulfillmentMethod(method,item){logger.assert(item.product.id===product.id,'Change fulfillment method is called with unexpected product id');setIsChangeFulfillment(true);setCartItem(item);if([ROPIS,BOPIS].includes(method)&&(item.fulfillment===null||item.fulfillment.method===DIRECT_SHIP)){/**
|
|
41
56
|
* When the fulfillment method of the current cart item was DIRECT_SHIP before, and is
|
|
42
57
|
* switched to a ROPE method, the customer needs to pick a store for the item.
|
|
43
|
-
*/setFulfillmentPath(MULTI_LINE_RESERVE);setStage(STAGE_SELECT_STORE);setFulfillmentMethod(method);setIsOpen(true);return;}if([DIRECT_SHIP,ROPIS,BOPIS].includes(method)){updateProductsInCart([{quantity:item.quantity,cartItemId:item.id,fulfillment:{method:method}}]);handleClose(null,item.product.id);}}var handleSelectStoreFinderLocation=useCallback(function(location){setStoreFinderLocation(location);},[]);var context={stage:stage,title:title,fulfillmentPath:fulfillmentPath,changeOnly:changeOnly,isStage:isStage,isOpen:isOpen,handleOpen:handleOpen,handleClose:handleClose,locations:locations,inventory:inventory,baseProduct:propsBaseProduct,product:product,location:productLocation,storeFinderLocation:storeFinderLocation,userInput:userInput,fulfillmentPaths:fulfillmentPaths,fulfillmentMethods:fulfillmentMethods,enabledFulfillmentMethods:enabledFulfillmentMethods,shopSettings:shopSettings,selectLocation:handleSelectLocation,selectStoreFinderLocation:handleSelectStoreFinderLocation,changeFulfillment:handleChangeFulfillmentMethod,sendReservation:sendReservation,orderNumbers:orderNumbers,errors:errors,noInventory:noInventory,noLocationSelection:noLocationSelection,isStoreFinder:isStoreFinder,isFetching:isFetching,isLoading:isLoading,setIsLoading:setIsLoading,meta:props.meta||undefined};return React.createElement(FulfillmentContext.Provider,{value:context},children);}FulfillmentProvider.defaultProps={open:false,changeOnly:false,updatePreferredLocation:true,fulfillmentMethods:null,title:null};var FulfillmentProviderWrapped=withCurrentProduct(connect(FulfillmentProvider));/**
|
|
58
|
+
*/setFulfillmentPath(MULTI_LINE_RESERVE);setStage(STAGE_SELECT_STORE);setFulfillmentMethod(method);setIsOpen(true);return;}if([DIRECT_SHIP,ROPIS,BOPIS].includes(method)){updateProductsInCart([{quantity:item.quantity,cartItemId:item.id,fulfillment:{method:method}}]);handleClose(null,item.product.id);}};var handleSelectStoreFinderLocation=useCallback(function(location){setStoreFinderLocation(location);},[]);var context={stage:stage,title:title,fulfillmentPath:fulfillmentPath,changeOnly:changeOnly,isStage:isStage,isOpen:isOpen,handleOpen:handleOpen,handleClose:handleClose,locations:locations,inventory:inventory,baseProduct:propsBaseProduct,product:product,location:productLocation,storeFinderLocation:storeFinderLocation,userInput:userInput,fulfillmentPaths:fulfillmentPaths,fulfillmentMethods:fulfillmentMethods,enabledFulfillmentMethods:enabledFulfillmentMethods,shopSettings:shopSettings,selectLocation:handleSelectLocation,selectStoreFinderLocation:handleSelectStoreFinderLocation,changeFulfillment:handleChangeFulfillmentMethod,sendReservation:sendReservation,orderNumbers:orderNumbers,errors:errors,noInventory:noInventory,noLocationSelection:noLocationSelection,isStoreFinder:isStoreFinder,isFetching:isFetching,isLoading:isLoading,setIsLoading:setIsLoading,meta:props.meta||undefined};return React.createElement(FulfillmentContext.Provider,{value:context},children);};FulfillmentProvider.defaultProps={open:false,changeOnly:false,updatePreferredLocation:true,fulfillmentMethods:null,title:null,activeFulfillmentSlot:null,activeFulfillmentSlotLocationCode:null,baseProduct:null,cartProducts:[],enabledFulfillmentMethods:[],fulfillmentMethod:null,fulfillmentPath:null,fulfillmentPaths:[],fulfillmentSchedulingEnabled:false,inventory:null,isCart:false,isFetching:false,isInitialized:false,isStoreFinder:false,location:null,locations:[],noInventory:false,noLocationSelection:false,product:null,restrictMultiLocationOrders:false,shopSettings:null,showModal:null,userInput:null,stage:null,onClose:null,meta:null};var FulfillmentProviderWrapped=withCurrentProduct(connect(FulfillmentProvider));/**
|
|
44
59
|
* Opens the sheet that is wrapped inside the provider.
|
|
45
|
-
* @param {
|
|
46
|
-
|
|
47
|
-
* @property {string} [params.stage] A specific stage to show.
|
|
48
|
-
* @property {string} [params.fulfillmentPath] The fulfillment path that was chosen.
|
|
49
|
-
* @property {boolean} [params.changeOnly=false] Whether only the location will be changed.
|
|
50
|
-
*/export function openSheet(params){UIEvents.emit(EVENT_SET_OPEN,params);}export default FulfillmentProviderWrapped;
|
|
60
|
+
* @param {SheetOpenParams} params The opening parameters.
|
|
61
|
+
*/export var openSheet=function openSheet(params){UIEvents.emit(EVENT_SET_OPEN,params);};export default FulfillmentProviderWrapped;
|
|
@@ -1 +1,42 @@
|
|
|
1
|
-
|
|
1
|
+
/* eslint-disable max-len */ /**
|
|
2
|
+
* @typedef {import('../../product/product.types').Product} Product
|
|
3
|
+
* @typedef {import('../locations.types').Location} Location
|
|
4
|
+
* @typedef {import('../locations.types').ReservationFormValues} ReservationFormValues
|
|
5
|
+
* @typedef {import('../locations.types').ReservationResponse} ReservationResponse
|
|
6
|
+
* @typedef {import('../locations.types').SheetStage} SheetStage
|
|
7
|
+
* @typedef {import('../../cart/cart.types').AddToCartProduct} AddToCartProduct
|
|
8
|
+
* @typedef {import('../../cart/cart.types').Item} Item
|
|
9
|
+
* @typedef {import('../../core/config/config.types').ShopSettings} ShopSettings
|
|
10
|
+
*/ /**
|
|
11
|
+
* @typedef {Object} OwnProps
|
|
12
|
+
* @property {React.ReactNode} children
|
|
13
|
+
* @property {boolean} [open]
|
|
14
|
+
* @property {string} [title]
|
|
15
|
+
* @property {boolean} [changeOnly]
|
|
16
|
+
* @property {(location: Location|null, productId: string|null, orderSuccess?: boolean|null) => void} [onClose]
|
|
17
|
+
* @property {Object<string, any>} [meta]
|
|
18
|
+
* @property {SheetStage} [stage]
|
|
19
|
+
* @property {boolean} [updatePreferredLocation]
|
|
20
|
+
* @property {boolean} [restrictMultiLocationOrders]
|
|
21
|
+
* @property {boolean} [isCart]
|
|
22
|
+
* @property {Object[]} [cartProducts]
|
|
23
|
+
* @property {boolean} [fulfillmentSchedulingEnabled]
|
|
24
|
+
* @property {string} [activeFulfillmentSlotLocationCode]
|
|
25
|
+
* @property {Object} [activeFulfillmentSlot]
|
|
26
|
+
*/ /**
|
|
27
|
+
* @typedef {Object} StateProps
|
|
28
|
+
* @property {Location[]|null} locations
|
|
29
|
+
* @property {ReservationFormValues|null} userInput
|
|
30
|
+
* @property {string[]} fulfillmentPaths
|
|
31
|
+
* @property {string[]} [fulfillmentMethods]
|
|
32
|
+
* @property {ShopSettings} [shopSettings]
|
|
33
|
+
* @property {any} inventory
|
|
34
|
+
* @mixes Product
|
|
35
|
+
*/ /**
|
|
36
|
+
* @typedef {Object} DispatchProps
|
|
37
|
+
* @property {function({location: Location}):void} selectLocation
|
|
38
|
+
* @property {function(ReservationFormValues, Product|null):Promise<ReservationResponse>} submitReservation
|
|
39
|
+
* @property {function(ReservationFormValues):void} storeFormInput
|
|
40
|
+
* @property {function(AddToCartProduct[]):void} addProductsToCart
|
|
41
|
+
* @property {function(Item[]):void} updateProductsInCart
|
|
42
|
+
*/ /* eslint-enable max-len */
|
|
@@ -5,5 +5,5 @@ import _regeneratorRuntime from"@babel/runtime/regenerator";function asyncGenera
|
|
|
5
5
|
// might clear product data from the resultsByHash product storage.
|
|
6
6
|
selectGlobalLocation(location);}// Back navigation
|
|
7
7
|
pop();case 4:case"end":return _context.stop();}},_callee);}));return function(_x){return _ref2.apply(this,arguments);};}(),[selectedLocation,pop,selectLocation,selectGlobalLocation]);/**
|
|
8
|
-
* @param {
|
|
8
|
+
* @param {boolean} loading
|
|
9
9
|
*/var setIsLoading=useCallback(function(loading){if(loading){LoadingProvider.setLoading(STORE_FINDER_PATTERN);return;}LoadingProvider.unsetLoading(STORE_FINDER_PATTERN);},[]);var value=useMemo(function(){return{locations:locations,selectedLocation:selectedLocation,selectLocation:selectLocationCb,isFetching:isFetching,shopSettings:shopSettings,userSearch:userSearch,storeFinderSearch:storeFinderSearch,setIsLoading:setIsLoading};},[isFetching,locations,selectLocationCb,selectedLocation,shopSettings,storeFinderSearch,userSearch,setIsLoading]);return React.createElement(StoreFinderContext.Provider,{value:value},children);};StoreFinderProvider.defaultProps={children:null,locations:[],isFetching:false,shopSettings:null,userSearch:null,storeFinderSearch:null};export default connect(StoreFinderProvider);
|
|
@@ -1 +1,3 @@
|
|
|
1
|
-
import{combineReducers}from'redux';import userFormInput from"./userFormInput";import userSearch from"./userSearch";import storeFinderSearch from"./storeFinderSearch";import storage from"./storage";import user from"./user"
|
|
1
|
+
import{combineReducers}from'redux';import userFormInput from"./userFormInput";import userSearch from"./userSearch";import storeFinderSearch from"./storeFinderSearch";import storage from"./storage";import user from"./user";/**
|
|
2
|
+
* @typedef {import('../locations.types').LocationsState} LocationsState
|
|
3
|
+
*/export default combineReducers(/** @type {LocationsState} */{userFormInput:userFormInput,userSearch:userSearch,user:user,storeFinderSearch:storeFinderSearch,storage:storage});
|
|
@@ -1,8 +1,8 @@
|
|
|
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);}import
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* Stores the user's reserve form input
|
|
5
|
-
* @param {Object} state The current state.
|
|
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);}import{STORE_FORM_INPUT}from"../constants";/** @typedef {import('./locations.types').UserLocationState} */ /**
|
|
2
|
+
* Stores the user's reserve form input.
|
|
3
|
+
* @param {UserLocationState} [state={}] The current state.
|
|
6
4
|
* @param {Object} action The action object.
|
|
7
|
-
* @
|
|
8
|
-
|
|
5
|
+
* @param {string} action.type The action type.
|
|
6
|
+
* @param {Object} [action.input] The input data to store.
|
|
7
|
+
* @returns {UserLocationState} The new state.
|
|
8
|
+
*/var formInput=function formInput(){var state=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var action=arguments.length>1?arguments[1]:undefined;switch(action.type){case STORE_FORM_INPUT:return _extends({},state,{},action.input);default:return state;}};export default formInput;
|
|
@@ -115,7 +115,7 @@ if(!method){try{var available=getProductFulfillmentMethods(state,props);return(a
|
|
|
115
115
|
* @param {Function} getLocationCode Has to retrieve the location code.
|
|
116
116
|
* @param {Function} getProductCode Has to retrieve the product code.
|
|
117
117
|
* @param {string} fulfillmentMethod The fulfillment method to check.
|
|
118
|
-
* @param {
|
|
118
|
+
* @param {boolean} ignoreLocationMethods[false] Whether location fulfillment methods are ignored
|
|
119
119
|
* @returns {Function}
|
|
120
120
|
*/export var makeIsFulfillmentSelectorMethodEnabled=function makeIsFulfillmentSelectorMethodEnabled(getLocationCode,getProductCode,fulfillmentMethod){var ignoreLocationMethods=arguments.length>3&&arguments[3]!==undefined?arguments[3]:false;var getLocation=makeGetLocation(getLocationCode);var getInventory=makeGetLocationInventory(getLocationCode,getProductCode);var getMerchantFulfillmentMethods=makeGetEnabledFulfillmentMethods();var isProductActive=makeIsProductActive();var isBaseProductActive=makeIsBaseProductActive();var useLocationFulfillmentMethods=makeUseLocationFulfillmentMethods();var getLocationFulfillmentMethods=makeGetLocationFulfillmentMethods(getLocationCode);return createSelector(isProductActive,isBaseProductActive,getLocation,getInventory,getMerchantFulfillmentMethods,getProductFulfillmentMethods,getLocationFulfillmentMethods,getIsLocationBasedShopping,useLocationFulfillmentMethods,function(productActive,baseProductActive,location,inventory,merchantMethods,productMethods,locationMethods,isLocationBasedShopping,locationFulfillmentMethodsUsed){if(!productActive||!baseProductActive){return false;}if(isLocationBasedShopping&&(!location||!inventory)){return false;}var methodSupported=Array.isArray(merchantMethods)&&merchantMethods.includes(fulfillmentMethod)&&Array.isArray(productMethods)&&productMethods.includes(fulfillmentMethod);if(fulfillmentMethod===DIRECT_SHIP&&methodSupported){return true;}if(locationFulfillmentMethodsUsed&&!ignoreLocationMethods&&location){methodSupported=methodSupported&&Array.isArray(locationMethods)&&locationMethods.includes(fulfillmentMethod);}if(!methodSupported){return false;}return true;});};/**
|
|
121
121
|
* Returns the externalCustomerNumber that is used to create a new order.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shopgate/engage",
|
|
3
|
-
"version": "7.29.1-beta.
|
|
3
|
+
"version": "7.29.1-beta.3",
|
|
4
4
|
"description": "Shopgate's ENGAGE library.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Shopgate <support@shopgate.com>",
|
|
@@ -17,12 +17,12 @@
|
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@emotion/react": "^11.14.0",
|
|
19
19
|
"@shopgate/native-modules": "1.0.0-beta.25",
|
|
20
|
-
"@shopgate/pwa-common": "7.29.1-beta.
|
|
21
|
-
"@shopgate/pwa-common-commerce": "7.29.1-beta.
|
|
22
|
-
"@shopgate/pwa-core": "7.29.1-beta.
|
|
23
|
-
"@shopgate/pwa-ui-ios": "7.29.1-beta.
|
|
24
|
-
"@shopgate/pwa-ui-material": "7.29.1-beta.
|
|
25
|
-
"@shopgate/pwa-ui-shared": "7.29.1-beta.
|
|
20
|
+
"@shopgate/pwa-common": "7.29.1-beta.3",
|
|
21
|
+
"@shopgate/pwa-common-commerce": "7.29.1-beta.3",
|
|
22
|
+
"@shopgate/pwa-core": "7.29.1-beta.3",
|
|
23
|
+
"@shopgate/pwa-ui-ios": "7.29.1-beta.3",
|
|
24
|
+
"@shopgate/pwa-ui-material": "7.29.1-beta.3",
|
|
25
|
+
"@shopgate/pwa-ui-shared": "7.29.1-beta.3",
|
|
26
26
|
"@stripe/react-stripe-js": "^1.16.5",
|
|
27
27
|
"@stripe/stripe-js": "^1.3.1",
|
|
28
28
|
"@virtuous/conductor": "~2.5.0",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
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;}import React,{useEffect,useMemo,useState}from'react';import{makeStyles}from'@shopgate/engage/styles';import{useReduceMotion}from'@shopgate/engage/a11y/hooks';import{usePrevious}from'@shopgate/engage/core';import{useVideoWidget}from"./hooks";import{isHttpsUrl}from"../../helpers";var useStyles=makeStyles()(function(
|
|
1
|
+
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;}import React,{useEffect,useMemo,useState}from'react';import{makeStyles}from'@shopgate/engage/styles';import{useReduceMotion}from'@shopgate/engage/a11y/hooks';import{usePrevious}from'@shopgate/engage/core';import{useVideoWidget}from"./hooks";import{isHttpsUrl}from"../../helpers";var useStyles=makeStyles()(function(_theme,_ref){var borderRadius=_ref.borderRadius;return{video:{width:'100%',borderRadius:borderRadius}};});/**
|
|
2
2
|
* The VideoWidget is used to display a video.
|
|
3
3
|
* @returns {JSX.Element}
|
|
4
4
|
*/var Video=function Video(){var _useVideoWidget=useVideoWidget(),url=_useVideoWidget.url,muted=_useVideoWidget.muted,loop=_useVideoWidget.loop,controls=_useVideoWidget.controls,autoplay=_useVideoWidget.autoplay,borderRadius=_useVideoWidget.borderRadius;var _useStyles=useStyles({borderRadius:borderRadius}),classes=_useStyles.classes;var reduceMotion=useReduceMotion();var _useState=useState(false),_useState2=_slicedToArray(_useState,2),hasError=_useState2[0],setHasError=_useState2[1];var videoRef=React.useRef(null);var prevAutoPlay=usePrevious(autoplay);var prevUrl=usePrevious(url);var isValidUrl=useMemo(function(){return url?isHttpsUrl(url):false;},[url]);useEffect(function(){if(videoRef.current&&prevAutoPlay&&!autoplay){videoRef.current.pause();videoRef.current.currentTime=0;}if(videoRef.current&&!prevAutoPlay&&autoplay){videoRef.current.play();}if(!url||url!==prevUrl||!hasError){setHasError(false);}},[autoplay,hasError,prevAutoPlay,prevUrl,url]);if(!url||hasError||!isValidUrl)return null;return React.createElement("video",{ref:videoRef,src:url,muted:muted,controls:!autoplay||reduceMotion?true:controls,autoPlay:reduceMotion?false:autoplay,className:classes.video,preload:"auto",playsInline:true,loop:loop,"aria-hidden":true,onError:function onError(){return setHasError(true);}},React.createElement("track",{kind:"captions",src:"",srcLang:"de",label:"Deutsch"}));};export default Video;
|
package/product/product.types.js
CHANGED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {Object} ProductCharacteristic
|
|
3
|
+
* @property {string|number} id
|
|
4
|
+
* @property {string} label
|
|
5
|
+
* @property {string} value
|
|
6
|
+
*/ /**
|
|
7
|
+
* @typedef {Object} ProductTierPrice
|
|
8
|
+
* @property {number|null} from
|
|
9
|
+
* @property {number|null} to
|
|
10
|
+
* @property {number} unitPrice
|
|
11
|
+
*/ /**
|
|
12
|
+
* @typedef {Object} ProductPrice
|
|
13
|
+
* @property {string} currency
|
|
14
|
+
* @property {string} info
|
|
15
|
+
* @property {number} unitPrice
|
|
16
|
+
* @property {number} [unitPriceStriked]
|
|
17
|
+
* @property {number} [unitPriceMin]
|
|
18
|
+
* @property {number} [unitPriceMax]
|
|
19
|
+
* @property {number} unitPriceNet
|
|
20
|
+
* @property {number} unitPriceWithTax
|
|
21
|
+
* @property {number} taxAmount
|
|
22
|
+
* @property {number} taxPercent
|
|
23
|
+
* @property {number} [msrp]
|
|
24
|
+
* @property {ProductTierPrice[]} tiers
|
|
25
|
+
* @property {number} [discount]
|
|
26
|
+
*/ /**
|
|
27
|
+
* @typedef {Object} Product
|
|
28
|
+
* @property {string} id
|
|
29
|
+
* @property {string} name
|
|
30
|
+
* @property {ProductCharacteristic[]|null} [characteristics]
|
|
31
|
+
* @property {ProductPrice|null} [price]
|
|
32
|
+
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import{useContext}from'react';import RegistrationContext from"../providers/RegistrationProvider.context";import GuestRegistrationContext from"../providers/GuestRegistrationProvider.context";/**
|
|
2
2
|
* Returns the value of the checkout provider state.
|
|
3
|
-
* @param {
|
|
3
|
+
* @param {boolean} isGuest Whether the registration is a guest registration
|
|
4
4
|
* @returns {Object}
|
|
5
5
|
*/export var useRegistration=function useRegistration(){var isGuest=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;return useContext(isGuest?GuestRegistrationContext:RegistrationContext);};
|
|
@@ -1,10 +1,20 @@
|
|
|
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);});};}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 _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);}import React,{useMemo,useState,useEffect,useCallback}from'react';import{REGISTER_PATH}from'@shopgate/pwa-common/constants/RoutePaths';import{LoadingProvider,i18n,useRoute,SHOP_SETTING_REGISTRATION_MODE_SIMPLE}from'@shopgate/engage/core';import{useFormState}from'@shopgate/engage/core/hooks/useFormState';import appConfig from'@shopgate/pwa-common/helpers/config';import{extractDefaultValues}from"../../account/helper/form";import Context from"./RegistrationProvider.context";import{generateBaseConstraints,generateBillingConstraints,generateShippingConstraints,generateExtraConstraints}from"./RegistrationProvider.constraints";import connect from"./RegistrationProvider.connector";import{MARKETING_OPT_IN_DEFAULT}from"../constants";var initialBaseFormState={emailAddress:'',password:'',passwordConfirm:''};var initialAddressFormState={firstName:'',lastName:'',company:'',address1:'',address2:'',city:'',country:'',postalCode:'',mobile:''};var initialBillingFormState=_extends({},initialAddressFormState);var initialShippingFormState=_extends({},initialAddressFormState);var initialOptInFormState={marketingOptIn:MARKETING_OPT_IN_DEFAULT};/**
|
|
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);});};}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 _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);}import React,{useMemo,useState,useEffect,useCallback}from'react';import{REGISTER_PATH}from'@shopgate/pwa-common/constants/RoutePaths';import{LoadingProvider,i18n,useRoute,SHOP_SETTING_REGISTRATION_MODE_SIMPLE}from'@shopgate/engage/core';import{useFormState}from'@shopgate/engage/core/hooks/useFormState';import appConfig from'@shopgate/pwa-common/helpers/config';import PropTypes from'prop-types';import{extractDefaultValues}from"../../account/helper/form";import Context from"./RegistrationProvider.context";import{generateBaseConstraints,generateBillingConstraints,generateShippingConstraints,generateExtraConstraints}from"./RegistrationProvider.constraints";import connect from"./RegistrationProvider.connector";import{MARKETING_OPT_IN_DEFAULT}from"../constants";var initialBaseFormState={emailAddress:'',password:'',passwordConfirm:''};var initialAddressFormState={firstName:'',lastName:'',company:'',address1:'',address2:'',city:'',country:'',postalCode:'',mobile:''};var initialBillingFormState=_extends({},initialAddressFormState);var initialShippingFormState=_extends({},initialAddressFormState);var initialOptInFormState={marketingOptIn:MARKETING_OPT_IN_DEFAULT};/**
|
|
2
2
|
* Converts validation errors into errors for form builder.
|
|
3
3
|
* @param {Object} validationErrors The validation errors.
|
|
4
4
|
* @returns {Array}
|
|
5
5
|
*/var convertValidationErrors=function convertValidationErrors(validationErrors){return Object.keys(validationErrors).map(function(key){return{path:key,message:i18n.text(validationErrors[key])};});};/**
|
|
6
6
|
* Registration Provider
|
|
7
|
-
* @
|
|
7
|
+
* @param {React.ReactNode} children Child components.
|
|
8
|
+
* @param {Object} shopSettings Shop settings object.
|
|
9
|
+
* @param {Object} userLocation User location object.
|
|
10
|
+
* @param {Object} customerAttributes Customer attributes object.
|
|
11
|
+
* @param {boolean} isDataReady Indicates if data is ready.
|
|
12
|
+
* @param {string} registrationMode Registration mode.
|
|
13
|
+
* @param {boolean} [cartHasDirectShipItems=false] Indicates if the cart has direct ship items.
|
|
14
|
+
* @param {number} [numberOfAddressLines=null] Number of address lines.
|
|
15
|
+
* @param {Function} submitRegistration Function to submit registration.
|
|
16
|
+
* @param {Object} [formContainerRef=null] Reference to the form container.
|
|
17
|
+
* @returns {JSX.Element}
|
|
8
18
|
*/var RegistrationProvider=function RegistrationProvider(_ref){var isDataReady=_ref.isDataReady,cartHasDirectShipItems=_ref.cartHasDirectShipItems,shopSettings=_ref.shopSettings,userLocation=_ref.userLocation,customerAttributes=_ref.customerAttributes,numberOfAddressLines=_ref.numberOfAddressLines,registrationMode=_ref.registrationMode,submitRegistration=_ref.submitRegistration,children=_ref.children,formContainerRef=_ref.formContainerRef;var _useState=useState(false),_useState2=_slicedToArray(_useState,2),isLocked=_useState2[0],setLocked=_useState2[1];var _useState3=useState(false),_useState4=_slicedToArray(_useState3,2),isBaseFormSubmitted=_useState4[0],setIsBaseFormSubmitted=_useState4[1];var _useState5=useState(false),_useState6=_slicedToArray(_useState5,2),isBillingFormSubmitted=_useState6[0],setIsBillingFormSubmitted=_useState6[1];var _useState7=useState(false),_useState8=_slicedToArray(_useState7,2),isShippingFormSubmitted=_useState8[0],setIsShippingFormSubmitted=_useState8[1];var _useState9=useState(false),_useState10=_slicedToArray(_useState9,2),isExtraFormSubmitted=_useState10[0],setIsExtraFormSubmitted=_useState10[1];var _useState11=useState(null),_useState12=_slicedToArray(_useState11,2),baseFormRequestErrors=_useState12[0],setBaseFormRequestErrors=_useState12[1];var _useState13=useState(null),_useState14=_slicedToArray(_useState13,2),billingFormRequestErrors=_useState14[0],setBillingFormRequestErrors=_useState14[1];var _useState15=useState(null),_useState16=_slicedToArray(_useState15,2),shippingFormRequestErrors=_useState16[0],setShippingFormRequestErrors=_useState16[1];var _useState17=useState(null),_useState18=_slicedToArray(_useState17,2),extraFormRequestErrors=_useState18[0],setExtraFormRequestErrors=_useState18[1];var _useState19=useState(false),_useState20=_slicedToArray(_useState19,2),isShippingFormVisible=_useState20[0],setIsShippingFormVisible=_useState20[1];var _useRoute=useRoute(),query=_useRoute.query;var isShippingAddressSelectionEnabled=useMemo(function(){return(query===null||query===void 0?void 0:query.checkout)&&cartHasDirectShipItems&®istrationMode!==SHOP_SETTING_REGISTRATION_MODE_SIMPLE;},[cartHasDirectShipItems,query,registrationMode]);var isBillingAddressSelectionEnabled=useMemo(function(){return registrationMode!==SHOP_SETTING_REGISTRATION_MODE_SIMPLE;},[registrationMode]);// Determine values to prefill some form fields
|
|
9
19
|
var userCountry=useMemo(function(){return(userLocation===null||userLocation===void 0?void 0:userLocation.country)||(appConfig===null||appConfig===void 0?void 0:appConfig.marketId)||null;},[userLocation]);var userRegion=useMemo(function(){return(userLocation===null||userLocation===void 0?void 0:userLocation.region)||null;},[userLocation]);var baseConstraints=useMemo(function(){return generateBaseConstraints({registrationMode:registrationMode});},[registrationMode]);var billingConstraints=useMemo(function(){return generateBillingConstraints({registrationMode:registrationMode});},[registrationMode]);var shippingConstraints=useMemo(function(){return generateShippingConstraints({registrationMode:registrationMode});},[registrationMode]);var extraConstraints=useMemo(function(){return generateExtraConstraints(customerAttributes);},[customerAttributes]);// Default form states
|
|
10
20
|
var defaultBaseFormState=_extends({},initialBaseFormState);var defaultBillingFormState=useMemo(function(){return _extends({},initialBillingFormState,{country:userCountry,region:userRegion});},[userCountry,userRegion]);var defaultShippingFormState=useMemo(function(){return _extends({},initialShippingFormState,{country:userCountry,region:userRegion});},[userCountry,userRegion]);var defaultExtraFormState=useMemo(function(){return _extends({},initialOptInFormState,{},extractDefaultValues(customerAttributes));},[customerAttributes]);// Form submit handlers
|
package/types.js
DELETED
|
File without changes
|