@sonic-equipment/ui 219.0.0 → 220.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 (29) hide show
  1. package/dist/algolia/algolia-search-provider.js +5 -3
  2. package/dist/algolia/algolia-sonic-searchclient.js +2 -2
  3. package/dist/algolia/use-algolia-insights.d.ts +7 -0
  4. package/dist/algolia/use-algolia-insights.js +45 -7
  5. package/dist/algolia/use-algolia-search.d.ts +1 -0
  6. package/dist/buttons/favorite/connected-favorite-button.d.ts +1 -1
  7. package/dist/buttons/favorite/connected-favorite-button.js +0 -2
  8. package/dist/cards/product-card/product-card.js +5 -2
  9. package/dist/exports.d.ts +1 -0
  10. package/dist/global-search/types.d.ts +2 -0
  11. package/dist/header/buttons/account/connected-account-button.js +1 -1
  12. package/dist/index.js +2 -1
  13. package/dist/intl/translation-id.d.ts +1 -1
  14. package/dist/navigation/quick-access-menu/quick-access-menu.d.ts +2 -1
  15. package/dist/navigation/quick-access-menu/quick-access-menu.js +2 -2
  16. package/dist/pages/account/sign-in-page/sign-in-page.js +1 -1
  17. package/dist/pages/my-sonic/layouts/my-sonic-layout/my-sonic-layout-page.d.ts +1 -1
  18. package/dist/pages/my-sonic/layouts/my-sonic-layout/my-sonic-layout-page.js +1 -1
  19. package/dist/pages/my-sonic/pages/favorites/favorites-page.js +26 -1
  20. package/dist/shared/api/bff/hooks/use-fetch-favorites.d.ts +2 -0
  21. package/dist/shared/api/bff/hooks/use-fetch-favorites.js +29 -0
  22. package/dist/shared/api/storefront/hooks/wishlist/use-add-wishlist-item-to-current-wishlist.js +5 -12
  23. package/dist/shared/api/storefront/hooks/wishlist/use-add-wishlist-item-to-wishlist.js +6 -9
  24. package/dist/shared/api/storefront/hooks/wishlist/use-delete-wishlist-item-from-wishlist.js +4 -7
  25. package/dist/shared/api/storefront/hooks/wishlist/use-fetch-all-wishlists-items.js +10 -20
  26. package/dist/shared/api/storefront/services/wishlist-service.d.ts +4 -1
  27. package/dist/shared/api/storefront/services/wishlist-service.js +16 -1
  28. package/dist/styles.css +6 -6
  29. package/package.json +1 -1
@@ -37,9 +37,9 @@ function AlgoliaSearchProvider({ children, searchClient: _searchClient, }) {
37
37
  host: config.ALGOLIA_HOST,
38
38
  }), [_searchClient]);
39
39
  const languageCode = useLanguageCode();
40
- const index = getAlgoliaIndex(environment, languageCode);
41
- const productsIndexName = index.default;
42
- const productsQuerySuggestionsIndexName = index.suggestions;
40
+ const indexes = getAlgoliaIndex(environment, languageCode);
41
+ const productsIndexName = indexes.default;
42
+ const productsQuerySuggestionsIndexName = indexes.suggestions;
43
43
  const getSources = useDebouncedCallback(({ query }) => {
44
44
  return [
45
45
  {
@@ -145,6 +145,7 @@ function AlgoliaSearchProvider({ children, searchClient: _searchClient, }) {
145
145
  const globalSearchContextValue = useMemo(() => ({
146
146
  autocomplete,
147
147
  formRef,
148
+ indexes,
148
149
  inputRef,
149
150
  panelRef,
150
151
  productsIndexName,
@@ -153,6 +154,7 @@ function AlgoliaSearchProvider({ children, searchClient: _searchClient, }) {
153
154
  setState,
154
155
  state,
155
156
  }), [
157
+ indexes,
156
158
  autocomplete,
157
159
  formRef,
158
160
  inputRef,
@@ -15,9 +15,9 @@ const createSonicSearchClient = ({ apiKey, appId, host, protocol = 'https', }) =
15
15
  searchClient.transporter.timeouts = { connect: 3000, read: 3000, write: 3000 };
16
16
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
17
17
  // @ts-ignore
18
- searchClient.transporter.read = (request) => {
18
+ searchClient.transporter.read = (request, options) => {
19
19
  request.path = `/api/v1/bff/${request.path.replace('*', 'x')}`;
20
- return read(request);
20
+ return read(request, options);
21
21
  };
22
22
  return searchClient;
23
23
  };
@@ -2,6 +2,9 @@ import { CartLineModel, CartModel } from '../shared/api/storefront/model/storefr
2
2
  import { AlgoliaInsightsProviderGlobalState } from './use-algolia-insights-provider-global-state';
3
3
  export interface UseAlgoliaEventResult {
4
4
  context: Readonly<AlgoliaInsightsProviderGlobalState>;
5
+ sendAddToCartFromFavoritesPageEvent({ cartLine, }: {
6
+ cartLine: CartLineModel;
7
+ }): void;
5
8
  sendAddToCartFromProductDetailsPageEvent({ cartLine, }: {
6
9
  cartLine: CartLineModel;
7
10
  }): void;
@@ -32,6 +35,10 @@ export interface UseAlgoliaEventResult {
32
35
  objectId: string;
33
36
  position: number;
34
37
  }): void;
38
+ sendProductClickFromFavoritesPageEvent({ objectId, position, }: {
39
+ objectId: string;
40
+ position: number;
41
+ }): void;
35
42
  sendProductClickFromProductListPageEvent({ objectId, position, }: {
36
43
  objectId: string;
37
44
  position: number;
@@ -17,9 +17,27 @@ function useAlgoliaInsights() {
17
17
  const [, setGlobalState] = useAlgoliaInsightsGlobalState();
18
18
  const result = useMemo(() => ({
19
19
  context,
20
+ sendAddToCartFromFavoritesPageEvent({ cartLine }) {
21
+ if (!context.index)
22
+ return logger.warn('Unable to send addedToCartObjectIDs event, no index', context);
23
+ aa('addedToCartObjectIDs', {
24
+ currency: getCurrencyFromPriceString(cartLine.pricing?.actualPriceDisplay),
25
+ eventName: 'Favorites: AddToCart Clicked',
26
+ index: context.index,
27
+ objectData: [
28
+ {
29
+ price: cartLine.pricing?.actualPrice || undefined,
30
+ quantity: cartLine.qtyOrdered || undefined,
31
+ queryID: context.queryId,
32
+ },
33
+ ],
34
+ objectIDs: [cartLine.erpNumber],
35
+ userToken,
36
+ });
37
+ },
20
38
  sendAddToCartFromProductDetailsPageEvent({ cartLine }) {
21
39
  if (!context.index)
22
- return logger.warn('Unable to send clickedObjectIDsAfterSearch event, no index', context);
40
+ return logger.warn('Unable to send addedToCartObjectIDsAfterSearch event, no index', context);
23
41
  if (context.queryId) {
24
42
  aa('addedToCartObjectIDsAfterSearch', {
25
43
  currency: getCurrencyFromPriceString(cartLine.pricing?.actualPriceDisplay),
@@ -56,9 +74,9 @@ function useAlgoliaInsights() {
56
74
  },
57
75
  sendAddToCartFromProductListPageEvent({ cartLine }) {
58
76
  if (!context.index)
59
- return logger.warn('Unable to send clickedObjectIDsAfterSearch event, no index', context);
77
+ return logger.warn('Unable to send addedToCartObjectIDsAfterSearch event, no index', context);
60
78
  if (!context.queryId)
61
- return logger.warn('Unable to send clickedObjectIDsAfterSearch event, no queryId', context);
79
+ return logger.warn('Unable to send addedToCartObjectIDsAfterSearch event, no queryId', context);
62
80
  aa('addedToCartObjectIDsAfterSearch', {
63
81
  currency: getCurrencyFromPriceString(cartLine.pricing?.actualPriceDisplay),
64
82
  eventName: 'PLP: AddToCart ClickedAfterSearch',
@@ -77,7 +95,7 @@ function useAlgoliaInsights() {
77
95
  },
78
96
  sendAddToCartFromSearchEvent({ cartLine, queryId }) {
79
97
  if (!context.index)
80
- return logger.warn('Unable to send clickedObjectIDsAfterSearch event, no index', context);
98
+ return logger.warn('Unable to send addedToCartObjectIDsAfterSearch event, no index', context);
81
99
  aa('addedToCartObjectIDsAfterSearch', {
82
100
  currency: getCurrencyFromPriceString(cartLine.pricing?.actualPriceDisplay),
83
101
  eventName: 'SRP: AddToCart ClickedAfterSearch',
@@ -96,9 +114,9 @@ function useAlgoliaInsights() {
96
114
  },
97
115
  sendAddToCartFromSearchResultPageEvent({ cartLine }) {
98
116
  if (!context.index)
99
- return logger.warn('Unable to send clickedObjectIDsAfterSearch event, no index', context);
117
+ return logger.warn('Unable to send addedToCartObjectIDsAfterSearch event, no index', context);
100
118
  if (!context.queryId)
101
- return logger.warn('Unable to send clickedObjectIDsAfterSearch event, no queryId', context);
119
+ return logger.warn('Unable to send addedToCartObjectIDsAfterSearch event, no queryId', context);
102
120
  aa('addedToCartObjectIDsAfterSearch', {
103
121
  currency: getCurrencyFromPriceString(cartLine.pricing?.actualPriceDisplay),
104
122
  eventName: 'SRP: AddToCart ClickedAfterSearch',
@@ -179,6 +197,26 @@ function useAlgoliaInsights() {
179
197
  userToken,
180
198
  });
181
199
  },
200
+ sendProductClickFromFavoritesPageEvent({ objectId, position }) {
201
+ if (!objectId)
202
+ return logger.warn('Unable to send clickedObjectIDsAfterSearch event, no index', context);
203
+ if (!context.index)
204
+ return logger.warn('Unable to send clickedObjectIDsAfterSearch event, no index', context);
205
+ if (!context.queryId)
206
+ return logger.warn('Unable to send clickedObjectIDsAfterSearch event, no queryId', context);
207
+ aa('clickedObjectIDsAfterSearch', {
208
+ eventName: 'Favorites: Product Clicked',
209
+ index: context.index,
210
+ objectIDs: [objectId],
211
+ positions: [position],
212
+ queryID: context.queryId,
213
+ userToken,
214
+ });
215
+ setGlobalState({
216
+ index: context.index,
217
+ queryId: context.queryId,
218
+ });
219
+ },
182
220
  sendProductClickFromProductListPageEvent({ objectId, position }) {
183
221
  if (!objectId)
184
222
  return logger.warn('Unable to send clickedObjectIDsAfterSearch event, no index', context);
@@ -239,7 +277,7 @@ function useAlgoliaInsights() {
239
277
  },
240
278
  sendPurchaseEventFromPaymentPage({ cart }) {
241
279
  if (!context.index)
242
- return logger.warn('Unable to send clickedObjectIDsAfterSearch event, no index', context);
280
+ return logger.warn('Unable to send purchasedObjectIDs event, no index', context);
243
281
  if (!cart.cartLines || cart.cartLines.length === 0)
244
282
  return logger.warn('Unable to send purchasedObjectIDs event, no cartLines', cart);
245
283
  aa('purchasedObjectIDs', {
@@ -26,6 +26,7 @@ export declare function useAlgoliaSearch(): {
26
26
  recentSearches: ExtendedAutoCompleteCollection<RecentSearchHit> | undefined;
27
27
  autocomplete: import("..").Autocomplete;
28
28
  formRef: React.RefObject<HTMLFormElement>;
29
+ indexes: import("./algolia-index-config").Indexes;
29
30
  inputRef: React.RefObject<HTMLInputElement>;
30
31
  panelRef: React.RefObject<HTMLDivElement>;
31
32
  productsIndexName: string;
@@ -2,4 +2,4 @@ export declare function ConnectedFavoriteButton({ onFavorited: _onFavorited, onF
2
2
  onFavorited?: VoidFunction;
3
3
  onFavoriting?: VoidFunction;
4
4
  productId: string;
5
- }): import("react/jsx-runtime").JSX.Element | null;
5
+ }): import("react/jsx-runtime").JSX.Element;
@@ -50,8 +50,6 @@ function ConnectedFavoriteButton({ onFavorited: _onFavorited, onFavoriting: _onF
50
50
  setShowSignInDialog(true);
51
51
  refetch();
52
52
  }
53
- if (isFetching)
54
- return null;
55
53
  return (jsxs(Fragment, { children: [jsx(FavoriteButton, { isDisabled: isFetching, isFavorite: isFavorite, onClick: onFavorite }), jsx(SignInDialog, { isOpen: showSignInDialog, onOpenChange: setShowSignInDialog })] }));
56
54
  }
57
55
 
@@ -1,5 +1,6 @@
1
1
  "use client";
2
2
  import { jsx, jsxs } from 'react/jsx-runtime';
3
+ import { useEffect } from 'react';
3
4
  import { Tag } from '../../badges/tag/tag.js';
4
5
  import { Link } from '../../buttons/link/link.js';
5
6
  import { Price } from '../../display/price/price.js';
@@ -10,9 +11,11 @@ import { Image } from '../../media/image/image.js';
10
11
  import styles from './product-card.module.css.js';
11
12
 
12
13
  function ProductCard({ addToCartButton: AddToCartButton, favoriteButton: FavoriteButton, href, id, image, onClick, price, route, sku, tags, title, }) {
13
- if (!price.currencyCode) {
14
+ useEffect(() => {
15
+ if (price.currencyCode)
16
+ return;
14
17
  logger.error(`Product '${sku}' does not have a currency code`);
15
- }
18
+ }, [price.currencyCode, sku]);
16
19
  return (jsx("div", { className: styles['product-card-container'], children: jsxs("article", { "aria-labelledby": `title-${id}`, className: styles['product-card'], "data-product-id": sku, id: id, children: [jsx(Link, { className: styles.title, href: href, id: `title-${id}`, onClick: onClick, route: route, children: title }), tags && tags.length > 0 && (jsx("div", { className: styles.tags, children: tags.map(tag => (jsx(Tag, { children: jsx(FormattedMessage, { noTranslationId: true, fallbackValue: tag, id: `tag.${tag.toLowerCase()}` }) }, tag))) })), jsx(ProductSku, { className: styles.sku, sku: sku }), price.currencyCode && (jsx(Price, { className: styles.price, currencyCode: price.currencyCode, isVatIncluded: price.isVatIncluded, originalPrice: price.originalPrice, price: price.price, variant: "sonic" })), jsx("div", { className: styles['image-container'], children: jsx(Image, { ...image, fit: "contain" }) }), jsx("div", { className: styles['add-to-cart-button'], children: AddToCartButton }), jsx("div", { className: styles['favorite-button'], children: FavoriteButton && FavoriteButton })] }) }));
17
20
  }
18
21
 
package/dist/exports.d.ts CHANGED
@@ -314,6 +314,7 @@ export * from './shared/api/bff/hooks/cart/use-patch-cart';
314
314
  export * from './shared/api/bff/hooks/cart/use-place-order';
315
315
  export * from './shared/api/bff/hooks/cart/use-save-cart-for-later';
316
316
  export * from './shared/api/bff/hooks/use-fetch-announcements';
317
+ export * from './shared/api/bff/hooks/use-fetch-favorites';
317
318
  export * from './shared/api/bff/hooks/use-fetch-navigation-links';
318
319
  export * from './shared/api/bff/hooks/use-fetch-product-details-page-data';
319
320
  export * from './shared/api/bff/hooks/use-fetch-product-listing-page-data';
@@ -1,6 +1,7 @@
1
1
  import { AutocompleteApi, AutocompleteState as _AutocompleteState } from '@algolia/autocomplete-core';
2
2
  import { SearchClient } from 'algoliasearch';
3
3
  import { AlgoliaProductHit } from '../algolia/algolia-hit-type';
4
+ import { Indexes } from '../algolia/algolia-index-config';
4
5
  import { CategoryHit } from './plugins/categories-plugin';
5
6
  import { PopularCategoryHit } from './plugins/popular-categories-plugin';
6
7
  import { PopularSearchHit } from './plugins/popular-searches-plugin';
@@ -13,6 +14,7 @@ export type AutocompleteState = _AutocompleteState<AutocompleteItem>;
13
14
  export type GlobalSearchContextValue = {
14
15
  autocomplete: Autocomplete;
15
16
  formRef: React.RefObject<HTMLFormElement>;
17
+ indexes: Indexes;
16
18
  inputRef: React.RefObject<HTMLInputElement>;
17
19
  panelRef: React.RefObject<HTMLDivElement>;
18
20
  productsIndexName: string;
@@ -23,7 +23,7 @@ function ConnectedAccountButton({ className, 'data-test-selector': dataTestSelec
23
23
  const lastName = data?.lastName ? data.lastName.trim() : undefined;
24
24
  const customerName = firstName ? [firstName, lastName].join(' ') : undefined;
25
25
  const customerCompany = data?.billTo?.companyName;
26
- return (jsxs(Fragment, { children: [jsx(IconButton, { ref: triggerRef, className: className, "data-authenticated": data?.isAuthenticated ? true : false, "data-test-selector": dataTestSelector, isDisabled: isLoadingSession, onClick: toggle, children: jsx(AccountIcon, { "aria-label": t('My Sonic'), isAuthenticated: data?.isAuthenticated }) }), jsx(Popover, { className: styles['popover'], isOpen: isOpen, onOpenChange: state => (state ? open() : close()), placement: "bottom", triggerRef: triggerRef, children: jsx(QuickAccessMenu, { customerCompany: customerCompany, customerName: customerName, isAuthenticated: data?.isAuthenticated, onSignOut: signOut }) })] }));
26
+ return (jsxs(Fragment, { children: [jsx(IconButton, { ref: triggerRef, className: className, "data-authenticated": data?.isAuthenticated ? true : false, "data-test-selector": dataTestSelector, isDisabled: isLoadingSession, onClick: toggle, children: jsx(AccountIcon, { "aria-label": t('My Sonic'), isAuthenticated: data?.isAuthenticated }) }), jsx(Popover, { className: styles['popover'], isOpen: isOpen, onOpenChange: state => (state ? open() : close()), placement: "bottom", triggerRef: triggerRef, children: jsx(QuickAccessMenu, { className: styles['quick-access-menu'], customerCompany: customerCompany, customerName: customerName, isAuthenticated: data?.isAuthenticated, isGuest: data?.isGuest, onSignOut: signOut }) })] }));
27
27
  }
28
28
 
29
29
  export { ConnectedAccountButton };
package/dist/index.js CHANGED
@@ -315,6 +315,7 @@ export { usePatchCart } from './shared/api/bff/hooks/cart/use-patch-cart.js';
315
315
  export { usePlaceOrder } from './shared/api/bff/hooks/cart/use-place-order.js';
316
316
  export { useSaveCartForLater } from './shared/api/bff/hooks/cart/use-save-cart-for-later.js';
317
317
  export { useFetchAnnouncements } from './shared/api/bff/hooks/use-fetch-announcements.js';
318
+ export { useFetchFavorites } from './shared/api/bff/hooks/use-fetch-favorites.js';
318
319
  export { useFetchNavigationLinks } from './shared/api/bff/hooks/use-fetch-navigation-links.js';
319
320
  export { useFetchProductDetailsPageData } from './shared/api/bff/hooks/use-fetch-product-details-page-data.js';
320
321
  export { useFetchProductListingPageData } from './shared/api/bff/hooks/use-fetch-product-listing-page-data.js';
@@ -388,7 +389,7 @@ export { createAdyenSession, fetchAdyenConfig } from './shared/api/storefront/se
388
389
  export { markProductAsRecentlyViewed } from './shared/api/storefront/services/product-service.js';
389
390
  export { fetchTranslations } from './shared/api/storefront/services/translation-service.js';
390
391
  export { fetchCountriesLanguages, fetchCountriesWithLanguages, fetchSettings, updateLocale } from './shared/api/storefront/services/website-service.js';
391
- export { WishListNameAlreadyExistsError, addWishListItemToWishList, createWishList, deleteWishList, deleteWishListItemFromWishList, getWishList, getWishListItemsByWishListId, getWishLists } from './shared/api/storefront/services/wishlist-service.js';
392
+ export { WishListNameAlreadyExistsError, addWishListItemToWishList, createWishList, deleteWishList, deleteWishListItemFromWishList, fetchAllWishListsItems, getWishList, getWishListItemsByWishListId, getWishLists } from './shared/api/storefront/services/wishlist-service.js';
392
393
  export { cart } from './shared/data/cart.data.js';
393
394
  export { countries, dutch, english, france, french, german, germany, languages, netherlands, switzerland, unitedKingdom } from './shared/data/countries-languages.data.js';
394
395
  export { navigationData } from './shared/data/navigation.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' | '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 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' | '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';
@@ -3,6 +3,7 @@ export interface QuickAccessMenuProps {
3
3
  customerCompany?: string;
4
4
  customerName?: string;
5
5
  isAuthenticated?: boolean;
6
+ isGuest?: boolean;
6
7
  onSignOut?: () => void;
7
8
  }
8
- export declare function QuickAccessMenu({ className, customerCompany, customerName, isAuthenticated, onSignOut, }: QuickAccessMenuProps): import("react/jsx-runtime").JSX.Element;
9
+ export declare function QuickAccessMenu({ className, customerCompany, customerName, isAuthenticated, isGuest, onSignOut, }: QuickAccessMenuProps): import("react/jsx-runtime").JSX.Element;
@@ -10,12 +10,12 @@ import { useGreeting } from '../../shared/utils/greeting.js';
10
10
  import { Truncated } from '../../text/truncated/truncated.js';
11
11
  import styles from './quick-access-menu.module.css.js';
12
12
 
13
- function QuickAccessMenu({ className, customerCompany, customerName, isAuthenticated, onSignOut, }) {
13
+ function QuickAccessMenu({ className, customerCompany, customerName, isAuthenticated, isGuest, onSignOut, }) {
14
14
  const t = useFormattedMessage();
15
15
  const paths = usePaths();
16
16
  const greeting = useGreeting();
17
17
  const links = useMySonicNavigationItems().filter(item => isMySonicNavigationLink(item));
18
- return (jsxs("section", { "aria-label": t('My Sonic menu'), className: clsx(styles['quick-access-menu'], className), "data-test-selector": "quickAccessMenu", children: [jsxs("header", { className: styles['header'], children: [jsx("h2", { className: styles['title'], "data-test-selector": "quickAccessMenuTitle", children: `${greeting}${customerName || customerCompany ? ',' : ''}` }), customerName && (jsx(Truncated, { className: styles['name'], "data-test-selector": "quickAccessMenuCustomerName", lines: 2, children: customerName })), customerCompany && (jsx(Truncated, { className: styles['company'], "data-test-selector": "quickAccessMenuCustomerCompany", lines: 2, children: customerCompany }))] }), isAuthenticated && (jsx("nav", { className: styles['navigation'], children: jsx("ul", { children: links.map(link => (jsx("li", { className: styles['item'], children: jsx(Link, { className: styles['link'], "data-test-selector": link['data-test-selector'], href: link.path, children: t(link.label) }) }, link.path))) }) })), jsxs("div", { className: styles['actions'], children: [isAuthenticated && (jsx(Button, { withArrow: true, "data-test-selector": "logoutButton", onClick: onSignOut, size: "sm", children: t('Log out') })), !isAuthenticated && (jsxs(Fragment, { children: [jsx(Button, { withArrow: true, "data-test-selector": "signInButton", href: paths.SIGN_IN, size: "sm", children: t('sign in') }), jsx(Button, { withArrow: true, color: "secondary", "data-test-selector": "createAccountButton", href: paths.ACCOUNT_CREATE, size: "sm", variant: "outline", children: t('create account') })] }))] })] }));
18
+ return (jsxs("section", { "aria-label": t('My Sonic menu'), className: clsx(styles['quick-access-menu'], className), "data-test-selector": "quickAccessMenu", children: [jsxs("header", { className: styles['header'], children: [jsx("h2", { className: styles['title'], "data-test-selector": "quickAccessMenuTitle", children: `${greeting}${customerName || customerCompany ? ',' : ''}` }), !isGuest && customerName && (jsx(Truncated, { className: styles['name'], "data-test-selector": "quickAccessMenuCustomerName", lines: 2, children: customerName })), !isGuest && customerCompany && (jsx(Truncated, { className: styles['company'], "data-test-selector": "quickAccessMenuCustomerCompany", lines: 2, children: customerCompany })), isGuest && t('Guest')] }), !isGuest && isAuthenticated && (jsx("nav", { className: styles['navigation'], children: jsx("ul", { children: links.map(link => (jsx("li", { className: styles['item'], children: jsx(Link, { className: styles['link'], "data-test-selector": link['data-test-selector'], href: link.path, children: t(link.label) }) }, link.path))) }) })), jsxs("div", { className: styles['actions'], children: [isAuthenticated && (jsx(Button, { withArrow: true, "data-test-selector": "logoutButton", onClick: onSignOut, size: "sm", children: t('Log out') })), !isAuthenticated && (jsxs(Fragment, { children: [jsx(Button, { withArrow: true, "data-test-selector": "signInButton", href: paths.SIGN_IN, size: "sm", children: t('sign in') }), jsx(Button, { withArrow: true, color: "secondary", "data-test-selector": "createAccountButton", href: paths.ACCOUNT_CREATE, size: "sm", variant: "outline", children: t('create account') })] }))] })] }));
19
19
  }
20
20
 
21
21
  export { QuickAccessMenu };
@@ -36,7 +36,7 @@ function SignInPage({ returnUrl } = {}) {
36
36
  setIsSuccess(true);
37
37
  navigate(returnUrl || paths.HOME, { reload: true });
38
38
  };
39
- const allowGuestSignIn = returnUrl === paths.CHECKOUT_SHIPPING;
39
+ const allowGuestSignIn = returnUrl?.toLowerCase() === paths.CHECKOUT_SHIPPING.toLowerCase();
40
40
  const createAccountPath = `${paths.ACCOUNT_CREATE}${returnUrl ? `?returnUrl=${encodeURIComponent(returnUrl)}` : ''}`;
41
41
  const onSubmit = ({ data }) => {
42
42
  resetSignIn();
@@ -1,5 +1,5 @@
1
1
  import { ReactNode } from 'react';
2
2
  export declare function MySonicLayoutPage({ children, title, }: {
3
3
  children?: ReactNode;
4
- title: string;
4
+ title?: string;
5
5
  }): import("react/jsx-runtime").JSX.Element;
@@ -4,7 +4,7 @@ import { MySonicLayoutMain } from './my-sonic-layout-main.js';
4
4
  import { MySonicLayoutTitle } from './my-sonic-layout-title.js';
5
5
 
6
6
  function MySonicLayoutPage({ children, title, }) {
7
- return (jsxs(Fragment, { children: [jsx(MySonicLayoutTitle, { children: title }), jsx(MySonicLayoutMain, { children: children })] }));
7
+ return (jsxs(Fragment, { children: [title && jsx(MySonicLayoutTitle, { children: title }), jsx(MySonicLayoutMain, { children: children })] }));
8
8
  }
9
9
 
10
10
  export { MySonicLayoutPage };
@@ -1,14 +1,39 @@
1
1
  "use client";
2
2
  import { jsx } from 'react/jsx-runtime';
3
+ import { useAlgoliaInsights } from '../../../../algolia/use-algolia-insights.js';
3
4
  import { Breadcrumb } from '../../../../breadcrumbs/breadcrumb.js';
5
+ import { ConnectedProductCard } from '../../../../cards/product-card/connected-product-card.js';
4
6
  import { useFormattedMessage } from '../../../../intl/use-formatted-message.js';
7
+ import { ProductOverviewGrid } from '../../../../lists/product-overview-grid/product-overview-grid.js';
8
+ import { useFetchFavorites } from '../../../../shared/api/bff/hooks/use-fetch-favorites.js';
5
9
  import { usePaths } from '../../../../shared/routing/use-paths.js';
10
+ import { ErrorPage } from '../../../error-page/error-page.js';
6
11
  import { MySonicLayoutBreadcrumb } from '../../layouts/my-sonic-layout/my-sonic-layout-breadcrumb.js';
7
12
  import { MySonicLayoutPage } from '../../layouts/my-sonic-layout/my-sonic-layout-page.js';
8
13
 
9
14
  function FavoritesPage() {
10
15
  const t = useFormattedMessage();
11
- return (jsx(MySonicLayoutPage, { title: t('Favorites'), children: "Not implemented yet" }));
16
+ const { data: favorites, error, isFetching, isLoading } = useFetchFavorites();
17
+ const { sendAddToCartFromFavoritesPageEvent, sendProductClickFromFavoritesPageEvent, } = useAlgoliaInsights();
18
+ if (error)
19
+ return (jsx(MySonicLayoutPage, { children: jsx(ErrorPage, { error: error }) }));
20
+ return (jsx(MySonicLayoutPage, { title: t('Favorites'), children: (favorites && favorites.length > 0) || isFetching ? (jsx(ProductOverviewGrid, { isLoading: isLoading, children: favorites?.map(favorite => (jsx(ConnectedProductCard, { href: favorite.storefrontSlug, id: favorite.storefrontId, image: {
21
+ fit: 'contain',
22
+ image: favorite.image,
23
+ title: favorite.name,
24
+ }, onAddToCart: ({ cartLine }) => sendAddToCartFromFavoritesPageEvent({
25
+ cartLine,
26
+ }), onClick: () => {
27
+ sendProductClickFromFavoritesPageEvent({
28
+ objectId: favorite.objectId,
29
+ position: favorite.position,
30
+ });
31
+ }, price: {
32
+ currencyCode: favorite.currencyCode,
33
+ isVatIncluded: favorite.isVatIncluded,
34
+ originalPrice: favorite.originalPrice,
35
+ price: favorite.price,
36
+ }, sku: favorite.id, tags: favorite.labels, title: favorite.name }, favorite.storefrontId))) })) : (jsx("p", { children: t('You have no favorite products yet.') })) }));
12
37
  }
13
38
  function FavoritesPageBreadcrumb() {
14
39
  const t = useFormattedMessage();
@@ -0,0 +1,2 @@
1
+ import { ProductHit } from '../../../model/hit';
2
+ export declare function useFetchFavorites(): import("@tanstack/react-query").UseQueryResult<ProductHit[], Error>;
@@ -0,0 +1,29 @@
1
+ import { useQuery } from '@tanstack/react-query';
2
+ import { useAlgoliaSearch } from '../../../../algolia/use-algolia-search.js';
3
+ import { transformAlgoliaProductHitToProductHit } from '../../../model/hit.js';
4
+ import { fetchAllWishListsItems } from '../../storefront/services/wishlist-service.js';
5
+
6
+ function useFetchFavorites() {
7
+ const { indexes, searchClient } = useAlgoliaSearch();
8
+ return useQuery({
9
+ placeholderData: prev => prev,
10
+ queryFn: async () => {
11
+ const wishListLines = await fetchAllWishListsItems();
12
+ const filters = wishListLines
13
+ .map(({ wishListItem }) => wishListItem.erpNumber)
14
+ .map(objectID => `objectID:${objectID}`)
15
+ .join(' OR ');
16
+ if (!filters)
17
+ return [];
18
+ const searchIndex = searchClient.initIndex(indexes.default);
19
+ const { hits } = await searchIndex.search('', {
20
+ filters,
21
+ hitsPerPage: 999,
22
+ });
23
+ return hits.map(transformAlgoliaProductHitToProductHit);
24
+ },
25
+ queryKey: ['wishlists', 'wishlistlines', 'favorites'],
26
+ });
27
+ }
28
+
29
+ export { useFetchFavorites };
@@ -12,22 +12,15 @@ function useAddWishListItemToCurrentWishList() {
12
12
  wishList = await createWishList();
13
13
  queryClient.setQueryData(['wishlists'], [...wishLists, wishList]);
14
14
  }
15
- const wishListItem = await addWishListItemToWishList({
15
+ await addWishListItemToWishList({
16
16
  productId,
17
17
  wishListId: wishList.id,
18
18
  });
19
- const wishListLines = queryClient.getQueryData(['wishlistlines']) || [];
20
- queryClient.setQueryData(['wishlistlines'], [
21
- ...wishListLines,
22
- {
23
- wishList,
24
- wishListItem,
25
- },
26
- ]);
27
19
  },
28
- onError() {
29
- queryClient.invalidateQueries({ queryKey: ['wishlists'] });
30
- queryClient.invalidateQueries({ queryKey: ['wishlistlines'] });
20
+ onSettled() {
21
+ queryClient.invalidateQueries({
22
+ queryKey: ['wishlists', 'wishlistlines'],
23
+ });
31
24
  },
32
25
  });
33
26
  }
@@ -14,18 +14,15 @@ function useAddWishListItemToWishList() {
14
14
  const wishList = wishLists.find(wishList => wishList.id === wishListId);
15
15
  if (!wishList)
16
16
  throw new Error(`Wish list with id ${wishListId} not found`);
17
- const wishListItem = await addWishListItemToWishList({
17
+ await addWishListItemToWishList({
18
18
  productId,
19
19
  wishListId,
20
20
  });
21
- const wishListLines = queryClient.getQueryData(['wishlistlines']) || [];
22
- queryClient.setQueryData(['wishlistlines'], [
23
- ...wishListLines,
24
- {
25
- wishList,
26
- wishListItem,
27
- },
28
- ]);
21
+ },
22
+ onSettled() {
23
+ queryClient.invalidateQueries({
24
+ queryKey: ['wishlists', 'wishlistlines'],
25
+ });
29
26
  },
30
27
  });
31
28
  }
@@ -7,14 +7,11 @@ function useDeleteWishListItemFromWishList() {
7
7
  return useMutation({
8
8
  mutationFn: async ({ wishListId, wishListItemId }) => {
9
9
  await deleteWishListItemFromWishList({ wishListId, wishListItemId });
10
- const wishListLines = queryClient.getQueryData(['wishlistlines']) || [];
11
- if (wishListLines.some(item => item.wishListItem.id === wishListItemId)) {
12
- queryClient.setQueryData(['wishlistlines'], wishListLines.filter(line => line.wishListItem.id !== wishListItemId));
13
- }
14
10
  },
15
- onError() {
16
- queryClient.invalidateQueries({ queryKey: ['wishlists'] });
17
- queryClient.invalidateQueries({ queryKey: ['wishlistlines'] });
11
+ onSettled() {
12
+ queryClient.invalidateQueries({
13
+ queryKey: ['wishlists', 'wishlistlines'],
14
+ });
18
15
  },
19
16
  });
20
17
  }
@@ -1,34 +1,24 @@
1
1
  "use client";
2
2
  import { useQueryClient, useQuery } from '@tanstack/react-query';
3
3
  import { TIME } from '../../../../utils/time.js';
4
- import { getWishLists, getWishListItemsByWishListId } from '../../services/wishlist-service.js';
4
+ import { fetchAllWishListsItems } from '../../services/wishlist-service.js';
5
5
 
6
6
  function useFetchAllWishListsItems({ enabled = true } = { enabled: true }) {
7
7
  const queryClient = useQueryClient();
8
8
  return useQuery({
9
9
  enabled,
10
10
  gcTime: 15 * TIME.MINUTE,
11
+ placeholderData: prev => prev,
11
12
  queryFn: async () => {
12
- let wishLists =
13
- // Reuse existing data if available
14
- queryClient.getQueryData(['wishlists']);
15
- if (wishLists === undefined) {
16
- wishLists = (await getWishLists()).wishListCollection || [];
17
- // Update the cache with the new or existing data
18
- queryClient.setQueryData(['wishlists'], wishLists);
19
- }
20
- if (wishLists.length === 0)
21
- return [];
22
- const wishListLines = await Promise.all(wishLists.map(async (wishList) => {
23
- return ((await getWishListItemsByWishListId({ wishListId: wishList.id }))
24
- .wishListLines || []).map(wishListItem => ({
25
- wishList,
26
- wishListItem,
27
- }));
28
- }));
29
- return wishListLines.flat();
13
+ let wishLists = queryClient.getQueryData(['wishlists']);
14
+ const results = await fetchAllWishListsItems(wishLists && { wishListCollection: wishLists });
15
+ if (wishLists && wishLists.length > 0)
16
+ return results;
17
+ wishLists = Object.values(results.reduce((map, { wishList }) => ({ ...map, [wishList.id]: wishList }), {}));
18
+ queryClient.setQueryData(['wishlists'], wishLists);
19
+ return results;
30
20
  },
31
- queryKey: ['wishlistlines'],
21
+ queryKey: ['wishlists', 'wishlistlines'],
32
22
  staleTime: 15 * TIME.MINUTE,
33
23
  });
34
24
  }
@@ -1,4 +1,4 @@
1
- import { WishListCollectionModel, WishListLineCollectionModel, WishListLineModel, WishListModel } from '../model/storefront.model';
1
+ import { WishListCollectionModel, WishListLineCollectionModel, WishListLineModel, WishListLines, WishListModel } from '../model/storefront.model';
2
2
  export declare function getWishList({ wishListId, }: {
3
3
  wishListId: string;
4
4
  }): Promise<WishListModel>;
@@ -23,3 +23,6 @@ export declare function deleteWishListItemFromWishList({ wishListId, wishListIte
23
23
  export declare function getWishListItemsByWishListId({ wishListId, }: {
24
24
  wishListId: string;
25
25
  }): Promise<WishListLineCollectionModel>;
26
+ export declare function fetchAllWishListsItems(currentWishLists?: {
27
+ wishListCollection?: WishListModel[];
28
+ }): Promise<WishListLines>;
@@ -68,5 +68,20 @@ async function getWishListItemsByWishListId({ wishListId, }) {
68
68
  });
69
69
  return body;
70
70
  }
71
+ async function fetchAllWishListsItems(currentWishLists) {
72
+ const { wishListCollection: wishLists } = currentWishLists || (await getWishLists());
73
+ if (!wishLists || wishLists.length === 0)
74
+ return [];
75
+ const wishListLines = await Promise.all(wishLists.map(async (wishList) => {
76
+ const { wishListLines } = await getWishListItemsByWishListId({
77
+ wishListId: wishList.id,
78
+ });
79
+ return (wishListLines?.map((wishListItem) => ({
80
+ wishList,
81
+ wishListItem,
82
+ })) || []);
83
+ }));
84
+ return wishListLines.flat();
85
+ }
71
86
 
72
- export { WishListNameAlreadyExistsError, addWishListItemToWishList, createWishList, deleteWishList, deleteWishListItemFromWishList, getWishList, getWishListItemsByWishListId, getWishLists };
87
+ export { WishListNameAlreadyExistsError, addWishListItemToWishList, createWishList, deleteWishList, deleteWishListItemFromWishList, fetchAllWishListsItems, getWishList, getWishListItemsByWishListId, getWishLists };
package/dist/styles.css CHANGED
@@ -1105,11 +1105,11 @@ html {
1105
1105
  outline-offset: var(--focus-outline-offset);
1106
1106
  }
1107
1107
 
1108
- .button-module-V4meK .button-module-XaNWz {
1109
- display: block;
1110
- width: 1.5em;
1111
- height: 1.5em;
1112
- }
1108
+ .button-module-V4meK .button-module-XaNWz svg {
1109
+ display: block;
1110
+ width: 24px;
1111
+ height: 24px;
1112
+ }
1113
1113
 
1114
1114
  .button-module-V4meK .button-module-ydQAo {
1115
1115
  block-size: 0.7em;
@@ -7696,7 +7696,7 @@ button.swiper-pagination-bullet {
7696
7696
  left: 0;
7697
7697
  width: 100%;
7698
7698
  box-sizing: border-box;
7699
- padding: 16px var(--padding-inline);
7699
+ padding: 16px calc(2 * var(--padding-inline));
7700
7700
  margin: auto;
7701
7701
  background-color: var(--color-white);
7702
7702
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sonic-equipment/ui",
3
- "version": "219.0.0",
3
+ "version": "220.0.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "engines": {