@sonic-equipment/ui 1.1.3 → 1.1.5
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/algolia/algolia-search-provider.js +24 -2
- package/dist/exports.d.ts +3 -0
- package/dist/index.js +4 -0
- package/dist/intl/translation-id.d.ts +1 -1
- package/dist/pages/checkout/payment-page/components/payment.js +7 -4
- package/dist/pages/checkout/shipping-page/components/address-book-selector.js +1 -1
- package/dist/pages/checkout/shipping-page/components/readonly-address.d.ts +2 -1
- package/dist/pages/checkout/shipping-page/components/readonly-address.js +19 -17
- package/dist/pages/checkout/shipping-page/components/ship-to-mode-selector.js +1 -1
- package/dist/pages/checkout/shipping-page/shipping-page.js +1 -1
- package/dist/pages/my-sonic/actions/create-ship-to-address/connected-create-ship-to-address-form.js +1 -1
- package/dist/pages/my-sonic/actions/edit-ship-to-address/connected-edit-ship-to-address-form.js +5 -2
- package/dist/pages/my-sonic/actions/edit-vat/connected-edit-vat-dialog.d.ts +5 -0
- package/dist/pages/my-sonic/actions/edit-vat/connected-edit-vat-dialog.js +35 -0
- package/dist/pages/my-sonic/actions/edit-vat/edit-vat-dialog.d.ts +10 -0
- package/dist/pages/my-sonic/actions/edit-vat/edit-vat-dialog.js +15 -0
- package/dist/pages/my-sonic/actions/edit-vat/edit-vat.d.ts +7 -0
- package/dist/pages/my-sonic/actions/edit-vat/edit-vat.js +27 -0
- package/dist/pages/my-sonic/actions/edit-vat/edit-vat.module.css.js +3 -0
- package/dist/pages/my-sonic/widgets/connected-customer-information-widget.js +24 -7
- package/dist/pages/my-sonic/widgets/connected-ship-to-address-widget.js +1 -1
- package/dist/shared/model/price.d.ts +1 -0
- package/dist/shared/model/price.js +3 -0
- package/dist/styles.css +16 -0
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
|
-
import { createContext, useState,
|
|
3
|
+
import { createContext, useState, useRef, useEffect, useMemo } from 'react';
|
|
4
4
|
import { config } from '../config.js';
|
|
5
5
|
import { categoriesPlugin } from '../global-search/plugins/categories-plugin.js';
|
|
6
6
|
import { popularCategoriesPlugin } from '../global-search/plugins/popular-categories-plugin.js';
|
|
@@ -30,6 +30,23 @@ function AlgoliaSearchProvider({ children, searchClient: _searchClient, }) {
|
|
|
30
30
|
query: '',
|
|
31
31
|
status: 'idle',
|
|
32
32
|
});
|
|
33
|
+
// `createAutocomplete` is instantiated in a `useMemo` below, and its
|
|
34
|
+
// plugins (notably the Algolia insights plugin) can synchronously kick
|
|
35
|
+
// off `onStateChange` before the component has committed/mounted — e.g.
|
|
36
|
+
// when `window.aa`'s insights queue already resolved from a prior render
|
|
37
|
+
// (React Strict Mode's double-invoke, or a Fast Refresh remount). Calling
|
|
38
|
+
// `setState` at that point trips React's "state update on a component
|
|
39
|
+
// that hasn't mounted yet" warning. Buffer any pre-mount update and flush
|
|
40
|
+
// it once mounted instead of calling `setState` directly from render.
|
|
41
|
+
const isMountedRef = useRef(false);
|
|
42
|
+
const pendingStateRef = useRef(null);
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
isMountedRef.current = true;
|
|
45
|
+
if (pendingStateRef.current) {
|
|
46
|
+
setState(pendingStateRef.current);
|
|
47
|
+
pendingStateRef.current = null;
|
|
48
|
+
}
|
|
49
|
+
}, []);
|
|
33
50
|
const searchClient = useMemo(() => _searchClient ||
|
|
34
51
|
createSonicSearchClient({
|
|
35
52
|
apiKey: config.ALGOLIA_API_KEY,
|
|
@@ -86,7 +103,12 @@ function AlgoliaSearchProvider({ children, searchClient: _searchClient, }) {
|
|
|
86
103
|
getSources,
|
|
87
104
|
insights: true,
|
|
88
105
|
onStateChange({ state }) {
|
|
89
|
-
|
|
106
|
+
if (isMountedRef.current) {
|
|
107
|
+
setState(state);
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
pendingStateRef.current = state;
|
|
111
|
+
}
|
|
90
112
|
},
|
|
91
113
|
openOnFocus: true,
|
|
92
114
|
plugins: [
|
package/dist/exports.d.ts
CHANGED
|
@@ -337,6 +337,9 @@ export * from './pages/my-sonic/actions/edit-ship-to-address/connected-edit-ship
|
|
|
337
337
|
export * from './pages/my-sonic/actions/edit-user-info/connected-edit-user-info-dialog';
|
|
338
338
|
export * from './pages/my-sonic/actions/edit-user-info/edit-user-info';
|
|
339
339
|
export * from './pages/my-sonic/actions/edit-user-info/edit-user-info-dialog';
|
|
340
|
+
export * from './pages/my-sonic/actions/edit-vat/connected-edit-vat-dialog';
|
|
341
|
+
export * from './pages/my-sonic/actions/edit-vat/edit-vat';
|
|
342
|
+
export * from './pages/my-sonic/actions/edit-vat/edit-vat-dialog';
|
|
340
343
|
export * from './pages/my-sonic/actions/upload-order/upload-order';
|
|
341
344
|
export * from './pages/my-sonic/actions/upload-order/upload-order-form';
|
|
342
345
|
export * from './pages/my-sonic/actions/upload-order/upload-order-instructions';
|
package/dist/index.js
CHANGED
|
@@ -339,6 +339,9 @@ export { ConnectedEditShipToAddressForm } from './pages/my-sonic/actions/edit-sh
|
|
|
339
339
|
export { ConnectedEditUserInfoDialog } from './pages/my-sonic/actions/edit-user-info/connected-edit-user-info-dialog.js';
|
|
340
340
|
export { EditUserInfo } from './pages/my-sonic/actions/edit-user-info/edit-user-info.js';
|
|
341
341
|
export { EditUserInfoDialog } from './pages/my-sonic/actions/edit-user-info/edit-user-info-dialog.js';
|
|
342
|
+
export { ConnectedEditVatDialog } from './pages/my-sonic/actions/edit-vat/connected-edit-vat-dialog.js';
|
|
343
|
+
export { EditVat } from './pages/my-sonic/actions/edit-vat/edit-vat.js';
|
|
344
|
+
export { EditVatDialog } from './pages/my-sonic/actions/edit-vat/edit-vat-dialog.js';
|
|
342
345
|
export { UploadOrder } from './pages/my-sonic/actions/upload-order/upload-order.js';
|
|
343
346
|
export { UploadOrderForm } from './pages/my-sonic/actions/upload-order/upload-order-form.js';
|
|
344
347
|
export { UploadOrderInstructions } from './pages/my-sonic/actions/upload-order/upload-order-instructions.js';
|
|
@@ -514,6 +517,7 @@ export { currencies, getCurrencyCodeBySymbol } from './shared/model/currency.js'
|
|
|
514
517
|
export { voidFunction } from './shared/model/defaults.js';
|
|
515
518
|
export { isProductHit, transformAlgoliaProductHitToProductHit, transformAlgoliaPromoHitToPromoHit } from './shared/model/hit.js';
|
|
516
519
|
export { isResponsiveImage } from './shared/model/image.js';
|
|
520
|
+
export { VATNumberPattern } from './shared/model/price.js';
|
|
517
521
|
export { CartProvider, useCartEvents } from './shared/providers/cart-provider.js';
|
|
518
522
|
export { FavoriteProvider, useFavorite, useFavoriteProduct } from './shared/providers/favorite-provider.js';
|
|
519
523
|
export { GlobalStateProvider, GlobalStateProviderContext, useGlobalState } from './shared/providers/global-state-provider.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 favorites' | '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.' | 'Announcements' | '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' | 'Choose another region if you want to see the content for your location and shop online.' | 'Choose your country or region…' | 'Chosen filters' | 'City' | 'Clear filters' | 'Create' | 'Clear' | 'Click the button below to continue shopping.' | 'Client cases' | 'Close' | 'Close and don’t show again' | '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' | '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 enter a valid VAT number, starting with your country code, e.g. NL123456789.' | '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' | 'Remove from favorites' | '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 a region and language' | 'Select an industry' | 'Select another country or language…' | '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?' | 'Yes' | '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' | 'Your VAT number starts with your 2-letter country code, e.g. NL123456789. Leave this field empty if you do not have one.';
|
|
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 favorites' | '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.' | 'Announcements' | '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' | 'Choose another region if you want to see the content for your location and shop online.' | 'Choose your country or region…' | 'Chosen filters' | 'City' | 'Clear filters' | 'Create' | 'Clear' | 'Click the button below to continue shopping.' | 'Client cases' | 'Close' | 'Close and don’t show again' | '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 VAT number' | 'Edit' | 'Editing your VAT number will empty your cart. You will need to add your products again.' | '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' | '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 enter a valid VAT number, starting with your country code, e.g. NL123456789.' | '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' | 'Remove from favorites' | '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 a region and language' | 'Select an industry' | 'Select another country or language…' | '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?' | 'Yes' | '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 cannot change the default ship to address while there are items in your cart.' | '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' | 'Your VAT number has already been set. Please go to your account to change it.' | 'Your VAT number is set, so the shipping address for this order cannot be changed. Please complete or empty this order, then update your shipping address from your account.' | 'Your VAT number starts with your 2-letter country code, e.g. NL123456789. Leave this field empty if you do not have one.';
|
|
@@ -20,12 +20,12 @@ import { useInvalidateCurrentCart } from '../../../../shared/api/storefront/hook
|
|
|
20
20
|
import { useInvalidateAdyen } from '../../../../shared/api/storefront/hooks/payment/use-invalidate-adyen.js';
|
|
21
21
|
import { useDataLayer } from '../../../../shared/ga/use-data-layer.js';
|
|
22
22
|
import { getCurrencyCodeBySymbol } from '../../../../shared/model/currency.js';
|
|
23
|
+
import { VATNumberPattern } from '../../../../shared/model/price.js';
|
|
23
24
|
import { isProductionEnvironment } from '../../../../shared/utils/environment.js';
|
|
24
25
|
import { BillingAndInvoiceInformation } from '../../components/billing-and-invoice-information.js';
|
|
25
26
|
import { removeAdyenQueryParamsFromUrl, AdyenPayment } from './adyen-payment.js';
|
|
26
27
|
import styles from './payment.module.css.js';
|
|
27
28
|
|
|
28
|
-
const VAT_NUMBER_PATTERN = /^(AT|BE|BG|CY|CZ|DE|DK|EE|ES|FI|FR|GR|HR|HU|IE|IT|LT|LU|LV|MT|NL|PL|PT|RO|SE|SI|SK)[\dA-Z]{4,20}$/;
|
|
29
29
|
function Payment({ atp, cart: _cart, form, isProcessing, onError: _onError, onPaymentComplete, onProcessing, }) {
|
|
30
30
|
const { createEcommerceEvent, dataLayer } = useDataLayer();
|
|
31
31
|
const { mutate: patchCart } = usePatchCart();
|
|
@@ -55,6 +55,7 @@ function Payment({ atp, cart: _cart, form, isProcessing, onError: _onError, onPa
|
|
|
55
55
|
cart.billTo?.id &&
|
|
56
56
|
countryCode;
|
|
57
57
|
const isDisabled = isProcessing;
|
|
58
|
+
const hasVatNumber = Boolean(cart.customerVatNumber);
|
|
58
59
|
useEffect(() => {
|
|
59
60
|
cartRef.current = _cart;
|
|
60
61
|
}, [_cart]);
|
|
@@ -211,12 +212,12 @@ function Payment({ atp, cart: _cart, form, isProcessing, onError: _onError, onPa
|
|
|
211
212
|
// Only send values the server could accept; format errors show on submit
|
|
212
213
|
if (customerVatNumber &&
|
|
213
214
|
!(customerVatNumber.length >= 8 &&
|
|
214
|
-
|
|
215
|
+
VATNumberPattern.test(customerVatNumber)))
|
|
215
216
|
return;
|
|
216
217
|
try {
|
|
217
218
|
cartRef.current = await patchCart({
|
|
218
219
|
cart: { ...cartRef.current, customerVatNumber },
|
|
219
|
-
forceRecalculation:
|
|
220
|
+
forceRecalculation: true,
|
|
220
221
|
});
|
|
221
222
|
setValidationErrors(({ customerVatNumber: _, ...rest }) => cartRef.current.properties.customerVatNumberStatus === 'invalid'
|
|
222
223
|
? { ...rest, customerVatNumber: t('validation.invalid') }
|
|
@@ -273,7 +274,9 @@ function Payment({ atp, cart: _cart, form, isProcessing, onError: _onError, onPa
|
|
|
273
274
|
setAsSoonAsPossible(checked);
|
|
274
275
|
if (checked)
|
|
275
276
|
setDeliveryDate('');
|
|
276
|
-
}, children: t('As soon as possible') }), jsx(InfoIconTooltip, { size: "sm", 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, showLabel: true, "data-test-selector": "industrySelect", defaultSelectedOption: cart.properties.industry || 'AU', isDisabled: isDisabled, label: t('Industry'), name: "industry", options: industryOptions, placeholder: t('Select an industry'), variant: "solid" }), jsx(TextField, {
|
|
277
|
+
}, children: t('As soon as possible') }), jsx(InfoIconTooltip, { size: "sm", 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, showLabel: true, "data-test-selector": "industrySelect", defaultSelectedOption: cart.properties.industry || 'AU', isDisabled: isDisabled, label: t('Industry'), name: "industry", options: industryOptions, placeholder: t('Select an industry'), variant: "solid" }), jsx(TextField, { info: hasVatNumber
|
|
278
|
+
? t('Your VAT number has already been set. Please go to your account to change it.')
|
|
279
|
+
: t('Your VAT number starts with your 2-letter country code, e.g. NL123456789. Leave this field empty if you do not have one.'), isDisabled: isDisabled || hasVatNumber, label: t('VAT Number'), name: "customerVatNumber", onBlur: onVatNumberBlur, onChange: setVatNumber, validate: value => !value || (value.length >= 8 && VATNumberPattern.test(value))
|
|
277
280
|
? true
|
|
278
281
|
: t('Please enter a valid VAT number, starting with your country code, e.g. NL123456789.'), value: vatNumber }, `vat${Boolean(validationErrors.customerVatNumber)}`), jsx(TextField, { showLabel: true, defaultValue: cart.poNumber, isDisabled: isDisabled, isRequired: cart.requiresPoNumber, label: t('PO Number'), name: "poNumber" }), paymentMethodOptions && Object.keys(paymentMethodOptions).length > 1 && (jsx(Select, { "data-test-selector": "paymentMethodSelect", defaultSelectedOption: cart.paymentOptions?.paymentMethods?.[0]?.name || 'ADY', isDisabled: isDisabled, label: t('Payment method'), name: "paymentMethod", onChange: setSelectedPaymentMethod, options: paymentMethodOptions, selectedOption: selectedPaymentMethod, variant: "solid" })), isAdyenPayment && cart.billTo && (jsx(AdyenPayment, { amount: cart.orderGrandTotal, cartId: cart.trackId, countryCode: countryCode, currencyCode: currencyCode, customerId: cart.billTo.id, dropinRef: dropinRef, environment: isProductionEnvironment ? 'live' : 'test', isDisabled: isDisabled, onComplete: onComplete, onError: onError, orderAmount: cart.orderGrandTotal, returnUrl:
|
|
279
282
|
/* eslint-disable ssr-friendly/no-dom-globals-in-react-fc */
|
|
@@ -63,7 +63,7 @@ className, currentShipToId, }) {
|
|
|
63
63
|
Math.random().toString(36).slice(2, 15) + currentShipToId,
|
|
64
64
|
];
|
|
65
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 }) => {
|
|
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", "data-test-selector": "search-shipping-adress-field", isDisabled: isFetching, isLoading: isFetching, label: t('Search addresses'), onChange: setSearch, onKeyUp: ({ key }) => {
|
|
67
67
|
if (key === 'ArrowDown') {
|
|
68
68
|
listBoxRef.current?.focus();
|
|
69
69
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { BillToModel, PatchCartModel, PostShipToModel, ShipToModel } from '../../../../shared/api/storefront/model/storefront.model';
|
|
2
2
|
import { Country } from '../../../../shared/model/countries-languages';
|
|
3
|
-
export declare function ReadOnlyAddresses({ billTo, cartId, countries, currentCountry, isLoading, isPickup, notes, onSubmit, shipTo, }: {
|
|
3
|
+
export declare function ReadOnlyAddresses({ billTo, cartId, countries, currentCountry, hasVatNumber, isLoading, isPickup, notes, onSubmit, shipTo, }: {
|
|
4
4
|
billTo: BillToModel | undefined | null;
|
|
5
5
|
cartId: string;
|
|
6
6
|
countries: Country[];
|
|
7
7
|
currentCountry?: Country | undefined;
|
|
8
|
+
hasVatNumber: boolean;
|
|
8
9
|
isLoading: boolean;
|
|
9
10
|
isPickup: boolean;
|
|
10
11
|
notes: string | undefined;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs,
|
|
2
|
+
import { jsx, jsxs, Fragment } 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
5
|
import { TextField } from '../../../../forms/fields/text-field/text-field.js';
|
|
6
6
|
import { AddressForm } from '../../../../forms/partials/address-form/address-form.js';
|
|
7
7
|
import { FormattedMessage } from '../../../../intl/formatted-message.js';
|
|
8
8
|
import { useFormattedMessage } from '../../../../intl/use-formatted-message.js';
|
|
9
|
+
import { Message } from '../../../../message/message.js';
|
|
9
10
|
import { CheckoutPageSection } from '../../layouts/checkout-page-layout/components/checkout-page-section.js';
|
|
10
11
|
import { CheckoutPageSectionContent } from '../../layouts/checkout-page-layout/components/checkout-page-section-content.js';
|
|
11
12
|
import { AddressBookSelector } from './address-book-selector.js';
|
|
@@ -14,11 +15,25 @@ import ShipToModeSelector from './ship-to-mode-selector.js';
|
|
|
14
15
|
import { SonicAddress } from './sonic-address.js';
|
|
15
16
|
import styles from './readonly-address.module.css.js';
|
|
16
17
|
|
|
17
|
-
function ReadOnlyAddresses({ billTo, cartId, countries, currentCountry, isLoading, isPickup, notes, onSubmit, shipTo, }) {
|
|
18
|
+
function ReadOnlyAddresses({ billTo, cartId, countries, currentCountry, hasVatNumber, isLoading, isPickup, notes, onSubmit, shipTo, }) {
|
|
18
19
|
const t = useFormattedMessage();
|
|
19
20
|
const billToId = billTo?.id;
|
|
20
21
|
const shipToId = shipTo?.id;
|
|
21
22
|
const isShipToABillToAddress = billToId && shipToId && billToId === shipToId;
|
|
23
|
+
const shipToInfoDisplay = shipTo && (jsx("div", { className: styles['ship-to-info-display'], children: jsx(AddressInfoDisplay, { address: {
|
|
24
|
+
address1: shipTo.address1,
|
|
25
|
+
address2: shipTo.address2,
|
|
26
|
+
address3: shipTo.address3,
|
|
27
|
+
attention: shipTo.attention,
|
|
28
|
+
city: shipTo.city,
|
|
29
|
+
companyName: shipTo.companyName,
|
|
30
|
+
country: shipTo.country,
|
|
31
|
+
email: shipTo.email,
|
|
32
|
+
firstName: shipTo.firstName,
|
|
33
|
+
lastName: shipTo.lastName,
|
|
34
|
+
phone: shipTo.phone,
|
|
35
|
+
postalCode: shipTo.postalCode,
|
|
36
|
+
}, "data-test-selector": "shipToAddress" }) }));
|
|
22
37
|
const onSubmitHandler = (event) => {
|
|
23
38
|
event.preventDefault();
|
|
24
39
|
const formData = new FormData(event.currentTarget);
|
|
@@ -107,24 +122,11 @@ function ReadOnlyAddresses({ billTo, cartId, countries, currentCountry, isLoadin
|
|
|
107
122
|
lastName: billTo.lastName,
|
|
108
123
|
phone: billTo.phone,
|
|
109
124
|
postalCode: billTo.postalCode,
|
|
110
|
-
}, "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
|
|
125
|
+
}, "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, {})) : hasVatNumber ? (jsxs(Fragment, { children: [jsx(Message, { type: "info", children: jsx(FormattedMessage, { id: "Your VAT number is set, so the shipping address for this order cannot be changed. Please complete or empty this order, then update your shipping address from your account." }) }), shipToInfoDisplay] })) : (jsx(ShipToModeSelector, { addressBookSelector: billTo?.id && (jsx("div", { className: styles['address-book-selector'], children: jsx(AddressBookSelector, { billToId: billTo.id, currentShipToId: shipTo?.id }) })), defaultShippingOption: isShipToABillToAddress
|
|
111
126
|
? 'useBillTo'
|
|
112
127
|
: shipTo
|
|
113
128
|
? 'selectFromAddressBook'
|
|
114
|
-
: 'useNewAddress', newAddressForm: jsx("div", { className: styles['new-address-form'], children: jsx(AddressForm, { address: shipTo, countries: countries, currentCountry: currentCountry }) }), shipToInfoDisplay:
|
|
115
|
-
address1: shipTo.address1,
|
|
116
|
-
address2: shipTo.address2,
|
|
117
|
-
address3: shipTo.address3,
|
|
118
|
-
attention: shipTo.attention,
|
|
119
|
-
city: shipTo.city,
|
|
120
|
-
companyName: shipTo.companyName,
|
|
121
|
-
country: shipTo.country,
|
|
122
|
-
email: shipTo.email,
|
|
123
|
-
firstName: shipTo.firstName,
|
|
124
|
-
lastName: shipTo.lastName,
|
|
125
|
-
phone: shipTo.phone,
|
|
126
|
-
postalCode: shipTo.postalCode,
|
|
127
|
-
}, "data-test-selector": "shipToAddress" }) })) })) }) })] }));
|
|
129
|
+
: 'useNewAddress', newAddressForm: jsx("div", { className: styles['new-address-form'], children: jsx(AddressForm, { address: shipTo, countries: countries, currentCountry: currentCountry }) }), shipToInfoDisplay: shipToInfoDisplay })) }) })] }));
|
|
128
130
|
}
|
|
129
131
|
|
|
130
132
|
export { ReadOnlyAddresses };
|
|
@@ -19,7 +19,7 @@ function ShipToModeSelector(props) {
|
|
|
19
19
|
// useDefaultShipTo: props.shipToInfoDisplay,
|
|
20
20
|
useNewAddress: props.newAddressForm,
|
|
21
21
|
}[shippingOption];
|
|
22
|
-
return (jsxs(Fragment, { children: [jsx(SelectField, { "data-test-selector": "
|
|
22
|
+
return (jsxs(Fragment, { children: [jsx(SelectField, { "data-test-selector": "select-shipping-adress", label: t('Shipping address'), name: "shippingType", onChange: setShippingOption, options: options, selectedOption: shippingOption, showLabel: false }), additionalComponentForShipping] }));
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
export { ShipToModeSelector as default };
|
|
@@ -159,7 +159,7 @@ function ShippingPage() {
|
|
|
159
159
|
},
|
|
160
160
|
});
|
|
161
161
|
await refetchCart();
|
|
162
|
-
}, 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 }) => {
|
|
162
|
+
}, readOnlyAddress: jsx(ReadOnlyAddresses, { billTo: cart.billTo, cartId: cart.id, countries: countries || [], currentCountry: currentCountry, hasVatNumber: Boolean(cart.customerVatNumber), isLoading: isPatching, isPickup: isPickup, notes: cart.notes, onSubmit: async ({ cart: updatedCart, notes, shipTo }) => {
|
|
163
163
|
if (!cart.billTo)
|
|
164
164
|
return;
|
|
165
165
|
if (notes ||
|
package/dist/pages/my-sonic/actions/create-ship-to-address/connected-create-ship-to-address-form.js
CHANGED
|
@@ -83,7 +83,7 @@ function ConnectedCreateShipToAddressForm({ billToId, makeDefault, returnUrl, })
|
|
|
83
83
|
});
|
|
84
84
|
}
|
|
85
85
|
return navigate(`${paths.ACCOUNT_EDIT_BILL_TO_ADDRESS}/${billToId}${paths.ACCOUNT_EDIT_SHIP_TO_ADDRESS}/${createdShipToAddress.id}?returnUrl=${encodeURIComponent(returnUrl || '')}`);
|
|
86
|
-
}, children: [jsx(AddressForm, { address: undefined, countries: countries, currentCountry: currentCountry, isLoading: isPatching }), jsx(Checkbox, { defaultSelected: makeDefault, isDisabled: isPatching, name: "setAsDefault", value: "TRUE", children: jsx(FormattedMessage, { id: "Make this the default ship to address" }) }), Boolean(errorShipToAddress) && (jsx("div", { className: styles.info, children: jsx(Message, { type: "danger", children: jsx(FormattedMessage, { id: "An unexpected error occured" }) }) })), isSuccess && !isPatching && (jsx("div", { className: styles.info, children: jsx(Message, { type: "info", children: jsx(FormattedMessage, { id: "Saved" }) }) })), jsxs("div", { className: styles.actions, children: [returnUrl && (jsx(Button, { color: "secondary", isDisabled: isPatching, onClick: () => navigate(returnUrl), variant: "outline", children: jsx(FormattedMessage, { id: "Back" }) })), jsx(Button, { isLoading: isPatching ? jsx(FormattedMessage, { id: "Saving" }) : undefined, type: "submit", children: jsx(FormattedMessage, { id: "Save" }) })] })] }));
|
|
86
|
+
}, children: [jsx(AddressForm, { address: undefined, countries: countries, currentCountry: currentCountry, isLoading: isPatching }), jsx(Checkbox, { "data-test-selector": "makeDefaultShippingAddress", defaultSelected: makeDefault, isDisabled: isPatching, name: "setAsDefault", value: "TRUE", children: jsx(FormattedMessage, { id: "Make this the default ship to address" }) }), Boolean(errorShipToAddress) && (jsx("div", { className: styles.info, children: jsx(Message, { type: "danger", children: jsx(FormattedMessage, { id: "An unexpected error occured" }) }) })), isSuccess && !isPatching && (jsx("div", { className: styles.info, children: jsx(Message, { type: "info", children: jsx(FormattedMessage, { id: "Saved" }) }) })), jsxs("div", { className: styles.actions, children: [returnUrl && (jsx(Button, { color: "secondary", isDisabled: isPatching, onClick: () => navigate(returnUrl), variant: "outline", children: jsx(FormattedMessage, { id: "Back" }) })), jsx(Button, { isLoading: isPatching ? jsx(FormattedMessage, { id: "Saving" }) : undefined, type: "submit", children: jsx(FormattedMessage, { id: "Save" }) })] })] }));
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
export { ConnectedCreateShipToAddressForm };
|
package/dist/pages/my-sonic/actions/edit-ship-to-address/connected-edit-ship-to-address-form.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
3
3
|
import { useMemo } from 'react';
|
|
4
4
|
import { Button } from '../../../../buttons/button/button.js';
|
|
5
5
|
import { useCountries } from '../../../../country-select/hooks/use-countries.js';
|
|
@@ -10,6 +10,7 @@ import { FormattedMessage } from '../../../../intl/formatted-message.js';
|
|
|
10
10
|
import { Message } from '../../../../message/message.js';
|
|
11
11
|
import { usePatchCurrentAccount } from '../../../../shared/api/storefront/hooks/account/use-patch-current-account.js';
|
|
12
12
|
import { usePatchSession } from '../../../../shared/api/storefront/hooks/authentication/use-patch-session.js';
|
|
13
|
+
import { useFetchCurrentCart } from '../../../../shared/api/storefront/hooks/cart/use-fetch-current-cart.js';
|
|
13
14
|
import { useFetchShipToAddress } from '../../../../shared/api/storefront/hooks/customer/use-fetch-ship-to-address.js';
|
|
14
15
|
import { usePatchShipToAddress } from '../../../../shared/api/storefront/hooks/customer/use-patch-ship-to-address.js';
|
|
15
16
|
import { DefaultErrorView } from '../../../../shared/error/default-error-view.js';
|
|
@@ -23,6 +24,8 @@ function ConnectedEditShipToAddressForm({ billToId, returnUrl, shipToId, }) {
|
|
|
23
24
|
const { navigate } = useNavigate();
|
|
24
25
|
const { countries, currentCountry, error: errorCountries, isFetching: isLoadingCountries, } = useCountries();
|
|
25
26
|
const { data: shipToAddress, error: errorShipToAddress, isLoading: isLoadingShipToAddress, } = useFetchShipToAddress({ billToId, includeValidation: true, shipToId });
|
|
27
|
+
const { data: cart } = useFetchCurrentCart();
|
|
28
|
+
const hasCartItems = Boolean(cart?.lineCount);
|
|
26
29
|
const { isLoading: isPatchingShipToAddress, isSuccess, mutate: patchShipToAddress, } = usePatchShipToAddress();
|
|
27
30
|
const { isLoading: isPatchingSession, mutate: patchSession } = usePatchSession();
|
|
28
31
|
const { isLoading: isPatchingCurrentAccount, mutate: patchCurrentAccount } = usePatchCurrentAccount();
|
|
@@ -120,7 +123,7 @@ function ConnectedEditShipToAddressForm({ billToId, returnUrl, shipToId, }) {
|
|
|
120
123
|
},
|
|
121
124
|
});
|
|
122
125
|
}
|
|
123
|
-
}, children: [jsx(AddressForm, { address: shipToAddress, countries: countries, currentCountry: currentCountry, isLoading: isPatching, isReadonly: isReadonly || isPatching }), shipToAddress.id !== 'current' && (jsx(Checkbox, { defaultSelected: shipToAddress.isDefault, isDisabled: isReadonly || isPatching, name: "setAsDefault", value: "TRUE", children: jsx(FormattedMessage, { id: "Make this the default ship to address" }) })), isSuccess && !isPatching && (jsx("div", { className: styles.info, children: jsx(Message, { type: "success", children: jsx(FormattedMessage, { id: "Saved" }) }) })), jsxs("div", { className: styles.actions, children: [returnUrl && (jsx(Button, { color: "secondary", isDisabled: isPatching, onClick: () => navigate(returnUrl), variant: "outline", children: jsx(FormattedMessage, { id: "Back" }) })), !isReadonly && (jsx(Button, { isLoading: isPatching ? jsx(FormattedMessage, { id: "Saving" }) : undefined, type: "submit", children: jsx(FormattedMessage, { id: "Save" }) }))] })] }));
|
|
126
|
+
}, children: [jsx(AddressForm, { address: shipToAddress, countries: countries, currentCountry: currentCountry, isLoading: isPatching, isReadonly: isReadonly || isPatching }), shipToAddress.id !== 'current' && (jsxs(Fragment, { children: [jsx(Checkbox, { "data-test-selector": "makeDefaultShippingAddress", defaultSelected: shipToAddress.isDefault, isDisabled: isReadonly || isPatching || hasCartItems, name: "setAsDefault", value: "TRUE", children: jsx(FormattedMessage, { id: "Make this the default ship to address" }) }), hasCartItems && (jsx("div", { className: styles.info, children: jsx(Message, { type: "info", children: jsx(FormattedMessage, { id: "You cannot change the default ship to address while there are items in your cart." }) }) }))] })), isSuccess && !isPatching && (jsx("div", { className: styles.info, children: jsx(Message, { type: "success", children: jsx(FormattedMessage, { id: "Saved" }) }) })), jsxs("div", { className: styles.actions, children: [returnUrl && (jsx(Button, { color: "secondary", isDisabled: isPatching, onClick: () => navigate(returnUrl), variant: "outline", children: jsx(FormattedMessage, { id: "Back" }) })), !isReadonly && (jsx(Button, { isLoading: isPatching ? jsx(FormattedMessage, { id: "Saving" }) : undefined, type: "submit", children: jsx(FormattedMessage, { id: "Save" }) }))] })] }));
|
|
124
127
|
}
|
|
125
128
|
|
|
126
129
|
export { ConnectedEditShipToAddressForm };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { useEffect } from 'react';
|
|
4
|
+
import { usePatchCart } from '../../../../shared/api/bff/hooks/cart/use-patch-cart.js';
|
|
5
|
+
import { useDeleteCurrentCart } from '../../../../shared/api/storefront/hooks/cart/use-delete-current-cart.js';
|
|
6
|
+
import { useFetchCurrentCart } from '../../../../shared/api/storefront/hooks/cart/use-fetch-current-cart.js';
|
|
7
|
+
import { useInvalidateCurrentCart } from '../../../../shared/api/storefront/hooks/cart/use-invalidate-current-cart.js';
|
|
8
|
+
import { EditVatDialog } from './edit-vat-dialog.js';
|
|
9
|
+
|
|
10
|
+
function ConnectedEditVatDialog({ isOpen, onClose, }) {
|
|
11
|
+
const { data: cart, error, isLoading, } = useFetchCurrentCart({
|
|
12
|
+
enabled: isOpen,
|
|
13
|
+
});
|
|
14
|
+
const { error: errorPatchCart, isLoading: isMutating, mutate, reset, } = usePatchCart();
|
|
15
|
+
const { error: errorDeleteCurrentCart, isPending: isDeletingCurrentCart, mutateAsync: deleteCurrentCart, } = useDeleteCurrentCart();
|
|
16
|
+
const invalidateCurrentCart = useInvalidateCurrentCart();
|
|
17
|
+
useEffect(() => reset(), [isOpen, reset]);
|
|
18
|
+
if (!isOpen)
|
|
19
|
+
return null;
|
|
20
|
+
return (jsx(EditVatDialog, { cart: cart, error: error || errorPatchCart || errorDeleteCurrentCart, isLoading: isLoading, isOpen: isOpen, isUpdating: isMutating || isDeletingCurrentCart, onOpenChange: isOpen => !isOpen && onClose?.(), onSubmit: async ({ formData }) => {
|
|
21
|
+
if (!cart)
|
|
22
|
+
throw new Error('Cart not loaded');
|
|
23
|
+
const customerVatNumber = formData.get('customerVatNumber')?.toString();
|
|
24
|
+
// Patching the VAT number while the cart has cart lines causes
|
|
25
|
+
// pricing recalculation errors, so the cart is emptied first.
|
|
26
|
+
const emptiedCart = cart.lineCount > 0 ? await deleteCurrentCart() : cart;
|
|
27
|
+
await mutate({
|
|
28
|
+
cart: { ...emptiedCart, customerVatNumber },
|
|
29
|
+
});
|
|
30
|
+
invalidateCurrentCart();
|
|
31
|
+
onClose?.();
|
|
32
|
+
} }));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export { ConnectedEditVatDialog };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { OnSubmitHandler, ValidationErrors } from '../../../../forms/layout/form/form';
|
|
2
|
+
import { EditVatProps } from './edit-vat';
|
|
3
|
+
export interface EditVatDialogProps extends EditVatProps {
|
|
4
|
+
isOpen: boolean;
|
|
5
|
+
isUpdating?: boolean;
|
|
6
|
+
onOpenChange?: (isOpen: boolean) => void;
|
|
7
|
+
onSubmit?: OnSubmitHandler;
|
|
8
|
+
validationErrors?: ValidationErrors;
|
|
9
|
+
}
|
|
10
|
+
export declare function EditVatDialog({ cart, error, isLoading, isOpen, isUpdating, onOpenChange, onSubmit, validationErrors, }: EditVatDialogProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { useFormattedMessage } from '../../../../intl/use-formatted-message.js';
|
|
4
|
+
import { Dialog } from '../../../../modals/dialog/dialog.js';
|
|
5
|
+
import { UnauthorizedRequestError } from '../../../../shared/fetch/request.js';
|
|
6
|
+
import { EditVat } from './edit-vat.js';
|
|
7
|
+
|
|
8
|
+
function EditVatDialog({ cart, error, isLoading, isOpen = false, isUpdating = false, onOpenChange, onSubmit, validationErrors, }) {
|
|
9
|
+
const t = useFormattedMessage();
|
|
10
|
+
return (jsx(Dialog, { allowSubmit: !isLoading &&
|
|
11
|
+
!isUpdating &&
|
|
12
|
+
!(error instanceof UnauthorizedRequestError), isOpen: isOpen, isSubmitting: isUpdating, onOpenChange: onOpenChange, onSubmit: onSubmit, title: t('Edit VAT number'), validationErrors: validationErrors, children: jsx(EditVat, { cart: cart, error: error, isLoading: isLoading }) }));
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { EditVatDialog };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CartModel } from '../../../../shared/api/storefront/model/storefront.model';
|
|
2
|
+
export interface EditVatProps {
|
|
3
|
+
cart?: CartModel;
|
|
4
|
+
error?: Error | null | unknown;
|
|
5
|
+
isLoading?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare function EditVat({ cart, error, isLoading }: EditVatProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
3
|
+
import { TextField } from '../../../../forms/fields/text-field/text-field.js';
|
|
4
|
+
import { useFormattedMessage } from '../../../../intl/use-formatted-message.js';
|
|
5
|
+
import { ProgressCircle } from '../../../../loading/progress-circle.js';
|
|
6
|
+
import { Message } from '../../../../message/message.js';
|
|
7
|
+
import { UnauthorizedRequestError } from '../../../../shared/fetch/request.js';
|
|
8
|
+
import { VATNumberPattern } from '../../../../shared/model/price.js';
|
|
9
|
+
import styles from './edit-vat.module.css.js';
|
|
10
|
+
|
|
11
|
+
function EditVat({ cart, error, isLoading = false }) {
|
|
12
|
+
const t = useFormattedMessage();
|
|
13
|
+
if (error instanceof UnauthorizedRequestError) {
|
|
14
|
+
return (jsx(Message, { type: "danger", children: t('You are not authorized to perform this action') }));
|
|
15
|
+
}
|
|
16
|
+
if (isLoading) {
|
|
17
|
+
return (jsx("div", { className: styles['loading-panel'], children: jsx(ProgressCircle, { variant: "gray" }) }));
|
|
18
|
+
}
|
|
19
|
+
if (!cart) {
|
|
20
|
+
return jsx(Message, { type: "danger", children: t('An unexpected error occured') });
|
|
21
|
+
}
|
|
22
|
+
return (jsxs(Fragment, { children: [cart.lineCount > 0 && (jsx(Message, { className: styles['warning-message'], type: "warning", children: t('Editing your VAT number will empty your cart. You will need to add your products again.') })), jsx(TextField, { "data-test-selector": "vat-number", defaultValue: cart.customerVatNumber, info: t('Your VAT number starts with your 2-letter country code, e.g. NL123456789. Leave this field empty if you do not have one.'), isRequired: true, label: t('VAT Number'), name: "customerVatNumber", showLabel: false, validate: value => !value || (value.length >= 8 && VATNumberPattern.test(value))
|
|
23
|
+
? true
|
|
24
|
+
: t('Please enter a valid VAT number, starting with your country code, e.g. NL123456789.') }), error && (jsx(Message, { className: styles['error-message'], type: "danger", children: t('An unexpected error occured') }))] }));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { EditVat };
|
|
@@ -4,16 +4,20 @@ import { useState } from 'react';
|
|
|
4
4
|
import { Button } from '../../../buttons/button/button.js';
|
|
5
5
|
import { DataCard } from '../../../cards/data-card/data-card.js';
|
|
6
6
|
import { FormattedMessage } from '../../../intl/formatted-message.js';
|
|
7
|
+
import { useFetchCurrentCart } from '../../../shared/api/storefront/hooks/cart/use-fetch-current-cart.js';
|
|
7
8
|
import { useFetchBillToAddresses } from '../../../shared/api/storefront/hooks/customer/use-fetch-bill-to-addresses.js';
|
|
8
9
|
import { useFetchCurrentBillToAddress } from '../../../shared/api/storefront/hooks/customer/use-fetch-current-bill-to-address.js';
|
|
9
10
|
import { ConnectedChangeCustomerDialog } from '../actions/change-customer/connected-change-customer-dialog.js';
|
|
11
|
+
import { ConnectedEditVatDialog } from '../actions/edit-vat/connected-edit-vat-dialog.js';
|
|
10
12
|
|
|
11
13
|
function ConnectedCustomerInformationWidget() {
|
|
12
14
|
const [isOpenChangeCustomerDialog, setIsOpenChangeCustomerDialog] = useState(false);
|
|
15
|
+
const [isOpenEditVatDialog, setIsOpenEditVatDialog] = useState(false);
|
|
13
16
|
const { data: billToAddress, error: fetchBillToAddressError, isLoading: isLoadingFetchCurrentBillToAddress, } = useFetchCurrentBillToAddress();
|
|
14
17
|
const { data: billToAddresses, error: fetchBillToAddressesError, isLoading: isLoadingFetchBillToAddresses, } = useFetchBillToAddresses();
|
|
18
|
+
const { data: cart, error: fetchCartError, isLoading: isLoadingFetchCart, } = useFetchCurrentCart();
|
|
15
19
|
const hasMoreThanOneBillToAddress = Boolean((billToAddresses?.pagination?.totalItemCount || 0) > 1);
|
|
16
|
-
const data = billToAddress
|
|
20
|
+
const data = billToAddress && cart
|
|
17
21
|
? [
|
|
18
22
|
{
|
|
19
23
|
key: 'company-name',
|
|
@@ -25,6 +29,11 @@ function ConnectedCustomerInformationWidget() {
|
|
|
25
29
|
label: 'CoC number',
|
|
26
30
|
value: billToAddress.properties.cocRegistration,
|
|
27
31
|
},
|
|
32
|
+
{
|
|
33
|
+
key: 'vat-number',
|
|
34
|
+
label: 'VAT Number',
|
|
35
|
+
value: cart.customerVatNumber,
|
|
36
|
+
},
|
|
28
37
|
{
|
|
29
38
|
key: 'billing',
|
|
30
39
|
label: 'Billing',
|
|
@@ -45,13 +54,21 @@ function ConnectedCustomerInformationWidget() {
|
|
|
45
54
|
function onChangeCustomer() {
|
|
46
55
|
setIsOpenChangeCustomerDialog(true);
|
|
47
56
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
57
|
+
function onEditVat() {
|
|
58
|
+
setIsOpenEditVatDialog(true);
|
|
59
|
+
}
|
|
60
|
+
return (jsxs(Fragment, { children: [jsx(DataCard, { actions: [
|
|
61
|
+
jsx(Button, { color: "secondary", onClick: onEditVat, size: "sm", variant: "outline", children: jsx(FormattedMessage, { id: "Edit VAT number" }) }, "edit-vat"),
|
|
62
|
+
...(hasMoreThanOneBillToAddress
|
|
63
|
+
? [
|
|
64
|
+
jsx(Button, { color: "secondary", onClick: onChangeCustomer, size: "sm", variant: "outline", children: jsx(FormattedMessage, { id: "Select other customer" }) }, "edit"),
|
|
65
|
+
]
|
|
66
|
+
: []),
|
|
67
|
+
], data: data, "data-test-selector": "customer-information-widget", isLoading: isLoadingFetchCurrentBillToAddress ||
|
|
68
|
+
isLoadingFetchBillToAddresses ||
|
|
69
|
+
isLoadingFetchCart, showError: fetchBillToAddressError || fetchBillToAddressesError || fetchCartError, title: "Selected customer" }), hasMoreThanOneBillToAddress && (jsx(ConnectedChangeCustomerDialog, { allowSetDefault: true, isOpen: isOpenChangeCustomerDialog, onClose: () => setIsOpenChangeCustomerDialog(false), onCustomerSelected: () => {
|
|
53
70
|
window?.location.reload();
|
|
54
|
-
} }, billToAddress?.id))] }));
|
|
71
|
+
} }, billToAddress?.id)), isOpenEditVatDialog && (jsx(ConnectedEditVatDialog, { isOpen: isOpenEditVatDialog, onClose: () => setIsOpenEditVatDialog(false) }))] }));
|
|
55
72
|
}
|
|
56
73
|
|
|
57
74
|
export { ConnectedCustomerInformationWidget };
|
|
@@ -19,7 +19,7 @@ function ConnectedShipToAddressWidget({ billToId = 'current', shipToId = 'curren
|
|
|
19
19
|
});
|
|
20
20
|
return (jsx(AddressDataCard, { actions: [
|
|
21
21
|
jsx(Button, { color: "secondary", "data-test-selector": "shipping-address-edit-adress", href: editAddressUrl, size: "sm", variant: "outline", children: jsx(FormattedMessage, { id: "Edit" }) }, "edit"),
|
|
22
|
-
jsx(Button, { color: "secondary", "data-test-selector": "
|
|
22
|
+
jsx(Button, { color: "secondary", "data-test-selector": "shipping-address-create-adress", href: createAddressUrl, size: "sm", variant: "outline", children: jsx(FormattedMessage, { id: "Create" }) }, "create"),
|
|
23
23
|
], data: {
|
|
24
24
|
address1: shipToAddress?.address1,
|
|
25
25
|
address2: shipToAddress?.address2,
|
package/dist/styles.css
CHANGED
|
@@ -8800,6 +8800,22 @@ button.swiper-pagination-bullet {
|
|
|
8800
8800
|
margin-top: var(--space-16);
|
|
8801
8801
|
}
|
|
8802
8802
|
|
|
8803
|
+
.edit-vat-module-KZlfI {
|
|
8804
|
+
display: grid;
|
|
8805
|
+
inset: 0;
|
|
8806
|
+
min-block-size: 150px;
|
|
8807
|
+
min-inline-size: 250px;
|
|
8808
|
+
place-content: center;
|
|
8809
|
+
}
|
|
8810
|
+
|
|
8811
|
+
.edit-vat-module-OiNwK {
|
|
8812
|
+
margin-top: var(--space-16);
|
|
8813
|
+
}
|
|
8814
|
+
|
|
8815
|
+
.edit-vat-module-6IGJx {
|
|
8816
|
+
margin-bottom: var(--space-16);
|
|
8817
|
+
}
|
|
8818
|
+
|
|
8803
8819
|
.upload-order-module-m3QNF {
|
|
8804
8820
|
display: grid;
|
|
8805
8821
|
align-items: start;
|