@sonic-equipment/ui 258.0.4 → 258.1.1

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/dist/config.js CHANGED
@@ -70,7 +70,7 @@ const configPerEnvironment = {
70
70
  production: () => ({
71
71
  ALGOLIA_API_KEY: 'e31a3a53449eceb4d0f9273b9bcd9759',
72
72
  ALGOLIA_APP_ID: '14CUFCVMAD',
73
- ALGOLIA_HOST: 'shopapi.sonic-equipment.com',
73
+ ALGOLIA_HOST: 'shop.sonic-equipment.com',
74
74
  BFF_API_URL: 'https://shopapi.sonic-equipment.com/api/v1/bff',
75
75
  COOKIE_DOMAIN: '.sonic-equipment.com',
76
76
  HOME_PAGE_URL: 'https://sonic-equipment.com/',
@@ -81,10 +81,10 @@ const configPerEnvironment = {
81
81
  ALGOLIA_API_KEY: 'e0edf30798a6b2e4e44fd25f0f2f9646',
82
82
  ALGOLIA_APP_ID: 'testing9VXJ0U4GSV',
83
83
  ALGOLIA_HOST: 'shop.accept-sonic-equipment.com',
84
- BFF_API_URL: 'https://shop.accept-sonic-equipment.com/api/v1/bff',
84
+ BFF_API_URL: 'https://shopapi.accept-sonic-equipment.com/api/v1/bff',
85
85
  COOKIE_DOMAIN: '.accept-sonic-equipment.com',
86
86
  HOME_PAGE_URL: 'https://accept-sonic-equipment.com/',
87
- SHOP_API_URL: 'https://shop.accept-sonic-equipment.com',
87
+ SHOP_API_URL: 'https://shopapi.accept-sonic-equipment.com',
88
88
  SHOP_URL: 'https://shop.accept-sonic-equipment.com',
89
89
  }),
90
90
  'sandbox-reverse-proxy': () => ({
package/dist/exports.d.ts CHANGED
@@ -243,9 +243,11 @@ export * from './pages/checkout/payment-page/hooks/use-has-returned-from-adyen';
243
243
  export * from './pages/checkout/payment-page/payment-page';
244
244
  export * from './pages/checkout/payment-page/payment-page-content';
245
245
  export * from './pages/checkout/payment-page/utils/parse-amount';
246
+ export * from './pages/checkout/shipping-page/components/address-book-selector';
246
247
  export * from './pages/checkout/shipping-page/components/currency-change-dialog';
247
248
  export * from './pages/checkout/shipping-page/components/edit-checkout-bill-to-address-form';
248
249
  export * from './pages/checkout/shipping-page/components/readonly-address';
250
+ export * from './pages/checkout/shipping-page/components/ship-to-mode-selector';
249
251
  export * from './pages/checkout/shipping-page/components/sonic-address';
250
252
  export * from './pages/checkout/shipping-page/hooks/use-patch-shipping-details';
251
253
  export * from './pages/checkout/shipping-page/shipping-page';
@@ -17,7 +17,7 @@ export interface CheckboxWithLabelProps extends CheckboxPropsBase {
17
17
  'aria-label': string;
18
18
  }
19
19
  export interface CheckboxWithChildrenProps extends CheckboxPropsBase {
20
- children: ReactNode;
20
+ children?: ReactNode;
21
21
  }
22
22
  export type CheckboxProps = CheckboxWithLabelProps | CheckboxWithChildrenProps;
23
23
  export declare function Checkbox(props: CheckboxProps): import("react/jsx-runtime").JSX.Element;
package/dist/index.js CHANGED
@@ -244,9 +244,12 @@ export { useHasReturnedFromAdyen } from './pages/checkout/payment-page/hooks/use
244
244
  export { PaymentPage } from './pages/checkout/payment-page/payment-page.js';
245
245
  export { PaymentPageContent } from './pages/checkout/payment-page/payment-page-content.js';
246
246
  export { parseAmount } from './pages/checkout/payment-page/utils/parse-amount.js';
247
+ export { AddressBookSelector } from './pages/checkout/shipping-page/components/address-book-selector.js';
247
248
  export { CurrencyChangeDialog } from './pages/checkout/shipping-page/components/currency-change-dialog.js';
248
249
  export { EDIT_ADDRESS_FORM_ID, EditCheckoutBillToAddressForm } from './pages/checkout/shipping-page/components/edit-checkout-bill-to-address-form.js';
249
250
  export { ReadOnlyAddresses } from './pages/checkout/shipping-page/components/readonly-address.js';
251
+ import 'react/jsx-runtime';
252
+ import 'react';
250
253
  export { SonicAddress } from './pages/checkout/shipping-page/components/sonic-address.js';
251
254
  export { usePatchShippingDetails } from './pages/checkout/shipping-page/hooks/use-patch-shipping-details.js';
252
255
  export { ShippingPage } from './pages/checkout/shipping-page/shipping-page.js';
@@ -1 +1 @@
1
- export type TranslationId = "'{0}' in all products" | "Try 'Search' and try to find the product you're looking for" | "Unfortnately, We found no articles for your search '{0}'" | ' to your account to manage your lists.' | 'Access denied.' | 'Account' | 'Account was activated successfully.' | 'active' | 'Add address' | 'Add order notes' | 'Add to cart' | 'Add to list' | 'Address 1' | 'Address 2' | 'Address 3' | 'Address 4' | 'Address not found' | 'Address' | 'Address book' | 'addressProperty.Default' | 'addressProperty.Company Name' | 'addressProperty.Address Line' | 'addressProperty.Postal Code' | 'addressProperty.City' | 'addressProperty.Country' | 'All payment methods are unavailable at this time. Please contact customer support.' | 'Amount: {0}' | 'An error occurred while changing the customer.' | 'An error occurred while fetching customers. Please try again later.' | 'An error occurred while processing your payment. Please try again.' | 'An unexpected error occured' | 'An unexpected error occured. Please try again.' | 'Are you looking for information about our service? Please visit our customer support page' | 'Are you sure you want to remove all items from your cart?' | 'Are you sure you want to remove this item from your cart?' | 'article' | 'articles' | 'As soon as possible' | 'ASC' | 'Attention' | 'Availability unknown, please contact customer support for lead time or alternatives.' | 'Back' | 'Billing address' | 'Billing and shipping address' | 'Billing and shipping information' | 'Billing' | 'Cancel' | 'Cart' | 'Change customer' | 'Change password' | 'Changing password…' | 'Changing your address is currently not possible. Please contact customer support to change your address.' | 'Checkout order' | 'Chosen filters' | 'City' | 'Clear filters' | 'Create' | 'Clear' | 'Click the button below to continue shopping.' | 'Client cases' | 'Close' | 'CoC number' | 'Column 1: Item number or customer part number' | 'Column 2: Quantity (optional)' | 'Column 3: Unit of measure (optional)' | 'Company name' | 'Conceal value' | 'Confirm new password' | 'Continue shopping' | 'Continue to sign in' | 'Continue' | 'Copyright © Sonic Equipment B.V.' | 'Cost overview' | 'Country' | 'Create a row for each product. The allowed maximum is 500 rows' | 'Create account' | 'Create new list' | 'Create or modify a spreadsheet' | 'Currency Change' | 'Current page' | 'Current password' | 'Current Password is invalid' | 'Date' | 'Decrease' | 'Default shipping address' | 'Delivery date' | 'Delivery expected on {0}' | 'DESC' | 'Double check your spelling' | 'Download spreadsheet template' | 'Downloads' | 'Easily add your favorite products' | 'Edit billing address' | 'Edit shipping address' | 'Edit Sonic account' | 'Edit' | 'Email' | 'Enter your email address and we will send you an email that will allow you to recover your password.' | 'Excl. VAT' | 'Explore by categories' | 'Exploring our products by category' | 'facet.categories' | 'facet.height' | 'facet.weight' | 'Favorites' | 'Features' | 'Filter order status' | 'Finalize order' | 'Finalize payment' | 'First name' | 'Forgot password?' | 'Fulfillment method' | 'General' | 'Good day' | 'Good morning' | 'Good afternoon' | 'Good evening' | 'Goodnight' | 'Guest' | 'Hide filters' | 'Home' | 'If an account matches the email address you entered, instructions on how to recover the password will be sent to that email address shortly. If you do not receive this email, please contact Customer Support.' | 'If you want to proceed, click the continue button. If you want to change your country, close this message and select a different country.' | 'Incl. VAT' | 'Includes' | 'Increase' | 'Industry' | 'industry.AG' | 'industry.AU' | 'industry.AV' | 'industry.BC' | 'industry.MA' | 'industry.MC' | 'industry.OT' | 'industry.PP' | 'industry.TR' | 'Information' | 'Instructions' | 'Language' | 'Last name' | 'List name already exists' | 'Log out' | 'Main menu' | 'Make sure the spreadsheet has 3 columns' | 'Make this the default customer' | 'Make this the default ship to address' | 'More than {0} articles' | 'My account' | 'My Sonic' | 'My Sonic menu' | 'Name' | 'Navigate to...' | 'Navigation' | 'New list name' | 'New Password is required and must be different than Current Password' | 'New password' | 'New user?' | 'Next' | 'No countries available. Unable to change address.' | 'No orders found.' | 'No results found. Please refine your search.' | 'No search results' | 'Number of favorites' | 'Number of products' | 'of' | 'OK' | 'Or continue as guest' | 'Order confirmation' | 'Order date' | 'Order details' | 'Order history' | 'Order number' | 'Order#' | 'Order' | 'orderProperty.Date' | 'orderProperty.Number' | 'orderProperty.PO Number' | 'orderProperty.Price' | 'orderProperty.Shipping Address' | 'orderProperty.Status' | 'Orders' | 'orderStatus.Any' | 'orderStatus.Cancelled' | 'orderStatus.ForwardToReseller' | 'orderStatus.Fulfilled' | 'orderStatus.Partially fulfilled' | 'orderStatus.Processing' | 'orderStatus.Saved' | 'orderStatus.Waiting for customer service' | 'Our products' | 'Overview' | 'Page not found.' | 'Password changed. Please sign in again.' | 'Password does not meet requirements' | 'Password' | 'Passwords do not match' | 'Pay by invoice' | 'Payment method' | 'Payment' | 'pc' | 'Phone' | 'Pick up' | 'Pickup address' | 'Please contact Customer Support if you need assistance.' | 'Please enter a valid email address' | 'Please enter a valid phone number' | 'please go back to your cart.' | 'Please Sign In' | 'PO Number' | 'Popular searches' | 'Postal Code' | 'Previous' | 'Print' | 'Private account' | 'Processing' | 'Product Features' | 'Product' | 'Products' | 'Quantity' | 'Quick access' | 'Recent searches' | 'Recently viewed' | 'Recover your password' | 'Reset' | 'Remember me' | 'Remove' | 'Remove all' | 'Reorder' | 'Reordering...' | 'Requested delivery date' | 'Results' | 'Reveal value' | 'Review and payment' | 'Save order' | 'Save' | 'Save the file in XLS, XLSX or CSV format' | 'Saved' | 'Saved cart for later.' | 'Saving' | 'Search for a customer' | 'Search' | 'Searching again using more general terms' | 'Search orders' | 'See all results' | 'Select a country' | 'Select a desired delivery date' | 'Select a language' | 'Select a list' | 'Select an industry' | 'Select other customer' | 'Select the file to upload in the form and click Upload order' | 'Selected customer' | 'Selecting As Soon As Possible will enable us to send the products to you as they become available.' | 'Selecting this country will result in your cart to be converted to the currency {0}' | 'Share your favorite list with others' | 'Ship' | 'Shipping address' | 'Shipping and handling' | 'Shipping details' | 'Shop more efficiently and quicker with a favorites list' | 'Shopping cart' | 'Show all' | 'Show filters' | 'Show less' | 'Show' | 'Sign in or create account' | 'Sign in' | 'Sign me up for newsletters and product updates' | 'Signed in' | 'Signed out' | 'Signing in…' | 'Something went wrong' | 'Sonic account' | 'Sonic address' | 'Sonic Equipment' | 'Sorry, there are no products found' | 'Sorry, we could not find matches for' | 'Sort by' | 'sort.newest' | 'sort.price_asc' | 'sort.price_desc' | 'sort.relevance' | 'sort.ASC' | 'sort.DESC' | 'sort.NONE' | 'Specifications' | 'Start checkout' | 'Status' | 'Submenu' | 'Submit email address' | 'Submit' | 'Submitting…' | 'Subtotal' | 'Suggestions' | 'Support' | 'tag.limited' | 'tag.new' | 'The email address you entered is already associated with an existing account. Please sign in to this account or contact Customer Support.' | 'The expected delivery is an indication based on the product availability and the shipping location.' | 'The link you used for resetting your password is invalid. Please, reset your password again, or contact Customer Support.' | 'The password could not be changed. Please, reset your password again, or contact Customer Support.' | 'The product has been added to your cart.' | 'The product has been removed from your cart.' | 'The product has been updated in your cart.' | 'The option to upload an Excel file with your order is temporarily unavailable.' | 'The order has been added to your cart.' | 'The user to change the password for could not be found. Please, reset your password again, or contact Customer Support.' | 'There are more customers, please refine your search if needed.' | 'There are no products in your shopping cart.' | 'There is no information to display' | 'This email is already in use' | 'Toggle navigation menu' | 'Total amount is' | 'Total' | 'Try another search' | 'Unable to add the product to your cart.' | 'Unable to add the order to your cart.' | 'Unable to empty your cart.' | 'Unable to remove the product from your cart.' | 'Unable to save cart for later.' | 'Unable to update the product in your cart.' | 'Unknown' | 'Updating address' | 'Upload order' | 'Upload an Excel (XLS/XLSX) spreadsheet or CSV file to quickly add items to your cart.' | 'Use billing address' | 'Use fewer keywords' | 'Username' | 'Validating' | 'validation.badInput' | 'validation.customError' | 'validation.invalid' | 'validation.patternMismatch' | 'validation.rangeOverflow' | 'validation.rangeUnderflow' | 'validation.stepMismatch' | 'validation.tooLong' | 'validation.tooShort' | 'validation.typeMismatch' | 'validation.valid' | 'validation.valueMissing' | 'VAT Number' | 'VAT' | 'Welcome to Sonic Equipment. Please choose your country and language below.' | 'What are you searching for?' | 'You are not authorized to access this information.' | 'You are not authorized to perform this action' | 'You are not authorized to view customers. Please log in or contact support.' | 'You are required to change your password and then sign in again, using your new credentials.' | 'You could try checking the spelling of your search query' | 'You could try exploring our products by category' | 'You could try' | 'You have no favorite products yet.' | 'You have reached the end of the results, but there may be more articles available. Adjust your filters or search to discover more!' | 'You must ' | 'You selected a country where we invoice in a different currency. This will result in your cart being converted to the new currency. If you would like to review your order, ' | 'Your account is temporarily locked. Please try again later or contact Customer Support.' | 'Your cart has been emptied.' | 'Your email and password were not recognized.' | 'Your favorites are available on multiple devices' | 'Your new Sonic Equipment account was succesfully created. You should receive an email soon with further instructions on how to activate this account. If you do not receive this email, please contact Customer Support.' | 'Your shopping cart is still empty';
1
+ export type TranslationId = "'{0}' in all products" | "Try 'Search' and try to find the product you're looking for" | "Unfortnately, We found no articles for your search '{0}'" | ' to your account to manage your lists.' | 'Access denied.' | 'Account' | 'Account was activated successfully.' | 'active' | 'Add address' | 'Add order notes' | 'Add to cart' | 'Add to list' | 'Address 1' | 'Address 2' | 'Address 3' | 'Address 4' | 'Address not found' | 'Address' | 'Address book' | 'addressProperty.Default' | 'addressProperty.Company Name' | 'addressProperty.Address Line' | 'addressProperty.Postal Code' | 'addressProperty.City' | 'addressProperty.Country' | 'All payment methods are unavailable at this time. Please contact customer support.' | 'Amount: {0}' | 'An error occurred while changing the customer.' | 'An error occurred while fetching customers. Please try again later.' | 'An error occurred while fetching addresses. Please try again later.' | 'An error occurred while processing your payment. Please try again.' | 'An unexpected error occured' | 'An unexpected error occured. Please try again.' | 'Are you looking for information about our service? Please visit our customer support page' | 'Are you sure you want to remove all items from your cart?' | 'Are you sure you want to remove this item from your cart?' | 'article' | 'articles' | 'As soon as possible' | 'ASC' | 'Attention' | 'Availability unknown, please contact customer support for lead time or alternatives.' | 'Back' | 'Billing address' | 'Billing and shipping address' | 'Billing and shipping information' | 'Billing' | 'Cancel' | 'Cart' | 'Change customer' | 'Change password' | 'Changing password…' | 'Changing your address is currently not possible. Please contact customer support to change your address.' | 'Checkout order' | 'Chosen filters' | 'City' | 'Clear filters' | 'Create' | 'Clear' | 'Click the button below to continue shopping.' | 'Client cases' | 'Close' | 'CoC number' | 'Column 1: Item number or customer part number' | 'Column 2: Quantity (optional)' | 'Column 3: Unit of measure (optional)' | 'Company name' | 'Conceal value' | 'Confirm new password' | 'Continue shopping' | 'Continue to sign in' | 'Continue' | 'Copyright © Sonic Equipment B.V.' | 'Cost overview' | 'Country' | 'Create a row for each product. The allowed maximum is 500 rows' | 'Create account' | 'Create new list' | 'Create or modify a spreadsheet' | 'Currency Change' | 'Current page' | 'Current password' | 'Current Password is invalid' | 'Date' | 'Decrease' | 'Default shipping address' | 'Delivery date' | 'Delivery expected on {0}' | 'DESC' | 'Double check your spelling' | 'Download spreadsheet template' | 'Downloads' | 'Easily add your favorite products' | 'Edit billing address' | 'Edit shipping address' | 'Edit Sonic account' | 'Edit' | 'Email' | 'Enter your email address and we will send you an email that will allow you to recover your password.' | 'Excl. VAT' | 'Explore by categories' | 'Exploring our products by category' | 'facet.categories' | 'facet.height' | 'facet.weight' | 'Favorites' | 'Features' | 'Filter order status' | 'Finalize order' | 'Finalize payment' | 'First name' | 'Forgot password?' | 'Fulfillment method' | 'General' | 'Good day' | 'Good morning' | 'Good afternoon' | 'Good evening' | 'Goodnight' | 'Guest' | 'Hide filters' | 'Home' | 'If an account matches the email address you entered, instructions on how to recover the password will be sent to that email address shortly. If you do not receive this email, please contact Customer Support.' | 'If you want to proceed, click the continue button. If you want to change your country, close this message and select a different country.' | 'Incl. VAT' | 'Includes' | 'Increase' | 'Industry' | 'industry.AG' | 'industry.AU' | 'industry.AV' | 'industry.BC' | 'industry.MA' | 'industry.MC' | 'industry.OT' | 'industry.PP' | 'industry.TR' | 'Information' | 'Instructions' | 'Language' | 'Last name' | 'List name already exists' | 'Log out' | 'Main menu' | 'Make sure the spreadsheet has 3 columns' | 'Make this the default customer' | 'Make this the default ship to address' | 'More than {0} articles' | 'My account' | 'My Sonic' | 'My Sonic menu' | 'Name' | 'Navigate to...' | 'Navigation' | 'New list name' | 'New Password is required and must be different than Current Password' | 'New password' | 'New user?' | 'Next' | 'No countries available. Unable to change address.' | 'No orders found.' | 'No results found. Please refine your search.' | 'No search results' | 'Number of favorites' | 'Number of products' | 'of' | 'OK' | 'Or continue as guest' | 'Order confirmation' | 'Order date' | 'Order details' | 'Order history' | 'Order number' | 'Order#' | 'Order' | 'orderProperty.Date' | 'orderProperty.Number' | 'orderProperty.PO Number' | 'orderProperty.Price' | 'orderProperty.Shipping Address' | 'orderProperty.Status' | 'Orders' | 'orderStatus.Any' | 'orderStatus.Cancelled' | 'orderStatus.ForwardToReseller' | 'orderStatus.Fulfilled' | 'orderStatus.Partially fulfilled' | 'orderStatus.Processing' | 'orderStatus.Saved' | 'orderStatus.Waiting for customer service' | 'Our products' | 'Overview' | 'Page not found.' | 'Password changed. Please sign in again.' | 'Password does not meet requirements' | 'Password' | 'Passwords do not match' | 'Pay by invoice' | 'Payment method' | 'Payment' | 'pc' | 'Phone' | 'Pick up' | 'Pickup address' | 'Please contact Customer Support if you need assistance.' | 'Please enter a valid email address' | 'Please enter a valid phone number' | 'please go back to your cart.' | 'Please Sign In' | 'PO Number' | 'Popular searches' | 'Postal Code' | 'Previous' | 'Print' | 'Private account' | 'Processing' | 'Product Features' | 'Product' | 'Products' | 'Quantity' | 'Quick access' | 'Recent searches' | 'Recently viewed' | 'Recover your password' | 'Reset' | 'Remember me' | 'Remove' | 'Remove all' | 'Reorder' | 'Reordering...' | 'Requested delivery date' | 'Results' | 'Reveal value' | 'Review and payment' | 'Save order' | 'Save' | 'Save the file in XLS, XLSX or CSV format' | 'Saved' | 'Saved cart for later.' | 'Saving' | 'Search for a customer' | 'Search' | 'Searching again using more general terms' | 'Search orders' | 'Search addresses' | 'See all results' | 'Select a country' | 'Select a desired delivery date' | 'Select a language' | 'Select a list' | 'Select an industry' | 'Select other customer' | 'Select the file to upload in the form and click Upload order' | 'Selected customer' | 'Selecting As Soon As Possible will enable us to send the products to you as they become available.' | 'Selecting this country will result in your cart to be converted to the currency {0}' | 'Share your favorite list with others' | 'Ship' | 'Shipping address' | 'Shipping and handling' | 'Shipping details' | 'Shop more efficiently and quicker with a favorites list' | 'Shopping cart' | 'Show all' | 'Show filters' | 'Show less' | 'Show' | 'Sign in or create account' | 'Sign in' | 'Sign me up for newsletters and product updates' | 'Signed in' | 'Signed out' | 'Signing in…' | 'Something went wrong' | 'Sonic account' | 'Sonic address' | 'Sonic Equipment' | 'Sorry, there are no products found' | 'Sorry, we could not find matches for' | 'Sort by' | 'sort.newest' | 'sort.price_asc' | 'sort.price_desc' | 'sort.relevance' | 'sort.ASC' | 'sort.DESC' | 'sort.NONE' | 'Specifications' | 'Start checkout' | 'Status' | 'Submenu' | 'Submit email address' | 'Submit' | 'Submitting…' | 'Subtotal' | 'Suggestions' | 'Support' | 'tag.limited' | 'tag.new' | 'The email address you entered is already associated with an existing account. Please sign in to this account or contact Customer Support.' | 'The expected delivery is an indication based on the product availability and the shipping location.' | 'The link you used for resetting your password is invalid. Please, reset your password again, or contact Customer Support.' | 'The password could not be changed. Please, reset your password again, or contact Customer Support.' | 'The product has been added to your cart.' | 'The product has been removed from your cart.' | 'The product has been updated in your cart.' | 'The option to upload an Excel file with your order is temporarily unavailable.' | 'The order has been added to your cart.' | 'The user to change the password for could not be found. Please, reset your password again, or contact Customer Support.' | 'There are more customers, please refine your search if needed.' | 'There are more addresses, please refine your search if needed.' | 'There are no products in your shopping cart.' | 'There is no information to display' | 'This email is already in use' | 'Toggle navigation menu' | 'Total amount is' | 'Total' | 'Try another search' | 'Unable to add the product to your cart.' | 'Unable to add the order to your cart.' | 'Unable to empty your cart.' | 'Unable to remove the product from your cart.' | 'Unable to save cart for later.' | 'Unable to update the product in your cart.' | 'Unknown' | 'Updating address' | 'Upload order' | 'Upload an Excel (XLS/XLSX) spreadsheet or CSV file to quickly add items to your cart.' | 'Use billing address' | 'Use default shipping address' | 'Use new address' | 'Use fewer keywords' | 'Username' | 'Validating' | 'validation.badInput' | 'validation.customError' | 'validation.invalid' | 'validation.patternMismatch' | 'validation.rangeOverflow' | 'validation.rangeUnderflow' | 'validation.stepMismatch' | 'validation.tooLong' | 'validation.tooShort' | 'validation.typeMismatch' | 'validation.valid' | 'validation.valueMissing' | 'VAT Number' | 'VAT' | 'Welcome to Sonic Equipment. Please choose your country and language below.' | 'What are you searching for?' | 'You are not authorized to access this information.' | 'You are not authorized to perform this action' | 'You are not authorized to view customers. Please log in or contact support.' | 'You are not authorized to view addresses. Please log in or contact support.' | 'You are required to change your password and then sign in again, using your new credentials.' | 'You could try checking the spelling of your search query' | 'You could try exploring our products by category' | 'You could try' | 'You have no favorite products yet.' | 'You have reached the end of the results, but there may be more articles available. Adjust your filters or search to discover more!' | 'You must ' | 'You selected a country where we invoice in a different currency. This will result in your cart being converted to the new currency. If you would like to review your order, ' | 'Your account is temporarily locked. Please try again later or contact Customer Support.' | 'Your cart has been emptied.' | 'Your email and password were not recognized.' | 'Your favorites are available on multiple devices' | 'Your new Sonic Equipment account was succesfully created. You should receive an email soon with further instructions on how to activate this account. If you do not receive this email, please contact Customer Support.' | 'Your shopping cart is still empty';
@@ -1,32 +1,19 @@
1
1
  "use client";
2
2
  import { jsx } from 'react/jsx-runtime';
3
- import { useEffect } from 'react';
4
3
  import { LoadingPage } from '../../loading-page/loading-page.js';
5
4
  import { useIsAuthenticated } from '../../../shared/api/storefront/hooks/authentication/use-is-authenticated.js';
6
5
  import { useFetchCartById } from '../../../shared/api/storefront/hooks/cart/use-fetch-cart-by-id.js';
7
6
  import { useNavigate } from '../../../shared/routing/use-navigate.js';
8
- import { usePaths } from '../../../shared/routing/use-paths.js';
9
7
  import { hasNo } from '../../../shared/utils/types.js';
10
8
  import { ErrorPage } from '../../error-page/error-page.js';
11
9
  import { OrderConfirmationPageContent } from './order-confirmation-page-content.js';
12
10
 
13
11
  function OrderConfirmationPage({ cartId }) {
14
- const paths = usePaths();
15
12
  const isAuthenticated = useIsAuthenticated();
16
- const { isNavigating, navigate } = useNavigate();
13
+ const { isNavigating } = useNavigate();
17
14
  const { data: cart, error, isLoading: cartIsLoading, } = useFetchCartById({
18
15
  id: cartId,
19
16
  });
20
- useEffect(() => {
21
- if (!cart)
22
- return;
23
- if (isAuthenticated === undefined)
24
- return;
25
- if (!isAuthenticated)
26
- return navigate(paths.CART);
27
- if (cart.status === 'Cart')
28
- navigate(paths.CART);
29
- }, [cart, navigate, isAuthenticated, paths]);
30
17
  if (error)
31
18
  return jsx(ErrorPage, { error: error });
32
19
  if (cartIsLoading || isNavigating)
@@ -24,7 +24,9 @@ function PaymentPage({ hasReturnedFromAdyen, }) {
24
24
  const [isProcessing, setIsProcessing] = useState(false);
25
25
  const { isNavigating, navigate } = useNavigate();
26
26
  const onPaymentComplete = useCallback(({ cartId }) => {
27
- navigate(`${paths.ORDER_CONFIRMATION}?cartId=${cartId}`);
27
+ setTimeout(() => {
28
+ navigate(`${paths.ORDER_CONFIRMATION}?cartId=${cartId}`);
29
+ }, 500);
28
30
  }, [navigate, paths]);
29
31
  useEffect(() => {
30
32
  if (isNavigating)
@@ -0,0 +1,6 @@
1
+ export interface AddressBookSelectorProps {
2
+ billToId: string;
3
+ className?: string;
4
+ currentShipToId?: string;
5
+ }
6
+ export declare function AddressBookSelector({ className, currentShipToId, }: AddressBookSelectorProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,81 @@
1
+ "use client";
2
+ import { jsxs, jsx } from 'react/jsx-runtime';
3
+ import { useRef, useState, useCallback, useMemo } from 'react';
4
+ import { ListBox, ListBoxItem, Text } from 'react-aria-components';
5
+ import clsx from 'clsx';
6
+ import { Checkbox } from '../../../../forms/elements/checkbox/checkbox.js';
7
+ import { SearchField } from '../../../../forms/fields/search-field/search-field.js';
8
+ import { FormattedMessage } from '../../../../intl/formatted-message.js';
9
+ import { useFormattedMessage } from '../../../../intl/use-formatted-message.js';
10
+ import { Message } from '../../../../message/message.js';
11
+ import { useFetchPagedShipToAddresses } from '../../../../shared/api/storefront/hooks/customer/use-fetch-paged-ship-to-addresses.js';
12
+ import { UnauthorizedRequestError } from '../../../../shared/fetch/request.js';
13
+ import { HighlightText } from '../../../../text/highlight-text/highlight-text.js';
14
+ import styles from './address-book-selector.module.css.js';
15
+
16
+ const DEFAULT_PAGE_SIZE = 20;
17
+ function AddressBookSelector({
18
+ // billToId,
19
+ className, currentShipToId, }) {
20
+ const t = useFormattedMessage();
21
+ const listBoxRef = useRef(null);
22
+ const [selectedAddressId, setSelectedAddressId] = useState(currentShipToId);
23
+ const [search, setSearch] = useState('');
24
+ const [page] = useState(1);
25
+ const { data, error, isFetching } = useFetchPagedShipToAddresses({
26
+ page,
27
+ pageSize: DEFAULT_PAGE_SIZE,
28
+ search,
29
+ });
30
+ const hasMoreResults = !isFetching &&
31
+ data?.pagination &&
32
+ data.pagination.totalItemCount > DEFAULT_PAGE_SIZE;
33
+ const onAddressSelectionChanged = useCallback((key) => {
34
+ if (key && key !== 'undefined' && key !== '') {
35
+ setSelectedAddressId(String(key));
36
+ }
37
+ }, []);
38
+ const [listBoxItems, rerenderKey] = useMemo(() => {
39
+ const listBoxItems = [...(data?.shipTos || [])];
40
+ if (error instanceof UnauthorizedRequestError) {
41
+ listBoxItems.push({
42
+ id: 'message',
43
+ message: t('You are not authorized to view addresses. Please log in or contact support.'),
44
+ type: 'danger',
45
+ });
46
+ }
47
+ else if (error) {
48
+ listBoxItems.push({
49
+ id: 'message',
50
+ message: t('An error occurred while fetching addresses. Please try again later.'),
51
+ type: 'danger',
52
+ });
53
+ }
54
+ else if (hasMoreResults) {
55
+ listBoxItems.push({
56
+ id: 'message',
57
+ message: t('There are more addresses, please refine your search if needed.'),
58
+ type: 'warning',
59
+ });
60
+ }
61
+ return [
62
+ listBoxItems,
63
+ Math.random().toString(36).slice(2, 15) + currentShipToId,
64
+ ];
65
+ }, [data?.shipTos, error, hasMoreResults, t, currentShipToId]);
66
+ return (jsxs("div", { className: clsx(styles['address-book-selector-container'], className), children: [jsx(SearchField, { autoFocus: true, isDebounced: true, "aria-controls": "filtered-address-results-list", isDisabled: isFetching, isLoading: isFetching, label: t('Search addresses'), onChange: setSearch, onKeyUp: ({ key }) => {
67
+ if (key === 'ArrowDown') {
68
+ listBoxRef.current?.focus();
69
+ }
70
+ }, placeholder: t('Search addresses'), showLabel: false, size: "md", value: search, variant: "outline" }), jsx(ListBox, { ref: listBoxRef, "aria-label": "List of addresses", "aria-live": "polite", className: styles['list-box'], id: "filtered-address-results-list", items: listBoxItems, onSelectionChange: keys => onAddressSelectionChanged(String([...keys][0])), renderEmptyState: () => !isFetching && (jsx(Message, { type: "info", children: jsx(FormattedMessage, { id: "Address not found" }) })), selectedKeys: selectedAddressId ? [selectedAddressId] : [], selectionBehavior: "replace", selectionMode: "single", children: listBoxItem => 'type' in listBoxItem ? (jsx(ListBoxItem, { isDisabled: true, textValue: listBoxItem.id, children: jsx(Message, { type: listBoxItem.type, children: jsx(Text, { slot: "description", children: listBoxItem.message }) }) }, "marker")) : (jsxs(ListBoxItem, { className: styles['list-box-item'], id: listBoxItem.id, textValue: listBoxItem.id, children: [jsx(Checkbox, { isReadOnly: true, isSelected: selectedAddressId === listBoxItem.id }), jsxs("div", { className: styles['list-box-item-content'], children: [jsx(Text, { slot: "label", children: jsx("div", { className: styles['company-name'], children: jsx(HighlightText, { className: styles['company-name-text'], highlightText: search, text: `${listBoxItem.address1} ${listBoxItem.address2 || ''}`.trim() }) }) }), jsxs(Text, { slot: "description", children: [jsx("div", { children: jsx(HighlightText, { highlightText: search, text: [listBoxItem.companyName, listBoxItem.customerName]
71
+ .filter(Boolean)
72
+ .join(', ') }) }), jsx("div", { children: jsx(HighlightText, { highlightText: search, text: [
73
+ listBoxItem.city,
74
+ listBoxItem.postalCode,
75
+ listBoxItem.country?.name,
76
+ ]
77
+ .filter(Boolean)
78
+ .join(', ') }) })] })] })] }, `${listBoxItem.id}-${selectedAddressId === listBoxItem.id}`)) }, `${rerenderKey}-${selectedAddressId}`), selectedAddressId && (jsx("input", { name: "selectedShipToId", type: "hidden", value: selectedAddressId }))] }));
79
+ }
80
+
81
+ export { AddressBookSelector };
@@ -0,0 +1,3 @@
1
+ var styles = {"address-book-selector-container":"address-book-selector-module-vK8zS","list-box":"address-book-selector-module-l-Ld-","list-box-item":"address-book-selector-module-mdKrg","list-box-item-content":"address-book-selector-module-ApSjS","company-name":"address-book-selector-module-sWeiG","company-name-text":"address-book-selector-module-txXx3"};
2
+
3
+ export { styles as default };
@@ -1,11 +1,17 @@
1
- import { BillToModel, ShipToModel } from '../../../../shared/api/storefront/model/storefront.model';
2
- export declare function ReadOnlyAddresses({ billTo, isLoading, isPickup, notes, onSubmit, shipTo, }: {
1
+ import { BillToModel, PatchCartModel, PostShipToModel, ShipToModel } from '../../../../shared/api/storefront/model/storefront.model';
2
+ import { Country } from '../../../../shared/model/countries-languages';
3
+ export declare function ReadOnlyAddresses({ billTo, cartId, countries, currentCountry, isLoading, isPickup, notes, onSubmit, shipTo, }: {
3
4
  billTo: BillToModel | undefined | null;
5
+ cartId: string;
6
+ countries: Country[];
7
+ currentCountry?: Country | undefined;
4
8
  isLoading: boolean;
5
9
  isPickup: boolean;
6
10
  notes: string | undefined;
7
- onSubmit: ({ notes }: {
11
+ onSubmit: (args: {
12
+ cart?: PatchCartModel;
8
13
  notes: string | undefined;
14
+ shipTo?: PostShipToModel;
9
15
  }) => void;
10
16
  shipTo: ShipToModel | undefined | null;
11
17
  }): import("react/jsx-runtime").JSX.Element;
@@ -1,73 +1,123 @@
1
1
  "use client";
2
- import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
2
+ import { jsxs, jsx } from 'react/jsx-runtime';
3
3
  import { Form } from 'react-aria-components';
4
4
  import { AddressInfoDisplay } from '../../../../address-info-display/address-info-display.js';
5
- import { Link } from '../../../../buttons/link/link.js';
6
- import { Checkbox } from '../../../../forms/elements/checkbox/checkbox.js';
7
5
  import { TextField } from '../../../../forms/fields/text-field/text-field.js';
6
+ import { AddressForm } from '../../../../forms/partials/address-form/address-form.js';
8
7
  import { FormattedMessage } from '../../../../intl/formatted-message.js';
9
8
  import { useFormattedMessage } from '../../../../intl/use-formatted-message.js';
10
- import { useLocation } from '../../../../shared/routing/use-location.js';
11
- import { usePaths } from '../../../../shared/routing/use-paths.js';
12
- import { environment } from '../../../../shared/utils/environment.js';
13
9
  import { CheckoutPageSection } from '../../layouts/checkout-page-layout/components/checkout-page-section.js';
14
10
  import { CheckoutPageSectionContent } from '../../layouts/checkout-page-layout/components/checkout-page-section-content.js';
15
- import { CheckoutPageSectionLink } from '../../layouts/checkout-page-layout/components/checkout-page-section-link.js';
11
+ import { AddressBookSelector } from './address-book-selector.js';
16
12
  import { EDIT_ADDRESS_FORM_ID } from './edit-checkout-bill-to-address-form.js';
13
+ import ShipToModeSelector from './ship-to-mode-selector.js';
17
14
  import { SonicAddress } from './sonic-address.js';
18
15
  import styles from './readonly-address.module.css.js';
19
16
 
20
- function ReadOnlyAddresses({ billTo, isLoading, isPickup, notes, onSubmit, shipTo, }) {
17
+ function ReadOnlyAddresses({ billTo, cartId, countries, currentCountry, isLoading, isPickup, notes, onSubmit, shipTo, }) {
21
18
  const t = useFormattedMessage();
22
- const paths = usePaths();
23
- const { pathname, search } = useLocation();
24
- const href = `${pathname}${search}`;
25
19
  const billToId = billTo?.id;
26
20
  const shipToId = shipTo?.id;
27
21
  const isShipToABillToAddress = billToId && shipToId && billToId === shipToId;
28
- const editBillToAddressUrl = environment.includes('next')
29
- ? `${paths.ACCOUNT_EDIT_BILL_TO_ADDRESS}/${billToId}?returnUrl=${encodeURIComponent(href)}`
30
- : paths.ACCOUNT_ADDRESSES;
31
- const editShipToAddressUrl = environment.includes('next')
32
- ? isShipToABillToAddress
33
- ? `${paths.ACCOUNT_EDIT_BILL_TO_ADDRESS}/${billToId}${paths.ACCOUNT_EDIT_SHIP_TO_ADDRESS}/new?returnUrl=${encodeURIComponent(href)}&makeDefault=true`
34
- : `${paths.ACCOUNT_EDIT_BILL_TO_ADDRESS}/${billToId}${paths.ACCOUNT_EDIT_SHIP_TO_ADDRESS}/${shipToId}?returnUrl=${encodeURIComponent(href)}`
35
- : paths.ACCOUNT_ADDRESSES;
36
- return (jsxs(Form, { id: EDIT_ADDRESS_FORM_ID, onSubmit: e => {
37
- e.preventDefault();
38
- const formData = new FormData(e.currentTarget);
39
- onSubmit({
40
- notes: notes === formData.get('notes')
41
- ? undefined
42
- : formData.get('notes')?.toString() || '',
43
- });
44
- }, children: [jsxs(CheckoutPageSection, { title: jsx(FormattedMessage, { id: "Billing address" }), children: [jsx(CheckoutPageSectionLink, { children: jsxs(Link, { color: "secondary", href: editBillToAddressUrl, isDisabled: isLoading, children: [jsx(FormattedMessage, { id: "Edit billing address" }), " >"] }) }), jsxs(CheckoutPageSectionContent, { children: [billTo && (jsx(AddressInfoDisplay, { address: {
45
- address1: billTo.address1,
46
- address2: billTo.address2,
47
- address3: billTo.address3,
48
- attention: billTo.attention,
49
- city: billTo.city,
50
- companyName: billTo.companyName,
51
- country: billTo.country,
52
- email: billTo.email,
53
- firstName: billTo.firstName,
54
- lastName: billTo.lastName,
55
- phone: billTo.phone,
56
- postalCode: billTo.postalCode,
57
- }, "data-test-selector": "billToAddress" })), 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(Link, { color: "secondary", href: editShipToAddressUrl, 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(AddressInfoDisplay, { address: {
58
- address1: shipTo.address1,
59
- address2: shipTo.address2,
60
- address3: shipTo.address3,
61
- attention: shipTo.attention,
62
- city: shipTo.city,
63
- companyName: shipTo.companyName,
64
- country: shipTo.country,
65
- email: shipTo.email,
66
- firstName: shipTo.firstName,
67
- lastName: shipTo.lastName,
68
- phone: shipTo.phone,
69
- postalCode: shipTo.postalCode,
70
- }, "data-test-selector": "shipToAddress" }))] })) })] })] }));
22
+ const onSubmitHandler = (event) => {
23
+ event.preventDefault();
24
+ const formData = new FormData(event.currentTarget);
25
+ const shippingType = formData
26
+ .get('shippingType')
27
+ ?.toString();
28
+ switch (shippingType) {
29
+ case 'selectFromAddressBook': {
30
+ const selectedShipToId = formData.get('selectedShipToId')?.toString();
31
+ if (!selectedShipToId) {
32
+ return;
33
+ }
34
+ onSubmit({
35
+ cart: {
36
+ id: cartId,
37
+ shipTo: { id: selectedShipToId },
38
+ },
39
+ notes: notes === formData.get('notes')
40
+ ? undefined
41
+ : formData.get('notes')?.toString() || '',
42
+ });
43
+ break;
44
+ }
45
+ case 'useNewAddress': {
46
+ const countryFormValue = formData.get('countrySelect')?.toString();
47
+ const country = countries.find(country => country.id === countryFormValue);
48
+ if (!country)
49
+ throw new Error(`Country not found ${formData.get('country')}`);
50
+ const shipToUpdate = {
51
+ address1: formData.get('address1')?.toString() || '',
52
+ address2: formData.get('address2')?.toString() || '',
53
+ address3: formData.get('address3')?.toString() || '',
54
+ attention: formData.get('attention')?.toString() || '',
55
+ city: formData.get('city')?.toString() || '',
56
+ companyName: formData.get('companyName')?.toString() || '',
57
+ country,
58
+ email: formData.get('email')?.toString() || '',
59
+ firstName: formData.get('firstName')?.toString() || '',
60
+ isNew: true,
61
+ lastName: formData.get('lastName')?.toString() || '',
62
+ phone: formData.get('phone')?.toString() || '',
63
+ postalCode: formData.get('postalCode')?.toString() || '',
64
+ };
65
+ onSubmit({
66
+ notes: notes === formData.get('notes')
67
+ ? undefined
68
+ : formData.get('notes')?.toString() || '',
69
+ shipTo: shipToUpdate,
70
+ });
71
+ break;
72
+ }
73
+ case 'useBillTo': {
74
+ const country = countries.find(country => country.id === billTo.country.id);
75
+ if (!country)
76
+ throw new Error(`Country not found ${formData.get('country')}`);
77
+ onSubmit({
78
+ cart: {
79
+ id: cartId,
80
+ shipTo: null,
81
+ },
82
+ notes: notes === formData.get('notes')
83
+ ? undefined
84
+ : formData.get('notes')?.toString() || '',
85
+ });
86
+ break;
87
+ }
88
+ }
89
+ };
90
+ return (jsxs(Form, { id: EDIT_ADDRESS_FORM_ID, onSubmit: onSubmitHandler, children: [jsx(CheckoutPageSection, { title: jsx(FormattedMessage, { id: "Billing address" }), children: jsxs(CheckoutPageSectionContent, { children: [billTo && (jsx(AddressInfoDisplay, { address: {
91
+ address1: billTo.address1,
92
+ address2: billTo.address2,
93
+ address3: billTo.address3,
94
+ attention: billTo.attention,
95
+ city: billTo.city,
96
+ companyName: billTo.companyName,
97
+ country: billTo.country,
98
+ email: billTo.email,
99
+ firstName: billTo.firstName,
100
+ lastName: billTo.lastName,
101
+ phone: billTo.phone,
102
+ postalCode: billTo.postalCode,
103
+ }, "data-test-selector": "billToAddress" })), 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 }) })] }) }), jsx(CheckoutPageSection, { title: jsx(FormattedMessage, { id: isPickup ? 'Pickup address' : 'Shipping address' }), children: jsx(CheckoutPageSectionContent, { stretch: true, children: isPickup ? (jsx(SonicAddress, {})) : (jsx(ShipToModeSelector, { addressBookSelector: billTo?.id && (jsx("div", { className: styles['address-book-selector'], children: jsx(AddressBookSelector, { billToId: billTo.id, currentShipToId: shipTo?.id }) })), defaultShippingOption: isShipToABillToAddress
104
+ ? 'useBillTo'
105
+ : shipTo
106
+ ? 'selectFromAddressBook'
107
+ : 'useNewAddress', newAddressForm: jsx("div", { className: styles['new-address-form'], children: jsx(AddressForm, { address: shipTo, countries: countries, currentCountry: currentCountry }) }), shipToInfoDisplay: shipTo && (jsx("div", { className: styles['ship-to-info-display'], children: jsx(AddressInfoDisplay, { address: {
108
+ address1: shipTo.address1,
109
+ address2: shipTo.address2,
110
+ address3: shipTo.address3,
111
+ attention: shipTo.attention,
112
+ city: shipTo.city,
113
+ companyName: shipTo.companyName,
114
+ country: shipTo.country,
115
+ email: shipTo.email,
116
+ firstName: shipTo.firstName,
117
+ lastName: shipTo.lastName,
118
+ phone: shipTo.phone,
119
+ postalCode: shipTo.postalCode,
120
+ }, "data-test-selector": "shipToAddress" }) })) })) }) })] }));
71
121
  }
72
122
 
73
123
  export { ReadOnlyAddresses };
@@ -1,3 +1,3 @@
1
- var styles = {"notes":"readonly-address-module-1hAQK","use-invoice-checkbox":"readonly-address-module-jMyJ-"};
1
+ var styles = {"notes":"readonly-address-module-1hAQK","ship-to-info-display":"readonly-address-module-1bMRB","address-book-selector":"readonly-address-module-8Y-8n","new-address-form":"readonly-address-module-p6QoO"};
2
2
 
3
3
  export { styles as default };
@@ -0,0 +1,8 @@
1
+ export type ShippingOption = 'useBillTo' | 'selectFromAddressBook' | 'useNewAddress';
2
+ export type ShipToSelectorProps = {
3
+ addressBookSelector?: React.ReactNode;
4
+ defaultShippingOption?: ShippingOption;
5
+ newAddressForm: React.ReactNode;
6
+ shipToInfoDisplay?: React.ReactNode;
7
+ };
8
+ export default function ShipToModeSelector(props: ShipToSelectorProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,25 @@
1
+ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
2
+ import { useState } from 'react';
3
+ import { SelectField } from '../../../../forms/fields/select-field/select-field.js';
4
+ import { useFormattedMessage } from '../../../../intl/use-formatted-message.js';
5
+
6
+ function ShipToModeSelector(props) {
7
+ const t = useFormattedMessage();
8
+ const [shippingOption, setShippingOption] = useState(props.defaultShippingOption ?? 'useBillTo');
9
+ const options = {
10
+ // @ts-expect-error - Translation key will be added to translation files
11
+ selectFromAddressBook: t('Select from address book'),
12
+ useBillTo: t('Use billing address'),
13
+ // useDefaultShipTo: t('Use default shipping address'),
14
+ useNewAddress: t('Use new address'),
15
+ };
16
+ const additionalComponentForShipping = {
17
+ selectFromAddressBook: props.addressBookSelector,
18
+ useBillTo: null,
19
+ // useDefaultShipTo: props.shipToInfoDisplay,
20
+ useNewAddress: props.newAddressForm,
21
+ }[shippingOption];
22
+ return (jsxs(Fragment, { children: [jsx(SelectField, { "data-test-selector": "order-history-filter", label: t('Shipping address'), name: "shippingType", onChange: setShippingOption, options: options, selectedOption: shippingOption, showLabel: false }), additionalComponentForShipping] }));
23
+ }
24
+
25
+ export { ShipToModeSelector as default };
@@ -8,6 +8,11 @@ export declare function usePatchShippingDetails(): {
8
8
  billTo?: PatchBillToModel;
9
9
  cart: PatchCartModel;
10
10
  notes: string | undefined;
11
+ shipTo?: Partial<Omit<import("../../../../shared/api/storefront/model/storefront.model").ShipToModel, "country"> & {
12
+ country?: import("../../../../shared/api/storefront/model/storefront.model").CountryModel | {
13
+ id: string;
14
+ } | null;
15
+ }>;
11
16
  }) => Promise<{
12
17
  patchedBillTo: BillToModel | undefined;
13
18
  patchedCart: CartModel | undefined;
@@ -2,26 +2,41 @@
2
2
  import { patchCart } from '../../../../shared/api/bff/services/bff-service.js';
3
3
  import { useAwaitableMutation } from '../../../../shared/api/shared/hooks/use-awaitable-mutation.js';
4
4
  import { patchSession } from '../../../../shared/api/storefront/services/authentication-service.js';
5
- import { patchBillToAddress } from '../../../../shared/api/storefront/services/customer-service.js';
5
+ import { postShipToAddress, patchBillToAddress } from '../../../../shared/api/storefront/services/customer-service.js';
6
6
 
7
7
  function usePatchShippingDetails() {
8
8
  return useAwaitableMutation({
9
- mutationFn: async ({ billTo, cart, notes, }) => {
9
+ mutationFn: async ({ billTo, cart, notes, shipTo, }) => {
10
+ const postedShipTo = shipTo
11
+ ? await postShipToAddress({
12
+ billToId: cart.billTo.id,
13
+ shipTo,
14
+ })
15
+ : undefined;
10
16
  const patchedBillTo = billTo
11
17
  ? await patchBillToAddress({ billTo })
12
18
  : undefined;
13
- const patchedSession = patchedBillTo
19
+ const patchedSession = patchedBillTo || cart.shipTo !== null
14
20
  ? await patchSession({
15
21
  session: {
16
- billTo: { id: patchedBillTo.id },
22
+ billTo: patchedBillTo ? { id: patchedBillTo.id } : undefined,
17
23
  customerWasUpdated: true,
18
- shipTo: { id: cart.shipTo?.id || patchedBillTo.id },
24
+ shipTo: postedShipTo ? { id: postedShipTo.id } : undefined,
19
25
  },
20
26
  })
21
27
  : undefined;
22
- const patchedCart = patchedBillTo || notes !== undefined
28
+ const patchedCart = patchedBillTo ||
29
+ patchedSession ||
30
+ notes !== undefined ||
31
+ postedShipTo ||
32
+ cart.shipTo === null
23
33
  ? await patchCart({
24
- cart: { ...cart, billTo: patchedBillTo, notes },
34
+ cart: {
35
+ ...cart,
36
+ billTo: patchedBillTo || cart.billTo,
37
+ notes,
38
+ shipTo: postedShipTo ?? cart.shipTo ?? { id: cart.billTo.id },
39
+ },
25
40
  })
26
41
  : undefined;
27
42
  return { patchedBillTo, patchedCart, patchedSession };
@@ -154,14 +154,26 @@ function ShippingPage() {
154
154
  },
155
155
  });
156
156
  await refetchCart();
157
- }, readOnlyAddress: jsx(ReadOnlyAddresses, { billTo: cart.billTo, isLoading: isPatching, isPickup: isPickup, notes: cart.notes, onSubmit: async ({ notes }) => {
157
+ }, readOnlyAddress: jsx(ReadOnlyAddresses, { billTo: cart.billTo, cartId: cart.id, countries: countries || [], currentCountry: currentCountry, isLoading: isPatching, isPickup: isPickup, notes: cart.notes, onSubmit: async ({ cart: updatedCart, notes, shipTo }) => {
158
158
  if (!cart.billTo)
159
159
  return;
160
- if (notes === undefined) {
161
- navigate(paths.REVIEW_AND_SUBMIT);
160
+ if (notes ||
161
+ cart.shipTo === null ||
162
+ (shipTo && shipTo.id !== cart.shipTo?.id) ||
163
+ (updatedCart &&
164
+ (updatedCart.shipTo?.id !== cart.shipTo?.id ||
165
+ updatedCart.shipTo === null))) {
166
+ await patchShippingDetails({
167
+ cart: {
168
+ ...cart,
169
+ ...updatedCart,
170
+ },
171
+ notes,
172
+ shipTo,
173
+ });
162
174
  }
163
175
  else {
164
- await patchShippingDetails({ cart, notes });
176
+ navigate(paths.REVIEW_AND_SUBMIT);
165
177
  }
166
178
  dataLayer.push(createEcommerceEvent({
167
179
  cart,
@@ -1001,10 +1001,13 @@ export type PatchShipToModel = Partial<Omit<ShipToModel, 'country'> & {
1001
1001
  }> & {
1002
1002
  id: string;
1003
1003
  };
1004
- export type PatchCartModel = Partial<Omit<CartModel, 'billTo'> & {
1004
+ export type PatchCartModel = Partial<Omit<Omit<CartModel, 'billTo'>, 'shipTo'> & {
1005
1005
  billTo?: PatchBillToModel | {
1006
1006
  id: string;
1007
1007
  } | null;
1008
+ shipTo?: PatchShipToModel | {
1009
+ id: string;
1010
+ } | null;
1008
1011
  }> & {
1009
1012
  id: string;
1010
1013
  };
package/dist/styles.css CHANGED
@@ -8100,6 +8100,93 @@ button.swiper-pagination-bullet {
8100
8100
  gap: var(--space-8);
8101
8101
  }
8102
8102
 
8103
+ .highlight-text-module-e6Irk {
8104
+ background-color: var(--highlighted-text-bg-color, rgb(109 170 200 / 40%));
8105
+ }
8106
+
8107
+ .address-book-selector-module-vK8zS {
8108
+ display: grid;
8109
+ block-size: 100%;
8110
+ gap: var(--space-8);
8111
+ grid-template-rows: min-content 1fr;
8112
+ }
8113
+
8114
+ .address-book-selector-module-l-Ld- {
8115
+ box-sizing: border-box;
8116
+ border: 1.5px solid var(--color-brand-medium-gray);
8117
+ border-radius: var(--border-radius-8);
8118
+ block-size: 100%;
8119
+ inline-size: 100%;
8120
+ overflow-y: scroll;
8121
+ }
8122
+
8123
+ .address-book-selector-module-mdKrg {
8124
+ position: relative;
8125
+ display: flex;
8126
+ box-sizing: border-box;
8127
+ flex-direction: row;
8128
+ padding: var(--space-4) var(--space-12);
8129
+ -moz-column-gap: 16px;
8130
+ column-gap: 16px;
8131
+ cursor: pointer;
8132
+ }
8133
+
8134
+ .address-book-selector-module-mdKrg .address-book-selector-module-ApSjS {
8135
+ flex-grow: 1;
8136
+ }
8137
+
8138
+ .address-book-selector-module-mdKrg::after {
8139
+ position: absolute;
8140
+ display: block;
8141
+ background: var(--color-brand-light-gray);
8142
+ block-size: 1.5px;
8143
+ content: '';
8144
+ inset: auto 12px 0;
8145
+ }
8146
+
8147
+ .address-book-selector-module-mdKrg .address-book-selector-module-mabQ4 {
8148
+ width: 16px;
8149
+ height: 16px;
8150
+ color: var(--color-brand-primary);
8151
+ }
8152
+
8153
+ .address-book-selector-module-mdKrg [slot='label'] {
8154
+ display: flex;
8155
+ width: 100%;
8156
+ flex-direction: column;
8157
+ }
8158
+
8159
+ .address-book-selector-module-mdKrg [slot='label'] .address-book-selector-module-sWeiG {
8160
+ display: flex;
8161
+ flex-direction: row;
8162
+ align-items: center;
8163
+ gap: var(--space-4);
8164
+ }
8165
+
8166
+ .address-book-selector-module-mdKrg [slot='label'] .address-book-selector-module-sWeiG .address-book-selector-module-txXx3 {
8167
+ font-weight: bold;
8168
+ }
8169
+
8170
+ .address-book-selector-module-mdKrg:focus,
8171
+ .address-book-selector-module-mdKrg:hover,
8172
+ .address-book-selector-module-mdKrg:focus-visible {
8173
+ outline: none;
8174
+ }
8175
+
8176
+ .address-book-selector-module-mdKrg:focus::before, .address-book-selector-module-mdKrg:hover::before, .address-book-selector-module-mdKrg:focus-visible::before {
8177
+ position: absolute;
8178
+ z-index: -1;
8179
+ display: block;
8180
+ background: color-mix(in srgb, var(--color-brand-red) 25%, white);
8181
+ content: '';
8182
+ inset: 0;
8183
+ pointer-events: none;
8184
+ }
8185
+
8186
+ .address-book-selector-module-mdKrg:focus::after, .address-book-selector-module-mdKrg:hover::after, .address-book-selector-module-mdKrg:focus-visible::after {
8187
+ display: none;
8188
+ }
8189
+
8103
8190
  .sonic-address-module-9Q9-Q {
8104
8191
  line-height: 1.5;
8105
8192
  white-space: pre;
@@ -8143,6 +8230,38 @@ button.swiper-pagination-bullet {
8143
8230
  margin-bottom: var(--space-12);
8144
8231
  }
8145
8232
 
8233
+ .readonly-address-module-1bMRB {
8234
+ margin-top: var(--space-12);
8235
+ }
8236
+
8237
+ .readonly-address-module-8Y-8n {
8238
+ margin-top: var(--space-12);
8239
+ }
8240
+
8241
+ .readonly-address-module-p6QoO {
8242
+ display: grid;
8243
+ margin-top: var(--space-12);
8244
+ gap: var(--space-16);
8245
+ grid-template-columns: auto;
8246
+ }
8247
+
8248
+ .readonly-address-module-p6QoO .readonly-address-module-xkryv {
8249
+ display: grid;
8250
+ }
8251
+
8252
+ @media (width >= 768px) {
8253
+
8254
+ .readonly-address-module-p6QoO {
8255
+ align-items: flex-start;
8256
+ grid-template-columns: 1fr 1fr
8257
+ }
8258
+
8259
+ .readonly-address-module-p6QoO .readonly-address-module-xkryv {
8260
+ display: grid;
8261
+ grid-column: span 2;
8262
+ }
8263
+ }
8264
+
8146
8265
  .shipping-page-module-v6oci {
8147
8266
  display: grid;
8148
8267
  }
@@ -8151,10 +8270,6 @@ button.swiper-pagination-bullet {
8151
8270
  color: var(--color-brand-red);
8152
8271
  }
8153
8272
 
8154
- .highlight-text-module-e6Irk {
8155
- background-color: var(--highlighted-text-bg-color, rgb(109 170 200 / 40%));
8156
- }
8157
-
8158
8273
  .change-customer-module-2kOw4 {
8159
8274
  display: grid;
8160
8275
  block-size: 100%;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sonic-equipment/ui",
3
- "version": "258.0.4",
3
+ "version": "258.1.1",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "engines": {