@shopgate/engage 7.12.7-beta.1 → 7.20.0-beta.10
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/a11y/components/Section/index.js +2 -2
- package/a11y/components/VisuallyHidden/index.js +8 -0
- package/a11y/components/index.js +1 -0
- package/a11y/constants/index.js +1 -0
- package/a11y/helpers/index.js +1 -0
- package/a11y/index.js +1 -4
- package/account/actions/addContacts.js +2 -2
- package/account/actions/deleteContact.js +2 -2
- package/account/actions/deleteCustomer.js +2 -2
- package/account/actions/fetchContacts.js +2 -2
- package/account/actions/fetchCustomer.js +2 -2
- package/account/actions/updateContact.js +2 -2
- package/account/actions/updateCustomer.js +2 -2
- package/account/components/Account/Account.js +1 -1
- package/account/components/Account/Account.style.js +1 -1
- package/account/components/Profile/Profile.provider.js +3 -3
- package/account/components/ProfileContact/ProfileContact.js +1 -1
- package/account/reducers/index.js +1 -1
- package/app-rating/action-creators/appStart.js +3 -3
- package/app-rating/action-creators/ordersPlaced.js +3 -3
- package/app-rating/action-creators/popup.js +4 -4
- package/app-rating/action-creators/timer.js +3 -3
- package/app-rating/actions/showModal.js +6 -6
- package/app-rating/constants/index.js +2 -2
- package/app-rating/reducers/index.js +2 -2
- package/app-rating/subscriptions/index.js +4 -4
- package/back-in-stock/actions/index.js +14 -0
- package/back-in-stock/components/BackInStockButton/connector.js +1 -0
- package/back-in-stock/components/BackInStockButton/index.js +14 -0
- package/back-in-stock/components/BackInStockButton/style.js +1 -0
- package/back-in-stock/components/CharacteristicsButton/connector.js +3 -0
- package/back-in-stock/components/CharacteristicsButton/index.js +8 -0
- package/back-in-stock/components/ProductInfoBackInStockButton/connector.js +3 -0
- package/back-in-stock/components/ProductInfoBackInStockButton/index.js +10 -0
- package/back-in-stock/components/Subscriptions/components/List/index.js +4 -0
- package/back-in-stock/components/Subscriptions/components/Subscription/index.js +7 -0
- package/back-in-stock/components/Subscriptions/index.js +4 -0
- package/back-in-stock/components/index.js +1 -0
- package/back-in-stock/constants/Actions.js +1 -0
- package/back-in-stock/constants/Common.js +1 -0
- package/back-in-stock/constants/Pipelines.js +1 -0
- package/back-in-stock/constants/Portals.js +9 -0
- package/back-in-stock/constants/index.js +1 -0
- package/back-in-stock/hooks/index.js +4 -0
- package/back-in-stock/providers/BackInStockSubscriptionsProvider.connector.js +7 -0
- package/back-in-stock/providers/BackInStockSubscriptionsProvider.js +5 -0
- package/back-in-stock/providers/index.js +1 -0
- package/back-in-stock/reducers/index.js +5 -0
- package/back-in-stock/selectors/index.js +43 -0
- package/back-in-stock/streams/index.js +1 -0
- package/back-in-stock/subscriptions/index.js +11 -0
- package/cart/cart.helpers.js +9 -2
- package/cart/components/CartItem/CartItemCoupon.js +10 -6
- package/cart/components/CartItem/CartItemCouponCode.js +2 -2
- package/cart/components/CartItem/CartItemCouponDelete.js +1 -1
- package/cart/components/CartItem/CartItemCouponFreeShipping.js +1 -1
- package/cart/components/CartItem/CartItemCouponIcon.js +2 -2
- package/cart/components/CartItem/CartItemCouponLayout.style.js +5 -1
- package/cart/components/CartItem/CartItemCouponTitle.js +2 -2
- package/cart/components/CartItem/CartItemProductLayout.js +4 -2
- package/cart/components/CartItem/CartItemProductLayoutWide.style.js +1 -1
- package/cart/components/CartItem/CartItemProductTitle.js +2 -2
- package/cart/components/CartItem/CartItemQuantityPicker.js +26 -14
- package/cart/components/CartItem/CartItemSubstitution.js +1 -1
- package/cart/components/CartItems/CartItemCardReservation.js +1 -1
- package/cart/components/CartItems/CartItemGroupReservation.js +1 -1
- package/cart/components/CartSummaryWide/CartSummaryWideCheckoutButton.style.js +1 -1
- package/cart/components/PaymentBar/PaymentBar.js +1 -1
- package/cart/components/PaymentBar/PaymentBarCheckoutButton.style.js +1 -1
- package/cart/components/PaymentBar/PaymentBarPromotionCouponMessages.js +1 -1
- package/cart/index.js +3 -2
- package/cart/streams/index.js +1 -0
- package/category/actions/index.js +1 -0
- package/category/components/CategoryList/index.js +7 -0
- package/category/components/CategoryList/style.js +1 -0
- package/category/components/index.js +1 -1
- package/category/constants/index.js +1 -0
- package/category/helpers/index.js +1 -0
- package/category/index.js +1 -6
- package/category/selectors/index.js +2 -0
- package/category/streams/index.js +1 -1
- package/checkout/actions/errorCheckout.js +1 -1
- package/checkout/actions/fetchCheckoutOrder.js +1 -1
- package/checkout/actions/fetchPaymentMethods.js +1 -1
- package/checkout/actions/initializeCheckout.js +1 -1
- package/checkout/actions/prepareCheckout.js +2 -2
- package/checkout/actions/submitCheckoutOrder.js +1 -1
- package/checkout/actions/updateCheckoutOrder.js +1 -1
- package/checkout/components/Checkout/CheckoutPickupContactForm.config.js +1 -1
- package/checkout/components/Checkout/CheckoutSectionMessages.js +1 -1
- package/checkout/components/CheckoutConfirmation/CheckoutConfirmation.js +1 -1
- package/checkout/components/CheckoutConfirmation/CheckoutConfirmationBilledTo.js +1 -1
- package/checkout/components/GuestCheckout/GuestCheckoutPickupNotes.config.js +1 -1
- package/checkout/components/PaymentMethodButton/PaymentMethodButton.js +1 -1
- package/checkout/components/ShippingMethods/ShippingMethods.js +4 -4
- package/checkout/components/index.js +1 -1
- package/checkout/constants/index.js +1 -1
- package/checkout/index.js +3 -4
- package/checkout/paymentMethods/index.js +2 -2
- package/checkout/paymentMethods/paypal/PaypalButtonApp.js +1 -1
- package/checkout/paymentMethods/paypal/PaypalButtonWeb.js +1 -1
- package/checkout/paymentMethods/paypal/PaypalPayButton.js +1 -1
- package/checkout/paymentMethods/paypal/PaypalProvider.js +1 -1
- package/checkout/paymentMethods/stripe/StripeButton.js +2 -2
- package/checkout/paymentMethods/stripe/StripeCreditCard.js +3 -3
- package/checkout/paymentMethods/stripe/StripeProvider.js +8 -8
- package/checkout/paymentMethods/stripe/sdk.js +3 -2
- package/checkout/providers/AddressBookProvider.js +1 -1
- package/checkout/providers/CheckoutProvider.js +8 -8
- package/components/ChipLayout/index.js +38 -0
- package/components/ChipLayout/spec.js +5 -0
- package/components/ChipLayout/style.js +5 -0
- package/components/ConditionalWrapper/ConditionalWrapper.js +7 -2
- package/components/Footer/Footer.js +7 -7
- package/components/Form/Builder/Builder.js +50 -29
- package/components/Form/Builder/ElementCheckbox.js +1 -1
- package/components/Form/Builder/ElementMultiSelect.js +1 -1
- package/components/Form/Builder/ElementPhoneNumber.js +3 -3
- package/components/Form/Builder/ElementRadio.js +1 -1
- package/components/Form/Builder/ElementSelect.js +1 -1
- package/components/Form/Builder/ElementText.js +3 -3
- package/components/Form/Builder/classes/ActionListener.constants.js +2 -2
- package/components/Form/Builder/classes/ActionListener.js +73 -16
- package/components/Form/Builder/helpers/buildFormElements.js +2 -2
- package/components/Form/Form.js +8 -5
- package/components/IntersectionVisibility/index.js +14 -7
- package/components/Logo/connector.js +4 -0
- package/components/Logo/index.js +4 -0
- package/components/Logo/spec.js +1 -0
- package/components/Logo/style.js +1 -0
- package/components/Menu/components/Position/index.js +5 -5
- package/components/Menu/index.js +9 -9
- package/components/MessageBar/MessageBar.js +1 -1
- package/components/MessageBar/index.js +1 -1
- package/components/NavigationHandler/index.js +4 -4
- package/components/NavigationHandler/spec.js +1 -1
- package/components/Picker/components/Button/index.js +1 -1
- package/components/Picker/components/List/index.js +2 -2
- package/components/Picker/components/Modal/index.js +7 -7
- package/components/Picker/index.js +18 -9
- package/components/PickerUtilize/components/Button/index.js +5 -0
- package/components/PickerUtilize/components/Button/style.js +1 -0
- package/components/PickerUtilize/index.js +17 -0
- package/components/PickerUtilize/spec.js +1 -0
- package/components/PickerUtilize/style.js +1 -0
- package/components/QuantityInput/QuantityInput.js +5 -4
- package/components/Radio/Radio.js +1 -1
- package/components/RadioCard/RadioCard.js +1 -1
- package/components/RangeSlider/components/Handle/index.js +1 -1
- package/components/RangeSlider/index.js +36 -24
- package/components/ResponsiveContainer/ResponsiveContainer.js +2 -6
- package/components/ResponsiveContainer/breakpoints.js +2 -1
- package/components/ResponsiveContainer/hooks.js +20 -0
- package/components/ScrollHeader/index.js +2 -2
- package/components/ScrollHeader/style.js +1 -1
- package/components/SheetList/components/Item/index.js +5 -5
- package/components/SheetList/index.js +4 -4
- package/components/SideNavigation/SideNavigationCategories.connector.js +2 -2
- package/components/SnackBarContainer/index.js +5 -0
- package/components/Switch/index.js +12 -0
- package/components/Switch/style.js +1 -0
- package/components/Tabs/components/TabIndicator.js +2 -2
- package/components/Tabs/components/Tabs.js +1 -1
- package/components/TimeBoundary/index.js +8 -6
- package/components/VideoPlayer/index.js +9 -6
- package/components/View/components/Above/index.js +1 -1
- package/components/View/components/Below/index.js +1 -1
- package/components/View/components/Content/index.js +18 -11
- package/components/View/index.js +1 -1
- package/components/View/provider.js +22 -5
- package/components/index.js +2 -2
- package/core/action-creators/app.js +5 -0
- package/core/action-creators/appPermissions.js +9 -0
- package/core/action-creators/index.js +1 -1
- package/core/actions/getGeolocation.js +2 -2
- package/core/actions/grantAppTrackingTransparencyPermission.js +6 -0
- package/core/actions/grantCameraPermissions.js +1 -1
- package/core/actions/grantGeolocationPermissions.js +1 -1
- package/core/actions/grantPermissions.js +13 -6
- package/core/actions/grantPushPermissions.js +22 -0
- package/core/actions/index.js +7 -0
- package/core/actions/requestAppPermission.js +12 -0
- package/core/actions/requestAppPermissionStatus.js +12 -0
- package/core/classes/GeolocationRequest.js +2 -3
- package/core/classes/GeolocationRequestApp.js +6 -6
- package/core/classes/GeolocationRequestBrowser.js +2 -2
- package/core/classes/index.js +1 -0
- package/core/collections/AppInitialization.js +49 -0
- package/core/collections/index.js +1 -0
- package/core/commands/analyticsSetConsent.js +11 -0
- package/core/commands/index.js +1 -0
- package/core/config/ThemeConfigResolver.js +2 -2
- package/core/config/config.action-creators.js +1 -1
- package/core/config/config.actions.js +1 -1
- package/core/config/config.reducers.js +1 -1
- package/core/config/config.subscriptions.js +2 -2
- package/core/config/index.js +1 -1
- package/core/constants/actionTypes.js +1 -0
- package/core/constants/appFeatures.js +1 -0
- package/core/constants/index.js +6 -1
- package/core/contexts/index.js +1 -0
- package/core/helpers/appFeatures.js +15 -0
- package/core/helpers/appPermissions.js +43 -6
- package/core/helpers/baseUrl.js +14 -0
- package/core/helpers/environment.js +4 -0
- package/core/helpers/getFullImageSource.js +1 -1
- package/core/helpers/i18n.js +5 -3
- package/core/helpers/index.js +7 -0
- package/core/hocs/index.js +1 -0
- package/core/hocs/withCurrentProduct.js +6 -6
- package/core/hocs/withTheme.js +2 -2
- package/core/hooks/index.js +1 -0
- package/core/hooks/useAsyncMemo.js +1 -1
- package/core/hooks/useFormState.js +1 -1
- package/core/hooks/useScrollTo.js +1 -1
- package/core/hooks/useTheme.js +2 -2
- package/core/index.js +5 -52
- package/core/initialization/index.js +4 -2
- package/core/providers/AppProvider.js +10 -8
- package/core/providers/index.js +1 -0
- package/core/reducers/app.js +6 -0
- package/core/reducers/index.js +1 -1
- package/core/reducers/merchantSettings.js +1 -1
- package/core/reducers/shopSettings.js +1 -1
- package/core/selectors/app.js +9 -0
- package/core/selectors/index.js +6 -1
- package/core/streams/app.js +8 -0
- package/core/streams/appPermissions.js +19 -0
- package/core/streams/index.js +4 -0
- package/core/subscriptions/app.js +7 -0
- package/favorites/components/Item/Item.js +7 -7
- package/favorites/components/List/List.js +18 -7
- package/favorites/components/List/ListAccordionLabel.js +4 -0
- package/favorites/components/List/ListContent.js +8 -0
- package/favorites/components/List/ListItemWrapper.js +6 -0
- package/favorites/components/List/styles.js +1 -0
- package/favorites/components/Lists/Lists.js +5 -5
- package/favorites/components/Lists/ListsModal.js +3 -2
- package/favorites/constants/index.js +1 -0
- package/filter/actions/index.js +1 -0
- package/filter/components/PriceSlider/index.js +9 -9
- package/filter/components/PriceSlider/style.js +1 -3
- package/filter/components/index.js +1 -0
- package/filter/constants/index.js +1 -1
- package/filter/helpers/buildFilterParamsForFetchFiltersRequest.js +9 -0
- package/filter/helpers/buildInitialFilters.js +1 -1
- package/filter/helpers/buildUpdatedFilters.js +1 -1
- package/filter/helpers/index.js +1 -0
- package/filter/helpers/translateFilterLabel.js +6 -0
- package/filter/index.js +2 -7
- package/filter/providers/SortProvider.helpers.js +1 -1
- package/filter/selectors/index.js +1 -1
- package/filter/streams/index.js +1 -0
- package/i18n/locale/cs-cz/countries.json +255 -0
- package/i18n/locale/de-de/countries.json +26 -28
- package/i18n/locale/el-gr/countries.json +255 -0
- package/i18n/locale/en-us/countries.json +12 -14
- package/i18n/locale/es-es/countries.json +65 -67
- package/i18n/locale/fi-fi/countries.json +255 -0
- package/i18n/locale/fr-fr/countries.json +85 -87
- package/i18n/locale/hu-hu/countries.json +255 -0
- package/i18n/locale/it-it/countries.json +11 -13
- package/i18n/locale/nl-nl/countries.json +42 -44
- package/i18n/locale/pl-pl/countries.json +255 -0
- package/i18n/locale/pt-pt/countries.json +128 -130
- package/i18n/locale/ro-ro/countries.json +255 -0
- package/i18n/locale/sv-se/countries.json +255 -0
- package/locations/action-creators/receiveInventories.js +3 -5
- package/locations/actions/fetchFulfillmentSlots.js +1 -1
- package/locations/actions/fetchProductLocations.js +2 -2
- package/locations/actions/setUserGeolocation.js +1 -1
- package/locations/actions/setUserSearchGeolocation.js +1 -1
- package/locations/components/Cart/CartContextMenuChangeFulfillmentContent.js +1 -1
- package/locations/components/FulfillmentPath/FulfillmentPath.js +1 -1
- package/locations/components/FulfillmentPath/FulfillmentPathItem.js +2 -2
- package/locations/components/FulfillmentSelector/FulfillmentSelectorAddToCart.js +2 -2
- package/locations/components/FulfillmentSelector/FulfillmentSelectorAlternativeLocation.js +1 -1
- package/locations/components/FulfillmentSheet/FulfillmentSheet.js +2 -2
- package/locations/components/FulfillmentSlotSwitcher/FulfillmentSlotDialog.js +1 -1
- package/locations/components/ReserveForm/ReserveForm.js +1 -1
- package/locations/components/ReserveForm/ReserveFormPhone.js +1 -1
- package/locations/components/StockInfo/StockInfo.defaultSettings.js +1 -1
- package/locations/components/StoreFinder/StoreFinderMap.style.js +2 -2
- package/locations/components/StoreList/StoreListSearch.js +5 -3
- package/locations/locations.streams.js +1 -1
- package/locations/providers/FulfillmentProvider.js +4 -4
- package/locations/providers/StoreFinderProvider.js +1 -1
- package/locations/reducers/storage.js +3 -3
- package/locations/selectors/index.js +2 -2
- package/locations/subscriptions.js +13 -13
- package/login/components/ForgotPassword/ForgotPassword.js +1 -1
- package/orders/actions/cancelOrder.js +1 -1
- package/orders/actions/fetchOrderDetails.js +1 -1
- package/orders/constants/status.js +2 -2
- package/orders/index.js +1 -1
- package/orders/providers/OrderDetailsPrivateProvider.js +1 -1
- package/orders/providers/OrderDetailsProvider.js +3 -3
- package/package.json +8 -8
- package/page/actions/index.js +1 -0
- package/page/components/index.js +1 -0
- package/page/constants/index.js +1 -0
- package/page/index.js +2 -4
- package/page/selectors/index.js +7 -0
- package/product/collections/index.js +1 -0
- package/product/components/Availability/Availability.connector.js +4 -5
- package/product/components/Availability/Availability.js +3 -3
- package/product/components/Characteristics/Characteristic/components/Sheet/index.js +20 -0
- package/product/components/Characteristics/Characteristic/components/SheetItem/index.js +10 -0
- package/product/components/Characteristics/Characteristic/components/SheetItem/style.js +1 -0
- package/product/components/Characteristics/Characteristic/index.js +18 -0
- package/product/components/Characteristics/Characteristic/style.js +1 -0
- package/product/components/Characteristics/Swatch/index.js +12 -0
- package/product/components/Characteristics/Swatch/style.js +1 -0
- package/product/components/Characteristics/index.js +12 -0
- package/product/components/Characteristics/transition.js +1 -0
- package/product/components/Description/index.js +2 -2
- package/product/components/EffectivityDates/helpers.js +3 -3
- package/product/components/EffectivityDates/index.js +1 -1
- package/product/components/Header/PriceStriked/connector.js +9 -0
- package/product/components/Header/PriceStriked/index.js +5 -0
- package/product/components/Header/PriceStriked/style.js +1 -0
- package/product/components/Header/Shipping/components/Label/index.js +6 -0
- package/product/components/Header/Shipping/components/Label/style.js +1 -0
- package/product/components/Header/Shipping/connector.js +9 -0
- package/product/components/Header/Shipping/index.js +5 -0
- package/product/components/Header/Shipping/mock.js +1 -0
- package/product/components/Header/Shipping/spec.js +5 -0
- package/product/components/Header/Shipping/style.js +1 -0
- package/product/components/Header/Tiers/components/Tier/index.js +6 -0
- package/product/components/Header/Tiers/components/Tier/spec.js +1 -0
- package/product/components/Header/Tiers/connector.js +10 -0
- package/product/components/Header/Tiers/index.js +5 -0
- package/product/components/Header/Tiers/spec.js +1 -0
- package/product/components/Header/Tiers/style.js +1 -0
- package/product/components/Header/index.js +1 -0
- package/product/components/MapPriceHint/index.js +1 -1
- package/product/components/Media/FeaturedMedia.js +1 -1
- package/product/components/MediaSlider/index.js +1 -1
- package/product/components/Options/components/Content/connector.js +10 -0
- package/product/components/Options/components/Content/index.js +16 -0
- package/product/components/Options/components/Content/spec.js +2 -0
- package/product/components/Options/components/Option/index.js +4 -0
- package/product/components/Options/components/TextOption/components/OptionInfo/index.js +9 -0
- package/product/components/Options/components/TextOption/components/OptionInfo/spec.js +1 -0
- package/product/components/Options/components/TextOption/components/OptionInfo/style.js +1 -0
- package/product/components/Options/components/TextOption/index.js +22 -0
- package/product/components/Options/components/TextOption/style.js +1 -0
- package/product/components/Options/index.js +5 -0
- package/product/components/OrderQuantityHint/index.js +3 -2
- package/product/components/OrderQuantityHint/style.js +1 -1
- package/product/components/PriceDifference/index.js +1 -1
- package/product/components/ProductCard/index.js +2 -2
- package/product/components/ProductCharacteristics/helpers/index.js +1 -1
- package/product/components/ProductCharacteristics/index.js +28 -12
- package/product/components/ProductDiscountBadge/spec.js +1 -1
- package/product/components/ProductGridPrice/index.js +2 -2
- package/product/components/ProductImage/index.js +15 -12
- package/product/components/ProductList/components/Item/index.js +5 -0
- package/product/components/ProductList/components/Item/style.js +2 -0
- package/product/components/ProductList/components/Iterator/index.js +5 -0
- package/product/components/ProductList/components/Iterator/style.js +1 -0
- package/product/components/ProductList/components/Layout/index.js +5 -0
- package/product/components/ProductList/components/Layout/style.js +1 -0
- package/product/components/ProductList/index.js +5 -0
- package/product/components/ProductProperties/Content.js +1 -1
- package/product/components/ProductProperties/GroupedProperties.js +1 -1
- package/product/components/ProductProperties/ListsHTML.js +1 -1
- package/product/components/ProductProperties/ProductProperties.js +1 -1
- package/product/components/ProductProperties/RowHTML.js +1 -1
- package/product/components/ProductProperties/Wrapper.js +1 -1
- package/product/components/ProductProperties/style.js +1 -1
- package/product/components/ProductSlider/index.js +4 -0
- package/product/components/ProductSlider/spec.js +1 -0
- package/product/components/ProductSlider/style.js +1 -0
- package/product/components/QuantityPicker/hooks.js +5 -0
- package/product/components/QuantityPicker/index.js +2 -2
- package/product/components/Rating/connector.js +9 -0
- package/product/components/Rating/index.js +7 -0
- package/product/components/Rating/mock.js +5 -0
- package/product/components/Rating/spec.js +5 -0
- package/product/components/Rating/style.js +1 -0
- package/product/components/Swatch/SwatchContent.js +1 -1
- package/product/components/UnitQuantityPicker/CartUnitQuantityPicker.js +2 -2
- package/product/components/UnitQuantityPicker/ProductUnitQuantityPicker.js +3 -2
- package/product/components/UnitQuantityPicker/UnitQuantityPicker.js +6 -3
- package/product/components/UnitQuantityPicker/UnitQuantityPickerWithSection.js +7 -0
- package/product/components/UnitQuantityPicker/index.js +1 -1
- package/product/components/index.js +1 -0
- package/product/constants/index.js +1 -1
- package/product/contexts/index.js +1 -0
- package/product/helpers/index.js +2 -2
- package/product/helpers/redirects.js +1 -1
- package/product/hocs/index.js +1 -0
- package/product/hooks/index.js +1 -0
- package/product/index.js +4 -11
- package/product/providers/Product/connector.js +5 -0
- package/product/providers/Product/index.js +4 -0
- package/product/providers/index.js +1 -0
- package/product/selectors/product.js +24 -3
- package/product/selectors/variants.js +2 -2
- package/product/streams/index.js +1 -0
- package/push-opt-in/action-creators/index.js +1 -0
- package/push-opt-in/action-creators/optInTrigger.js +23 -0
- package/push-opt-in/action-creators/pushOptIn.js +7 -0
- package/push-opt-in/actions/index.js +1 -0
- package/push-opt-in/actions/pushOptInModal.js +8 -0
- package/push-opt-in/components/PushOptInModal/connector.js +9 -0
- package/push-opt-in/components/PushOptInModal/index.js +9 -0
- package/push-opt-in/components/PushOptInModal/push-opt-in.svg +62 -0
- package/push-opt-in/components/PushOptInModal/style.js +1 -0
- package/push-opt-in/components/index.js +1 -0
- package/push-opt-in/constants/index.js +1 -0
- package/push-opt-in/constants/optInModal.js +1 -0
- package/push-opt-in/constants/optInTrigger.js +1 -0
- package/push-opt-in/reducers/index.js +1 -0
- package/push-opt-in/reducers/optInModal.js +6 -0
- package/push-opt-in/reducers/optInTrigger.js +6 -0
- package/push-opt-in/selectors/index.js +1 -0
- package/push-opt-in/selectors/optInModal.js +8 -0
- package/push-opt-in/selectors/optInTrigger.js +5 -0
- package/push-opt-in/subscriptions/index.js +1 -0
- package/push-opt-in/subscriptions/optInTrigger.js +12 -0
- package/registration/components/index.js +1 -0
- package/registration/index.js +1 -1
- package/registration/providers/GuestRegistrationProvider.actions.js +2 -2
- package/registration/providers/GuestRegistrationProvider.js +3 -3
- package/registration/providers/RegistrationProvider.actions.js +3 -3
- package/registration/providers/RegistrationProvider.js +2 -2
- package/registration/subscriptions/index.js +1 -1
- package/reviews/actions/index.js +1 -0
- package/reviews/components/Reviews/components/Header/components/ReviewsExcerpt/index.js +1 -1
- package/reviews/components/Reviews/components/Header/components/ReviewsExcerpt/style.js +1 -2
- package/reviews/components/Reviews/components/List/index.js +3 -3
- package/reviews/components/Reviews/components/List/spec.js +1 -1
- package/reviews/components/Reviews/components/RatingCount/index.js +1 -1
- package/reviews/components/Reviews/components/RatingCount/style.js +1 -2
- package/reviews/components/Reviews/components/ReviewsInfo/index.js +1 -2
- package/reviews/components/Reviews/spec.js +1 -1
- package/reviews/components/index.js +1 -0
- package/reviews/constants/index.js +1 -0
- package/reviews/index.js +3 -7
- package/reviews/selectors/index.js +1 -0
- package/reviews/streams/index.js +1 -0
- package/scanner/action-creators/index.js +1 -0
- package/scanner/actions/index.js +1 -0
- package/scanner/classes/index.js +1 -0
- package/scanner/constants/index.js +1 -0
- package/scanner/helpers/index.js +1 -0
- package/scanner/index.js +1 -6
- package/scanner/streams/index.js +1 -0
- package/search/actions/index.js +1 -0
- package/search/constants/index.js +1 -0
- package/search/helpers/index.js +1 -0
- package/search/index.js +1 -6
- package/search/selectors/index.js +1 -0
- package/search/streams/index.js +1 -0
- package/styles/helpers/index.js +1 -0
- package/styles/helpers/initCSSCustomProperties.js +3 -3
- package/styles/helpers/loadCustomStyles.js +2 -2
- package/styles/helpers/setPageBackgroundColor.js +2 -1
- package/styles/helpers/setPageContentWidth.js +2 -1
- package/styles/index.js +1 -1
- package/tracking/action-creators/cookieConsent.js +24 -0
- package/tracking/action-creators/index.js +1 -4
- package/tracking/actions/cookieConsent.js +21 -0
- package/tracking/actions/index.js +1 -0
- package/tracking/components/CookieConsentModal/connector.js +6 -0
- package/tracking/components/CookieConsentModal/index.js +9 -0
- package/tracking/components/CookieConsentModal/style.js +1 -0
- package/tracking/components/CookieConsentModal/tracking-opt-in.svg +18 -0
- package/tracking/components/PrivacySettings/connector.js +6 -0
- package/tracking/components/PrivacySettings/index.js +4 -0
- package/tracking/components/PrivacySettings/style.js +1 -0
- package/tracking/components/index.js +1 -1
- package/tracking/constants/index.js +1 -1
- package/tracking/reducers/cookieConsentModal.js +6 -0
- package/tracking/reducers/cookieSettings.js +6 -0
- package/tracking/reducers/index.js +1 -0
- package/tracking/selectors/cookieConsent.js +35 -0
- package/tracking/selectors/index.js +1 -4
- package/tracking/streams/cookieConsent.js +46 -0
- package/tracking/streams/index.js +1 -1
- package/tracking/subscriptions/analytics.js +11 -0
- package/tracking/subscriptions/cookieConsent.js +13 -0
- package/tracking/subscriptions/index.js +1 -4
- package/components/MessageBar/MessageBar.types.js +0 -0
- package/components/MessageBar/style.js +0 -1
- package/i18n/locale/ru-ru/countries.json +0 -251
- package/product/components/Availability/Availability.types.js +0 -1
- package/product/components/QuantityPicker/helpers.js +0 -5
- package/tracking/components/CookieConsent/CookieConsent.connector.js +0 -4
- package/tracking/components/CookieConsent/CookieConsent.js +0 -4
- package/tracking/components/CookieConsent/CookieConsentButtons.js +0 -3
- package/tracking/components/CookieConsent/CookieConsentCheckboxes.js +0 -3
- package/tracking/components/CookieConsent/CookieConsentContent.js +0 -4
- package/tracking/components/CookieConsent/CookieConsentMessage.js +0 -4
- package/tracking/components/CookieConsent/index.js +0 -1
- package/tracking/helpers/index.js +0 -7
- package/tracking/hooks/index.js +0 -4
- package/tracking/index.js +0 -1
- package/tracking/providers/CookieConsentProvider.connector.js +0 -4
- package/tracking/providers/CookieConsentProvider.js +0 -8
- /package/{tracking/providers/CookieConsentProvider.context.js → back-in-stock/providers/BackInStockSubscriptionsProvider.context.js} +0 -0
- /package/page/{NotFound.js → components/NotFound.js} +0 -0
|
@@ -19,8 +19,8 @@ import _regeneratorRuntime from"@babel/runtime/regenerator";function _extends(){
|
|
|
19
19
|
*/function sendReservation(_x){return _sendReservation.apply(this,arguments);}/**
|
|
20
20
|
* @param {Object} location The selected location.
|
|
21
21
|
* @returns {boolean}
|
|
22
|
-
*/function _sendReservation(){_sendReservation=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(values){var response;return _regeneratorRuntime.wrap(function _callee2$(_context2){while(1)
|
|
23
|
-
storeFormInput(values);case 17:case"end":return _context2.stop();}}
|
|
22
|
+
*/function _sendReservation(){_sendReservation=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(values){var response;return _regeneratorRuntime.wrap(function _callee2$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:_context2.prev=0;_context2.next=3;return submitReservation(values,product);case 3:response=_context2.sent;if(response.errors&&response.errors.length>0){setStage(STAGE_RESPONSE_ERROR);setOrderNumbers(null);setErrors(response.errors);}setStage(STAGE_RESPONSE_SUCCESS);setOrderNumbers(response.orderNumbers);setErrors(null);_context2.next=16;break;case 10:_context2.prev=10;_context2.t0=_context2["catch"](0);logger.error(_context2.t0);setStage(STAGE_RESPONSE_ERROR);setOrderNumbers(null);setErrors([_context2.t0.message]);case 16:// Store the user's form in the user data.
|
|
23
|
+
storeFormInput(values);case 17:case"end":return _context2.stop();}},_callee2,null,[[0,10]]);}));return _sendReservation.apply(this,arguments);}var confirmSelection=/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(location){var code,name,ropeCartProducts,cartHasDifferentCodes,confirmed,updateData;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:code=location.code,name=location.name;ropeCartProducts=cartProducts.filter(function(cartProduct){var _cartProduct$fulfillm;return[ROPIS,BOPIS].includes(cartProduct===null||cartProduct===void 0?void 0:(_cartProduct$fulfillm=cartProduct.fulfillment)===null||_cartProduct$fulfillm===void 0?void 0:_cartProduct$fulfillm.method);});if(!(!restrictMultiLocationOrders||ropeCartProducts.length===0)){_context.next=4;break;}return _context.abrupt("return",true);case 4:if(!(isCart&&ropeCartProducts.length===1)){_context.next=6;break;}return _context.abrupt("return",true);case 6:cartHasDifferentCodes=!!ropeCartProducts.map(function(_ref2){var _fulfillment$location;var fulfillment=_ref2.fulfillment;return fulfillment===null||fulfillment===void 0?void 0:(_fulfillment$location=fulfillment.location)===null||_fulfillment$location===void 0?void 0:_fulfillment$location.code;}).filter(Boolean).filter(function(cartProductCode){return cartProductCode!==code;}).length;if(!(ropeCartProducts.length>=1&&!cartHasDifferentCodes)){_context.next=9;break;}return _context.abrupt("return",true);case 9:_context.next=11;return showModal({title:'locations.multi_location_modal.title',message:'locations.multi_location_modal.message',confirm:'locations.multi_location_modal.change_store',dismiss:'common.cancel'});case 11:confirmed=_context.sent;if(!(confirmed&&ropeCartProducts.length)){_context.next=18;break;}updateData=ropeCartProducts.map(function(_ref3){var cartItemId=_ref3.id,fulfillment=_ref3.fulfillment;return{cartItemId:cartItemId,fulfillment:{method:fulfillment===null||fulfillment===void 0?void 0:fulfillment.method,location:{code:code,name:name||''}}};});setIsLoading(true);_context.next=17;return updateProductsInCart(updateData);case 17:setIsLoading(false);case 18:return _context.abrupt("return",confirmed);case 19:case"end":return _context.stop();}},_callee);}));return function confirmSelection(_x2){return _ref.apply(this,arguments);};}();/**
|
|
24
24
|
* Handles multiline reservation.
|
|
25
25
|
* @param {Object} location The selected location.
|
|
26
26
|
*/function handleMultilineReservation(location){if(product===null||location.code===null){return;}var fulfillment=_extends({method:fulfillmentMethod,location:{code:location.code,name:location.name||''}},fulfillmentSchedulingEnabled&&activeFulfillmentSlotLocationCode===location.code&&(activeFulfillmentSlot===null||activeFulfillmentSlot===void 0?void 0:activeFulfillmentSlot.id)?{slotId:activeFulfillmentSlot.id}:null);if(isChangeFulfillment&&cartItem){updateProductsInCart([{quantity:cartItem.quantity,cartItemId:cartItem.id,fulfillment:fulfillment}]);}handleClose(location,product.id);}/**
|
|
@@ -31,12 +31,12 @@ storeFormInput(values);case 17:case"end":return _context2.stop();}}},_callee2,nu
|
|
|
31
31
|
*/function handleSelectLocation(_x3){return _handleSelectLocation.apply(this,arguments);}/**
|
|
32
32
|
* @param {string} method The selected fulfillment method.
|
|
33
33
|
* @param {Object} item The cart item to change.
|
|
34
|
-
*/function _handleSelectLocation(){_handleSelectLocation=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(location){var selectionConfirmed,handleReservationMethod;return _regeneratorRuntime.wrap(function _callee3$(_context3){while(1)
|
|
34
|
+
*/function _handleSelectLocation(){_handleSelectLocation=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(location){var selectionConfirmed,handleReservationMethod;return _regeneratorRuntime.wrap(function _callee3$(_context3){while(1)switch(_context3.prev=_context3.next){case 0:if(!isLoading){_context3.next=2;break;}return _context3.abrupt("return");case 2:if(!updatePreferredLocation){_context3.next=7;break;}_context3.next=5;return confirmSelection(location);case 5:selectionConfirmed=_context3.sent;if(selectionConfirmed){selectLocation({code:location.code,name:location.name});}case 7:if(!changeOnly){_context3.next=10;break;}if(selectionConfirmed){handleClose(location,product&&product.id);}return _context3.abrupt("return");case 10:/**
|
|
35
35
|
* Select the reservation method strategy.
|
|
36
36
|
* @param {string} method The reservation method.
|
|
37
37
|
* @param {Object} storeLocation A store location
|
|
38
38
|
*/handleReservationMethod=function handleReservationMethod(method,storeLocation){if(!method){return;}if(method===QUICK_RESERVE){handleQuickReservation();}if(method===MULTI_LINE_RESERVE){handleMultilineReservation(storeLocation);}};// No fulfillment path selected yet.
|
|
39
|
-
if(!(fulfillmentPath===null)){_context3.next=14;break;}if(fulfillmentPaths.length>1){FulfillmentPathSelector.open(function(method){if(!method){return;}handleReservationMethod(method,location);});}else if(fulfillmentPaths.length===1){handleReservationMethod(fulfillmentPaths[0],location);}return _context3.abrupt("return");case 14:if(!(fulfillmentPath===MULTI_LINE_RESERVE&&fulfillmentPaths.includes(MULTI_LINE_RESERVE))){_context3.next=17;break;}handleMultilineReservation(location);return _context3.abrupt("return");case 17:if(fulfillmentPath===QUICK_RESERVE){handleQuickReservation();}case 18:case"end":return _context3.stop();}}
|
|
39
|
+
if(!(fulfillmentPath===null)){_context3.next=14;break;}if(fulfillmentPaths.length>1){FulfillmentPathSelector.open(function(method){if(!method){return;}handleReservationMethod(method,location);});}else if(fulfillmentPaths.length===1){handleReservationMethod(fulfillmentPaths[0],location);}return _context3.abrupt("return");case 14:if(!(fulfillmentPath===MULTI_LINE_RESERVE&&fulfillmentPaths.includes(MULTI_LINE_RESERVE))){_context3.next=17;break;}handleMultilineReservation(location);return _context3.abrupt("return");case 17:if(fulfillmentPath===QUICK_RESERVE){handleQuickReservation();}case 18:case"end":return _context3.stop();}},_callee3);}));return _handleSelectLocation.apply(this,arguments);}function handleChangeFulfillmentMethod(method,item){logger.assert(item.product.id===product.id,'Change fulfillment method is called with unexpected product id');setIsChangeFulfillment(true);setCartItem(item);if([ROPIS,BOPIS].includes(method)&&(item.fulfillment===null||item.fulfillment.method===DIRECT_SHIP)){/**
|
|
40
40
|
* When the fulfillment method of the current cart item was DIRECT_SHIP before, and is
|
|
41
41
|
* switched to a ROPE method, the customer needs to pick a store for the item.
|
|
42
42
|
*/setFulfillmentPath(MULTI_LINE_RESERVE);setStage(STAGE_SELECT_STORE);setFulfillmentMethod(method);setIsOpen(true);return;}if([DIRECT_SHIP,ROPIS,BOPIS].includes(method)){updateProductsInCart([{quantity:item.quantity,cartItemId:item.id,fulfillment:{method:method}}]);handleClose(null,item.product.id);}}var handleSelectStoreFinderLocation=useCallback(function(location){setStoreFinderLocation(location);},[]);var context={stage:stage,title:title,fulfillmentPath:fulfillmentPath,changeOnly:changeOnly,isStage:isStage,isOpen:isOpen,handleOpen:handleOpen,handleClose:handleClose,locations:locations,inventory:inventory,baseProduct:propsBaseProduct,product:product,location:productLocation,storeFinderLocation:storeFinderLocation,userInput:userInput,fulfillmentPaths:fulfillmentPaths,fulfillmentMethods:fulfillmentMethods,enabledFulfillmentMethods:enabledFulfillmentMethods,shopSettings:shopSettings,selectLocation:handleSelectLocation,selectStoreFinderLocation:handleSelectStoreFinderLocation,changeFulfillment:handleChangeFulfillmentMethod,sendReservation:sendReservation,orderNumbers:orderNumbers,errors:errors,noInventory:noInventory,noLocationSelection:noLocationSelection,isStoreFinder:isStoreFinder,isFetching:isFetching,isLoading:isLoading,setIsLoading:setIsLoading,meta:props.meta||undefined};return React.createElement(FulfillmentContext.Provider,{value:context},children);}FulfillmentProvider.defaultProps={open:false,changeOnly:false,updatePreferredLocation:true,fulfillmentMethods:null,title:null};var FulfillmentProviderWrapped=withCurrentProduct(connect(FulfillmentProvider));/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance");}function _iterableToArrayLimit(arr,i){var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[Symbol.iterator](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}import React,{useMemo,useState,useCallback,useEffect}from'react';import PropTypes from'prop-types';import{LoadingProvider}from'@shopgate/pwa-common/providers';import{STORE_FINDER_PATTERN}from"../constants";import{StoreFinderContext}from"../locations.context";import connect from"./StoreFinder.connector";import{useNavigation}from"../../core";/**
|
|
2
2
|
* @param {Object} props The component props
|
|
3
3
|
* @returns {JSX}
|
|
4
|
-
*/var StoreFinderProvider=function StoreFinderProvider(_ref){var children=_ref.children,locations=_ref.locations,isFetching=_ref.isFetching,shopSettings=_ref.shopSettings,userSearch=_ref.userSearch,storeFinderSearch=_ref.storeFinderSearch,storeListRef=_ref.storeListRef,selectGlobalLocation=_ref.selectGlobalLocation,selectLocation=_ref.selectLocation;var _useNavigation=useNavigation(),pop=_useNavigation.pop;var _useState=useState(null),_useState2=_slicedToArray(_useState,2),selectedLocation=_useState2[0],setSelectedLocation=_useState2[1];var _useState3=useState(null),_useState4=_slicedToArray(_useState3,2),locationsHash=_useState4[0],setLocationsHash=_useState4[1];var changeLocation=useCallback(function(location){var scrollIntoView=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;setSelectedLocation(location);if(scrollIntoView&&storeListRef.current){var container=storeListRef.current;var element=container.querySelector("[data-location-code=\"".concat(location.code,"\"]"));var scrollParams={top:element.parentNode.offsetTop-container.offsetTop-10,behavior:'smooth'};var
|
|
4
|
+
*/var StoreFinderProvider=function StoreFinderProvider(_ref){var children=_ref.children,locations=_ref.locations,isFetching=_ref.isFetching,shopSettings=_ref.shopSettings,userSearch=_ref.userSearch,storeFinderSearch=_ref.storeFinderSearch,storeListRef=_ref.storeListRef,selectGlobalLocation=_ref.selectGlobalLocation,selectLocation=_ref.selectLocation;var _useNavigation=useNavigation(),pop=_useNavigation.pop;var _useState=useState(null),_useState2=_slicedToArray(_useState,2),selectedLocation=_useState2[0],setSelectedLocation=_useState2[1];var _useState3=useState(null),_useState4=_slicedToArray(_useState3,2),locationsHash=_useState4[0],setLocationsHash=_useState4[1];var changeLocation=useCallback(function(location){var scrollIntoView=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;setSelectedLocation(location);if(scrollIntoView&&storeListRef.current){var container=storeListRef.current;var element=container.querySelector("[data-location-code=\"".concat(location.code,"\"]"));var scrollParams={top:element.parentNode.offsetTop-container.offsetTop-10,behavior:'smooth'};var _getComputedStyle2=getComputedStyle(container),overflowY=_getComputedStyle2.overflowY;if(overflowY==='scroll'){container.scroll(scrollParams);}else{window.scroll(scrollParams);}}},[storeListRef]);var selectLocationCb=useCallback(function(location){setSelectedLocation(location);selectLocation(location);selectGlobalLocation(location);// Back navigation
|
|
5
5
|
pop();},[selectLocation,selectGlobalLocation,pop]);useEffect(function(){var hash=JSON.stringify(locations.map(function(_ref2){var code=_ref2.code;return code;}));if(hash!==locationsHash){setLocationsHash(hash);changeLocation(locations[0]);}});/**
|
|
6
6
|
* @param {bool} loading
|
|
7
7
|
*/var setIsLoading=useCallback(function(loading){if(loading){LoadingProvider.setLoading(STORE_FINDER_PATTERN);return;}LoadingProvider.unsetLoading(STORE_FINDER_PATTERN);},[]);var value=useMemo(function(){return{locations:locations,selectedLocation:selectedLocation,changeLocation:changeLocation,selectLocation:selectLocationCb,isFetching:isFetching,shopSettings:shopSettings,userSearch:userSearch,storeFinderSearch:storeFinderSearch,setIsLoading:setIsLoading};},[isFetching,locations,changeLocation,selectLocationCb,selectedLocation,shopSettings,storeFinderSearch,userSearch,setIsLoading]);return React.createElement(StoreFinderContext.Provider,{value:value},children);};StoreFinderProvider.defaultProps={children:null,locations:[],storeListRef:null,isFetching:false,shopSettings:null,userSearch:null,storeFinderSearch:null};export default connect(StoreFinderProvider);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}function _objectWithoutProperties(source,excluded){if(source==null)return{};var target=_objectWithoutPropertiesLoose(source,excluded);var key,i;if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++){key=sourceSymbolKeys[i];if(excluded.indexOf(key)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(source,key))continue;target[key]=source[key];}}return target;}function _objectWithoutPropertiesLoose(source,excluded){if(source==null)return{};var target={};var sourceKeys=Object.keys(source);var key,i;for(i=0;i<sourceKeys.length;i++){key=sourceKeys[i];if(excluded.indexOf(key)>=0)continue;target[key]=source[key];}return target;}import{produce}from'immer';import{generateSortedHash}from'@shopgate/pwa-common/helpers/redux/generateSortedHash';import{ERROR_LOCATIONS,REQUEST_LOCATIONS,RECEIVE_LOCATIONS,REQUEST_PRODUCT_LOCATIONS,RECEIVE_PRODUCT_LOCATIONS,RECEIVE_INVENTORIES,ERROR_PRODUCT_LOCATIONS,STORE_FULFILLMENT_METHOD,SELECT_LOCATION,FETCH_FULFILLMENT_SLOTS_SUCCESS,RECEIVE_PRODUCT_INVENTORIES}from"../constants";var initialState={// If general usage of state has been finished.
|
|
1
|
+
var _excluded=["productInventory"],_excluded2=["locationCode"],_excluded3=["locationCode","productCode"];function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}function _objectWithoutProperties(source,excluded){if(source==null)return{};var target=_objectWithoutPropertiesLoose(source,excluded);var key,i;if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++){key=sourceSymbolKeys[i];if(excluded.indexOf(key)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(source,key))continue;target[key]=source[key];}}return target;}function _objectWithoutPropertiesLoose(source,excluded){if(source==null)return{};var target={};var sourceKeys=Object.keys(source);var key,i;for(i=0;i<sourceKeys.length;i++){key=sourceKeys[i];if(excluded.indexOf(key)>=0)continue;target[key]=source[key];}return target;}import{produce}from'immer';import{generateSortedHash}from'@shopgate/pwa-common/helpers/redux/generateSortedHash';import{ERROR_LOCATIONS,REQUEST_LOCATIONS,RECEIVE_LOCATIONS,REQUEST_PRODUCT_LOCATIONS,RECEIVE_PRODUCT_LOCATIONS,RECEIVE_INVENTORIES,ERROR_PRODUCT_LOCATIONS,STORE_FULFILLMENT_METHOD,SELECT_LOCATION,FETCH_FULFILLMENT_SLOTS_SUCCESS,RECEIVE_PRODUCT_INVENTORIES}from"../constants";var initialState={// If general usage of state has been finished.
|
|
2
2
|
// Currently used to identify if any change is currently pending
|
|
3
3
|
// before the store switcher is being displayed.
|
|
4
4
|
pending:true,// If any data is being fetched right now.
|
|
@@ -14,10 +14,10 @@ fulfillmentSlotsByLocation:{}};/* eslint-disable no-param-reassign */ /**
|
|
|
14
14
|
* @param {Array} locations Locations
|
|
15
15
|
*/var storeLocationData=function storeLocationData(draft,locations){locations.forEach(function(location){// Remove some situational data to avoid confusion.
|
|
16
16
|
// The location storage should only contain the raw location info.
|
|
17
|
-
var productInventory=location.productInventory,filteredData=_objectWithoutProperties(location,
|
|
17
|
+
var productInventory=location.productInventory,filteredData=_objectWithoutProperties(location,_excluded);draft.locationsByCode[location.code]=filteredData;// Enhance with primary address for easier lookup.
|
|
18
18
|
draft.locationsByCode[location.code].address=location.addresses.find(function(a){return a.isPrimary;})||location.addresses[0];});};export default(function(){var state=arguments.length>0&&arguments[0]!==undefined?arguments[0]:initialState;var action=arguments.length>1?arguments[1]:undefined;var producer=produce(function(draft){var _action$location;switch(action.type){case REQUEST_LOCATIONS:case REQUEST_PRODUCT_LOCATIONS:draft.isFetching=true;break;case ERROR_LOCATIONS:case ERROR_PRODUCT_LOCATIONS:draft.isFetching=false;break;case FETCH_FULFILLMENT_SLOTS_SUCCESS:{draft.fulfillmentSlotsByLocation=draft.fulfillmentSlotsByLocation||{};draft.fulfillmentSlotsByLocation[action.locationCode]=action.fulfillmentSlots;break;}case RECEIVE_LOCATIONS:{// Store all missing locations.
|
|
19
19
|
storeLocationData(draft,action.locations);// Store filtered result set.
|
|
20
|
-
var locationCodes=action.locations.map(function(l){return l.code;});var filter=generateSortedHash(_extends({},action.filters));draft.locationsByFilter[filter]=locationCodes;draft.initialized=true;draft.isFetching=false;draft.pending=false;break;}case RECEIVE_PRODUCT_INVENTORIES:{action.inventories.forEach(function(inventory){var locationCode=inventory.locationCode,rest=_objectWithoutProperties(inventory,
|
|
20
|
+
var locationCodes=action.locations.map(function(l){return l.code;});var filter=generateSortedHash(_extends({},action.filters));draft.locationsByFilter[filter]=locationCodes;draft.initialized=true;draft.isFetching=false;draft.pending=false;break;}case RECEIVE_PRODUCT_INVENTORIES:{action.inventories.forEach(function(inventory){var locationCode=inventory.locationCode,rest=_objectWithoutProperties(inventory,_excluded2);var key=generateSortedHash({productCode:action.productCode,locationCode:locationCode});draft.inventoriesByCodePair[key]=rest;});break;}case RECEIVE_INVENTORIES:{action.productInventories.forEach(function(inventory){var locationCode=inventory.locationCode,productCode=inventory.productCode,rest=_objectWithoutProperties(inventory,_excluded3);var key=generateSortedHash({productCode:productCode,locationCode:locationCode});draft.inventoriesByCodePair[key]=rest;});break;}case RECEIVE_PRODUCT_LOCATIONS:{// Store all missing locations.
|
|
21
21
|
storeLocationData(draft,action.locations);// For each location we store a new inventory entry.
|
|
22
22
|
action.locations.forEach(function(location){var key=generateSortedHash({productCode:action.productCode,locationCode:location.code});// Keep bin/binLocation for location if present
|
|
23
23
|
draft.inventoriesByCodePair[key]=_extends({},draft.inventoriesByCodePair[key],{},location.productInventory);});// Store filtered result set.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
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 _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{createSelector}from'reselect';import pickBy from'lodash/pickBy';import{getUserData,getExternalCustomerNumber,getUserId}from'@shopgate/engage/user';import{generateSortedHash}from'@shopgate/pwa-common/helpers/redux/generateSortedHash';import{getProduct}from'@shopgate/engage/product/selectors/product';import{getCurrentRoute}from'@shopgate/pwa-common/selectors/router';import{getIsLocationBasedShopping,makeUseLocationFulfillmentMethods}from'@shopgate/engage/core';import{makeGetEnabledFulfillmentMethods}from"../../core/config";import{makeIsProductActive,makeIsBaseProductActive}from"../../product/selectors/product";import{isProductAvailable}from"../helpers/productInventory";import{DIRECT_SHIP}from"../constants";/**
|
|
1
|
+
var _excluded=["geolocation"];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 _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{createSelector}from'reselect';import pickBy from'lodash/pickBy';import{getUserData,getExternalCustomerNumber,getUserId}from'@shopgate/engage/user';import{generateSortedHash}from'@shopgate/pwa-common/helpers/redux/generateSortedHash';import{getProduct}from'@shopgate/engage/product/selectors/product';import{getCurrentRoute}from'@shopgate/pwa-common/selectors/router';import{getIsLocationBasedShopping,makeUseLocationFulfillmentMethods}from'@shopgate/engage/core/selectors';import{makeGetEnabledFulfillmentMethods}from"../../core/config";import{makeIsProductActive,makeIsBaseProductActive}from"../../product/selectors/product";import{isProductAvailable}from"../helpers/productInventory";import{DIRECT_SHIP}from"../constants";/**
|
|
2
2
|
* Selector to retrieve a product's fulfillment methods.
|
|
3
3
|
* @returns {Function}
|
|
4
4
|
*/export var getProductFulfillmentMethods=createSelector(getProduct,function(product){if(!product||!product.fulfillmentMethods||product.fulfillmentMethods.length===0){return null;}return product.fulfillmentMethods;});/**
|
|
@@ -31,7 +31,7 @@ var productCode=filters.productCode;if(!productCode){return locations;}return lo
|
|
|
31
31
|
* Creates a selector that retrieves active filter.
|
|
32
32
|
* @param {Object} state State.
|
|
33
33
|
* @returns {Object}
|
|
34
|
-
*/export var getActiveFilter=createSelector(getLocationsState,function(locationsState){var _locationsState$userS=locationsState.userSearch,geolocation=_locationsState$userS.geolocation,rest=_objectWithoutProperties(_locationsState$userS,
|
|
34
|
+
*/export var getActiveFilter=createSelector(getLocationsState,function(locationsState){var _locationsState$userS=locationsState.userSearch,geolocation=_locationsState$userS.geolocation,rest=_objectWithoutProperties(_locationsState$userS,_excluded);var longitude;var latitude;if(geolocation){longitude=geolocation.longitude;latitude=geolocation.latitude;}return pickBy(_extends({},rest,{longitude:longitude,latitude:latitude}));});/**
|
|
35
35
|
* Creates a selector that retrieves all locations for a given product.
|
|
36
36
|
* @param {Function} getProductCode Has to retrieve the product code.
|
|
37
37
|
* @returns {Object}
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import _regeneratorRuntime from"@babel/runtime/regenerator";function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}import{getProductsResult,productIsReady$,productsReceived$,productsReceivedCached$,RECEIVE_PRODUCTS_CACHED,variantDidChange$}from'@shopgate/engage/product';import{cartReceived$,fetchCart,cartDidEnter$,getCartItems}from'@shopgate/engage/cart';import{userDidLogin$}from'@shopgate/engage/user';import{appDidStart$,routeWillEnter$,UIEvents,getCurrentRoute,hex2bin,getThemeSettings,getCurrentSearchQuery}from'@shopgate/engage/core';import{receiveFavoritesWhileVisible$}from'@shopgate/pwa-common-commerce/favorites/streams';import{getFavoritesProductsIds,isFetching}from'@shopgate/pwa-common-commerce/favorites/selectors';import{categoryDidBackEnter$}from'@shopgate/pwa-common-commerce/category/streams';import{searchDidBackEntered$}from'@shopgate/pwa-common-commerce/search/streams';import{getUserSearch,getStoreFinderSearch,getPreferredLocation,getIsPending,getProductAlternativeLocationParams,getProductAlternativeLocations}from"./selectors";import{fetchLocations,fetchProductLocations,setPending,setUserGeolocation}from"./actions";import{setShowInventoryInLists,showInventoryInLists}from"./helpers/showInventoryInLists";import fetchInventories from"./actions/fetchInventories";import{EVENT_SET_OPEN}from"./providers/FulfillmentProvider";import fetchProductInventories from"./actions/fetchProductInventories";import{submitReservationSuccess$,userSearchChanged$,storeFinderWillEnter$,preferredLocationDidUpdateOnPDP$,provideAlternativeLocation$,preferredLocationDidUpdateGlobalOnWishlist$}from"./locations.streams";import selectLocation from"./action-creators/selectLocation";import{SET_STORE_FINDER_SEARCH_RADIUS}from"./constants";import selectGlobalLocation from"./action-creators/selectGlobalLocation";var initialLocationsResolve;var initialLocationsReject;var initialLocationsPromise=new Promise(function(resolve,reject){initialLocationsResolve=resolve;initialLocationsReject=reject;});/**
|
|
1
|
+
import _regeneratorRuntime from"@babel/runtime/regenerator";function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}import{getProductsResult,productIsReady$,productsReceived$,productsReceivedCached$,RECEIVE_PRODUCTS_CACHED,variantDidChange$}from'@shopgate/engage/product';import{cartReceived$,fetchCart,cartDidEnter$,getCartItems}from'@shopgate/engage/cart';import{userDidLogin$}from'@shopgate/engage/user';import{appDidStart$,routeWillEnter$,UIEvents,getCurrentRoute,hex2bin,getThemeSettings,getCurrentSearchQuery}from'@shopgate/engage/core';import{receiveFavoritesWhileVisible$}from'@shopgate/pwa-common-commerce/favorites/streams';import{getFavoritesProductsIds,isFetching}from'@shopgate/pwa-common-commerce/favorites/selectors';import{categoryDidBackEnter$}from'@shopgate/pwa-common-commerce/category/streams';import{searchDidBackEntered$}from'@shopgate/pwa-common-commerce/search/streams';import{hasNewServices}from'@shopgate/engage/core/helpers';import{cookieConsentInitialized$}from'@shopgate/engage/tracking/streams';import{getUserSearch,getStoreFinderSearch,getPreferredLocation,getIsPending,getProductAlternativeLocationParams,getProductAlternativeLocations}from"./selectors";import{fetchLocations,fetchProductLocations,setPending,setUserGeolocation}from"./actions";import{setShowInventoryInLists,showInventoryInLists}from"./helpers/showInventoryInLists";import fetchInventories from"./actions/fetchInventories";import{EVENT_SET_OPEN}from"./providers/FulfillmentProvider";import fetchProductInventories from"./actions/fetchProductInventories";import{submitReservationSuccess$,userSearchChanged$,storeFinderWillEnter$,preferredLocationDidUpdateOnPDP$,provideAlternativeLocation$,preferredLocationDidUpdateGlobalOnWishlist$}from"./locations.streams";import selectLocation from"./action-creators/selectLocation";import{SET_STORE_FINDER_SEARCH_RADIUS}from"./constants";import selectGlobalLocation from"./action-creators/selectGlobalLocation";var initialLocationsResolve;var initialLocationsReject;var initialLocationsPromise=new Promise(function(resolve,reject){initialLocationsResolve=resolve;initialLocationsReject=reject;});/**
|
|
2
2
|
* Sets a location once the location has been validated.
|
|
3
3
|
* @param {string} locationCode Location code
|
|
4
4
|
* @param {Function} dispatch Redux dispatch function
|
|
5
5
|
* @returns {Promise}
|
|
6
|
-
*/var setLocationOnceAvailable=/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(locationCode,dispatch){var
|
|
6
|
+
*/var setLocationOnceAvailable=/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(locationCode,dispatch){var _ref3,initialLocations;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:_context.prev=0;_context.next=3;return initialLocationsPromise;case 3:_ref3=_context.sent;initialLocations=_ref3.locations;if(initialLocations.some(function(l){return l.code===locationCode;})){_context.next=7;break;}return _context.abrupt("return");case 7:dispatch(selectLocation({code:locationCode}));requestAnimationFrame(function(){dispatch(setPending(false));});_context.next=13;break;case 11:_context.prev=11;_context.t0=_context["catch"](0);case 13:case"end":return _context.stop();}},_callee,null,[[0,11]]);}));return function setLocationOnceAvailable(_x,_x2){return _ref.apply(this,arguments);};}();/**
|
|
7
7
|
* Locations subscriptions.
|
|
8
8
|
* @param {Function} subscribe The subscribe function.
|
|
9
|
-
*/function locationsSubscriber(subscribe){subscribe(
|
|
10
|
-
userSearch=getUserSearch(getState());_context2.prev=
|
|
11
|
-
hasLocation=!!locations.find(function(location){return location.code===code;});if(hasLocation){_context2.next=
|
|
12
|
-
|
|
13
|
-
if(!preferredLocation){locationToPreselect=locations.find(function(l){return l.code===preferredLocationDefault;});if(locationToPreselect){dispatch(selectLocation({code:preferredLocationDefault}));}}}initialLocationsResolve(locations);_context2.next=
|
|
9
|
+
*/function locationsSubscriber(subscribe){subscribe(cookieConsentInitialized$,/*#__PURE__*/function(){var _ref5=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref4){var dispatch,getState,userSearch,_ref7,locations,preferredLocation,code,hasLocation,_ref9,preferredLocationDefault,locationToPreselect;return _regeneratorRuntime.wrap(function _callee2$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:dispatch=_ref4.dispatch,getState=_ref4.getState;if(hasNewServices()){_context2.next=3;break;}return _context2.abrupt("return");case 3:// Fetch merchants locations.
|
|
10
|
+
userSearch=getUserSearch(getState());_context2.prev=4;_context2.next=7;return dispatch(fetchLocations(userSearch));case 7:_ref7=_context2.sent;locations=_ref7.locations;preferredLocation=getPreferredLocation(getState());if(!preferredLocation){_context2.next=16;break;}code=preferredLocation.code;// Check if the preferred location is included within the fetched locations
|
|
11
|
+
hasLocation=!!locations.find(function(location){return location.code===code;});if(hasLocation){_context2.next=16;break;}_context2.next=16;return dispatch(fetchLocations({codes:[code]}));case 16:// Preset preferredLocation if configured
|
|
12
|
+
_ref9=getThemeSettings('@shopgate/engage/locations')||{},preferredLocationDefault=_ref9.preferredLocationDefault;if(preferredLocationDefault){// check if there is already a preferredLocation for the user, if not set one
|
|
13
|
+
if(!preferredLocation){locationToPreselect=locations.find(function(l){return l.code===preferredLocationDefault;});if(locationToPreselect){dispatch(selectLocation({code:preferredLocationDefault}));}}}initialLocationsResolve(locations);_context2.next=24;break;case 21:_context2.prev=21;_context2.t0=_context2["catch"](4);initialLocationsReject(_context2.t0);case 24:UIEvents.addListener(EVENT_SET_OPEN,function(){var route=getCurrentRoute(getState());if(!route.params.productId&&!route.state.productId){return;}var productId=route.state.productId||hex2bin(route.params.productId);if(productId){dispatch(fetchProductLocations(productId,getUserSearch(getState())));}});case 25:case"end":return _context2.stop();}},_callee2,null,[[4,21]]);}));return function(_x3){return _ref5.apply(this,arguments);};}());subscribe(userSearchChanged$,/*#__PURE__*/function(){var _ref11=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref10){var dispatch,getState,action,productId,isStoreFinder,silent,state,userSearch,storeFinderSearch;return _regeneratorRuntime.wrap(function _callee3$(_context3){while(1)switch(_context3.prev=_context3.next){case 0:dispatch=_ref10.dispatch,getState=_ref10.getState,action=_ref10.action;productId=action.productId,isStoreFinder=action.isStoreFinder,silent=action.silent;if(!(silent===true)){_context3.next=4;break;}return _context3.abrupt("return");case 4:state=getState();userSearch=getUserSearch(state);if(!(isStoreFinder||action.type===SET_STORE_FINDER_SEARCH_RADIUS)){_context3.next=12;break;}storeFinderSearch=getStoreFinderSearch(state);_context3.next=10;return dispatch(fetchLocations(_extends({},userSearch,{},storeFinderSearch,{enableInLocationFinder:true})));case 10:_context3.next=19;break;case 12:if(productId){_context3.next=17;break;}_context3.next=15;return dispatch(fetchLocations(userSearch));case 15:_context3.next=19;break;case 17:_context3.next=19;return dispatch(fetchProductLocations(productId,userSearch));case 19:case"end":return _context3.stop();}},_callee3);}));return function(_x4){return _ref11.apply(this,arguments);};}());var productInventoryNeedsUpdate$=productIsReady$.merge(variantDidChange$).merge(preferredLocationDidUpdateOnPDP$).debounceTime(200);subscribe(productInventoryNeedsUpdate$,function(_ref12){var action=_ref12.action,dispatch=_ref12.dispatch,getState=_ref12.getState;var productData=action.productData;// Skip if no fulfillment methods are set.
|
|
14
14
|
if(!productData||!productData.fulfillmentMethods||productData.fulfillmentMethods.length===0){return;}var state=getState();var preferredLocation=getPreferredLocation(state);if(!preferredLocation){return;}// Fetch inventories for this specific product.
|
|
15
15
|
dispatch(fetchProductInventories(action.productData.id,{locationCodes:[preferredLocation.code]}));});// Core config and cart subscriptions
|
|
16
|
-
var fetchCart$=cartDidEnter$.switchMap(function(){return submitReservationSuccess$.first();}).delay(500);subscribe(fetchCart$,function(
|
|
17
|
-
userSearch=getUserSearch(state);storeFinderSearch=getStoreFinderSearch(state);_context4.next=6;return dispatch(fetchLocations(_extends({},userSearch,{},storeFinderSearch,{enableInLocationFinder:true})));case 6:case"end":return _context4.stop();}}
|
|
16
|
+
var fetchCart$=cartDidEnter$.switchMap(function(){return submitReservationSuccess$.first();}).delay(500);subscribe(fetchCart$,function(_ref13){var dispatch=_ref13.dispatch;dispatch(fetchCart());});subscribe(storeFinderWillEnter$,/*#__PURE__*/function(){var _ref15=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(_ref14){var dispatch,getState,state,userSearch,storeFinderSearch;return _regeneratorRuntime.wrap(function _callee4$(_context4){while(1)switch(_context4.prev=_context4.next){case 0:dispatch=_ref14.dispatch,getState=_ref14.getState;state=getState();// Fetch merchants locations.
|
|
17
|
+
userSearch=getUserSearch(state);storeFinderSearch=getStoreFinderSearch(state);_context4.next=6;return dispatch(fetchLocations(_extends({},userSearch,{},storeFinderSearch,{enableInLocationFinder:true})));case 6:case"end":return _context4.stop();}},_callee4);}));return function(_x5){return _ref15.apply(this,arguments);};}());/**
|
|
18
18
|
* Makes sure that the active location is switched after logging in
|
|
19
19
|
* to a location that is also available in the cart.
|
|
20
20
|
* Avoids having a selected location that differs from the cart
|
|
21
|
-
*/var afterCartMerge$=userDidLogin$.mergeMap(function(){return cartReceived$.first();});subscribe(afterCartMerge$,/*#__PURE__*/function(){var
|
|
21
|
+
*/var afterCartMerge$=userDidLogin$.mergeMap(function(){return cartReceived$.first();});subscribe(afterCartMerge$,/*#__PURE__*/function(){var _ref17=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5(_ref16){var _cartItems$,_cartItems$$fulfillme,_cartItems$$fulfillme2;var dispatch,getState,state,cartItems,preferredLocation,activeCartLocation,firstLocationCode;return _regeneratorRuntime.wrap(function _callee5$(_context5){while(1)switch(_context5.prev=_context5.next){case 0:dispatch=_ref16.dispatch,getState=_ref16.getState;state=getState();cartItems=getCartItems(state);preferredLocation=getPreferredLocation(state,{});if(cartItems===null||cartItems===void 0?void 0:cartItems.length){_context5.next=6;break;}return _context5.abrupt("return");case 6:activeCartLocation=cartItems.find(function(item){var _item$fulfillment,_item$fulfillment$loc;return((_item$fulfillment=item.fulfillment)===null||_item$fulfillment===void 0?void 0:(_item$fulfillment$loc=_item$fulfillment.location)===null||_item$fulfillment$loc===void 0?void 0:_item$fulfillment$loc.code)===(preferredLocation===null||preferredLocation===void 0?void 0:preferredLocation.code);});if(!activeCartLocation){_context5.next=9;break;}return _context5.abrupt("return");case 9:firstLocationCode=(_cartItems$=cartItems[0])===null||_cartItems$===void 0?void 0:(_cartItems$$fulfillme=_cartItems$.fulfillment)===null||_cartItems$$fulfillme===void 0?void 0:(_cartItems$$fulfillme2=_cartItems$$fulfillme.location)===null||_cartItems$$fulfillme2===void 0?void 0:_cartItems$$fulfillme2.code;if(firstLocationCode){_context5.next=12;break;}return _context5.abrupt("return");case 12:dispatch(selectLocation({code:firstLocationCode}));dispatch(selectGlobalLocation({code:firstLocationCode}));case 14:case"end":return _context5.stop();}},_callee5);}));return function(_x6){return _ref17.apply(this,arguments);};}());/**
|
|
22
22
|
* Handles an added store url parameter that will set the default store location
|
|
23
|
-
*/subscribe(routeWillEnter$,function(
|
|
23
|
+
*/subscribe(routeWillEnter$,function(_ref18){var action=_ref18.action,dispatch=_ref18.dispatch,getState=_ref18.getState;var locationCode=action.route.query.store;if(!locationCode){if(!getIsPending(getState())){dispatch(setPending(false));}return;}setLocationOnceAvailable(locationCode,dispatch);});var alternative$=productInventoryNeedsUpdate$.switchMap(function(){return provideAlternativeLocation$.first();});/**
|
|
24
24
|
* Provide alternative location on PDP when preferred location is out of stock
|
|
25
|
-
*/subscribe(alternative$,/*#__PURE__*/function(){var
|
|
26
|
-
state=getState();alternativeLocations=getProductAlternativeLocations(state,action);if(!alternativeLocations){_context6.next=7;break;}return _context6.abrupt("return");case 7:productId=action.productId,params=action.params;alternativeParams=getProductAlternativeLocationParams(state);fetchParams=_extends({},alternativeParams,{},params);if(fetchParams.geolocation||fetchParams.postalCode){dispatch(fetchProductLocations(productId,fetchParams));}case 11:case"end":return _context6.stop();}}
|
|
25
|
+
*/subscribe(alternative$,/*#__PURE__*/function(){var _ref20=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6(_ref19){var action,dispatch,getState,state,alternativeLocations,productId,params,alternativeParams,fetchParams;return _regeneratorRuntime.wrap(function _callee6$(_context6){while(1)switch(_context6.prev=_context6.next){case 0:action=_ref19.action,dispatch=_ref19.dispatch,getState=_ref19.getState;_context6.next=3;return dispatch(setUserGeolocation({silent:true}));case 3:// Get new state with geolocation
|
|
26
|
+
state=getState();alternativeLocations=getProductAlternativeLocations(state,action);if(!alternativeLocations){_context6.next=7;break;}return _context6.abrupt("return");case 7:productId=action.productId,params=action.params;alternativeParams=getProductAlternativeLocationParams(state);fetchParams=_extends({},alternativeParams,{},params);if(fetchParams.geolocation||fetchParams.postalCode){dispatch(fetchProductLocations(productId,fetchParams));}case 11:case"end":return _context6.stop();}},_callee6);}));return function(_x7){return _ref20.apply(this,arguments);};}());subscribe(categoryDidBackEnter$.merge(searchDidBackEntered$),function(_ref21){var _getProductsResult;var action=_ref21.action,dispatch=_ref21.dispatch,getState=_ref21.getState;var state=getState();if(!showInventoryInLists(state)){return;}var categoryId=action.route.params.categoryId;var query=getCurrentSearchQuery(state);var products=(_getProductsResult=getProductsResult(state,{categoryId:hex2bin(categoryId),searchPhrase:query}))===null||_getProductsResult===void 0?void 0:_getProductsResult.products;if(!products||!products.length){return;}var productCodes=products.map(function(_ref22){var id=_ref22.id;return id;});dispatch(fetchInventories(productCodes));});subscribe(productsReceived$.merge(productsReceivedCached$),function(_ref23){var action=_ref23.action,dispatch=_ref23.dispatch,getState=_ref23.getState;if(!showInventoryInLists(getState())){return;}if(!action.products||!action.products.length||(action===null||action===void 0?void 0:action.fetchInventory)===false){return;}var productCodes=action.type!==RECEIVE_PRODUCTS_CACHED?action.products.map(function(_ref24){var id=_ref24.id;return id;}):action.products;dispatch(fetchInventories(productCodes));});subscribe(receiveFavoritesWhileVisible$.merge(preferredLocationDidUpdateGlobalOnWishlist$),function(_ref25){var dispatch=_ref25.dispatch,getState=_ref25.getState;var state=getState();if(!showInventoryInLists(state)||isFetching(getState())){return;}var productIds=getFavoritesProductsIds(state);if(!productIds||!productIds.length){return;}dispatch(fetchInventories(productIds));});subscribe(appDidStart$,function(_ref26){var getState=_ref26.getState;// enable inventory in product lists for some users
|
|
27
27
|
setShowInventoryInLists(getState());});}export default locationsSubscriber;
|
|
@@ -2,4 +2,4 @@ import _regeneratorRuntime from"@babel/runtime/regenerator";function asyncGenera
|
|
|
2
2
|
* The ForgotPassword component.
|
|
3
3
|
* @param {Object} props The component props.
|
|
4
4
|
* @returns {JSX}
|
|
5
|
-
*/var ForgotPassword=function ForgotPassword(_ref){var resetPassword=_ref.resetPassword,goBack=_ref.goBack;var _useState=useState(false),_useState2=_slicedToArray(_useState,2),showSuccess=_useState2[0],setShowSuccess=_useState2[1];var _useState3=useState(''),_useState4=_slicedToArray(_useState3,2),email=_useState4[0],setEmail=_useState4[1];var _useState5=useState(''),_useState6=_slicedToArray(_useState5,2),validationError=_useState6[0],setValidationError=_useState6[1];var _useState7=useState(false),_useState8=_slicedToArray(_useState7,2),loading=_useState8[0],setLoading=_useState8[1];var handleSubmit=useCallback(/*#__PURE__*/function(){var _ref2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(event){var code;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)
|
|
5
|
+
*/var ForgotPassword=function ForgotPassword(_ref){var resetPassword=_ref.resetPassword,goBack=_ref.goBack;var _useState=useState(false),_useState2=_slicedToArray(_useState,2),showSuccess=_useState2[0],setShowSuccess=_useState2[1];var _useState3=useState(''),_useState4=_slicedToArray(_useState3,2),email=_useState4[0],setEmail=_useState4[1];var _useState5=useState(''),_useState6=_slicedToArray(_useState5,2),validationError=_useState6[0],setValidationError=_useState6[1];var _useState7=useState(false),_useState8=_slicedToArray(_useState7,2),loading=_useState8[0],setLoading=_useState8[1];var handleSubmit=useCallback(/*#__PURE__*/function(){var _ref2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(event){var code;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:event.preventDefault();setValidationError('');if(!email){_context.next=17;break;}setLoading(true);_context.prev=4;_context.next=7;return resetPassword(email);case 7:setShowSuccess(true);_context.next=14;break;case 10:_context.prev=10;_context.t0=_context["catch"](4);code=_context.t0.code;if(code===EUSERNOTFOUND){setValidationError('login.reset_password.customer_not_found');}case 14:setLoading(false);_context.next=18;break;case 17:setValidationError('validation.email');case 18:case"end":return _context.stop();}},_callee,null,[[4,10]]);}));return function(_x){return _ref2.apply(this,arguments);};}(),[email,resetPassword]);var handleBackToLogin=useCallback(function(){goBack();},[goBack]);return React.createElement("div",{className:container},React.createElement("div",{className:headline},React.createElement(I18n.Text,{string:"login.forgot_password"})),!showSuccess?React.createElement(Fragment,null,React.createElement("div",{className:subline},React.createElement(I18n.Text,{string:"login.reset_password.subline"})),React.createElement("form",{onSubmit:handleSubmit,className:form},React.createElement(TextField,{type:"email",name:"email",className:input,label:"login.email",value:email,onChange:function onChange(value){return setEmail(value);},errorText:validationError}),React.createElement("div",{className:buttonContainer},React.createElement(RippleButton,{className:button,type:"secondary",disabled:loading},React.createElement(I18n.Text,{string:"common.submit"}))))):React.createElement(Fragment,null,React.createElement("div",{className:resetInstructions},React.createElement("span",{/* eslint-disable react/no-danger */dangerouslySetInnerHTML:{__html:i18n.text('login.reset_password.reset_instructions',{email:"<span class=\"".concat(resetInstructionsEmail,"\">").concat(email,"</span>")})}/* eslint-enable react/no-danger */})),React.createElement("div",{className:goBackButtonContainer},React.createElement(RippleButton,{flat:true,className:goBackButton,type:"secondary",onClick:handleBackToLogin},React.createElement(ArrowIcon,{className:goBackButtonIcon}),React.createElement(I18n.Text,{string:"login.reset_password.back_to_login"})))));};export default hot(connect(ForgotPassword));
|
|
@@ -5,4 +5,4 @@ import _regeneratorRuntime from"@babel/runtime/regenerator";function asyncGenera
|
|
|
5
5
|
* @param {string} [params.orderNumber] Order Number
|
|
6
6
|
* @param {string} [params.token] Request params
|
|
7
7
|
* @returns {Function} A redux thunk.
|
|
8
|
-
*/var cancelOrder=function cancelOrder(_ref){var orderId=_ref.orderId,orderNumber=_ref.orderNumber,token=_ref.token;return(/*#__PURE__*/function(){var _ref2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(dispatch){var confirmed;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)
|
|
8
|
+
*/var cancelOrder=function cancelOrder(_ref){var orderId=_ref.orderId,orderNumber=_ref.orderNumber,token=_ref.token;return(/*#__PURE__*/function(){var _ref2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(dispatch){var confirmed;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:_context.next=2;return dispatch(showModal({title:i18n.text('order_details.cancel.modal.title'),message:i18n.text('order_details.cancel.modal.message'),confirm:i18n.text('order_details.cancel.modal.confirm')}));case 2:confirmed=_context.sent;if(!confirmed){_context.next=16;break;}_context.prev=4;_context.next=7;return new PipelineRequest(SHOPGATE_ORDER_CANCEL_ORDER).setInput({orderId:orderId,orderNumber:orderNumber,token:token}).setErrorBlacklist([EAUTHENTICATION,ENOTFOUND]).dispatch();case 7:_context.next=9;return dispatch(fetchOrderDetails({orderId:orderId,orderNumber:orderNumber,token:token}));case 9:_context.next=16;break;case 11:_context.prev=11;_context.t0=_context["catch"](4);if(![EAUTHENTICATION,ENOTFOUND].includes(_context.t0.code)){_context.next=16;break;}dispatch(errorCancelOrder(_context.t0,{orderId:orderId,orderNumber:orderNumber}));throw _context.t0;case 16:case"end":return _context.stop();}},_callee,null,[[4,11]]);}));return function(_x){return _ref2.apply(this,arguments);};}());};export default cancelOrder;
|
|
@@ -7,4 +7,4 @@ import _regeneratorRuntime from"@babel/runtime/regenerator";function asyncGenera
|
|
|
7
7
|
* @param {string} [params.phone] Phone Number
|
|
8
8
|
* @param {string} [params.token] Request params
|
|
9
9
|
* @returns {Function} A redux thunk.
|
|
10
|
-
*/var fetchOrderDetails=function fetchOrderDetails(){var params=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};return(/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(dispatch){var request,response;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)
|
|
10
|
+
*/var fetchOrderDetails=function fetchOrderDetails(){var params=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};return(/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(dispatch){var request,response;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:dispatch(requestOrderDetails(params));request=new PipelineRequest(SHOPGATE_ORDER_GET_ORDER_DETAILS).setInput(params).setErrorBlacklist([EUNAUTHORIZED,EAUTHENTICATION,ENOTFOUND]).dispatch();_context.prev=2;_context.next=5;return request;case 5:response=_context.sent;dispatch(receiveOrderDetails(params,response.order));return _context.abrupt("return",response.order);case 10:_context.prev=10;_context.t0=_context["catch"](2);dispatch(errorOrderDetails(_context.t0,params));return _context.abrupt("return",null);case 14:case"end":return _context.stop();}},_callee,null,[[2,10]]);}));return function(_x){return _ref.apply(this,arguments);};}());};export default fetchOrderDetails;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
export var ORDER_STATUS_SUBMITTED='submitted';var orderStatusMapping=(
|
|
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;}export var ORDER_STATUS_NEW='new';export var ORDER_STATUS_OPEN='open';export var ORDER_STATUS_REJECTED='rejected';export var ORDER_STATUS_CANCELED='canceled';export var ORDER_STATUS_READY='ready';export var ORDER_STATUS_FULFILLED='fulfilled';export var ORDER_STATUS_COMPLETED='completed';export var ORDER_STATUS_IN_PROGRESS='inProgress';// Does not come from the API
|
|
2
|
+
export var ORDER_STATUS_SUBMITTED='submitted';var orderStatusMapping=_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({},ORDER_STATUS_NEW,ORDER_STATUS_SUBMITTED),ORDER_STATUS_OPEN,ORDER_STATUS_SUBMITTED),ORDER_STATUS_IN_PROGRESS,ORDER_STATUS_IN_PROGRESS),ORDER_STATUS_READY,ORDER_STATUS_READY),ORDER_STATUS_FULFILLED,ORDER_STATUS_COMPLETED),ORDER_STATUS_COMPLETED,ORDER_STATUS_COMPLETED),ORDER_STATUS_CANCELED,ORDER_STATUS_CANCELED),ORDER_STATUS_REJECTED,ORDER_STATUS_CANCELED);/**
|
|
3
3
|
* Retrieves a final mapped order status of an original order status.
|
|
4
4
|
* @param {string} orderStatus The original order status
|
|
5
5
|
* @returns {string}
|
package/orders/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** @module orders */import{CHECKOUT_PATH}from'@shopgate/pwa-common/constants/RoutePaths';// CONSTANTS
|
|
2
|
-
export*from'@shopgate/pwa-common-commerce/orders/constants';export{CHECKOUT_PATH};export{
|
|
2
|
+
export*from'@shopgate/pwa-common-commerce/orders/constants';export{CHECKOUT_PATH};export{makeGetOrderById}from"./selectors";export{getTranslatedOrderStatus,getTranslatedLineItemStatus,getLineItemActiveStatus}from"./helpers";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
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;}import React,{useState,useMemo,useCallback,useEffect}from'react';import PropTypes from'prop-types';import{useRoute,LoadingProvider}from'@shopgate/engage/core';import connect from"./OrderDetailsPrivateProvider.connector";import Context from"./OrderDetailsProvider.context";/**
|
|
2
2
|
* @param {Object} props The component props.
|
|
3
3
|
* @returns {JSX}
|
|
4
|
-
*/var OrderDetailsProvider=function OrderDetailsProvider(_ref){var order=_ref.order,orderNumber=_ref.orderNumber,shopSettings=_ref.shopSettings,userLocation=_ref.userLocation,fetchOrderDetails=_ref.fetchOrderDetails,cancelOrder=_ref.cancelOrder,children=_ref.children;var _useRoute=useRoute(),pathname=_useRoute.pathname;var _useState=useState(false),_useState2=_slicedToArray(_useState,2),isLoading=_useState2[0],setIsLoading=_useState2[1];var handleRequest=useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(){return _regeneratorRuntime.wrap(function _callee$(_context){while(1)
|
|
4
|
+
*/var OrderDetailsProvider=function OrderDetailsProvider(_ref){var order=_ref.order,orderNumber=_ref.orderNumber,shopSettings=_ref.shopSettings,userLocation=_ref.userLocation,fetchOrderDetails=_ref.fetchOrderDetails,cancelOrder=_ref.cancelOrder,children=_ref.children;var _useRoute=useRoute(),pathname=_useRoute.pathname;var _useState=useState(false),_useState2=_slicedToArray(_useState,2),isLoading=_useState2[0],setIsLoading=_useState2[1];var handleRequest=useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(){return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:setIsLoading(true);_context.next=3;return fetchOrderDetails(orderNumber);case 3:setIsLoading(false);case 4:case"end":return _context.stop();}},_callee);})),[fetchOrderDetails,orderNumber]);var handleCancel=useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(){return _regeneratorRuntime.wrap(function _callee2$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:setIsLoading(true);_context2.next=3;return cancelOrder(orderNumber);case 3:setIsLoading(false);case 4:case"end":return _context2.stop();}},_callee2);})),[cancelOrder,orderNumber]);// Loading state
|
|
5
5
|
useEffect(function(){if(isLoading){LoadingProvider.setLoading(pathname);return;}LoadingProvider.unsetLoading(pathname);},[isLoading,pathname]);useEffect(function(){handleRequest();},[handleRequest]);var value=useMemo(function(){return{order:order,isLoading:isLoading,supportedCountries:shopSettings.supportedCountries,countrySortOrder:shopSettings.countrySortOrder,userLocation:userLocation,fetchOrderDetails:fetchOrderDetails,cancelOrder:handleCancel};},[order,isLoading,shopSettings.supportedCountries,shopSettings.countrySortOrder,userLocation,fetchOrderDetails,handleCancel]);return React.createElement(Context.Provider,{value:value},children);};OrderDetailsProvider.defaultProps={children:null,shopSettings:null,userLocation:null,order:null};export default connect(OrderDetailsProvider);
|
|
@@ -6,6 +6,6 @@ import _regeneratorRuntime from"@babel/runtime/regenerator";function asyncGenera
|
|
|
6
6
|
* @param {Object} props The component props.
|
|
7
7
|
* @returns {JSX}
|
|
8
8
|
*/var OrderDetailsProvider=function OrderDetailsProvider(_ref){var isUserLoggedIn=_ref.isUserLoggedIn,order=_ref.order,orderId=_ref.orderId,shopSettings=_ref.shopSettings,userLocation=_ref.userLocation,fetchOrderDetails=_ref.fetchOrderDetails,cancelOrder=_ref.cancelOrder,children=_ref.children;var _useRoute=useRoute(),pathname=_useRoute.pathname;var _useState=useState(!isUserLoggedIn),_useState2=_slicedToArray(_useState,2),showForm=_useState2[0],setShowForm=_useState2[1];var _useState3=useState(false),_useState4=_slicedToArray(_useState3,2),isLoading=_useState4[0],setIsLoading=_useState4[1];var _useState5=useState(''),_useState6=_slicedToArray(_useState5,2),errorMessage=_useState6[0],setErrorMessage=_useState6[1];var orderTokenCookie=["shopgate_order_token_".concat(orderId)];var _useCookies=useCookies([orderTokenCookie]),_useCookies2=_slicedToArray(_useCookies,2),cookies=_useCookies2[0],setCookie=_useCookies2[1];var orderToken=cookies[orderTokenCookie];// Form visibility
|
|
9
|
-
useEffect(function(){if(isUserLoggedIn){setShowForm(errorMessage);}else{setShowForm(!order&&!orderToken||errorMessage);}},[errorMessage,isUserLoggedIn,order,orderToken]);var handleRequest=useCallback(/*#__PURE__*/function(){var _ref2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(email,phone,token){var message,response,code;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)
|
|
10
|
-
useEffect(function(){if(isLoading){LoadingProvider.setLoading(pathname);return;}LoadingProvider.unsetLoading(pathname);},[isLoading,pathname]);useEffect(function(){if(!isUserLoggedIn&&!orderToken){return;}_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(){return _regeneratorRuntime.wrap(function _callee3$(_context3){while(1)
|
|
11
|
-
var handleAuthenticateFormSubmit=useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(){var _authenticateFormStat,email,phone;return _regeneratorRuntime.wrap(function _callee4$(_context4){while(1)
|
|
9
|
+
useEffect(function(){if(isUserLoggedIn){setShowForm(errorMessage);}else{setShowForm(!order&&!orderToken||errorMessage);}},[errorMessage,isUserLoggedIn,order,orderToken]);var handleRequest=useCallback(/*#__PURE__*/function(){var _ref2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(email,phone,token){var message,response,code;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:setIsLoading(true);_context.prev=1;_context.next=4;return fetchOrderDetails(orderId,{email:email,phone:phone,token:token});case 4:response=_context.sent;if(response.token&&response.tokenExpires){setCookie(orderTokenCookie,response.token,{expires:new Date(response.tokenExpires)});}setErrorMessage('');_context.next=13;break;case 9:_context.prev=9;_context.t0=_context["catch"](1);code=_context.t0.code;if(code===EUNAUTHORIZED){message='order_details.errors.authorize';}else if(code===EAUTHENTICATION){message='order_details.errors.authenticate';}else if(code===ENOTFOUND){message='order_details.errors.not_found';}case 13:if(message){setErrorMessage(i18n.text(message));}setIsLoading(false);case 15:case"end":return _context.stop();}},_callee,null,[[1,9]]);}));return function(_x,_x2,_x3){return _ref2.apply(this,arguments);};}(),[fetchOrderDetails,orderTokenCookie,orderId,setCookie]);var handleCancel=useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(){var message,code;return _regeneratorRuntime.wrap(function _callee2$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:setIsLoading(true);_context2.prev=1;_context2.next=4;return cancelOrder(orderId,orderToken);case 4:setErrorMessage('');_context2.next=11;break;case 7:_context2.prev=7;_context2.t0=_context2["catch"](1);code=_context2.t0.code;if(code===EAUTHENTICATION){message='order_details.errors.expired';}else if(code===ENOTFOUND){message='order_details.errors.not_found';}case 11:if(message){setErrorMessage(i18n.text(message));}setIsLoading(false);case 13:case"end":return _context2.stop();}},_callee2,null,[[1,7]]);})),[cancelOrder,orderId,orderToken]);// Loading state
|
|
10
|
+
useEffect(function(){if(isLoading){LoadingProvider.setLoading(pathname);return;}LoadingProvider.unsetLoading(pathname);},[isLoading,pathname]);useEffect(function(){if(!isUserLoggedIn&&!orderToken){return;}_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(){return _regeneratorRuntime.wrap(function _callee3$(_context3){while(1)switch(_context3.prev=_context3.next){case 0:_context3.next=2;return handleRequest(undefined,undefined,!isUserLoggedIn?orderToken:undefined);case 2:case"end":return _context3.stop();}},_callee3);}))();/* eslint-disable react-hooks/exhaustive-deps */},[]);/* eslint-enable react-hooks/exhaustive-deps */var authenticateFormState={valid:false,values:[]};// Authentication form
|
|
11
|
+
var handleAuthenticateFormSubmit=useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(){var _authenticateFormStat,email,phone;return _regeneratorRuntime.wrap(function _callee4$(_context4){while(1)switch(_context4.prev=_context4.next){case 0:if(authenticateFormState.valid){_context4.next=2;break;}return _context4.abrupt("return");case 2:_authenticateFormStat=authenticateFormState.values,email=_authenticateFormStat.email,phone=_authenticateFormStat.phone;_context4.next=5;return handleRequest(email,phone);case 5:case"end":return _context4.stop();}},_callee4);})),[authenticateFormState.valid,authenticateFormState.values,handleRequest]);authenticateFormState=useFormState(defaultFormState,handleAuthenticateFormSubmit,authenticateConstraints);var handleSubmit=useCallback(function(){authenticateFormState.handleSubmit(new Event('submit'));},[authenticateFormState]);var value=useMemo(function(){return{isUserLoggedIn:isUserLoggedIn,order:order,handleSubmit:handleSubmit,isLoading:isLoading,showForm:showForm,supportedCountries:shopSettings.supportedCountries,countrySortOrder:shopSettings.countrySortOrder,validationErrors:convertValidationErrors(authenticateFormState.validationErrors||{}),updateForm:authenticateFormState.setValues,defaultFormState:defaultFormState,userLocation:userLocation,fetchOrderDetails:fetchOrderDetails,cancelOrder:handleCancel,errorMessage:errorMessage};},[authenticateFormState.setValues,authenticateFormState.validationErrors,fetchOrderDetails,handleCancel,handleSubmit,isUserLoggedIn,showForm,isLoading,order,shopSettings.supportedCountries,shopSettings.countrySortOrder,userLocation,errorMessage]);return React.createElement(Context.Provider,{value:value},children);};OrderDetailsProvider.defaultProps={children:null,shopSettings:null,userLocation:null,order:null,orderId:null};export default connect(OrderDetailsProvider);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shopgate/engage",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.20.0-beta.10",
|
|
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.
|
|
20
|
-
"@shopgate/pwa-common-commerce": "7.
|
|
21
|
-
"@shopgate/pwa-core": "7.
|
|
22
|
-
"@shopgate/pwa-ui-ios": "7.
|
|
23
|
-
"@shopgate/pwa-ui-material": "7.
|
|
24
|
-
"@shopgate/pwa-ui-shared": "7.
|
|
19
|
+
"@shopgate/pwa-common": "7.20.0-beta.10",
|
|
20
|
+
"@shopgate/pwa-common-commerce": "7.20.0-beta.10",
|
|
21
|
+
"@shopgate/pwa-core": "7.20.0-beta.10",
|
|
22
|
+
"@shopgate/pwa-ui-ios": "7.20.0-beta.10",
|
|
23
|
+
"@shopgate/pwa-ui-material": "7.20.0-beta.10",
|
|
24
|
+
"@shopgate/pwa-ui-shared": "7.20.0-beta.10",
|
|
25
25
|
"@stripe/react-stripe-js": "^1.1.2",
|
|
26
26
|
"@stripe/stripe-js": "^1.3.1",
|
|
27
27
|
"@virtuous/conductor": "~2.5.0",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"validate.js": "^0.13.1"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"classnames": "
|
|
46
|
+
"classnames": "2.3.3",
|
|
47
47
|
"jest-mock-console": "^0.4.2",
|
|
48
48
|
"lodash": "^4.17.11",
|
|
49
49
|
"prop-types": "~15.7.2",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{default as fetchPageConfig}from'@shopgate/pwa-common/actions/page/fetchPageConfig';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{default as NotFound}from"./NotFound";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{PAGE_PATH,PAGE_PATTERN}from'@shopgate/pwa-common/constants/RoutePaths';export*from'@shopgate/pwa-common/constants/PageIDs';export{PAGE_PATH,PAGE_PATTERN};export var IMPRINT_PATH="".concat(PAGE_PATH,"/imprint");export var PAYMENT_PATH="".concat(PAGE_PATH,"/payment");export var PRIVACY_PATH="".concat(PAGE_PATH,"/privacy");export var RETURN_POLICY_PATH="".concat(PAGE_PATH,"/return_policy");export var SHIPPING_PATH="".concat(PAGE_PATH,"/shipping");export var TERMS_PATH="".concat(PAGE_PATH,"/terms");
|
package/page/index.js
CHANGED
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
/** @module page */
|
|
2
|
-
export
|
|
3
|
-
export*from'@shopgate/pwa-common/constants/PageIDs';export{PAGE_PATH,PAGE_PATTERN};// SELECTORS
|
|
4
|
-
export*from'@shopgate/pwa-common/selectors/page';export{default as NotFound}from"./NotFound";
|
|
1
|
+
/** @module page */export*from"./actions";export*from"./components";export*from"./constants";// eslint-disable-next-line import/export
|
|
2
|
+
export*from"./selectors";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{createSelector}from'reselect';import{makeGetMenu,makeGetIsFetchingMenu}from'@shopgate/engage/core/selectors';import{LEGAL_MENU}from'@shopgate/engage/core/constants';import{hasNewServices}from'@shopgate/engage/core';import{PRIVACY_PATH}from"../constants";export*from'@shopgate/pwa-common/selectors/page';/**
|
|
2
|
+
* Creates a selector that retrieves the privacy policy link.
|
|
3
|
+
*
|
|
4
|
+
* When the new services are active, the link is extracted from the "shopgate.cms.getMenu" response.
|
|
5
|
+
* Otherwise it's a static link to the legacy privacy page.
|
|
6
|
+
* @returns {string|null}
|
|
7
|
+
*/export var makeGetPrivacyPolicyLink=function makeGetPrivacyPolicyLink(){var getMenu=makeGetMenu(LEGAL_MENU);var getIsFetchingMenu=makeGetIsFetchingMenu(LEGAL_MENU);return createSelector(getMenu,getIsFetchingMenu,function(menu,fetching){if(!hasNewServices()){return PRIVACY_PATH;}if(fetching||!menu){return null;}var entry=menu.find(function(item){return item.url.includes('privacy');})||{};return(entry===null||entry===void 0?void 0:entry.url)||null;});};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{default as productImageFormats}from'@shopgate/pwa-common-commerce/product/collections/ProductImageFormats';
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import{connect}from'react-redux';import{getProduct}from'@shopgate/pwa-common-commerce/product/selectors/product';import{AVAILABILITY_STATE_OK}from'@shopgate/pwa-common-commerce/product/constants';/**
|
|
2
|
-
*
|
|
3
|
-
* @
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
availability:!product.stock?null:{text:product.stock.info,state:AVAILABILITY_STATE_OK},fulfillmentMethods:product.fulfillmentMethods||null};}export default connect(mapStateToProps);
|
|
2
|
+
* Creates the mapStateToProps connector function.
|
|
3
|
+
* @returns {Function}
|
|
4
|
+
*/var makeMapStateToProps=function makeMapStateToProps(){return function(state,props){var product=getProduct(state,props);if(!product){return{availability:null,fulfillmentMethods:null};}return{// Show stock info always as availability on PDP
|
|
5
|
+
availability:!product.stock?null:{text:product.stock.info,state:AVAILABILITY_STATE_OK},fulfillmentMethods:product.fulfillmentMethods||null};};};export default connect(makeMapStateToProps);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import*as React from'react';import classNames from'classnames';import{SurroundPortals,PlaceholderLabel,Availability as AvailableText}from'@shopgate/engage/components';import{PRODUCT_AVAILABILITY}from'@shopgate/engage/product';import connect from"./Availability.connector";import{placeholder,availability as availabilityStyle}from"./Availability.style";/**
|
|
1
|
+
import*as React from'react';import PropTypes from'prop-types';import classNames from'classnames';import{AVAILABILITY_STATE_OK,AVAILABILITY_STATE_WARNING,AVAILABILITY_STATE_ALERT}from'@shopgate/pwa-common-commerce/product/constants';import{SurroundPortals,PlaceholderLabel,Availability as AvailableText}from'@shopgate/engage/components';import{PRODUCT_AVAILABILITY}from'@shopgate/engage/product';import{hasNewServices}from'@shopgate/engage/core/helpers';import connect from"./Availability.connector";import{placeholder,availability as availabilityStyle}from"./Availability.style";/**
|
|
2
2
|
* The Availability component.
|
|
3
3
|
* @param {Object} props The component props.
|
|
4
4
|
* @return {JSX}
|
|
5
|
-
*/function Availability(
|
|
6
|
-
if(!fulfillmentMethods||fulfillmentMethods.indexOf(fulfillmentSelection)!==-1){return null;}var classes=classNames(placeholder,className?className.toString():null);return React.createElement(SurroundPortals,{portalName:PRODUCT_AVAILABILITY,portalProps:{availability:availability}},React.createElement(PlaceholderLabel,{className:classes,ready:availability!==null},availability&&React.createElement(AvailableText,{className:availabilityStyle,showWhenAvailable:true,text:availability.text,state:availability.state})));}Availability.defaultProps={availability:null,fulfillmentMethods:null,fulfillmentSelection:'',className:null};export default connect(React.memo(Availability));
|
|
5
|
+
*/function Availability(_ref){var availability=_ref.availability,fulfillmentMethods=_ref.fulfillmentMethods,fulfillmentSelection=_ref.fulfillmentSelection,className=_ref.className;// Render only when no fulfillment methods are available or when the given method exists
|
|
6
|
+
if(hasNewServices()&&(!fulfillmentMethods||fulfillmentMethods.indexOf(fulfillmentSelection)!==-1)){return null;}var classes=classNames(placeholder,className?className.toString():null);return React.createElement(SurroundPortals,{portalName:PRODUCT_AVAILABILITY,portalProps:{availability:availability}},React.createElement(PlaceholderLabel,{className:classes,ready:availability!==null},availability&&React.createElement(AvailableText,{className:availabilityStyle,showWhenAvailable:true,text:availability.text||'',state:availability.state})));}Availability.defaultProps={availability:null,fulfillmentMethods:null,fulfillmentSelection:'',className:null};export default connect(React.memo(Availability));
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}function _objectDestructuringEmpty(obj){if(obj==null)throw new TypeError("Cannot destructure undefined");}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 _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}function _callSuper(_this,derived,args){function isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(e){return false;}}derived=_getPrototypeOf(derived);return _possibleConstructorReturn(_this,isNativeReflectConstruct()?Reflect.construct(derived,args||[],_getPrototypeOf(_this).constructor):derived.apply(_this,args));}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import React,{PureComponent,Fragment}from'react';import PropTypes from'prop-types';import{SheetDrawer,SheetList,Menu,ResponsiveContainer}from'@shopgate/engage/components';import{ThemeContext}from'@shopgate/engage/core/contexts';import{VariantContext,ProductContext}from'@shopgate/engage/product/contexts';import{VariantAvailability}from'@shopgate/engage/product/components';import{ViewContext}from'@shopgate/engage/components/View';import Item from"../SheetItem";/**
|
|
2
|
+
* The CharacteristicSheet component.
|
|
3
|
+
*/var CharacteristicSheet=/*#__PURE__*/function(_PureComponent){function CharacteristicSheet(){var _this2;_classCallCheck(this,CharacteristicSheet);for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}_this2=_callSuper(this,CharacteristicSheet,[].concat(args));_defineProperty(_this2,"firstSelectableItemRef",React.createRef());/**
|
|
4
|
+
* Focuses the first selectable item and hides the view for screen readers.
|
|
5
|
+
*/_defineProperty(_this2,"onDidOpen",function(){if(_this2.firstSelectableItemRef.current){_this2.firstSelectableItemRef.current.focus();}_this2.props.setViewAriaHidden(true);});/**
|
|
6
|
+
* Shows the view for screen readers.
|
|
7
|
+
* @param {Object} e The event payload.
|
|
8
|
+
*/_defineProperty(_this2,"onClose",function(e){_this2.props.onClose(e);_this2.props.setViewAriaHidden(false);});/**
|
|
9
|
+
* @param {Object} event The event object.
|
|
10
|
+
* @param {string} itemId The id that was selected
|
|
11
|
+
*/_defineProperty(_this2,"handleItemClick",function(event,itemId){event.stopPropagation();_this2.props.onSelect(itemId);});/**
|
|
12
|
+
* Renders the availability text inside the sheet item.
|
|
13
|
+
* @param {string} value The value that the sheet item represents.
|
|
14
|
+
* @return {React.Component|null}
|
|
15
|
+
*/_defineProperty(_this2,"renderAvailability",function(value){var _this2$props=_this2.props,fulfillmentMethods=_this2$props.fulfillmentMethods,isFetching=_this2$props.isFetching;if(fulfillmentMethods||isFetching){return null;}var selection=_extends({},_this2.props.selection,_defineProperty({},_this2.props.charId,value));return React.createElement(VariantAvailability,{characteristics:selection,productId:_this2.props.productId});});return _this2;}_inherits(CharacteristicSheet,_PureComponent);return _createClass(CharacteristicSheet,[{key:"render",value:/**
|
|
16
|
+
* @return {JSX}
|
|
17
|
+
*/function render(){var _this3=this;var _this$props=this.props,items=_this$props.items,label=_this$props.label,open=_this$props.open,selectedValue=_this$props.selectedValue,contextRef=_this$props.contextRef;var selectedIndex;if(selectedValue){selectedIndex=items.findIndex(function(item){return item.id===selectedValue;});}else{selectedIndex=items.findIndex(function(item){return item.selectable;});}return React.createElement(Fragment,null,React.createElement(ResponsiveContainer,{appAlways:true,breakpoint:"xs"},React.createElement(SheetDrawer,{title:label,isOpen:open,onClose:this.onClose,onDidOpen:this.onDidOpen},React.createElement(SheetList,{className:"theme__product__characteristic__sheet"},items.map(function(item,index){return React.createElement(Item,{item:item,key:item.id,onClick:_this3.handleItemClick,rightComponent:function rightComponent(){return _this3.renderAvailability(item.id);},selected:item.id===selectedValue,ref:index===selectedIndex?_this3.firstSelectableItemRef:null,characteristics:_extends({},_this3.props.selection,_defineProperty({},_this3.props.charId,item.id))});})))),React.createElement(ResponsiveContainer,{webOnly:true,breakpoint:">xs"},React.createElement(ThemeContext.Consumer,null,function(_ref){var contextProps=_extends({},(_objectDestructuringEmpty(_ref),_ref));return React.createElement(Menu,{isOpen:open,onClose:_this3.onClose,contextRef:contextRef},React.createElement(ThemeContext.Provider,{value:contextProps},items.map(function(item,index){return React.createElement(Item,{key:item.id,item:item,onClick:_this3.handleItemClick,rightComponent:function rightComponent(){return _this3.renderAvailability(item.id);},selected:item.id===selectedValue,ref:index===selectedIndex?_this3.firstSelectableItemRef:null,characteristics:_extends({},_this3.props.selection,_defineProperty({},_this3.props.charId,item.id))});})));})));}}]);}(PureComponent);/**
|
|
18
|
+
* @param {Object} props The original component props.
|
|
19
|
+
* @returns {JSX}
|
|
20
|
+
*/_defineProperty(CharacteristicSheet,"defaultProps",{fulfillmentMethods:null,onClose:function onClose(){},onSelect:function onSelect(){},productId:null,selectedValue:null,contextRef:null,selection:null,isFetching:false});var SheetComponent=function SheetComponent(props){return React.createElement(ViewContext.Consumer,null,function(_ref2){var setAriaHidden=_ref2.setAriaHidden;return React.createElement(ProductContext.Consumer,null,function(_ref3){var productId=_ref3.productId,fulfillmentMethods=_ref3.fulfillmentMethods,isFetching=_ref3.isFetching;return React.createElement(VariantContext.Consumer,null,function(_ref4){var characteristics=_ref4.characteristics;return React.createElement(CharacteristicSheet,_extends({productId:productId,selection:characteristics,setViewAriaHidden:setAriaHidden,fulfillmentMethods:fulfillmentMethods,isFetching:isFetching},props));});});});};export default SheetComponent;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}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 _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}function _callSuper(_this,derived,args){function isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(e){return false;}}derived=_getPrototypeOf(derived);return _possibleConstructorReturn(_this,isNativeReflectConstruct()?Reflect.construct(derived,args||[],_getPrototypeOf(_this).constructor):derived.apply(_this,args));}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import React,{PureComponent}from'react';import PropTypes from'prop-types';import classNames from'classnames';import{withForwardedRef}from'@shopgate/engage/core/hocs';import{CharacteristicsButton}from'@shopgate/engage/back-in-stock/components';import styles from"./style";/**
|
|
2
|
+
* The SheetItem component.
|
|
3
|
+
*/var SheetItem=/*#__PURE__*/function(_PureComponent){function SheetItem(){var _this2;_classCallCheck(this,SheetItem);for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}_this2=_callSuper(this,SheetItem,[].concat(args));/**
|
|
4
|
+
* @param {boolean} selectable Whether or not the item can be selected.
|
|
5
|
+
* @returns {string}
|
|
6
|
+
*/_defineProperty(_this2,"getStyle",function(selectable){if(!selectable){return styles.buttonDisabled;}return styles.button;});/**
|
|
7
|
+
* @returns {Object}
|
|
8
|
+
*/_defineProperty(_this2,"buildProps",function(){var _this2$props=_this2.props,item=_this2$props.item,_onClick=_this2$props.onClick,forwardedRef=_this2$props.forwardedRef;return _extends({className:"".concat(_this2.getStyle(item.selectable).toString()," theme__product__characteristic__option"),key:item.id,ref:forwardedRef,value:item.id,'aria-hidden':!item.selectable},item.selectable&&{onClick:function onClick(event){return _onClick(event,item.id);}});});return _this2;}_inherits(SheetItem,_PureComponent);return _createClass(SheetItem,[{key:"render",value:/**
|
|
9
|
+
* @returns {JSX}
|
|
10
|
+
*/function render(){var _this$props=this.props,item=_this$props.item,Right=_this$props.rightComponent,selected=_this$props.selected,characteristics=_this$props.characteristics;return React.createElement("div",{className:classNames(styles.root,_defineProperty({},styles.rootSelected,selected))},React.createElement("button",_extends({},this.buildProps(),{"data-test-id":item.label,"aria-selected":selected,role:"option",type:"button"}),React.createElement("div",{className:styles.mainRow},React.createElement("div",null,item.label),React.createElement("div",{className:styles.mainRowRight},item.selectable&&React.createElement(Right,null)))),React.createElement("div",{className:styles.bottomRow},item.selectable&&React.createElement(CharacteristicsButton,{characteristics:characteristics})));}}]);}(PureComponent);_defineProperty(SheetItem,"defaultProps",{forwardedRef:null,onClick:function onClick(){},rightComponent:null,selected:false});export default withForwardedRef(SheetItem);
|
|
@@ -0,0 +1 @@
|
|
|
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{css}from'glamor';import{themeConfig}from'@shopgate/pwa-common/helpers/config';import{responsiveMediaQuery}from'@shopgate/engage/styles';var colors=themeConfig.colors;var button=css({outline:0,textAlign:'left',paddingLeft:0,paddingRight:0,width:'100%',display:'flex',justifyContent:'space-between',flexWrap:'wrap',color:'var(--color-text-high-emphasis)'});var buttonDisabled=css(button,{color:colors.shade4});var root=css(_defineProperty({padding:'16px 0'},responsiveMediaQuery('>xs',{webOnly:true}),{padding:'8px 16px'}));var rootSelected=css(button,_defineProperty({background:"var(--color-background-accent, ".concat(colors.darkGray,")"),boxShadow:"-16px 0 0 var(--color-background-accent, ".concat(colors.darkGray,"), 16px 0 0 var(--color-background-accent, ").concat(colors.darkGray,")"),margin:'-1px 0',paddingTop:17,paddingBottom:17,fontWeight:500},responsiveMediaQuery('>xs',{webOnly:true}),{margin:0,paddingTop:8,paddingBottom:8,padding:'8px 16px',boxShadow:'none'}));var mainRow=css({display:'flex',flexWrap:'wrap',gap:'4px 8px',justifyContent:'space-between',width:'100%'}).toString();var mainRowRight=css({marginLeft:'auto'}).toString();var bottomRow=css({'&:not(:empty)':{textAlign:'right'}}).toString();export default{root:root,rootSelected:rootSelected,button:button,buttonDisabled:buttonDisabled,mainRow:mainRow,mainRowRight:mainRowRight,bottomRow:bottomRow};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
function _typeof(obj){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}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 _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}function _callSuper(_this,derived,args){function isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(e){return false;}}derived=_getPrototypeOf(derived);return _possibleConstructorReturn(_this,isNativeReflectConstruct()?Reflect.construct(derived,args||[],_getPrototypeOf(_this).constructor):derived.apply(_this,args));}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}return _assertThisInitialized(self);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import React,{PureComponent,Fragment}from'react';import PropTypes from'prop-types';import classNames from'classnames';import Transition from'react-transition-group/Transition';import{ResponsiveContainer,ArrowDropIcon}from'@shopgate/engage/components';import Sheet from"./components/Sheet";import styles from"./style";import transition from"../transition";/**
|
|
2
|
+
* A single characteristic.
|
|
3
|
+
*/var Characteristic=/*#__PURE__*/function(_PureComponent){function Characteristic(){var _this2;_classCallCheck(this,Characteristic);for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}_this2=_callSuper(this,Characteristic,[].concat(args));_defineProperty(_this2,"state",{highlight:false,sheet:false});/**
|
|
4
|
+
* @param {string} defaultLabel The default button label.
|
|
5
|
+
* @return {string}
|
|
6
|
+
*/_defineProperty(_this2,"getButtonLabel",function(defaultLabel){if(!_this2.props.selected){return defaultLabel;}var value=_this2.props.values.find(function(val){return val.id===_this2.props.selected;});return value.label;});/**
|
|
7
|
+
* @param {Object} event The event object.
|
|
8
|
+
*/_defineProperty(_this2,"handleButtonClick",function(event){event.preventDefault();if(_this2.props.disabled){return;}_this2.setState({sheet:true});});/**
|
|
9
|
+
* @param {string} valueId The ID of the selected value.
|
|
10
|
+
*/_defineProperty(_this2,"handleItemSelection",function(valueId){_this2.props.select({id:_this2.props.id,value:valueId});_this2.closeSheet();});_defineProperty(_this2,"closeSheet",function(){_this2.setState({sheet:false});if(_this2.props.charRef&&_this2.props.charRef.current){_this2.props.charRef.current.focus();}});_defineProperty(_this2,"removeHighlight",function(){_this2.setState({highlight:false});});/**
|
|
11
|
+
* Renders the transition contents.
|
|
12
|
+
* @param {string} state The current transition state.
|
|
13
|
+
* @returns {JSX}
|
|
14
|
+
*/_defineProperty(_this2,"transitionRenderer",function(state){var _this2$context$i18n=_this2.context.i18n(),__=_this2$context$i18n.__;var _this2$props=_this2.props,disabled=_this2$props.disabled,selected=_this2$props.selected,charRef=_this2$props.charRef,label=_this2$props.label;var translatedLabel=__('product.pick_an_attribute',[label]);var buttonLabel=_this2.getButtonLabel(translatedLabel);var classes=classNames(styles.button,_defineProperty({},styles.buttonDisabled,disabled),'theme__product__characteristic');return React.createElement("div",{role:"button","aria-disabled":disabled,"aria-haspopup":!disabled,tabIndex:0,className:classes,onClick:_this2.handleButtonClick,onKeyDown:function onKeyDown(){},ref:charRef,style:transition[state],"data-test-id":label},selected&&React.createElement("div",{className:"".concat(styles.label," theme__product__characteristic__label")},label),React.createElement("div",_extends({className:"".concat(styles.selection," theme__product__characteristic__selection")},selected&&{'data-selected':true}),buttonLabel),React.createElement(ResponsiveContainer,{breakpoint:">xs",webOnly:true},React.createElement("div",{className:styles.arrow},React.createElement(ArrowDropIcon,null))));});return _this2;}_inherits(Characteristic,_PureComponent);return _createClass(Characteristic,[{key:"UNSAFE_componentWillReceiveProps",value:/**
|
|
15
|
+
* @param {Object} nextProps The next component props.
|
|
16
|
+
*/function UNSAFE_componentWillReceiveProps(nextProps){this.setState({highlight:nextProps.highlight});}},{key:"render",value:/**
|
|
17
|
+
* @return {JSX}
|
|
18
|
+
*/function render(){var _this$context$i18n=this.context.i18n(),__=_this$context$i18n.__;var _this$props=this.props,id=_this$props.id,selected=_this$props.selected,values=_this$props.values,charRef=_this$props.charRef;var displayLabel=this.props.label;var translatedLabel=__('product.pick_an_attribute',[displayLabel]);return React.createElement(Fragment,null,React.createElement(Transition,{"in":this.state.highlight,timeout:500,onEntered:this.removeHighlight},this.transitionRenderer),React.createElement(Sheet,{charId:id,contextRef:charRef,items:values,label:translatedLabel,onClose:this.closeSheet,onSelect:this.handleItemSelection,open:this.state.sheet,selectedValue:selected}));}}]);}(PureComponent);_defineProperty(Characteristic,"contextTypes",{i18n:PropTypes.func});_defineProperty(Characteristic,"defaultProps",{selected:null});export default Characteristic;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{css}from'glamor';import{themeColors}from'@shopgate/pwa-common/helpers/config';var button=css({background:"var(--color-background-accent, ".concat(themeColors.overlay,")"),color:'var(--color-text-high-emphasis)',position:'relative',cursor:'pointer',display:'flex',flexDirection:'column',justifyContent:'center',minHeight:56,outline:0,padding:'12px 16px',marginBottom:8,transition:'background 250ms ease-in, color 250ms ease-in'}).toString();var buttonDisabled=css({color:"".concat(themeColors.shade4," !important")}).toString();var label=css({fontSize:12,marginTop:-2,marginBottom:4}).toString();var selection=css({fontWeight:500,lineHeight:1.125}).toString();var arrow=css({position:'absolute',right:32,fontSize:20}).toString();export default{arrow:arrow,button:button,buttonDisabled:buttonDisabled,label:label,selection:selection};
|