@faststore/core 2.2.0-alpha.1 → 2.2.0-alpha.12

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 (188) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/build-manifest.json +74 -75
  3. package/.next/cache/.tsbuildinfo +1 -1
  4. package/.next/cache/config.json +3 -3
  5. package/.next/cache/eslint/.cache_1gneedd +1 -1
  6. package/.next/cache/next-server.js.nft.json +1 -1
  7. package/.next/cache/webpack/client-production/0.pack +0 -0
  8. package/.next/cache/webpack/client-production/index.pack +0 -0
  9. package/.next/cache/webpack/server-production/0.pack +0 -0
  10. package/.next/cache/webpack/server-production/index.pack +0 -0
  11. package/.next/next-server.js.nft.json +1 -1
  12. package/.next/prerender-manifest.json +1 -1
  13. package/.next/react-loadable-manifest.json +11 -8
  14. package/.next/required-server-files.json +1 -1
  15. package/.next/routes-manifest.json +1 -1
  16. package/.next/server/chunks/{647.js → 117.js} +32 -35
  17. package/.next/server/chunks/183.js +1 -0
  18. package/.next/server/chunks/289.js +25 -27
  19. package/.next/server/chunks/312.js +53 -72
  20. package/.next/server/chunks/350.js +8 -8
  21. package/.next/server/chunks/{483.js → 37.js} +121 -162
  22. package/.next/server/chunks/386.js +200 -0
  23. package/.next/server/chunks/{753.js → 387.js} +8 -12
  24. package/.next/server/chunks/574.js +42 -23
  25. package/.next/server/chunks/576.js +1 -0
  26. package/.next/server/chunks/{530.js → 585.js} +65 -51
  27. package/.next/server/chunks/{186.js → 692.js} +6 -8
  28. package/.next/server/chunks/{112.js → 732.js} +282 -457
  29. package/.next/server/chunks/74.js +247 -345
  30. package/.next/server/chunks/825.js +38 -3
  31. package/.next/server/chunks/{71.js → 897.js} +174 -181
  32. package/.next/server/chunks/98.js +42 -23
  33. package/.next/server/middleware-build-manifest.js +1 -1
  34. package/.next/server/middleware-react-loadable-manifest.js +1 -1
  35. package/.next/server/pages/404.js +13 -13
  36. package/.next/server/pages/404.js.nft.json +1 -1
  37. package/.next/server/pages/500.js +14 -14
  38. package/.next/server/pages/500.js.nft.json +1 -1
  39. package/.next/server/pages/[...slug].js +141 -184
  40. package/.next/server/pages/[...slug].js.nft.json +1 -1
  41. package/.next/server/pages/[slug]/p.js +242 -219
  42. package/.next/server/pages/[slug]/p.js.nft.json +1 -1
  43. package/.next/server/pages/_app.js +3 -4
  44. package/.next/server/pages/_app.js.nft.json +1 -1
  45. package/.next/server/pages/_document.js +17 -33
  46. package/.next/server/pages/_document.js.nft.json +1 -1
  47. package/.next/server/pages/account.js +12 -12
  48. package/.next/server/pages/account.js.nft.json +1 -1
  49. package/.next/server/pages/api/graphql.js +15 -8
  50. package/.next/server/pages/api/graphql.js.nft.json +1 -1
  51. package/.next/server/pages/api/preview.js +2 -20
  52. package/.next/server/pages/checkout.js +12 -12
  53. package/.next/server/pages/checkout.js.nft.json +1 -1
  54. package/.next/server/pages/en-US/404.html +2 -2
  55. package/.next/server/pages/en-US/500.html +2 -2
  56. package/.next/server/pages/en-US/account.html +2 -2
  57. package/.next/server/pages/en-US/checkout.html +2 -2
  58. package/.next/server/pages/en-US/login.html +2 -2
  59. package/.next/server/pages/en-US/s.html +2 -2
  60. package/.next/server/pages/en-US.html +11 -2
  61. package/.next/server/pages/index.js +41 -48
  62. package/.next/server/pages/index.js.nft.json +1 -1
  63. package/.next/server/pages/login.js +15 -15
  64. package/.next/server/pages/login.js.nft.json +1 -1
  65. package/.next/server/pages/s.js +52 -52
  66. package/.next/server/pages/s.js.nft.json +1 -1
  67. package/.next/server/pages-manifest.json +2 -2
  68. package/.next/static/6R1hrzilfMwT81RW6cNqt/_buildManifest.js +1 -0
  69. package/.next/static/chunks/251.ffc4f3998ecb915a.js +1 -0
  70. package/.next/static/chunks/383-6217b37bd38ffd07.js +1 -0
  71. package/.next/static/chunks/386.d01e0db26c523f0f.js +1 -0
  72. package/.next/static/chunks/{574.d13dd0afe15cd635.js → 574.70612be06fd1365f.js} +1 -1
  73. package/.next/static/chunks/585.3350efefe61c9461.js +1 -0
  74. package/.next/static/chunks/635-666ee2cad2925bb7.js +1 -0
  75. package/.next/static/chunks/721-f1665b3f1d98b7a9.js +1 -0
  76. package/.next/static/chunks/722-d0cc87aacd616b5d.js +1 -0
  77. package/.next/static/chunks/783-ded9d8cda0d5c8d9.js +1 -0
  78. package/.next/static/chunks/{709.daf1eddebf1e7952.js → 800.851af48fe2ab4a4c.js} +1 -1
  79. package/.next/static/chunks/98.40c7e17d9de4eb8f.js +1 -0
  80. package/.next/static/chunks/988.afda042dd9ba11d1.js +1 -0
  81. package/.next/static/chunks/main-e4e873ee741162eb.js +1 -0
  82. package/.next/static/chunks/pages/{404-af78f7cd1d3c1f60.js → 404-6c674028b2f80cbb.js} +1 -1
  83. package/.next/static/chunks/pages/{500-f6346ca5f9dc4fef.js → 500-ff55de77265a7e43.js} +1 -1
  84. package/.next/static/chunks/pages/[...slug]-7f8dc13cc9542463.js +1 -0
  85. package/.next/static/chunks/pages/[slug]/p-2fb3fd9027f2923b.js +1 -0
  86. package/.next/static/chunks/pages/{_app-6d0e6ab9a4dd8106.js → _app-7db7de3d205714be.js} +1 -1
  87. package/.next/static/chunks/pages/{account-05bd79fb78365e88.js → account-b06035cba2c99604.js} +1 -1
  88. package/.next/static/chunks/pages/{checkout-c973786e68f25a39.js → checkout-f0c3e8d691cb8a54.js} +1 -1
  89. package/.next/static/chunks/pages/index-a141c747fcc197a1.js +1 -0
  90. package/.next/static/chunks/pages/{login-8deb9243376b6aa1.js → login-4e0e6cab7a07f1f3.js} +1 -1
  91. package/.next/static/chunks/pages/s-823f8e1cabbf63b3.js +1 -0
  92. package/.next/static/chunks/webpack-f3d0973d5a781e73.js +1 -0
  93. package/.next/static/css/6a7fdc5a21fbead5.css +1 -0
  94. package/.next/static/css/723835bce380750d.css +1 -0
  95. package/.next/static/css/8f93a4630936c20b.css +1 -0
  96. package/.next/static/css/9f79fa103f49bca1.css +1 -0
  97. package/.next/static/css/fd27ecc37832aa54.css +1 -0
  98. package/.next/trace +77 -80
  99. package/.turbo/turbo-build.log +24 -21
  100. package/.turbo/turbo-lint.log +3 -0
  101. package/.turbo/turbo-test.log +10 -10
  102. package/@generated/graphql/index.ts +38 -14
  103. package/@generated/graphql/persisted.json +6 -6
  104. package/README.md +3 -3
  105. package/cms/faststore/sections.json +24 -0
  106. package/cypress/global.js +8 -0
  107. package/cypress/integration/a11y.test.js +7 -24
  108. package/cypress/integration/analytics.test.js +78 -87
  109. package/cypress/integration/cart.test.js +4 -4
  110. package/cypress/integration/plp.test.js +6 -6
  111. package/cypress/integration/search.test.js +1 -1
  112. package/cypress/integration/seo.test.js +14 -14
  113. package/cypress.config.ts +19 -0
  114. package/faststore.config.js +1 -0
  115. package/index.ts +4 -0
  116. package/next.config.js +4 -0
  117. package/package.json +22 -18
  118. package/src/components/cart/CartSidebar/CartSidebar.tsx +41 -27
  119. package/src/components/product/NotAvailableButton/NotAvailableButton.tsx +13 -0
  120. package/src/components/product/NotAvailableButton/index.ts +1 -0
  121. package/src/components/product/ProductGrid/ProductGrid.tsx +2 -2
  122. package/src/components/search/Filter/Filter.tsx +1 -1
  123. package/src/components/search/Filter/FilterDesktop.tsx +1 -1
  124. package/src/components/search/Filter/FilterSlider.tsx +1 -1
  125. package/src/components/search/SearchInput/SearchInput.tsx +12 -1
  126. package/src/components/search/SearchTop/SearchTop.tsx +7 -1
  127. package/src/components/sections/CrossSellingShelf/CrossSellingShelf.tsx +0 -1
  128. package/src/components/sections/Newsletter/Overrides.tsx +4 -0
  129. package/src/components/sections/ProductDetails/Overrides.tsx +8 -4
  130. package/src/components/sections/ProductDetails/ProductDetails.tsx +26 -15
  131. package/src/components/sections/ProductTiles/ProductTiles.tsx +3 -2
  132. package/src/components/ui/ImageGallery/ImageGallery.tsx +13 -6
  133. package/src/components/ui/Newsletter/Newsletter.tsx +6 -44
  134. package/src/components/ui/Newsletter/NewsletterAddendum.tsx +86 -0
  135. package/src/components/ui/ProductDescription/ProductDescription.tsx +6 -1
  136. package/src/components/ui/ProductDetails/ProductDetailsSettings.tsx +97 -58
  137. package/src/components/ui/ProductGallery/ProductGallery.tsx +2 -2
  138. package/src/components/ui/ShippingSimulation/ShippingSimulation.tsx +12 -34
  139. package/src/customizations/fragments/{ClientProducts.ts → ClientManyProducts.ts} +1 -1
  140. package/src/customizations/fragments/ClientSearchSuggestions.ts +13 -0
  141. package/src/customizations/fragments/ClientShippingSimulation.ts +11 -0
  142. package/src/customizations/fragments/ClientTopSearchSuggestions.ts +13 -0
  143. package/src/customizations/fragments/{ServerProductPage.ts → ServerProduct.ts} +1 -1
  144. package/src/experimental/index.ts +36 -0
  145. package/src/pages/[...slug].tsx +5 -2
  146. package/src/pages/[slug]/p.tsx +7 -7
  147. package/src/sdk/analytics/index.tsx +1 -1
  148. package/src/sdk/analytics/platform/vtex/search.ts +53 -21
  149. package/src/sdk/analytics/types.ts +14 -0
  150. package/src/sdk/overrides/PageProvider.tsx +9 -5
  151. package/src/sdk/product/useLocalizedVariables.ts +2 -2
  152. package/src/sdk/product/usePageProductsQuery.ts +8 -8
  153. package/src/sdk/product/useProductGalleryQuery.ts +32 -3
  154. package/src/sdk/product/useProductsPrefetch.ts +4 -4
  155. package/src/sdk/product/useProductsQuery.ts +7 -7
  156. package/src/sdk/search/useSuggestions.ts +48 -16
  157. package/src/sdk/search/useTopSearch.ts +7 -12
  158. package/src/sdk/shipping/index.ts +6 -4
  159. package/src/{components/ui/ShippingSimulation → sdk/shipping}/useShippingSimulation.ts +33 -56
  160. package/src/server/generator/schema.ts +2 -1
  161. package/src/typings/overrides.ts +8 -2
  162. package/tsconfig.json +2 -1
  163. package/.next/static/chunks/148.3bb7e05cc5d1c1c4.js +0 -1
  164. package/.next/static/chunks/238-86838f629f3d0aa4.js +0 -1
  165. package/.next/static/chunks/243-ef9e49ef3df579c0.js +0 -1
  166. package/.next/static/chunks/530.848b014622932b93.js +0 -1
  167. package/.next/static/chunks/548-ab84e9e8b49413ab.js +0 -1
  168. package/.next/static/chunks/738-67a288ca3569cdbb.js +0 -1
  169. package/.next/static/chunks/932-33f45603c7d12a4b.js +0 -1
  170. package/.next/static/chunks/98.1632997dfd4d3a52.js +0 -1
  171. package/.next/static/chunks/988.d10040040cdfebbb.js +0 -1
  172. package/.next/static/chunks/main-fd466221927468fd.js +0 -1
  173. package/.next/static/chunks/pages/[...slug]-362204c7e0b533cf.js +0 -1
  174. package/.next/static/chunks/pages/[slug]/p-885042c4b2b4f8ed.js +0 -1
  175. package/.next/static/chunks/pages/index-79b05b0071c02fff.js +0 -1
  176. package/.next/static/chunks/pages/s-e1bb00f8de6a386e.js +0 -1
  177. package/.next/static/chunks/webpack-88d120cefa1c4c09.js +0 -1
  178. package/.next/static/css/20e4a3a45cdd65f4.css +0 -1
  179. package/.next/static/css/4b7138899cd07c63.css +0 -1
  180. package/.next/static/css/e3b039e8f5daf95f.css +0 -1
  181. package/.next/static/css/f0e2d1b8832e935d.css +0 -1
  182. package/.next/static/wPqgZ8bYrPY473PZzuIX_/_buildManifest.js +0 -1
  183. package/cypress.json +0 -9
  184. package/generate.sh +0 -71
  185. /package/.next/static/{wPqgZ8bYrPY473PZzuIX_ → 6R1hrzilfMwT81RW6cNqt}/_ssgManifest.js +0 -0
  186. /package/src/{components/ui/ProductGallery → sdk/search}/useDelayedFacets.ts +0 -0
  187. /package/src/{components/ui/ProductGallery → sdk/search}/useDelayedPagination.ts +0 -0
  188. /package/src/{components/search/Filter → sdk/search}/useFilter.ts +0 -0
@@ -1,8 +1,8 @@
1
1
  import { gql } from '@faststore/graphql-utils'
2
2
  import { useSearch } from '@faststore/sdk'
3
3
  import {
4
- ClientProductsQueryQuery,
5
- ClientProductsQueryQueryVariables,
4
+ ClientManyProductsQueryQuery,
5
+ ClientManyProductsQueryQueryVariables,
6
6
  } from '@generated/graphql'
7
7
  import {
8
8
  useEffect,
@@ -31,14 +31,14 @@ export const useGalleryPage = (page: number) => {
31
31
  }
32
32
 
33
33
  export const query = gql`
34
- query ClientProductsQuery(
34
+ query ClientManyProductsQuery(
35
35
  $first: Int!
36
36
  $after: String
37
37
  $sort: StoreSort!
38
38
  $term: String!
39
39
  $selectedFacets: [IStoreSelectedFacet!]!
40
40
  ) {
41
- ...ClientProducts
41
+ ...ClientManyProducts
42
42
  search(
43
43
  first: $first
44
44
  after: $after
@@ -66,9 +66,9 @@ const getKey = (object: any) => JSON.stringify(object)
66
66
  * Use this hook for managed pages state and creating useGalleryPage hook that will be used for fetching a list of products per pages in PLP or Search
67
67
  */
68
68
  export const useCreateUseGalleryPage = () => {
69
- const [pages, setPages] = useState<ClientProductsQueryQuery[]>([])
69
+ const [pages, setPages] = useState<ClientManyProductsQueryQuery[]>([])
70
70
  // We create pagesRef as a mirror of the pages state so we don't have to add pages as a dependency of the useGalleryPage hook
71
- const pagesRef = useRef<ClientProductsQueryQuery[]>([])
71
+ const pagesRef = useRef<ClientManyProductsQueryQuery[]>([])
72
72
  const pagesCache = useRef<string[]>([])
73
73
 
74
74
  const useGalleryPage = useCallback(function useGalleryPage(page: number) {
@@ -89,8 +89,8 @@ export const useCreateUseGalleryPage = () => {
89
89
  pagesCache.current[page] === getKey(localizedVariables)
90
90
 
91
91
  const { data } = useQuery<
92
- ClientProductsQueryQuery,
93
- ClientProductsQueryQueryVariables
92
+ ClientManyProductsQueryQuery,
93
+ ClientManyProductsQueryQueryVariables
94
94
  >(query, localizedVariables, {
95
95
  fallbackData: null,
96
96
  suspense: true,
@@ -1,17 +1,26 @@
1
+ import { sendAnalyticsEvent } from '@faststore/sdk'
1
2
  import { gql } from '@faststore/graphql-utils'
2
3
 
4
+ import { useQuery } from 'src/sdk/graphql/useQuery'
5
+ import { useLocalizedVariables } from './useLocalizedVariables'
6
+ import { useSession } from 'src/sdk/session'
7
+
3
8
  import type {
4
9
  ClientProductGalleryQueryQuery as Query,
5
10
  ClientProductGalleryQueryQueryVariables as Variables,
6
11
  } from '@generated/graphql'
7
- import { useQuery } from 'src/sdk/graphql/useQuery'
8
- import { useLocalizedVariables } from './useLocalizedVariables'
12
+ import type { IntelligentSearchQueryEvent } from 'src/sdk/analytics/types'
9
13
 
10
14
  /**
11
15
  * This query is run on the browser and contains
12
16
  * the current search state of the user
13
17
  */
14
18
  export const query = gql`
19
+ fragment SearchEvent_metadata on SearchMetadata {
20
+ isTermMisspelled
21
+ logicalOperator
22
+ }
23
+
15
24
  query ClientProductGalleryQuery(
16
25
  $first: Int!
17
26
  $after: String!
@@ -35,6 +44,9 @@ export const query = gql`
35
44
  facets {
36
45
  ...Filter_facets
37
46
  }
47
+ metadata {
48
+ ...SearchEvent_metadata
49
+ }
38
50
  }
39
51
  }
40
52
  `
@@ -45,6 +57,7 @@ export const useProductGalleryQuery = ({
45
57
  selectedFacets,
46
58
  itemsPerPage,
47
59
  }) => {
60
+ const { locale } = useSession()
48
61
  const localizedVariables = useLocalizedVariables({
49
62
  first: itemsPerPage,
50
63
  after: '0',
@@ -53,5 +66,21 @@ export const useProductGalleryQuery = ({
53
66
  selectedFacets,
54
67
  })
55
68
 
56
- return useQuery<Query, Variables>(query, localizedVariables)
69
+ return useQuery<Query, Variables>(query, localizedVariables, {
70
+ onSuccess: (data) => {
71
+ if (data && term) {
72
+ sendAnalyticsEvent<IntelligentSearchQueryEvent>({
73
+ name: 'intelligent_search_query',
74
+ params: {
75
+ locale,
76
+ term,
77
+ url: window.location.href,
78
+ logicalOperator: data.search.metadata?.logicalOperator ?? 'and',
79
+ isTermMisspelled: data.search.metadata?.isTermMisspelled ?? false,
80
+ totalCount: data.search.products.pageInfo.totalCount,
81
+ },
82
+ })
83
+ }
84
+ },
85
+ })
57
86
  }
@@ -1,6 +1,6 @@
1
1
  import { gql } from '@faststore/graphql-utils'
2
2
  import { useSearch } from '@faststore/sdk'
3
- import { ClientProductsQueryQueryVariables } from '@generated/graphql'
3
+ import { ClientManyProductsQueryQueryVariables } from '@generated/graphql'
4
4
  import { useEffect, useCallback } from 'react'
5
5
  import type { QueryOptions } from '../graphql/useQuery'
6
6
  import { useSWRConfig } from 'swr'
@@ -8,14 +8,14 @@ import { prefetchQuery } from '../graphql/prefetchQuery'
8
8
  import { useLocalizedVariables } from './useLocalizedVariables'
9
9
 
10
10
  export const query = gql`
11
- query ClientProductsQuery(
11
+ query ClientManyProductsQuery(
12
12
  $first: Int!
13
13
  $after: String
14
14
  $sort: StoreSort!
15
15
  $term: String!
16
16
  $selectedFacets: [IStoreSelectedFacet!]!
17
17
  ) {
18
- ...ClientProducts
18
+ ...ClientManyProducts
19
19
  search(
20
20
  first: $first
21
21
  after: $after
@@ -38,7 +38,7 @@ export const query = gql`
38
38
  `
39
39
 
40
40
  export const useProductsQueryPrefetch = (
41
- variables: ClientProductsQueryQueryVariables,
41
+ variables: ClientManyProductsQueryQueryVariables,
42
42
  options?: QueryOptions
43
43
  ) => {
44
44
  const localizedVariables = useLocalizedVariables(variables)
@@ -1,8 +1,8 @@
1
1
  import { gql } from '@faststore/graphql-utils'
2
2
 
3
3
  import type {
4
- ClientProductsQueryQuery,
5
- ClientProductsQueryQueryVariables,
4
+ ClientManyProductsQueryQuery,
5
+ ClientManyProductsQueryQueryVariables,
6
6
  } from '@generated/graphql'
7
7
 
8
8
  import type { QueryOptions } from '../graphql/useQuery'
@@ -10,14 +10,14 @@ import { useQuery } from '../graphql/useQuery'
10
10
  import { useLocalizedVariables } from './useLocalizedVariables'
11
11
 
12
12
  export const query = gql`
13
- query ClientProductsQuery(
13
+ query ClientManyProductsQuery(
14
14
  $first: Int!
15
15
  $after: String
16
16
  $sort: StoreSort!
17
17
  $term: String!
18
18
  $selectedFacets: [IStoreSelectedFacet!]!
19
19
  ) {
20
- ...ClientProducts
20
+ ...ClientManyProducts
21
21
  search(
22
22
  first: $first
23
23
  after: $after
@@ -43,14 +43,14 @@ export const query = gql`
43
43
  * Use this hook for fetching a list of products, like shelves and tiles
44
44
  */
45
45
  export const useProductsQuery = (
46
- variables: Partial<ClientProductsQueryQueryVariables>,
46
+ variables: Partial<ClientManyProductsQueryQueryVariables>,
47
47
  options?: QueryOptions
48
48
  ) => {
49
49
  const localizedVariables = useLocalizedVariables(variables)
50
50
 
51
51
  const { data } = useQuery<
52
- ClientProductsQueryQuery,
53
- ClientProductsQueryQueryVariables
52
+ ClientManyProductsQueryQuery,
53
+ ClientManyProductsQueryQueryVariables
54
54
  >(query, localizedVariables, {
55
55
  fallbackData: null,
56
56
  suspense: true,
@@ -1,20 +1,23 @@
1
- import { gql } from '@faststore/graphql-utils'
1
+ import { useMemo } from 'react'
2
2
 
3
+ import { sendAnalyticsEvent } from '@faststore/sdk'
4
+ import { gql } from '@faststore/graphql-utils'
3
5
  import { useQuery } from 'src/sdk/graphql/useQuery'
6
+
4
7
  import type {
5
- SearchSuggestionsQueryQuery as Query,
6
- SearchSuggestionsQueryQueryVariables as Variables,
8
+ ClientSearchSuggestionsQueryQuery as Query,
9
+ ClientSearchSuggestionsQueryQueryVariables as Variables,
7
10
  } from '@generated/graphql'
11
+ import type { IntelligentSearchQueryEvent } from '../analytics/types'
8
12
 
9
13
  import { useSession } from '../session'
10
14
 
11
- const MAX_SUGGESTIONS = 5
12
-
13
15
  const query = gql`
14
- query SearchSuggestionsQuery(
16
+ query ClientSearchSuggestionsQuery(
15
17
  $term: String!
16
18
  $selectedFacets: [IStoreSelectedFacet!]
17
19
  ) {
20
+ ...ClientSearchSuggestions
18
21
  search(first: 5, term: $term, selectedFacets: $selectedFacets) {
19
22
  suggestions {
20
23
  terms {
@@ -24,25 +27,54 @@ const query = gql`
24
27
  ...ProductSummary_product
25
28
  }
26
29
  }
30
+ products {
31
+ pageInfo {
32
+ totalCount
33
+ }
34
+ }
35
+ metadata {
36
+ ...SearchEvent_metadata
37
+ }
27
38
  }
28
39
  }
29
40
  `
30
41
 
31
- function useSuggestions(term: string, limit: number = MAX_SUGGESTIONS) {
42
+ function useSuggestions(term: string) {
32
43
  const { channel, locale } = useSession()
33
44
 
34
- const { data, error } = useQuery<Query, Variables>(query, {
35
- term,
36
- selectedFacets: [
37
- { key: 'channel', value: channel ?? '' },
38
- { key: 'locale', value: locale },
39
- ],
45
+ const variables = useMemo(
46
+ () => ({
47
+ term,
48
+ selectedFacets: [
49
+ { key: 'channel', value: channel ?? '' },
50
+ { key: 'locale', value: locale },
51
+ ],
52
+ }),
53
+ [term, locale, channel]
54
+ )
55
+ const { data, error } = useQuery<Query, Variables>(query, variables, {
56
+ onSuccess: (callbackData) => {
57
+ if (callbackData && term) {
58
+ sendAnalyticsEvent<IntelligentSearchQueryEvent>({
59
+ name: 'intelligent_search_query',
60
+ params: {
61
+ locale,
62
+ term,
63
+ url: window.location.href,
64
+ logicalOperator:
65
+ callbackData.search.metadata?.logicalOperator ?? 'and',
66
+ isTermMisspelled:
67
+ callbackData.search.metadata?.isTermMisspelled ?? false,
68
+ totalCount: callbackData.search.products.pageInfo.totalCount,
69
+ },
70
+ })
71
+ }
72
+ },
40
73
  })
41
74
 
42
75
  return {
43
- terms: (data?.search.suggestions.terms ?? []).slice(0, limit),
44
- products: (data?.search.suggestions.products ?? []).slice(0, limit),
45
- isLoading: !error && !data,
76
+ data,
77
+ error,
46
78
  }
47
79
  }
48
80
 
@@ -2,20 +2,18 @@ import { gql } from '@faststore/graphql-utils'
2
2
 
3
3
  import { useQuery } from 'src/sdk/graphql/useQuery'
4
4
  import type {
5
- StoreSuggestionTerm,
6
- SearchSuggestionsQueryQuery as Query,
7
- SearchSuggestionsQueryQueryVariables as Variables,
5
+ ClientSearchSuggestionsQueryQuery as Query,
6
+ ClientSearchSuggestionsQueryQueryVariables as Variables,
8
7
  } from '@generated/graphql'
9
8
 
10
9
  import { useSession } from '../session'
11
10
 
12
- const MAX_TOP_SEARCH_TERMS = 5
13
-
14
11
  const query = gql`
15
- query TopSearchSuggestionsQuery(
12
+ query ClientTopSearchSuggestionsQuery(
16
13
  $term: String!
17
14
  $selectedFacets: [IStoreSelectedFacet!]
18
15
  ) {
16
+ ...ClientTopSearchSuggestions
19
17
  search(first: 5, term: $term, selectedFacets: $selectedFacets) {
20
18
  suggestions {
21
19
  terms {
@@ -26,10 +24,7 @@ const query = gql`
26
24
  }
27
25
  `
28
26
 
29
- function useTopSearch(
30
- initialTerms: StoreSuggestionTerm[] = [],
31
- limit: number = MAX_TOP_SEARCH_TERMS
32
- ) {
27
+ function useTopSearch() {
33
28
  const { channel, locale } = useSession()
34
29
 
35
30
  const { data, error } = useQuery<Query, Variables>(query, {
@@ -41,8 +36,8 @@ function useTopSearch(
41
36
  })
42
37
 
43
38
  return {
44
- terms: (data?.search.suggestions.terms ?? initialTerms).slice(0, limit),
45
- isLoading: !error && !data,
39
+ data,
40
+ error,
46
41
  }
47
42
  }
48
43
 
@@ -2,18 +2,19 @@ import type { IShippingItem } from '@faststore/api'
2
2
  import { gql } from '@faststore/graphql-utils'
3
3
 
4
4
  import type {
5
- ShippingSimulationQueryQuery as Query,
6
- ShippingSimulationQueryQueryVariables as Variables,
5
+ ClientShippingSimulationQueryQuery as Query,
6
+ ClientShippingSimulationQueryQueryVariables as Variables,
7
7
  } from '@generated/graphql'
8
8
 
9
9
  import { request } from '../graphql/request'
10
10
 
11
11
  const query = gql`
12
- query ShippingSimulationQuery(
12
+ query ClientShippingSimulationQuery(
13
13
  $postalCode: String!
14
14
  $country: String!
15
15
  $items: [IShippingItem!]!
16
16
  ) {
17
+ ...ClientShippingSimulation
17
18
  shipping(items: $items, postalCode: $postalCode, country: $country) {
18
19
  logisticsInfo {
19
20
  slas {
@@ -32,6 +33,7 @@ const query = gql`
32
33
  address {
33
34
  city
34
35
  neighborhood
36
+ state
35
37
  }
36
38
  }
37
39
  }
@@ -54,7 +56,7 @@ export const getShippingSimulation = async ({
54
56
  country,
55
57
  })
56
58
 
57
- return data.shipping
59
+ return data
58
60
  }
59
61
 
60
62
  export default getShippingSimulation
@@ -1,6 +1,8 @@
1
1
  import type { ChangeEvent } from 'react'
2
- import { useCallback, useEffect, useReducer } from 'react'
3
- import { ShippingSimulationProps as UIShippingSimulationProps } from '@faststore/components'
2
+ import { useCallback, useEffect, useReducer, useRef } from 'react'
3
+ import { ClientShippingSimulationQueryQuery } from '@generated/graphql'
4
+ import getShippingSimulation from '.'
5
+ import { useSession } from '../session'
4
6
 
5
7
  export interface ProductShippingInfo {
6
8
  id: string
@@ -14,14 +16,9 @@ type InputProps = {
14
16
  errorMessage?: string
15
17
  }
16
18
 
17
- type ShippingSimulationProps = {
18
- location?: string
19
- options?: UIShippingSimulationProps['options']
20
- }
21
-
22
19
  type State = {
23
20
  input: InputProps
24
- shippingSimulation: ShippingSimulationProps
21
+ shippingSimulation?: ClientShippingSimulationQueryQuery['shipping']
25
22
  }
26
23
 
27
24
  type Action =
@@ -41,17 +38,15 @@ type Action =
41
38
  type: 'clear'
42
39
  }
43
40
 
44
- const createEmptySimulation = () => ({
45
- input: {
46
- postalCode: '',
47
- displayClearButton: false,
48
- errorMessage: '',
49
- },
50
- shippingSimulation: {
51
- location: '',
52
- options: [],
53
- },
54
- })
41
+ const createEmptySimulation = () =>
42
+ ({
43
+ input: {
44
+ postalCode: '',
45
+ displayClearButton: false,
46
+ errorMessage: '',
47
+ },
48
+ shippingSimulation: undefined,
49
+ } as State)
55
50
 
56
51
  const reducer = (state: State, action: Action) => {
57
52
  const { type } = action
@@ -104,38 +99,31 @@ const reducer = (state: State, action: Action) => {
104
99
  }
105
100
  }
106
101
 
107
- export type FetchShippingSimulation = (
108
- shippingItem: ProductShippingInfo,
109
- country: string,
110
- postalCode: string
111
- ) => Promise<[string, UIShippingSimulationProps['options']]>
112
-
113
- export const useShippingSimulation = (
114
- shippingItem: ProductShippingInfo,
115
- fetchShippingSimulationFn: FetchShippingSimulation,
116
- sessionPostalCode: string,
117
- country: string
118
- ) => {
102
+ export const useShippingSimulation = (shippingItem: ProductShippingInfo) => {
119
103
  const [{ input, shippingSimulation }, dispatch] = useReducer(
120
104
  reducer,
121
105
  null,
122
106
  createEmptySimulation
123
107
  )
124
108
 
109
+ const { country, postalCode: sessionPostalCode } = useSession()
125
110
  const { postalCode: shippingPostalCode } = input
111
+ const shippingPostalCodeRef = useRef(shippingPostalCode)
126
112
 
127
113
  useEffect(() => {
128
- if (!sessionPostalCode || shippingPostalCode) {
114
+ const shouldFetch = sessionPostalCode && !shippingPostalCodeRef.current
115
+ if (!shouldFetch) {
129
116
  return
130
117
  }
131
118
 
132
119
  // Use sessionPostalCode if there is no shippingPostalCode
133
120
  async function fetchShipping() {
134
- const [location, options] = await fetchShippingSimulationFn(
135
- shippingItem,
121
+ const data = await getShippingSimulation({
136
122
  country,
137
- sessionPostalCode ?? ''
138
- )
123
+ postalCode: sessionPostalCode ?? '',
124
+ items: [shippingItem],
125
+ })
126
+ const shippingSimulation = data.shipping
139
127
 
140
128
  dispatch({
141
129
  type: 'update',
@@ -145,30 +133,22 @@ export const useShippingSimulation = (
145
133
  displayClearButton: true,
146
134
  errorMessage: '',
147
135
  },
148
- shippingSimulation: {
149
- location,
150
- options,
151
- },
136
+ shippingSimulation,
152
137
  },
153
138
  })
154
139
  }
155
140
 
156
141
  fetchShipping()
157
- }, [
158
- country,
159
- fetchShippingSimulationFn,
160
- sessionPostalCode,
161
- shippingItem,
162
- shippingPostalCode,
163
- ])
142
+ }, [country, sessionPostalCode, shippingItem])
164
143
 
165
144
  const handleSubmit = useCallback(async () => {
166
145
  try {
167
- const [location, options] = await fetchShippingSimulationFn(
168
- shippingItem,
146
+ const data = await getShippingSimulation({
169
147
  country,
170
- shippingPostalCode ?? ''
171
- )
148
+ postalCode: shippingPostalCode ?? '',
149
+ items: [shippingItem],
150
+ })
151
+ const shippingSimulation = data.shipping
172
152
 
173
153
  dispatch({
174
154
  type: 'update',
@@ -177,10 +157,7 @@ export const useShippingSimulation = (
177
157
  displayClearButton: true,
178
158
  errorMessage: '',
179
159
  },
180
- shippingSimulation: {
181
- location,
182
- options,
183
- },
160
+ shippingSimulation,
184
161
  },
185
162
  })
186
163
  } catch (error) {
@@ -192,7 +169,7 @@ export const useShippingSimulation = (
192
169
  },
193
170
  })
194
171
  }
195
- }, [country, fetchShippingSimulationFn, shippingItem, shippingPostalCode])
172
+ }, [country, shippingItem, shippingPostalCode])
196
173
 
197
174
  const handleOnInput = useCallback((e: ChangeEvent<HTMLInputElement>) => {
198
175
  const currentValue = e.currentTarget.value
@@ -1,3 +1,4 @@
1
+ import path from 'path'
1
2
  import { writeFileSync } from 'fs-extra'
2
3
  import { getSchema, getTypeDefs } from '@faststore/api'
3
4
  import { printSchemaWithDirectives } from '@graphql-tools/utils'
@@ -69,7 +70,7 @@ export const getMergedSchema = (): GraphQLSchema =>
69
70
  export function writeGraphqlSchemaFile(apiSchema: GraphQLSchema) {
70
71
  try {
71
72
  writeFileSync(
72
- [process.cwd(), '@generated', 'graphql', 'schema.graphql'].join('/'),
73
+ path.join(process.cwd(), '@generated', 'graphql', 'schema.graphql'),
73
74
  printSchemaWithDirectives(apiSchema)
74
75
  )
75
76
 
@@ -13,7 +13,7 @@ import type {
13
13
  IconButtonProps,
14
14
  IconProps,
15
15
  ImageGalleryProps,
16
- ImageZoomProps,
16
+ ImageGalleryViewerProps,
17
17
  InputFieldProps,
18
18
  LinkButtonProps,
19
19
  NavbarButtonsProps,
@@ -40,6 +40,7 @@ import type {
40
40
  ComponentOverrideDefinition,
41
41
  SectionOverrideDefinition,
42
42
  } from './overrideDefinitionUtils'
43
+ import { NewsletterAddendumProps } from 'src/components/ui/Newsletter/NewsletterAddendum'
43
44
 
44
45
  export type SectionOverride =
45
46
  | AlertOverrideDefinition
@@ -164,6 +165,7 @@ export type NewsletterOverrideDefinition = SectionOverrideDefinition<
164
165
  Omit<InputFieldProps, 'inputRef'>
165
166
  >
166
167
  Button: ComponentOverrideDefinition<ButtonProps, ButtonProps>
168
+ __experimentalNewsletterAddendum: ComponentOverrideDefinition<NewsletterAddendumProps, NewsletterAddendumProps>
167
169
  }
168
170
  >
169
171
 
@@ -197,10 +199,14 @@ export type ProductDetailsOverrideDefinition = SectionOverrideDefinition<
197
199
  ImageGalleryProps,
198
200
  ImageGalleryProps
199
201
  >
200
- ImageZoom: ComponentOverrideDefinition<ImageZoomProps, ImageZoomProps>
202
+ ImageGalleryViewer: ComponentOverrideDefinition<
203
+ ImageGalleryViewerProps,
204
+ ImageGalleryViewerProps
205
+ >
201
206
  __experimentalImageGalleryImage: ComponentOverrideDefinition<any, any>
202
207
  __experimentalImageGallery: ComponentOverrideDefinition<any, any>
203
208
  __experimentalShippingSimulation: ComponentOverrideDefinition<any, any>
209
+ __experimentalNotAvailableButton: ComponentOverrideDefinition<any, any>
204
210
  }
205
211
  >
206
212
 
package/tsconfig.json CHANGED
@@ -13,7 +13,8 @@
13
13
  "allowJs": true,
14
14
  "paths": {
15
15
  "src/*": ["src/*"],
16
- "@generated/*": ["@generated/*"]
16
+ "@generated/*": ["@generated/*"],
17
+ "@faststore/core/experimental": ["src/experimental/index.ts"]
17
18
  },
18
19
  "forceConsistentCasingInFileNames": true,
19
20
  "strict": false,
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[148],{9767:function(e,t,r){var a=r(2784),n=r(5450);const c=(0,a.forwardRef)((function({value:e,as:t="span",variant:r="selling",testId:c="fs-price",formatter:i=(e=>e),SRText:s,...o},l){const u=i(e,r);return a.createElement(t,{ref:l,"data-fs-price":!0,"data-fs-price-variant":r,"data-testid":c,...o},s&&a.createElement(n.Z,{text:s}),u)}));t.Z=c},6148:function(e,t,r){r.r(t),r.d(t,{default:function(){return X}});var a=r(9499),n=r(4730),c=r(2784),i=r(101);const s=()=>{const e=(0,c.useContext)(i.c);return e?{inContext:!0,values:e}:{inContext:!1}},o=()=>{const{inContext:e,values:t}=s();return c.createElement(c.Fragment,null,e&&t.isLoading&&c.createElement("p",{"data-fs-search-dropdown-loading-text":!0},"Loading..."))};var l=(0,c.forwardRef)((function({testId:e="fs-search-dropdown",children:t,...r},a){return c.createElement("div",{ref:a,"data-fs-search-dropdown":!0,"data-testid":e,...r},c.createElement("section",null,c.createElement(o,null),t))})),u=r(4564);var d=({testId:e="fs-search-auto-complete",children:t,...r})=>{const{inContext:a,values:n}=s();return a&&(n.terms.length<=0||n.term.length<=0)?null:c.createElement("section",{"data-testid":e,"data-fs-search-auto-complete":!0,...r},c.createElement(u.Z,{as:"ol"},t))},f=r(2614),p=r(4272);var m=({testId:e="fs-search-auto-complete-term",suggestion:t,term:r,linkProps:a,icon:n=c.createElement(f.Z,{name:"MagnifyingGlass",width:18,height:18})})=>{const i=t.toLowerCase().split(r.toLowerCase());return c.createElement("li",{"data-fs-search-auto-complete-item":!0,"data-testid":e},c.createElement(p.Z,{...a,"data-fs-search-auto-complete-item-link":!0,variant:"display"},c.createElement("span",{"data-fs-search-auto-complete-item-icon":!0},n),c.createElement("p",null,i.map(((e,a)=>c.createElement(c.Fragment,{key:[e,a].join()},e.length>0&&c.createElement("strong",{"data-fs-search-auto-complete-item-suggestion":!0},0===a?e.charAt(0).toUpperCase()+e.slice(1):e),a!==i.length-1&&function(e,t,r){return 0===e?t.split("").map(((e,t)=>0===t&&0===r.indexOf(e.toUpperCase())?e.toUpperCase():e.toLowerCase())).join(""):t.toLowerCase()}(a,r,t)))))))};var h=({testId:e="fs-search-products",title:t="Suggested Products",children:r,...a})=>{const{inContext:n,values:i}=s();return n&&i.products.length<=0?null:c.createElement("section",{"data-testid":e,"data-fs-search-products":!0,...a},c.createElement("header",{"data-fs-search-products-header":!0},c.createElement("p",{"data-fs-search-products-title":!0},t)),c.createElement(u.Z,{as:"ol"},r))},v=r(3339);var g=({testId:e="fs-search-history",title:t="History",clearLabel:r="Clear History",onClear:a,children:n,...i})=>{const{inContext:o,values:l}=s();return o&&(0!==l.term.length||l.isLoading)?null:c.createElement("section",{"data-testid":e,"data-fs-search-history":!0,...i},c.createElement("header",{"data-fs-search-history-header":!0},c.createElement("p",{"data-fs-search-history-title":!0},t),c.createElement(v.Z,{variant:"tertiary",onClick:a,size:"small"},r)),c.createElement(u.Z,{as:"ol"},n))};var O=({testId:e="fs-search-history-term",value:t,linkProps:r,icon:a=c.createElement(f.Z,{name:"ClockClockwise",width:18,height:18})})=>c.createElement("li",{"data-fs-search-history-item":!0,"data-testid":e},c.createElement(p.Z,{...r,"data-fs-search-history-item-link":!0,variant:"display"},c.createElement("span",{"data-fs-search-history-item-icon":!0},a),c.createElement("span",null,t))),y=r(5098),b=r(2322);function j(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,a)}return r}function E(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?j(Object(r),!0).forEach((function(t){(0,a.Z)(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):j(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var P=e=>{var t=Object.assign({},e),{values:{onSearchSelection:r}}=s(),{searchHistory:a,clearSearchHistory:n}=(0,y.Z)();return a.length?(0,b.jsx)(g,E(E({title:"History",onClear:n},t),{},{children:a.map((e=>(0,b.jsx)(O,{value:e.term,linkProps:{href:e.path,onClick:()=>null===r||void 0===r?void 0:r(e.term,e.path)}},e.term)))})):null};var w=(0,c.forwardRef)((function({testId:e="fs-top-search",title:t="Top Search",children:r,...a},n){const{inContext:i,values:o}=s();return i&&(0!==o.term.length||o.isLoading)?null:c.createElement("section",{ref:n,"data-testid":e,"data-fs-search-top":!0,...a},c.createElement("header",{"data-fs-search-top-header":!0},c.createElement("p",{"data-fs-search-top-title":!0},t)),c.createElement(u.Z,{as:"ol"},r))})),k=r(276);var x=(0,c.forwardRef)((function({testId:e="fs-top-search-term",value:t,linkProps:r,index:a},n){return c.createElement("li",{ref:n,"data-fs-search-top-item":!0,"data-testid":e},c.createElement(p.Z,{...r,"data-fs-search-top-item-link":!0,variant:"display"},c.createElement(k.Z,{"data-fs-search-top-item-badge":!0,variant:"info"},a+1),t))})),C=r(5882),S=r(7732),Z=r(7295),D="TopSearchSuggestionsQuery";var _=function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5,{channel:a,locale:n}=(0,Z.kP)(),{data:c,error:i}=(0,S.aM)(D,{term:"",selectedFacets:[{key:"channel",value:null!==a&&void 0!==a?a:""},{key:"locale",value:n}]});return{terms:(null!==(e=null===c||void 0===c?void 0:c.search.suggestions.terms)&&void 0!==e?e:t).slice(0,r),isLoading:!i&&!c}},I=["topTerms","sort"];function L(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,a)}return r}function R(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?L(Object(r),!0).forEach((function(t){(0,a.Z)(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):L(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var T=function(e){var{topTerms:t,sort:r}=e,a=(0,n.Z)(e,I),{values:{onSearchSelection:c}}=s(),{terms:i}=_(t);return 0===i.length?null:(0,b.jsx)(w,R(R({title:"Top Search"},a),{},{children:i.map(((e,t)=>(0,b.jsx)(x,{value:e.value,index:t,linkProps:{href:(0,C.u)({term:e.value,sort:r}),onClick:()=>null===c||void 0===c?void 0:c(e.value,(0,C.u)({term:e.value,sort:r}))}},t)))}))};var F=(0,c.forwardRef)((function({testId:e="fs-search-product-item",linkProps:t,children:r},a){return c.createElement("li",{ref:a,"data-fs-search-product-item":!0,"data-testid":e},c.createElement(p.Z,{...t,"data-fs-search-product-item-link":!0,variant:"display"},r))}));var H=(0,c.forwardRef)((function({testId:e="fs-search-product-item-image",children:t,...r},a){return c.createElement("div",{ref:a,"data-fs-search-product-item-image":!0,"data-testid":e,...r},t)})),N=r(9767);var V=(0,c.forwardRef)((function({price:e,title:t,...r},a){return c.createElement("section",{ref:a,"data-fs-search-product-item-content":!0,...r},c.createElement("p",{"data-fs-search-product-item-title":!0},t),c.createElement("span",{"data-fs-search-product-item-prices":!0},c.createElement(N.Z,{value:e?.listPrice?e.listPrice:0,formatter:e?.formatter,testId:"list-price","data-value":e?.listPrice,variant:"listing",SRText:"Original price:"}),c.createElement(N.Z,{value:e?.value?e.value:0,formatter:e?.formatter,testId:"price","data-value":e?.value,variant:"spot",SRText:"Price:"})))})),G=r(9266),M=r(5346),U=r(9854),z=["product","index"],A=["href","onClick"];function Q(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,a)}return r}function q(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Q(Object(r),!0).forEach((function(t){(0,a.Z)(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Q(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var B=function(e){var{product:t,index:r}=e,a=(0,n.Z)(e,z),{values:{onSearchSelection:c}}=s(),i=(0,U.w)({product:t,selectedOffer:0,index:r}),{href:o,onClick:l}=i,u=(0,n.Z)(i,A),{isVariantOf:{name:d},image:[f],offers:{lowPrice:p,offers:[{listPrice:m}]}}=t,h=q({href:o,onClick:()=>{l(),null===c||void 0===c||c(d,o)}},u);return(0,b.jsxs)(F,q(q({linkProps:h},a),{},{children:[(0,b.jsx)(H,{children:(0,b.jsx)(G.E,{src:f.url,alt:f.alternateName,width:56,height:56})}),(0,b.jsx)(V,{title:d,price:{value:p,listPrice:m,formatter:M.P}})]}))},J=["sort"];function K(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,a)}return r}function W(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?K(Object(r),!0).forEach((function(t){(0,a.Z)(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):K(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var X=function(e){var{sort:t}=e,r=(0,n.Z)(e,J),{values:{onSearchSelection:a,products:c,term:i,terms:o}}=s();return(0,b.jsxs)(l,W(W({},r),{},{children:[(0,b.jsx)(P,{sort:t}),(0,b.jsx)(T,{sort:t}),(0,b.jsx)(d,{children:null===o||void 0===o?void 0:o.map((e=>{var{value:r}=e;return(0,b.jsx)(m,{term:i,suggestion:r,linkProps:{href:(0,C.u)({term:r,sort:t}),onClick:()=>null===a||void 0===a?void 0:a(r,(0,C.u)({term:r,sort:t}))}},r)}))}),(0,b.jsx)(h,{children:c.map(((e,t)=>{var r=e;return(0,b.jsx)(B,{product:r,index:t},r.id)}))})]}))}},5346:function(e,t,r){r.d(t,{P:function(){return c}});var a=r(2784),n=r(7295),c=e=>{var t=function(){var{decimals:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{currency:t,locale:r}=(0,n.kP)();return(0,a.useCallback)((a=>Intl.NumberFormat(r,{style:"currency",currency:t.code,minimumFractionDigits:e?2:0}).format(a)),[t.code,r,e])}();return(0,a.useMemo)((()=>t(e)),[t,e])}},9854:function(e,t,r){r.d(t,{w:function(){return i}});var a=r(1072),n=r(2784),c=r(7295),i=e=>{var{index:t,product:r,selectedOffer:i}=e,{slug:s}=r,{currency:{code:o}}=(0,c.kP)(),l=(0,n.useCallback)((()=>{(0,a._)({name:"select_item",params:{items:[{item_id:r.isVariantOf.productGroupID,item_name:r.isVariantOf.name,item_brand:r.brand.name,item_variant:r.sku,index:t,price:r.offers.offers[i].price,discount:r.offers.offers[i].listPrice-r.offers.offers[i].price,currency:o,item_variant_name:r.name,product_reference_id:r.gtin}]}}),(0,a._)({name:"search_select_item",params:{url:window.location.href,items:[{item_id:r.isVariantOf.productGroupID,item_variant:r.sku,index:t}]}})}),[o,r,t,i]);return{href:"/".concat(s,"/p"),onClick:l,"data-testid":"product-link"}}}}]);