@sonic-equipment/ui 133.0.0 → 135.0.0

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.
Files changed (79) hide show
  1. package/dist/address/address.d.ts +5 -2
  2. package/dist/address/address.js +3 -2
  3. package/dist/algolia/{algolia-intialization.js → algolia-initialization.js} +7 -0
  4. package/dist/algolia/algolia-insights-provider.js +7 -0
  5. package/dist/algolia/algolia-search-provider.js +19 -0
  6. package/dist/algolia/use-algolia-insights.d.ts +13 -6
  7. package/dist/algolia/use-algolia-insights.js +93 -10
  8. package/dist/buttons/button/button.d.ts +4 -1
  9. package/dist/buttons/button/button.js +2 -2
  10. package/dist/country-selector/country-select/country-select.d.ts +1 -0
  11. package/dist/country-selector/country-select/country-select.js +2 -2
  12. package/dist/delivery-time/delivery-time.js +1 -1
  13. package/dist/exports.d.ts +10 -2
  14. package/dist/forms/checkbox/checkbox.d.ts +2 -1
  15. package/dist/forms/checkbox/checkbox.js +2 -2
  16. package/dist/forms/field-error/field-error.d.ts +2 -1
  17. package/dist/forms/field-error/field-error.js +3 -2
  18. package/dist/forms/input/input.d.ts +1 -0
  19. package/dist/forms/input/input.js +2 -2
  20. package/dist/forms/label/label.d.ts +3 -1
  21. package/dist/forms/label/label.js +3 -2
  22. package/dist/forms/switch/switch.d.ts +2 -1
  23. package/dist/forms/switch/switch.js +2 -2
  24. package/dist/forms/text-field/text-field.d.ts +3 -1
  25. package/dist/forms/text-field/text-field.js +4 -3
  26. package/dist/forms/text-field/text-field.module.css.js +1 -1
  27. package/dist/forms/textarea/textarea.d.ts +1 -0
  28. package/dist/forms/textarea/textarea.js +3 -2
  29. package/dist/global-search/plugins/categories-plugin.js +2 -1
  30. package/dist/global-search/plugins/popular-categories-plugin.js +2 -0
  31. package/dist/global-search/plugins/query-suggestions-plugin.js +1 -0
  32. package/dist/global-search/plugins/quick-access-plugin.js +2 -2
  33. package/dist/global-search/search-result-panel/sections/with-results.js +0 -1
  34. package/dist/header/hamburger-button/hamburger-button.d.ts +6 -0
  35. package/dist/header/hamburger-button/hamburger-button.js +14 -0
  36. package/dist/header/hamburger-button/hamburger-button.module.css.js +3 -0
  37. package/dist/header/header-layout/header-layout.d.ts +9 -0
  38. package/dist/header/header-layout/header-layout.js +8 -0
  39. package/dist/header/header-layout/header-layout.module.css.js +3 -0
  40. package/dist/header/sonic-logo/sonic-logo.d.ts +5 -0
  41. package/dist/header/sonic-logo/sonic-logo.js +11 -0
  42. package/dist/header/sonic-logo/sonic-logo.module.css.js +3 -0
  43. package/dist/index.js +11 -3
  44. package/dist/info-icon-tooltip/info-icon-tooltip.d.ts +7 -0
  45. package/dist/info-icon-tooltip/info-icon-tooltip.js +20 -0
  46. package/dist/info-icon-tooltip/info-icon-tooltip.module.css.js +3 -0
  47. package/dist/intl/translation-id.d.ts +1 -1
  48. package/dist/pages/checkout/components/billing-and-invoice-information.js +1 -1
  49. package/dist/pages/checkout/order-confirmation-page/order-confirmation-page-content.d.ts +5 -0
  50. package/dist/pages/checkout/order-confirmation-page/order-confirmation-page-content.js +83 -0
  51. package/dist/pages/checkout/order-confirmation-page/order-confirmation-page.js +3 -77
  52. package/dist/pages/checkout/payment-page/components/payment.js +49 -4
  53. package/dist/pages/checkout/payment-page/payment-page-content.d.ts +15 -0
  54. package/dist/pages/checkout/payment-page/payment-page-content.js +43 -0
  55. package/dist/pages/checkout/payment-page/payment-page.js +3 -37
  56. package/dist/pages/checkout/shipping-page/components/edit-address.js +3 -3
  57. package/dist/pages/checkout/shipping-page/components/readonly-address.js +25 -1
  58. package/dist/pages/checkout/shipping-page/shipping-page-content.d.ts +14 -0
  59. package/dist/pages/checkout/shipping-page/shipping-page-content.js +40 -0
  60. package/dist/pages/checkout/shipping-page/shipping-page.js +45 -54
  61. package/dist/pages/product/product-details-page/components/product-details-panel/product-details-panel.js +11 -1
  62. package/dist/pages/product/product-listing-page/product-listing-product-overview/product-listing-product-overview.js +0 -1
  63. package/dist/pages/product/search-result-page/search-result-product-overview/search-result-product-overview.js +0 -1
  64. package/dist/shared/fetch/request.d.ts +18 -13
  65. package/dist/shared/fetch/request.js +22 -9
  66. package/dist/shared/ga/use-data-layer.d.ts +7 -3
  67. package/dist/shared/ga/use-data-layer.js +6 -1
  68. package/dist/shared/utils/promise.d.ts +2 -0
  69. package/dist/shared/utils/promise.js +9 -0
  70. package/dist/sign-in-form/sign-in-form.d.ts +19 -0
  71. package/dist/sign-in-form/sign-in-form.js +49 -0
  72. package/dist/sign-in-form/sign-in-form.module.css.js +3 -0
  73. package/dist/styles.css +338 -44
  74. package/dist/tooltip/tooltip.d.ts +3 -2
  75. package/dist/tooltip/tooltip.js +5 -4
  76. package/package.json +1 -1
  77. package/dist/shared/utils/wait.d.ts +0 -1
  78. package/dist/shared/utils/wait.js +0 -5
  79. /package/dist/algolia/{algolia-intialization.d.ts → algolia-initialization.d.ts} +0 -0
@@ -1,6 +1,7 @@
1
1
  import { jsxs, jsx } from 'react/jsx-runtime';
2
2
  import { useRef, useState, useMemo, useEffect, useCallback } from 'react';
3
3
  import { Form } from 'react-aria-components';
4
+ import { useAlgoliaInsights } from '../../../../algolia/use-algolia-insights.js';
4
5
  import { Accordion } from '../../../../collapsables/accordion/accordion.js';
5
6
  import { AccordionItem } from '../../../../collapsables/accordion/accordion-item.js';
6
7
  import { config } from '../../../../config.js';
@@ -8,6 +9,7 @@ import { InfoDisplay } from '../../../../display/info-display/info-display.js';
8
9
  import { Checkbox } from '../../../../forms/checkbox/checkbox.js';
9
10
  import { Select } from '../../../../forms/select/select.js';
10
11
  import { TextField } from '../../../../forms/text-field/text-field.js';
12
+ import { InfoIconTooltip } from '../../../../info-icon-tooltip/info-icon-tooltip.js';
11
13
  import { FormattedMessage } from '../../../../intl/formatted-message.js';
12
14
  import { useFormattedMessage } from '../../../../intl/use-formatted-message.js';
13
15
  import { usePatchSession } from '../../../../shared/api/storefront/hooks/authentication/use-patch-session.js';
@@ -15,18 +17,20 @@ import { usePatchCart } from '../../../../shared/api/storefront/hooks/cart/use-p
15
17
  import { usePlaceOrder } from '../../../../shared/api/storefront/hooks/cart/use-place-order.js';
16
18
  import { useInvalidateAdyen } from '../../../../shared/api/storefront/hooks/payment/use-invalidate-adyen.js';
17
19
  import { validateVATNumber } from '../../../../shared/api/storefront/services/finance-service.js';
20
+ import { useDataLayer } from '../../../../shared/ga/use-data-layer.js';
18
21
  import { useDebouncedCallback } from '../../../../shared/hooks/use-debounced-callback.js';
19
22
  import { currencySymbolToISO } from '../../../../shared/model/currency.js';
20
- import { Tooltip } from '../../../../tooltip/tooltip.js';
21
23
  import { BillingAndInvoiceInformation } from '../../components/billing-and-invoice-information.js';
22
24
  import { useHasReturnedFromAdyen } from '../hooks/use-has-returned-from-adyen.js';
23
25
  import { AdyenPayment } from './adyen-payment.js';
24
26
  import styles from './payment.module.css.js';
25
27
 
26
28
  function Payment({ atp, cart: _cart, form, onError: _onError, onPaymentComplete, onProcessing, onValidating, }) {
29
+ const { createEcommerceEvent, dataLayer } = useDataLayer();
27
30
  const { isLoading: isPatchingCart, mutate: patchCart } = usePatchCart();
28
31
  const { isLoading: isPatchingSession } = usePatchSession();
29
32
  const { isLoading: isPlacingCart, mutate: placeOrder } = usePlaceOrder();
33
+ const { sendPurchaseEventFromPaymentPage } = useAlgoliaInsights();
30
34
  const dropinRef = useRef(null);
31
35
  const [paymentError, setPaymentError] = useState();
32
36
  const [apiError, setAPIError] = useState();
@@ -104,6 +108,40 @@ function Payment({ atp, cart: _cart, form, onError: _onError, onPaymentComplete,
104
108
  setIsValidatingVAT(false);
105
109
  }
106
110
  }, 500);
111
+ const onPlaceOrderCompleted = useCallback(({ cart, payment_type }) => {
112
+ dataLayer.push(createEcommerceEvent({
113
+ cart,
114
+ event: {
115
+ ecommerce: {
116
+ payment_type,
117
+ },
118
+ event: 'add_payment_info',
119
+ },
120
+ }), createEcommerceEvent({
121
+ cart,
122
+ event: {
123
+ ecommerce: {
124
+ payment_type,
125
+ },
126
+ event: 'purchase',
127
+ },
128
+ }), {
129
+ currency: currencySymbolToISO[cart.currencySymbol],
130
+ event: 'transactionComplete',
131
+ transactionAffiliation: cart.billTo?.companyName,
132
+ transactionId: cart.orderNumber,
133
+ transactionProducts: cart.cartLines?.map(cartLine => ({
134
+ name: cartLine.shortDescription,
135
+ price: cartLine.pricing?.unitNetPrice,
136
+ quantity: cartLine.qtyOrdered,
137
+ sku: cartLine.erpNumber,
138
+ })) || [],
139
+ transactionShipping: cart.shippingAndHandling,
140
+ transactionTax: cart.totalTax,
141
+ transactionTotal: cart.orderGrandTotal,
142
+ });
143
+ sendPurchaseEventFromPaymentPage({ cart });
144
+ }, [createEcommerceEvent, dataLayer, sendPurchaseEventFromPaymentPage]);
107
145
  async function onSubmit(e) {
108
146
  const formData = new FormData(e.currentTarget);
109
147
  const cart = cartRef.current;
@@ -151,6 +189,10 @@ function Payment({ atp, cart: _cart, form, onError: _onError, onPaymentComplete,
151
189
  const cart = cartRef.current;
152
190
  try {
153
191
  await placeOrder({ cart });
192
+ onPlaceOrderCompleted({
193
+ cart,
194
+ payment_type: cart.paymentMethod?.name || '',
195
+ });
154
196
  return onPaymentComplete({ cartId: cart.trackId });
155
197
  }
156
198
  catch (error) {
@@ -175,14 +217,17 @@ function Payment({ atp, cart: _cart, form, onError: _onError, onPaymentComplete,
175
217
  },
176
218
  },
177
219
  });
220
+ onPlaceOrderCompleted({
221
+ cart,
222
+ payment_type: 'Adyen',
223
+ });
178
224
  return onPaymentComplete({ cartId: cart.trackId });
179
225
  }
180
226
  catch (error) {
181
227
  console.error(error);
182
- // TODO: Errors from the placeOrder call are not displayed
183
228
  setAPIError(error);
184
229
  }
185
- }, [onPaymentComplete, placeOrder]);
230
+ }, [onPaymentComplete, onPlaceOrderCompleted, placeOrder]);
186
231
  const onError = useCallback((error, result) => {
187
232
  invalidateAdyen();
188
233
  // invalidateCurrentCart()
@@ -197,7 +242,7 @@ function Payment({ atp, cart: _cart, form, onError: _onError, onPaymentComplete,
197
242
  setAsSoonAsPossible(checked);
198
243
  if (checked)
199
244
  setDeliveryDate('');
200
- }, children: jsx(FormattedMessage, { id: "As soon as possible" }) }), jsx(Tooltip, { text: t('Selecting As Soon As Possible will enable us to send the products to you as they become available.') })] })] })), jsx(Select, { isRequired: true, "data-test-selector": "industrySelect", defaultSelectedOption: cart.properties.industry, isDisabled: hasReturnedFromAdyen, label: t('Industry'), name: "industry", options: {
245
+ }, children: jsx(FormattedMessage, { id: "As soon as possible" }) }), jsx(InfoIconTooltip, { variant: "stroke", children: t('Selecting As Soon As Possible will enable us to send the products to you as they become available.') })] })] })), jsx(Select, { isRequired: true, "data-test-selector": "industrySelect", defaultSelectedOption: cart.properties.industry, isDisabled: hasReturnedFromAdyen, label: t('Industry'), name: "industry", options: {
201
246
  /* eslint-disable sort-keys-fix/sort-keys-fix */
202
247
  PP: 'Private User',
203
248
  AU: 'Automotive',
@@ -0,0 +1,15 @@
1
+ import { CartModel, CheckoutAtpEntry } from '../../../shared/api/storefront/model/storefront.model';
2
+ export interface PaymentContentProps {
3
+ atp: CheckoutAtpEntry[];
4
+ cart: CartModel;
5
+ formId: string;
6
+ hasAtp: boolean;
7
+ isProcessing: boolean;
8
+ isValidating: boolean;
9
+ onPaymentComplete: ({ cartId }: {
10
+ cartId: string;
11
+ }) => void;
12
+ setIsProcessing: (isProcessing: boolean) => void;
13
+ setIsValidating: (isValidating: boolean) => void;
14
+ }
15
+ export declare function PaymentPageContent({ atp, cart, formId, hasAtp, isProcessing, isValidating, onPaymentComplete, setIsProcessing, setIsValidating, }: PaymentContentProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,43 @@
1
+ import { jsx, jsxs } from 'react/jsx-runtime';
2
+ import { Button } from '../../../buttons/button/button.js';
3
+ import { OrderLineCard } from '../../../cards/orderline-card/orderline-card.js';
4
+ import { CartTotals } from '../../../cart-totals/cart-totals.js';
5
+ import { CartTotalsSummary } from '../../../cart-totals/cart-totals-summary.js';
6
+ import { FormattedMessage } from '../../../intl/formatted-message.js';
7
+ import { useFormattedMessage } from '../../../intl/use-formatted-message.js';
8
+ import { OrderLineList } from '../../../lists/orderline-list/orderline-list.js';
9
+ import { Page } from '../../components/page/page.js';
10
+ import { CHECKOUT_PATHS } from '../constants.js';
11
+ import { CheckoutPageLayout } from '../layouts/checkout-page-layout/checkout-page-layout.js';
12
+ import { CheckoutPageSection } from '../layouts/checkout-page-layout/components/checkout-page-section.js';
13
+ import { CheckoutPageSectionContent } from '../layouts/checkout-page-layout/components/checkout-page-section-content.js';
14
+ import { Payment } from './components/payment.js';
15
+
16
+ function PaymentPageContent({ atp, cart, formId, hasAtp, isProcessing, isValidating, onPaymentComplete, setIsProcessing, setIsValidating, }) {
17
+ const t = useFormattedMessage();
18
+ return (jsx(Page, { breadCrumb: [
19
+ { href: CHECKOUT_PATHS.HOME, label: t('Home') },
20
+ {
21
+ href: CHECKOUT_PATHS.REVIEW_AND_SUBMIT,
22
+ label: t('Review and payment'),
23
+ },
24
+ ], title: t('Review and payment'), children: jsxs(CheckoutPageLayout, { actions: {
25
+ primary: (jsx(Button, { withArrow: true, "data-test-selector": "checkoutReviewAndSubmit_placeOrder", form: formId, isDisabled: isProcessing, isLoading: isProcessing ? (jsx(FormattedMessage, { id: "Processing" })) : isValidating ? (jsx(FormattedMessage, { id: "Validating" })) : (false), type: "submit", children: jsx(FormattedMessage, { id: "Pay" }) })),
26
+ }, mobileSummary: jsx(CartTotalsSummary, { totalAmount: cart.orderGrandTotalDisplay }), overview: jsx(CartTotals, { deliveryDate: hasAtp ? undefined : cart.requestedDeliveryDate, fulfillmentMethod: cart.fulfillmentMethod, isPayByInvoice: (cart.paymentOptions?.paymentMethods?.length || 1) <= 1 &&
27
+ cart.paymentMethod?.name === 'PBI', shippingCost: cart.shippingAndHandlingDisplay, subtotal: cart.orderSubTotalDisplay, tax: cart.totalTaxDisplay, total: cart.orderGrandTotalDisplay, vatPercentage: cart.cartLines?.[0]?.pricing?.vatRate || 0 }), children: [jsx(CheckoutPageSection, { hasBorder: false, title: jsx(FormattedMessage, { id: "Payment" }), children: jsx(CheckoutPageSectionContent, { children: jsx(Payment, { atp: atp, cart: cart, form: formId, onPaymentComplete: onPaymentComplete, onProcessing: setIsProcessing, onValidating: setIsValidating }) }) }), jsx(CheckoutPageSection, { hasBorder: false, title: jsx(FormattedMessage, { id: "Order" }), children: jsx(CheckoutPageSectionContent, { stretch: true, children: jsx(OrderLineList, { children: cart.cartLines?.map(cartLine => (jsx(OrderLineCard, { deliveryDate: cartLine.atp?.date, href: cartLine.productUri, image: {
28
+ fit: 'contain',
29
+ image: {
30
+ '1': cartLine.smallImagePath,
31
+ '2': cartLine.smallImagePath,
32
+ '3': cartLine.smallImagePath,
33
+ altText: cartLine.altText,
34
+ },
35
+ title: cartLine.altText,
36
+ }, isReadonly: true, price: {
37
+ originalTotalPrice: cartLine.pricing?.extendedUnitNetPrice || 0,
38
+ pricePerUnit: cartLine.pricing?.unitNetPrice || 0,
39
+ totalPrice: cartLine.pricing?.extendedUnitNetPrice || 0,
40
+ }, productId: cartLine.productId || '', quantity: cartLine.qtyOrdered || 1, sku: cartLine.erpNumber || '', tags: [], title: cartLine.productName }, cartLine.id))) }) }) })] }) }));
41
+ }
42
+
43
+ export { PaymentPageContent };
@@ -1,26 +1,15 @@
1
- import { jsx, jsxs } from 'react/jsx-runtime';
1
+ import { jsx } from 'react/jsx-runtime';
2
2
  import { useState, useCallback, useEffect } from 'react';
3
- import { Button } from '../../../buttons/button/button.js';
4
- import { OrderLineCard } from '../../../cards/orderline-card/orderline-card.js';
5
- import { CartTotals } from '../../../cart-totals/cart-totals.js';
6
- import { CartTotalsSummary } from '../../../cart-totals/cart-totals-summary.js';
7
- import { FormattedMessage } from '../../../intl/formatted-message.js';
8
- import { useFormattedMessage } from '../../../intl/use-formatted-message.js';
9
- import { OrderLineList } from '../../../lists/orderline-list/orderline-list.js';
10
3
  import { useIsAuthenticated } from '../../../shared/api/storefront/hooks/authentication/use-is-authenticated.js';
11
4
  import { useFetchCurrentCheckoutAtp } from '../../../shared/api/storefront/hooks/cart/use-fetch-current-cart-checkout-atp.js';
12
5
  import { useFetchCurrentCartWithAtp } from '../../../shared/api/storefront/hooks/cart/use-fetch-current-cart-with-atp.js';
13
6
  import { useNavigate } from '../../../shared/routing/route-provider.js';
14
7
  import { hasNo } from '../../../shared/utils/types.js';
15
- import { Page } from '../../components/page/page.js';
16
8
  import { ErrorPage } from '../../error-page/error-page.js';
17
9
  import { LoadingPage } from '../../loading-page/loading-page.js';
18
10
  import { CHECKOUT_PATHS } from '../constants.js';
19
- import { CheckoutPageLayout } from '../layouts/checkout-page-layout/checkout-page-layout.js';
20
- import { CheckoutPageSection } from '../layouts/checkout-page-layout/components/checkout-page-section.js';
21
- import { CheckoutPageSectionContent } from '../layouts/checkout-page-layout/components/checkout-page-section-content.js';
22
- import { Payment } from './components/payment.js';
23
11
  import { useHasReturnedFromAdyen } from './hooks/use-has-returned-from-adyen.js';
12
+ import { PaymentPageContent } from './payment-page-content.js';
24
13
 
25
14
  const PAYMENT_FORM_ID = 'paymentForm';
26
15
  function PaymentPage() {
@@ -32,7 +21,6 @@ function PaymentPage() {
32
21
  const { data: atp, isLoading: isAtpLoading } = useFetchCurrentCheckoutAtp();
33
22
  const hasAtp = atp && atp.length > 1;
34
23
  const isLoading = isLoadingCart || isAtpLoading;
35
- const t = useFormattedMessage();
36
24
  const [isProcessing, setIsProcessing] = useState(false);
37
25
  const [isValidating, setIsValidating] = useState(false);
38
26
  const { isNavigating, navigate } = useNavigate();
@@ -66,29 +54,7 @@ function PaymentPage() {
66
54
  cart.cartLines.length === 0 ||
67
55
  hasNo(cart.billTo?.address1))
68
56
  return null;
69
- return (jsx(Page, { breadCrumb: [
70
- { href: CHECKOUT_PATHS.HOME, label: t('Home') },
71
- {
72
- href: CHECKOUT_PATHS.REVIEW_AND_SUBMIT,
73
- label: t('Review and payment'),
74
- },
75
- ], title: t('Review and payment'), children: jsxs(CheckoutPageLayout, { actions: {
76
- primary: (jsx(Button, { withArrow: true, "data-test-selector": "checkoutShippingCartTotalContinueButton", form: PAYMENT_FORM_ID, isDisabled: isProcessing, isLoading: isProcessing ? (jsx(FormattedMessage, { id: "Processing" })) : isValidating ? (jsx(FormattedMessage, { id: "Validating" })) : (false), type: "submit", children: jsx(FormattedMessage, { id: "Pay" }) })),
77
- }, mobileSummary: jsx(CartTotalsSummary, { totalAmount: cart.orderGrandTotalDisplay }), overview: jsx(CartTotals, { deliveryDate: hasAtp ? undefined : cart.requestedDeliveryDate, fulfillmentMethod: cart.fulfillmentMethod, isPayByInvoice: (cart.paymentOptions?.paymentMethods?.length || 1) <= 1 &&
78
- cart.paymentMethod?.name === 'PBI', shippingCost: cart.shippingAndHandlingDisplay, subtotal: cart.orderSubTotalDisplay, tax: cart.totalTaxDisplay, total: cart.orderGrandTotalDisplay, vatPercentage: cart.cartLines[0]?.pricing?.vatRate || 0 }), children: [jsx(CheckoutPageSection, { hasBorder: false, title: jsx(FormattedMessage, { id: "Payment" }), children: jsx(CheckoutPageSectionContent, { children: jsx(Payment, { atp: atp, cart: cart, form: PAYMENT_FORM_ID, onPaymentComplete: onPaymentComplete, onProcessing: setIsProcessing, onValidating: setIsValidating }) }) }), jsx(CheckoutPageSection, { hasBorder: false, title: jsx(FormattedMessage, { id: "Order" }), children: jsx(CheckoutPageSectionContent, { stretch: true, children: jsx(OrderLineList, { children: cart.cartLines.map(cartLine => (jsx(OrderLineCard, { deliveryDate: cartLine.atp?.date, href: cartLine.productUri, image: {
79
- fit: 'contain',
80
- image: {
81
- '1': cartLine.smallImagePath,
82
- '2': cartLine.smallImagePath,
83
- '3': cartLine.smallImagePath,
84
- altText: cartLine.altText,
85
- },
86
- title: cartLine.altText,
87
- }, isReadonly: true, price: {
88
- originalTotalPrice: cartLine.pricing?.extendedUnitNetPrice || 0,
89
- pricePerUnit: cartLine.pricing?.unitNetPrice || 0,
90
- totalPrice: cartLine.pricing?.extendedUnitNetPrice || 0,
91
- }, productId: cartLine.productId || '', quantity: cartLine.qtyOrdered || 1, sku: cartLine.erpNumber || '', tags: [], title: cartLine.productName }, cartLine.id))) }) }) })] }) }));
57
+ return (jsx(PaymentPageContent, { atp: atp, cart: cart, formId: PAYMENT_FORM_ID, hasAtp: Boolean(hasAtp), isProcessing: isProcessing, isValidating: isValidating, onPaymentComplete: onPaymentComplete, setIsProcessing: setIsProcessing, setIsValidating: setIsValidating }));
92
58
  }
93
59
 
94
60
  export { PaymentPage };
@@ -4,11 +4,11 @@ import { Form } from 'react-aria-components';
4
4
  import { CountrySelect } from '../../../../country-selector/country-select/country-select.js';
5
5
  import { Checkbox } from '../../../../forms/checkbox/checkbox.js';
6
6
  import { TextField } from '../../../../forms/text-field/text-field.js';
7
+ import { InfoIconTooltip } from '../../../../info-icon-tooltip/info-icon-tooltip.js';
7
8
  import { FormattedMessage } from '../../../../intl/formatted-message.js';
8
9
  import { useFormattedMessage } from '../../../../intl/use-formatted-message.js';
9
10
  import { useFetchCurrentCart } from '../../../../shared/api/storefront/hooks/cart/use-fetch-current-cart.js';
10
11
  import { validatePhone, validateEmail } from '../../../../shared/model/address.js';
11
- import { Tooltip } from '../../../../tooltip/tooltip.js';
12
12
  import { CheckoutPageSection } from '../../layouts/checkout-page-layout/components/checkout-page-section.js';
13
13
  import { CheckoutPageSectionContent } from '../../layouts/checkout-page-layout/components/checkout-page-section-content.js';
14
14
  import { SonicAddress } from './sonic-address.js';
@@ -43,7 +43,7 @@ function EditAddresses({ countries, isLoading, isPickup, onSubmit, }) {
43
43
  },
44
44
  notes: formData.get('notes')?.toString() || '',
45
45
  });
46
- }, children: [jsx(TextField, { isDisabled: isLoading, label: t('First name'), name: "firstName", showLabel: true }), jsx(TextField, { isDisabled: isLoading, isRequired: !companyName, label: t('Last name'), minLength: 3, name: "lastName", onChange: setLastName, showLabel: true, value: lastName }, `lastname-${Boolean(companyName)}`), jsx(TextField, { isDisabled: isLoading, label: t('Company name'), name: "companyName", onChange: setCompanyName, showLabel: true, value: companyName }), jsx(TextField, { isDisabled: isLoading, label: t('Attention'), name: "attention", showLabel: true }), jsx("div", { className: styles['span-2'], children: jsx(TextField, { isRequired: true, isDisabled: isLoading, label: `${t('Address')} 1`, maxLength: 30, minLength: 3, name: "address1", showLabel: true }) }), jsx("div", { className: styles['span-2'], children: jsx(TextField, { isDisabled: isLoading, label: `${t('Address')} 2`, maxLength: 30, minLength: 3, name: "address2", showLabel: true }) }), jsx("div", { className: styles['span-2'], children: jsx(TextField, { isDisabled: isLoading, label: `${t('Address')} 3`, maxLength: 30, minLength: 3, name: "address3", showLabel: true }) }), jsx(TextField, { isRequired: true, isDisabled: isLoading, label: t('Postal Code'), maxLength: 10, minLength: 4, name: "postalCode", showLabel: true }), jsx(TextField, { isRequired: true, isDisabled: isLoading, label: t('City'), maxLength: 30, minLength: 3, name: "city", showLabel: true }), jsx("div", { className: styles['span-2'], children: jsx(CountrySelect, { isRequired: true, countries: countries, "data-test-selector": "countrySelect", name: "countrySelect" }) }), jsx("div", { className: styles['span-2'], children: jsx(TextField, { isRequired: true, isDisabled: isLoading, label: t('Phone'), name: "phone", showLabel: true, validate: value => {
46
+ }, children: [jsx(TextField, { isDisabled: isLoading, label: t('First name'), name: "firstName", showLabel: true }), jsx(TextField, { isDisabled: isLoading, isRequired: !companyName, label: t('Last name'), minLength: 3, name: "lastName", onChange: setLastName, showLabel: true, value: lastName }, `lastname-${Boolean(companyName)}`), jsx(TextField, { isDisabled: isLoading, label: t('Company name'), name: "companyName", onChange: setCompanyName, showLabel: true, value: companyName }), jsx(TextField, { isDisabled: isLoading, label: t('Attention'), name: "attention", showLabel: true }), jsx("div", { className: styles['span-2'], children: jsx(TextField, { isRequired: true, isDisabled: isLoading, label: `${t('Address')} 1`, maxLength: 30, minLength: 3, name: "address1", showLabel: true }) }), jsx("div", { className: styles['span-2'], children: jsx(TextField, { isDisabled: isLoading, label: `${t('Address')} 2`, maxLength: 30, minLength: 3, name: "address2", showLabel: true }) }), jsx("div", { className: styles['span-2'], children: jsx(TextField, { isDisabled: isLoading, label: `${t('Address')} 3`, maxLength: 30, minLength: 3, name: "address3", showLabel: true }) }), jsx(TextField, { isRequired: true, isDisabled: isLoading, label: t('Postal Code'), maxLength: 10, minLength: 4, name: "postalCode", showLabel: true }), jsx(TextField, { isRequired: true, isDisabled: isLoading, label: t('City'), maxLength: 30, minLength: 3, name: "city", showLabel: true }), jsx("div", { className: styles['span-2'], children: jsx(CountrySelect, { isRequired: true, countries: countries, "data-test-selector": "countrySelect", isDisabled: isLoading, name: "countrySelect" }) }), jsx("div", { className: styles['span-2'], children: jsx(TextField, { isRequired: true, isDisabled: isLoading, label: t('Phone'), name: "phone", showLabel: true, validate: value => {
47
47
  if (!value)
48
48
  return value;
49
49
  return (validatePhone(value) ||
@@ -53,7 +53,7 @@ function EditAddresses({ countries, isLoading, isPickup, onSubmit, }) {
53
53
  return value;
54
54
  return (validateEmail(value) ||
55
55
  t('Please enter a valid e-mail address'));
56
- } }) }), jsx("div", { className: styles['span-2'], children: jsx(TextField, { isDisabled: isLoading, isMultiline: true, label: t('Add order notes'), name: "notes", rows: 3, showLabel: true }) })] }) }) }), jsx(CheckoutPageSection, { title: jsx(FormattedMessage, { id: isPickup ? 'Pickup address' : 'Shipping address' }), children: jsx(CheckoutPageSectionContent, { children: jsx(Fragment, { children: isPickup ? (jsx(SonicAddress, {})) : (jsxs("div", { className: styles['use-invoice-checkbox'], children: [jsx(Checkbox, { "data-test-selector": "checkboxUseBillingAddress", isDisabled: true, isSelected: true, children: jsx(FormattedMessage, { id: "Use billing address" }) }), jsx(Tooltip, { text: t('Changing your address is currently not possible. Please contact customer support to change your address.') })] })) }) }) })] }));
56
+ } }) }), jsx("div", { className: styles['span-2'], children: jsx(TextField, { isDisabled: isLoading, isMultiline: true, label: t('Add order notes'), name: "notes", rows: 3, showLabel: true }) })] }) }) }), jsx(CheckoutPageSection, { title: jsx(FormattedMessage, { id: isPickup ? 'Pickup address' : 'Shipping address' }), children: jsx(CheckoutPageSectionContent, { children: jsx(Fragment, { children: isPickup ? (jsx(SonicAddress, {})) : (jsxs("div", { className: styles['use-invoice-checkbox'], children: [jsx(Checkbox, { "data-test-selector": "checkboxUseBillingAddress", isDisabled: true, isSelected: true, children: jsx(FormattedMessage, { id: "Use billing address" }) }), jsx(InfoIconTooltip, { variant: "stroke", children: t('Changing your address is currently not possible. Please contact customer support to change your address.') })] })) }) }) })] }));
57
57
  }
58
58
 
59
59
  export { EDIT_ADDRESS_FORM_ID, EditAddresses };
@@ -22,7 +22,31 @@ function ReadOnlyAddresses({ billTo, isLoading, isPickup, notes, onSubmit, shipT
22
22
  onSubmit({
23
23
  notes: formData.get('notes')?.toString() || '',
24
24
  });
25
- }, children: [jsxs(CheckoutPageSection, { title: jsx(FormattedMessage, { id: "Billing address" }), children: [jsx(CheckoutPageSectionLink, { children: jsxs(RouteLink, { color: "secondary", href: ACCOUNT_ADDRESSES_PATH, isDisabled: isLoading, children: [jsx(FormattedMessage, { id: "Edit billing address" }), " >"] }) }), jsxs(CheckoutPageSectionContent, { children: [billTo && (jsx(Address, { address1: billTo.address1, address2: billTo.address2, address3: billTo.address3, city: billTo.city, companyName: billTo.companyName, country: billTo.country?.name, email: billTo.email, firstName: billTo.firstName, lastName: billTo.lastName, phone: billTo.phone, postalCode: billTo.postalCode })), jsx("div", { className: styles.notes, children: jsx(TextField, { defaultValue: notes, isDisabled: isLoading, isMultiline: true, label: t('Add order notes'), name: "notes", rows: 3, showLabel: true }) })] })] }), jsxs(CheckoutPageSection, { title: jsx(FormattedMessage, { id: isPickup ? 'Pickup address' : 'Shipping address' }), children: [!isPickup && (jsx(CheckoutPageSectionLink, { children: jsxs(RouteLink, { color: "secondary", href: ACCOUNT_ADDRESSES_PATH, isDisabled: isLoading, children: [jsx(FormattedMessage, { id: "Edit shipping address" }), " >"] }) })), jsx(CheckoutPageSectionContent, { children: isPickup ? (jsx(SonicAddress, {})) : (jsxs(Fragment, { children: [jsx(Checkbox, { className: styles['use-invoice-checkbox'], "data-test-selector": "checkboxUseBillingAddress", isDisabled: true, isSelected: true, children: jsx(FormattedMessage, { id: "Use billing address" }) }), shipTo && (jsx(Address, { address1: shipTo.address1, address2: shipTo.address2, address3: shipTo.address3, city: shipTo.city, companyName: shipTo.companyName, country: shipTo.country?.name, email: shipTo.email, firstName: shipTo.firstName, lastName: shipTo.lastName, phone: shipTo.phone, postalCode: shipTo.postalCode }))] })) })] })] }));
25
+ }, children: [jsxs(CheckoutPageSection, { title: jsx(FormattedMessage, { id: "Billing address" }), children: [jsx(CheckoutPageSectionLink, { children: jsxs(RouteLink, { color: "secondary", href: ACCOUNT_ADDRESSES_PATH, isDisabled: isLoading, children: [jsx(FormattedMessage, { id: "Edit billing address" }), " >"] }) }), jsxs(CheckoutPageSectionContent, { children: [billTo && (jsx(Address, { address: {
26
+ address1: billTo.address1,
27
+ address2: billTo.address2,
28
+ address3: billTo.address3,
29
+ city: billTo.city,
30
+ companyName: billTo.companyName,
31
+ country: billTo.country?.name,
32
+ email: billTo.email,
33
+ firstName: billTo.firstName,
34
+ lastName: billTo.lastName,
35
+ phone: billTo.phone,
36
+ postalCode: billTo.postalCode,
37
+ } })), jsx("div", { className: styles.notes, children: jsx(TextField, { defaultValue: notes, isDisabled: isLoading, isMultiline: true, label: t('Add order notes'), name: "notes", rows: 3, showLabel: true }) })] })] }), jsxs(CheckoutPageSection, { title: jsx(FormattedMessage, { id: isPickup ? 'Pickup address' : 'Shipping address' }), children: [!isPickup && (jsx(CheckoutPageSectionLink, { children: jsxs(RouteLink, { color: "secondary", href: ACCOUNT_ADDRESSES_PATH, isDisabled: isLoading, children: [jsx(FormattedMessage, { id: "Edit shipping address" }), " >"] }) })), jsx(CheckoutPageSectionContent, { children: isPickup ? (jsx(SonicAddress, {})) : (jsxs(Fragment, { children: [jsx(Checkbox, { className: styles['use-invoice-checkbox'], "data-test-selector": "checkboxUseBillingAddress", isDisabled: true, isSelected: true, children: jsx(FormattedMessage, { id: "Use billing address" }) }), shipTo && (jsx(Address, { address: {
38
+ address1: shipTo.address1,
39
+ address2: shipTo.address2,
40
+ address3: shipTo.address3,
41
+ city: shipTo.city,
42
+ companyName: shipTo.companyName,
43
+ country: shipTo.country?.name,
44
+ email: shipTo.email,
45
+ firstName: shipTo.firstName,
46
+ lastName: shipTo.lastName,
47
+ phone: shipTo.phone,
48
+ postalCode: shipTo.postalCode,
49
+ } }))] })) })] })] }));
26
50
  }
27
51
 
28
52
  export { ReadOnlyAddresses };
@@ -0,0 +1,14 @@
1
+ import { ReactNode } from 'react';
2
+ import { CartModel } from '../../../shared/api/storefront/model/storefront.model';
3
+ export interface ShippingPageContentProps {
4
+ cart: CartModel;
5
+ editAddress: ReactNode;
6
+ errorPatchBillingAddress?: unknown;
7
+ fulfillmentMethods: string[] | undefined;
8
+ isLoadingFulfillmentMethods: boolean;
9
+ isPatching: boolean;
10
+ isPatchingSession: boolean;
11
+ onChangeFulfillmentMethod: (value: string) => void;
12
+ readOnlyAddress: ReactNode;
13
+ }
14
+ export declare function ShippingPageContent({ cart, editAddress, errorPatchBillingAddress, fulfillmentMethods, isLoadingFulfillmentMethods, isPatching, isPatchingSession, onChangeFulfillmentMethod, readOnlyAddress, }: ShippingPageContentProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,40 @@
1
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
+ import { useMemo } from 'react';
3
+ import { Button } from '../../../buttons/button/button.js';
4
+ import { CartTotals } from '../../../cart-totals/cart-totals.js';
5
+ import { CartTotalsSummary } from '../../../cart-totals/cart-totals-summary.js';
6
+ import { Select } from '../../../forms/select/select.js';
7
+ import { FormattedMessage } from '../../../intl/formatted-message.js';
8
+ import { useFormattedMessage } from '../../../intl/use-formatted-message.js';
9
+ import { Page } from '../../components/page/page.js';
10
+ import { CHECKOUT_PATHS } from '../constants.js';
11
+ import { CheckoutPageLayout } from '../layouts/checkout-page-layout/checkout-page-layout.js';
12
+ import { CheckoutPageSection } from '../layouts/checkout-page-layout/components/checkout-page-section.js';
13
+ import { CheckoutPageSectionContent } from '../layouts/checkout-page-layout/components/checkout-page-section-content.js';
14
+ import { EDIT_ADDRESS_FORM_ID } from './components/edit-address.js';
15
+ import styles from './shipping-page.module.css.js';
16
+
17
+ function ShippingPageContent({ cart, editAddress, errorPatchBillingAddress, fulfillmentMethods, isLoadingFulfillmentMethods, isPatching, isPatchingSession, onChangeFulfillmentMethod, readOnlyAddress, }) {
18
+ const t = useFormattedMessage();
19
+ const fulfillmentMethodOptions = fulfillmentMethods?.reduce((acc, method) => ({
20
+ ...acc,
21
+ [method]: t(`fulfillmentMethod.${method}`),
22
+ }), {});
23
+ const hasBillToAddress = useMemo(() => {
24
+ return Boolean(cart.billTo?.address1);
25
+ // eslint-disable-next-line react-hooks/exhaustive-deps
26
+ }, [Boolean(cart)]);
27
+ return (jsx(Page, { breadCrumb: [
28
+ { href: CHECKOUT_PATHS.HOME, label: t('Home') },
29
+ {
30
+ href: CHECKOUT_PATHS.CHECKOUT_SHIPPING,
31
+ label: t('Shipping details'),
32
+ },
33
+ ], title: t('Shipping details'), children: jsxs(CheckoutPageLayout, { actions: {
34
+ primary: (jsx(Button, { withArrow: true, "data-test-selector": "checkoutShippingCartTotalContinueButton", form: EDIT_ADDRESS_FORM_ID, isDisabled: isPatching, isLoading: isPatching || isPatchingSession ? (jsx(FormattedMessage, { id: "Updating address" })) : undefined, type: "submit", children: jsx(FormattedMessage, { id: "Continue shopping" }) })),
35
+ }, mobileSummary: jsx(CartTotalsSummary, { totalAmount: cart.orderGrandTotalDisplay }), overview: jsx(CartTotals, { fulfillmentMethod: fulfillmentMethods && fulfillmentMethods.length === 1
36
+ ? cart.fulfillmentMethod
37
+ : undefined, shippingCost: cart.shippingAndHandlingDisplay, subtotal: cart.orderSubTotalDisplay, tax: cart.totalTaxDisplay, total: cart.orderGrandTotalDisplay, vatPercentage: cart.cartLines?.[0]?.pricing?.vatRate }), children: [jsxs(Fragment, { children: [fulfillmentMethods && fulfillmentMethods.length > 1 && (jsx(CheckoutPageSection, { hasBorder: true, title: t('Fulfillment method'), children: jsx(CheckoutPageSectionContent, { children: jsx("div", { className: styles['fulfillment-select-wrapper'], children: jsx(Select, { isRequired: true, showLabel: true, "data-test-selector": "fulfillmentMethodSelect", defaultSelectedOption: cart.fulfillmentMethod, isLoading: isLoadingFulfillmentMethods, label: t('Fulfillment method'), name: "fulfillmentMethod", onChange: onChangeFulfillmentMethod, options: fulfillmentMethodOptions || {}, variant: "solid" }) }) }) })), hasBillToAddress ? readOnlyAddress : editAddress] }), Boolean(errorPatchBillingAddress) && (jsx("div", { className: styles['error-message'], children: jsx(FormattedMessage, { id: "An unexpected error occured" }) }))] }) }));
38
+ }
39
+
40
+ export { ShippingPageContent };
@@ -1,33 +1,26 @@
1
- import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
- import { useMemo, useEffect } from 'react';
3
- import { Button } from '../../../buttons/button/button.js';
4
- import { CartTotals } from '../../../cart-totals/cart-totals.js';
5
- import { CartTotalsSummary } from '../../../cart-totals/cart-totals-summary.js';
6
- import { Select } from '../../../forms/select/select.js';
7
- import { FormattedMessage } from '../../../intl/formatted-message.js';
8
- import { useFormattedMessage } from '../../../intl/use-formatted-message.js';
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { useRef, useEffect } from 'react';
9
3
  import { useFetchSession } from '../../../shared/api/storefront/hooks/authentication/use-fetch-session.js';
10
4
  import { useIsAuthenticated } from '../../../shared/api/storefront/hooks/authentication/use-is-authenticated.js';
11
5
  import { usePatchSession } from '../../../shared/api/storefront/hooks/authentication/use-patch-session.js';
12
6
  import { useFetchCurrentCart } from '../../../shared/api/storefront/hooks/cart/use-fetch-current-cart.js';
13
7
  import { useFetchFulfillmentMethodsForCurrentCart } from '../../../shared/api/storefront/hooks/customer/use-fetch-fulfillment-methods-for-current-cart.js';
14
8
  import { useFetchCountries } from '../../../shared/api/storefront/hooks/website/use-fetch-countries.js';
9
+ import { useDataLayer } from '../../../shared/ga/use-data-layer.js';
15
10
  import { useNavigate } from '../../../shared/routing/route-provider.js';
16
11
  import { hasNo } from '../../../shared/utils/types.js';
17
- import { Page } from '../../components/page/page.js';
18
12
  import { ErrorPage } from '../../error-page/error-page.js';
19
13
  import { LoadingPage } from '../../loading-page/loading-page.js';
20
14
  import { CHECKOUT_PATHS } from '../constants.js';
21
- import { CheckoutPageLayout } from '../layouts/checkout-page-layout/checkout-page-layout.js';
22
- import { CheckoutPageSection } from '../layouts/checkout-page-layout/components/checkout-page-section.js';
23
- import { CheckoutPageSectionContent } from '../layouts/checkout-page-layout/components/checkout-page-section-content.js';
24
- import { EDIT_ADDRESS_FORM_ID, EditAddresses } from './components/edit-address.js';
15
+ import { EditAddresses } from './components/edit-address.js';
25
16
  import { ReadOnlyAddresses } from './components/readonly-address.js';
26
17
  import { usePatchShippingDetails } from './hooks/use-patch-shipping-details.js';
27
- import styles from './shipping-page.module.css.js';
18
+ import { ShippingPageContent } from './shipping-page-content.js';
28
19
 
29
20
  function ShippingPage() {
30
21
  const isAuthenticated = useIsAuthenticated();
22
+ const { createEcommerceEvent, dataLayer } = useDataLayer();
23
+ const gaEventPushed = useRef(false);
31
24
  const { data: cart, error: errorFetchCart, isLoading: isLoadingCart, refetch: refetchCart, } = useFetchCurrentCart();
32
25
  const { data: countries, isLoading: isLoadingCountries } = useFetchCountries({
33
26
  enabled: hasNo(cart?.billTo?.address1),
@@ -37,16 +30,7 @@ function ShippingPage() {
37
30
  const { isLoading: isPatchingSession, mutate: patchSession } = usePatchSession();
38
31
  const { error: errorPatchBillingAddress, isError, isLoading: isPatching, isSuccess, mutate: patchShippingDetails, } = usePatchShippingDetails();
39
32
  const isLoading = isLoadingCart || isLoadingCountries || isLoadingFulfillmentMethods;
40
- const t = useFormattedMessage();
41
33
  const { isNavigating, navigate } = useNavigate();
42
- const hasBillToAddress = useMemo(() => {
43
- return Boolean(cart?.billTo?.address1);
44
- // eslint-disable-next-line react-hooks/exhaustive-deps
45
- }, [Boolean(cart)]);
46
- const fulfillmentMethodOptions = fulfillmentMethods?.reduce((acc, method) => ({
47
- ...acc,
48
- [method]: t(`fulfillmentMethod.${method}`),
49
- }), {});
50
34
  const isPickup = cart?.fulfillmentMethod === 'PickUp';
51
35
  useEffect(() => {
52
36
  /* Initial guards. When these are not met, we should not proceed */
@@ -77,6 +61,15 @@ function ShippingPage() {
77
61
  return;
78
62
  return navigate(CHECKOUT_PATHS.REVIEW_AND_SUBMIT);
79
63
  }, [isSuccess, cart, navigate, isNavigating, isPatching, isError]);
64
+ useEffect(() => {
65
+ if (!cart || gaEventPushed.current)
66
+ return;
67
+ dataLayer.push(createEcommerceEvent({
68
+ cart,
69
+ event: { event: 'begin_checkout' },
70
+ }));
71
+ gaEventPushed.current = true;
72
+ }, [cart, createEcommerceEvent, dataLayer]);
80
73
  if (errorFetchCart)
81
74
  return jsx(ErrorPage, { error: errorFetchCart });
82
75
  if (isLoading || isNavigating || isError || isSuccess)
@@ -88,37 +81,35 @@ function ShippingPage() {
88
81
  hasNo(cart.billTo) ||
89
82
  (hasNo(cart.billTo.address1) && hasNo(countries)))
90
83
  return null;
91
- return (jsx(Page, { breadCrumb: [
92
- { href: CHECKOUT_PATHS.HOME, label: t('Home') },
93
- {
94
- href: CHECKOUT_PATHS.CHECKOUT_SHIPPING,
95
- label: t('Shipping details'),
96
- },
97
- ], title: t('Shipping details'), children: jsxs(CheckoutPageLayout, { actions: {
98
- primary: (jsx(Button, { withArrow: true, "data-test-selector": "checkoutShippingCartTotalContinueButton", form: EDIT_ADDRESS_FORM_ID, isDisabled: isPatching, isLoading: isPatching || isPatchingSession ? (jsx(FormattedMessage, { id: "Updating address" })) : undefined, type: "submit", children: jsx(FormattedMessage, { id: "Continue shopping" }) })),
99
- }, mobileSummary: jsx(CartTotalsSummary, { totalAmount: cart.orderGrandTotalDisplay }), overview: jsx(CartTotals, { fulfillmentMethod: fulfillmentMethods && fulfillmentMethods.length === 1
100
- ? cart.fulfillmentMethod
101
- : undefined, shippingCost: cart.shippingAndHandlingDisplay, subtotal: cart.orderSubTotalDisplay, tax: cart.totalTaxDisplay, total: cart.orderGrandTotalDisplay, vatPercentage: cart.cartLines[0]?.pricing?.vatRate }), children: [jsxs(Fragment, { children: [fulfillmentMethods && fulfillmentMethods.length > 1 && (jsx(CheckoutPageSection, { hasBorder: true, title: t('Fulfillment method'), children: jsx(CheckoutPageSectionContent, { children: jsx("div", { className: styles['fulfillment-select-wrapper'], children: jsx(Select, { isRequired: true, showLabel: true, "data-test-selector": "fulfillmentMethodSelect", defaultSelectedOption: cart.fulfillmentMethod, isLoading: isLoadingFulfillmentMethods, label: t('Fulfillment method'), name: "fulfillmentMethod", onChange: async (value) => {
102
- await patchSession({
103
- session: {
104
- ...session,
105
- fulfillmentMethod: value,
106
- },
107
- });
108
- await refetchCart();
109
- }, options: fulfillmentMethodOptions || {}, variant: "solid" }) }) }) })), hasBillToAddress ? (jsx(ReadOnlyAddresses, { billTo: cart.billTo, isLoading: isPatching, isPickup: isPickup, notes: cart.notes, onSubmit: async ({ notes }) => {
110
- if (!cart.billTo)
111
- return;
112
- await patchShippingDetails({ cart, notes });
113
- }, shipTo: cart.shipTo })) : (jsx(EditAddresses, { countries: countries || [], isLoading: isPatching, isPickup: isPickup, onSubmit: async ({ address, notes }) => {
114
- if (!cart.billTo)
115
- return;
116
- await patchShippingDetails({
117
- billTo: { ...cart.billTo, ...address },
118
- cart,
119
- notes,
120
- });
121
- } }))] }), Boolean(errorPatchBillingAddress) && (jsx("div", { className: styles['error-message'], children: jsx(FormattedMessage, { id: "An unexpected error occured" }) }))] }) }));
84
+ return (jsx(ShippingPageContent, { cart: cart, editAddress: jsx(EditAddresses, { countries: countries || [], isLoading: isPatching, isPickup: isPickup, onSubmit: async ({ address, notes }) => {
85
+ if (!cart.billTo)
86
+ return;
87
+ await patchShippingDetails({
88
+ billTo: { ...cart.billTo, ...address },
89
+ cart,
90
+ notes,
91
+ });
92
+ dataLayer.push(createEcommerceEvent({
93
+ cart,
94
+ event: { event: 'add_shipping_info' },
95
+ }));
96
+ } }), errorPatchBillingAddress: errorPatchBillingAddress, fulfillmentMethods: fulfillmentMethods, isLoadingFulfillmentMethods: isLoadingFulfillmentMethods, isPatching: isPatching, isPatchingSession: isPatchingSession, onChangeFulfillmentMethod: async (value) => {
97
+ await patchSession({
98
+ session: {
99
+ ...session,
100
+ fulfillmentMethod: value,
101
+ },
102
+ });
103
+ await refetchCart();
104
+ }, readOnlyAddress: jsx(ReadOnlyAddresses, { billTo: cart.billTo, isLoading: isPatching, isPickup: isPickup, notes: cart.notes, onSubmit: async ({ notes }) => {
105
+ if (!cart.billTo)
106
+ return;
107
+ await patchShippingDetails({ cart, notes });
108
+ dataLayer.push(createEcommerceEvent({
109
+ cart,
110
+ event: { event: 'add_shipping_info' },
111
+ }));
112
+ }, shipTo: cart.shipTo }) }));
122
113
  }
123
114
 
124
115
  export { ShippingPage };
@@ -10,10 +10,20 @@ import { FormattedMessage } from '../../../../../intl/formatted-message.js';
10
10
  import { DownloadDocumentList } from '../../../../../lists/download-document-list/download-document-list.js';
11
11
  import { FeatureList } from '../../../../../lists/feature-list/feature-list.js';
12
12
  import { Heading } from '../../../../../typography/heading/heading.js';
13
+ import { useAlgoliaInsights } from '../../../../../algolia/use-algolia-insights.js';
13
14
  import styles from './product-details-panel.module.css.js';
14
15
 
15
16
  function ProductDetailsPanel({ priceComponent, product, }) {
16
- return (jsxs("div", { className: styles['product-details-panel'], children: [jsxs("div", { className: styles.heading, children: [jsx(Heading, { italic: true, size: "xs", children: product.productTitle }), jsx(ProductSku, { sku: product.productNumber })] }), jsxs("div", { className: styles['price-action-container'], children: [priceComponent || (jsx(ProductPrice, { "data-test": "productPrice_unitNetPrice", isVatIncluded: product.isVatIncluded, originalPrice: product.originalPrice, price: product.price })), jsxs("div", { className: styles['action-container'], children: [product.canAddToCart && (jsx(ConnectedAddToCartButton, { productId: product.storefrontId })), product.canAddToWishlist && (jsx(ConnectedFavoriteButton, { productId: product.storefrontId }))] })] }), jsxs("div", { children: [jsx(Heading, { italic: true, className: styles['product-features-heading'], size: "xxs", children: jsx(FormattedMessage, { id: "Product Features" }) }), product.content.htmlContent && (jsx(ShowAll, { initialHeight: 216, children: jsx("div", { className: styles.description, dangerouslySetInnerHTML: {
17
+ const { sendAddToCartFromProductDetailsPageEvent, sendAddToWishListFromProductDetailsPageEvent, } = useAlgoliaInsights();
18
+ return (jsxs("div", { className: styles['product-details-panel'], children: [jsxs("div", { className: styles.heading, children: [jsx(Heading, { italic: true, size: "xs", children: product.productTitle }), jsx(ProductSku, { sku: product.productNumber })] }), jsxs("div", { className: styles['price-action-container'], children: [priceComponent || (jsx(ProductPrice, { "data-test": "productPrice_unitNetPrice", isVatIncluded: product.isVatIncluded, originalPrice: product.originalPrice, price: product.price })), jsxs("div", { className: styles['action-container'], children: [product.canAddToCart && (jsx(ConnectedAddToCartButton, { onAddToCart: ({ cartLine }) => {
19
+ sendAddToCartFromProductDetailsPageEvent({
20
+ cartLine,
21
+ });
22
+ }, productId: product.storefrontId })), product.canAddToWishlist && (jsx(ConnectedFavoriteButton, { onFavoriting: () => {
23
+ sendAddToWishListFromProductDetailsPageEvent({
24
+ objectId: product.productNumber,
25
+ });
26
+ }, productId: product.storefrontId }))] })] }), jsxs("div", { children: [jsx(Heading, { italic: true, className: styles['product-features-heading'], size: "xxs", children: jsx(FormattedMessage, { id: "Product Features" }) }), product.content.htmlContent && (jsx(ShowAll, { initialHeight: 216, children: jsx("div", { className: styles.description, dangerouslySetInnerHTML: {
17
27
  __html: product.content.htmlContent,
18
28
  } }) }))] }), jsx("div", { children: jsxs(Accordion, { indented: true, borderType: ['top', 'middle-accentuated'], children: [product.attributeTypes.length > 0 && (jsx(AccordionItem, { id: "specification", title: jsx(FormattedMessage, { id: "Specifications" }), children: jsx(FeatureList, { className: styles['feature-list'], features: product.attributeTypes.map(attribute => ({
19
29
  id: `${attribute.id}`,
@@ -15,7 +15,6 @@ function ProductHitCard({ hit }) {
15
15
  title: hit.name,
16
16
  }, onAddToCart: ({ cartLine }) => sendAddToCartFromProductListPageEvent({
17
17
  cartLine,
18
- objectId: hit.objectId,
19
18
  }), onClick: () => sendProductClickFromProductListPageEvent({
20
19
  objectId: hit.objectId,
21
20
  position: hit.position,
@@ -15,7 +15,6 @@ function ProductHitCard({ hit }) {
15
15
  title: hit.name,
16
16
  }, onAddToCart: ({ cartLine }) => sendAddToCartFromSearchResultPageEvent({
17
17
  cartLine,
18
- objectId: hit.objectId,
19
18
  }), onClick: () => {
20
19
  sendProductClickFromSearchResultPageEvent({
21
20
  objectId: hit.objectId,