@shopgate/engage 7.8.0-beta.1 → 7.8.0-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/account/components/Profile/Profile.config.js +8 -3
- package/account/components/Profile/Profile.js +1 -1
- package/account/components/Profile/Profile.provider.js +9 -8
- package/account/components/Profile/ProfileForm.js +2 -2
- package/account/helper/form.js +28 -8
- package/checkout/components/Checkout/CheckoutSection.js +1 -1
- package/checkout/components/ShippingMethods/ShippingMethods.js +2 -2
- package/checkout/paymentMethods/index.js +2 -2
- package/checkout/paymentMethods/paypal/PaypalPayButton.js +1 -1
- package/checkout/paymentMethods/stripe/StripeCreditCard.js +1 -1
- package/checkout/providers/CheckoutProvider.js +2 -2
- package/components/Form/Builder/Builder.js +4 -9
- package/components/Form/Builder/ElementCheckbox.js +2 -2
- package/components/Form/Builder/ElementMultiSelect.js +2 -2
- package/components/Form/Builder/ElementPhoneNumber.js +3 -3
- package/components/Form/Builder/ElementRadio.js +2 -2
- package/components/Form/Builder/ElementSelect.js +2 -2
- package/components/Form/Builder/ElementText.js +2 -2
- package/components/Form/Builder/FormHelper.js +5 -0
- package/components/Form/Builder/helpers/common.js +6 -0
- package/components/Form/Builder/stylePresets.js +1 -1
- package/core/constants/index.js +1 -1
- package/core/constants/shopSettings.js +1 -1
- package/core/hooks/useFormState.js +5 -1
- package/core/hooks/useScrollTo.js +2 -1
- package/core/index.js +1 -1
- package/core/selectors/index.js +1 -1
- package/core/selectors/shopSettings.js +5 -2
- package/package.json +7 -7
- package/registration/components/Registration/Registration.js +2 -2
- package/registration/components/Registration/RegistrationContent.js +4 -0
- package/registration/components/Registration/RegistrationContent.style.js +2 -0
- package/registration/components/Registration/RegistrationFormActions.js +1 -1
- package/registration/components/Registration/RegistrationFormBase.config.js +2 -2
- package/registration/components/Registration/RegistrationFormBase.js +2 -2
- package/registration/components/Registration/RegistrationFormBilling.js +2 -2
- package/registration/components/Registration/RegistrationFormExtra.config.js +2 -2
- package/registration/components/Registration/RegistrationFormExtra.js +2 -2
- package/registration/components/Registration/RegistrationFormShipping.js +1 -1
- package/registration/components/Registration/RegistrationFormToggle.js +1 -1
- package/registration/providers/GuestRegistrationProvider.actions.js +2 -2
- package/registration/providers/GuestRegistrationProvider.js +9 -4
- package/registration/providers/RegistrationProvider.actions.js +3 -2
- package/registration/providers/RegistrationProvider.connector.js +2 -2
- package/registration/providers/RegistrationProvider.constraints.js +22 -2
- package/registration/providers/RegistrationProvider.js +5 -5
- package/registration/components/Registration/RegisterFormBilling.config.js +0 -6
- package/registration/components/Registration/Registration.style.js +0 -2
- package/registration/helpers/index.js +0 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
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{themeConfig}from'@shopgate/engage';import{responsiveMediaQuery}from'@shopgate/engage/styles';var colors=themeConfig.colors;export var TWO_COLUMN_LAYOUT=_defineProperty({},responsiveMediaQuery('>=md',{webOnly:false}),{display:'flex',flexDirection:'row',flexWrap:'wrap',margin:-8,marginTop:16,marginBottom:8,'>div':{flex:'1 1 50%',padding:'0 8px',maxWidth:'50%'},'>.phonePicker':{marginLeft:8,marginRight:8,flexBasis:'calc(50% - 16px)'}});export var OUTLINED_FORM_FIELDS={' .formHelper':{minHeight:32,' .errorText':{position:'relative',textOverflow:'unset',whiteSpace:'unset',lineHeight:'15px',bottom:'unset',padding:'8px 8px 8px 16px'}},' .formBuilderField':{' .textField, .formElement:not(.radioGroup):not(.checkbox), .phonePicker':{marginBottom:'unset',paddingBottom:'unset'}},' .radioGroup + .formHelper, .checkbox + .formHelper':{minHeight:16},' .checkbox':{paddingBottom:0},' .textField, .formElement:not(.radioGroup):not(.checkbox), .phonePicker':{paddingBottom:8,background:"var(--color-background-accent, ".concat(colors.shade8,")"),padding:0,marginBottom:32,borderTopLeftRadius:4,borderTopRightRadius:4,borderBottom:"1px solid ".concat(colors.shade12)},' .phonePickerError':{borderBottom:"2px solid var(--color-state-alert, ".concat(colors.error,")")},' .phonePickerFocused:not(.phonePickerError)':{borderBottom:'2px solid var(--color-primary)'},' .formElement:not(.radioGroup) label':{paddingLeft:24,color:'var(--color-text-low-emphasis)',transform:'translate3d(0, -18px, 0) scale3d(0.75, 0.75, 0.75)'},' .textField label':{paddingLeft:17,color:'var(--color-text-low-emphasis)','.floating':{transform:'translate3d(3px, -18px, 0) scale3d(0.75, 0.75, 0.75)'}},' .formElement:not(.radioGroup) select, .formElement .info-field':{paddingLeft:16,color:'var(--color-text-high-emphasis)'},' .formElement:not(.radioGroup):not(.checkbox) svg':{marginTop:8,right:8},' .formElement:not(.radioGroup) .placeholder':{paddingLeft:20,color:'var(--color-text-low-emphasis)'},' .formElement.disabled, .textField.disabled':{' input, select, svg':{opacity:0.28},' .label':{opacity:0.6}},' .textField input':{paddingLeft:16,color:'var(--color-text-high-emphasis)'},' .underline':{marginBottom:0,borderBottom:'none'},' .errorText':{bottom:-20,paddingLeft:16},' .phonePicker':{paddingTop:24,paddingBottom:2},' .phonePicker .PhoneInputInput':{borderBottom:'none',color:'var(--color-text-high-emphasis)','&:focus':{borderBottom:'none'},'::placeholder':{color:'var(--color-text-low-emphasis)'}},' .phonePicker .errorText':{marginLeft:-8},' .PhoneInputCountryIcon':{marginBottom:8,marginLeft:16},' .PhoneInputCountrySelectArrow':{marginRight:6,marginLeft:10,marginBottom:8},' .placeholder':{color:colors.shade12}};
|
package/core/constants/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{RECEIVE_SHOP_SETTINGS,ERROR_SHOP_SETTINGS,CACHE_LEASE_SHOP_SETTINGS,SHOP_SETTING_GOOGLE_SITE_VERIFICATION_CODE,SHOP_SETTING_CART_SUPPLEMENTAL_CONTENT,SHOP_SETTING_ORDER_SUPPLEMENTAL_CONTENT,SHOP_SETTING_SHOW_SHOP_LOGO_IN_APP,SHOP_SETTING_SHOW_SHOP_LOGO_IN_WEB,SHOP_SETTING_PRODUCTS_SORT_ORDER,SHOP_SETTING_COOKIE_CONSENT_MODE,SHOP_SETTING_DISPLAY_PRICE_PER_MEASURE_UNIT,SHOP_SETTING_IMAGES,SHOP_SETTING_IMAGES_PRODUCT_PLACEHOLDER,SHOP_SETTING_IMAGES_CATEGORY_PLACEHOLDER,SHOP_SETTING_IMAGES_FAVICON,SHOP_SETTING_NUMBER_OF_ADDRESS_LINES}from"./shopSettings";export{RECEIVE_MERCHANT_SETTINGS,MERCHANT_SETTINGS_LOCATION_BASED_SHOPPING_ENABLED,MERCHANT_SETTINGS_SUBSTITUTION_PREFERENCES_ENABLED,MERCHANT_SETTINGS_CUSTOMER_ATTRIBUTES,MERCHANT_SETTINGS_FULFILLMENT_SCHEDULED_ENABLED,MERCHANT_SETTINGS_RESTRICT_MULTI_LOCATION_ORDERS,MERCHANT_SETTINGS_DEFAULT_CURRENCY,MERCHANT_SETTINGS_ENABLE_WEB_INDEXING,MERCHANT_SETTINGS_PRODUCT_SHOW_ALTERNATIVE_LOCATION,MERCHANT_SETTINGS_PRODUCTLIST_SHOW_INVENTORY}from"./merchantSettings";export{SHOPGATE_CORE_GET_SHOP_SETTINGS,EUNAUTHORIZED,EAUTHENTICATION}from"./pipelines";
|
|
1
|
+
export{RECEIVE_SHOP_SETTINGS,ERROR_SHOP_SETTINGS,CACHE_LEASE_SHOP_SETTINGS,SHOP_SETTING_GOOGLE_SITE_VERIFICATION_CODE,SHOP_SETTING_CART_SUPPLEMENTAL_CONTENT,SHOP_SETTING_ORDER_SUPPLEMENTAL_CONTENT,SHOP_SETTING_SHOW_SHOP_LOGO_IN_APP,SHOP_SETTING_SHOW_SHOP_LOGO_IN_WEB,SHOP_SETTING_PRODUCTS_SORT_ORDER,SHOP_SETTING_COOKIE_CONSENT_MODE,SHOP_SETTING_DISPLAY_PRICE_PER_MEASURE_UNIT,SHOP_SETTING_IMAGES,SHOP_SETTING_IMAGES_PRODUCT_PLACEHOLDER,SHOP_SETTING_IMAGES_CATEGORY_PLACEHOLDER,SHOP_SETTING_IMAGES_FAVICON,SHOP_SETTING_NUMBER_OF_ADDRESS_LINES,SHOP_SETTING_REGISTRATION_MODE_SIMPLE,SHOP_SETTING_REGISTRATION_MODE_EXTENDED}from"./shopSettings";export{RECEIVE_MERCHANT_SETTINGS,MERCHANT_SETTINGS_LOCATION_BASED_SHOPPING_ENABLED,MERCHANT_SETTINGS_SUBSTITUTION_PREFERENCES_ENABLED,MERCHANT_SETTINGS_CUSTOMER_ATTRIBUTES,MERCHANT_SETTINGS_FULFILLMENT_SCHEDULED_ENABLED,MERCHANT_SETTINGS_RESTRICT_MULTI_LOCATION_ORDERS,MERCHANT_SETTINGS_DEFAULT_CURRENCY,MERCHANT_SETTINGS_ENABLE_WEB_INDEXING,MERCHANT_SETTINGS_PRODUCT_SHOW_ALTERNATIVE_LOCATION,MERCHANT_SETTINGS_PRODUCTLIST_SHOW_INVENTORY}from"./merchantSettings";export{SHOPGATE_CORE_GET_SHOP_SETTINGS,EUNAUTHORIZED,EAUTHENTICATION}from"./pipelines";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export var RECEIVE_SHOP_SETTINGS='RECEIVE_SHOP_SETTINGS';export var ERROR_SHOP_SETTINGS='ERROR_SHOP_SETTINGS';export var CACHE_LEASE_SHOP_SETTINGS=10*60*1000;// 10 minutes in milliseconds
|
|
2
|
-
export var SHOP_SETTING_GOOGLE_SITE_VERIFICATION_CODE='googleSiteVerificationCode';export var SHOP_SETTING_CART_SUPPLEMENTAL_CONTENT='cartSupplementalContent';export var SHOP_SETTING_ORDER_SUPPLEMENTAL_CONTENT='orderSupplementalContent';export var SHOP_SETTING_SHOW_SHOP_LOGO_IN_APP='showShopLogoInApp';export var SHOP_SETTING_SHOW_SHOP_LOGO_IN_WEB='showShopLogoInWeb';export var SHOP_SETTING_PRODUCTS_SORT_ORDER='productsSortOrder';export var SHOP_SETTING_WISHLIST_MODE='wishlistMode';export var SHOP_SETTING_COOKIE_CONSENT_MODE='cookieConsentMode';export var SHOP_SETTING_DISPLAY_PRICE_PER_MEASURE_UNIT='displayPricePerMeasureUnit';export var SHOP_SETTING_IMAGES='images';export var SHOP_SETTING_IMAGES_PRODUCT_PLACEHOLDER='productPlaceholder';export var SHOP_SETTING_IMAGES_CATEGORY_PLACEHOLDER='categoryPlaceholder';export var SHOP_SETTING_IMAGES_FAVICON='favicon';export var SHOP_SETTING_NUMBER_OF_ADDRESS_LINES='numberOfAddressLines';export var SHOP_SETTINGS_SHOW_CATEGORY_IMAGES='showCategoryImages';export var WISHLIST_MODE_PERSIST_ON_ADD='persistOnAdd';
|
|
2
|
+
export var SHOP_SETTING_GOOGLE_SITE_VERIFICATION_CODE='googleSiteVerificationCode';export var SHOP_SETTING_CART_SUPPLEMENTAL_CONTENT='cartSupplementalContent';export var SHOP_SETTING_ORDER_SUPPLEMENTAL_CONTENT='orderSupplementalContent';export var SHOP_SETTING_SHOW_SHOP_LOGO_IN_APP='showShopLogoInApp';export var SHOP_SETTING_SHOW_SHOP_LOGO_IN_WEB='showShopLogoInWeb';export var SHOP_SETTING_PRODUCTS_SORT_ORDER='productsSortOrder';export var SHOP_SETTING_WISHLIST_MODE='wishlistMode';export var SHOP_SETTING_COOKIE_CONSENT_MODE='cookieConsentMode';export var SHOP_SETTING_DISPLAY_PRICE_PER_MEASURE_UNIT='displayPricePerMeasureUnit';export var SHOP_SETTING_IMAGES='images';export var SHOP_SETTING_IMAGES_PRODUCT_PLACEHOLDER='productPlaceholder';export var SHOP_SETTING_IMAGES_CATEGORY_PLACEHOLDER='categoryPlaceholder';export var SHOP_SETTING_IMAGES_FAVICON='favicon';export var SHOP_SETTING_NUMBER_OF_ADDRESS_LINES='numberOfAddressLines';export var SHOP_SETTINGS_SHOW_CATEGORY_IMAGES='showCategoryImages';export var SHOP_SETTING_REGISTRATION_MODE='registrationMode';export var SHOP_SETTING_REGISTRATION_MODE_SIMPLE='simple';export var SHOP_SETTING_REGISTRATION_MODE_EXTENDED='extended';export var WISHLIST_MODE_PERSIST_ON_ADD='persistOnAdd';
|
|
@@ -7,8 +7,12 @@ import _regeneratorRuntime from"@babel/runtime/regenerator";import _debounce fro
|
|
|
7
7
|
* @param {Function} complete The completion callback.
|
|
8
8
|
* @param {Object} validationConstraints validationConstraints
|
|
9
9
|
* @param {Object} [formContainerRef=null] A ref to a container with forms
|
|
10
|
+
* @param {number} [validationErrorScrollOffset=10] When a form container ref is passed with the
|
|
11
|
+
* parameters, whenever validation errors occur, the page will scroll to the first error. Depending
|
|
12
|
+
* on the page, the scroll logic might not be accurate. So this offset parameter can be used
|
|
13
|
+
* to influence scroll behavior.
|
|
10
14
|
* @returns {{ handleChange, handleSubmit, values, valid, validationErrors: ?Object, isSubmitting }}
|
|
11
|
-
*/export function useFormState(initialState,complete){var validationConstraints=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};var formContainerRef=arguments.length>3&&arguments[3]!==undefined?arguments[3]:null;var _useScrollTo=useScrollTo(formContainerRef),scrollTo=_useScrollTo.scrollTo;// Submit lock prevents the form from being submitted multiple times
|
|
15
|
+
*/export function useFormState(initialState,complete){var validationConstraints=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};var formContainerRef=arguments.length>3&&arguments[3]!==undefined?arguments[3]:null;var validationErrorScrollOffset=arguments.length>4&&arguments[4]!==undefined?arguments[4]:10;var _useScrollTo=useScrollTo(formContainerRef,validationErrorScrollOffset),scrollTo=_useScrollTo.scrollTo;// Submit lock prevents the form from being submitted multiple times
|
|
12
16
|
var submitLock=useRef(false);var _useState=useState(initialState),_useState2=_slicedToArray(_useState,2),values=_useState2[0],setValues=_useState2[1];var _useState3=useState(false),_useState4=_slicedToArray(_useState3,2),isSubmitting=_useState4[0],setSubmitting=_useState4[1];var _useState5=useState(false),_useState6=_slicedToArray(_useState5,2),changed=_useState6[0],setChanged=_useState6[1];var _useState7=useState(false),_useState8=_slicedToArray(_useState7,2),ignoreErrors=_useState8[0],setIgnoreErrors=_useState8[1];var _useValidation=useValidation(validationConstraints),valid=_useValidation.valid,validationErrors=_useValidation.validationErrors,validate=_useValidation.validate,reset=_useValidation.reset;var scrollToError=useCallback(function(){scrollTo('.validationError');},[scrollTo]);// -- CHANGED ---------------
|
|
13
17
|
useEffect(function(){var isEqual=JSON.stringify(values)===JSON.stringify(initialState);if(!isEqual&&!changed){setChanged(true);}else if(isEqual&&changed){setChanged(false);}},[changed,initialState,values]);// -- IS_SUBMITTING ---------
|
|
14
18
|
/* eslint-disable react-hooks/exhaustive-deps */useEffect(function(){if(!isSubmitting){return;}var mounted=true;if((valid===true||ignoreErrors)&&!submitLock.current){submitLock.current=true;_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(){return _regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:_context.next=2;return complete(values);case 2:if(mounted){setSubmitting(false);setChanged(false);submitLock.current=false;}case 3:case"end":return _context.stop();}}},_callee);}))();}// eslint-disable-next-line consistent-return
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import{useCallback}from'react';import{getCSSCustomProp}from'@shopgate/engage/styles';import{hasWebBridge}from"../helpers/bridge";/**
|
|
2
2
|
* @param {Object} ref A ref to the scroll container
|
|
3
|
+
* @param {number} [offset=10] Optional offset for the scroll operation
|
|
3
4
|
* @returns {Object}
|
|
4
|
-
*/export var useScrollTo=function useScrollTo(ref){var scrollTo=useCallback(function(selector){if(!(ref===null||ref===void 0?void 0:ref.current)){return;}var firstElement=ref.current.querySelector(selector);if(firstElement){if(hasWebBridge()){var offset
|
|
5
|
+
*/export var useScrollTo=function useScrollTo(ref){var offset=arguments.length>1&&arguments[1]!==undefined?arguments[1]:10;var scrollTo=useCallback(function(selector){if(!(ref===null||ref===void 0?void 0:ref.current)){return;}var firstElement=ref.current.querySelector(selector);if(firstElement){if(hasWebBridge()){var scrollOffset=offset;var appBarHeight=getCSSCustomProp('--app-bar-height')||0;var _firstElement$getBoun=firstElement.getBoundingClientRect(),top=_firstElement$getBoun.top;var scrollTop=top+window.pageYOffset-parseInt(appBarHeight,10)-scrollOffset;window.scroll({top:scrollTop,behavior:'smooth'});}else{firstElement.scrollIntoView({behavior:'smooth'});}}},[offset,ref]);return{scrollTo:scrollTo};};
|
package/core/index.js
CHANGED
|
@@ -49,4 +49,4 @@ export{withTheme}from"./hocs/withTheme";export{withRoute}from"./hocs/withRoute";
|
|
|
49
49
|
export{ThemeConfigResolver}from"./config/ThemeConfigResolver";export{isBeta}from"./config/isBeta";export{getThemeConfig}from"./config/getThemeConfig";export{getThemeSettings}from"./config/getThemeSettings";export{getThemeColors}from"./config/getThemeColors";export{getThemeAssets}from"./config/getThemeAssets";export{getPageConfig}from"./config/getPageConfig";export{getPageSettings}from"./config/getPageSettings";export{getWidgetConfig}from"./config/getWidgetConfig";export{getWidgetSettings}from"./config/getWidgetSettings";// -------------- HELPERS -------------- //
|
|
50
50
|
export{i18n,getWeekDaysOrder}from"./helpers/i18n";export{default as nl2br}from"./helpers/nl2br";export*from"./helpers/string";export{updateLegacyNavigationBar}from"./helpers/updateLegacyNavigationBar";export{getFullImageSource}from"./helpers/getFullImageSource";export{isIOSTheme}from"./helpers/isIOSTheme";export{isTouchDevice}from"./helpers/isTouchDevice";export{generateGoogleMapsDirectionsUrl}from"./helpers/googleMaps";export{hasWebBridge}from"./helpers/bridge";export{useScrollContainer}from"./helpers/scrollContainer";export{getDeviceTypeForCms}from"./helpers/deviceType";export*from"./helpers/featureFlag";// -------------- CONFIG -------------- //
|
|
51
51
|
export*from"./config/config.actions";export*from"./config/config.selectors";export*from"./config/config.streams";export*from"./initialization";// -------------- VALIDATION -------------- //
|
|
52
|
-
export*from"./validation";export{default as errorBehavior}from"./helpers/errorBehavior";export{makeGetShopSettingByKey,makeGetShopSettings,getIsLocationBasedShopping,getRestrictMultiLocationOrders,getFulfillmentSchedulingEnabled,getProductImagePlaceholder,getCategoryImagePlaceholder,getFavicon,getDefaultCurrency,getEnableWebIndexing,getNumberOfAddressLines,getGoogleSiteVerificationCode}from"./selectors";export{SHOP_SETTING_CART_SUPPLEMENTAL_CONTENT,SHOP_SETTING_ORDER_SUPPLEMENTAL_CONTENT,SHOP_SETTING_SHOW_SHOP_LOGO_IN_APP,SHOP_SETTING_SHOW_SHOP_LOGO_IN_WEB,SHOP_SETTING_PRODUCTS_SORT_ORDER,SHOP_SETTING_COOKIE_CONSENT_MODE,SHOP_SETTING_DISPLAY_PRICE_PER_MEASURE_UNIT,EUNAUTHORIZED,EAUTHENTICATION}from"./constants";
|
|
52
|
+
export*from"./validation";export{default as errorBehavior}from"./helpers/errorBehavior";export{makeGetShopSettingByKey,makeGetShopSettings,getIsLocationBasedShopping,getRestrictMultiLocationOrders,getFulfillmentSchedulingEnabled,getProductImagePlaceholder,getCategoryImagePlaceholder,getFavicon,getDefaultCurrency,getEnableWebIndexing,getNumberOfAddressLines,getGoogleSiteVerificationCode,getRegistrationMode}from"./selectors";export{SHOP_SETTING_CART_SUPPLEMENTAL_CONTENT,SHOP_SETTING_ORDER_SUPPLEMENTAL_CONTENT,SHOP_SETTING_SHOW_SHOP_LOGO_IN_APP,SHOP_SETTING_SHOW_SHOP_LOGO_IN_WEB,SHOP_SETTING_PRODUCTS_SORT_ORDER,SHOP_SETTING_COOKIE_CONSENT_MODE,SHOP_SETTING_DISPLAY_PRICE_PER_MEASURE_UNIT,SHOP_SETTING_REGISTRATION_MODE_SIMPLE,SHOP_SETTING_REGISTRATION_MODE_EXTENDED,EUNAUTHORIZED,EAUTHENTICATION}from"./constants";
|
package/core/selectors/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{getState as getShopSettingsState,makeGetShopSettingByKey,makeGetShopSettings,getProductImagePlaceholder,getCategoryImagePlaceholder,getFavicon,getNumberOfAddressLines,getGoogleSiteVerificationCode}from"./shopSettings";export{getIsLocationBasedShopping,getFulfillmentSchedulingEnabled,getRestrictMultiLocationOrders,getDefaultCurrency,getEnableWebIndexing,getProductShowAlternativeLocation,getProductListShowInventory}from"./merchantSettings";
|
|
1
|
+
export{getState as getShopSettingsState,makeGetShopSettingByKey,makeGetShopSettings,getProductImagePlaceholder,getCategoryImagePlaceholder,getFavicon,getNumberOfAddressLines,getGoogleSiteVerificationCode,getRegistrationMode}from"./shopSettings";export{getIsLocationBasedShopping,getFulfillmentSchedulingEnabled,getRestrictMultiLocationOrders,getDefaultCurrency,getEnableWebIndexing,getProductShowAlternativeLocation,getProductListShowInventory}from"./merchantSettings";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{createSelector}from'reselect';import{WISHLIST_MODE_PERSIST_ON_ADD,SHOP_SETTING_WISHLIST_MODE,SHOP_SETTING_IMAGES,SHOP_SETTING_IMAGES_PRODUCT_PLACEHOLDER,SHOP_SETTING_IMAGES_CATEGORY_PLACEHOLDER,SHOP_SETTING_IMAGES_FAVICON,SHOP_SETTING_NUMBER_OF_ADDRESS_LINES,SHOP_SETTING_GOOGLE_SITE_VERIFICATION_CODE,SHOP_SETTINGS_SHOW_CATEGORY_IMAGES}from"../constants/shopSettings";/**
|
|
1
|
+
import{createSelector}from'reselect';import{WISHLIST_MODE_PERSIST_ON_ADD,SHOP_SETTING_WISHLIST_MODE,SHOP_SETTING_IMAGES,SHOP_SETTING_IMAGES_PRODUCT_PLACEHOLDER,SHOP_SETTING_IMAGES_CATEGORY_PLACEHOLDER,SHOP_SETTING_IMAGES_FAVICON,SHOP_SETTING_NUMBER_OF_ADDRESS_LINES,SHOP_SETTING_GOOGLE_SITE_VERIFICATION_CODE,SHOP_SETTINGS_SHOW_CATEGORY_IMAGES,SHOP_SETTING_REGISTRATION_MODE,SHOP_SETTING_REGISTRATION_MODE_EXTENDED}from"../constants/shopSettings";/**
|
|
2
2
|
* Retrieves the shopSettings state from the store.
|
|
3
3
|
* @param {Object} state The current application state.
|
|
4
4
|
* @return {Object} The locations state.
|
|
@@ -19,4 +19,7 @@ import{createSelector}from'reselect';import{WISHLIST_MODE_PERSIST_ON_ADD,SHOP_SE
|
|
|
19
19
|
* Selects the placeholder image for products
|
|
20
20
|
*/export var getFavicon=createSelector(getShopSettingImages,function(images){return(images===null||images===void 0?void 0:images[SHOP_SETTING_IMAGES_FAVICON])||null;});/**
|
|
21
21
|
* Selects the number of address lines for registration / address forms
|
|
22
|
-
*/export var getNumberOfAddressLines=makeGetShopSettingByKey(SHOP_SETTING_NUMBER_OF_ADDRESS_LINES,2);export var getGoogleSiteVerificationCode=makeGetShopSettingByKey(SHOP_SETTING_GOOGLE_SITE_VERIFICATION_CODE,'');export var getShowCategoryImages=makeGetShopSettingByKey(SHOP_SETTINGS_SHOW_CATEGORY_IMAGES,true)
|
|
22
|
+
*/export var getNumberOfAddressLines=makeGetShopSettingByKey(SHOP_SETTING_NUMBER_OF_ADDRESS_LINES,2);export var getGoogleSiteVerificationCode=makeGetShopSettingByKey(SHOP_SETTING_GOOGLE_SITE_VERIFICATION_CODE,'');export var getShowCategoryImages=makeGetShopSettingByKey(SHOP_SETTINGS_SHOW_CATEGORY_IMAGES,true);/**
|
|
23
|
+
* Creates a selector to retrieve the current active registration mode.
|
|
24
|
+
* When the selector returns "simple" the form will not contain any address related fields.
|
|
25
|
+
*/export var getRegistrationMode=makeGetShopSettingByKey(SHOP_SETTING_REGISTRATION_MODE,SHOP_SETTING_REGISTRATION_MODE_EXTENDED);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shopgate/engage",
|
|
3
|
-
"version": "7.8.0-beta.
|
|
3
|
+
"version": "7.8.0-beta.3",
|
|
4
4
|
"description": "Shopgate's ENGAGE library.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Shopgate <support@shopgate.com>",
|
|
@@ -16,12 +16,12 @@
|
|
|
16
16
|
],
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@shopgate/native-modules": "1.0.0-beta.18",
|
|
19
|
-
"@shopgate/pwa-common": "7.8.0-beta.
|
|
20
|
-
"@shopgate/pwa-common-commerce": "7.8.0-beta.
|
|
21
|
-
"@shopgate/pwa-core": "7.8.0-beta.
|
|
22
|
-
"@shopgate/pwa-ui-ios": "7.8.0-beta.
|
|
23
|
-
"@shopgate/pwa-ui-material": "7.8.0-beta.
|
|
24
|
-
"@shopgate/pwa-ui-shared": "7.8.0-beta.
|
|
19
|
+
"@shopgate/pwa-common": "7.8.0-beta.3",
|
|
20
|
+
"@shopgate/pwa-common-commerce": "7.8.0-beta.3",
|
|
21
|
+
"@shopgate/pwa-core": "7.8.0-beta.3",
|
|
22
|
+
"@shopgate/pwa-ui-ios": "7.8.0-beta.3",
|
|
23
|
+
"@shopgate/pwa-ui-material": "7.8.0-beta.3",
|
|
24
|
+
"@shopgate/pwa-ui-shared": "7.8.0-beta.3",
|
|
25
25
|
"@stripe/react-stripe-js": "^1.1.2",
|
|
26
26
|
"@stripe/stripe-js": "^1.3.1",
|
|
27
27
|
"@virtuous/conductor": "~2.5.0",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React,{useRef}from'react';import RegistrationProvider from"../../providers/RegistrationProvider";import
|
|
1
|
+
import React,{useRef}from'react';import RegistrationProvider from"../../providers/RegistrationProvider";import RegistrationContent from"./RegistrationContent";/**
|
|
2
2
|
* The Registration component.
|
|
3
3
|
* @returns {JSX}
|
|
4
|
-
*/var Registration=function Registration(){var formContainerRef=useRef(null);return React.createElement(RegistrationProvider,{formContainerRef:formContainerRef},React.createElement(
|
|
4
|
+
*/var Registration=function Registration(){var formContainerRef=useRef(null);return React.createElement(RegistrationProvider,{formContainerRef:formContainerRef},React.createElement(RegistrationContent,{ref:formContainerRef}));};export default Registration;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import React,{forwardRef}from'react';import{SHOP_SETTING_REGISTRATION_MODE_SIMPLE}from'@shopgate/engage/core';import RegistrationFormBase from"./RegistrationFormBase";import RegistrationFormBilling from"./RegistrationFormBilling";import RegistrationFormShipping from"./RegistrationFormShipping";import RegistrationFormActions from"./RegistrationFormActions";import RegistrationFormExtra from"./RegistrationFormExtra";import RegistrationFormToggle from"./RegistrationFormToggle";import{container,containerItem}from"./RegistrationContent.style";import{useRegistration}from"../../hooks";/**
|
|
2
|
+
* The Registration component.
|
|
3
|
+
* @returns {JSX}
|
|
4
|
+
*/var Registration=forwardRef(function(_,ref){var _useRegistration=useRegistration(),registrationMode=_useRegistration.registrationMode;var renderSingleColumn=registrationMode===SHOP_SETTING_REGISTRATION_MODE_SIMPLE;return React.createElement(React.Fragment,null,React.createElement("div",{className:container,ref:ref},React.createElement("div",{className:containerItem},!renderSingleColumn&&React.createElement(RegistrationFormBase,null)),React.createElement("div",{className:containerItem},renderSingleColumn&&React.createElement(RegistrationFormBase,null),React.createElement(RegistrationFormBilling,null),React.createElement(RegistrationFormToggle,null),React.createElement(RegistrationFormShipping,null),React.createElement(RegistrationFormExtra,null))),React.createElement(RegistrationFormActions,null));});export default Registration;
|
|
@@ -0,0 +1,2 @@
|
|
|
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{css}from'glamor';import{themeConfig}from'@shopgate/pwa-common/helpers/config';import{StylePresets}from'@shopgate/engage/components/Form';import{isIOSTheme}from'@shopgate/engage/core';var variables=themeConfig.variables;export var container=css(_extends({padding:"".concat(variables.gap.big,"px ").concat(variables.gap.big,"px 0"),display:'flex',flex:'0 0 auto',flexDirection:'column'},!isIOSTheme()?{'@media(min-width: 768px)':{flexDirection:'row-reverse','> :not(:first-child)':{marginRight:variables.gap.big}}}:null));export var containerItem=css(_extends({flexGrow:1,flexShrink:0},!isIOSTheme()?{'@media(min-width: 768px)':{width:"calc(50% - ".concat(variables.gap.big,"px)")}}:null));export var form=css(_extends({},StylePresets.OUTLINED_FORM_FIELDS,{' .registrationOptInMarketingOptIn':{paddingTop:0,paddingBottom:variables.gap.big}}));export var section=css({// marginBottom: variables.gap.big * 1.5,
|
|
2
|
+
}).toString();export var shippingFormSection=css({paddingBottom:32}).toString();export var hidden=css({display:'none'}).toString();export var submitButtonContainer=css(_extends({margin:"0 ".concat(variables.gap.big,"px ").concat(variables.gap.big,"px")},!isIOSTheme()?{'@media(min-width: 768px)':{width:"calc(50% - ".concat(variables.gap.big,"px)")}}:null));export var submitButton=css({width:'100%',marginTop:8}).toString();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React,{useMemo}from'react';import PropTypes from'prop-types';import{i18n}from'@shopgate/engage/core';import{RippleButton}from'@shopgate/engage/components';import{useRegistration}from"../../hooks";import{submitButton,submitButtonContainer}from"./
|
|
1
|
+
import React,{useMemo}from'react';import PropTypes from'prop-types';import{i18n}from'@shopgate/engage/core';import{RippleButton}from'@shopgate/engage/components';import{useRegistration}from"../../hooks";import{submitButton,submitButtonContainer}from"./RegistrationContent.style";/**
|
|
2
2
|
* PickupContactForm
|
|
3
3
|
* @param {Object} props The component props
|
|
4
4
|
* @returns {JSX}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i18n}from'@shopgate/engage/core';/**
|
|
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{i18n,SHOP_SETTING_REGISTRATION_MODE_SIMPLE,SHOP_SETTING_REGISTRATION_MODE_EXTENDED}from'@shopgate/engage/core';/**
|
|
2
2
|
* Generates form configuration.
|
|
3
3
|
* @returns {Object}
|
|
4
|
-
*/var generateFormConfig=function generateFormConfig(){return{fields:{emailAddress:{type:'email',label:"".concat(i18n.text('checkout.pickup_contact.form.emailAddress')," *")},password:{type:'password',label:i18n.text('checkout.pickup_contact.form.password')},passwordConfirm:{type:'password',label:i18n.text('checkout.pickup_contact.form.passwordConfirm')}}};};export default generateFormConfig;
|
|
4
|
+
*/var generateFormConfig=function generateFormConfig(_ref){var _ref$registrationMode=_ref.registrationMode,registrationMode=_ref$registrationMode===void 0?SHOP_SETTING_REGISTRATION_MODE_EXTENDED:_ref$registrationMode;return{fields:_extends({},registrationMode===SHOP_SETTING_REGISTRATION_MODE_SIMPLE?{firstName:{type:'text',label:"".concat(i18n.text('checkout.pickup_contact.form.firstName')," *")},lastName:{type:'text',label:"".concat(i18n.text('checkout.pickup_contact.form.lastName')," *")}}:null,{emailAddress:{type:'email',label:"".concat(i18n.text('checkout.pickup_contact.form.emailAddress')," *")},password:{type:'password',label:i18n.text('checkout.pickup_contact.form.password')},passwordConfirm:{type:'password',label:i18n.text('checkout.pickup_contact.form.passwordConfirm')}})};};export default generateFormConfig;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React,{useMemo,useCallback}from'react';import{FormBuilder}from'@shopgate/engage/components';import{useRegistration}from"../../hooks";import Section from"../../../checkout/components/Checkout/CheckoutSection";import generateFormConfig from"./RegistrationFormBase.config";import{form,section}from"./
|
|
1
|
+
import React,{useMemo,useCallback}from'react';import{FormBuilder}from'@shopgate/engage/components';import{useRegistration}from"../../hooks";import Section from"../../../checkout/components/Checkout/CheckoutSection";import generateFormConfig from"./RegistrationFormBase.config";import{form,section}from"./RegistrationContent.style";/**
|
|
2
2
|
* The RegistrationFormBase component.
|
|
3
3
|
* @returns {JSX}
|
|
4
|
-
*/var RegistrationFormBase=function RegistrationFormBase(){var _useRegistration=useRegistration(),defaultBaseFormState=_useRegistration.defaultBaseFormState,baseFormValidationErrors=_useRegistration.baseFormValidationErrors,updateBaseForm=_useRegistration.updateBaseForm;var formConfig=useMemo(function(){return generateFormConfig();},[]);var handleUpdate=useCallback(function(values){updateBaseForm(values);},[updateBaseForm]);return React.createElement(Section,{title:"registration.headlines.create_new_account",className:section,hasForm:true},React.createElement(FormBuilder,{className:form,name:"RegistrationBase",config:formConfig,defaults:defaultBaseFormState,validationErrors:baseFormValidationErrors,handleUpdate:handleUpdate}));};export default RegistrationFormBase;
|
|
4
|
+
*/var RegistrationFormBase=function RegistrationFormBase(){var _useRegistration=useRegistration(),defaultBaseFormState=_useRegistration.defaultBaseFormState,baseFormValidationErrors=_useRegistration.baseFormValidationErrors,updateBaseForm=_useRegistration.updateBaseForm,registrationMode=_useRegistration.registrationMode;var formConfig=useMemo(function(){return generateFormConfig({registrationMode:registrationMode});},[registrationMode]);var handleUpdate=useCallback(function(values){updateBaseForm(values);},[updateBaseForm]);return React.createElement(Section,{title:"registration.headlines.create_new_account",className:section,hasForm:true},React.createElement(FormBuilder,{className:form,name:"RegistrationBase",config:formConfig,defaults:defaultBaseFormState,validationErrors:baseFormValidationErrors,handleUpdate:handleUpdate}));};export default RegistrationFormBase;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React,{useMemo,useCallback}from'react';import PropTypes from'prop-types';import{FormBuilder}from'@shopgate/engage/components';import{useRegistration}from"../../hooks";import Section from"../../../checkout/components/Checkout/CheckoutSection";import{ELEMENT_ID_BILLING_CONTACT}from"../../constants";import generateFormConfig from"./RegistrationFormBilling.config";import{form,section}from"./
|
|
1
|
+
import React,{useMemo,useCallback}from'react';import PropTypes from'prop-types';import{FormBuilder}from'@shopgate/engage/components';import{useRegistration}from"../../hooks";import Section from"../../../checkout/components/Checkout/CheckoutSection";import{ELEMENT_ID_BILLING_CONTACT}from"../../constants";import generateFormConfig from"./RegistrationFormBilling.config";import{form,section}from"./RegistrationContent.style";/**
|
|
2
2
|
* The RegistrationFormBilling component.
|
|
3
3
|
* @param {Object} props The component props
|
|
4
4
|
* @returns {JSX}
|
|
5
|
-
*/var RegistrationFormBilling=function RegistrationFormBilling(_ref){var isGuest=_ref.isGuest;var _useRegistration=useRegistration(isGuest),supportedCountries=_useRegistration.supportedCountries,userLocation=_useRegistration.userLocation,defaultBillingFormState=_useRegistration.defaultBillingFormState,billingFormValidationErrors=_useRegistration.billingFormValidationErrors,updateBillingForm=_useRegistration.updateBillingForm,numberOfAddressLines=_useRegistration.numberOfAddressLines,orderReserveOnly=_useRegistration.orderReserveOnly;var formConfig=useMemo(function(){return generateFormConfig({supportedCountries:supportedCountries,userLocation:userLocation,numberOfAddressLines:numberOfAddressLines,isGuest:isGuest,isReserveOnly:orderReserveOnly});},[isGuest,numberOfAddressLines,orderReserveOnly,supportedCountries,userLocation]);var title=useMemo(function(){if(isGuest&&orderReserveOnly){return'registration.headlines.billing_address_reserve';}return'registration.headlines.billing_address';},[isGuest,orderReserveOnly]);var handleUpdate=useCallback(function(values){updateBillingForm(values);},[updateBillingForm]);return React.createElement(Section,{title:title,className:section,hasForm:true,id:ELEMENT_ID_BILLING_CONTACT},React.createElement(FormBuilder,{className:form,name:"RegistrationBilling",config:formConfig,defaults:defaultBillingFormState,validationErrors:billingFormValidationErrors,handleUpdate:handleUpdate}));};RegistrationFormBilling.defaultProps={isGuest:false};export default RegistrationFormBilling;
|
|
5
|
+
*/var RegistrationFormBilling=function RegistrationFormBilling(_ref){var isGuest=_ref.isGuest;var _useRegistration=useRegistration(isGuest),supportedCountries=_useRegistration.supportedCountries,userLocation=_useRegistration.userLocation,defaultBillingFormState=_useRegistration.defaultBillingFormState,billingFormValidationErrors=_useRegistration.billingFormValidationErrors,updateBillingForm=_useRegistration.updateBillingForm,numberOfAddressLines=_useRegistration.numberOfAddressLines,orderReserveOnly=_useRegistration.orderReserveOnly,isBillingAddressSelectionEnabled=_useRegistration.isBillingAddressSelectionEnabled;var formConfig=useMemo(function(){return generateFormConfig({supportedCountries:supportedCountries,userLocation:userLocation,numberOfAddressLines:numberOfAddressLines,isGuest:isGuest,isReserveOnly:orderReserveOnly});},[isGuest,numberOfAddressLines,orderReserveOnly,supportedCountries,userLocation]);var title=useMemo(function(){if(isGuest&&orderReserveOnly){return'registration.headlines.billing_address_reserve';}return'registration.headlines.billing_address';},[isGuest,orderReserveOnly]);var handleUpdate=useCallback(function(values){updateBillingForm(values);},[updateBillingForm]);if(!isBillingAddressSelectionEnabled){return null;}return React.createElement(Section,{title:title,className:section,hasForm:true,id:ELEMENT_ID_BILLING_CONTACT},React.createElement(FormBuilder,{className:form,name:"RegistrationBilling",config:formConfig,defaults:defaultBillingFormState,validationErrors:billingFormValidationErrors,handleUpdate:handleUpdate}));};RegistrationFormBilling.defaultProps={isGuest:false};export default RegistrationFormBilling;
|
|
@@ -1,5 +1,5 @@
|
|
|
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{i18n}from'@shopgate/engage/core';import{
|
|
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{i18n}from'@shopgate/engage/core';import{generateCustomerAttributesFields}from'@shopgate/engage/account/helper/form';/**
|
|
2
2
|
* Generates form configuration.
|
|
3
3
|
* @param {Object} params Additional parameters
|
|
4
4
|
* @returns {Object}
|
|
5
|
-
*/var generateFormConfig=function generateFormConfig(_ref){var customerAttributes=_ref.customerAttributes,isGuest=_ref.isGuest;return{fields:_extends({},!isGuest&&{marketingOptIn:{type:'checkbox',label:i18n.text('registration.marketing_opt_in_label')}},{},
|
|
5
|
+
*/var generateFormConfig=function generateFormConfig(_ref){var customerAttributes=_ref.customerAttributes,isGuest=_ref.isGuest,supportedCountries=_ref.supportedCountries,userLocation=_ref.userLocation;return{fields:_extends({},!isGuest&&{marketingOptIn:{type:'checkbox',label:i18n.text('registration.marketing_opt_in_label')}},{},generateCustomerAttributesFields({customerAttributes:customerAttributes,supportedCountries:supportedCountries,userLocation:userLocation}))};};export default generateFormConfig;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React,{useMemo,useCallback}from'react';import PropTypes from'prop-types';import{FormBuilder}from'@shopgate/engage/components';import Section from"../../../checkout/components/Checkout/CheckoutSection";import{useRegistration}from"../../hooks";import{ELEMENT_ID_CUSTOMER_ATTRIBUTES}from"../../constants";import generateFormConfig from"./RegistrationFormExtra.config";import{form,section}from"./
|
|
1
|
+
import React,{useMemo,useCallback}from'react';import PropTypes from'prop-types';import{FormBuilder}from'@shopgate/engage/components';import Section from"../../../checkout/components/Checkout/CheckoutSection";import{useRegistration}from"../../hooks";import{ELEMENT_ID_CUSTOMER_ATTRIBUTES}from"../../constants";import generateFormConfig from"./RegistrationFormExtra.config";import{form,section}from"./RegistrationContent.style";/**
|
|
2
2
|
* The RegistrationFormExtra component.
|
|
3
3
|
* @param {Object} props The component props
|
|
4
4
|
* @returns {JSX}
|
|
5
|
-
*/var RegistrationFormExtra=function RegistrationFormExtra(_ref){var isGuest=_ref.isGuest;var _useRegistration=useRegistration(isGuest),defaultExtraFormState=_useRegistration.defaultExtraFormState,updateExtraForm=_useRegistration.updateExtraForm,customerAttributes=_useRegistration.customerAttributes,extraFormValidationErrors=_useRegistration.extraFormValidationErrors;var formConfig=useMemo(function(){return generateFormConfig({customerAttributes:customerAttributes,isGuest:isGuest});},[customerAttributes,isGuest]);var handleUpdate=useCallback(function(values){updateExtraForm(values);},[updateExtraForm]);return React.createElement(Section,{className:section,hasForm:true,id:ELEMENT_ID_CUSTOMER_ATTRIBUTES},React.createElement(FormBuilder,{className:form,name:"RegistrationExtra",config:formConfig,defaults:defaultExtraFormState,validationErrors:extraFormValidationErrors,handleUpdate:handleUpdate}));};RegistrationFormExtra.defaultProps={isGuest:false};export default RegistrationFormExtra;
|
|
5
|
+
*/var RegistrationFormExtra=function RegistrationFormExtra(_ref){var isGuest=_ref.isGuest;var _useRegistration=useRegistration(isGuest),defaultExtraFormState=_useRegistration.defaultExtraFormState,updateExtraForm=_useRegistration.updateExtraForm,customerAttributes=_useRegistration.customerAttributes,extraFormValidationErrors=_useRegistration.extraFormValidationErrors,supportedCountries=_useRegistration.supportedCountries,userLocation=_useRegistration.userLocation;var formConfig=useMemo(function(){return generateFormConfig({customerAttributes:customerAttributes,isGuest:isGuest,supportedCountries:supportedCountries,userLocation:userLocation});},[customerAttributes,isGuest,supportedCountries,userLocation]);var handleUpdate=useCallback(function(values){updateExtraForm(values);},[updateExtraForm]);return React.createElement(Section,{className:section,hasForm:true,id:ELEMENT_ID_CUSTOMER_ATTRIBUTES},React.createElement(FormBuilder,{className:form,name:"RegistrationExtra",config:formConfig,defaults:defaultExtraFormState,validationErrors:extraFormValidationErrors,handleUpdate:handleUpdate}));};RegistrationFormExtra.defaultProps={isGuest:false};export default RegistrationFormExtra;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React,{useMemo,useCallback}from'react';import PropTypes from'prop-types';import classNames from'classnames';import{FormBuilder}from'@shopgate/engage/components';import{useRegistration}from"../../hooks";import Section from"../../../checkout/components/Checkout/CheckoutSection";import{ELEMENT_ID_SHIPPING_CONTACT}from"../../constants";import generateFormConfig from"./RegistrationFormShipping.config";import{form,section,shippingFormSection}from"./
|
|
1
|
+
import React,{useMemo,useCallback}from'react';import PropTypes from'prop-types';import classNames from'classnames';import{FormBuilder}from'@shopgate/engage/components';import{useRegistration}from"../../hooks";import Section from"../../../checkout/components/Checkout/CheckoutSection";import{ELEMENT_ID_SHIPPING_CONTACT}from"../../constants";import generateFormConfig from"./RegistrationFormShipping.config";import{form,section,shippingFormSection}from"./RegistrationContent.style";/**
|
|
2
2
|
* The RegistrationFormShipping component.
|
|
3
3
|
* @param {Object} props The component props
|
|
4
4
|
* @returns {JSX}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import React,{useCallback}from'react';import PropTypes from'prop-types';import{css}from'glamor';import{i18n}from'@shopgate/engage/core';import{Toggle}from'@shopgate/engage/components';import{ELEMENT_ID_SHIPPING_CONTACT_TOGGLE}from"../../constants";import{useRegistration}from"../../hooks";var styles={root:css({display:'flex',justifyContent:'space-between',paddingBottom:24}).toString(),label:css({paddingRight:8}).toString()};/**
|
|
2
2
|
* @param {Object} props The component props
|
|
3
3
|
* @returns {JSX}
|
|
4
4
|
*/var RegistrationFormToggle=function RegistrationFormToggle(_ref){var isGuest=_ref.isGuest;var _useRegistration=useRegistration(isGuest),isShippingAddressSelectionEnabled=_useRegistration.isShippingAddressSelectionEnabled,isShippingFormVisible=_useRegistration.isShippingFormVisible,setIsShippingFormVisible=_useRegistration.setIsShippingFormVisible;var handleChange=useCallback(function(e){setIsShippingFormVisible(e.target.checked);},[setIsShippingFormVisible]);if(!isShippingAddressSelectionEnabled){return null;}return React.createElement("div",{className:styles.root,id:ELEMENT_ID_SHIPPING_CONTACT_TOGGLE},React.createElement("span",{className:styles.label},i18n.text('registration.different_shipping_address_label')),React.createElement(Toggle,{id:"toggle-shipping-form",checked:isShippingFormVisible,onChange:handleChange}));};RegistrationFormToggle.defaultProps={isGuest:false};export default RegistrationFormToggle;
|
|
@@ -1,4 +1,4 @@
|
|
|
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 _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;}function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}import{EVALIDATION}from'@shopgate/engage/core';import{updateCheckoutOrder}from'@shopgate/engage/checkout/actions';import{extractAttributes}from'@shopgate/engage/account/helper/form';import{getMerchantCustomerAttributes}from'@shopgate/engage/core/selectors/merchantSettings'
|
|
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 _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;}function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}import{EVALIDATION}from'@shopgate/engage/core';import{updateCheckoutOrder}from'@shopgate/engage/checkout/actions';import{extractAttributes,convertPipelineValidationErrors}from'@shopgate/engage/account/helper/form';import{getMerchantCustomerAttributes}from'@shopgate/engage/core/selectors/merchantSettings';/**
|
|
2
2
|
* Submits guest registration form data.
|
|
3
3
|
* @returns {Function}
|
|
4
|
-
*/export var submitGuestRegistration=function submitGuestRegistration(_ref){var billingFormData=_ref.billingFormData,shippingFormData=_ref.shippingFormData,pickupFormData=_ref.pickupFormData,extraFormData=_ref.extraFormData,processShipping=_ref.processShipping;return(/*#__PURE__*/function(){var _ref2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(dispatch,getState){var customerAttributes,marketingOptIn,attributeData,attributes,pickupPerson,restPickupFormData,_pickupFormData,shippingFormVisible,pickupFormVisible,addressSequences,order,errors,response,code,validationErrors,converted,_converted$validation,sequenceErrors,shippingIndex,pickupIndex,billing,shipping,pickup;return _regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:customerAttributes=getMerchantCustomerAttributes(getState());marketingOptIn=extraFormData.marketingOptIn,attributeData=_objectWithoutProperties(extraFormData,["marketingOptIn"]);attributes=extractAttributes(customerAttributes,attributeData);restPickupFormData={};if(pickupFormData){_pickupFormData=pickupFormData;pickupPerson=_pickupFormData.pickupPerson;restPickupFormData=_objectWithoutPropertiesLoose(_pickupFormData,["pickupPerson"]);_pickupFormData;}shippingFormVisible=processShipping&&!!shippingFormData;pickupFormVisible=pickupFormData&&pickupPerson!=='me';addressSequences=[_extends({type:'billing'},billingFormData)].concat(processShipping?_extends({type:'shipping'},shippingFormData||billingFormData):[],pickupFormData?_extends({},pickupPerson==='me'?_extends({type:'pickup'},billingFormData):_extends({type:'pickup'},restPickupFormData)):[]);order=_extends({addressSequences:addressSequences,primaryBillToAddressSequenceIndex:0,primaryShipToAddressSequenceIndex:1},(attributes===null||attributes===void 0?void 0:attributes.length)?{customer:{attributes:attributes}}:{});_context.prev=9;_context.next=12;return dispatch(updateCheckoutOrder(order));case 12:response=_context.sent;_context.next=23;break;case 15:_context.prev=15;_context.t0=_context["catch"](9);code=_context.t0.code,validationErrors=_context.t0.errors;if(!(code===EVALIDATION)){_context.next=22;break;}errors=validationErrors;_context.next=23;break;case 22:throw _context.t0;case 23:converted=
|
|
4
|
+
*/export var submitGuestRegistration=function submitGuestRegistration(_ref){var billingFormData=_ref.billingFormData,shippingFormData=_ref.shippingFormData,pickupFormData=_ref.pickupFormData,extraFormData=_ref.extraFormData,processShipping=_ref.processShipping;return(/*#__PURE__*/function(){var _ref2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(dispatch,getState){var customerAttributes,marketingOptIn,attributeData,attributes,pickupPerson,restPickupFormData,_pickupFormData,shippingFormVisible,pickupFormVisible,addressSequences,order,errors,response,code,validationErrors,converted,_converted$validation,_converted$validation2,sequenceErrors,shippingIndex,pickupIndex,billing,shipping,pickup,extra;return _regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:customerAttributes=getMerchantCustomerAttributes(getState());marketingOptIn=extraFormData.marketingOptIn,attributeData=_objectWithoutProperties(extraFormData,["marketingOptIn"]);attributes=extractAttributes(customerAttributes,attributeData);restPickupFormData={};if(pickupFormData){_pickupFormData=pickupFormData;pickupPerson=_pickupFormData.pickupPerson;restPickupFormData=_objectWithoutPropertiesLoose(_pickupFormData,["pickupPerson"]);_pickupFormData;}shippingFormVisible=processShipping&&!!shippingFormData;pickupFormVisible=pickupFormData&&pickupPerson!=='me';addressSequences=[_extends({type:'billing'},billingFormData)].concat(processShipping?_extends({type:'shipping'},shippingFormData||billingFormData):[],pickupFormData?_extends({},pickupPerson==='me'?_extends({type:'pickup'},billingFormData):_extends({type:'pickup'},restPickupFormData)):[]);order=_extends({addressSequences:addressSequences,primaryBillToAddressSequenceIndex:0,primaryShipToAddressSequenceIndex:1},(attributes===null||attributes===void 0?void 0:attributes.length)?{customer:{attributes:attributes}}:{});_context.prev=9;_context.next=12;return dispatch(updateCheckoutOrder(order));case 12:response=_context.sent;_context.next=23;break;case 15:_context.prev=15;_context.t0=_context["catch"](9);code=_context.t0.code,validationErrors=_context.t0.errors;if(!(code===EVALIDATION)){_context.next=22;break;}errors=validationErrors;_context.next=23;break;case 22:throw _context.t0;case 23:converted=convertPipelineValidationErrors(errors,attributes);if(!((converted===null||converted===void 0?void 0:converted.validation)&&Object.keys(converted.validation).length>0)){_context.next=33;break;}sequenceErrors=converted===null||converted===void 0?void 0:(_converted$validation=converted.validation)===null||_converted$validation===void 0?void 0:_converted$validation.addressSequences;shippingIndex=addressSequences.findIndex(function(item){return item.type==='shipping';});pickupIndex=addressSequences.findIndex(function(item){return item.type==='pickup';});billing=(sequenceErrors===null||sequenceErrors===void 0?void 0:sequenceErrors['0'])||{};shipping=shippingFormVisible?(sequenceErrors===null||sequenceErrors===void 0?void 0:sequenceErrors[shippingIndex])||{}:{};pickup=pickupFormVisible?(sequenceErrors===null||sequenceErrors===void 0?void 0:sequenceErrors[pickupIndex])||{}:{};extra=(converted===null||converted===void 0?void 0:(_converted$validation2=converted.validation)===null||_converted$validation2===void 0?void 0:_converted$validation2.attributes)||{};return _context.abrupt("return",{response:response,errors:{billingFormData:_extends({},billing),shippingFormData:_extends({},shipping),pickupFormData:_extends({},pickup),extraFormData:_extends({},extra)}});case 33:return _context.abrupt("return",{response:response});case 34:case"end":return _context.stop();}}},_callee,null,[[9,15]]);}));return function(_x,_x2){return _ref2.apply(this,arguments);};}());};
|
|
@@ -1,11 +1,11 @@
|
|
|
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,useCallback,useEffect}from'react';import PropTypes from'prop-types';import pickBy from'lodash/pickBy';import identity from'lodash/identity';import appConfig from'@shopgate/pwa-common/helpers/config';import{useFormState}from'@shopgate/engage/core/hooks/useFormState';import{useScrollTo}from'@shopgate/engage/core/hooks/useScrollTo';import{LoadingProvider,i18n,useAsyncMemo,useRoute}from'@shopgate/engage/core';import{ADDRESS_TYPE_SHIPPING,ADDRESS_TYPE_PICKUP}from'@shopgate/engage/checkout';import{extractDefaultValues}from"../../account/helper/form";import{GUEST_CHECKOUT_PATTERN,GUEST_CHECKOUT_PAYMENT_PATTERN}from"../../checkout/constants/routes";import Context from"./GuestRegistrationProvider.context";import{generateBillingConstraints,generateShippingConstraints,generatePickupConstraints,generateSelfPickupConstraints,generateExtraConstraints}from"./GuestRegistrationProvider.constraints";import{MARKETING_OPT_IN_DEFAULT,ELEMENT_ID_SHIPPING_CONTACT,ELEMENT_ID_SHIPPING_CONTACT_TOGGLE,ELEMENT_ID_PICKUP_CONTACT}from"../constants";import connect from"./GuestRegistrationProvider.connector";var initialAddressFormState={firstName:'',lastName:'',company:'',address1:'',address2:'',city:'',country:'',postalCode:'',mobile:''};var initialBillingFormState=_extends({},initialAddressFormState);var initialShippingFormState=_extends({},initialAddressFormState);var initialPickupFormState={pickupPerson:'me',firstName:'',lastName:'',mobile:'',emailAddress:''};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,useCallback,useEffect}from'react';import PropTypes from'prop-types';import pickBy from'lodash/pickBy';import identity from'lodash/identity';import appConfig from'@shopgate/pwa-common/helpers/config';import{useFormState}from'@shopgate/engage/core/hooks/useFormState';import{useScrollTo}from'@shopgate/engage/core/hooks/useScrollTo';import{LoadingProvider,i18n,useAsyncMemo,useRoute,SHOP_SETTING_REGISTRATION_MODE_EXTENDED}from'@shopgate/engage/core';import{ADDRESS_TYPE_SHIPPING,ADDRESS_TYPE_PICKUP}from'@shopgate/engage/checkout';import{extractDefaultValues}from"../../account/helper/form";import{GUEST_CHECKOUT_PATTERN,GUEST_CHECKOUT_PAYMENT_PATTERN}from"../../checkout/constants/routes";import Context from"./GuestRegistrationProvider.context";import{generateBillingConstraints,generateShippingConstraints,generatePickupConstraints,generateSelfPickupConstraints,generateExtraConstraints}from"./GuestRegistrationProvider.constraints";import{MARKETING_OPT_IN_DEFAULT,ELEMENT_ID_SHIPPING_CONTACT,ELEMENT_ID_SHIPPING_CONTACT_TOGGLE,ELEMENT_ID_PICKUP_CONTACT}from"../constants";import connect from"./GuestRegistrationProvider.connector";var initialAddressFormState={firstName:'',lastName:'',company:'',address1:'',address2:'',city:'',country:'',postalCode:'',mobile:''};var initialBillingFormState=_extends({},initialAddressFormState);var initialShippingFormState=_extends({},initialAddressFormState);var initialPickupFormState={pickupPerson:'me',firstName:'',lastName:'',mobile:'',emailAddress:''};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
|
* @param {Object} props The provider props
|
|
7
7
|
* @returns {JSX}
|
|
8
|
-
*/var GuestRegistrationProvider=function GuestRegistrationProvider(_ref){var children=_ref.children,formContainerRef=_ref.formContainerRef,isDataReady=_ref.isDataReady,userLocation=_ref.userLocation,customerAttributes=_ref.customerAttributes,billingAddress=_ref.billingAddress,shippingAddress=_ref.shippingAddress,pickupAddress=_ref.pickupAddress,customer=_ref.customer,billingPickupEquals=_ref.billingPickupEquals,billingShippingEquals=_ref.billingShippingEquals,numberOfAddressLines=_ref.numberOfAddressLines,cartHasDirectShipItems=_ref.cartHasDirectShipItems,orderReserveOnly=_ref.orderReserveOnly,orderNeedsPayment=_ref.orderNeedsPayment,isShippingAddressSelectionEnabled=_ref.isShippingAddressSelectionEnabled,isPickupContactSelectionEnabled=_ref.isPickupContactSelectionEnabled,shopSettings=_ref.shopSettings,submitGuestRegistration=_ref.submitGuestRegistration,prepareCheckout=_ref.prepareCheckout,isLastStackEntry=_ref.isLastStackEntry,historyPop=_ref.historyPop,historyPush=_ref.historyPush;var _useScrollTo=useScrollTo(formContainerRef),scrollTo=_useScrollTo.scrollTo;var isShippingFormEnabled=useMemo(function(){return cartHasDirectShipItems;},[cartHasDirectShipItems]);var getIsShippingFormVisible=useCallback(function(){return isShippingFormEnabled&&!!shippingAddress&&!billingShippingEquals;},[billingShippingEquals,isShippingFormEnabled,shippingAddress]);var _useState=useState(false),_useState2=_slicedToArray(_useState,2),isLocked=_useState2[0],setIsLocked=_useState2[1];var _useState3=useState(false),_useState4=_slicedToArray(_useState3,2),isBillingFormSubmitted=_useState4[0],setIsBillingFormSubmitted=_useState4[1];var _useState5=useState(false),_useState6=_slicedToArray(_useState5,2),isShippingFormSubmitted=_useState6[0],setIsShippingFormSubmitted=_useState6[1];var _useState7=useState(false),_useState8=_slicedToArray(_useState7,2),isExtraFormSubmitted=_useState8[0],setIsExtraFormSubmitted=_useState8[1];var _useState9=useState(false),_useState10=_slicedToArray(_useState9,2),isPickupFormSubmitted=_useState10[0],setIsPickupFormSubmitted=_useState10[1];var _useState11=useState(null),_useState12=_slicedToArray(_useState11,2),billingFormRequestErrors=_useState12[0],setBillingFormRequestErrors=_useState12[1];var _useState13=useState(null),_useState14=_slicedToArray(_useState13,2),shippingFormRequestErrors=_useState14[0],setShippingFormRequestErrors=_useState14[1];var _useState15=useState(null),_useState16=_slicedToArray(_useState15,2),pickupFormRequestErrors=_useState16[0],setPickupFormRequestErrors=_useState16[1];var _useState17=useState(
|
|
8
|
+
*/var GuestRegistrationProvider=function GuestRegistrationProvider(_ref){var children=_ref.children,formContainerRef=_ref.formContainerRef,isDataReady=_ref.isDataReady,userLocation=_ref.userLocation,customerAttributes=_ref.customerAttributes,billingAddress=_ref.billingAddress,shippingAddress=_ref.shippingAddress,pickupAddress=_ref.pickupAddress,customer=_ref.customer,billingPickupEquals=_ref.billingPickupEquals,billingShippingEquals=_ref.billingShippingEquals,numberOfAddressLines=_ref.numberOfAddressLines,cartHasDirectShipItems=_ref.cartHasDirectShipItems,orderReserveOnly=_ref.orderReserveOnly,orderNeedsPayment=_ref.orderNeedsPayment,isShippingAddressSelectionEnabled=_ref.isShippingAddressSelectionEnabled,isPickupContactSelectionEnabled=_ref.isPickupContactSelectionEnabled,shopSettings=_ref.shopSettings,submitGuestRegistration=_ref.submitGuestRegistration,prepareCheckout=_ref.prepareCheckout,isLastStackEntry=_ref.isLastStackEntry,historyPop=_ref.historyPop,historyPush=_ref.historyPush;var _useScrollTo=useScrollTo(formContainerRef),scrollTo=_useScrollTo.scrollTo;var isShippingFormEnabled=useMemo(function(){return cartHasDirectShipItems;},[cartHasDirectShipItems]);var getIsShippingFormVisible=useCallback(function(){return isShippingFormEnabled&&!!shippingAddress&&!billingShippingEquals;},[billingShippingEquals,isShippingFormEnabled,shippingAddress]);var _useState=useState(false),_useState2=_slicedToArray(_useState,2),isLocked=_useState2[0],setIsLocked=_useState2[1];var _useState3=useState(false),_useState4=_slicedToArray(_useState3,2),isBillingFormSubmitted=_useState4[0],setIsBillingFormSubmitted=_useState4[1];var _useState5=useState(false),_useState6=_slicedToArray(_useState5,2),isShippingFormSubmitted=_useState6[0],setIsShippingFormSubmitted=_useState6[1];var _useState7=useState(false),_useState8=_slicedToArray(_useState7,2),isExtraFormSubmitted=_useState8[0],setIsExtraFormSubmitted=_useState8[1];var _useState9=useState(false),_useState10=_slicedToArray(_useState9,2),isPickupFormSubmitted=_useState10[0],setIsPickupFormSubmitted=_useState10[1];var _useState11=useState(null),_useState12=_slicedToArray(_useState11,2),billingFormRequestErrors=_useState12[0],setBillingFormRequestErrors=_useState12[1];var _useState13=useState(null),_useState14=_slicedToArray(_useState13,2),shippingFormRequestErrors=_useState14[0],setShippingFormRequestErrors=_useState14[1];var _useState15=useState(null),_useState16=_slicedToArray(_useState15,2),pickupFormRequestErrors=_useState16[0],setPickupFormRequestErrors=_useState16[1];var _useState17=useState(null),_useState18=_slicedToArray(_useState17,2),extraFormRequestErrors=_useState18[0],setExtraFormRequestErrors=_useState18[1];var _useState19=useState(getIsShippingFormVisible()),_useState20=_slicedToArray(_useState19,2),isShippingFormVisible=_useState20[0],setIsShippingFormVisible=_useState20[1];var _useState21=useState(generateSelfPickupConstraints()),_useState22=_slicedToArray(_useState21,2),pickupConstraints=_useState22[0],setPickupConstraints=_useState22[1];var _useRoute=useRoute(),_useRoute$query$edit=_useRoute.query.edit,guestRegistrationEditMode=_useRoute$query$edit===void 0?null:_useRoute$query$edit;// Initialize checkout process.
|
|
9
9
|
var _useAsyncMemo=useAsyncMemo(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(){return _regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:if(!guestRegistrationEditMode){_context.next=2;break;}return _context.abrupt("return",true);case 2:_context.prev=2;setIsLocked(true);_context.next=6;return prepareCheckout({initializePayment:false,initializeOrder:!!isLastStackEntry});case 6:setIsLocked(false);return _context.abrupt("return",true);case 10:_context.prev=10;_context.t0=_context["catch"](2);setIsLocked(false);return _context.abrupt("return",false);case 14:case"end":return _context.stop();}}},_callee,null,[[2,10]]);})),[],false),_useAsyncMemo2=_slicedToArray(_useAsyncMemo,1),isInitialized=_useAsyncMemo2[0];useEffect(function(){setIsShippingFormVisible(getIsShippingFormVisible());},[getIsShippingFormVisible,setIsShippingFormVisible]);// Determine values to prefill some form fields
|
|
10
10
|
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]);// ===== billing form =====
|
|
11
11
|
var defaultBillingFormState=useMemo(function(){return _extends({},initialBillingFormState,{country:userCountry,region:userRegion},pickBy(billingAddress||{},identity));},[billingAddress,userCountry,userRegion]);var billingConstraints=useMemo(function(){return generateBillingConstraints(orderReserveOnly);},[orderReserveOnly]);var handleBillingFormSubmit=useCallback(function(){setIsBillingFormSubmitted(true);},[setIsBillingFormSubmitted]);var billingFormState=useFormState(defaultBillingFormState,handleBillingFormSubmit,billingConstraints,formContainerRef);// ===== shipping form =====
|
|
@@ -13,5 +13,10 @@ var defaultShippingFormState=useMemo(function(){return _extends({},initialShippi
|
|
|
13
13
|
var defaultPickupFormState=useMemo(function(){return _extends({},initialPickupFormState,{},!billingPickupEquals?pickBy(pickupAddress||{},identity):{},{pickupPerson:billingPickupEquals?'me':'someoneElse'});},[billingPickupEquals,pickupAddress]);var handlePickupFormSubmit=useCallback(function(){setIsPickupFormSubmitted(true);},[]);var pickupFormState=useFormState(defaultPickupFormState,handlePickupFormSubmit,pickupConstraints,formContainerRef);useEffect(function(){setPickupConstraints(pickupFormState.values.pickupPerson==='me'?generateSelfPickupConstraints():generatePickupConstraints());},[pickupFormState.values.pickupPerson]);// ===== extra form =====
|
|
14
14
|
var defaultExtraFormState=useMemo(function(){return _extends({},initialOptInFormState,{},extractDefaultValues((customer===null||customer===void 0?void 0:customer.attributes)||[]));},[customer]);var extraConstraints=useMemo(function(){return generateExtraConstraints(customerAttributes);},[customerAttributes]);var handleExtraFormSubmit=useCallback(function(){setIsExtraFormSubmitted(true);},[]);var extraFormState=useFormState(defaultExtraFormState,handleExtraFormSubmit,extraConstraints,formContainerRef);var handleSubmit=useCallback(function(){billingFormState.handleSubmit();shippingFormState.handleSubmit();pickupFormState.handleSubmit();extraFormState.handleSubmit();},[billingFormState,extraFormState,pickupFormState,shippingFormState]);useEffect(function(){if(!isBillingFormSubmitted||!isShippingFormSubmitted||!isPickupFormSubmitted||!isExtraFormSubmitted){return;}// Break the process when one of the forms has validation errors from the constraints
|
|
15
15
|
if(!billingFormState.valid||!shippingFormState.valid||!pickupFormState.valid||!extraFormState.valid){setIsBillingFormSubmitted(false);setIsShippingFormSubmitted(false);setIsPickupFormSubmitted(false);setIsExtraFormSubmitted(false);}/** Async wrapper for submit registration */var fn=/*#__PURE__*/function(){var _ref3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(){var response,_ref4,errors;return _regeneratorRuntime.wrap(function _callee2$(_context2){while(1){switch(_context2.prev=_context2.next){case 0:setIsLocked(true);_context2.prev=1;_context2.next=4;return submitGuestRegistration(_extends({billingFormData:billingFormState.values},isShippingFormVisible?{shippingFormData:shippingFormState.values}:{},{},isPickupContactSelectionEnabled?{pickupFormData:pickupFormState.values}:{},{extraFormData:extraFormState.values,processShipping:isShippingAddressSelectionEnabled}));case 4:response=_context2.sent;_context2.next=11;break;case 7:_context2.prev=7;_context2.t0=_context2["catch"](1);setIsLocked(false);return _context2.abrupt("return");case 11:_ref4=response||{},errors=_ref4.errors;if(errors){_context2.next=17;break;}setIsLocked(false);LoadingProvider.setLoading(GUEST_CHECKOUT_PAYMENT_PATTERN);if(guestRegistrationEditMode){historyPop();}else{historyPush({pathname:GUEST_CHECKOUT_PAYMENT_PATTERN});}return _context2.abrupt("return");case 17:// Updated the request validation errors
|
|
16
|
-
setBillingFormRequestErrors((errors===null||errors===void 0?void 0:errors.billingFormData)||null);setShippingFormRequestErrors((errors===null||errors===void 0?void 0:errors.shippingFormData)||null);setPickupFormRequestErrors((errors===null||errors===void 0?void 0:errors.pickupFormData)||null);// Release forms for additional submits
|
|
17
|
-
setIsBillingFormSubmitted(false);setIsShippingFormSubmitted(false);setIsPickupFormSubmitted(false);setIsExtraFormSubmitted(false);setIsLocked(false);case
|
|
16
|
+
setBillingFormRequestErrors((errors===null||errors===void 0?void 0:errors.billingFormData)||null);setShippingFormRequestErrors((errors===null||errors===void 0?void 0:errors.shippingFormData)||null);setPickupFormRequestErrors((errors===null||errors===void 0?void 0:errors.pickupFormData)||null);setExtraFormRequestErrors((errors===null||errors===void 0?void 0:errors.extraFormData)||null);// Release forms for additional submits
|
|
17
|
+
setIsBillingFormSubmitted(false);setIsShippingFormSubmitted(false);setIsPickupFormSubmitted(false);setIsExtraFormSubmitted(false);setIsLocked(false);case 26:case"end":return _context2.stop();}}},_callee2,null,[[1,7]]);}));return function fn(){return _ref3.apply(this,arguments);};}();fn();/* eslint-disable react-hooks/exhaustive-deps */},[isBillingFormSubmitted,isShippingFormSubmitted,isPickupFormSubmitted,isExtraFormSubmitted]);/* eslint-enable react-hooks/exhaustive-deps */ /* eslint-disable react-hooks/exhaustive-deps */useEffect(function(){billingFormState.scrollToError();},[billingFormRequestErrors,shippingFormRequestErrors,pickupFormRequestErrors,billingFormState.scrollToError]);/* eslint-enable react-hooks/exhaustive-deps */useEffect(function(){if(isLocked){LoadingProvider.setLoading(GUEST_CHECKOUT_PATTERN);return;}LoadingProvider.unsetLoading(GUEST_CHECKOUT_PATTERN);},[isLocked]);useEffect(function(){var timer=setTimeout(function(){if(!guestRegistrationEditMode){return;}var scrollToElement;if(guestRegistrationEditMode===ADDRESS_TYPE_SHIPPING){if(isShippingFormVisible){scrollToElement=ELEMENT_ID_SHIPPING_CONTACT;}else{scrollToElement=ELEMENT_ID_SHIPPING_CONTACT_TOGGLE;}}else if(guestRegistrationEditMode===ADDRESS_TYPE_PICKUP){scrollToElement=ELEMENT_ID_PICKUP_CONTACT;}if(scrollToElement){scrollTo("#".concat(scrollToElement));}},500);return function(){return clearTimeout(timer);};/* eslint-disable react-hooks/exhaustive-deps */},[]);/* eslint-enable react-hooks/exhaustive-deps */var value=useMemo(function(){return{isShippingFormEnabled:isShippingFormEnabled,isShippingFormVisible:isShippingFormVisible,setIsShippingFormVisible:setIsShippingFormVisible,orderReserveOnly:orderReserveOnly,orderNeedsPayment:orderNeedsPayment,guestRegistrationEditMode:guestRegistrationEditMode,defaultBillingFormState:defaultBillingFormState,updateBillingForm:billingFormState.setValues,defaultShippingFormState:defaultShippingFormState,updateShippingForm:shippingFormState.setValues,defaultPickupFormState:defaultPickupFormState,updatePickupForm:pickupFormState.setValues,defaultExtraFormState:defaultExtraFormState,updateExtraForm:extraFormState.setValues,billingFormValidationErrors:convertValidationErrors(billingFormState.validationErrors||billingFormRequestErrors||{}),shippingFormValidationErrors:convertValidationErrors(shippingFormState.validationErrors||shippingFormRequestErrors||{}),pickupFormValidationErrors:convertValidationErrors(pickupFormState.validationErrors||pickupFormRequestErrors||{}),extraFormValidationErrors:convertValidationErrors(extraFormState.validationErrors||extraFormRequestErrors||{}),isShippingAddressSelectionEnabled:isShippingAddressSelectionEnabled,isPickupContactSelectionEnabled:isPickupContactSelectionEnabled,customerAttributes:customerAttributes,numberOfAddressLines:numberOfAddressLines,userLocation:userLocation,supportedCountries:shopSettings.supportedCountries,isLocked:isLocked,handleSubmit:handleSubmit,/**
|
|
18
|
+
* Handling of registrationMode "simple" is not implemented for checkout. But since
|
|
19
|
+
* the guest registration is actually an order update and not a real registration, we
|
|
20
|
+
* hardcode the registration mode here, since the provider value will be used inside
|
|
21
|
+
* the shared form components.
|
|
22
|
+
*/registrationMode:SHOP_SETTING_REGISTRATION_MODE_EXTENDED,isBillingAddressSelectionEnabled:true};},[isShippingFormEnabled,isShippingFormVisible,defaultBillingFormState,billingFormState.setValues,billingFormState.validationErrors,defaultShippingFormState,shippingFormState.setValues,shippingFormState.validationErrors,defaultExtraFormState,extraFormState.setValues,extraFormState.validationErrors,extraFormRequestErrors,defaultPickupFormState,pickupFormState.setValues,pickupFormState.validationErrors,billingFormRequestErrors,shippingFormRequestErrors,pickupFormRequestErrors,orderReserveOnly,orderNeedsPayment,guestRegistrationEditMode,isShippingAddressSelectionEnabled,isPickupContactSelectionEnabled,customerAttributes,numberOfAddressLines,userLocation,shopSettings.supportedCountries,isLocked,handleSubmit]);if(!isDataReady||!isInitialized){return null;}return React.createElement(Context.Provider,{value:value},children);};GuestRegistrationProvider.defaultProps={children:null,customer:null,formContainerRef:null,billingAddress:null,shippingAddress:null,pickupAddress:null,billingPickupEquals:true,billingShippingEquals:true,cartHasDirectShipItems:false,orderReserveOnly:false,orderNeedsPayment:false,numberOfAddressLines:null,isShippingAddressSelectionEnabled:false,isPickupContactSelectionEnabled:false};export default connect(GuestRegistrationProvider);
|
|
@@ -1,7 +1,8 @@
|
|
|
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 _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;}function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}import{EVALIDATION}from'@shopgate/engage/core';import{extractAttributes}from'@shopgate/engage/account/helper/form';import{getMerchantCustomerAttributes}from'@shopgate/engage/core/selectors/merchantSettings';import{submitRegistration as submit}from"../actions"
|
|
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 _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;}function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}import{EVALIDATION,getRegistrationMode,SHOP_SETTING_REGISTRATION_MODE_SIMPLE}from'@shopgate/engage/core';import{extractAttributes,convertPipelineValidationErrors}from'@shopgate/engage/account/helper/form';import{getMerchantCustomerAttributes}from'@shopgate/engage/core/selectors/merchantSettings';import{submitRegistration as submit}from"../actions";/**
|
|
2
2
|
* Submits registration form data.
|
|
3
3
|
* @param {Object} baseFormData Data from the base form
|
|
4
4
|
* @param {Object} shippingFormData Data from the shipping form
|
|
5
5
|
* @param {Object} additionalData Additional data for the request.
|
|
6
6
|
* @returns {Function}
|
|
7
|
-
*/export var submitRegistration=function submitRegistration(_ref){var baseFormData=_ref.baseFormData,billingFormData=_ref.billingFormData,shippingFormData=_ref.shippingFormData,additionalFormData=_ref.additionalFormData;return(/*#__PURE__*/function(){var _ref2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(dispatch,getState){var customerAttributes,marketingOptIn,attributeData,attributes,emailAddress,password,firstName,lastName,customer,errors,code,validationErrors,converted,_converted$validation2,_converted$validation3,_converted$validation4,_converted$validation5,_converted$validation,errEmailAddress,errPassword,billing,shipping;return _regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:customerAttributes=getMerchantCustomerAttributes(getState());marketingOptIn=additionalFormData.marketingOptIn,attributeData=_objectWithoutProperties(additionalFormData,["marketingOptIn"]);attributes=extractAttributes(customerAttributes,attributeData);emailAddress=baseFormData.emailAddress,password=baseFormData.password;firstName=billingFormData.firstName
|
|
7
|
+
*/export var submitRegistration=function submitRegistration(_ref){var baseFormData=_ref.baseFormData,billingFormData=_ref.billingFormData,shippingFormData=_ref.shippingFormData,additionalFormData=_ref.additionalFormData;return(/*#__PURE__*/function(){var _ref2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(dispatch,getState){var customerAttributes,registrationMode,marketingOptIn,attributeData,attributes,emailAddress,password,firstName,lastName,customer,errors,code,validationErrors,converted,_converted$validation2,_converted$validation3,_converted$validation4,_converted$validation5,_converted$validation6,_converted$validation,errEmailAddress,errPassword,billing,shipping,extra;return _regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:customerAttributes=getMerchantCustomerAttributes(getState());registrationMode=getRegistrationMode(getState());marketingOptIn=additionalFormData.marketingOptIn,attributeData=_objectWithoutProperties(additionalFormData,["marketingOptIn"]);attributes=extractAttributes(customerAttributes,attributeData);emailAddress=baseFormData.emailAddress,password=baseFormData.password;if(registrationMode===SHOP_SETTING_REGISTRATION_MODE_SIMPLE){firstName=baseFormData.firstName;lastName=baseFormData.lastName;}else{firstName=billingFormData.firstName;lastName=billingFormData.lastName;}customer={firstName:firstName,lastName:lastName,emailAddress:emailAddress,password:password,attributes:attributes,settings:{marketingOptIn:marketingOptIn}};if(registrationMode!==SHOP_SETTING_REGISTRATION_MODE_SIMPLE){// No contacts creation at "simple" registration mode
|
|
8
|
+
customer.contacts=[_extends({},billingFormData,{emailAddress:emailAddress,isDefaultBilling:true,isDefaultShipping:!shippingFormData})].concat(shippingFormData?[_extends({},shippingFormData,{emailAddress:emailAddress,isDefaultBilling:false,isDefaultShipping:true})]:[]);}_context.prev=8;_context.next=11;return dispatch(submit(customer));case 11:_context.next=18;break;case 13:_context.prev=13;_context.t0=_context["catch"](8);code=_context.t0.code;validationErrors=_context.t0.errors;if(code===EVALIDATION){errors=validationErrors;}case 18:converted=convertPipelineValidationErrors(errors,attributes);if(!((converted===null||converted===void 0?void 0:converted.validation)&&Object.keys(converted.validation).length>0)){_context.next=25;break;}_converted$validation=converted.validation,errEmailAddress=_converted$validation.emailAddress,errPassword=_converted$validation.password;billing=(converted===null||converted===void 0?void 0:(_converted$validation2=converted.validation)===null||_converted$validation2===void 0?void 0:(_converted$validation3=_converted$validation2.contacts)===null||_converted$validation3===void 0?void 0:_converted$validation3['0'])||{};shipping=(converted===null||converted===void 0?void 0:(_converted$validation4=converted.validation)===null||_converted$validation4===void 0?void 0:(_converted$validation5=_converted$validation4.contacts)===null||_converted$validation5===void 0?void 0:_converted$validation5['1'])||{};extra=(converted===null||converted===void 0?void 0:(_converted$validation6=converted.validation)===null||_converted$validation6===void 0?void 0:_converted$validation6.attributes)||{};return _context.abrupt("return",{errors:{baseFormData:_extends({},errEmailAddress?{emailAddress:errEmailAddress}:{},{},errPassword?{password:errPassword}:{}),billingFormData:_extends({},billing),shippingFormData:_extends({},shipping),extraFormData:_extends({},extra)}});case 25:return _context.abrupt("return",null);case 26:case"end":return _context.stop();}}},_callee,null,[[8,13]]);}));return function(_x,_x2){return _ref2.apply(this,arguments);};}());};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{connect}from'react-redux';import{getShopSettings,getConfigFetching}from'@shopgate/engage/core/config';import{getNumberOfAddressLines}from'@shopgate/engage/core';import{hasDirectShipItems}from'@shopgate/engage/cart';import{getPreferredLocationAddress}from'@shopgate/engage/locations/selectors';import{getMerchantCustomerAttributes}from'@shopgate/engage/core/selectors/merchantSettings';import{submitRegistration}from"./RegistrationProvider.actions";/**
|
|
1
|
+
import{connect}from'react-redux';import{getShopSettings,getConfigFetching}from'@shopgate/engage/core/config';import{getNumberOfAddressLines,getRegistrationMode}from'@shopgate/engage/core';import{hasDirectShipItems}from'@shopgate/engage/cart';import{getPreferredLocationAddress}from'@shopgate/engage/locations/selectors';import{getMerchantCustomerAttributes}from'@shopgate/engage/core/selectors/merchantSettings';import{submitRegistration}from"./RegistrationProvider.actions";/**
|
|
2
2
|
* @returns {Function}
|
|
3
3
|
*/function makeMapStateToProps(){/**
|
|
4
4
|
* @param {Object} state The application state.
|
|
5
5
|
* @returns {Object}
|
|
6
|
-
*/return function(state){return{isDataReady:!getConfigFetching(state),shopSettings:getShopSettings(state),userLocation:getPreferredLocationAddress(state),customerAttributes:getMerchantCustomerAttributes(state),cartHasDirectShipItems:hasDirectShipItems(state),numberOfAddressLines:getNumberOfAddressLines(state)};};}var mapDispatchToProps={submitRegistration:submitRegistration};export default connect(makeMapStateToProps,mapDispatchToProps);
|
|
6
|
+
*/return function(state){return{isDataReady:!getConfigFetching(state),shopSettings:getShopSettings(state),userLocation:getPreferredLocationAddress(state),customerAttributes:getMerchantCustomerAttributes(state),cartHasDirectShipItems:hasDirectShipItems(state),numberOfAddressLines:getNumberOfAddressLines(state),registrationMode:getRegistrationMode(state)};};}var mapDispatchToProps={submitRegistration:submitRegistration};export default connect(makeMapStateToProps,mapDispatchToProps);
|
|
@@ -1,6 +1,26 @@
|
|
|
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{
|
|
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{SHOP_SETTING_REGISTRATION_MODE_EXTENDED,SHOP_SETTING_REGISTRATION_MODE_SIMPLE}from'@shopgate/engage/core';import{generateFormConstraints}from'@shopgate/engage/account/helper/form';/**
|
|
2
|
+
* Helper to generate base constraints
|
|
3
|
+
* @param {Object} params Options for the helper
|
|
4
|
+
* @param {string} params.registrationMode Current active registration mode
|
|
2
5
|
* @returns {Object}
|
|
3
|
-
*/export var generateBaseConstraints=function generateBaseConstraints(){
|
|
6
|
+
*/export var generateBaseConstraints=function generateBaseConstraints(_ref){var _ref$registrationMode=_ref.registrationMode,registrationMode=_ref$registrationMode===void 0?SHOP_SETTING_REGISTRATION_MODE_EXTENDED:_ref$registrationMode;return _extends({},registrationMode===SHOP_SETTING_REGISTRATION_MODE_SIMPLE?{firstName:{presence:{message:'validation.required',allowEmpty:false}},lastName:{presence:{message:'validation.required',allowEmpty:false}}}:null,{emailAddress:{presence:{message:'validation.required',allowEmpty:false},email:{message:'validation.email'}},password:{presence:{message:'validation.required',allowEmpty:false}},passwordConfirm:{presence:{message:'validation.required',allowEmpty:false},equality:{attribute:'password',message:'validation.passwordMismatch',comparator:function comparator(v1,v2){return JSON.stringify(v1)===JSON.stringify(v2);}}}});};/**
|
|
7
|
+
* Helper to generate address constraints
|
|
8
|
+
* @param {Object} params Options for the helper
|
|
9
|
+
* @param {string} params.registrationMode Current active registration mode
|
|
10
|
+
* @returns {Object}
|
|
11
|
+
*/var generateAddressConstraints=function generateAddressConstraints(_ref2){var _ref2$registrationMod=_ref2.registrationMode,registrationMode=_ref2$registrationMod===void 0?SHOP_SETTING_REGISTRATION_MODE_EXTENDED:_ref2$registrationMod;return _extends({},registrationMode===SHOP_SETTING_REGISTRATION_MODE_EXTENDED?{firstName:{presence:{message:'validation.required',allowEmpty:false}},lastName:{presence:{message:'validation.required',allowEmpty:false}},address1:{presence:{message:'validation.required',allowEmpty:false}},city:{presence:{message:'validation.required',allowEmpty:false}},country:{presence:{message:'validation.required',allowEmpty:false}},postalCode:{presence:{message:'validation.required',allowEmpty:false}},mobile:{presence:{message:'validation.required',allowEmpty:false},format:{pattern:'^[+0-9]+',message:'validation.mobileNumber'}}}:null);};/**
|
|
12
|
+
* Helper to generate billing form constraints
|
|
13
|
+
* @param {Object} params Options for the helper
|
|
14
|
+
* @param {string} [params.registrationMode] Current active registration mode
|
|
15
|
+
* @returns {Object}
|
|
16
|
+
*/export var generateBillingConstraints=function generateBillingConstraints(_ref3){var _ref3$registrationMod=_ref3.registrationMode,registrationMode=_ref3$registrationMod===void 0?SHOP_SETTING_REGISTRATION_MODE_EXTENDED:_ref3$registrationMod;return generateAddressConstraints({registrationMode:registrationMode});};/**
|
|
17
|
+
* Helper to generate shipping form constraints
|
|
18
|
+
* @param {Object} params Options for the helper
|
|
19
|
+
* @param {string} [params.registrationMode] Current active registration mode
|
|
20
|
+
* @returns {Object}
|
|
21
|
+
*/export var generateShippingConstraints=function generateShippingConstraints(_ref4){var _ref4$registrationMod=_ref4.registrationMode,registrationMode=_ref4$registrationMod===void 0?SHOP_SETTING_REGISTRATION_MODE_EXTENDED:_ref4$registrationMod;return registrationMode===SHOP_SETTING_REGISTRATION_MODE_EXTENDED// Only at "extended" mode there will be constraints for the shipping form since "simple" has no
|
|
22
|
+
// shipping form.
|
|
23
|
+
?generateAddressConstraints({registrationMode:registrationMode}):{};};/**
|
|
4
24
|
* Generates constraints for the "extra" form.
|
|
5
25
|
* @param {Object} customerAttributes Customer attributes.
|
|
6
26
|
* @returns {Object}
|
|
@@ -1,17 +1,17 @@
|
|
|
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}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,
|
|
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};/**
|
|
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
|
* @returns {JSX}
|
|
8
|
-
*/var RegistrationProvider=function RegistrationProvider(_ref){var isDataReady=_ref.isDataReady,cartHasDirectShipItems=_ref.cartHasDirectShipItems,shopSettings=_ref.shopSettings,userLocation=_ref.userLocation,customerAttributes=_ref.customerAttributes,numberOfAddressLines=_ref.numberOfAddressLines,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(
|
|
9
|
-
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();},[]);var extraConstraints=useMemo(function(){return generateExtraConstraints(customerAttributes);},[customerAttributes]);// Default form states
|
|
8
|
+
*/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
|
+
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
10
|
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
|
|
11
11
|
var handleBaseFormSubmit=useCallback(function(){setIsBaseFormSubmitted(true);},[setIsBaseFormSubmitted]);var handleBillingFormSubmit=useCallback(function(){setIsBillingFormSubmitted(true);},[setIsBillingFormSubmitted]);var handleShippingFormSubmit=useCallback(function(){setIsShippingFormSubmitted(true);},[setIsShippingFormSubmitted]);var handleExtraFormSubmit=useCallback(function(){setIsExtraFormSubmitted(true);},[]);// Form states
|
|
12
12
|
var baseFormState=useFormState(defaultBaseFormState,handleBaseFormSubmit,baseConstraints,formContainerRef);var billingFormState=useFormState(defaultBillingFormState,handleBillingFormSubmit,billingConstraints,formContainerRef);var shippingFormState=useFormState(defaultShippingFormState,handleShippingFormSubmit,shippingConstraints,formContainerRef);var extraFormState=useFormState(defaultExtraFormState,handleExtraFormSubmit,extraConstraints,formContainerRef);// Central submit handler
|
|
13
13
|
var handleSubmit=useCallback(function(){baseFormState.handleSubmit(new Event('submit'));billingFormState.handleSubmit(new Event('submit'));shippingFormState.handleSubmit(new Event('submit'));extraFormState.handleSubmit(new Event('submit'));},[baseFormState,billingFormState,extraFormState,shippingFormState]);useEffect(function(){// Break the process when the forms are not submitted yet
|
|
14
14
|
if(!isBaseFormSubmitted||!isBillingFormSubmitted||!isShippingFormSubmitted||!isExtraFormSubmitted){return;}// Break the process when one of the forms has validation errors from the constraints
|
|
15
15
|
if(!baseFormState.valid||!billingFormState.valid||isShippingFormVisible&&!shippingFormState.valid||!extraFormState.valid){setIsBaseFormSubmitted(false);setIsBillingFormSubmitted(false);setIsShippingFormSubmitted(false);setIsExtraFormSubmitted(false);return;}/** Async wrapper for submit registration */var fn=/*#__PURE__*/function(){var _ref2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(){var response,_ref3,errors;return _regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:setLocked(true);_context.next=3;return submitRegistration(_extends({baseFormData:baseFormState.values,billingFormData:billingFormState.values,additionalFormData:extraFormState.values},isShippingFormVisible?{shippingFormData:shippingFormState.values}:{}));case 3:response=_context.sent;_ref3=response||{},errors=_ref3.errors;// Updated the request validation errors
|
|
16
|
-
setBaseFormRequestErrors((errors===null||errors===void 0?void 0:errors.baseFormData)||null);setBillingFormRequestErrors((errors===null||errors===void 0?void 0:errors.billingFormData)||null);setShippingFormRequestErrors((errors===null||errors===void 0?void 0:errors.shippingFormData)||null);// Release forms for additional submits
|
|
17
|
-
setIsBaseFormSubmitted(false);setIsBillingFormSubmitted(false);setIsShippingFormSubmitted(false);setIsExtraFormSubmitted(false);setLocked(false);case
|
|
16
|
+
setBaseFormRequestErrors((errors===null||errors===void 0?void 0:errors.baseFormData)||null);setBillingFormRequestErrors((errors===null||errors===void 0?void 0:errors.billingFormData)||null);setShippingFormRequestErrors((errors===null||errors===void 0?void 0:errors.shippingFormData)||null);setExtraFormRequestErrors((errors===null||errors===void 0?void 0:errors.extraFormData)||null);// Release forms for additional submits
|
|
17
|
+
setIsBaseFormSubmitted(false);setIsBillingFormSubmitted(false);setIsShippingFormSubmitted(false);setIsExtraFormSubmitted(false);setLocked(false);case 14:case"end":return _context.stop();}}},_callee);}));return function fn(){return _ref2.apply(this,arguments);};}();fn();/* eslint-disable react-hooks/exhaustive-deps */},[isBaseFormSubmitted,isBillingFormSubmitted,isShippingFormSubmitted,isExtraFormSubmitted,baseFormState.valid,billingFormState.valid,shippingFormState.valid,extraFormState.valid,isShippingFormVisible,submitRegistration]);/* eslint-enable react-hooks/exhaustive-deps */ /* eslint-disable react-hooks/exhaustive-deps */useEffect(function(){baseFormState.scrollToError();},[baseFormRequestErrors,billingFormRequestErrors,shippingFormRequestErrors,baseFormState.scrollToError]);/* eslint-enable react-hooks/exhaustive-deps */ /* eslint-disable react-hooks/exhaustive-deps */useEffect(function(){shippingFormState.setIgnoreErrors(!isShippingFormVisible);},[isShippingFormVisible]);/* eslint-enable react-hooks/exhaustive-deps */useEffect(function(){if(isLocked){LoadingProvider.setLoading(REGISTER_PATH);return;}LoadingProvider.unsetLoading(REGISTER_PATH);},[isLocked]);var value=useMemo(function(){return{supportedCountries:shopSettings.supportedCountries||[],customerAttributes:customerAttributes,userLocation:userLocation,defaultBaseFormState:defaultBaseFormState,defaultBillingFormState:defaultBillingFormState,defaultShippingFormState:defaultShippingFormState,defaultExtraFormState:defaultExtraFormState,baseFormValidationErrors:convertValidationErrors(baseFormState.validationErrors||baseFormRequestErrors||{}),billingFormValidationErrors:convertValidationErrors(billingFormState.validationErrors||billingFormRequestErrors||{}),shippingFormValidationErrors:convertValidationErrors(shippingFormState.validationErrors||shippingFormRequestErrors||{}),extraFormValidationErrors:convertValidationErrors(extraFormState.validationErrors||extraFormRequestErrors||{}),handleSubmit:handleSubmit,updateBaseForm:baseFormState.setValues,updateBillingForm:billingFormState.setValues,updateShippingForm:shippingFormState.setValues,updateExtraForm:extraFormState.setValues,isShippingAddressSelectionEnabled:isShippingAddressSelectionEnabled,isBillingAddressSelectionEnabled:isBillingAddressSelectionEnabled,isShippingFormVisible:isShippingFormVisible,setIsShippingFormVisible:setIsShippingFormVisible,numberOfAddressLines:numberOfAddressLines,registrationMode:registrationMode};},[shopSettings.supportedCountries,customerAttributes,userLocation,defaultBaseFormState,defaultBillingFormState,defaultShippingFormState,baseFormState.validationErrors,baseFormState.setValues,baseFormRequestErrors,billingFormState.validationErrors,billingFormState.setValues,billingFormRequestErrors,shippingFormState.validationErrors,shippingFormState.setValues,shippingFormRequestErrors,handleSubmit,defaultExtraFormState,extraFormState.setValues,extraFormState.validationErrors,extraFormRequestErrors,isShippingAddressSelectionEnabled,isBillingAddressSelectionEnabled,isShippingFormVisible,setIsShippingFormVisible,numberOfAddressLines,registrationMode]);if(!isDataReady){return null;}return React.createElement(Context.Provider,{value:value},children);};RegistrationProvider.defaultProps={formContainerRef:null,cartHasDirectShipItems:false,numberOfAddressLines:null};export default connect(RegistrationProvider);
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import{i18n}from'@shopgate/engage/core';/**
|
|
2
|
-
* Generates form configuration.
|
|
3
|
-
* @param {Array} supportedCountries A list of supported countries.
|
|
4
|
-
* @param {Object} userLocation User location for better phone picker defaults.
|
|
5
|
-
* @returns {Object}
|
|
6
|
-
*/var generateFormConfig=function generateFormConfig(supportedCountries,userLocation){return{fields:{firstName:{type:'text',label:"".concat(i18n.text('checkout.pickup_contact.form.firstName')," *")},lastName:{type:'text',label:"".concat(i18n.text('checkout.pickup_contact.form.lastName')," *")},company:{type:'text',label:i18n.text('checkout.pickup_contact.form.company')},address1:{type:'text',label:"".concat(i18n.text('checkout.pickup_contact.form.address1')," *")},address2:{type:'text',label:i18n.text('checkout.pickup_contact.form.address2')},city:{type:'text',label:"".concat(i18n.text('checkout.pickup_contact.form.city')," *")},region:{type:'province',label:"".concat(i18n.text('checkout.pickup_contact.form.region')," *"),required:true},country:{type:'country',label:"".concat(i18n.text('checkout.pickup_contact.form.country')," *"),countries:supportedCountries},postalCode:{type:'text',label:"".concat(i18n.text('checkout.pickup_contact.form.postalCode')," *")},mobile:{type:'phone_picker',label:"".concat(i18n.text('checkout.pickup_contact.form.mobile')," *"),config:{supportedCountries:supportedCountries,userLocation:userLocation}}}};};export default generateFormConfig;
|
|
@@ -1,2 +0,0 @@
|
|
|
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{css}from'glamor';import{themeConfig}from'@shopgate/pwa-common/helpers/config';import{isIOSTheme}from'@shopgate/engage/core';import{StylePresets}from'@shopgate/engage/components/Form';var variables=themeConfig.variables;export var container=css({padding:"".concat(variables.gap.big,"px ").concat(variables.gap.big,"px 0"),display:'flex',flex:'0 0 auto',flexDirection:'column','@media(min-width: 768px)':{flexDirection:'row-reverse','> :not(:first-child)':{marginRight:variables.gap.big}}});export var containerItem=css({flexGrow:1,flexShrink:0,'@media(min-width: 768px)':{width:"calc(50% - ".concat(variables.gap.big,"px)")}});export var form=css(_extends({},StylePresets.OUTLINED_FORM_FIELDS,{' .registrationOptInMarketingOptIn':_extends({' .checkbox':_extends({},isIOSTheme()?{paddingBottom:0}:{})},!isIOSTheme()?{paddingTop:0,paddingBottom:variables.gap.big}:{})}));export var section=css({// marginBottom: variables.gap.big * 1.5,
|
|
2
|
-
}).toString();export var shippingFormSection=css({paddingBottom:32}).toString();export var hidden=css({display:'none'}).toString();export var submitButtonContainer=css({margin:"0 ".concat(variables.gap.big,"px ").concat(variables.gap.big,"px"),'@media(min-width: 768px)':{width:"calc(50% - ".concat(variables.gap.big,"px)")}});export var submitButton=css({width:'100%'}).toString();
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import setWith from'lodash/setWith';import{i18n}from'@shopgate/engage/core';/**
|
|
2
|
-
* Converts validation errors from the shopgate.user.register pipeline
|
|
3
|
-
* @param {Array} errors The errors
|
|
4
|
-
* @returns {Object|null}
|
|
5
|
-
*/export var convertSubmitRegistrationValidationErrors=function convertSubmitRegistrationValidationErrors(errors){if(!Array.isArray(errors)||errors.length===0){return null;}var converted=errors.reduce(function(result,error){var _error$path=error.path,path=_error$path===void 0?[]:_error$path,code=error.code;var _error$subentityPath=error.subentityPath,subentityPath=_error$subentityPath===void 0?[]:_error$subentityPath;var message=error.message;if(path.length===0&&subentityPath.length===0){result.general.push(error);return result;}if(path.length>0){message=i18n.text('validation.checkField');setWith(result.validation,path.slice(2).join('.'),message,Object);}else if(subentityPath.length>0){var field=subentityPath[subentityPath.length-1];if(code===409&&field==='emailAddress'){message=i18n.text('validation.emailConflict');}else{message=i18n.text('validation.checkField');}setWith(result.validation,subentityPath.join('.'),message,Object);}return result;},{validation:{},general:[]});return converted;};
|