@faststore/core 3.0.56 → 3.0.58
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.next/BUILD_ID +1 -1
- package/.next/app-build-manifest.json +4 -4
- package/.next/build-manifest.json +31 -31
- package/.next/cache/.tsbuildinfo +1 -1
- package/.next/cache/config.json +3 -3
- package/.next/cache/eslint/.cache_1gneedd +1 -1
- package/.next/cache/fetch-cache/50912854cb7c781522a6ff8792d714e549515fcbbbfd660761961b06afe01c07 +1 -1
- package/.next/cache/webpack/client-production/0.pack +0 -0
- package/.next/cache/webpack/client-production/index.pack +0 -0
- package/.next/cache/webpack/server-production/0.pack +0 -0
- package/.next/cache/webpack/server-production/index.pack +0 -0
- package/.next/next-minimal-server.js.nft.json +1 -1
- package/.next/next-server.js.nft.json +1 -1
- package/.next/prerender-manifest.js +1 -1
- package/.next/prerender-manifest.json +1 -1
- package/.next/react-loadable-manifest.json +3 -3
- package/.next/routes-manifest.json +1 -1
- package/.next/server/app/_not-found.html +2 -2
- package/.next/server/app/_not-found.js +1 -1
- package/.next/server/app/_not-found.js.nft.json +1 -1
- package/.next/server/app/_not-found.rsc +4 -4
- package/.next/server/app/_not-found_client-reference-manifest.js +1 -1
- package/.next/server/app/fs-next-update/page.js +1 -1
- package/.next/server/app/fs-next-update/page.js.nft.json +1 -1
- package/.next/server/app/fs-next-update/page_client-reference-manifest.js +1 -1
- package/.next/server/app/fs-next-update.html +2 -2
- package/.next/server/app/fs-next-update.rsc +4 -4
- package/.next/server/chunks/1481.js +2 -2
- package/.next/server/chunks/{1889.js → 2317.js} +2 -2
- package/.next/server/middleware-build-manifest.js +1 -1
- package/.next/server/middleware-react-loadable-manifest.js +1 -1
- package/.next/server/pages/404.html +2 -2
- package/.next/server/pages/404.js.nft.json +1 -1
- package/.next/server/pages/500.js.nft.json +1 -1
- package/.next/server/pages/[...slug].js.nft.json +1 -1
- package/.next/server/pages/[slug]/p.js +4 -4
- package/.next/server/pages/[slug]/p.js.nft.json +1 -1
- package/.next/server/pages/_app.js.nft.json +1 -1
- package/.next/server/pages/_document.js.nft.json +1 -1
- package/.next/server/pages/_error.js.nft.json +1 -1
- package/.next/server/pages/account.js.nft.json +1 -1
- package/.next/server/pages/api/graphql.js.nft.json +1 -1
- package/.next/server/pages/api/health/live.js.nft.json +1 -1
- package/.next/server/pages/api/health/ready.js.nft.json +1 -1
- package/.next/server/pages/api/preview.js.nft.json +1 -1
- package/.next/server/pages/checkout.js.nft.json +1 -1
- package/.next/server/pages/en-US/404.html +2 -2
- package/.next/server/pages/en-US/404.json +1 -1
- package/.next/server/pages/en-US/500.html +2 -2
- package/.next/server/pages/en-US/500.json +1 -1
- package/.next/server/pages/en-US/account.html +2 -2
- package/.next/server/pages/en-US/account.json +1 -1
- package/.next/server/pages/en-US/checkout.html +2 -2
- package/.next/server/pages/en-US/checkout.json +1 -1
- package/.next/server/pages/en-US/login.html +2 -2
- package/.next/server/pages/en-US/login.json +1 -1
- package/.next/server/pages/en-US/s.html +2 -2
- package/.next/server/pages/en-US/s.json +1 -1
- package/.next/server/pages/en-US.html +2 -2
- package/.next/server/pages/en-US.json +1 -1
- package/.next/server/pages/index.js.nft.json +1 -1
- package/.next/server/pages/login.js.nft.json +1 -1
- package/.next/server/pages/s.js.nft.json +1 -1
- package/.next/server/pages-manifest.json +1 -1
- package/.next/static/2K9MWkRja381SNNuLNTU8/_buildManifest.js +1 -0
- package/.next/static/chunks/{432-2a9341d243613db4.js → 432-ea0bb3dcebbaab7b.js} +1 -1
- package/.next/static/chunks/{590-a0b6f16148203bf2.js → 590-2e7ce772420d1e1a.js} +1 -1
- package/.next/static/chunks/{667.83389641ca332aef.js → 667.2cacb6e5980b1219.js} +1 -1
- package/.next/static/chunks/{722-ed59bc6f32bb342f.js → 722-36fe06b9c486056e.js} +1 -1
- package/.next/static/chunks/{724.78d40a7affe1d40b.js → 724.39212f642dc0d0bf.js} +1 -1
- package/.next/static/chunks/{853.a3933410052d23c8.js → 853.50e13fd0510fbf80.js} +1 -1
- package/.next/static/chunks/app/{layout-91b2430897aac937.js → layout-aa18388c0586ed1f.js} +2 -2
- package/.next/static/chunks/pages/[slug]/p-25a61a48b78901e5.js +1 -0
- package/.next/static/chunks/pages/{_app-1930798899758fda.js → _app-00cee674a20813ff.js} +1 -1
- package/.next/static/chunks/{webpack-a45dc84c9a0ef3fd.js → webpack-d7ccbda472189c19.js} +1 -1
- package/.next/trace +62 -62
- package/.turbo/turbo-build.log +6 -6
- package/.turbo/turbo-test.log +5 -19
- package/package.json +3 -3
- package/src/components/sections/ProductDetails/DefaultComponents.ts +2 -0
- package/src/components/sections/ProductDetails/ProductDetails.tsx +8 -4
- package/src/server/cms/index.ts +70 -4
- package/src/typings/overrides.ts +1 -0
- package/test/server/cms/index.test.ts +95 -0
- package/.next/static/YVsdypyAbd7fqsNOnAbXQ/_buildManifest.js +0 -1
- package/.next/static/chunks/pages/[slug]/p-542d088f5d009ce8.js +0 -1
- /package/.next/static/{YVsdypyAbd7fqsNOnAbXQ → 2K9MWkRja381SNNuLNTU8}/_ssgManifest.js +0 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
$ yarn partytown & yarn generate && next build
|
|
2
|
+
$ faststore generate-graphql -c
|
|
2
3
|
$ partytown copylib ./public/~partytown
|
|
3
4
|
Partytown lib copied to: /home/runner/work/faststore/faststore/packages/core/public/~partytown
|
|
4
|
-
$ faststore generate-graphql -c
|
|
5
5
|
success - GraphQL schema, types, and optimizations successfully generated 🎉
|
|
6
6
|
⚠ No build cache found. Please configure build caching for faster rebuilds. Read more: https://nextjs.org/docs/messages/no-cache
|
|
7
7
|
Attention: Next.js now collects completely anonymous telemetry regarding usage.
|
|
@@ -24,8 +24,8 @@ Browserslist: caniuse-lite is outdated. Please run:
|
|
|
24
24
|
Collecting page data ...
|
|
25
25
|
Generating static pages (0/9) ...
|
|
26
26
|
|
|
27
27
|
Generating static pages (2/9)
|
|
28
|
-
|
|
29
28
|
Generating static pages (4/9)
|
|
30
29
|
Warning: Dynamic Content not found for the page: home. Refer to the Dynamic Content documentation at https://developers.vtex.com/docs/guides/faststore/dynamic-content-overview for mapping the page and the corresponding data-fetching function.
|
|
30
|
+
|
|
31
31
|
Generating static pages (4/9)
|
|
32
32
|
|
|
33
33
|
Generating static pages (6/9)
|
|
34
34
|
|
|
35
35
|
✓ Generating static pages (9/9)
|
|
36
36
|
Finalizing page optimization ...
|
|
@@ -38,7 +38,7 @@ Route (app) Size First Load JS
|
|
|
38
38
|
├ chunks/472-369461a1f39981d5.js 28.4 kB
|
|
39
39
|
├ chunks/fd9d1056-43c43818840d7811.js 51.1 kB
|
|
40
40
|
├ chunks/main-app-e13fa67c2c3ceca5.js 230 B
|
|
41
|
-
└ chunks/webpack-
|
|
41
|
+
└ chunks/webpack-d7ccbda472189c19.js 2.43 kB
|
|
42
42
|
|
|
43
43
|
Route (pages) Size First Load JS
|
|
44
44
|
┌ ● / 1.04 kB 148 kB
|
|
@@ -46,7 +46,7 @@ Route (pages) Size First Load JS
|
|
|
46
46
|
├ /_app 0 B 93.8 kB
|
|
47
47
|
├ ● /[...slug] 2.66 kB 160 kB
|
|
48
48
|
├ └ css/3eed8d7ed5000eb8.css 2.4 kB
|
|
49
|
-
├ ● /[slug]/p 10.
|
|
49
|
+
├ ● /[slug]/p 10.9 kB 158 kB
|
|
50
50
|
├ └ css/65f6dd6d16812461.css 9.49 kB
|
|
51
51
|
├ ○ /404 1.17 kB 131 kB
|
|
52
52
|
├ ● /500 1.17 kB 131 kB
|
|
@@ -61,8 +61,8 @@ Route (pages) Size First Load JS
|
|
|
61
61
|
+ First Load JS shared by all 96.9 kB
|
|
62
62
|
├ chunks/framework-21e9365486ba23a6.js 45.4 kB
|
|
63
63
|
├ chunks/main-9c9c62c368c0a47e.js 34.8 kB
|
|
64
|
-
├ chunks/pages/_app-
|
|
65
|
-
├ chunks/webpack-
|
|
64
|
+
├ chunks/pages/_app-00cee674a20813ff.js 11.2 kB
|
|
65
|
+
├ chunks/webpack-d7ccbda472189c19.js 2.43 kB
|
|
66
66
|
└ css/5d1f64b61ea581f4.css 3.05 kB
|
|
67
67
|
|
|
68
68
|
λ (Server) server-side renders at runtime (uses getInitialProps or getServerSideProps)
|
package/.turbo/turbo-test.log
CHANGED
|
@@ -1,23 +1,9 @@
|
|
|
1
1
|
$ jest
|
|
2
|
-
PASS test/server/index.test.ts (
|
|
3
|
-
|
|
4
|
-
@faststore/api
|
|
5
|
-
✓ should return a valid GraphQL schema (6 ms)
|
|
6
|
-
✓ should return a valid GraphQL schema contain all expected types (7 ms)
|
|
7
|
-
✓ should return a valid GraphQL schema contain all expected queries (2 ms)
|
|
8
|
-
✓ should return a valid GraphQL schema contain all expected mutations
|
|
9
|
-
VTEX API Extension
|
|
10
|
-
✓ getTypeDefsFromFolder function should return an Array (8 ms)
|
|
11
|
-
Third Party API Extension
|
|
12
|
-
✓ getTypeDefsFromFolder function should return an Array (7 ms)
|
|
13
|
-
Final Schema after merging
|
|
14
|
-
✓ should return a valid merged GraphQL schema (31 ms)
|
|
15
|
-
Envelop
|
|
16
|
-
✓ should exist with its plugins (29 ms)
|
|
17
|
-
✓ should handle options and execute (138 ms)
|
|
2
|
+
PASS test/server/cms/index.test.ts (28.539 s)
|
|
3
|
+
PASS test/server/index.test.ts (30.283 s)
|
|
18
4
|
|
|
19
|
-
Test Suites:
|
|
20
|
-
Tests:
|
|
5
|
+
Test Suites: 2 passed, 2 total
|
|
6
|
+
Tests: 12 passed, 12 total
|
|
21
7
|
Snapshots: 0 total
|
|
22
|
-
Time:
|
|
8
|
+
Time: 31.156 s
|
|
23
9
|
Ran all test suites.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faststore/core",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.58",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": "vtex/faststore",
|
|
6
6
|
"browserslist": "supports es6-module and not dead",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"css-loader": "^6.7.1",
|
|
63
63
|
"deepmerge": "^4.3.1",
|
|
64
64
|
"draftjs-to-html": "^0.9.1",
|
|
65
|
-
"graphql": "^15.
|
|
65
|
+
"graphql": "^15.6.0",
|
|
66
66
|
"include-media": "^1.4.10",
|
|
67
67
|
"next": "^13.5.6",
|
|
68
68
|
"next-seo": "^6.4.0",
|
|
@@ -125,5 +125,5 @@
|
|
|
125
125
|
"node": "18.19.0",
|
|
126
126
|
"yarn": "1.19.1"
|
|
127
127
|
},
|
|
128
|
-
"gitHead": "
|
|
128
|
+
"gitHead": "e1f415c74cfb74de617dc85669792439a1e6be29"
|
|
129
129
|
}
|
|
@@ -15,6 +15,7 @@ import LocalImageGallery from 'src/components/ui/ImageGallery'
|
|
|
15
15
|
import LocalShippingSimulation from 'src/components/ui/ShippingSimulation/ShippingSimulation'
|
|
16
16
|
import { Image } from 'src/components/ui/Image'
|
|
17
17
|
import LocalNotAvailableButton from 'src/components/product/NotAvailableButton'
|
|
18
|
+
import LocalProductDescription from 'src/components/ui/ProductDescription'
|
|
18
19
|
|
|
19
20
|
export const ProductDetailsDefaultComponents = {
|
|
20
21
|
ProductTitle: UIProductTitle,
|
|
@@ -31,4 +32,5 @@ export const ProductDetailsDefaultComponents = {
|
|
|
31
32
|
__experimentalImageGallery: LocalImageGallery,
|
|
32
33
|
__experimentalShippingSimulation: LocalShippingSimulation,
|
|
33
34
|
__experimentalNotAvailableButton: LocalNotAvailableButton,
|
|
35
|
+
__experimentalProductDescription: LocalProductDescription,
|
|
34
36
|
}
|
|
@@ -8,7 +8,6 @@ import type { AnalyticsItem } from 'app/sdk/analytics/types'
|
|
|
8
8
|
import { useFormattedPrice } from 'src/sdk/product/useFormattedPrice'
|
|
9
9
|
import { useSession } from 'src/sdk/session'
|
|
10
10
|
|
|
11
|
-
import ProductDescription from '../../../components/ui/ProductDescription'
|
|
12
11
|
import { ProductDetailsSettings } from '../../../components/ui/ProductDetails'
|
|
13
12
|
import Section from '../Section'
|
|
14
13
|
|
|
@@ -82,6 +81,7 @@ function ProductDetails({
|
|
|
82
81
|
__experimentalImageGallery: ImageGallery,
|
|
83
82
|
__experimentalShippingSimulation: ShippingSimulation,
|
|
84
83
|
__experimentalNotAvailableButton: NotAvailableButton,
|
|
84
|
+
__experimentalProductDescription: ProductDescription,
|
|
85
85
|
} = useOverrideComponents<'ProductDetails'>()
|
|
86
86
|
const { currency } = useSession()
|
|
87
87
|
const context = usePDP()
|
|
@@ -230,11 +230,15 @@ function ProductDetails({
|
|
|
230
230
|
</section>
|
|
231
231
|
|
|
232
232
|
{shouldDisplayProductDescription && (
|
|
233
|
-
<ProductDescription
|
|
234
|
-
initiallyExpanded={
|
|
233
|
+
<ProductDescription.Component
|
|
234
|
+
initiallyExpanded={
|
|
235
|
+
productDescriptionInitiallyExpanded ??
|
|
236
|
+
ProductDescription.props.initiallyExpanded
|
|
237
|
+
}
|
|
235
238
|
descriptionData={[
|
|
236
|
-
{
|
|
239
|
+
{ content: description, title: productDescriptionDetailsTitle },
|
|
237
240
|
]}
|
|
241
|
+
{...ProductDescription.props}
|
|
238
242
|
/>
|
|
239
243
|
)}
|
|
240
244
|
</section>
|
package/src/server/cms/index.ts
CHANGED
|
@@ -5,6 +5,14 @@ import MissingContentError from 'src/sdk/error/MissingContentError'
|
|
|
5
5
|
import MultipleContentError from 'src/sdk/error/MultipleContentError'
|
|
6
6
|
import config from '../../../faststore.config'
|
|
7
7
|
|
|
8
|
+
type Cache<T> = {
|
|
9
|
+
[key: string]: { data: Array<T> }
|
|
10
|
+
}
|
|
11
|
+
type ExtraOptions = {
|
|
12
|
+
cmsClient?: ClientCMS
|
|
13
|
+
cache?: Cache<ContentData>
|
|
14
|
+
}
|
|
15
|
+
|
|
8
16
|
export type Options =
|
|
9
17
|
| Locator
|
|
10
18
|
| {
|
|
@@ -45,10 +53,68 @@ export const clientCMS = new ClientCMS({
|
|
|
45
53
|
tenant: config.api.storeId,
|
|
46
54
|
})
|
|
47
55
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
56
|
+
/*
|
|
57
|
+
* This in memory cache exists because for each page (think category or department)
|
|
58
|
+
* we are fetching all the pages of the same content type from the headless CMS to
|
|
59
|
+
* find the one that matches the slug.
|
|
60
|
+
*
|
|
61
|
+
* So instead of making multiple request for the Headless CMS API for each page we make
|
|
62
|
+
* one for each content-type and reuse the results for the next page.
|
|
63
|
+
*
|
|
64
|
+
* Since we rebuild on a CMS publication the server will go away and will "invalidate"
|
|
65
|
+
* the cache
|
|
66
|
+
*/
|
|
67
|
+
const getCMSPageCache = {}
|
|
68
|
+
|
|
69
|
+
export const getCMSPage = async (
|
|
70
|
+
options: Options,
|
|
71
|
+
extraOptions?: ExtraOptions
|
|
72
|
+
) => {
|
|
73
|
+
const cmsClient = extraOptions?.cmsClient ?? clientCMS
|
|
74
|
+
const cache = extraOptions?.cache ?? getCMSPageCache
|
|
75
|
+
|
|
76
|
+
if (isLocator(options)) {
|
|
77
|
+
return await cmsClient
|
|
78
|
+
.getCMSPage(options)
|
|
79
|
+
.then((page) => ({ data: [page] }))
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (!cache[options.contentType]) {
|
|
83
|
+
const pages = []
|
|
84
|
+
let page = 1
|
|
85
|
+
const perPage = 10
|
|
86
|
+
const response = await cmsClient.getCMSPagesByContentType(
|
|
87
|
+
options.contentType,
|
|
88
|
+
{ ...options.filters, page: page, perPage }
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
pages.push(...response.data)
|
|
92
|
+
|
|
93
|
+
const totalPagesToFetch = Math.ceil(response.totalItems / perPage) // How many pages have content
|
|
94
|
+
const pagesToFetch = Array.from(
|
|
95
|
+
{ length: totalPagesToFetch - 1 }, // We want all those pages minus the first one that we fetched
|
|
96
|
+
(_, i) => i + 2 // + 1 because indices are 0 based, and + 1 because we already fetched the first
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
if (response.totalItems > pages.length) {
|
|
100
|
+
const restOfPages = await Promise.all(
|
|
101
|
+
pagesToFetch.map((i) =>
|
|
102
|
+
cmsClient.getCMSPagesByContentType(options.contentType, {
|
|
103
|
+
...options.filters,
|
|
104
|
+
page: i,
|
|
105
|
+
perPage,
|
|
106
|
+
})
|
|
107
|
+
)
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
restOfPages.forEach((response) => {
|
|
111
|
+
pages.push(...response.data)
|
|
112
|
+
})
|
|
113
|
+
}
|
|
114
|
+
cache[options.contentType] = { data: pages }
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return cache[options.contentType]
|
|
52
118
|
}
|
|
53
119
|
|
|
54
120
|
export const getPage = async <T extends ContentData>(options: Options) => {
|
package/src/typings/overrides.ts
CHANGED
|
@@ -272,6 +272,7 @@ export type SectionsOverrides = {
|
|
|
272
272
|
__experimentalImageGallery: ComponentOverrideDefinition<any, any>
|
|
273
273
|
__experimentalShippingSimulation: ComponentOverrideDefinition<any, any>
|
|
274
274
|
__experimentalNotAvailableButton: ComponentOverrideDefinition<any, any>
|
|
275
|
+
__experimentalProductDescription: ComponentOverrideDefinition<any, any>
|
|
275
276
|
}
|
|
276
277
|
}
|
|
277
278
|
ProductGallery: {
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { clientCMS, getCMSPage } from '../../../src/server/cms'
|
|
2
|
+
import { jest } from '@jest/globals'
|
|
3
|
+
import { ContentData } from '@vtex/client-cms'
|
|
4
|
+
|
|
5
|
+
describe('CMS Integration', () => {
|
|
6
|
+
const mockData = (count = 1) => {
|
|
7
|
+
const data: ContentData[] = []
|
|
8
|
+
for (let i = 0; i < count; i = i + 1) {
|
|
9
|
+
data.push({
|
|
10
|
+
id: `data-id-${i}`,
|
|
11
|
+
name: `data-name-${i}`,
|
|
12
|
+
status: `data-status-${i}`,
|
|
13
|
+
type: `data-type-${i}`,
|
|
14
|
+
sections: [],
|
|
15
|
+
releaseId: `release-${i}`,
|
|
16
|
+
})
|
|
17
|
+
}
|
|
18
|
+
return data
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
describe('getCMSPage', () => {
|
|
22
|
+
it('returns the first page if there is only one page', async () => {
|
|
23
|
+
const mockFunction = jest.fn(() => {
|
|
24
|
+
return Promise.resolve({
|
|
25
|
+
data: mockData(3),
|
|
26
|
+
hasNextPage: false,
|
|
27
|
+
totalItems: 3,
|
|
28
|
+
})
|
|
29
|
+
})
|
|
30
|
+
clientCMS.getCMSPagesByContentType = mockFunction
|
|
31
|
+
|
|
32
|
+
const result = await getCMSPage(
|
|
33
|
+
{ contentType: 'plp' },
|
|
34
|
+
{ cmsClient: clientCMS }
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
expect(mockFunction.mock.calls.length).toBe(1)
|
|
38
|
+
expect(result.data.length).toBe(3)
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
it('loads multiple pages', async () => {
|
|
42
|
+
const mockFunction: jest.Mock<typeof clientCMS.getCMSPagesByContentType> =
|
|
43
|
+
jest.fn()
|
|
44
|
+
|
|
45
|
+
mockFunction.mockImplementationOnce(() => {
|
|
46
|
+
return Promise.resolve({
|
|
47
|
+
data: mockData(10),
|
|
48
|
+
hasNextPage: true,
|
|
49
|
+
totalItems: 15,
|
|
50
|
+
})
|
|
51
|
+
})
|
|
52
|
+
mockFunction.mockImplementationOnce(() => {
|
|
53
|
+
return Promise.resolve({
|
|
54
|
+
data: mockData(5),
|
|
55
|
+
hasNextPage: false,
|
|
56
|
+
totalItems: 15,
|
|
57
|
+
})
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
clientCMS.getCMSPagesByContentType = mockFunction
|
|
61
|
+
|
|
62
|
+
const result = await getCMSPage(
|
|
63
|
+
{ contentType: 'plp' },
|
|
64
|
+
{ cmsClient: clientCMS, cache: {} }
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
expect(mockFunction.mock.calls.length).toBe(2)
|
|
68
|
+
expect(result.data.length).toBe(15)
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
it('it makes no request if the cache is filled', async () => {
|
|
72
|
+
const mockFunction: jest.Mock<typeof clientCMS.getCMSPagesByContentType> =
|
|
73
|
+
jest.fn()
|
|
74
|
+
|
|
75
|
+
mockFunction.mockImplementationOnce(() => {
|
|
76
|
+
return Promise.resolve({
|
|
77
|
+
data: mockData(10),
|
|
78
|
+
hasNextPage: true,
|
|
79
|
+
totalItems: 15,
|
|
80
|
+
})
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
clientCMS.getCMSPagesByContentType = mockFunction
|
|
84
|
+
|
|
85
|
+
const cache = { plp: { data: [] } }
|
|
86
|
+
const result = await getCMSPage(
|
|
87
|
+
{ contentType: 'plp' },
|
|
88
|
+
{ cmsClient: clientCMS, cache: cache }
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
expect(mockFunction.mock.calls.length).toBe(0)
|
|
92
|
+
expect(result.data.length).toBe(0)
|
|
93
|
+
})
|
|
94
|
+
})
|
|
95
|
+
})
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
self.__BUILD_MANIFEST=function(s,c,a,t,e,f,d,i){return{__rewrites:{afterFiles:[],beforeFiles:[],fallback:[]},"/":[s,c,a,t,e,"static/css/fa6d43e3c11a59dc.css","static/chunks/pages/index-86dd2dba6f6f1621.js"],"/404":[s,c,a,f,"static/chunks/pages/404-be2217109dab18cf.js"],"/500":[s,c,a,f,"static/chunks/pages/500-64a07a16830e129c.js"],"/_error":["static/chunks/pages/_error-65ac7445167ddb62.js"],"/account":[s,c,a,"static/chunks/pages/account-70e52900601fc5eb.js"],"/checkout":[s,c,a,"static/chunks/pages/checkout-fe8c38b138ddecef.js"],"/login":[s,c,a,f,"static/chunks/pages/login-258e5b7ecec36481.js"],"/s":[s,c,a,t,e,d,i,"static/chunks/pages/s-53cc10ba9aa8331e.js"],"/[slug]/p":[s,c,a,t,e,"static/css/65f6dd6d16812461.css","static/chunks/pages/[slug]/p-542d088f5d009ce8.js"],"/[...slug]":[s,c,a,t,e,d,i,"static/css/3eed8d7ed5000eb8.css","static/chunks/pages/[...slug]-12c6dd879f1da8e0.js"],sortedPages:["/","/404","/500","/_app","/_error","/account","/checkout","/login","/s","/[slug]/p","/[...slug]"]}}("static/chunks/470-a762f2bf2d218abf.js","static/css/25261a033e496803.css","static/chunks/432-2a9341d243613db4.js","static/css/548bab931c45c770.css","static/chunks/590-a0b6f16148203bf2.js","static/css/ec44b650be144ada.css","static/css/185f3332f3d0db64.css","static/chunks/722-ed59bc6f32bb342f.js"),self.__BUILD_MANIFEST_CB&&self.__BUILD_MANIFEST_CB();
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[103],{6693:function(e,t,n){"use strict";var r=n(2784),a=n(7041),i=n(2614),l=n(2256);t.Z=({max:e,min:t=1,unitMultiplier:n=1,useUnitMultiplier:o,initial:s,disabled:d=!1,onChange:u,testId:c="fs-quantity-selector",...p})=>{let[m,f]=(0,r.useState)(s??t),[g,v]=(0,r.useState)(m*n),roundUpQuantityIfNeeded=e=>o?Math.ceil(e/n)*n:e,h=m===t,b=m===e,changeQuantity=e=>{let t=validateQuantityBounds(m+e);u?.(t),f(t),v(t*n)};function validateQuantityBounds(r){let a=t?Math.max(r,t):r;return e?Math.min(a,o?e*n:e):a}return(0,r.useEffect)(()=>{s&&f(s)},[s]),r.createElement("div",{"data-fs-quantity-selector":d?"disabled":"true","data-testid":c,...p},r.createElement(a.Z,{"data-quantity-selector-button":"left",icon:r.createElement(i.Z,{name:"Minus",width:16,height:16,weight:"bold"}),"aria-label":"Decrement Quantity","aria-controls":"quantity-selector-input",disabled:h||d,onClick:()=>changeQuantity(-1),testId:`${c}-left-button`,size:"small"}),r.createElement(l.Z,{"data-quantity-selector-input":!0,id:"quantity-selector-input","aria-label":"Quantity",value:o?g:m,onChange:function(e){let t=e.currentTarget.value;Number.isNaN(Number(t))||f(()=>{let e=validateQuantityBounds(Number(t));return v(e),u?.(e),e})},onBlur:function(){let e=roundUpQuantityIfNeeded(m);f(()=>(v(e),u?.(e/n),e/n))},disabled:d}),r.createElement(a.Z,{"data-quantity-selector-button":"right","aria-controls":"quantity-selector-input","aria-label":"Increment Quantity",disabled:b||d,icon:r.createElement(i.Z,{name:"Plus",width:16,height:16,weight:"bold"}),onClick:()=>changeQuantity(1),testId:`${c}-right-button`,size:"small"}))}},6258:function(e,t,n){(window.__NEXT_P=window.__NEXT_P||[]).push(["/[slug]/p",function(){return n(4961)}])},536:function(e,t,n){"use strict";n.d(t,{j:function(){return I}});var r=n(7460),a=n(6692),i=n(6877),l=n(4761),o=n(4195),s=n(2322),d=n(2784),u=n(9035),c=n(7944),p=n.n(c),m=n(5114),f=n(8134),g=n(2614),v=n(727);let h=(0,d.createContext)({isOpen:!1,dropdownButtonRef:null,selectedDropdownItemIndexRef:null,dropdownItemsRef:null,id:"fs-dropdown"});var Dropdown_Dropdown=({children:e,isOpen:t=!1,onDismiss:n,id:r="fs-dropdown"})=>{let[a,i]=(0,d.useState)(t),l=(0,d.useRef)([]),o=(0,d.useRef)(0),s=(0,d.useRef)(null),u=(0,d.useCallback)(()=>{i(!1),n?.()},[n]),open=()=>{i(!0)},c=(0,d.useCallback)(()=>{i(e=>(e&&(n?.(),s.current?.focus()),!e))},[n]);(0,d.useEffect)(()=>{i(t)},[t]),(0,d.useEffect)(()=>{a&&l?.current[0]?.focus()},[a]),(0,d.useEffect)(()=>{let e=!0,event=t=>{let n=l?.current.some(e=>t.target===e);if(e){e=!1;return}n||u()};return a?document.addEventListener("click",event):document.removeEventListener("click",event),()=>{document.removeEventListener("click",event)}},[u,a]);let p=(0,d.useMemo)(()=>({isOpen:a,close:u,open,toggle:c,dropdownButtonRef:s,onDismiss:n,selectedDropdownItemIndexRef:o,dropdownItemsRef:l,id:r}),[u,r,a,n,c]);return d.createElement(h.Provider,{value:p},e)},b=n(3339);let useDropdown=()=>{let e=(0,d.useContext)(h);if(void 0===e)throw Error("Do not use useDropdown hook outside the Dropdown context.");return e},y=(0,d.forwardRef)(function({testId:e="fs-dropdown-button","aria-label":t,children:n,...r},a){let{toggle:i,dropdownButtonRef:l,isOpen:o,id:s}=useDropdown();return(0,d.useImperativeHandle)(a,()=>l.current,[l]),d.createElement(b.Z,{"data-fs-dropdown-button":!0,onClick:i,"data-testid":e,ref:l,"aria-label":t,"aria-expanded":o,"aria-haspopup":"menu","aria-controls":s,variant:"tertiary",...r},n)});var _=n(8316);let useDropdownPosition=()=>{let{dropdownButtonRef:e}=useDropdown(),t="undefined"!=typeof window,n=e?.current?.getBoundingClientRect(),r=n?.top??0,a=n?.height??0,i=n?.left??0,l=t?document?.documentElement?.scrollTop:0,o=t?document?.documentElement?.scrollLeft:0;return{position:"absolute",top:r+a+l,left:i+o}};var Dropdown_DropdownMenu=({children:e,testId:t="fs-dropdown-menu",size:n="regular",style:r,...a})=>{let{isOpen:i,close:l,dropdownItemsRef:o,selectedDropdownItemIndexRef:s,dropdownButtonRef:u,id:c}=useDropdown(),p=useDropdownPosition(),m=d.Children.toArray(e).length,handleDownPress=()=>{s.current<m-1?s.current++:s.current=0,o?.current[s.current]?.focus()},handleUpPress=()=>{s.current>0?s.current--:s.current=m-1,o?.current[s.current]?.focus()},handleHomePress=()=>{s.current=0,o?.current[s.current]?.focus()},handleEndPress=()=>{s.current=m-1,o?.current[s.current]?.focus()},handleEscapePress=()=>{l?.(),u?.current?.focus()};return i?(0,_.createPortal)(d.createElement("div",{role:"presentation","data-fs-dropdown-overlay":!0,onKeyDown:e=>{e.defaultPrevented||"Enter"===e.key||(e.preventDefault(),"Escape"===e.key&&handleEscapePress(),"ArrowDown"===e.key&&handleDownPress(),"ArrowUp"===e.key&&handleUpPress(),"Home"===e.key&&handleHomePress(),"End"===e.key&&handleEndPress(),e.stopPropagation())},"data-testid":`${t}-overlay`},d.createElement("div",{role:"menu","aria-orientation":"vertical","data-fs-dropdown-menu":!0,"data-fs-dropdown-menu-size":n,"data-testid":t,style:{...p,...r},id:c,...a},e)),document.body):(o.current=[],null)};let E=(0,d.forwardRef)(function({children:e,icon:t,onClick:n,testId:r="fs-dropdown-item",...a},i){let{dropdownItemsRef:l,selectedDropdownItemIndexRef:o,close:s}=useDropdown(),[u,c]=(0,d.useState)(0),p=(0,d.useRef)(),onFocusItem=()=>{o.current=u,l?.current[o.current]?.focus()};return(0,d.useImperativeHandle)(i,()=>p.current,[]),d.createElement("button",{"data-fs-dropdown-item":!0,"data-testid":r,ref:e=>{e&&!l?.current.includes(e)&&(l?.current.push(e),c(l?.current.findIndex(t=>t===e)??0)),p.current=e},onFocus:onFocusItem,onMouseEnter:onFocusItem,onClick:e=>{n?.(e),s?.()},role:"menuitem",tabIndex:-1,"data-index":u,...a},!!t&&t,e)});var w=n(4564),Breadcrumb_Divider=({divider:e,testId:t})=>{let n={"data-fs-breadcrumb-divider":!0,"aria-hidden":!0,"data-testid":`${t}-divider`};return d.isValidElement(e)?d.cloneElement(e,n):d.createElement("span",{...n},e??"/")},Breadcrumb_ListItem=({children:e,isLastItem:t,divider:n,testId:r})=>{let a={"data-testid":`${r}-item`,"data-fs-breadcrumb-item":!t||"current","aria-current":t?"page":void 0};return d.isValidElement(e)?d.createElement("li",{"data-fs-breadcrumb-list-item":!0},d.cloneElement(e,a),t?null:d.createElement(Breadcrumb_Divider,{divider:n,testId:r})):d.createElement("li",{"data-fs-breadcrumb-list-item":!0},d.createElement("span",{...a},e,t?null:d.createElement(Breadcrumb_Divider,{divider:n,testId:r})))};let k=(0,d.forwardRef)(function({children:e,divider:t="",testId:n="fs-breadcrumb",...r},a){return d.createElement("nav",{"aria-label":"Breadcrumb",role:"navigation",ref:a,"data-fs-breadcrumb":!0,"data-testid":n,...r},d.createElement(w.Z,{as:"ol","data-fs-breadcrumb-list":!0,"data-fs-content":"breadcrumb"},d.Children.toArray(e).map((e,r,a)=>{let i=r===a.length-1;return d.createElement(Breadcrumb_ListItem,{isLastItem:i,divider:t,key:`breadcrumb-${r}`,testId:n},e)})))}),P=(0,d.forwardRef)(function({children:e,divider:t="",testId:n="fs-breadcrumb",breadcrumbList:r,isDesktop:a=!1,renderLink:i,homeLink:l,dropdownButtonIcon:o=d.createElement(g.Z,{name:"DotsThree"}),collapsedItemsIcon:s=d.createElement(g.Z,{"data-fs-dropdown-item-icon":!0,name:"ArrowElbowDownRight"}),...u},c){let p=a?r[0]:null,m=a?r.slice(1,-2):r.slice(0,-2),f=r.slice(-2),h=r.length>4,b=(0,d.useCallback)(e=>{let t=i?.(e),n=e.collapsed?{"data-fs-breadcrumb-dropdown-link":!0}:{"data-fs-breadcrumb-link":!0};return t?(0,d.cloneElement)(t,{...n,key:e.itemProps.position}):d.createElement(v.Z,{...n,href:e.itemProps.item,key:e.itemProps.position},e.itemProps.name)},[i]);return d.createElement(k,{ref:c,"data-fs-breadcrumb-is-desktop":a,...u},l,!h&&r.map((e,t)=>r.length===t+1?d.createElement("span",{key:String(e.position)},e.name):b({itemProps:e,collapsed:!1})),h&&p&&b({itemProps:p,collapsed:!1}),h&&d.createElement(Dropdown_Dropdown,null,d.createElement(y,{"aria-label":"View More","data-fs-breadcrumb-dropdown-button":!0,size:"small"},o),d.createElement(Dropdown_DropdownMenu,{"data-fs-breadcrumb-dropdown-menu":!0},m.map(e=>d.createElement(E,{"data-fs-breadcrumb-dropdown-item":!0,key:String(e.position),icon:s},b({itemProps:e,collapsed:!0}))))),h&&f.map((e,t)=>f.length===t+1?d.createElement("span",{key:String(e.position)},e.name):b({itemProps:e,collapsed:!1})))});var x={Breadcrumb:({breadcrumbList:e,...t})=>d.createElement(d.Fragment,null,d.createElement(P,{breadcrumbList:e,...t}),d.createElement(P,{breadcrumbList:e,isDesktop:!0,...t})),Icon:g.Z},C=(0,i.B)("Breadcrumb",function(e){var t,n,a,i,d,c,g,v,h,b=(0,l._)({},(0,o._)(e)),{Breadcrumb:y}=(0,f.r3)(),_=(0,m.qt)(),E=(0,m.OJ)(_)?null==_?void 0:null===(a=_.data)||void 0===a?void 0:null===(n=a.collection)||void 0===n?void 0:null===(t=n.seo)||void 0===t?void 0:t.title:"All Products",w=(0,m.tS)(_)?null==_?void 0:null===(c=_.data)||void 0===c?void 0:null===(d=c.product)||void 0===d?void 0:null===(i=d.breadcrumbList)||void 0===i?void 0:i.itemListElement:(0,m.OJ)(_)?null==_?void 0:null===(h=_.data)||void 0===h?void 0:null===(v=h.collection)||void 0===v?void 0:null===(g=v.breadcrumbList)||void 0===g?void 0:g.itemListElement:[{item:"/",name:E,position:1}];return(0,s.jsx)(u.Z,{className:"".concat(p().section," section-breadcrumb"),children:(0,s.jsx)(y.Component,(0,r._)({breadcrumbList:w},b))})},x),S=(0,d.memo)(C),I=(0,i.v)((0,a._)((0,r._)({},{section:"Breadcrumb"}),{Section:S}))},4298:function(e,t,n){"use strict";n.d(t,{Z:function(){return y}});var r=n(7460),a=n(6692),i=n(6877),l=n(2322),o=n(2784),s=n(8975),d=n(7704),u=n(5114),c=n(4914),p=n.n(c),m=n(9035),f=n(6737),g=n(9756),v=n(4644),h={ProductShelf:f.Z,__experimentalCarousel:v.Z,__experimentalProductCard:g.Z},b=(0,i.B)("CrossSellingShelf",e=>{var t,n,r,{numberOfItems:a,itemsPerPage:i,title:c,kind:f}=e,{ref:g,inView:v}=(0,d.YD)(),h=(0,u.al)(),b=null==h?void 0:null===(r=h.data)||void 0===r?void 0:null===(n=r.product)||void 0===n?void 0:null===(t=n.isVariantOf)||void 0===t?void 0:t.productGroupID,y=(0,o.useMemo)(()=>[{key:f,value:b}],[f,b]);return(0,l.jsx)(m.Z,{className:"".concat(p().section," section-product-shelf layout__section"),ref:g,children:(0,l.jsx)(s.Z,{inView:v,numberOfItems:a,itemsPerPage:i,title:c,selectedFacets:y})})},h),y=(0,i.v)((0,a._)((0,r._)({},{section:"CrossSellingShelf"}),{Section:b}))},4961:function(e,t,n){"use strict";n.r(t),n.d(t,{__N_SSG:function(){return ew},default:function(){return ek}});var r,a=n(7460),i=n(6692),l=n(2322),o=n(9996),s=n.n(o),d=n(5351),u=n(208),c=n(2826),p=n(7153),m=n(536),f=n(4298),g=n(8899),v=n(8318),h=n(6877),b=n(2784),y=n(1072),_=n(2346),E=n(3370),w=n(7672),k=n(1516),P=n(783),x=n(7734),C=n(7583),ProductDescription_ProductDescription=function(e){var{descriptionData:t,initiallyExpanded:n="first"}=e,r=(0,b.useMemo)(()=>({none:[],first:[0],all:[0,1,2,3]}),[]),[a,i]=(0,b.useState)(new Set(r[n]));return(0,l.jsx)("section",{"data-fs-product-description":!0,children:(0,l.jsx)(k.Z,{indices:a,onChange:e=>{i(t=>{var n=new Set(t);return t.has(e)?n.delete(e):n.add(e),n})},"aria-label":"Product Details Content",children:t.map((e,t)=>{var{title:n,content:r}=e;return(0,l.jsxs)(P.Z,{as:"article",index:t,prefixId:"product-description","data-fs-product-details-description":!0,children:[(0,l.jsx)(x.Z,{children:n}),(0,l.jsx)(C.Z,{children:(0,l.jsx)("div",{"data-fs-product-details-description-content":!0,dangerouslySetInnerHTML:{__html:r}})})]},String(t))})})})},S=n(7938),I=n(6105),useBuyButton=e=>{var{openCart:t}=(0,S.l)(),{currency:{code:n}}=(0,w.kP)();return{onClick:(0,b.useCallback)(r=>{r.preventDefault(),e&&((0,y._)({name:"add_to_cart",params:{currency:n,value:e.price*e.quantity,items:[{item_id:e.itemOffered.isVariantOf.productGroupID,item_name:e.itemOffered.isVariantOf.name,item_brand:e.itemOffered.brand.name,item_variant:e.itemOffered.sku,quantity:e.quantity,price:e.price,discount:e.listPrice-e.price,currency:n,item_variant_name:e.itemOffered.name,product_reference_id:e.itemOffered.gtin}]}}),I.i8.addItem(e),t())},[n,e,t]),"data-testid":"buy-button","data-sku":null==e?void 0:e.itemOffered.sku,"data-seller":null==e?void 0:e.seller.identifier}},j=n(2281),D=n(1664),B=n.n(D),Z=n(7301),N=n(8134),ImageComponent=e=>{var{src:t,alt:n}=e,r=(0,j._)(e,["src","alt"]);return(0,l.jsx)(Z.Z,(0,a._)({src:t,alt:n,width:34,height:34},r))},SkuSelector_Selectors=function(e){var{slugsMap:t,activeVariations:n,availableVariations:r}=e,o=(0,j._)(e,["slugsMap","activeVariations","availableVariations"]),{SkuSelector:s}=(0,N.r3)();return(0,l.jsx)("section",(0,i._)((0,a._)({},o),{children:r&&Object.keys(r).map(e=>{var l,o,d,u,c;return(0,b.createElement)(s.Component,(0,i._)((0,a._)({ImageComponent:ImageComponent},s.props),{key:e,skuPropertyName:e,availableVariations:r,activeVariations:n,slugsMap:t,linkProps:(0,i._)((0,a._)({},null!==(d=s.props.linkProps)&&void 0!==d?d:{}),{as:null!==(u=null===(l=s.props.linkProps)||void 0===l?void 0:l.as)&&void 0!==u?u:B(),legacyBehavior:null!==(c=null===(o=s.props.linkProps)||void 0===o?void 0:o.legacyBehavior)&&void 0!==c&&c})}))})}))};function AddToCartLoadingSkeleton(){return(0,l.jsxs)("svg",{role:"img",width:"100%",height:"48","aria-labelledby":"loading-aria",viewBox:"0 0 112 48",preserveAspectRatio:"none",children:[(0,l.jsx)("title",{id:"loading-aria",children:"Loading..."}),(0,l.jsx)("rect",{x:"0",y:"0",width:"100%",height:"100%",clipPath:"url(#clip-path)",style:{fill:'url("#fill")'}}),(0,l.jsxs)("defs",{children:[(0,l.jsx)("clipPath",{id:"clip-path",children:(0,l.jsx)("rect",{x:"0",y:"0",rx:"2",ry:"2",width:"112",height:"48"})}),(0,l.jsxs)("linearGradient",{id:"fill",children:[(0,l.jsx)("stop",{offset:"0.599964",stopColor:"#f3f3f3",stopOpacity:"1",children:(0,l.jsx)("animate",{attributeName:"offset",values:"-2; -2; 1",keyTimes:"0; 0.25; 1",dur:"2s",repeatCount:"indefinite"})}),(0,l.jsx)("stop",{offset:"1.59996",stopColor:"#ecebeb",stopOpacity:"1",children:(0,l.jsx)("animate",{attributeName:"offset",values:"-1; -1; 2",keyTimes:"0; 0.25; 1",dur:"2s",repeatCount:"indefinite"})}),(0,l.jsx)("stop",{offset:"2.59996",stopColor:"#f3f3f3",stopOpacity:"1",children:(0,l.jsx)("animate",{attributeName:"offset",values:"0; 0; 3",keyTimes:"0; 0.25; 1",dur:"2s",repeatCount:"indefinite"})})]})]})]})}var ProductDetails_ProductDetailsSettings=function(e){var{product:t,buyButtonTitle:n,isValidating:r,quantity:o,setQuantity:s,buyButtonIcon:{icon:d,alt:u},notAvailableButtonTitle:c,useUnitMultiplier:p}=e,{BuyButton:m,Icon:f,ProductPrice:g,QuantitySelector:v,__experimentalNotAvailableButton:h}=(0,N.r3)(),{id:y,sku:_,gtin:w,unitMultiplier:k,name:P,brand:x,isVariantOf:C,isVariantOf:{skuVariants:S},image:I,additionalProperty:j,offers:{offers:[{availability:D,price:B,listPrice:Z,seller:L}]}}=t,M=useBuyButton({id:y,price:B,listPrice:Z,seller:L,quantity:o,itemOffered:{sku:_,name:P,gtin:w,image:I,brand:x,isVariantOf:C,additionalProperty:j,unitMultiplier:k}}),O=(0,b.useMemo)(()=>"https://schema.org/OutOfStock"===D,[D]);return(0,l.jsxs)(l.Fragment,{children:[!O&&(0,l.jsxs)("section",{"data-fs-product-details-values":!0,children:[(0,l.jsx)(g.Component,(0,a._)({"data-fs-product-details-prices":!0,value:B,listPrice:Z,formatter:E.P},g.props)),(0,l.jsx)(v.Component,(0,i._)((0,a._)({min:1,max:10,unitMultiplier:p?k:1,useUnitMultiplier:p},v.props),{onChange:s}))]}),S&&(0,l.jsx)(SkuSelector_Selectors,{slugsMap:S.slugsMap,availableVariations:S.availableVariations,activeVariations:S.activeVariations,"data-fs-product-details-selectors":!0}),r?(0,l.jsx)(AddToCartLoadingSkeleton,{}):(0,l.jsx)(()=>O?(0,l.jsx)(h.Component,{children:c}):(0,l.jsx)(m.Component,(0,i._)((0,a._)((0,i._)((0,a._)({},m.props),{icon:(0,l.jsx)(f.Component,(0,i._)((0,a._)({},f.props),{name:null!=d?d:f.props.name,"aria-label":null!=u?u:f.props["aria-label"]}))}),M),{children:n||"Add to Cart"})),{})]})},L=n(9035),M=n(2590),O=n.n(M),R=n(5114),T=n(3024);let V=(0,b.forwardRef)(function({title:e,label:t,refTag:n="Ref.: ",refNumber:r,testId:a="fs-product-title",ratingValue:i,...l},o){return b.createElement("header",{ref:o,"data-fs-product-title":!0,"data-testid":a,...l},b.createElement("div",{"data-fs-product-title-header":!0},e,!!t&&t),(r||i)&&b.createElement("div",{"data-fs-product-title-addendum":!0},i&&b.createElement(T.Z,{value:i}),r&&b.createElement(b.Fragment,null,n," ",r)))});var G=n(2946),$=n(3339),A=n(2614),F=n(9088),Q=n(6693),q=n(1953),z=n(727),H=n(5450);let getImageName=e=>{let t=new URL(e).pathname,n=t.split("/").slice(-1)[0];return n},useDefineVariant=(e,t)=>(0,b.useMemo)(()=>{if(t)return t;let n=e.every(e=>e.hexColor);if(n)return"color";let r=e[0]?.src&&getImageName(e[0].src);if(r&&1===e.length)return"image";let a=e.every(e=>{if(!e.src)return!0;let t=getImageName(e.src);return t===r});return a?"label":"image"},[e,t]),useSkuSlug=(e,t,n,r)=>{let a=(0,b.useCallback)(a=>{if(r)return{getItemHrefProp:r};let i=`/${function(e,t,n){let r=Object.entries(t).flat().join("-");if(r in e)return e[r];let a=Object.keys(e),i=a.find(e=>e.includes(`${n}-${t[n]}`));return e[i??a[0]]}(t,{...e,[n]:a.value},n)}/p`;return i},[e,r,t,n]);return{getItemHref:a}},ImageComponentFallback=({src:e,alt:t,...n})=>b.createElement("img",{src:e,alt:t,...n}),U=(0,b.forwardRef)(function({availableVariations:e,skuPropertyName:t,testId:n,activeVariations:r,linkProps:a,slugsMap:i,getItemHref:l,ImageComponent:o=ImageComponentFallback,variant:s,...d},u){let c=r[t],p=e[t],m=useDefineVariant(p,s),{getItemHref:f}=useSkuSlug(r,i,t,l);return b.createElement("div",{ref:u,"data-fs-sku-selector":!0,"data-testid":n,"data-fs-sku-selector-variant":m,...d},t&&b.createElement(q.Z,{"data-fs-sku-selector-title":!0},t,": ",b.createElement("strong",null,c)),b.createElement("ul",{"data-fs-sku-selector-list":!0},p.map((e,n)=>b.createElement("li",{key:String(n),title:e.label,"data-fs-sku-selector-option":!0,"data-fs-sku-selector-disabled":e.disabled,"data-fs-sku-selector-checked":e.value===r[t]},b.createElement(z.Z,{"data-fs-sku-selector-option-link":!0,href:f(e),...a},b.createElement(H.Z,{text:e.label})),"label"===m&&b.createElement("span",null,e.value),"image"===m&&o&&b.createElement("span",null,b.createElement(o,{src:e.src??"",alt:e.alt??"","data-fs-sku-selector-option-image":!0})),"color"===m&&b.createElement("span",null,b.createElement("div",{"data-fs-sku-selector-option-color":!0,title:e.value,style:{"--data-fs-sku-selector-option-color-bkg-color":e.hexColor}}))))))});var W=n(3779);let J=(0,b.forwardRef)(function({children:e,variant:t="colored",testId:n="fs-table",...r},a){return b.createElement("div",{"data-fs-table":!0},b.createElement("table",{ref:a,"data-fs-table-content":!0,"data-fs-table-variant":t,"data-testid":n,...r},e))}),X=(0,b.forwardRef)(function({children:e,testId:t="fs-table-body",...n},r){return b.createElement("tbody",{ref:r,"data-testid":t,"data-fs-table-body":!0,...n},e)}),Y=(0,b.forwardRef)(function({children:e,testId:t="fs-table-row",...n},r){return b.createElement("tr",{ref:r,"data-fs-table-row":!0,"data-testid":t,...n},e)}),K=(0,b.forwardRef)(function({scope:e,align:t,children:n,variant:r="data",testId:a="fs-table-cell",...i},l){return b.createElement("header"===r?"th":"td",{ref:l,"data-fs-table-cell":r,"data-fs-table-cell-align":t,"data-testid":a,scope:e,...i},n)});var ee=n(9767),et=n(7704),en=n(7041);let moveScroll=(e,t)=>{e&&(e.scrollHeight>e.clientHeight?(e.style.overflow="auto",window.requestAnimationFrame(()=>e.scrollTo({top:t,behavior:"smooth"})),setTimeout(()=>e.style.overflow="hidden",2e3)):e.scrollLeft+=t)},hasScroll=e=>!!e&&(e.scrollHeight>e.clientHeight||e.scrollWidth>e.clientWidth);var ImageGallery_ImageGallerySelector=function({images:e,onSelect:t,ImageComponent:n,currentImageIdx:r,testId:a="fs-image-gallery-selector","aria-label":i="Product Images",navigationButtonLeftAriaLabel:l="Backward slide image selector",navigationButtonRightAriaLabel:o="Forward slide image selector"}){let s=(0,b.useRef)(null),d=hasScroll(s.current),[u,c]=(0,b.useState)(!0),[p,m]=(0,b.useState)(!0),f=(0,b.useCallback)((t,n)=>{0===t&&c(n),t===e.length-1&&m(n)},[e.length]);return b.createElement("section",{"data-fs-image-gallery-selector":!0,"data-testid":a,"aria-label":i},d&&!u&&b.createElement("div",{"data-fs-image-gallery-selector-control":!0},b.createElement(en.Z,{"data-fs-image-gallery-selector-control-button":!0,"aria-label":l,icon:b.createElement(A.Z,{name:"ArrowLeft"}),onClick:()=>moveScroll(s.current,-400)})),b.createElement("div",{"data-fs-image-gallery-selector-elements":!0,ref:s},e.map((a,i)=>b.createElement(et.df,{key:i,onChange:e=>f(i,e)},b.createElement($.Z,{key:i,"aria-label":`${a.alternateName} - Image ${i+1} of ${e.length}`,onClick:()=>t(i),"data-fs-image-gallery-selector-thumbnail":i===r?"selected":"true"},b.createElement(n,{url:a.url??"",loading:0===i?"eager":"lazy",alternateName:a.alternateName??""}))))),d&&!p&&b.createElement("div",{"data-fs-image-gallery-selector-control":!0},b.createElement(en.Z,{"data-fs-image-gallery-selector-control-button":!0,"aria-label":o,icon:b.createElement(A.Z,{name:"ArrowLeft"}),onClick:()=>moveScroll(s.current,400)})))};let er=(0,b.forwardRef)(function({images:e,children:t,ImageComponent:n,selectedImageIdx:r,setSelectedImageIdx:a,testId:i="fs-image-gallery",...l},o){let s=e.length>1;return b.createElement("section",{ref:o,"data-fs-image-gallery":s?"with-selector":"without-selector","data-testid":i,...l},t,s&&b.createElement(ImageGallery_ImageGallerySelector,{images:e,onSelect:a,currentImageIdx:r,ImageComponent:n}))});var ea=n(1163),ImageGallery_ImageComponent=e=>{var{url:t,alternateName:n}=e,{__experimentalImageGalleryImage:r}=(0,N.r3)();return(0,l.jsx)(r.Component,{src:t,alt:n,width:68,height:68})},ei=n(1862),el=n(5563),eo=(0,_.P)("\n query ClientShippingSimulationQuery(\n $postalCode: String!\n $country: String!\n $items: [IShippingItem!]!\n ) {\n ...ClientShippingSimulation\n shipping(items: $items, postalCode: $postalCode, country: $country) {\n logisticsInfo {\n slas {\n carrier\n price\n availableDeliveryWindows {\n startDateUtc\n endDateUtc\n price\n listPrice\n }\n shippingEstimate\n localizedEstimates\n }\n }\n address {\n city\n neighborhood\n state\n }\n }\n }\n"),es=(r=(0,ei._)(function*(e){var{items:t,postalCode:n,country:r}=e;return yield(0,el.W)(eo,{items:t,postalCode:n,country:r})}),function(e){return r.apply(this,arguments)}),createEmptySimulation=()=>({input:{postalCode:"",displayClearButton:!1,errorMessage:""},shippingSimulation:void 0}),reducer=(e,t)=>{var{type:n}=t;switch(n){case"clear":return createEmptySimulation();case"update":var{payload:r}=t;return{input:(0,a._)({},e.input,r.input),shippingSimulation:(0,a._)({},e.shippingSimulation,r.shippingSimulation)};case"onInput":var{payload:l}=t;return(0,i._)((0,a._)({},e),{input:(0,a._)({},l)});case"onError":var{payload:o}=t;return(0,i._)((0,a._)({},e),{input:(0,a._)({},e.input,o)});default:throw Error("Action ".concat(n," not implemented"))}},useShippingSimulation=e=>{var[{input:t,shippingSimulation:n},r]=(0,b.useReducer)(reducer,null,createEmptySimulation),{country:a,postalCode:i}=(0,w.kP)(),{postalCode:l}=t,o=(0,b.useRef)(l);return(0,b.useEffect)(()=>{i&&!o.current&&function(){_fetchShipping.apply(this,arguments)}();function _fetchShipping(){return(_fetchShipping=(0,ei._)(function*(){var t=(yield es({country:a,postalCode:null!=i?i:"",items:[e]})).shipping;r({type:"update",payload:{input:{postalCode:null!=i?i:"",displayClearButton:!0,errorMessage:""},shippingSimulation:t}})})).apply(this,arguments)}},[a,i,e]),{input:t,shippingSimulation:n,handleOnClear:()=>{r({type:"clear"})},handleSubmit:(0,b.useCallback)((0,ei._)(function*(){try{var t=(yield es({country:a,postalCode:null!=l?l:"",items:[e]})).shipping;r({type:"update",payload:{input:{displayClearButton:!0,errorMessage:""},shippingSimulation:t}})}catch(e){r({type:"onError",payload:{displayClearButton:!0,errorMessage:"You entered an invalid Postal Code"}})}}),[a,e,l]),handleOnInput:(0,b.useCallback)(e=>{var t=e.currentTarget.value;t?r({type:"onInput",payload:{postalCode:t,displayClearButton:!1,errorMessage:""}}):r({type:"clear"})},[])}},ed={ProductTitle:V,DiscountBadge:G.Z,BuyButton:function({testId:e="fs-buy-button",icon:t,children:n,...r}){return b.createElement($.Z,{"data-fs-buy-button":!0,icon:t,iconPosition:"left","data-testid":e,...r},n)},Icon:A.Z,ProductPrice:F.Z,QuantitySelector:Q.Z,SkuSelector:U,ShippingSimulation:function({testId:e="fs-shipping-simulation",formatter:t,title:n="Shipping",inputLabel:r="Postal Code",optionsLabel:a="Shipping options",idkPostalCodeLinkProps:i,onInput:l,onSubmit:o,onClear:s,location:d,options:u=[],displayClearButton:c=!1,errorMessage:p,postalCode:m,...f}){let g=!!u&&u.length>0;return b.createElement("section",{"data-fs-shipping-simulation":!0,"data-fs-shipping-simulation-empty":g?"false":"true","data-testid":e,...f},b.createElement("h2",{"data-fs-shipping-simulation-title":!0},n),b.createElement(W.Z,{actionable:!0,error:p,id:`${e}-input-field`,label:r,value:m,onInput:e=>l?.(e),onSubmit:()=>o?.(),onClear:()=>s?.(),displayClearButton:c}),b.createElement(z.Z,{href:"/","data-fs-shipping-simulation-link":!0,size:"small",...i},i?.children??b.createElement(b.Fragment,null,"I don't know my Postal Code",b.createElement(A.Z,{name:"ArrowSquareOut",width:20,height:20}))),g&&b.createElement(b.Fragment,null,b.createElement("header",{"data-fs-shipping-simulation-header":!0},b.createElement("h3",{"data-fs-shipping-simulation-subtitle":!0},a),b.createElement("p",{"data-fs-shipping-simulation-location":!0},d)),b.createElement(J,null,b.createElement(X,null,u.map(e=>b.createElement(Y,{key:e.carrier},b.createElement(K,{align:"left"},e.carrier),b.createElement(K,null,e.localizedEstimates),b.createElement(K,{align:"right"},e.price&&b.createElement(ee.Z,{formatter:t,value:e.price,SRText:"price"}))))))))},ImageGallery:er,ImageGalleryViewer:({children:e})=>b.createElement(b.Fragment,null,e),__experimentalImageGalleryImage:Z.Z,__experimentalImageGallery:e=>{var t,{images:n}=e,r=(0,j._)(e,["images"]),{ImageGallery:o,ImageGalleryViewer:s,__experimentalImageGalleryImage:d}=(0,N.r3)(),[u,c]=(0,b.useState)(0),p=null!==(t=n[u])&&void 0!==t?t:n[0],m=(0,ea.useRouter)().asPath;return(0,b.useEffect)(()=>c(0),[m]),(0,l.jsx)(o.Component,(0,i._)((0,a._)((0,i._)((0,a._)({},o.props),{images:n,ImageComponent:ImageGallery_ImageComponent,selectedImageIdx:u,setSelectedImageIdx:c}),r),{children:(0,l.jsx)(s.Component,(0,i._)((0,a._)({},s.props),{children:(0,l.jsx)(d.Component,(0,i._)((0,a._)({sizes:"(max-width: 360px) 50vw, (max-width: 768px) 90vw, 50vw",width:691,height:691*(3/4),loading:"eager"},d.props),{src:p.url,alt:p.alternateName}))}))}))},__experimentalShippingSimulation:function(e){var t,n,r,i,o,s,{productShippingInfo:d,formatter:u,inputLabel:c,title:p,idkPostalCodeLinkProps:m}=e,f=(0,j._)(e,["productShippingInfo","formatter","inputLabel","title","idkPostalCodeLinkProps"]),{ShippingSimulation:g}=(0,N.r3)(),{input:v,shippingSimulation:h,handleSubmit:b,handleOnInput:y,handleOnClear:_}=useShippingSimulation(d),{postalCode:E,displayClearButton:w,errorMessage:k}=v,P=null!==(o=[null==h?void 0:null===(t=h.address)||void 0===t?void 0:t.neighborhood,null==h?void 0:null===(n=h.address)||void 0===n?void 0:n.city].filter(Boolean).join(" / "))&&void 0!==o?o:"",x=null!==(s=null==h?void 0:null===(i=h.logisticsInfo)||void 0===i?void 0:null===(r=i[0])||void 0===r?void 0:r.slas)&&void 0!==s?s:[];return(0,l.jsx)(g.Component,(0,a._)({formatter:u,onInput:y,onSubmit:b,onClear:_,location:P,options:x,address:null==h?void 0:h.address,displayClearButton:w,errorMessage:k,postalCode:E,inputLabel:c,title:p,idkPostalCodeLinkProps:m},f))},__experimentalNotAvailableButton:function(e){var{children:t}=e;return(0,l.jsx)($.Z,{variant:"primary",disabled:!0,"data-fs-buy-button":!0,children:t})}};(0,_.P)("\n fragment ProductDetailsFragment_product on StoreProduct {\n id: productID\n sku\n name\n gtin\n description\n unitMultiplier\n isVariantOf {\n name\n productGroupID\n skuVariants {\n activeVariations\n slugsMap\n availableVariations\n }\n }\n\n image {\n url\n alternateName\n }\n\n brand {\n name\n }\n\n offers {\n lowPrice\n offers {\n availability\n price\n listPrice\n seller {\n identifier\n }\n }\n }\n\n additionalProperty {\n propertyID\n name\n value\n valueReference\n }\n\n # Contains necessary info to add this item to cart\n ...CartProductItem\n }\n");var eu=(0,h.B)("ProductDetails",function(e){var t,n,r,{productTitle:{refNumber:o,discountBadge:{showDiscountBadge:s,size:d}},buyButton:{icon:u,title:c},shippingSimulator:{title:p,inputLabel:m,shippingOptionsTableTitle:f,link:{to:g,text:v}},productDescription:{title:h,initiallyExpanded:_,displayDescription:k},notAvailableButton:{title:P},quantitySelector:x}=e,{DiscountBadge:C,ProductTitle:S,__experimentalImageGallery:I,__experimentalShippingSimulation:j,__experimentalNotAvailableButton:D}=(0,N.r3)(),{currency:B}=(0,w.kP)(),Z=(0,R.al)(),{product:M,isValidating:T}=null==Z?void 0:Z.data,[V,G]=(0,b.useState)(1);if(!M)throw Error("NotFound");var{id:$,sku:A,gtin:F,name:Q,brand:q,isVariantOf:z,description:H,isVariantOf:{name:U,productGroupID:W},image:J,offers:{offers:[{availability:X,price:Y,listPrice:K,seller:ee}],lowPrice:et}}=M;(0,b.useEffect)(()=>{(0,y._)({name:"view_item",params:{currency:B.code,value:Y,items:[{item_id:z.productGroupID,item_name:z.name,item_brand:q.name,item_variant:A,price:Y,discount:K-Y,currency:B.code,item_variant_name:Q,product_reference_id:F}]}})},[z.productGroupID,z.name,q.name,A,Y,K,B.code,Q,F]);var en=(0,b.useMemo)(()=>"https://schema.org/OutOfStock"===X,[X]);return(0,l.jsx)(L.Z,{className:"".concat(O().section," section-product-details"),children:(0,l.jsx)("section",{"data-fs-product-details":!0,children:(0,l.jsxs)("section",{"data-fs-product-details-body":!0,"data-fs-content":"product-details",children:[(0,l.jsx)("header",{"data-fs-product-details-title":!0,"data-fs-product-details-section":!0,children:(0,l.jsx)(S.Component,(0,i._)((0,a._)({title:(0,l.jsx)("h1",{children:U})},S.props),{label:s&&(0,l.jsx)(C.Component,(0,i._)((0,a._)({},C.props),{size:null!=d?d:C.props.size,listPrice:K,spotPrice:et})),refNumber:o&&W}))}),(0,l.jsx)(I.Component,(0,i._)((0,a._)({"data-fs-product-details-gallery":!0},I.props),{images:J})),(0,l.jsxs)("section",{"data-fs-product-details-info":!0,children:[(0,l.jsx)("section",{"data-fs-product-details-settings":!0,"data-fs-product-details-section":!0,children:(0,l.jsx)(ProductDetails_ProductDetailsSettings,{product:M,isValidating:T,buyButtonTitle:c,quantity:V,setQuantity:G,buyButtonIcon:u,notAvailableButtonTitle:null!=P?P:D.props.title,useUnitMultiplier:null!==(r=null==x?void 0:x.useUnitMultiplier)&&void 0!==r&&r})}),!en&&(0,l.jsx)(j.Component,(0,i._)((0,a._)({"data-fs-product-details-section":!0,"data-fs-product-details-shipping":!0,formatter:E.P},j.props),{idkPostalCodeLinkProps:(0,i._)((0,a._)({},j.props.idkPostalCodeLinkProps),{href:null!=g?g:null===(t=j.props.idkPostalCodeLinkProps)||void 0===t?void 0:t.href,children:null!=v?v:null===(n=j.props.idkPostalCodeLinkProps)||void 0===n?void 0:n.children}),productShippingInfo:{id:$,quantity:V,seller:ee.identifier},title:null!=p?p:j.props.title,inputLabel:null!=m?m:j.props.inputLabel,optionsLabel:null!=f?f:j.props.optionsLabel}))]}),k&&(0,l.jsx)(ProductDescription_ProductDescription,{initiallyExpanded:_,descriptionData:[{title:h,content:H}]})]})})})},ed),ec=(0,h.v)((0,i._)((0,a._)({},{section:"ProductDetails"}),{Section:eu})),ep=n(5786),em=n(7553),ef=n(8945),eg=n(6841),ev=n(6226),eh=n.n(ev),eb=n(7432),ey=n(1179),e_=(0,_.P)("\n query ClientProductQuery($locator: [IStoreSelectedFacet!]!) {\n ...ClientProduct\n product(locator: $locator) {\n ...ProductDetailsFragment_product\n }\n }\n"),useProductQuery=(e,t)=>{var{channel:n,locale:r}=(0,w.kP)(),a=(0,b.useMemo)(()=>{if(!n)throw Error("useProductQuery: 'channel' from session is an empty string.");return{locator:[{key:"id",value:e},{key:"channel",value:n},{key:"locale",value:r}]}},[n,r,e]);return(0,ey.aM)(e_,a,{fallbackData:t,revalidateOnMount:!0})},eE=(0,a._)({Breadcrumb:m.j,BannerNewsletter:c.Z,Newsletter:v.O,BannerText:p.i,Hero:g.V,ProductDetails:ec,ProductShelf:ep.T,ProductTiles:em.Z,CrossSellingShelf:f.Z},ef.Z),overwriteMerge=(e,t)=>t;function Page(e){var t,n,r,o,{data:c,sections:p,globalSections:m,offers:f,meta:g}=e,{product:v}=c,{currency:h}=(0,w.kP)(),b=null!==(r=null===eh()||void 0===eh()?void 0:null===(t=eh().seo)||void 0===t?void 0:t.titleTemplate)&&void 0!==r?r:"",{data:y,isValidating:_}=useProductQuery(v.id,{product:v}),E={data:(0,i._)((0,a._)({},s()(c,y,{arrayMerge:overwriteMerge})),{isValidating:_})};return(0,l.jsxs)(eb.ZP,(0,i._)((0,a._)({},m),{children:[(0,l.jsx)(d.PB,{title:g.title,description:g.description,canonical:g.canonical,openGraph:{type:"og:product",url:g.canonical,title:g.title,description:g.description,images:v.image.map(e=>({url:e.url,alt:e.alternateName}))},additionalMetaTags:[{property:"product:price:amount",content:null!==(o=null===(n=v.offers.lowPrice)||void 0===n?void 0:n.toString())&&void 0!==o?o:void 0},{property:"product:price:currency",content:h.code}],titleTemplate:b}),(0,l.jsx)(d.gR,{itemListElements:v.breadcrumbList.itemListElement}),(0,l.jsx)(d.Qb,{productName:v.name,description:v.description,brand:v.brand.name,sku:v.sku,gtin:v.gtin,releaseDate:v.releaseDate,images:v.image.map(e=>e.url),offers:f}),(0,l.jsx)(R.ZP,{context:E,children:(0,l.jsx)(u.Z,{sections:p,components:eE})})]}))}Page.displayName="Page";var ew=!0,ek=(0,eg.B)(Page)},7944:function(e){e.exports={section:"section_section__dvBbv"}},2590:function(e){e.exports={section:"section_section__VI73U"}}},function(e){e.O(0,[470,432,590,774,888,179],function(){return e(e.s=6258)}),_N_E=e.O()}]);
|
|
File without changes
|