@sonic-equipment/ui 126.0.0 → 128.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 (175) hide show
  1. package/dist/address/address.d.ts +6 -1
  2. package/dist/address/address.js +2 -2
  3. package/dist/algolia/filter-section.js +1 -1
  4. package/dist/cards/orderline-card/connected-orderline-card.js +1 -1
  5. package/dist/cards/orderline-card/orderline-card.d.ts +3 -3
  6. package/dist/cards/orderline-card/orderline-card.js +3 -2
  7. package/dist/cards/orderline-card/orderline-card.module.css.js +1 -1
  8. package/dist/cards/product-card/product-card.js +1 -1
  9. package/dist/cart-totals/cart-totals.d.ts +1 -1
  10. package/dist/cart-totals/cart-totals.js +1 -1
  11. package/dist/checkout/adyen-payment.d.ts +3 -5
  12. package/dist/checkout/adyen-payment.js +22 -10
  13. package/dist/checkout/adyen-payment.module.css.js +3 -0
  14. package/dist/checkout/payment-details.d.ts +5 -2
  15. package/dist/checkout/payment-details.js +54 -4
  16. package/dist/checkout/payment.d.ts +8 -3
  17. package/dist/checkout/payment.js +168 -34
  18. package/dist/checkout/payment.module.css.js +3 -0
  19. package/dist/checkout/use-get-adyen-redirect-result.d.ts +1 -0
  20. package/dist/checkout/use-get-adyen-redirect-result.js +13 -0
  21. package/dist/checkout/use-has-returned-from-adyen.d.ts +1 -0
  22. package/dist/checkout/use-has-returned-from-adyen.js +8 -0
  23. package/dist/collapsables/accordion/accordion.d.ts +10 -2
  24. package/dist/collapsables/accordion/accordion.js +20 -1
  25. package/dist/collapsables/accordion/accordion.module.css.js +1 -1
  26. package/dist/exports.d.ts +38 -24
  27. package/dist/forms/checkbox/checkbox.d.ts +2 -1
  28. package/dist/forms/checkbox/checkbox.js +2 -2
  29. package/dist/forms/input/input.js +1 -3
  30. package/dist/forms/label/label.d.ts +1 -1
  31. package/dist/forms/select/select.d.ts +4 -2
  32. package/dist/forms/select/select.js +6 -3
  33. package/dist/forms/select/select.module.css.js +1 -1
  34. package/dist/global-search/search-input/connected-search-input.js +1 -1
  35. package/dist/index.js +41 -27
  36. package/dist/intl/missing-translation-provider.js +9 -2
  37. package/dist/intl/translation-id.d.ts +1 -1
  38. package/dist/loading/loading-overlay.js +1 -1
  39. package/dist/pages/{cart-page → checkout/cart-page}/cart-page.js +20 -20
  40. package/dist/pages/{layouts → checkout/layouts}/checkout-page-layout/checkout-page-layout.js +3 -3
  41. package/dist/pages/checkout/layouts/checkout-page-layout/checkout-page-layout.module.css.js +3 -0
  42. package/dist/pages/checkout/layouts/checkout-page-layout/components/checkout-page-section-content.d.ts +7 -0
  43. package/dist/pages/checkout/layouts/checkout-page-layout/components/checkout-page-section-content.js +9 -0
  44. package/dist/pages/checkout/layouts/checkout-page-layout/components/checkout-page-section-header.d.ts +8 -0
  45. package/dist/pages/checkout/layouts/checkout-page-layout/components/checkout-page-section-header.js +9 -0
  46. package/dist/pages/checkout/layouts/checkout-page-layout/components/checkout-page-section-link.d.ts +4 -0
  47. package/dist/pages/checkout/layouts/checkout-page-layout/components/checkout-page-section-link.js +8 -0
  48. package/dist/pages/checkout/layouts/checkout-page-layout/components/checkout-page-section.d.ts +7 -0
  49. package/dist/pages/checkout/layouts/checkout-page-layout/components/checkout-page-section.js +10 -0
  50. package/dist/pages/checkout/layouts/checkout-page-layout/components/checkout-page-section.module.css.js +3 -0
  51. package/dist/pages/checkout/payment-page/payment-page.d.ts +1 -0
  52. package/dist/pages/checkout/payment-page/payment-page.js +89 -0
  53. package/dist/pages/{shipping-page → checkout/shipping-page}/components/edit-address.d.ts +1 -1
  54. package/dist/pages/{shipping-page → checkout/shipping-page}/components/edit-address.js +13 -13
  55. package/dist/pages/checkout/shipping-page/components/edit-address.module.css.js +3 -0
  56. package/dist/pages/{shipping-page → checkout/shipping-page}/components/readonly-address.d.ts +1 -1
  57. package/dist/pages/checkout/shipping-page/components/readonly-address.js +27 -0
  58. package/dist/pages/checkout/shipping-page/components/readonly-address.module.css.js +3 -0
  59. package/dist/pages/checkout/shipping-page/shipping-page.js +114 -0
  60. package/dist/pages/{page → components/page}/page.d.ts +1 -1
  61. package/dist/pages/{page → components/page}/page.js +3 -5
  62. package/dist/pages/components/page/page.module.css.js +3 -0
  63. package/dist/pages/components/page-container/page-container.module.css.js +3 -0
  64. package/dist/pages/components/page-meta-data/page-meta-data.d.ts +16 -0
  65. package/dist/pages/components/page-meta-data/page-meta-data.js +95 -0
  66. package/dist/pages/error-page/error-page.js +1 -1
  67. package/dist/pages/product/layouts/product-details-page-layout/product-details-page-layout.module.css.js +3 -0
  68. package/dist/pages/{product-details-page → product/product-details-page}/components/product-details-images/product-detail-images.d.ts +1 -1
  69. package/dist/pages/{product-details-page → product/product-details-page}/components/product-details-images/product-detail-images.js +6 -6
  70. package/dist/pages/{product-details-page → product/product-details-page}/components/product-details-images/product-detail-images.module.css.js +1 -1
  71. package/dist/pages/{product-details-page → product/product-details-page}/components/product-details-panel/product-details-panel.js +11 -11
  72. package/dist/pages/product/product-details-page/components/product-details-panel/product-details-panel.module.css.js +3 -0
  73. package/dist/pages/{product-details-page → product/product-details-page}/components/product-details-recently-viewed/product-details-recently-viewed.d.ts +1 -1
  74. package/dist/pages/{product-details-page → product/product-details-page}/components/product-details-recently-viewed/product-details-recently-viewed.js +4 -4
  75. package/dist/pages/product/product-details-page/product-details-page.js +30 -0
  76. package/dist/pages/{product-details-page → product/product-details-page}/product-details.d.ts +1 -1
  77. package/dist/pages/{product-details-page → product/product-details-page}/product-details.js +7 -7
  78. package/dist/pages/{product-listing-page → product/product-listing-page}/no-results/no-results.js +4 -4
  79. package/dist/pages/product/product-listing-page/no-results/no-results.module.css.js +3 -0
  80. package/dist/pages/{product-listing-page → product/product-listing-page}/product-listing-page-category-carousel/product-listing-page-category-carousel.js +3 -3
  81. package/dist/pages/{product-listing-page → product/product-listing-page}/product-listing-page-data-types.d.ts +3 -1
  82. package/dist/pages/product/product-listing-page/product-listing-page.js +37 -0
  83. package/dist/pages/product/product-listing-page/product-listing-page.module.css.js +3 -0
  84. package/dist/pages/{product-listing-page → product/product-listing-page}/product-listing-product-overview/product-listing-product-overview.js +6 -6
  85. package/dist/pages/{product-listing-page → product/product-listing-page}/product-listing.js +16 -16
  86. package/dist/pages/{search-result-page → product/search-result-page}/search-result-product-overview/search-result-product-overview.js +6 -6
  87. package/dist/pages/{search-result-page → product/search-result-page}/search-results-page-category-carousel/search-results-page-category-carousel.js +3 -3
  88. package/dist/pages/{search-result-page → product/search-result-page}/search-results-page.js +22 -17
  89. package/dist/pages/product/search-result-page/search-results-page.module.css.js +3 -0
  90. package/dist/shared/api/bff/model/bff.model.d.ts +14 -0
  91. package/dist/shared/api/bff/services/bff-service.d.ts +1 -1
  92. package/dist/shared/api/bff/services/bff-service.js +1 -0
  93. package/dist/shared/api/shared/hooks/use-awaitable-mutation.d.ts +20 -4
  94. package/dist/shared/api/shared/hooks/use-awaitable-mutation.js +29 -21
  95. package/dist/shared/api/storefront/hooks/authentication/use-patch-session.d.ts +7 -4
  96. package/dist/shared/api/storefront/hooks/authentication/use-patch-session.js +4 -3
  97. package/dist/shared/api/storefront/hooks/cart/use-fetch-current-cart-with-atp.d.ts +2 -1
  98. package/dist/shared/api/storefront/hooks/cart/use-fetch-current-cart-with-atp.js +4 -2
  99. package/dist/shared/api/storefront/hooks/cart/use-fetch-current-cart.d.ts +3 -1
  100. package/dist/shared/api/storefront/hooks/cart/use-fetch-current-cart.js +3 -2
  101. package/dist/shared/api/storefront/hooks/cart/use-patch-cart.d.ts +9 -8
  102. package/dist/shared/api/storefront/hooks/cart/use-patch-cart.js +6 -4
  103. package/dist/shared/api/storefront/hooks/cart/use-place-order.d.ts +10 -4
  104. package/dist/shared/api/storefront/hooks/cart/use-place-order.js +11 -6
  105. package/dist/shared/api/storefront/hooks/customer/use-fetch-fulfillment-methods-by-customer-id.d.ts +4 -0
  106. package/dist/shared/api/storefront/hooks/customer/use-fetch-fulfillment-methods-by-customer-id.js +12 -0
  107. package/dist/shared/api/storefront/hooks/customer/use-fetch-fulfillment-methods-for-current-cart.d.ts +3 -0
  108. package/dist/shared/api/storefront/hooks/customer/use-fetch-fulfillment-methods-for-current-cart.js +12 -0
  109. package/dist/shared/api/storefront/hooks/customer/use-patch-bill-to-address.d.ts +5 -2
  110. package/dist/shared/api/storefront/hooks/customer/use-patch-bill-to-address.js +1 -1
  111. package/dist/shared/api/storefront/hooks/payment/use-invalidate-adyen.d.ts +1 -1
  112. package/dist/shared/api/storefront/hooks/payment/use-invalidate-adyen.js +1 -1
  113. package/dist/shared/api/storefront/model/storefront.model.d.ts +3 -1
  114. package/dist/shared/api/storefront/services/cart-service.d.ts +7 -3
  115. package/dist/shared/api/storefront/services/cart-service.js +11 -8
  116. package/dist/shared/api/storefront/services/customer-service.d.ts +3 -0
  117. package/dist/shared/api/storefront/services/customer-service.js +9 -1
  118. package/dist/shared/api/storefront/services/finance-service.d.ts +13 -0
  119. package/dist/shared/api/storefront/services/finance-service.js +17 -0
  120. package/dist/shared/api/storefront/services/translation-service.js +1 -1
  121. package/dist/shared/hooks/use-css-link.d.ts +3 -0
  122. package/dist/shared/hooks/use-css-link.js +20 -0
  123. package/dist/shared/hooks/use-script.d.ts +15 -0
  124. package/dist/shared/hooks/use-script.js +33 -0
  125. package/dist/shared/providers/react-query-container.js +4 -2
  126. package/dist/shared/routing/route-provider.d.ts +12 -4
  127. package/dist/shared/routing/route-provider.js +14 -10
  128. package/dist/shared/routing/with-routing.js +6 -6
  129. package/dist/shared/utils/string.d.ts +1 -0
  130. package/dist/shared/utils/string.js +6 -1
  131. package/dist/shared/utils/string.test.d.ts +1 -0
  132. package/dist/shared/utils/types.d.ts +3 -0
  133. package/dist/shared/utils/types.js +8 -0
  134. package/dist/styles.css +690 -331
  135. package/dist/tooltip/tooltip.d.ts +2 -2
  136. package/dist/typography/heading/heading.d.ts +4 -2
  137. package/dist/typography/heading/heading.js +3 -2
  138. package/dist/typography/heading/heading.module.css.js +1 -1
  139. package/package.json +1 -1
  140. package/dist/pages/layouts/checkout-page-layout/checkout-page-layout.module.css.js +0 -3
  141. package/dist/pages/layouts/product-details-page-layout/product-details-page-layout.module.css.js +0 -3
  142. package/dist/pages/page/page.module.css.js +0 -3
  143. package/dist/pages/page-container/page-container.module.css.js +0 -3
  144. package/dist/pages/product-details-page/components/product-details-panel/product-details-panel.module.css.js +0 -3
  145. package/dist/pages/product-details-page/product-details-page.js +0 -22
  146. package/dist/pages/product-listing-page/no-results/no-results.module.css.js +0 -3
  147. package/dist/pages/product-listing-page/product-listing-page.js +0 -29
  148. package/dist/pages/product-listing-page/product-listing-page.module.css.js +0 -3
  149. package/dist/pages/search-result-page/search-results-page.module.css.js +0 -3
  150. package/dist/pages/shipping-page/components/edit-address.module.css.js +0 -3
  151. package/dist/pages/shipping-page/components/readonly-address.js +0 -25
  152. package/dist/pages/shipping-page/components/readonly-address.module.css.js +0 -3
  153. package/dist/pages/shipping-page/shipping-page.js +0 -75
  154. package/dist/pages/shipping-page/shipping-page.module.css.js +0 -3
  155. /package/dist/pages/{cart-page → checkout/cart-page}/cart-page.d.ts +0 -0
  156. /package/dist/pages/{layouts → checkout/layouts}/checkout-page-layout/checkout-page-layout.d.ts +0 -0
  157. /package/dist/pages/{shipping-page → checkout/shipping-page}/shipping-page.d.ts +0 -0
  158. /package/dist/pages/{page-container → components/page-container}/page-container.d.ts +0 -0
  159. /package/dist/pages/{page-container → components/page-container}/page-container.js +0 -0
  160. /package/dist/pages/{layouts → product/layouts}/product-details-page-layout/product-details-page-layout.d.ts +0 -0
  161. /package/dist/pages/{layouts → product/layouts}/product-details-page-layout/product-details-page-layout.js +0 -0
  162. /package/dist/pages/{product-details-page → product/product-details-page}/components/product-details-panel/product-details-panel.d.ts +0 -0
  163. /package/dist/pages/{product-details-page → product/product-details-page}/product-details-page.d.ts +0 -0
  164. /package/dist/pages/{product-listing-page → product/product-listing-page}/no-results/no-results.d.ts +0 -0
  165. /package/dist/pages/{product-listing-page → product/product-listing-page}/product-listing-page-category-carousel/product-listing-page-category-carousel.d.ts +0 -0
  166. /package/dist/pages/{product-listing-page → product/product-listing-page}/product-listing-page-provider/product-listing-page-context.d.ts +0 -0
  167. /package/dist/pages/{product-listing-page → product/product-listing-page}/product-listing-page-provider/product-listing-page-context.js +0 -0
  168. /package/dist/pages/{product-listing-page → product/product-listing-page}/product-listing-page-provider/product-listing-page-provider.d.ts +0 -0
  169. /package/dist/pages/{product-listing-page → product/product-listing-page}/product-listing-page-provider/product-listing-page-provider.js +0 -0
  170. /package/dist/pages/{product-listing-page → product/product-listing-page}/product-listing-page.d.ts +0 -0
  171. /package/dist/pages/{product-listing-page → product/product-listing-page}/product-listing-product-overview/product-listing-product-overview.d.ts +0 -0
  172. /package/dist/pages/{product-listing-page → product/product-listing-page}/product-listing.d.ts +0 -0
  173. /package/dist/pages/{search-result-page → product/search-result-page}/search-result-product-overview/search-result-product-overview.d.ts +0 -0
  174. /package/dist/pages/{search-result-page → product/search-result-page}/search-results-page-category-carousel/search-results-page-category-carousel.d.ts +0 -0
  175. /package/dist/pages/{search-result-page → product/search-result-page}/search-results-page.d.ts +0 -0
@@ -1,9 +1,9 @@
1
1
  "use client";
2
2
  import { jsx } from 'react/jsx-runtime';
3
3
  import { useRefinementList } from 'react-instantsearch';
4
- import { CategoryCard } from '../../../cards/category-card/category-card.js';
5
- import { CategoryCarousel } from '../../../carousel/category-carousel/category-carousel.js';
6
- import { transformAlgoliaCategoryData } from '../../../shared/model/category.js';
4
+ import { CategoryCard } from '../../../../cards/category-card/category-card.js';
5
+ import { CategoryCarousel } from '../../../../carousel/category-carousel/category-carousel.js';
6
+ import { transformAlgoliaCategoryData } from '../../../../shared/model/category.js';
7
7
 
8
8
  function SearchResultsPageCategoryCarousel() {
9
9
  const { items } = useRefinementList({
@@ -1,20 +1,21 @@
1
1
  "use client";
2
2
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
3
3
  import qs from 'query-string';
4
- import { AlgoliaFilterPanel } from '../../algolia/algolia-filter-panel.js';
5
- import { AlgoliaPagination } from '../../algolia/algolia-pagination.js';
6
- import { AlgoliaProvider } from '../../algolia/algolia-provider.js';
7
- import { AlgoliaResultsCount } from '../../algolia/algolia-results-count.js';
8
- import { AlgoliaSortBy } from '../../algolia/algolia-sort-by.js';
9
- import { useAlgoliaHits } from '../../algolia/use-algolia-hits.js';
10
- import { FormattedMessage } from '../../intl/formatted-message.js';
11
- import { useFormattedMessage } from '../../intl/use-formatted-message.js';
12
- import { useLanguageCode } from '../../intl/use-language-code.js';
13
- import { scrollToTop } from '../../shared/hooks/use-scroll-to.js';
14
- import { Sidebar } from '../../sidebar/sidebar.js';
15
- import { ToggleSidebarButton } from '../../sidebar/toggle-sidebar-button.js';
16
- import { LoadingPage } from '../loading-page/loading-page.js';
17
- import { Page } from '../page/page.js';
4
+ import { AlgoliaFilterPanel } from '../../../algolia/algolia-filter-panel.js';
5
+ import { AlgoliaPagination } from '../../../algolia/algolia-pagination.js';
6
+ import { AlgoliaProvider } from '../../../algolia/algolia-provider.js';
7
+ import { AlgoliaResultsCount } from '../../../algolia/algolia-results-count.js';
8
+ import { AlgoliaSortBy } from '../../../algolia/algolia-sort-by.js';
9
+ import { useAlgoliaHits } from '../../../algolia/use-algolia-hits.js';
10
+ import { FormattedMessage } from '../../../intl/formatted-message.js';
11
+ import { useFormattedMessage } from '../../../intl/use-formatted-message.js';
12
+ import { useLanguageCode } from '../../../intl/use-language-code.js';
13
+ import { scrollToTop } from '../../../shared/hooks/use-scroll-to.js';
14
+ import { Sidebar } from '../../../sidebar/sidebar.js';
15
+ import { ToggleSidebarButton } from '../../../sidebar/toggle-sidebar-button.js';
16
+ import { Page } from '../../components/page/page.js';
17
+ import { PageMetaData } from '../../components/page-meta-data/page-meta-data.js';
18
+ import { LoadingPage } from '../../loading-page/loading-page.js';
18
19
  import { NoResults } from '../product-listing-page/no-results/no-results.js';
19
20
  import { SearchResultProductOverview } from './search-result-product-overview/search-result-product-overview.js';
20
21
  import { SearchResultsPageCategoryCarousel } from './search-results-page-category-carousel/search-results-page-category-carousel.js';
@@ -27,9 +28,13 @@ function SearchResultsPage({ location, searchClient, }) {
27
28
  const keyword = Array.isArray(keywords) ? keywords.join(' ') : keywords;
28
29
  if (!keyword)
29
30
  return jsx("h1", { children: "No search results...." });
30
- return (jsx(AlgoliaProvider, { languageCode: languageCode, query: keyword, searchClient: searchClient, children: jsx(Page, { breadCrumb: [], className: styles['search-results'], title: t("'{0}' in all products", {
31
- replacementValues: { 0: keyword },
32
- }), children: jsx(SearchResultsPageContent, { keyword: keyword }) }) }));
31
+ return (jsxs(AlgoliaProvider, { languageCode: languageCode, query: keyword, searchClient: searchClient, children: [jsx(PageMetaData
32
+ // eslint-disable-next-line ssr-friendly/no-dom-globals-in-react-fc
33
+ , {
34
+ // eslint-disable-next-line ssr-friendly/no-dom-globals-in-react-fc
35
+ canonicalUrl: typeof window === 'undefined' ? '' : window.location.href, title: t('Search') }), jsx(Page, { breadCrumb: [], className: styles['search-results'], title: t("'{0}' in all products", {
36
+ replacementValues: { 0: keyword },
37
+ }), children: jsx(SearchResultsPageContent, { keyword: keyword }) })] }));
33
38
  }
34
39
  function SearchResultsPageContent({ keyword }) {
35
40
  const { hits, isLoading } = useAlgoliaHits();
@@ -0,0 +1,3 @@
1
+ var styles = {"search-results":"search-results-page-module-uE5NE","header":"search-results-page-module-grXkv","action-bar":"search-results-page-module--GBRi","sidebar-toggle":"search-results-page-module-7G8Fo","sort":"search-results-page-module-MzRkN","count":"search-results-page-module-rhDU1","categories":"search-results-page-module-uxlXw","product-grid-container":"search-results-page-module-p6Qod","product-grid":"search-results-page-module-7T07c","pagination":"search-results-page-module-zcJy7"};
2
+
3
+ export { styles as default };
@@ -1,3 +1,15 @@
1
+ export interface PageModel {
2
+ alternateLanguageUrls: {
3
+ [key: string]: string;
4
+ } | null;
5
+ canonicalPath: string;
6
+ metaDescription: string;
7
+ metaKeywords: string;
8
+ openGraphImage: string;
9
+ openGraphTitle: string;
10
+ openGraphUrl: string;
11
+ title: string;
12
+ }
1
13
  interface Category {
2
14
  activateOn: string;
3
15
  deactivateOn: string | null;
@@ -131,6 +143,7 @@ export interface Usp {
131
143
  export interface ProductDetailsPageDataResponse {
132
144
  breadCrumb: BreadCrumb[];
133
145
  included?: ProductSummary[];
146
+ page?: PageModel;
134
147
  product: ProductDetails;
135
148
  recentlyViewed?: ProductSummary[];
136
149
  usps?: Usp[];
@@ -143,6 +156,7 @@ export interface ProductListingPageDataResponse {
143
156
  categories: Category | null;
144
157
  categoryPages: string;
145
158
  hierarchicalCategories: string[];
159
+ page?: PageModel;
146
160
  promoBanners: PromoBanners | null;
147
161
  }
148
162
  export {};
@@ -1,5 +1,5 @@
1
1
  import { CultureCode } from '../../../../intl/types';
2
- import { ProductListingPageData } from '../../../../pages/product-listing-page/product-listing-page-data-types';
2
+ import { ProductListingPageData } from '../../../../pages/product/product-listing-page/product-listing-page-data-types';
3
3
  import { AnnouncementObject } from '../../../model/announcement';
4
4
  import { ProductDetailsPageDataResponse } from '../model/bff.model';
5
5
  export interface FetchAnnouncementsArgs {
@@ -55,6 +55,7 @@ async function fetchProductListingPageData({ cultureCode, pageUrl, }) {
55
55
  : undefined,
56
56
  categoryPages: body.categoryPages,
57
57
  hierarchicalCategories: body.hierarchicalCategories,
58
+ page: body.page,
58
59
  promoBanners: body.promoBanners
59
60
  ? {
60
61
  top: body.promoBanners.top || undefined,
@@ -2,12 +2,28 @@ import { QueryClient } from '@tanstack/react-query';
2
2
  export type InferPromiseResult<T> = T extends (...args: any) => Promise<infer TResult> ? TResult : never;
3
3
  interface UseAwaitableMutationArgs<T extends (...args: any) => Promise<TResult>, TResult = InferPromiseResult<T>> {
4
4
  mutationFn: T;
5
- onComplete?: (data: TResult | undefined, error: unknown | undefined, variables: Parameters<T>, queryClient: QueryClient) => void;
6
- onError?: (error: unknown, variables: Parameters<T>, queryClient: QueryClient) => void;
7
- onSuccess?: (data: TResult, variables: Parameters<T>, queryClient: QueryClient) => void;
5
+ onComplete?: (args: {
6
+ args: Parameters<T>;
7
+ data: TResult | undefined;
8
+ error: unknown | undefined;
9
+ queryClient: QueryClient;
10
+ }) => void;
11
+ onError?: (args: {
12
+ args: Parameters<T>;
13
+ error: unknown;
14
+ queryClient: QueryClient;
15
+ }) => void;
16
+ onSuccess?: (args: {
17
+ args: Parameters<T>;
18
+ data: TResult;
19
+ queryClient: QueryClient;
20
+ }) => void;
8
21
  }
9
22
  export declare function useAwaitableMutation<T extends (...args: any) => Promise<TResult>, TResult = InferPromiseResult<T>>({ mutationFn, onComplete, onError, onSuccess, }: UseAwaitableMutationArgs<T, TResult>): {
23
+ error: unknown;
24
+ isError: boolean;
10
25
  isLoading: boolean;
11
- mutate(...args: Parameters<T>): Promise<TResult>;
26
+ isSuccess: boolean;
27
+ mutate: (...args: Parameters<T>) => Promise<TResult>;
12
28
  };
13
29
  export {};
@@ -1,31 +1,39 @@
1
- import { useState } from 'react';
1
+ import { useState, useCallback } from 'react';
2
2
  import { useQueryClient } from '@tanstack/react-query';
3
3
 
4
4
  function useAwaitableMutation({ mutationFn, onComplete, onError, onSuccess, }) {
5
5
  const queryClient = useQueryClient();
6
6
  const [isLoading, setIsLoading] = useState(false);
7
+ const [isSuccess, setIsSuccess] = useState(false);
8
+ const [error, setError] = useState();
9
+ const mutate = useCallback(async (...args) => {
10
+ let result;
11
+ let error;
12
+ try {
13
+ setIsLoading(true);
14
+ const _result = await mutationFn(...args);
15
+ result = _result;
16
+ setIsSuccess(true);
17
+ onSuccess?.({ args, data: _result, queryClient });
18
+ return result;
19
+ }
20
+ catch (err) {
21
+ error = err;
22
+ setError(error);
23
+ onError?.({ args, error, queryClient });
24
+ throw err;
25
+ }
26
+ finally {
27
+ setIsLoading(false);
28
+ onComplete?.({ args, data: result, error, queryClient });
29
+ }
30
+ }, [mutationFn, onComplete, onError, onSuccess, queryClient]);
7
31
  return {
32
+ error,
33
+ isError: Boolean(error),
8
34
  isLoading,
9
- async mutate(...args) {
10
- let result;
11
- let error;
12
- try {
13
- setIsLoading(true);
14
- const _result = await mutationFn(...args);
15
- result = _result;
16
- onSuccess?.(_result, args, queryClient);
17
- return result;
18
- }
19
- catch (err) {
20
- error = err;
21
- onError?.(error, args, queryClient);
22
- throw err;
23
- }
24
- finally {
25
- setIsLoading(false);
26
- onComplete?.(result, error, args, queryClient);
27
- }
28
- },
35
+ isSuccess,
36
+ mutate,
29
37
  };
30
38
  }
31
39
 
@@ -1,4 +1,7 @@
1
- import { PatchSessionModel, SessionModel } from 'shared/api/storefront/model/storefront.model';
2
- export declare function usePatchSession(): import("@tanstack/react-query").UseMutationResult<SessionModel, Error, {
3
- session: PatchSessionModel;
4
- }, unknown>;
1
+ export declare function usePatchSession(): {
2
+ error: unknown;
3
+ isError: boolean;
4
+ isLoading: boolean;
5
+ isSuccess: boolean;
6
+ mutate: (args_0: any) => Promise<import("../../model/storefront.model").SessionModel>;
7
+ };
@@ -1,12 +1,13 @@
1
- import { useQueryClient, useMutation } from '@tanstack/react-query';
1
+ import { useQueryClient } from '@tanstack/react-query';
2
2
  import { patchSession } from '../../services/authentication-service.js';
3
+ import { useAwaitableMutation } from '../../../shared/hooks/use-awaitable-mutation.js';
3
4
 
4
5
  function usePatchSession() {
5
6
  const queryClient = useQueryClient();
6
- return useMutation({
7
+ return useAwaitableMutation({
7
8
  mutationFn: async ({ session }) => {
8
9
  const updatedSession = await patchSession({ session });
9
- queryClient.setQueriesData({ queryKey: ['session'] }, updatedSession);
10
+ queryClient.setQueriesData({ exact: true, queryKey: ['session'] }, updatedSession);
10
11
  return updatedSession;
11
12
  },
12
13
  });
@@ -1,5 +1,6 @@
1
1
  import { CartModel } from '../../model/storefront.model';
2
- export declare function useFetchCurrentCartWithAtp<T = CartModel>({ select, }?: {
2
+ export declare function useFetchCurrentCartWithAtp<T = CartModel>({ forceRecalculation, select, }?: {
3
+ forceRecalculation?: boolean;
3
4
  select?: (data: CartModel) => T;
4
5
  }): {
5
6
  data: T | undefined;
@@ -1,8 +1,10 @@
1
1
  import { useFetchCurrentCart } from './use-fetch-current-cart.js';
2
2
  import { useFetchCurrentCartProductAtp } from './use-fetch-current-cart-product-atp.js';
3
3
 
4
- function useFetchCurrentCartWithAtp({ select = cartModel => cartModel, } = { select: cartModel => cartModel }) {
5
- const cartResult = useFetchCurrentCart();
4
+ function useFetchCurrentCartWithAtp({ forceRecalculation = true, select = cartModel => cartModel, } = { select: cartModel => cartModel }) {
5
+ const cartResult = useFetchCurrentCart({
6
+ forceRecalculation,
7
+ });
6
8
  const { data: atp, error, isError, isFetching, isLoading, } = useFetchCurrentCartProductAtp();
7
9
  return {
8
10
  ...cartResult,
@@ -1,4 +1,6 @@
1
1
  import { CartModel } from '../../model/storefront.model';
2
- export declare function useFetchCurrentCart<T = CartModel>({ select, }?: {
2
+ export declare function useFetchCurrentCart<T = CartModel>({ enabled, forceRecalculation, select, }?: {
3
+ enabled?: boolean;
4
+ forceRecalculation?: boolean;
3
5
  select?: (data: CartModel) => T;
4
6
  }): import("@tanstack/react-query").UseQueryResult<T, Error>;
@@ -2,12 +2,13 @@ import { useQuery } from '@tanstack/react-query';
2
2
  import { TIME } from '../../../../utils/time.js';
3
3
  import { fetchCurrentCart } from '../../services/cart-service.js';
4
4
 
5
- function useFetchCurrentCart({ select, } = {}) {
5
+ function useFetchCurrentCart({ enabled = true, forceRecalculation = true, select, } = {}) {
6
6
  return useQuery({
7
+ enabled,
7
8
  gcTime: 15 * TIME.MINUTE,
8
9
  placeholderData: prev => prev,
9
10
  queryFn: () => {
10
- return fetchCurrentCart({ needFullCart: true });
11
+ return fetchCurrentCart({ forceRecalculation });
11
12
  },
12
13
  queryKey: ['carts', 'current'],
13
14
  retry: 3,
@@ -1,10 +1,11 @@
1
- export declare function usePatchCart(): {
1
+ export declare function usePatchCart({ skipInvalidation, }?: {
2
+ skipInvalidation?: boolean;
3
+ }): {
4
+ error: unknown;
5
+ isError: boolean;
2
6
  isLoading: boolean;
3
- mutate(args_0: {
4
- cart: Partial<Omit<import("../../model/storefront.model").CartModel, "billTo"> & {
5
- billTo?: import("../../model/storefront.model").BillToModel | {
6
- id: string;
7
- } | null;
8
- }>;
9
- }): Promise<import("../../model/storefront.model").CartModel>;
7
+ isSuccess: boolean;
8
+ mutate: (args_0: {
9
+ cart: import("../../model/storefront.model").PatchCartModel;
10
+ }) => Promise<import("../../model/storefront.model").CartModel>;
10
11
  };
@@ -1,14 +1,16 @@
1
1
  import { useAwaitableMutation } from '../../../shared/hooks/use-awaitable-mutation.js';
2
2
  import { patchCart } from '../../services/cart-service.js';
3
3
 
4
- function usePatchCart() {
4
+ function usePatchCart({ skipInvalidation = false, } = {}) {
5
5
  return useAwaitableMutation({
6
6
  mutationFn: patchCart,
7
- onError: (_, [{ cart }], queryClient) => {
7
+ onError: ({ args: [{ cart }], queryClient }) => {
8
8
  queryClient.invalidateQueries({ queryKey: ['carts', cart.id] });
9
9
  },
10
- onSuccess: (updatedCart, [{ cart }], queryClient) => {
11
- queryClient.setQueriesData({ queryKey: ['carts', updatedCart.id] }, { ...updatedCart, cartLines: cart.cartLines });
10
+ onSuccess: ({ args: [{ cart }], data: updatedCart, queryClient }) => {
11
+ if (skipInvalidation)
12
+ return;
13
+ queryClient.setQueriesData({ exact: true, queryKey: ['carts', updatedCart.id] }, { ...updatedCart, cartLines: cart.cartLines });
12
14
  },
13
15
  });
14
16
  }
@@ -1,4 +1,10 @@
1
- import { CartModel } from '../../model/storefront.model';
2
- export declare const usePlaceOrder: () => ({ cart }: {
3
- cart: any;
4
- }) => Promise<CartModel>;
1
+ export declare const usePlaceOrder: () => {
2
+ error: unknown;
3
+ isError: boolean;
4
+ isLoading: boolean;
5
+ isSuccess: boolean;
6
+ mutate: (args_0: {
7
+ cart: import("../../model/storefront.model").CartModel;
8
+ isPending?: boolean;
9
+ }) => Promise<any>;
10
+ };
@@ -1,14 +1,19 @@
1
- import { useQueryClient } from '@tanstack/react-query';
1
+ import { useCallback } from 'react';
2
+ import { useAwaitableMutation } from '../../../shared/hooks/use-awaitable-mutation.js';
2
3
  import { placeOrder } from '../../services/cart-service.js';
3
4
 
4
5
  const usePlaceOrder = () => {
5
- const queryClient = useQueryClient();
6
- return async ({ cart }) => {
7
- const updatedCart = await placeOrder({ cart });
6
+ const onComplete = useCallback(({ args: [{ cart }], queryClient }) => {
8
7
  queryClient.invalidateQueries({ queryKey: ['carts', cart.id] });
8
+ }, []);
9
+ const onSuccess = useCallback(({ data: updatedCart, queryClient }) => {
9
10
  queryClient.setQueryData(['carts', updatedCart.id], updatedCart);
10
- return updatedCart;
11
- };
11
+ }, []);
12
+ return useAwaitableMutation({
13
+ mutationFn: placeOrder,
14
+ onComplete,
15
+ onSuccess,
16
+ });
12
17
  };
13
18
 
14
19
  export { usePlaceOrder };
@@ -0,0 +1,4 @@
1
+ export declare function useFetchFulfillmentMethodsByCustomerId({ customerId, enabled, }: {
2
+ customerId?: string;
3
+ enabled?: boolean;
4
+ }): import("@tanstack/react-query").UseQueryResult<string[], Error>;
@@ -0,0 +1,12 @@
1
+ import { useQuery } from '@tanstack/react-query';
2
+ import { fetchFulfillmentMethods } from '../../services/customer-service.js';
3
+
4
+ function useFetchFulfillmentMethodsByCustomerId({ customerId, enabled = true, }) {
5
+ return useQuery({
6
+ enabled: Boolean(customerId) && enabled,
7
+ queryFn: () => fetchFulfillmentMethods({ customerId: customerId || '' }), // This function in only called when customerId is set using the enabled prop
8
+ queryKey: [customerId, 'fulfillment-methods'],
9
+ });
10
+ }
11
+
12
+ export { useFetchFulfillmentMethodsByCustomerId };
@@ -0,0 +1,3 @@
1
+ export declare function useFetchFulfillmentMethodsForCurrentCart({ enabled, }?: {
2
+ enabled?: boolean;
3
+ }): import("@tanstack/react-query").UseQueryResult<string[], Error>;
@@ -0,0 +1,12 @@
1
+ import { useFetchCurrentCart } from '../cart/use-fetch-current-cart.js';
2
+ import { useFetchFulfillmentMethodsByCustomerId } from './use-fetch-fulfillment-methods-by-customer-id.js';
3
+
4
+ function useFetchFulfillmentMethodsForCurrentCart({ enabled = true, } = {}) {
5
+ const { data: cart } = useFetchCurrentCart({ enabled });
6
+ return useFetchFulfillmentMethodsByCustomerId({
7
+ customerId: cart?.billTo?.id,
8
+ enabled,
9
+ });
10
+ }
11
+
12
+ export { useFetchFulfillmentMethodsForCurrentCart };
@@ -1,6 +1,9 @@
1
1
  export declare function usePatchBillToAddress(): {
2
+ error: unknown;
3
+ isError: boolean;
2
4
  isLoading: boolean;
3
- mutate(args_0: {
5
+ isSuccess: boolean;
6
+ mutate: (args_0: {
4
7
  billTo: import("../../model/storefront.model").BillToModel;
5
- }): Promise<import("../../model/storefront.model").BillToModel>;
8
+ }) => Promise<import("../../model/storefront.model").BillToModel>;
6
9
  };
@@ -4,7 +4,7 @@ import { useAwaitableMutation } from '../../../shared/hooks/use-awaitable-mutati
4
4
  function usePatchBillToAddress() {
5
5
  return useAwaitableMutation({
6
6
  mutationFn: patchBillToAddress,
7
- onComplete(_result, _error, _args, queryClient) {
7
+ onComplete({ queryClient }) {
8
8
  queryClient.invalidateQueries({ queryKey: ['customer'] });
9
9
  queryClient.invalidateQueries({ queryKey: ['carts'] });
10
10
  queryClient.invalidateQueries({ queryKey: ['session'] });
@@ -1 +1 @@
1
- export declare function useInvalidateAdyen(): () => Promise<void>;
1
+ export declare function useInvalidateAdyen(): () => void;
@@ -3,7 +3,7 @@ import { useQueryClient } from '@tanstack/react-query';
3
3
 
4
4
  function useInvalidateAdyen() {
5
5
  const queryClient = useQueryClient();
6
- return useCallback(() => queryClient.invalidateQueries({ queryKey: ['adyen'] }), [queryClient]);
6
+ return useCallback(() => queryClient.removeQueries({ queryKey: ['adyen'] }), [queryClient]);
7
7
  }
8
8
 
9
9
  export { useInvalidateAdyen };
@@ -970,7 +970,9 @@ export type PatchCartModel = Partial<Omit<CartModel, 'billTo'> & {
970
970
  billTo?: BillToModel | {
971
971
  id: string;
972
972
  } | null;
973
- }>;
973
+ }> & {
974
+ id: string;
975
+ };
974
976
  export interface WarehouseDto {
975
977
  address1: string;
976
978
  address2: string;
@@ -1,6 +1,10 @@
1
1
  import { AdyenPaymentModel, CartLineModel, CartLineModel as ShopCartLineModel, CartModel, CheckoutAtpEntry, PatchCartModel, ProductAtp, PromotionModel } from '../model/storefront.model';
2
- export declare function fetchCurrentCart({ needFullCart, }?: {
3
- needFullCart?: boolean;
2
+ export declare function fetchCart({ forceRecalculation, id, }: {
3
+ forceRecalculation?: boolean;
4
+ id: string;
5
+ }): Promise<CartModel>;
6
+ export declare function fetchCurrentCart({ forceRecalculation, }?: {
7
+ forceRecalculation?: boolean;
4
8
  }): Promise<CartModel>;
5
9
  export declare function fetchCurrentCartPromotions(): Promise<PromotionModel[]>;
6
10
  export declare function fetchCurrentCartLines(): Promise<CartLineModel[] | null>;
@@ -8,7 +12,7 @@ export declare function patchCartLineById({ cartLine, cartLineId, }: {
8
12
  cartLine: CartLineModel;
9
13
  cartLineId: string;
10
14
  }): Promise<void>;
11
- export declare function patchCart({ cart }: {
15
+ export declare function patchCart({ cart, }: {
12
16
  cart: PatchCartModel;
13
17
  }): Promise<CartModel>;
14
18
  export declare function deleteCurrentCart(): Promise<CartModel>;
@@ -1,13 +1,16 @@
1
1
  import { config } from '../../../../config.js';
2
2
  import { request } from '../../../fetch/request.js';
3
3
 
4
- async function fetchCurrentCart({ needFullCart = false, } = { needFullCart: false }) {
4
+ async function fetchCart({ forceRecalculation = false, id, }) {
5
5
  const { body } = await request({
6
6
  credentials: 'include',
7
- url: `${config.SHOP_API_URL}/api/v1/carts/current?expand=shipping%2Cvalidation%2CcartLines%2Crestrictions%2Ccarriers%2CpaymentOptions%2CcostCodes%2Chiddenproducts%2Ctax&forceRecalculation=${String(needFullCart)}${needFullCart ? '&allowInvalidAddress=true' : ''}`,
7
+ url: `${config.SHOP_API_URL}/api/v1/carts/${id}?expand=shipping%2Cvalidation%2CcartLines%2Crestrictions%2Ccarriers%2CpaymentOptions%2CcostCodes%2Chiddenproducts%2Ctax&forceRecalculation=${String(forceRecalculation)}&allowInvalidAddress=true`,
8
8
  });
9
9
  return body;
10
10
  }
11
+ async function fetchCurrentCart({ forceRecalculation = true, } = { forceRecalculation: true }) {
12
+ return await fetchCart({ forceRecalculation, id: 'current' });
13
+ }
11
14
  async function fetchCurrentCartPromotions() {
12
15
  const { body } = await request({
13
16
  credentials: 'include',
@@ -33,8 +36,8 @@ async function patchCartLineById({ cartLine, cartLineId, }) {
33
36
  url: `${config.SHOP_API_URL}/api/v1/carts/current/cartlines/${cartLineId}`,
34
37
  });
35
38
  }
36
- async function patchCart({ cart }) {
37
- const { body } = await request({
39
+ async function patchCart({ cart, }) {
40
+ await request({
38
41
  body: cart,
39
42
  credentials: 'include',
40
43
  headers: {
@@ -43,7 +46,7 @@ async function patchCart({ cart }) {
43
46
  method: 'PATCH',
44
47
  url: `${config.SHOP_API_URL}/api/v1/carts/current`,
45
48
  });
46
- return body;
49
+ return await fetchCart(cart);
47
50
  }
48
51
  async function deleteCurrentCart() {
49
52
  const { body } = await request({
@@ -100,7 +103,7 @@ async function placeOrder({ cart, isPending, }) {
100
103
  : isPending
101
104
  ? 'PendingPaymentValidation'
102
105
  : 'Submitted';
103
- const { body } = await request({
106
+ await request({
104
107
  body: { ...cart, status: newStatus },
105
108
  credentials: 'include',
106
109
  headers: {
@@ -109,7 +112,7 @@ async function placeOrder({ cart, isPending, }) {
109
112
  method: 'PATCH',
110
113
  url: `${config.SHOP_API_URL}/api/v1/carts/current`,
111
114
  });
112
- return body;
115
+ return await fetchCart(cart);
113
116
  }
114
117
  async function saveCartForLater({ cart }) {
115
118
  // USER NEEDS TO BE LOGGED IN
@@ -190,4 +193,4 @@ function convertToMinorUnits(value, currencyCode) {
190
193
  return Math.round(valueInMinorUnits);
191
194
  }
192
195
 
193
- export { addProductToCurrentCart, convertToMinorUnits, deleteCartLineById, deleteCurrentCart, fetchCurrentCart, fetchCurrentCartLines, fetchCurrentCartProductAtp, fetchCurrentCartPromotions, fetchCurrentCheckoutAtp, getAdyenPaymentDetails, patchCart, patchCartLineById, placeOrder, postAdyenPayment, saveCartForLater };
196
+ export { addProductToCurrentCart, convertToMinorUnits, deleteCartLineById, deleteCurrentCart, fetchCart, fetchCurrentCart, fetchCurrentCartLines, fetchCurrentCartProductAtp, fetchCurrentCartPromotions, fetchCurrentCheckoutAtp, getAdyenPaymentDetails, patchCart, patchCartLineById, placeOrder, postAdyenPayment, saveCartForLater };
@@ -6,3 +6,6 @@ export declare function fetchShipToAddresses({ shipToId }: {
6
6
  export declare function patchBillToAddress({ billTo }: {
7
7
  billTo: BillToModel;
8
8
  }): Promise<BillToModel>;
9
+ export declare function fetchFulfillmentMethods({ customerId, }: {
10
+ customerId: string;
11
+ }): Promise<string[]>;
@@ -27,5 +27,13 @@ async function patchBillToAddress({ billTo }) {
27
27
  });
28
28
  return updatedBillTo;
29
29
  }
30
+ async function fetchFulfillmentMethods({ customerId, }) {
31
+ const { body: updatedBillTo } = await request({
32
+ credentials: 'include',
33
+ method: 'GET',
34
+ url: `${config.SHOP_API_URL}/api/custom/fulfillmentmethods/customer?customerid=${customerId}`,
35
+ });
36
+ return updatedBillTo;
37
+ }
30
38
 
31
- export { fetchBillToAddresses, fetchShipToAddresses, patchBillToAddress };
39
+ export { fetchBillToAddresses, fetchFulfillmentMethods, fetchShipToAddresses, patchBillToAddress };
@@ -0,0 +1,13 @@
1
+ interface ValidateVATNumberResponse {
2
+ address: string;
3
+ countryCode: string;
4
+ isValid: boolean;
5
+ isViesVerified: boolean;
6
+ manualCheckRequired: false;
7
+ name: string;
8
+ vatNumber: string;
9
+ }
10
+ export declare function validateVATNumber({ vatNumber }: {
11
+ vatNumber: string;
12
+ }): Promise<ValidateVATNumberResponse>;
13
+ export {};
@@ -0,0 +1,17 @@
1
+ import { config } from '../../../../config.js';
2
+ import { request } from '../../../fetch/request.js';
3
+
4
+ async function validateVATNumber({ vatNumber }) {
5
+ const { body: updatedBillTo } = await request({
6
+ body: { vatNumber },
7
+ credentials: 'include',
8
+ headers: {
9
+ 'Content-Type': 'application/json',
10
+ },
11
+ method: 'POST',
12
+ url: `${config.SHOP_API_URL}/api/custom/finance/vat/validate`,
13
+ });
14
+ return updatedBillTo;
15
+ }
16
+
17
+ export { validateVATNumber };
@@ -8,7 +8,7 @@ async function fetchTranslations(languageCode) {
8
8
  url: `${config.SHOP_API_URL}/api/v1/translationdictionaries?page=1&pageSize=9999&languageCode=${languageCode}`,
9
9
  });
10
10
  body.translationDictionaries?.forEach(dictionary => {
11
- translations[dictionary.keyword] = dictionary.translation;
11
+ translations[dictionary.keyword.toLowerCase()] = dictionary.translation;
12
12
  });
13
13
  return translations;
14
14
  }
@@ -0,0 +1,3 @@
1
+ export declare const useCSSLink: (url: string, { enabled }?: {
2
+ enabled: boolean;
3
+ }) => void;