@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,2 +1,2 @@
|
|
|
1
|
-
import{css}from'glamor';import{themeConfig}from'@shopgate/pwa-common/helpers/config';var variables=themeConfig.variables;export var chevronButton=css({flexShrink:0,outline:0,margin:"0 -".concat(variables.gap.big,"px 0 ").concat(variables.gap.small,"px"),fontSize:'1.6em',color:'#373D41',position:'relative'});export var chevron=css({transformOrigin:'center center',transition:'transform 250ms cubic-bezier(0.25, 0.1, 0.25, 1)'});export var chevronDown=css(chevron,{transform:'rotateZ(0deg)'});export var chevronUp=css(chevron,{transform:'rotateZ(180deg)'});export var progressBar=css({position:'absolute',overflow:'hidden',width:'100%',bottom:0,height:3});export var open=css({// borderRight: '2px solid var(--color-primary)',
|
|
1
|
+
import{css}from'glamor';import{themeConfig}from'@shopgate/pwa-common/helpers/config';var variables=themeConfig.variables;export var chevronButton=css({flexShrink:0,outline:0,margin:"0 -".concat(variables.gap.big,"px 0 ").concat(variables.gap.small,"px"),fontSize:'1.6em',color:'#373D41',position:'relative'}).toString();export var chevron=css({transformOrigin:'center center',transition:'transform 250ms cubic-bezier(0.25, 0.1, 0.25, 1)'});export var chevronDown=css(chevron,{transform:'rotateZ(0deg)'});export var chevronUp=css(chevron,{transform:'rotateZ(180deg)'});export var progressBar=css({position:'absolute',overflow:'hidden',width:'100%',bottom:0,height:3}).toString();export var open=css({// borderRight: '2px solid var(--color-primary)',
|
|
2
2
|
}).toString();export var loadingIndicator=css({position:'absolute',padding:0,top:'50%',marginTop:'-50%',paddingTop:1,right:3}).toString();
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import React from'react';// eslint-disable-next-line import/no-cycle
|
|
1
|
+
import React from'react';import PropTypes from'prop-types';// eslint-disable-next-line import/no-cycle
|
|
2
2
|
import SideNavigationCategoriesItem from"./SideNavigationCategoriesItem";/**
|
|
3
|
-
* The SideNavigationCategoriesItemChildren component
|
|
4
|
-
* @
|
|
3
|
+
* The SideNavigationCategoriesItemChildren component.
|
|
4
|
+
* @param {Object} props The component props.
|
|
5
|
+
* @param {Array} props.subcategories The list of subcategories.
|
|
6
|
+
* @param {number} props.level The current nesting level.
|
|
7
|
+
* @returns {JSX.Element} The rendered component.
|
|
5
8
|
*/var SideNavigationCategoriesItemChildren=function SideNavigationCategoriesItemChildren(_ref){var subcategories=_ref.subcategories,level=_ref.level;return React.createElement("ul",null,subcategories.map(function(category){return React.createElement(SideNavigationCategoriesItem,{key:category.id,level:level,categoryId:category.id});}));};export default SideNavigationCategoriesItemChildren;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
import React,{useMemo}from'react';import{INDEX_PATH}from'@shopgate/pwa-common/constants/RoutePaths';import SideNavigationCategories from"./SideNavigationCategories";import SideNavigationLinks from"./SideNavigationLinks";import SideNavigationItem from"./SideNavigationItem";import{useSideNavigation}from"./SideNavigation.hooks";import{container}from"./SideNavigationContent.style";/**
|
|
2
|
-
*
|
|
1
|
+
import React,{useMemo}from'react';import PropTypes from'prop-types';import{INDEX_PATH}from'@shopgate/pwa-common/constants/RoutePaths';import SideNavigationCategories from"./SideNavigationCategories";import SideNavigationLinks from"./SideNavigationLinks";import SideNavigationItem from"./SideNavigationItem";import{useSideNavigation}from"./SideNavigation.hooks";import{container}from"./SideNavigationContent.style";/**
|
|
2
|
+
* SideNavigationContent component.
|
|
3
|
+
* @param {Object} props - The component props.
|
|
4
|
+
* @param {Object} [props.classNames] - The class names for the navigation visibility.
|
|
5
|
+
* @returns {JSX.Element} The rendered component.
|
|
3
6
|
*/var SideNavigationContent=function SideNavigationContent(_ref){var classNames=_ref.classNames;var _useSideNavigation=useSideNavigation(),isVisible=_useSideNavigation.isVisible;var wrapperClass=useMemo(function(){if(!classNames){return'';}var _classNames$visible=classNames.visible,visible=_classNames$visible===void 0?'':_classNames$visible,_classNames$hidden=classNames.hidden,hidden=_classNames$hidden===void 0?'':_classNames$hidden;return isVisible?visible:hidden;},[classNames,isVisible]);return React.createElement("div",{className:wrapperClass},isVisible&&React.createElement("nav",{className:container},React.createElement("ul",null,React.createElement(SideNavigationItem,{href:INDEX_PATH,label:"navigation.home"}),React.createElement(SideNavigationCategories,null),React.createElement(SideNavigationLinks,null))));};SideNavigationContent.defaultProps={classNames:null};export default SideNavigationContent;
|
|
@@ -1,4 +1,14 @@
|
|
|
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,{useMemo,memo}from'react';import classNames from'classnames';import Link from'@shopgate/pwa-common/components/Link';import{i18n}from'@shopgate/engage/core';import{getIndentation,item,itemActive,link,linkActive,list}from"./SideNavigationItem.style";import{useSideNavigation}from"./SideNavigation.hooks";/**
|
|
2
|
-
* SideNavigationItem component
|
|
3
|
-
* @
|
|
4
|
-
|
|
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,{useMemo,memo}from'react';import classNames from'classnames';import Link from'@shopgate/pwa-common/components/Link';import{i18n}from'@shopgate/engage/core';import PropTypes from'prop-types';import{getIndentation,item,itemActive,link,linkActive,list}from"./SideNavigationItem.style";import{useSideNavigation}from"./SideNavigation.hooks";/**
|
|
2
|
+
* SideNavigationItem component.
|
|
3
|
+
* @param {Object} props - The component props.
|
|
4
|
+
* @param {React.ReactNode} [props.children] - The child components.
|
|
5
|
+
* @param {number} [props.level=0] - The indentation level of the item.
|
|
6
|
+
* @param {React.ReactNode} [props.buttonRight] - The button to display on the right side.
|
|
7
|
+
* @param {boolean} [props.forceActive=false] - Whether to force the item to be active.
|
|
8
|
+
* @param {boolean} [props.forceInactive=false] - Whether to force the item to be inactive.
|
|
9
|
+
* @param {string} [props.className] - Additional class names for the item.
|
|
10
|
+
* @param {Function} [props.onClick] - The click handler for the item.
|
|
11
|
+
* @param {string} [props.href] - The URL the item links to.
|
|
12
|
+
* @param {string} props.label - The label text for the item.
|
|
13
|
+
* @returns {JSX.Element} The rendered component.
|
|
14
|
+
*/var SideNavigationItem=function SideNavigationItem(_ref){var children=_ref.children,level=_ref.level,buttonRight=_ref.buttonRight,forceActive=_ref.forceActive,forceInactive=_ref.forceInactive,className=_ref.className,onClick=_ref.onClick,href=_ref.href,label=_ref.label;var _useSideNavigation=useSideNavigation(),currentPathname=_useSideNavigation.currentPathname;var isActive=useMemo(function(){return!forceInactive&&(currentPathname===href||forceActive);},[currentPathname,forceActive,forceInactive,href]);return React.createElement("li",{className:classNames(list,className)},React.createElement("div",{className:classNames(item,_defineProperty({},itemActive,isActive))},href?React.createElement(Link,{tag:"a",href:href,className:classNames(link,getIndentation(level),_defineProperty({},linkActive,isActive))},i18n.text(label)):React.createElement("button",{type:"button",className:classNames(link,getIndentation(level),_defineProperty({},linkActive,isActive)),onClick:onClick},i18n.text(label)),buttonRight),children);};SideNavigationItem.defaultProps={buttonRight:null,children:null,forceActive:false,forceInactive:false,level:0,href:null,className:null,onClick:function onClick(){}};export default memo(SideNavigationItem);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import React from'react';import SideNavigationItem from"./SideNavigationItem";import connect from"./SideNavigationLinksLegal.connector";/**
|
|
2
|
-
*
|
|
3
|
-
* @param {Object} props The component props
|
|
4
|
-
* @
|
|
1
|
+
import React from'react';import PropTypes from'prop-types';import SideNavigationItem from"./SideNavigationItem";import connect from"./SideNavigationLinksLegal.connector";/**
|
|
2
|
+
* SideNavigationLinksLegal component.
|
|
3
|
+
* @param {Object} props - The component props.
|
|
4
|
+
* @param {Array<{label: string, url: string}>} [props.links] - The list of legal links.
|
|
5
|
+
* @returns {*[]} The rendered component or null.
|
|
5
6
|
*/var SideNavigationLinksLegal=function SideNavigationLinksLegal(_ref){var links=_ref.links;if(!links){return null;}return links.map(function(_ref2){var label=_ref2.label,url=_ref2.url;return React.createElement(SideNavigationItem,{key:url,href:url,label:label});});};SideNavigationLinksLegal.defaultProps={links:null,isFetching:false};export default connect(SideNavigationLinksLegal);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import React from'react';import SideNavigationItem from"./SideNavigationItem";import connect from"./SideNavigationLinksQuicklinks.connector";/**
|
|
1
|
+
import React from'react';import PropTypes from'prop-types';import SideNavigationItem from"./SideNavigationItem";import connect from"./SideNavigationLinksQuicklinks.connector";/**
|
|
2
2
|
*
|
|
3
3
|
* @param {Object} props The component props
|
|
4
|
-
* @
|
|
5
|
-
|
|
4
|
+
* @param {Array} props.links The quicklinks links
|
|
5
|
+
* @returns {*[]}
|
|
6
|
+
*/var SideNavigationLinksQuicklinks=function SideNavigationLinksQuicklinks(_ref){var links=_ref.links;if(!links){return null;}return links.map(function(_ref2){var label=_ref2.label,url=_ref2.url;return React.createElement(SideNavigationItem,{key:url,href:url,label:label});});};SideNavigationLinksQuicklinks.defaultProps={links:null};export default connect(SideNavigationLinksQuicklinks);
|
|
@@ -1,4 +1,10 @@
|
|
|
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,{useState,useCallback,useMemo,useEffect}from'react';import ArrowDrop from'@shopgate/pwa-ui-shared/icons/ArrowDropIcon';import{chevronButton,chevronUp,chevronDown,open}from"./SideNavigationCategoriesItem.style";import SideNavigationItem from"./SideNavigationItem";/**
|
|
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,{useState,useCallback,useMemo,useEffect}from'react';import ArrowDrop from'@shopgate/pwa-ui-shared/icons/ArrowDropIcon';import PropTypes from'prop-types';import{chevronButton,chevronUp,chevronDown,open}from"./SideNavigationCategoriesItem.style";import SideNavigationItem from"./SideNavigationItem";/**
|
|
2
2
|
* The SideNavigationCategoriesItem component
|
|
3
|
-
* @
|
|
3
|
+
* @param {Object} props The component props.
|
|
4
|
+
* @param {number} props.level The nesting level.
|
|
5
|
+
* @param {string} props.label The item label.
|
|
6
|
+
* @param {string} props.href The item href.
|
|
7
|
+
* @param {JSX.Element} props.children The nested items.
|
|
8
|
+
* @param {boolean} props.forceActive Whether the item should be forced open.
|
|
9
|
+
* @returns {JSX.Element}
|
|
4
10
|
*/var SideNavigationNestedItem=function SideNavigationNestedItem(_ref){var level=_ref.level,label=_ref.label,href=_ref.href,children=_ref.children,forceActive=_ref.forceActive;var _useState=useState(forceActive),_useState2=_slicedToArray(_useState,2),isOpen=_useState2[0],setIsOpen=_useState2[1];useEffect(function(){if(forceActive){setIsOpen(true);}},[forceActive]);var handleClick=useCallback(function(){setIsOpen(!isOpen);},[isOpen]);var buttonRight=useMemo(function(){return React.createElement("button",{type:"button",onClick:handleClick,className:chevronButton},React.createElement(ArrowDrop,{className:(isOpen?chevronUp:chevronDown).toString()}));},[handleClick,isOpen]);return React.createElement(SideNavigationItem,{href:href,label:label,level:level,buttonRight:buttonRight,className:level===0&&isOpen?open:null,forceInactive:true},isOpen?children:null);};SideNavigationNestedItem.defaultProps={level:0,forceActive:false};export default SideNavigationNestedItem;
|
|
@@ -1,4 +1,13 @@
|
|
|
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,{useState,useMemo,useEffect}from'react';import{CATEGORY_PATTERN,CATEGORY_FILTER_PATTERN}from'@shopgate/pwa-common-commerce/category/constants';import{ITEM_PATTERN,ITEM_GALLERY_PATTERN,ITEM_REVIEWS_PATTERN,ITEM_WRITE_REVIEW_PATTERN}from'@shopgate/pwa-common-commerce/product/constants';import{hex2bin}from'@shopgate/pwa-common/helpers/data';import Context from"./SideNavigationProvider.context";import connect from"./SideNavigationProvider.connector";var categoryPatterns=[CATEGORY_PATTERN,CATEGORY_FILTER_PATTERN];var itemPatterns=[ITEM_PATTERN,ITEM_GALLERY_PATTERN,ITEM_REVIEWS_PATTERN,ITEM_WRITE_REVIEW_PATTERN];/**
|
|
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,{useState,useMemo,useEffect}from'react';import PropTypes from'prop-types';import{CATEGORY_PATTERN,CATEGORY_FILTER_PATTERN}from'@shopgate/pwa-common-commerce/category/constants';import{ITEM_PATTERN,ITEM_GALLERY_PATTERN,ITEM_REVIEWS_PATTERN,ITEM_WRITE_REVIEW_PATTERN}from'@shopgate/pwa-common-commerce/product/constants';import{hex2bin}from'@shopgate/pwa-common/helpers/data';import Context from"./SideNavigationProvider.context";import connect from"./SideNavigationProvider.connector";var categoryPatterns=[CATEGORY_PATTERN,CATEGORY_FILTER_PATTERN];var itemPatterns=[ITEM_PATTERN,ITEM_GALLERY_PATTERN,ITEM_REVIEWS_PATTERN,ITEM_WRITE_REVIEW_PATTERN];/**
|
|
2
2
|
* SideNavigation Provider
|
|
3
|
-
* @
|
|
4
|
-
|
|
3
|
+
* @param {Object} props The component props.
|
|
4
|
+
* @param {number} props.maxCategoryNesting Maximum category nesting level.
|
|
5
|
+
* @param {Array} [props.routePatternBlacklist=[]] List of route patterns to blacklist.
|
|
6
|
+
* @param {Object} [props.currentParams=null] Current route parameters.
|
|
7
|
+
* @param {string} [props.currentPathname=''] Current pathname.
|
|
8
|
+
* @param {Object} [props.currentRoute=null] Current route object.
|
|
9
|
+
* @param {boolean} props.isLoggedIn Whether the user is logged in.
|
|
10
|
+
* @param {Function} props.logout Logout function.
|
|
11
|
+
* @param {React.ReactNode} props.children Child components.
|
|
12
|
+
* @returns {JSX.Element} The rendered component.
|
|
13
|
+
*/var SideNavigationProvider=function SideNavigationProvider(_ref){var maxCategoryNesting=_ref.maxCategoryNesting,routePatternBlacklist=_ref.routePatternBlacklist,currentParams=_ref.currentParams,currentPathname=_ref.currentPathname,currentRoute=_ref.currentRoute,isLoggedIn=_ref.isLoggedIn,logout=_ref.logout,children=_ref.children;var _useState=useState(null),_useState2=_slicedToArray(_useState,2),activeCategoryId=_useState2[0],setActiveCategoryId=_useState2[1];var _useState3=useState(true),_useState4=_slicedToArray(_useState3,2),isVisible=_useState4[0],setIsVisible=_useState4[1];useEffect(function(){if(!currentRoute){return;}var pattern=currentRoute.pattern;if(categoryPatterns.includes(pattern)){var categoryId=currentParams.categoryId;setActiveCategoryId(hex2bin(categoryId));}else if(!itemPatterns.includes(pattern)){setActiveCategoryId(null);}setIsVisible(!routePatternBlacklist.includes(pattern));},[currentRoute,currentParams,routePatternBlacklist]);var value=useMemo(function(){return{maxCategoryNesting:maxCategoryNesting,currentParams:currentParams,currentPathname:currentPathname,currentRoute:currentRoute,isLoggedIn:isLoggedIn,logout:logout,activeCategoryId:activeCategoryId,isVisible:isVisible};},[activeCategoryId,currentParams,currentPathname,currentRoute,isLoggedIn,isVisible,logout,maxCategoryNesting]);return React.createElement(Context.Provider,{value:value},children);};SideNavigationProvider.defaultProps={currentParams:null,currentPathname:'',routePatternBlacklist:[],currentRoute:null};export default connect(SideNavigationProvider);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {Object} MerchantSettings
|
|
3
|
+
* @property {string[]} enabledFulfillmentMethods
|
|
4
|
+
* @property {string[]} enabledFulfillmentMethodSelectionForEngage
|
|
5
|
+
*/ /**
|
|
6
|
+
* @typedef {Object} ShopSettings
|
|
7
|
+
* @property {string[]} [supportedCountries]
|
|
8
|
+
* @property {string[]} [countrySortOrder]
|
|
9
|
+
*/ /**
|
|
10
|
+
* @typedef {Object} ConfigState
|
|
11
|
+
* @property {boolean} isFetching
|
|
12
|
+
* @property {number} expires
|
|
13
|
+
* @property {MerchantSettings} merchantSettings
|
|
14
|
+
* @property {ShopSettings} shopSettings
|
|
15
|
+
*/
|
|
@@ -5,7 +5,7 @@ import _regeneratorRuntime from"@babel/runtime/regenerator";function asyncGenera
|
|
|
5
5
|
* @param {Function} asyncFunction The function that will be executed to generate memoized output.
|
|
6
6
|
* @param {Array} asyncFunctionDependencies
|
|
7
7
|
* A list of dependencies (same behavior as with `React.useMemo`)
|
|
8
|
-
* @param {
|
|
8
|
+
* @param {any} initialValue The initial value that is set before promise is fulfilled.
|
|
9
9
|
* @returns {Array}
|
|
10
10
|
*/export function useAsyncMemo(asyncFunction){var asyncFunctionDependencies=arguments.length>1&&arguments[1]!==undefined?arguments[1]:[];var initialValue=arguments.length>2&&arguments[2]!==undefined?arguments[2]:null;var _React$useState=React.useState(initialValue),_React$useState2=_slicedToArray(_React$useState,2),value=_React$useState2[0],setValue=_React$useState2[1];var _React$useState3=React.useState(false),_React$useState4=_slicedToArray(_React$useState3,2),error=_React$useState4[0],setError=_React$useState4[1];/* eslint-disable react-hooks/exhaustive-deps */React.useEffect(function(){/**
|
|
11
11
|
* Wraps the async function as React doesn't allow direct async usage.
|
package/i18n/countries.hooks.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import{useMemo}from'react';import{getCountryNames}from"./countries.helpers";/**
|
|
2
|
-
*
|
|
3
|
-
* @param {string[]} [countryCodes=[]] .
|
|
4
|
-
* @param {Object} [defaultLocales={}] Default locales from third
|
|
5
|
-
* @returns {Object|null}
|
|
6
|
-
*/export function useCountriesNames(){var countryCodes=arguments.length>0&&arguments[0]!==undefined?arguments[0]:[];var defaultLocales=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};return useMemo(function(){return getCountryNames(countryCodes,defaultLocales);},[countryCodes,defaultLocales]);}
|
|
2
|
+
* Custom hook to get country names as key-value pairs.
|
|
3
|
+
* @param {string[]} [countryCodes=[]] An array of country codes.
|
|
4
|
+
* @param {Object} [defaultLocales={}] Default locales from third-party sources.
|
|
5
|
+
* @returns {Object|null} An object containing country names as key-value pairs.
|
|
6
|
+
*/export var useCountriesNames=function useCountriesNames(){var countryCodes=arguments.length>0&&arguments[0]!==undefined?arguments[0]:[];var defaultLocales=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};return useMemo(function(){return getCountryNames(countryCodes,defaultLocales);},[countryCodes,defaultLocales]);};
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import{SET_USER_SEARCH_COUNTRY_CODE}from"../constants";/**
|
|
2
|
+
* @typedef {Object} SetUserSearchCountryCodeActionType
|
|
3
|
+
* @property {string} type The action type.
|
|
4
|
+
* @property {string} countryCode The country code.
|
|
5
|
+
* @property {string|null} productId The product ID.
|
|
6
|
+
* @property {boolean} isStoreFinder Indicates if the action was dispatched for the store finder.
|
|
7
|
+
*/ /**
|
|
2
8
|
* Creates the dispatched SET_USER_SEARCH_COUNTRY_CODE action object.
|
|
3
|
-
* @param {string} countryCode The
|
|
4
|
-
* @param {string} [productId=null] An optional product code.
|
|
5
|
-
* @param {boolean} [isStoreFinder=false]
|
|
6
|
-
*
|
|
9
|
+
* @param {string} countryCode The country code.
|
|
10
|
+
* @param {string|null} [productId=null] An optional product code.
|
|
11
|
+
* @param {boolean} [isStoreFinder=false]
|
|
12
|
+
* Indicates if the action was dispatched for the store finder.
|
|
13
|
+
* @returns {SetUserSearchCountryCodeActionType} The action object.
|
|
7
14
|
*/var setUserSearchCountryCode=function setUserSearchCountryCode(countryCode){var productId=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;var isStoreFinder=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;return{type:SET_USER_SEARCH_COUNTRY_CODE,countryCode:countryCode,productId:productId,isStoreFinder:isStoreFinder};};export default setUserSearchCountryCode;
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import{SET_USER_SEARCH_POSTAL_CODE}from"../constants";/**
|
|
2
|
+
* @typedef {Object} SetUserSearchPostalCodeActionType
|
|
3
|
+
* @property {string} type The action type.
|
|
4
|
+
* @property {string|null} postalCode The postal code.
|
|
5
|
+
* @property {string|null} productId The product ID.
|
|
6
|
+
* @property {boolean} isStoreFinder Indicates if the action was dispatched for the store finder.
|
|
7
|
+
*/ /**
|
|
2
8
|
* Creates the dispatched SET_USER_SEARCH_POSTAL_CODE action object.
|
|
3
|
-
* @param {string} postalCode The
|
|
4
|
-
* @param {string} [productId=null] An optional product code.
|
|
5
|
-
* @param {boolean} [isStoreFinder=false]
|
|
6
|
-
*
|
|
9
|
+
* @param {string|null} postalCode The postal code.
|
|
10
|
+
* @param {string|null} [productId=null] An optional product code.
|
|
11
|
+
* @param {boolean} [isStoreFinder=false]
|
|
12
|
+
* Indicates if the action was dispatched for the store finder.
|
|
13
|
+
* @returns {SetUserSearchPostalCodeActionType} The action object.
|
|
7
14
|
*/var setUserSearchPostalCode=function setUserSearchPostalCode(postalCode){var productId=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;var isStoreFinder=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;return{type:SET_USER_SEARCH_POSTAL_CODE,postalCode:postalCode,productId:productId,isStoreFinder:isStoreFinder};};export default setUserSearchPostalCode;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import{connect}from'react-redux';import{fetchProductLocations}from"../../actions";/**
|
|
2
|
+
* @typedef {import('./CartChangeFulfillmentMethod.types').OwnProps} OwnProps
|
|
3
|
+
* @typedef {import('./CartChangeFulfillmentMethod.types').DispatchProps} DispatchProps
|
|
4
|
+
*/ /**
|
|
2
5
|
* @param {Function} dispatch The redux dispatch function.
|
|
3
|
-
* @
|
|
6
|
+
* @returns {DispatchProps} The extended component props.
|
|
4
7
|
*/var mapDispatchToProps={fetchProductLocations:fetchProductLocations};export default connect(null,mapDispatchToProps);
|
|
@@ -1,8 +1,11 @@
|
|
|
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
|
|
2
|
-
* @
|
|
3
|
-
* @
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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,useState}from'react';import PropTypes from'prop-types';import{FulfillmentSheet}from"../FulfillmentSheet";import connect from"./CartChangeFulfillmentMethod.connector";import{STAGE_FULFILLMENT_METHOD}from"../../constants";/**
|
|
2
|
+
* @typedef {import('./CartChangeFulfillmentMethod.types').OwnProps} OwnProps
|
|
3
|
+
* @typedef {import('./CartChangeFulfillmentMethod.types').DispatchProps} DispatchProps
|
|
4
|
+
* @typedef {OwnProps & DispatchProps} Props
|
|
5
|
+
*/ /**
|
|
6
|
+
* Renders the CartChangeFulfillmentMethod component.
|
|
7
|
+
* @param {Props} props The component props.
|
|
8
|
+
* @returns {JSX.Element|null}
|
|
9
|
+
*/var CartChangeFulfillmentMethod=function CartChangeFulfillmentMethod(_ref){var cartItem=_ref.cartItem,fetchProductLocations=_ref.fetchProductLocations,registerAction=_ref.registerAction;var _useState=useState(false),_useState2=_slicedToArray(_useState,2),opened=_useState2[0],setOpened=_useState2[1];useEffect(function(){if(!registerAction||!cartItem){return;}registerAction('changeFulfillment',function(){fetchProductLocations(cartItem.product.id);setOpened(true);});},[cartItem,fetchProductLocations,registerAction]);/**
|
|
7
10
|
* Handles closing of the sheet.
|
|
8
|
-
*/function handleClose(){setOpened(false);}if(!opened){return null;}return React.createElement(FulfillmentSheet,{open:true,productId:cartItem.product.id,stage:STAGE_FULFILLMENT_METHOD,meta:{cartItem:cartItem},onClose:handleClose,updatePreferredLocation:true});}export default connect(CartChangeFulfillmentMethod);
|
|
11
|
+
*/function handleClose(){setOpened(false);}if(!opened){return null;}return React.createElement(FulfillmentSheet,{open:true,productId:cartItem.product.id,stage:STAGE_FULFILLMENT_METHOD,meta:{cartItem:cartItem},onClose:handleClose,updatePreferredLocation:true});};CartChangeFulfillmentMethod.defaultProps={registerAction:null};export default connect(CartChangeFulfillmentMethod);
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import React,{useMemo}from'react';import{hot}from'react-hot-loader/root';import{FulfillmentProvider}from"../../providers";import{FulfillmentSheetContent}from"../FulfillmentSheet/FulfillmentSheetContent";import CartContextMenuChangeFulfillmentContent from"./CartContextMenuChangeFulfillmentContent";/**
|
|
2
|
-
*
|
|
1
|
+
import React,{useMemo}from'react';import PropTypes from'prop-types';import{hot}from'react-hot-loader/root';import{FulfillmentProvider}from"../../providers";import{FulfillmentSheetContent}from"../FulfillmentSheet/FulfillmentSheetContent";import CartContextMenuChangeFulfillmentContent from"./CartContextMenuChangeFulfillmentContent";/**
|
|
2
|
+
* @typedef {import('../../../cart/cart.types').Item} Item
|
|
3
|
+
*/ /**
|
|
4
|
+
* @typedef {Object} Props
|
|
5
|
+
* @property {Item} cartItem
|
|
6
|
+
*/ /**
|
|
7
|
+
* The CartContextMenuChangeFulfillment component renders a context menu which enables
|
|
3
8
|
* switching the active fulfillment method for a cart item.
|
|
4
|
-
* @param {
|
|
5
|
-
* @returns {JSX}
|
|
9
|
+
* @param {Props} props The component props.
|
|
10
|
+
* @returns {JSX.Element}
|
|
6
11
|
*/var CartContextMenuChangeFulfillment=function CartContextMenuChangeFulfillment(_ref){var cartItem=_ref.cartItem;var contextProps=useMemo(function(){return{productId:cartItem.product.id,meta:{cartItem:cartItem},updatePreferredLocation:true};},[cartItem]);return React.createElement(FulfillmentProvider,contextProps,React.createElement(CartContextMenuChangeFulfillmentContent,null),React.createElement(FulfillmentSheetContent,null));};export default hot(CartContextMenuChangeFulfillment);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from'react';import PropTypes from'prop-types';import noop from'lodash/noop';import{I18n,ContextMenu}from'@shopgate/engage/components';import{DIRECT_SHIP}from"../../constants";/**
|
|
2
|
+
* Renders the cart context menu item for changing the location.
|
|
2
3
|
* @param {Object} props The component props.
|
|
3
|
-
* @
|
|
4
|
-
* @
|
|
5
|
-
* @
|
|
6
|
-
* @returns {JSX}
|
|
7
|
-
*/export var CartContextMenuItemChangeLocation=function CartContextMenuItemChangeLocation(
|
|
4
|
+
* @param {Object} props.cartItem The cart item.
|
|
5
|
+
* @param {Function} [props.onClick=noop] The click handler.
|
|
6
|
+
* @param {Function} [props.closeMenu=noop] The menu close handler.
|
|
7
|
+
* @returns {JSX.Element|null} The rendered component or null.
|
|
8
|
+
*/export var CartContextMenuItemChangeLocation=function CartContextMenuItemChangeLocation(_ref){var cartItem=_ref.cartItem,onClick=_ref.onClick,closeMenu=_ref.closeMenu;if(!cartItem.fulfillment||cartItem.fulfillment.method===DIRECT_SHIP){return null;}return React.createElement(ContextMenu.Item,{onClick:onClick,closeMenu:closeMenu},React.createElement(I18n.Text,{string:"locations.change_location"}));};CartContextMenuItemChangeLocation.defaultProps={onClick:noop,closeMenu:noop};
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import{connect}from'react-redux';import{updateProductsInCart}from'@shopgate/engage/cart';import{fetchProductLocations}from"../../actions";/**
|
|
2
|
+
* @typedef {import('./CartItemProductChangeLocation.types').OwnProps} OwnProps
|
|
3
|
+
* @typedef {import('./CartItemProductChangeLocation.types').DispatchProps} DispatchProps
|
|
4
|
+
*/ /**
|
|
2
5
|
* Connects the dispatch function to a callable function in the props.
|
|
3
6
|
* @param {Function} dispatch The redux dispatch function.
|
|
4
|
-
* @
|
|
7
|
+
* @returns {DispatchProps} The extended component props.
|
|
5
8
|
*/var mapDispatchToProps=function mapDispatchToProps(dispatch){return{fetchProductLocations:fetchProductLocations,updateProductInCart:function updateProductInCart(cartItemId,quantity,location,fulfillmentMethod){dispatch(updateProductsInCart([{cartItemId:cartItemId,quantity:quantity,fulfillment:{method:fulfillmentMethod,location:{code:location.code,name:location.name}}}]));}};};export default connect(null,mapDispatchToProps);
|
|
@@ -1,11 +1,14 @@
|
|
|
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
|
|
2
|
-
* @
|
|
3
|
-
* @
|
|
4
|
-
|
|
5
|
-
* @
|
|
6
|
-
|
|
7
|
-
|
|
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 noop from'lodash/noop';import React,{useEffect,useState,useCallback}from'react';import PropTypes from'prop-types';import{FulfillmentSheet}from"../FulfillmentSheet";import{isProductAvailable}from"../../helpers";import{STAGE_SELECT_STORE}from"../../constants";import connect from"./CartItemProductChangeLocation.connector";/**
|
|
2
|
+
* @typedef {import('./CartItemProductChangeLocation.types').OwnProps} OwnProps
|
|
3
|
+
* @typedef {import('./CartItemProductChangeLocation.types').DispatchProps} DispatchProps
|
|
4
|
+
*/ /**
|
|
5
|
+
* @typedef {OwnProps & DispatchProps} Props
|
|
6
|
+
*/ /**
|
|
7
|
+
* @param {Props} props The component props.
|
|
8
|
+
* @returns {JSX.Element|null}
|
|
9
|
+
*/var CartItemProductChangeLocation=function CartItemProductChangeLocation(props){var cartItem=props.cartItem,updateProductInCart=props.updateProductInCart,fetchProductLocations=props.fetchProductLocations,registerAction=props.registerAction;var _useState=useState(false),_useState2=_slicedToArray(_useState,2),opened=_useState2[0],setOpened=_useState2[1];var _useState3=useState(null),_useState4=_slicedToArray(_useState3,2),fulfillmentMethod=_useState4[0],setFulfillmentMethod=_useState4[1];/**
|
|
8
10
|
* Register cart item action
|
|
9
|
-
*/
|
|
11
|
+
*/useEffect(function(){if(!registerAction||!cartItem){return;}registerAction('changeLocation',function(currentFulfillmentMethod){fetchProductLocations(cartItem.product.id);setOpened(true);setFulfillmentMethod(currentFulfillmentMethod);});},[cartItem,fetchProductLocations,registerAction]);/**
|
|
10
12
|
* Select location callback
|
|
11
|
-
|
|
13
|
+
* @param {Object|null} location
|
|
14
|
+
*/var onLocationSelect=useCallback(function(location){setTimeout(function(){return setOpened(false);},500);if(!location||!isProductAvailable(location,location===null||location===void 0?void 0:location.inventory)){return;}updateProductInCart(cartItem.id,cartItem.quantity,location,fulfillmentMethod);setFulfillmentMethod(fulfillmentMethod);},[cartItem.id,cartItem.quantity,fulfillmentMethod,updateProductInCart]);var fulfillment=cartItem.fulfillment;if(!opened||!fulfillment){return null;}return React.createElement(FulfillmentSheet,{stage:STAGE_SELECT_STORE,open:true,title:"locations.headline",changeOnly:true,productId:cartItem.product.id,updatePreferredLocation:true,onClose:onLocationSelect,isCart:true});};CartItemProductChangeLocation.defaultProps={registerAction:noop};export default connect(CartItemProductChangeLocation);
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import React from'react';import{RippleButton,I18n,SurroundPortals}from'@shopgate/engage/components';import{button,ripple}from"./ChangeLocationButton.style";import{PRODUCT_FULFILLMENT_CHANGE_LOCATION}from"../../constants/Portals";/**
|
|
2
|
-
*
|
|
3
|
-
* @
|
|
1
|
+
import React from'react';import PropTypes from'prop-types';import{RippleButton,I18n,SurroundPortals}from'@shopgate/engage/components';import{button,ripple}from"./ChangeLocationButton.style";import{PRODUCT_FULFILLMENT_CHANGE_LOCATION}from"../../constants/Portals";/**
|
|
2
|
+
* Renders the Change Location button.
|
|
3
|
+
* @param {Object} props The component props.
|
|
4
|
+
* @param {Function} props.onClick The click handler.
|
|
5
|
+
* @param {boolean} [props.disabled=false] Whether the button is disabled.
|
|
6
|
+
* @returns {JSX.Element} The rendered component.
|
|
4
7
|
*/export var ChangeLocationButtonUnwrapped=function ChangeLocationButtonUnwrapped(_ref){var onClick=_ref.onClick,disabled=_ref.disabled;return React.createElement(SurroundPortals,{portalName:PRODUCT_FULFILLMENT_CHANGE_LOCATION,portalProps:{onClick:onClick,disabled:disabled}},React.createElement(RippleButton,{onClick:onClick,className:button,disabled:disabled,rippleClassName:ripple,type:"secondary",flat:true},React.createElement(I18n.Text,{string:"locations.change_location"})));};ChangeLocationButtonUnwrapped.defaultProps={disabled:false};export var ChangeLocationButton=React.memo(ChangeLocationButtonUnwrapped);
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
var _excluded=["name","children"];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
|
|
1
|
+
var _excluded=["name","children"];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 React from'react';import PropTypes from'prop-types';import{i18n}from"../../../core";import{RadioGroupItem}from"../../../components";import{radioItem,itemLabel}from"./FulfillmentPath.style";/**
|
|
2
2
|
* Renders a RadioItem element to be used by the FulfillmentPathSelector component.
|
|
3
|
-
* This component is meant to be rendered as child of a RadioGroup.
|
|
4
|
-
* @param {Object} props
|
|
5
|
-
* @
|
|
3
|
+
* This component is meant to be rendered as a child of a RadioGroup.
|
|
4
|
+
* @param {Object} props The component props required by the RadioGroupItem component.
|
|
5
|
+
* @param {React.ReactNode|null} [props.children=null] The child elements.
|
|
6
|
+
* @param {string} props.name The name of the radio item.
|
|
7
|
+
* @returns {JSX.Element} The rendered component.
|
|
6
8
|
*/export var FulfillmentPathItem=function FulfillmentPathItem(_ref){var name=_ref.name,children=_ref.children,rest=_objectWithoutProperties(_ref,_excluded);return React.createElement(RadioGroupItem,_extends({},rest,{name:name,className:radioItem,label:React.createElement("div",{className:itemLabel},React.createElement("span",null,i18n.text(name)),children)}));};FulfillmentPathItem.defaultProps={children:null};
|
|
@@ -1,9 +1,23 @@
|
|
|
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{connect}from'react-redux';import{hasProductVariants,isProductOrderable,makeIsBaseProductActive}from'@shopgate/engage/product';import{DIRECT_SHIP,ROPIS,BOPIS}from"../../constants";import{makeGetEnabledFulfillmentMethods,makeGetFulfillmentPaths,makeUseLocationFulfillmentMethods}from"../../../core/config";import{getProductShowAlternativeLocation}from"../../../core/selectors";import{MERCHANT_SETTINGS_PRODUCT_SHOW_ALTERNATIVE_LOCATION}from"../../../core/constants";import{makeIsFulfillmentSelectorMethodEnabled,getPreferredLocation,makeGetLocationInventory,makeGetLocationFulfillmentMethods,getPreferredFulfillmentMethod,getProductFulfillmentMethods,getUserSearch}from"../../selectors";import{storeFulfillmentMethod}from"../../action-creators"
|
|
2
|
-
*
|
|
3
|
-
|
|
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{connect}from'react-redux';import{hasProductVariants,isProductOrderable,makeIsBaseProductActive}from'@shopgate/engage/product';import{DIRECT_SHIP,ROPIS,BOPIS}from"../../constants";import{makeGetEnabledFulfillmentMethods,makeGetFulfillmentPaths,makeUseLocationFulfillmentMethods}from"../../../core/config";import{getProductShowAlternativeLocation}from"../../../core/selectors";import{MERCHANT_SETTINGS_PRODUCT_SHOW_ALTERNATIVE_LOCATION}from"../../../core/constants";import{makeIsFulfillmentSelectorMethodEnabled,getPreferredLocation,makeGetLocationInventory,makeGetLocationFulfillmentMethods,getPreferredFulfillmentMethod,getProductFulfillmentMethods,getUserSearch}from"../../selectors";import{storeFulfillmentMethod}from"../../action-creators";/* eslint-disable max-len */ /** @typedef {import('./FulfillmentSelector.types').OwnProps} OwnProps */ /** @typedef {import('./FulfillmentSelector.types').StateProps} StateProps */ /** @typedef {import('./FulfillmentSelector.types').DispatchProps} DispatchProps */ /**
|
|
2
|
+
* Maps state to props for the component.
|
|
3
|
+
* @returns {function(state: any, props: OwnProps): StateProps} A function that maps state and props to StateProps.
|
|
4
|
+
*/var makeMapStateToProps=function makeMapStateToProps(){/**
|
|
5
|
+
* Retrieves the location code based on the state and props.
|
|
6
|
+
* @param {any} state The application state.
|
|
7
|
+
* @param {OwnProps} props The component props.
|
|
8
|
+
* @returns {string|null} The location code.
|
|
9
|
+
*/var getLocationCode=function getLocationCode(state,props){var _getPreferredLocation;return(_getPreferredLocation=getPreferredLocation(state,props))===null||_getPreferredLocation===void 0?void 0:_getPreferredLocation.code;};/**
|
|
10
|
+
* Retrieves the product code based on the props.
|
|
11
|
+
* @param {any} _ Unused state parameter.
|
|
12
|
+
* @param {OwnProps} props The component props.
|
|
13
|
+
* @returns {string|null} The product code.
|
|
14
|
+
*/var getProductCode=function getProductCode(_,props){return props.variantId||props.productId||null;};var getFulfillmentPaths=makeGetFulfillmentPaths();var isDirectShipEnabled=makeIsFulfillmentSelectorMethodEnabled(getLocationCode,getProductCode,DIRECT_SHIP);var isROPISEnabled=makeIsFulfillmentSelectorMethodEnabled(getLocationCode,getProductCode,ROPIS,// Set to true when fulfillment methods shall not be disabled that are not supported by location
|
|
4
15
|
false);var isBOPISEnabled=makeIsFulfillmentSelectorMethodEnabled(getLocationCode,getProductCode,BOPIS,// Set to true when fulfillment methods shall not be disabled that are not supported by location
|
|
5
16
|
false);var getInventory=makeGetLocationInventory(getLocationCode,getProductCode);var getEnabledFulfillmentMethods=makeGetEnabledFulfillmentMethods();var getLocationFulfillmentMethods=makeGetLocationFulfillmentMethods(getLocationCode);var isBaseProductActive=makeIsBaseProductActive();var useLocationFulfillmentMethods=makeUseLocationFulfillmentMethods();/**
|
|
6
17
|
* @param {Object} state The application state.
|
|
7
|
-
* @param {
|
|
8
|
-
* @returns {
|
|
9
|
-
*/return function(state,props){var hasVariants=hasProductVariants(state,props);var baseProductActive=isBaseProductActive(state,props);return{merchantSettings:_defineProperty({},MERCHANT_SETTINGS_PRODUCT_SHOW_ALTERNATIVE_LOCATION,getProductShowAlternativeLocation(state)),fulfillmentPaths:getFulfillmentPaths(state),shopFulfillmentMethods:getEnabledFulfillmentMethods(state),productFulfillmentMethods:getProductFulfillmentMethods(state,props),locationFulfillmentMethods:getLocationFulfillmentMethods(state,props),useLocationFulfillmentMethods:useLocationFulfillmentMethods(state,props),userFulfillmentMethod:getPreferredFulfillmentMethod(state,props),preferredLocation:getPreferredLocation(state,props),inventory:getInventory(state,props),isDirectShipEnabled:isDirectShipEnabled(state,props),isROPISEnabled:isROPISEnabled(state,props),isBOPISEnabled:isBOPISEnabled(state,props),isOrderable:isProductOrderable(state,props)||!!hasVariants,isReady:hasVariants!==null&&(!hasVariants||!baseProductActive),userSearch:getUserSearch(state)};};}
|
|
18
|
+
* @param {OwnProps} props The component props.
|
|
19
|
+
* @returns {StateProps} The mapped state props.
|
|
20
|
+
*/return function(state,props){var hasVariants=hasProductVariants(state,props);var baseProductActive=isBaseProductActive(state,props);return{merchantSettings:_defineProperty({},MERCHANT_SETTINGS_PRODUCT_SHOW_ALTERNATIVE_LOCATION,getProductShowAlternativeLocation(state)),fulfillmentPaths:getFulfillmentPaths(state),shopFulfillmentMethods:getEnabledFulfillmentMethods(state),productFulfillmentMethods:getProductFulfillmentMethods(state,props),locationFulfillmentMethods:getLocationFulfillmentMethods(state,props),useLocationFulfillmentMethods:useLocationFulfillmentMethods(state,props),userFulfillmentMethod:getPreferredFulfillmentMethod(state,props),preferredLocation:getPreferredLocation(state,props),inventory:getInventory(state,props),isDirectShipEnabled:isDirectShipEnabled(state,props),isROPISEnabled:isROPISEnabled(state,props),isBOPISEnabled:isBOPISEnabled(state,props),isOrderable:isProductOrderable(state,props)||!!hasVariants,isReady:hasVariants!==null&&(!hasVariants||!baseProductActive),userSearch:getUserSearch(state)};};};/* eslint-enable max-len */ /**
|
|
21
|
+
* Maps dispatch actions to props for the component.
|
|
22
|
+
* @type {DispatchProps}
|
|
23
|
+
*/var mapDispatchToProps={storeFulfillmentMethod:storeFulfillmentMethod};export default connect(makeMapStateToProps,mapDispatchToProps);
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
// eslint-disable-next-line max-len
|
|
2
|
+
/** @typedef {import('./FulfillmentSelector.types').FulfillmentSelectorContextProps} FulfillmentSelectorContextProps */import{createContext}from'react';import{DIRECT_SHIP}from"../../constants";/** @type {FulfillmentSelectorContextProps} */export var FulfillmentSelectorContext=createContext({selection:DIRECT_SHIP,selectedLocation:null,location:null,isDirectShipEnabled:false,isROPISEnabled:false,isBOPISEnabled:false,isReady:false,productId:null,handleChange:function handleChange(){},conditioner:{},fulfillmentPaths:[],userFulfillmentMethod:null,isOrderable:false,shopFulfillmentMethods:null,productFulfillmentMethods:null,locationFulfillmentMethods:null,useLocationFulfillmentMethods:false,merchantSettings:null});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// eslint-disable-next-line max-len
|
|
2
|
+
/** @typedef {import('./FulfillmentSelector.types').FulfillmentSelectorContextProps} FulfillmentSelectorContextProps */import{useContext}from'react';import{FulfillmentSelectorContext}from"./FulfillmentSelector.context";/**
|
|
3
|
+
* @returns {FulfillmentSelectorContextProps} The fulfillment selector context.
|
|
3
4
|
*/export function useFulfillmentSelectorState(){return useContext(FulfillmentSelectorContext);}
|
|
@@ -1,20 +1,11 @@
|
|
|
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{hot}from'react-hot-loader/root';import React,{useState,useEffect,useCallback,useMemo}from'react';import{SurroundPortals}from"../../../components";import{DIRECT_SHIP,ROPIS,BOPIS,STAGE_SELECT_STORE,PRODUCT_FULFILLMENT_SELECTOR}from"../../constants";import{FulfillmentSheet}from"../FulfillmentSheet";import{FulfillmentSelectorContext}from"./FulfillmentSelector.context";import{FulfillmentSelectorHeader}from"./FulfillmentSelectorHeader";import{FulfillmentSelectorItem}from"./FulfillmentSelectorItem";import{FulfillmentSelectorDirectShip}from"./FulfillmentSelectorDirectShip";import{FulfillmentSelectorBOPIS}from"./FulfillmentSelectorBOPIS";import{FulfillmentSelectorROPIS}from"./FulfillmentSelectorROPIS";import{FulfillmentSelectorAddToCart}from"./FulfillmentSelectorAddToCart";import{FulfillmentSelectorLocation}from"./FulfillmentSelectorLocation";import{container}from"./FulfillmentSelector.style";import connect from"./FulfillmentSelector.connector"
|
|
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{hot}from'react-hot-loader/root';import React,{useState,useEffect,useCallback,useMemo}from'react';import PropTypes from'prop-types';import{SurroundPortals}from"../../../components";import{DIRECT_SHIP,ROPIS,BOPIS,STAGE_SELECT_STORE,PRODUCT_FULFILLMENT_SELECTOR}from"../../constants";import{FulfillmentSheet}from"../FulfillmentSheet";import{FulfillmentSelectorContext}from"./FulfillmentSelector.context";import{FulfillmentSelectorHeader}from"./FulfillmentSelectorHeader";import{FulfillmentSelectorItem}from"./FulfillmentSelectorItem";import{FulfillmentSelectorDirectShip}from"./FulfillmentSelectorDirectShip";import{FulfillmentSelectorBOPIS}from"./FulfillmentSelectorBOPIS";import{FulfillmentSelectorROPIS}from"./FulfillmentSelectorROPIS";import{FulfillmentSelectorAddToCart}from"./FulfillmentSelectorAddToCart";import{FulfillmentSelectorLocation}from"./FulfillmentSelectorLocation";import{container}from"./FulfillmentSelector.style";import connect from"./FulfillmentSelector.connector";/* eslint-disable max-len */ /** @typedef {import('./FulfillmentSelector.types').FulfillmentSelectorContextProps} FulfillmentSelectorContextProps */ /** @typedef {import('./FulfillmentSelector.types').OwnProps} OwnProps */ /** @typedef {import('./FulfillmentSelector.types').StateProps} StateProps */ /** @typedef {import('./FulfillmentSelector.types').DispatchProps} DispatchProps */ /** @typedef {import('../../locations.types').UserLocationFulfillmentMethod} UserLocationFulfillmentMethod */ /* eslint-enable max-len */ /**
|
|
2
|
+
* @typedef {OwnProps & StateProps & DispatchProps} Props
|
|
3
|
+
*/ /**
|
|
2
4
|
* Renders the fulfillment selector radio button group.
|
|
3
|
-
* @param {
|
|
4
|
-
* @returns {JSX}
|
|
5
|
-
*/function FulfillmentSelector(props){var productId=props.productId,merchantSettings=props.merchantSettings,shopFulfillmentMethods=props.shopFulfillmentMethods,productFulfillmentMethods=props.productFulfillmentMethods,locationFulfillmentMethods=props.locationFulfillmentMethods,useLocationFulfillmentMethods=props.useLocationFulfillmentMethods,preferredLocation=props.preferredLocation,inventory=props.inventory,conditioner=props.conditioner,isDirectShipEnabled=props.isDirectShipEnabled,isROPISEnabled=props.isROPISEnabled,isBOPISEnabled=props.isBOPISEnabled,storeFulfillmentMethod=props.storeFulfillmentMethod,userFulfillmentMethod=props.userFulfillmentMethod,fulfillmentPaths=props.fulfillmentPaths,isOrderable=props.isOrderable,isReady=props.isReady;var _useState=useState(userFulfillmentMethod),_useState2=_slicedToArray(_useState,2),selection=_useState2[0],setSelection=_useState2[1];var _useState3=useState(preferredLocation),_useState4=_slicedToArray(_useState3,2),selectedLocation=_useState4[0],setSelectedLocation=_useState4[1];var _useState5=useState(false),_useState6=_slicedToArray(_useState5,2),isOpen=_useState6[0],setIsOpen=_useState6[1];var usedLocation=selectedLocation||preferredLocation;// Initialize fo selection once it is available.
|
|
5
|
+
* @param {Props} props The component props.
|
|
6
|
+
* @returns {JSX.Element|null}
|
|
7
|
+
*/var FulfillmentSelector=function FulfillmentSelector(props){var productId=props.productId,merchantSettings=props.merchantSettings,shopFulfillmentMethods=props.shopFulfillmentMethods,productFulfillmentMethods=props.productFulfillmentMethods,locationFulfillmentMethods=props.locationFulfillmentMethods,useLocationFulfillmentMethods=props.useLocationFulfillmentMethods,preferredLocation=props.preferredLocation,inventory=props.inventory,conditioner=props.conditioner,isDirectShipEnabled=props.isDirectShipEnabled,isROPISEnabled=props.isROPISEnabled,isBOPISEnabled=props.isBOPISEnabled,storeFulfillmentMethod=props.storeFulfillmentMethod,userFulfillmentMethod=props.userFulfillmentMethod,fulfillmentPaths=props.fulfillmentPaths,isOrderable=props.isOrderable,isReady=props.isReady;var _useState=useState(userFulfillmentMethod),_useState2=_slicedToArray(_useState,2),selection=_useState2[0],setSelection=_useState2[1];var _useState3=useState(preferredLocation),_useState4=_slicedToArray(_useState3,2),selectedLocation=_useState4[0],setSelectedLocation=_useState4[1];var _useState5=useState(false),_useState6=_slicedToArray(_useState5,2),isOpen=_useState6[0],setIsOpen=_useState6[1];var usedLocation=selectedLocation||preferredLocation;// Initialize fo selection once it is available.
|
|
6
8
|
useEffect(function(){if(!selection&&userFulfillmentMethod){setSelection(userFulfillmentMethod);}},[selection,userFulfillmentMethod]);// Initialize location selection once it is available.
|
|
7
|
-
useEffect(function(){if(!selectedLocation&&preferredLocation){setSelectedLocation(preferredLocation);}},[preferredLocation,selectedLocation])
|
|
9
|
+
useEffect(function(){if(!selectedLocation&&preferredLocation){setSelectedLocation(preferredLocation);}},[preferredLocation,selectedLocation]);/** @type {UserLocationFulfillmentMethod} */var fulfillmentMethodFallback=useMemo(function(){if(!shopFulfillmentMethods){return null;}var states=[isDirectShipEnabled,isBOPISEnabled,isROPISEnabled];return[DIRECT_SHIP,BOPIS,ROPIS].find(function(method,index){return states[index]&&shopFulfillmentMethods.includes(method);})||null;},[isBOPISEnabled,isDirectShipEnabled,isROPISEnabled,shopFulfillmentMethods]);/**
|
|
8
10
|
* Determine and set a default fulfillment method when none was set before.
|
|
9
|
-
*/useEffect(function(){if(!shopFulfillmentMethods){return;}
|
|
10
|
-
* The user has already set a fulfillment method which is supported by the shop, so we don't
|
|
11
|
-
* need to apply the fallback. We don't check against the product fulfillment methods to
|
|
12
|
-
* avoid too much auto magic when navigating through catalogs with different set up products.
|
|
13
|
-
*/if(userFulfillmentMethod&&shopFulfillmentMethods.includes(userFulfillmentMethod)){return;}if(fulfillmentMethodFallback!==userFulfillmentMethod){setSelection(fulfillmentMethodFallback);storeFulfillmentMethod(fulfillmentMethodFallback);}},[fulfillmentMethodFallback,isBOPISEnabled,isDirectShipEnabled,isROPISEnabled,shopFulfillmentMethods,storeFulfillmentMethod,userFulfillmentMethod]);useEffect(function(){if((preferredLocation===null||preferredLocation===void 0?void 0:preferredLocation.code)!==(selectedLocation===null||selectedLocation===void 0?void 0:selectedLocation.code)){setSelectedLocation(preferredLocation);}},[preferredLocation,selectedLocation,shopFulfillmentMethods]);/**
|
|
14
|
-
* Updates the selected location when the sheet closes.
|
|
15
|
-
*/var handleClose=useCallback(function(newLocationData){setIsOpen(false);if(!newLocationData&&(!usedLocation||!usedLocation.code)){// Reset the UI back to directShip if there was no location selected already
|
|
16
|
-
setSelection(fulfillmentMethodFallback);return;}if(newLocationData){// Update the selected location only when the selection was done for the same product.
|
|
17
|
-
setSelectedLocation(newLocationData.location);}},[fulfillmentMethodFallback,usedLocation]);/**
|
|
18
|
-
* Whenever the pick-up selection is made, open the
|
|
19
|
-
* store selector sheet and use the new location.
|
|
20
|
-
*/var handleChange=useCallback(function(method){var changeOnly=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;conditioner.without('fulfillment-inventory').check().then(function(passed){if(!passed){return;}setSelection(method);storeFulfillmentMethod(method);var isValidRopeSelection=[ROPIS,BOPIS].includes(method)&&!!preferredLocation&&!!preferredLocation.code;if(!changeOnly&&(isOpen||isValidRopeSelection)){return;}if(method===DIRECT_SHIP){setSelectedLocation(null);return;}setIsOpen(true);FulfillmentSheet.open({stage:STAGE_SELECT_STORE,callback:handleClose,changeOnly:changeOnly});});},[conditioner,handleClose,isOpen,preferredLocation,storeFulfillmentMethod]);var shopHasRopeMethods=useMemo(function(){if(!Array.isArray(shopFulfillmentMethods)){return false;}return shopFulfillmentMethods.filter(function(method){return method!==DIRECT_SHIP;}).length>0;},[shopFulfillmentMethods]);if(!shopHasRopeMethods){return null;}var context={selection:selection,selectedLocation:selectedLocation,inventory:inventory,preferredLocation:preferredLocation,isDirectShipEnabled:isDirectShipEnabled,isBOPISEnabled:isBOPISEnabled,isROPISEnabled:isROPISEnabled,isReady:isReady,productId:productId,handleChange:handleChange,conditioner:conditioner,merchantSettings:merchantSettings,fulfillmentPaths:fulfillmentPaths,userFulfillmentMethod:userFulfillmentMethod,isOrderable:isOrderable,shopFulfillmentMethods:shopFulfillmentMethods,productFulfillmentMethods:productFulfillmentMethods,locationFulfillmentMethods:locationFulfillmentMethods,useLocationFulfillmentMethods:useLocationFulfillmentMethods};return React.createElement(FulfillmentSelectorContext.Provider,{value:context},React.createElement(SurroundPortals,{portalName:PRODUCT_FULFILLMENT_SELECTOR},React.createElement("div",{className:container,role:"radiogroup",tabIndex:"0"},React.createElement(FulfillmentSelectorHeader,null),shopFulfillmentMethods.includes(DIRECT_SHIP)&&React.createElement(FulfillmentSelectorItem,{name:DIRECT_SHIP,onChange:handleChange,disabled:!isReady||!isDirectShipEnabled},React.createElement(FulfillmentSelectorDirectShip,null)),shopFulfillmentMethods.includes(BOPIS)&&React.createElement(FulfillmentSelectorItem,{name:BOPIS,onChange:handleChange,disabled:!isReady||!isBOPISEnabled},React.createElement(FulfillmentSelectorBOPIS,null)),shopFulfillmentMethods.includes(ROPIS)&&React.createElement(FulfillmentSelectorItem,{name:ROPIS,onChange:handleChange,disabled:!isReady||!isROPISEnabled},React.createElement(FulfillmentSelectorROPIS,null)))),React.createElement(FulfillmentSelectorLocation,null),React.createElement(FulfillmentSelectorAddToCart,null));}export default hot(connect(React.memo(FulfillmentSelector)));
|
|
11
|
+
*/useEffect(function(){if(!shopFulfillmentMethods){return;}if(userFulfillmentMethod&&shopFulfillmentMethods.includes(userFulfillmentMethod)){return;}if(fulfillmentMethodFallback!==userFulfillmentMethod){setSelection(fulfillmentMethodFallback);storeFulfillmentMethod(fulfillmentMethodFallback);}},[fulfillmentMethodFallback,isBOPISEnabled,isDirectShipEnabled,isROPISEnabled,shopFulfillmentMethods,storeFulfillmentMethod,userFulfillmentMethod]);useEffect(function(){if((preferredLocation===null||preferredLocation===void 0?void 0:preferredLocation.code)!==(selectedLocation===null||selectedLocation===void 0?void 0:selectedLocation.code)){setSelectedLocation(preferredLocation);}},[preferredLocation,selectedLocation,shopFulfillmentMethods]);var handleClose=useCallback(function(newLocationData){setIsOpen(false);if(!newLocationData&&(!usedLocation||!usedLocation.code)){setSelection(fulfillmentMethodFallback);return;}if(newLocationData){setSelectedLocation(newLocationData.location);}},[fulfillmentMethodFallback,usedLocation]);var handleChange=useCallback(function(method){var changeOnly=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;conditioner.without('fulfillment-inventory').check().then(function(passed){if(!passed){return;}setSelection(method);storeFulfillmentMethod(method);var isValidRopeSelection=[ROPIS,BOPIS].includes(method)&&!!preferredLocation&&!!preferredLocation.code;if(!changeOnly&&(isOpen||isValidRopeSelection)){return;}if(method===DIRECT_SHIP){setSelectedLocation(null);return;}setIsOpen(true);FulfillmentSheet.open({stage:STAGE_SELECT_STORE,callback:handleClose,changeOnly:changeOnly});});},[conditioner,handleClose,isOpen,preferredLocation,storeFulfillmentMethod]);var shopHasRopeMethods=useMemo(function(){if(!Array.isArray(shopFulfillmentMethods)){return false;}return shopFulfillmentMethods.filter(function(method){return method!==DIRECT_SHIP;}).length>0;},[shopFulfillmentMethods]);if(!shopHasRopeMethods){return null;}var context=/** @type {FulfillmentSelectorContextProps} */{selection:selection,selectedLocation:selectedLocation,inventory:inventory,preferredLocation:preferredLocation,isDirectShipEnabled:isDirectShipEnabled,isBOPISEnabled:isBOPISEnabled,isROPISEnabled:isROPISEnabled,isReady:isReady,productId:productId,handleChange:handleChange,conditioner:conditioner,merchantSettings:merchantSettings,fulfillmentPaths:fulfillmentPaths,userFulfillmentMethod:userFulfillmentMethod,isOrderable:isOrderable,shopFulfillmentMethods:shopFulfillmentMethods,productFulfillmentMethods:productFulfillmentMethods,locationFulfillmentMethods:locationFulfillmentMethods,useLocationFulfillmentMethods:useLocationFulfillmentMethods};return React.createElement(FulfillmentSelectorContext.Provider,{value:context},React.createElement(SurroundPortals,{portalName:PRODUCT_FULFILLMENT_SELECTOR},React.createElement("div",{className:container,role:"radiogroup",tabIndex:"0"},React.createElement(FulfillmentSelectorHeader,null),shopFulfillmentMethods.includes(DIRECT_SHIP)&&React.createElement(FulfillmentSelectorItem,{name:DIRECT_SHIP,onChange:handleChange,disabled:!isReady||!isDirectShipEnabled},React.createElement(FulfillmentSelectorDirectShip,null)),shopFulfillmentMethods.includes(BOPIS)&&React.createElement(FulfillmentSelectorItem,{name:BOPIS,onChange:handleChange,disabled:!isReady||!isBOPISEnabled},React.createElement(FulfillmentSelectorBOPIS,null)),shopFulfillmentMethods.includes(ROPIS)&&React.createElement(FulfillmentSelectorItem,{name:ROPIS,onChange:handleChange,disabled:!isReady||!isROPISEnabled},React.createElement(FulfillmentSelectorROPIS,null)))),React.createElement(FulfillmentSelectorLocation,null),React.createElement(FulfillmentSelectorAddToCart,null));};FulfillmentSelector.defaultProps={merchantSettings:null,shopFulfillmentMethods:null,productFulfillmentMethods:null,locationFulfillmentMethods:null,useLocationFulfillmentMethods:false,preferredLocation:null,inventory:null,userFulfillmentMethod:null};export default hot(connect(React.memo(FulfillmentSelector)));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{css}from'glamor';import{themeConfig}from'@shopgate/pwa-common/helpers/config';var variables=themeConfig.variables;export var container=css({padding:"".concat(variables.gap.small,"px ").concat(variables.gap.big,"px")});
|
|
1
|
+
import{css}from'glamor';import{themeConfig}from'@shopgate/pwa-common/helpers/config';var variables=themeConfig.variables;export var container=css({padding:"".concat(variables.gap.small,"px ").concat(variables.gap.big,"px")}).toString();
|
|
@@ -1 +1,57 @@
|
|
|
1
|
-
import{
|
|
1
|
+
/* eslint-disable max-len */ /** @typedef {import('../../locations.types').Location} Location */ /** @typedef {import('../../locations.types').UserLocationFulfillmentMethod} UserLocationFulfillmentMethod */ /**
|
|
2
|
+
* @typedef {(
|
|
3
|
+
* typeof import('../../constants').DIRECT_SHIP |
|
|
4
|
+
* typeof import('../../constants').ROPIS |
|
|
5
|
+
* typeof import('../../constants').BOPIS |
|
|
6
|
+
* null
|
|
7
|
+
* )} Selection
|
|
8
|
+
*/ /**
|
|
9
|
+
* @typedef {Object} UserSearch
|
|
10
|
+
* @property {null} geolocation
|
|
11
|
+
* @property {null} postalCode
|
|
12
|
+
*/ /**
|
|
13
|
+
* @typedef {Object} FulfillmentSelectorContextProps
|
|
14
|
+
* @property {Selection} selection
|
|
15
|
+
* @property {Location|null} selectedLocation
|
|
16
|
+
* @property {Location|null} [location]
|
|
17
|
+
* @property {boolean} isDirectShipEnabled
|
|
18
|
+
* @property {boolean} isROPISEnabled
|
|
19
|
+
* @property {boolean} isBOPISEnabled
|
|
20
|
+
* @property {boolean} isReady
|
|
21
|
+
* @property {string} productId
|
|
22
|
+
* @property {function(Selection, boolean): void} handleChange
|
|
23
|
+
* @property {any} conditioner
|
|
24
|
+
* @property {string[]} fulfillmentPaths
|
|
25
|
+
* @property {Object} merchantSettings
|
|
26
|
+
* @property {string|null} userFulfillmentMethod
|
|
27
|
+
* @property {boolean} isOrderable
|
|
28
|
+
* @property {string[]|null} [shopFulfillmentMethods]
|
|
29
|
+
* @property {string[]|null} productFulfillmentMethods
|
|
30
|
+
* @property {string[]|null} locationFulfillmentMethods
|
|
31
|
+
* @property {boolean} useLocationFulfillmentMethods
|
|
32
|
+
* @property {Object} [inventory]
|
|
33
|
+
* @property {Object} [preferredLocation]
|
|
34
|
+
*/ /**
|
|
35
|
+
* @typedef {Object} OwnProps
|
|
36
|
+
* @property {any} conditioner
|
|
37
|
+
* @property {string} productId
|
|
38
|
+
*/ /**
|
|
39
|
+
* @typedef {Object} StateProps
|
|
40
|
+
* @property {Object} [merchantSettings]
|
|
41
|
+
* @property {string[]|null} [shopFulfillmentMethods]
|
|
42
|
+
* @property {string[]|null} productFulfillmentMethods
|
|
43
|
+
* @property {string[]|null} locationFulfillmentMethods
|
|
44
|
+
* @property {boolean} useLocationFulfillmentMethods
|
|
45
|
+
* @property {boolean} isDirectShipEnabled
|
|
46
|
+
* @property {boolean} isROPISEnabled
|
|
47
|
+
* @property {boolean} isBOPISEnabled
|
|
48
|
+
* @property {Location|null} preferredLocation
|
|
49
|
+
* @property {Object} inventory
|
|
50
|
+
* @property {string|null} userFulfillmentMethod
|
|
51
|
+
* @property {string[]} fulfillmentPaths
|
|
52
|
+
* @property {boolean} isOrderable
|
|
53
|
+
* @property {boolean} isReady
|
|
54
|
+
*/ /**
|
|
55
|
+
* @typedef {Object} DispatchProps
|
|
56
|
+
* @property {function(UserLocationFulfillmentMethod): void} storeFulfillmentMethod
|
|
57
|
+
*/ /* eslint-enable max-len */
|