@sonic-equipment/ui 225.0.0 → 227.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/exports.d.ts +5 -0
  2. package/dist/footer/connected-footer.js +3 -1
  3. package/dist/forms/partials/password-validation/password-validation.js +1 -1
  4. package/dist/index.js +6 -2
  5. package/dist/intl/translation-id.d.ts +1 -1
  6. package/dist/modals/dialog/dialog.d.ts +1 -0
  7. package/dist/modals/dialog/dialog.js +3 -2
  8. package/dist/notifications/announcements/connected-announcement-list.js +4 -4
  9. package/dist/pages/account/change-password-page/change-password-page.d.ts +6 -0
  10. package/dist/pages/account/change-password-page/change-password-page.js +57 -0
  11. package/dist/pages/account/components/change-password-form/change-password-form.d.ts +16 -0
  12. package/dist/pages/account/components/change-password-form/change-password-form.js +49 -0
  13. package/dist/pages/account/components/sign-in-form/sign-in-form.d.ts +3 -3
  14. package/dist/pages/account/components/sign-in-form/sign-in-form.js +4 -0
  15. package/dist/pages/account/sign-in-page/sign-in-page.js +51 -14
  16. package/dist/pages/my-sonic/actions/change-password/change-password-dialog.d.ts +4 -2
  17. package/dist/pages/my-sonic/actions/change-password/change-password-dialog.js +6 -6
  18. package/dist/pages/my-sonic/actions/change-password/change-password-dialog.module.css.js +3 -0
  19. package/dist/pages/my-sonic/actions/change-password/change-password.d.ts +4 -3
  20. package/dist/pages/my-sonic/actions/change-password/change-password.js +4 -12
  21. package/dist/pages/my-sonic/actions/change-password/connected-change-password-dialog.js +1 -1
  22. package/dist/pages/product/product-details-page/product-details.js +6 -2
  23. package/dist/shared/api/bff/hooks/use-fetch-products-prices.d.ts +2 -0
  24. package/dist/shared/api/bff/hooks/use-fetch-products-prices.js +14 -0
  25. package/dist/shared/api/bff/model/bff.model.d.ts +13 -0
  26. package/dist/shared/api/bff/services/bff-service.d.ts +11 -5
  27. package/dist/shared/api/bff/services/bff-service.js +52 -29
  28. package/dist/shared/api/shared/types.d.ts +6 -0
  29. package/dist/shared/api/storefront/hooks/authentication/use-sign-in.js +4 -7
  30. package/dist/shared/api/storefront/model/storefront.model.d.ts +4 -0
  31. package/dist/shared/api/storefront/services/account-service.d.ts +2 -2
  32. package/dist/shared/api/storefront/services/account-service.js +4 -6
  33. package/dist/shared/api/storefront/services/authentication-service.d.ts +20 -4
  34. package/dist/shared/api/storefront/services/authentication-service.js +100 -39
  35. package/dist/shared/api/storefront/services/cart-service.d.ts +3 -2
  36. package/dist/shared/api/storefront/services/cart-service.js +2 -1
  37. package/dist/shared/api/storefront/services/category-service.d.ts +6 -0
  38. package/dist/shared/api/storefront/services/category-service.js +19 -0
  39. package/dist/shared/api/storefront/services/translation-service.js +4 -0
  40. package/dist/shared/feature-flags/use-feature-flags.js +4 -2
  41. package/dist/styles.css +24 -20
  42. package/package.json +1 -1
package/dist/exports.d.ts CHANGED
@@ -217,6 +217,8 @@ export * from './notifications/announcements/announcement-list';
217
217
  export * from './notifications/announcements/connected-announcement-list';
218
218
  export * from './notifications/announcements/use-filter-announcements';
219
219
  export * from './observers/intersection-observer';
220
+ export * from './pages/account/change-password-page/change-password-page';
221
+ export * from './pages/account/components/change-password-form/change-password-form';
220
222
  export * from './pages/account/components/create-account-form/create-account-form';
221
223
  export * from './pages/account/components/sign-in-form/sign-in-form';
222
224
  export * from './pages/account/create-account-page/create-account-page';
@@ -318,9 +320,11 @@ export * from './shared/api/bff/hooks/use-fetch-favorites';
318
320
  export * from './shared/api/bff/hooks/use-fetch-navigation-links';
319
321
  export * from './shared/api/bff/hooks/use-fetch-product-details-page-data';
320
322
  export * from './shared/api/bff/hooks/use-fetch-product-listing-page-data';
323
+ export * from './shared/api/bff/hooks/use-fetch-products-prices';
321
324
  export * from './shared/api/bff/hooks/use-fetch-recently-viewed-products';
322
325
  export * from './shared/api/bff/services/bff-service';
323
326
  export * from './shared/api/shared/hooks/use-awaitable-mutation';
327
+ export * from './shared/api/shared/types';
324
328
  export * from './shared/api/storefront/hooks/account/use-create-account';
325
329
  export * from './shared/api/storefront/hooks/account/use-create-guest-account';
326
330
  export * from './shared/api/storefront/hooks/account/use-fetch-current-account';
@@ -381,6 +385,7 @@ export * from './shared/api/storefront/hooks/wishlist/use-fetch-wishlists';
381
385
  export * from './shared/api/storefront/services/account-service';
382
386
  export * from './shared/api/storefront/services/authentication-service';
383
387
  export * from './shared/api/storefront/services/cart-service';
388
+ export * from './shared/api/storefront/services/category-service';
384
389
  export * from './shared/api/storefront/services/customer-service';
385
390
  export * from './shared/api/storefront/services/finance-service';
386
391
  export * from './shared/api/storefront/services/order-service';
@@ -5,17 +5,19 @@ import { FormattedMessage } from '../intl/formatted-message.js';
5
5
  import { useCultureCode } from '../intl/use-culture-code.js';
6
6
  import { useFetchNavigationLinks } from '../shared/api/bff/hooks/use-fetch-navigation-links.js';
7
7
  import { isNavigationSection } from '../shared/api/bff/model/bff.model.js';
8
+ import { useIsAuthenticated } from '../shared/api/storefront/hooks/authentication/use-is-authenticated.js';
8
9
  import { Footer } from './footer.js';
9
10
 
10
11
  function ConnectedFooter({ className, onCountryLanguageChange, source, }) {
11
12
  const cultureCode = useCultureCode();
12
13
  const { data } = useFetchNavigationLinks({ cultureCode, source });
14
+ const isAuthenticated = useIsAuthenticated();
13
15
  if (data && data.key !== 'navigation')
14
16
  throw new Error('Invalid navigation data');
15
17
  const footerNavigationSection = data?.items
16
18
  .filter(isNavigationSection)
17
19
  .find(item => item.key === 'footer');
18
- return (jsx(Footer, { className: className, copyright: jsx(FormattedMessage, { id: "Copyright \u00A9 Sonic Equipment B.V." }), countrySelector: jsx(ConnectedCountrySelector, { defaultCountryCode: "NL", defaultLanguageCode: "EN", onChange: onCountryLanguageChange }), footerNavigationSection: footerNavigationSection }));
20
+ return (jsx(Footer, { className: className, copyright: jsx(FormattedMessage, { id: "Copyright \u00A9 Sonic Equipment B.V." }), countrySelector: jsx(ConnectedCountrySelector, { defaultCountryCode: "NL", defaultLanguageCode: "EN", onChange: onCountryLanguageChange, showCountry: isAuthenticated === false }), footerNavigationSection: footerNavigationSection }));
19
21
  }
20
22
 
21
23
  export { ConnectedFooter };
@@ -27,7 +27,7 @@ function PasswordValidation({ isDisabled = false, onPasswordChanged, }) {
27
27
  t('Password does not meet requirements'));
28
28
  } }) }), jsx(FormSegment, { children: jsx(PasswordField, { autoComplete: "new-password", customErrorMessage: isMatchingPasswords() === false
29
29
  ? 'Passwords do not match'
30
- : undefined, "data-test-selector": "new_passwordConfirm", isDisabled: isDisabled, isInvalid: isMatchingPasswords() === false ? true : undefined, isRequired: true, label: t('Confirm password'), onChange: setPasswordConfirm, value: passwordConfirm }) })] }));
30
+ : undefined, "data-test-selector": "new_passwordConfirm", isDisabled: isDisabled, isInvalid: isMatchingPasswords() === false ? true : undefined, isRequired: true, label: t('Confirm new password'), onChange: setPasswordConfirm, value: passwordConfirm }) })] }));
31
31
  }
32
32
 
33
33
  export { PasswordValidation };
package/dist/index.js CHANGED
@@ -218,6 +218,8 @@ export { AnnouncementList } from './notifications/announcements/announcement-lis
218
218
  export { ConnectedAnnouncementList } from './notifications/announcements/connected-announcement-list.js';
219
219
  export { useFilterAnnouncements } from './notifications/announcements/use-filter-announcements.js';
220
220
  export { IntersectionObserverComponent } from './observers/intersection-observer.js';
221
+ export { ChangePasswordPage } from './pages/account/change-password-page/change-password-page.js';
222
+ export { ChangePasswordForm } from './pages/account/components/change-password-form/change-password-form.js';
221
223
  export { CreateAccountForm } from './pages/account/components/create-account-form/create-account-form.js';
222
224
  export { SignInForm } from './pages/account/components/sign-in-form/sign-in-form.js';
223
225
  export { CreateAccountPage } from './pages/account/create-account-page/create-account-page.js';
@@ -318,8 +320,9 @@ export { useFetchFavorites } from './shared/api/bff/hooks/use-fetch-favorites.js
318
320
  export { useFetchNavigationLinks } from './shared/api/bff/hooks/use-fetch-navigation-links.js';
319
321
  export { useFetchProductDetailsPageData } from './shared/api/bff/hooks/use-fetch-product-details-page-data.js';
320
322
  export { useFetchProductListingPageData } from './shared/api/bff/hooks/use-fetch-product-listing-page-data.js';
323
+ export { useFetchProductsPrices } from './shared/api/bff/hooks/use-fetch-products-prices.js';
321
324
  export { useFetchRecentlyViewedProducts } from './shared/api/bff/hooks/use-fetch-recently-viewed-products.js';
322
- export { fetchAnnouncements, fetchNavigationLinks, fetchProductDetailsPageData, fetchProductListingPageData, fetchRecentlyViewedProducts, patchCart, placeOrder, saveCartForLater } from './shared/api/bff/services/bff-service.js';
325
+ export { fetchAnnouncements, fetchNavigationLinks, fetchProductDetailsPageData, fetchProductListingPageData, fetchProductsPrices, fetchRecentlyViewedProducts, patchCart, placeOrder, saveCartForLater } from './shared/api/bff/services/bff-service.js';
323
326
  export { useAwaitableMutation } from './shared/api/shared/hooks/use-awaitable-mutation.js';
324
327
  export { useCreateAccount } from './shared/api/storefront/hooks/account/use-create-account.js';
325
328
  export { useCreateGuestAccount } from './shared/api/storefront/hooks/account/use-create-guest-account.js';
@@ -379,8 +382,9 @@ export { useDeleteWishListItemFromWishList } from './shared/api/storefront/hooks
379
382
  export { useFetchAllWishListsItems } from './shared/api/storefront/hooks/wishlist/use-fetch-all-wishlists-items.js';
380
383
  export { useFetchWishLists } from './shared/api/storefront/hooks/wishlist/use-fetch-wishlists.js';
381
384
  export { ExistingAccountError, createAccount, createGuestAccount, fetchCurrentAccount, patchCurrentAccount } from './shared/api/storefront/services/account-service.js';
382
- export { InvalidPasswordError, NonUniquePasswordError, createSession, fetchSession, patchSession, recoverPassword, signIn, signOut } from './shared/api/storefront/services/authentication-service.js';
385
+ export { AccountLockedOutError, InvalidEmailPasswordCombinationError, InvalidGrantError, InvalidPasswordError, NonUniquePasswordError, UnableToChangePasswordError, UserNotFoundError, createSession, fetchSession, patchSession, recoverPassword, signIn, signOut } from './shared/api/storefront/services/authentication-service.js';
383
386
  export { addBulkProductsToCurrentCart, addProductToCurrentCart, convertToMinorUnits, deleteCartLineById, deleteCurrentCart, fetchCart, fetchCurrentCart, fetchCurrentCartLines, fetchCurrentCartProductAtp, fetchCurrentCartPromotions, fetchCurrentCheckoutAtp, getAdyenPaymentDetails, patchCartLineById, postAdyenPayment } from './shared/api/storefront/services/cart-service.js';
387
+ export { fetchCategories } from './shared/api/storefront/services/category-service.js';
384
388
  export { fetchBillToAddress, fetchBillToAddresses, fetchCurrentBillToAddress, fetchCurrentShipToAddress, fetchFulfillmentMethods, fetchPagedShipToAddresses, fetchShipToAddress, fetchShipToAddresses, patchBillToAddress, patchShipToAddress, postShipToAddress } from './shared/api/storefront/services/customer-service.js';
385
389
  export { validateVATNumber } from './shared/api/storefront/services/finance-service.js';
386
390
  export { fetchOrderById, fetchOrders } from './shared/api/storefront/services/order-service.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' | '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 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' | 'Company name' | 'Conceal value' | 'Confirm password' | 'Continue shopping' | 'Continue to sign in' | 'Continue' | 'Copyright © Sonic Equipment B.V.' | 'Cost overview' | 'Country' | 'create account' | 'Create new list' | 'Currency Change' | 'Current page' | 'Current Password is invalid' | 'Date' | 'Decrease' | 'Default shipping address' | 'Delivery date' | 'Delivery expected on {0}' | 'DESC' | 'Double check your spelling' | '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' | 'Language' | 'Last name' | 'List name already exists' | 'Log out' | 'Main menu' | '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.' | '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' | '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 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' | 'Remember me' | 'Remove' | 'Remove all' | 'Reorder' | 'Reordering...' | 'Requested delivery date' | 'Results' | 'Reveal value' | 'Review and payment' | 'Save order' | 'Save' | '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' | '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…' | '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 product has been added to your cart.' | 'The product has been removed from your cart.' | 'The product has been updated in your cart.' | 'The order has been added to your cart.' | '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' | '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 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 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 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' | 'Company name' | 'Conceal value' | 'Confirm new password' | 'Continue shopping' | 'Continue to sign in' | 'Continue' | 'Copyright © Sonic Equipment B.V.' | 'Cost overview' | 'Country' | 'create account' | 'Create new list' | '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' | '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' | 'Language' | 'Last name' | 'List name already exists' | 'Log out' | 'Main menu' | '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.' | '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' | '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 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' | 'Remember me' | 'Remove' | 'Remove all' | 'Reorder' | 'Reordering...' | 'Requested delivery date' | 'Results' | 'Reveal value' | 'Review and payment' | 'Save order' | 'Save' | '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' | '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…' | '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 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' | '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';
@@ -28,6 +28,7 @@ interface DialogProps extends Omit<ModalProps, 'children' | 'className'> {
28
28
  validationErrors?: ValidationErrors;
29
29
  }
30
30
  interface DialogFooterProps {
31
+ allowClose?: boolean;
31
32
  allowSubmit?: boolean;
32
33
  cancelLabel: string;
33
34
  close: VoidFunction;
@@ -12,8 +12,8 @@ import { Heading } from '../../typography/heading/heading.js';
12
12
  import { Modal } from '../modal/modal.js';
13
13
  import styles from './dialog.module.css.js';
14
14
 
15
- function Footer({ allowSubmit = true, cancelLabel, close, isSubmitting, submitLabel, }) {
16
- return (jsxs(Fragment, { children: [jsx(Button, { withArrow: true, color: "primary", "data-test-selector": "dialogSubmit", isDisabled: !allowSubmit, isLoading: isSubmitting ? jsx(FormattedMessage, { id: "Submitting\u2026" }) : undefined, size: "md", type: "submit", children: jsx(FormattedMessage, { noTranslationId: true, id: submitLabel }) }), jsx(Button, { color: "secondary", "data-test-selector": "dialogCancel", onClick: close, size: "md", variant: "outline", children: jsx(FormattedMessage, { noTranslationId: true, id: cancelLabel }) })] }));
15
+ function Footer({ allowClose = true, allowSubmit = true, cancelLabel, close, isSubmitting, submitLabel, }) {
16
+ return (jsxs(Fragment, { children: [jsx(Button, { withArrow: true, color: "primary", "data-test-selector": "dialogSubmit", isDisabled: !allowSubmit, isLoading: isSubmitting ? jsx(FormattedMessage, { id: "Submitting\u2026" }) : undefined, size: "md", type: "submit", children: jsx(FormattedMessage, { noTranslationId: true, id: submitLabel }) }), allowClose && (jsx(Button, { color: "secondary", "data-test-selector": "dialogCancel", onClick: close, size: "md", variant: "outline", children: jsx(FormattedMessage, { noTranslationId: true, id: cancelLabel }) }))] }));
17
17
  }
18
18
  function Dialog({ allowClose = true, allowSubmit = true, cancelLabel = 'Close', children, className, 'data-test-selector': dataTestSelector = 'dialog', footer = Footer, hasCloseButton = true, hideTitle, isDismissable, isFullScreen, isKeyboardDismissDisabled, isOpen, isSubmitting = false, onOpenChange, onSubmit, shouldCloseOnInteractOutside, submitLabel = 'Submit', title, validationErrors, }) {
19
19
  const t = useFormattedMessage();
@@ -22,6 +22,7 @@ function Dialog({ allowClose = true, allowSubmit = true, cancelLabel = 'Close',
22
22
  overlay: clsx(styles['modal-overlay'], typeof className === 'string' ? className : className?.modal),
23
23
  }, hasCloseButton: false, isDismissable: isDismissable, isFullScreen: isFullScreen, isKeyboardDismissDisabled: isKeyboardDismissDisabled, isOpen: isOpen, onOpenChange: onOpenChange, shouldCloseOnInteractOutside: shouldCloseOnInteractOutside, children: jsx(Dialog$1, { "aria-label": title, className: clsx(styles.dialog, typeof className === 'string' ? undefined : className?.dialog), "data-test-selector": dataTestSelector, children: ({ close }) => (jsx(Form, { className: clsx(styles.form, typeof className === 'string' ? undefined : className?.form), footer: jsx("div", { className: clsx(styles.footer, typeof className === 'string' ? undefined : className?.footer), children: footer instanceof Function
24
24
  ? footer({
25
+ allowClose,
25
26
  allowSubmit,
26
27
  cancelLabel,
27
28
  close,
@@ -1,9 +1,9 @@
1
1
  "use client";
2
2
  import { jsx } from 'react/jsx-runtime';
3
+ import { useCookie } from '../../cookies/use-cookie.js';
3
4
  import { useCultureCode } from '../../intl/use-culture-code.js';
4
5
  import { useLogError } from '../../logging/use-log-error.js';
5
6
  import { useFetchAnnouncements } from '../../shared/api/bff/hooks/use-fetch-announcements.js';
6
- import { useLocalStorage } from '../../shared/local-storage/use-local-storage.js';
7
7
  import { AnnouncementList } from './announcement-list.js';
8
8
 
9
9
  function ConnectedAnnouncementList({ className, }) {
@@ -12,11 +12,11 @@ function ConnectedAnnouncementList({ className, }) {
12
12
  cultureCode,
13
13
  });
14
14
  useLogError(error);
15
- const [dismissedIds, setDismissedIds] = useLocalStorage('dismissedAnnouncementIds', []);
16
- const filteredAnnouncements = announcements?.filter(({ id }) => !dismissedIds.includes(id));
15
+ const [dismissedIds, setDismissedIds] = useCookie('dismissedAnnouncementIds');
16
+ const filteredAnnouncements = announcements?.filter(({ id }) => !dismissedIds?.includes(id));
17
17
  if (!filteredAnnouncements)
18
18
  return null;
19
- return (jsx(AnnouncementList, { announcements: filteredAnnouncements, className: className, onDismiss: id => setDismissedIds(dismissedIds => [...dismissedIds, id]), sticky: true }));
19
+ return (jsx(AnnouncementList, { announcements: filteredAnnouncements, className: className, onDismiss: id => setDismissedIds(dismissedIds => [...(dismissedIds?.split(';') || []), id].join(';')), sticky: true }));
20
20
  }
21
21
 
22
22
  export { ConnectedAnnouncementList };
@@ -0,0 +1,6 @@
1
+ export interface ChangePasswordPageProps {
2
+ reset: boolean;
3
+ resetToken?: string;
4
+ userId?: string;
5
+ }
6
+ export declare function ChangePasswordPage({ reset: isResettingPassword, resetToken, userId, }: ChangePasswordPageProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,57 @@
1
+ "use client";
2
+ import { jsx } from 'react/jsx-runtime';
3
+ import { useState, useMemo } from 'react';
4
+ import { FormattedMessage } from '../../../intl/formatted-message.js';
5
+ import { useFetchSession } from '../../../shared/api/storefront/hooks/authentication/use-fetch-session.js';
6
+ import { usePatchSession } from '../../../shared/api/storefront/hooks/authentication/use-patch-session.js';
7
+ import { UserNotFoundError, UnableToChangePasswordError } from '../../../shared/api/storefront/services/authentication-service.js';
8
+ import { useNavigate } from '../../../shared/routing/use-navigate.js';
9
+ import { usePaths } from '../../../shared/routing/use-paths.js';
10
+ import { useToast } from '../../../toast/use-toast.js';
11
+ import { ChangePasswordForm } from '../components/change-password-form/change-password-form.js';
12
+ import { SignInPageLayout } from '../layouts/sign-in-page-layout/sign-in-page-layout.js';
13
+
14
+ function ChangePasswordPage({ reset: isResettingPassword, resetToken, userId, }) {
15
+ const paths = usePaths();
16
+ const { navigate } = useNavigate();
17
+ const [isSuccess, setIsSuccess] = useState(false);
18
+ const { data: session } = useFetchSession();
19
+ const { addToast } = useToast();
20
+ const { error: errorPatchSession, isLoading: isUpdating, mutate: patchSession, } = usePatchSession();
21
+ const handleSubmit = async ({ data }) => {
22
+ if (!resetToken || !userId)
23
+ return;
24
+ const { currentPassword, newPassword } = data;
25
+ await patchSession({
26
+ session: {
27
+ newPassword,
28
+ password: currentPassword,
29
+ resetToken,
30
+ userName: undefined,
31
+ userProfileId: userId,
32
+ },
33
+ });
34
+ setIsSuccess(true);
35
+ addToast({
36
+ body: (jsx(FormattedMessage, { id: isResettingPassword
37
+ ? 'Password changed. Please sign in again.'
38
+ : 'Account was activated successfully.' })),
39
+ isUserDismissable: false,
40
+ messageType: 'success',
41
+ });
42
+ navigate(paths.SIGN_IN, { replace: true });
43
+ };
44
+ const errorType = useMemo(() => {
45
+ const error = errorPatchSession;
46
+ if (!error)
47
+ return undefined;
48
+ if (error instanceof UserNotFoundError)
49
+ return 'User Not Found';
50
+ if (error instanceof UnableToChangePasswordError)
51
+ return 'Invalid Token';
52
+ return 'Unexpected error';
53
+ }, [errorPatchSession]);
54
+ return (jsx(SignInPageLayout, { fullHeight: true, "data-test-selector": "changeAccountPage", children: !resetToken || !userId ? (jsx("p", { children: jsx(FormattedMessage, { id: "The link you used for resetting your password is invalid. Please, reset your password again, or contact Customer Support." }) })) : (jsx(ChangePasswordForm, { errorType: errorType, isDisabled: !session || isSuccess, isPendingChangingPassword: isUpdating, onSubmit: handleSubmit, username: undefined })) }));
55
+ }
56
+
57
+ export { ChangePasswordPage };
@@ -0,0 +1,16 @@
1
+ export interface ChangePasswordSubmitData {
2
+ currentPassword?: string;
3
+ newPassword: string;
4
+ }
5
+ export type ChangePasswordErrorTypes = 'Invalid Token' | 'User Not Found' | 'Unexpected error' | undefined;
6
+ export interface ChangePasswordFormProps {
7
+ errorType?: ChangePasswordErrorTypes;
8
+ isDisabled?: boolean;
9
+ isLoading?: boolean;
10
+ isPendingChangingPassword?: boolean;
11
+ onSubmit?: ({ data, }: {
12
+ data: ChangePasswordSubmitData;
13
+ }) => void | Promise<void>;
14
+ username: string | undefined;
15
+ }
16
+ export declare function ChangePasswordForm({ errorType, isDisabled: _isDisabled, isLoading, isPendingChangingPassword, onSubmit, }: ChangePasswordFormProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,49 @@
1
+ "use client";
2
+ import { jsx } from 'react/jsx-runtime';
3
+ import { Button } from '../../../../buttons/button/button.js';
4
+ import { Form } from '../../../../forms/layout/form/form.js';
5
+ import { FormSegment } from '../../../../forms/layout/form/form-segment.js';
6
+ import { FormSegmentGroup } from '../../../../forms/layout/form/form-segment-group.js';
7
+ import { useFormattedMessage } from '../../../../intl/use-formatted-message.js';
8
+ import { DynamicLoadingOverlay } from '../../../../loading/dynamic-loading-overlay.js';
9
+ import { voidFunction } from '../../../../shared/model/defaults.js';
10
+ import { Heading } from '../../../../typography/heading/heading.js';
11
+ import { ChangePassword } from '../../../my-sonic/actions/change-password/change-password.js';
12
+
13
+ function ChangePasswordForm({ errorType, isDisabled: _isDisabled = false, isLoading = false, isPendingChangingPassword = false, onSubmit = voidFunction, }) {
14
+ const t = useFormattedMessage();
15
+ const title = t('Change password');
16
+ const isDisabled = isPendingChangingPassword || _isDisabled;
17
+ // form submit handler
18
+ const handleSubmit = ({ formData }) => {
19
+ // const currentPassword = formData.get('current-password')?.toString()
20
+ const newPassword = formData.get('new-password')?.toString();
21
+ if (!newPassword)
22
+ throw new Error('Password values are required');
23
+ onSubmit({
24
+ data: {
25
+ newPassword,
26
+ },
27
+ });
28
+ };
29
+ // error message to display
30
+ const errorMessage = (function (type) {
31
+ switch (type) {
32
+ case undefined:
33
+ return;
34
+ case 'User Not Found':
35
+ return t('The user to change the password for could not be found. Please, reset your password again, or contact Customer Support.');
36
+ case 'Invalid Token':
37
+ return t('The password could not be changed. Please, reset your password again, or contact Customer Support.');
38
+ default:
39
+ return t('An unexpected error occured. Please try again.');
40
+ }
41
+ })(errorType);
42
+ // form header
43
+ const header = (jsx(Heading, { "data-test-selector": "pageTitle", italic: true, size: "m", tag: "h1", uppercase: true, children: title }));
44
+ // form footer
45
+ const footer = (jsx(FormSegment, { children: jsx(Button, { "data-test-selector": "changePassword_submit", isDisabled: isDisabled, isLoading: isPendingChangingPassword && t('Changing password…'), type: "submit", withArrow: true, children: t('Change password') }) }));
46
+ return (jsx(Form, { autoComplete: true, errorMessage: errorMessage, footer: footer, header: header, onSubmit: handleSubmit, title: title, children: jsx(DynamicLoadingOverlay, { isLoading: isLoading, children: jsx(FormSegmentGroup, { children: jsx(ChangePassword, { isDisabled: isDisabled, requireCurrentPassword: false }) }) }) }));
47
+ }
48
+
49
+ export { ChangePasswordForm };
@@ -7,8 +7,8 @@ interface LoginData {
7
7
  interface GuestLoginData {
8
8
  guestSignIn: true;
9
9
  }
10
- export type SubmitData = LoginData | GuestLoginData;
11
- export type SignInErrorTypes = 'Access denied' | 'Unexpected error' | undefined;
10
+ export type SignInSubmitData = LoginData | GuestLoginData;
11
+ export type SignInErrorTypes = 'Access denied' | 'Account locked' | 'Unexpected error' | 'Unprocessable entity' | undefined;
12
12
  export interface SignInFormProps {
13
13
  allowGuestSignIn?: boolean;
14
14
  createAccountPath: string;
@@ -21,7 +21,7 @@ export interface SignInFormProps {
21
21
  isPendingUserSignIn?: boolean;
22
22
  onRecoverPasswordDialogOpen?: () => void;
23
23
  onSubmit?: ({ data }: {
24
- data: SubmitData;
24
+ data: SignInSubmitData;
25
25
  }) => void;
26
26
  }
27
27
  export declare function SignInForm({ allowGuestSignIn, createAccountPath, errorType, initialEmail, initialRememberMe, isDisabled: _isDisabled, isLoading, isPendingGuestSignIn, isPendingUserSignIn, onRecoverPasswordDialogOpen, onSubmit, }: SignInFormProps): import("react/jsx-runtime").JSX.Element;
@@ -54,6 +54,10 @@ function SignInForm({ allowGuestSignIn = false, createAccountPath, errorType, in
54
54
  return;
55
55
  case 'Access denied':
56
56
  return t('Your email and password were not recognized.');
57
+ case 'Account locked':
58
+ return t('Your account is temporarily locked. Please try again later or contact Customer Support.');
59
+ case 'Unprocessable entity':
60
+ return; // a Change Password dialog is shown
57
61
  default:
58
62
  return t('An unexpected error occured. Please try again.');
59
63
  }
@@ -1,63 +1,100 @@
1
1
  "use client";
2
2
  import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
3
3
  import { useState, useMemo } from 'react';
4
+ import { FormattedMessage } from '../../../intl/formatted-message.js';
5
+ import { useFormattedMessage } from '../../../intl/use-formatted-message.js';
4
6
  import { RecoverPasswordDialog } from '../../../modals/recover-password/recover-password-dialog.js';
5
7
  import { useCreateGuestAccount } from '../../../shared/api/storefront/hooks/account/use-create-guest-account.js';
6
8
  import { useFetchSession } from '../../../shared/api/storefront/hooks/authentication/use-fetch-session.js';
9
+ import { usePatchSession } from '../../../shared/api/storefront/hooks/authentication/use-patch-session.js';
7
10
  import { useSignIn } from '../../../shared/api/storefront/hooks/authentication/use-sign-in.js';
8
- import { isRequestError } from '../../../shared/fetch/request.js';
11
+ import { InvalidEmailPasswordCombinationError, AccountLockedOutError } from '../../../shared/api/storefront/services/authentication-service.js';
12
+ import { UnprocessableContentRequestError } from '../../../shared/fetch/request.js';
9
13
  import { useDisclosure } from '../../../shared/hooks/use-disclosure.js';
10
14
  import { useNavigate } from '../../../shared/routing/use-navigate.js';
11
15
  import { usePaths } from '../../../shared/routing/use-paths.js';
16
+ import { useToast } from '../../../toast/use-toast.js';
17
+ import { ChangePasswordDialog } from '../../my-sonic/actions/change-password/change-password-dialog.js';
12
18
  import { SignInForm } from '../components/sign-in-form/sign-in-form.js';
13
19
  import { SignInPageLayout } from '../layouts/sign-in-page-layout/sign-in-page-layout.js';
14
20
 
15
21
  function SignInPage({ returnUrl } = {}) {
16
22
  const paths = usePaths();
17
23
  const { navigate } = useNavigate();
24
+ const [userName, setUserName] = useState();
25
+ const [rememberMe, setRememberMe] = useState(false);
18
26
  const [isSuccess, setIsSuccess] = useState(false);
19
27
  const { isOpen: isRecoverPasswordDialogOpen, setIsOpen: setRecoverPasswordDialogOpen, } = useDisclosure(false);
28
+ const { isOpen: isChangePasswordDialogOpen, setIsOpen: setChangePasswordDialogOpen, } = useDisclosure(false);
20
29
  const { data: session, isLoading } = useFetchSession();
30
+ const t = useFormattedMessage();
31
+ const { addToast } = useToast();
32
+ /* Sign in */
21
33
  const { error: errorSignIn, isPending: isPendingSignIn, mutate: signIn, reset: resetSignIn, } = useSignIn();
22
34
  const { error: errorCreateGuest, isPending: isPendingCreateGuest, mutate: createGuest, reset: resetCreateGuest, } = useCreateGuestAccount();
23
- const errorType = useMemo(() => {
35
+ const signInErrorType = useMemo(() => {
24
36
  const error = errorSignIn || errorCreateGuest;
25
37
  if (!error)
26
38
  return undefined;
27
39
  if (errorCreateGuest)
28
40
  return 'Unexpected error';
29
- if (isRequestError(error) &&
30
- error.status === 400 &&
31
- error.body?.error === 'invalid_grant')
41
+ if (error instanceof InvalidEmailPasswordCombinationError)
32
42
  return 'Access denied';
43
+ if (error instanceof AccountLockedOutError)
44
+ return 'Account locked';
45
+ if (error instanceof UnprocessableContentRequestError) {
46
+ setChangePasswordDialogOpen(true);
47
+ return 'Unprocessable entity';
48
+ }
33
49
  return 'Unexpected error';
34
- }, [errorCreateGuest, errorSignIn]);
35
- const onSuccess = () => {
50
+ }, [errorCreateGuest, errorSignIn, setChangePasswordDialogOpen]);
51
+ const onSignInSuccess = () => {
36
52
  setIsSuccess(true);
37
53
  navigate(returnUrl || paths.HOME, { reload: true });
38
54
  };
39
55
  const allowGuestSignIn = returnUrl?.toLowerCase() === paths.CHECKOUT_SHIPPING.toLowerCase();
40
56
  const createAccountPath = `${paths.ACCOUNT_CREATE}${returnUrl ? `?returnUrl=${encodeURIComponent(returnUrl)}` : ''}`;
41
- const onSubmit = ({ data }) => {
57
+ const onSignIn = ({ data }) => {
42
58
  resetSignIn();
43
59
  resetCreateGuest();
44
60
  if (data.guestSignIn) {
45
61
  if (session?.isGuest && session.isAuthenticated)
46
- return onSuccess();
47
- createGuest(void undefined, { onSuccess });
62
+ return onSignInSuccess();
63
+ createGuest(void undefined, { onSuccess: onSignInSuccess });
48
64
  }
49
65
  else {
66
+ setUserName(data.email);
67
+ setRememberMe(data.rememberMe);
50
68
  signIn({
51
69
  password: data.password,
52
70
  rememberMe: data.rememberMe,
53
71
  userName: data.email,
54
- }, { onSuccess });
72
+ }, { onSuccess: onSignInSuccess });
55
73
  }
56
74
  };
57
- const onRecoverPasswordDialogOpen = () => {
58
- setRecoverPasswordDialogOpen(true);
75
+ // Change password
76
+ const { error: errorChangePassword, isLoading: isSessionUpdating, mutate: changePassword, } = usePatchSession();
77
+ const onChangePassword = async (currentPassword, newPassword) => {
78
+ await changePassword({
79
+ session: {
80
+ newPassword,
81
+ password: currentPassword,
82
+ userName: userName || '',
83
+ },
84
+ });
85
+ addToast({
86
+ body: jsx(FormattedMessage, { id: "Password changed. Please sign in again." }),
87
+ isUserDismissable: false,
88
+ messageType: 'success',
89
+ });
90
+ setChangePasswordDialogOpen(false);
91
+ signIn({
92
+ password: newPassword,
93
+ rememberMe,
94
+ userName: userName || '',
95
+ }, { onSuccess: onSignInSuccess });
59
96
  };
60
- return (jsxs(Fragment, { children: [jsx(SignInPageLayout, { fullHeight: true, "data-test-selector": "signInPage", children: jsx(SignInForm, { allowGuestSignIn: allowGuestSignIn, createAccountPath: createAccountPath, errorType: errorType, initialEmail: session?.isGuest ? '' : session?.email, initialRememberMe: session?.rememberMe, isDisabled: !session || isSuccess, isLoading: isLoading, isPendingGuestSignIn: isPendingCreateGuest, isPendingUserSignIn: isPendingSignIn, onRecoverPasswordDialogOpen: onRecoverPasswordDialogOpen, onSubmit: onSubmit }) }), jsx(RecoverPasswordDialog, { isOpen: isRecoverPasswordDialogOpen, onOpenChange: isOpen => setRecoverPasswordDialogOpen(isOpen) })] }));
97
+ return (jsxs(Fragment, { children: [jsx(SignInPageLayout, { fullHeight: true, "data-test-selector": "signInPage", children: jsx(SignInForm, { allowGuestSignIn: allowGuestSignIn, createAccountPath: createAccountPath, errorType: signInErrorType, initialEmail: session?.isGuest ? '' : session?.email, initialRememberMe: session?.rememberMe, isDisabled: !session || isSuccess, isLoading: isLoading, isPendingGuestSignIn: isPendingCreateGuest, isPendingUserSignIn: isPendingSignIn, onRecoverPasswordDialogOpen: () => setRecoverPasswordDialogOpen(true), onSubmit: onSignIn }) }), jsx(RecoverPasswordDialog, { isOpen: isRecoverPasswordDialogOpen, onOpenChange: isOpen => setRecoverPasswordDialogOpen(isOpen) }), jsx(ChangePasswordDialog, { allowClose: false, error: errorChangePassword, informationalText: t('You are required to change your password and then sign in again, using your new credentials.'), isOpen: isChangePasswordDialogOpen, isUpdating: isSessionUpdating, onClose: () => setChangePasswordDialogOpen(false), onPasswordChanged: onChangePassword, userName: userName })] }));
61
98
  }
62
99
 
63
100
  export { SignInPage };
@@ -1,10 +1,12 @@
1
1
  export interface ChangePasswordDialogProps {
2
+ allowClose?: boolean;
2
3
  error?: Error | null | unknown;
4
+ informationalText?: string;
3
5
  isLoading?: boolean;
4
6
  isOpen: boolean;
5
7
  isUpdating?: boolean;
6
8
  onClose: () => void;
7
9
  onPasswordChanged: (currentPassword: string, newPassword: string) => void;
8
- username: string | undefined;
10
+ userName?: string;
9
11
  }
10
- export declare function ChangePasswordDialog({ error, isLoading, isOpen, isUpdating, onClose, onPasswordChanged, username, }: ChangePasswordDialogProps): import("react/jsx-runtime").JSX.Element;
12
+ export declare function ChangePasswordDialog({ allowClose, error, informationalText, isLoading, isOpen, isUpdating, onClose, onPasswordChanged, userName, }: ChangePasswordDialogProps): import("react/jsx-runtime").JSX.Element;
@@ -1,17 +1,17 @@
1
1
  "use client";
2
- import { jsx } from 'react/jsx-runtime';
2
+ import { jsxs, jsx } from 'react/jsx-runtime';
3
3
  import { FormSegmentGroup } from '../../../../forms/layout/form/form-segment-group.js';
4
4
  import { useFormattedMessage } from '../../../../intl/use-formatted-message.js';
5
5
  import { Dialog } from '../../../../modals/dialog/dialog.js';
6
6
  import { UnauthorizedRequestError } from '../../../../shared/fetch/request.js';
7
7
  import { ChangePassword } from './change-password.js';
8
+ import styles from './change-password-dialog.module.css.js';
8
9
 
9
- function ChangePasswordDialog({ error, isLoading = false, isOpen, isUpdating = false, onClose, onPasswordChanged, username, }) {
10
+ function ChangePasswordDialog({ allowClose = true, error, informationalText, isLoading = false, isOpen, isUpdating = false, onClose, onPasswordChanged, userName, }) {
10
11
  const t = useFormattedMessage();
11
- return (jsx(Dialog, { allowSubmit: Boolean(username) &&
12
- !isLoading &&
12
+ return (jsxs(Dialog, { allowClose: allowClose, allowSubmit: !isLoading &&
13
13
  !isUpdating &&
14
- !(error instanceof UnauthorizedRequestError), isOpen: isOpen, onOpenChange: isOpen => !isOpen && onClose(), onSubmit: ({ formData }) => {
14
+ !(error instanceof UnauthorizedRequestError), hasCloseButton: allowClose, isDismissable: allowClose, isKeyboardDismissDisabled: !allowClose, isOpen: isOpen, onOpenChange: isOpen => !isOpen && onClose(), onSubmit: ({ formData }) => {
15
15
  const currentPassword = formData.get('current-password')?.toString();
16
16
  const newPassword = formData.get('new-password')?.toString();
17
17
  if (!currentPassword)
@@ -19,7 +19,7 @@ function ChangePasswordDialog({ error, isLoading = false, isOpen, isUpdating = f
19
19
  if (!newPassword)
20
20
  throw new Error('New password is required');
21
21
  onPasswordChanged(currentPassword, newPassword);
22
- }, title: t('Change password'), children: jsx(FormSegmentGroup, { children: jsx(ChangePassword, { error: error, isLoading: isLoading, isUpdating: isUpdating, username: username }) }) }));
22
+ }, title: t('Change password'), children: [informationalText && (jsx("p", { className: styles['informational-text'], children: informationalText })), jsx(FormSegmentGroup, { children: jsx(ChangePassword, { error: error, isDisabled: isUpdating, isLoading: isLoading, userName: userName }) })] }));
23
23
  }
24
24
 
25
25
  export { ChangePasswordDialog };
@@ -0,0 +1,3 @@
1
+ var styles = {"informational-text":"change-password-dialog-module-e1njU"};
2
+
3
+ export { styles as default };
@@ -1,7 +1,8 @@
1
1
  export interface ChangePasswordProps {
2
2
  error?: Error | null | unknown;
3
+ isDisabled?: boolean;
3
4
  isLoading?: boolean;
4
- isUpdating?: boolean;
5
- username: string | undefined;
5
+ requireCurrentPassword?: boolean;
6
+ userName?: string;
6
7
  }
7
- export declare function ChangePassword({ error, isLoading, isUpdating, username, }: ChangePasswordProps): import("react/jsx-runtime").JSX.Element;
8
+ export declare function ChangePassword({ error, isDisabled, isLoading, requireCurrentPassword, userName, }: ChangePasswordProps): import("react/jsx-runtime").JSX.Element;
@@ -8,10 +8,9 @@ import { ProgressCircle } from '../../../../loading/progress-circle.js';
8
8
  import { Message } from '../../../../message/message.js';
9
9
  import { NonUniquePasswordError, InvalidPasswordError } from '../../../../shared/api/storefront/services/authentication-service.js';
10
10
  import { UnauthorizedRequestError } from '../../../../shared/fetch/request.js';
11
- import { validatePassword } from '../../../../shared/model/account.js';
12
11
  import styles from './change-password.module.css.js';
13
12
 
14
- function ChangePassword({ error, isLoading = false, isUpdating = false, username, }) {
13
+ function ChangePassword({ error, isDisabled = false, isLoading = false, requireCurrentPassword = true, userName, }) {
15
14
  const t = useFormattedMessage();
16
15
  if (error instanceof UnauthorizedRequestError) {
17
16
  return (jsx(FormSegment, { children: jsx(Message, { type: "danger", children: t('You are not authorized to perform this action') }) }));
@@ -19,18 +18,11 @@ function ChangePassword({ error, isLoading = false, isUpdating = false, username
19
18
  if (isLoading) {
20
19
  return (jsx("div", { className: styles['loading-panel'], children: jsx(ProgressCircle, { variant: "gray" }) }));
21
20
  }
22
- if (!username) {
23
- return jsx(Message, { type: "danger", children: t('An unexpected error occured') });
24
- }
25
- return (jsxs(Fragment, { children: [jsxs(FormSegment, { children: [jsx("input", { autoComplete: "username", defaultValue: username, id: "username", name: "username", style: { display: 'none' }, type: "text" }), jsx(PasswordField, { autoComplete: "password", "data-test-selector": "current_password", isDisabled: isUpdating, isRequired: true, label: t('Password'), name: "current-password", validate: value => {
26
- if (!value)
27
- return;
28
- return (validatePassword(value) ||
29
- t('Password does not meet requirements'));
30
- } })] }), jsx(PasswordValidation, { isDisabled: isUpdating }), error && (jsx(FormSegment, { children: jsx(Message, { className: styles['error-message'], type: "danger", children: error instanceof NonUniquePasswordError ||
21
+ // rendering of hidden input with username is to assist browser password managers with complete credentials instead of password only
22
+ return (jsxs(Fragment, { children: [error && (jsx(FormSegment, { children: jsx(Message, { className: styles['error-message'], type: "danger", children: error instanceof NonUniquePasswordError ||
31
23
  error instanceof InvalidPasswordError
32
24
  ? t(error.message, { noTranslationId: true })
33
- : t('An unexpected error occured') }) }))] }));
25
+ : t('An unexpected error occured') }) })), requireCurrentPassword && (jsxs(FormSegment, { children: [userName && (jsx("input", { autoComplete: "username", defaultValue: userName, id: "username", name: "username", style: { display: 'none' }, type: "text" })), jsx(PasswordField, { autoComplete: "current-password", "data-test-selector": "current_password", isDisabled: isDisabled, isRequired: true, label: t('Current password'), name: "current-password" })] })), jsx(PasswordValidation, { isDisabled: isDisabled })] }));
34
26
  }
35
27
 
36
28
  export { ChangePassword };