@faststore/core 2.1.83 → 2.2.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +9 -7
- package/.turbo/turbo-test.log +25 -0
- package/@generated/graphql/index.ts +183 -79
- package/@generated/graphql/persisted.json +5 -5
- package/@generated/graphql/schema.graphql +1053 -0
- package/api/index.ts +15 -0
- package/codegen.yml +2 -1
- package/generate.sh +71 -0
- package/index.ts +15 -0
- package/jest.config.js +6 -0
- package/package.json +33 -18
- package/src/components/ThirdPartyScripts/ThirdPartyScripts.tsx +1 -2
- package/src/components/cms/RenderSections.tsx +4 -5
- package/src/components/product/ProductGrid/ProductGrid.tsx +4 -3
- package/src/components/sections/Breadcrumb/Breadcrumb.tsx +17 -22
- package/src/components/sections/CrossSellingShelf/CrossSellingShelf.tsx +8 -6
- package/src/components/sections/ProductDetails/ProductDetails.tsx +23 -33
- package/src/components/sections/ProductGallery/ProductGallery.tsx +15 -26
- package/src/components/sections/ProductShelf/ProductShelf.tsx +1 -1
- package/src/components/sections/ProductTiles/ProductTiles.tsx +4 -3
- package/src/components/templates/ProductListingPage/ProductListing.tsx +95 -0
- package/src/components/templates/ProductListingPage/ProductListingPage.tsx +34 -68
- package/src/components/templates/SearchPage/SearchPage.tsx +81 -0
- package/src/components/templates/SearchPage/index.ts +2 -0
- package/src/components/ui/ProductGallery/ProductGallery.tsx +24 -16
- package/src/components/ui/ProductGallery/ProductGalleryPage.tsx +8 -7
- package/src/components/ui/ProductGallery/useDelayedFacets.ts +3 -3
- package/src/components/ui/ProductShelf/ProductShelf.tsx +3 -2
- package/src/customizations/GlobalOverrides.tsx +0 -2
- package/src/customizations/fragments/ClientProduct.ts +9 -0
- package/src/customizations/fragments/ClientProductGallery.ts +19 -0
- package/src/customizations/fragments/ClientProducts.ts +19 -0
- package/src/customizations/fragments/ServerCollectionPage.ts +9 -0
- package/src/customizations/fragments/ServerProductPage.ts +9 -0
- package/src/customizations/graphql/thirdParty/resolvers/index.ts +3 -0
- package/src/customizations/graphql/vtex/resolvers/index.ts +3 -0
- package/src/pages/[...slug].tsx +5 -3
- package/src/pages/[slug]/p.tsx +38 -18
- package/src/pages/s.tsx +22 -34
- package/src/sdk/graphql/useQuery.ts +17 -13
- package/src/sdk/overrides/PageProvider.tsx +78 -0
- package/src/sdk/product/useLocalizedVariables.ts +33 -0
- package/src/sdk/product/usePageProductsQuery.ts +139 -0
- package/src/{components/sections/ProductGallery/useGalleryQuery.ts → sdk/product/useProductGalleryQuery.ts} +12 -13
- package/src/sdk/product/{useProduct.ts → useProductQuery.ts} +10 -7
- package/src/sdk/product/useProductsPrefetch.ts +72 -0
- package/src/sdk/product/useProductsQuery.ts +17 -63
- package/src/server/generator/generateGraphQLSchemaFile.ts +3 -0
- package/src/server/generator/schema.ts +82 -0
- package/src/server/index.ts +34 -21
- package/src/server/options.ts +16 -0
- package/test/server/index.test.ts +146 -0
- package/.next/BUILD_ID +0 -1
- package/.next/build-manifest.json +0 -129
- package/.next/cache/.tsbuildinfo +0 -1
- package/.next/cache/config.json +0 -7
- package/.next/cache/eslint/.cache_1gneedd +0 -1
- package/.next/cache/next-server.js.nft.json +0 -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/export-marker.json +0 -1
- package/.next/images-manifest.json +0 -1
- package/.next/next-server.js.nft.json +0 -1
- package/.next/package.json +0 -1
- package/.next/prerender-manifest.json +0 -1
- package/.next/react-loadable-manifest.json +0 -44
- package/.next/required-server-files.json +0 -1
- package/.next/routes-manifest.json +0 -1
- package/.next/server/chunks/143.js +0 -106
- package/.next/server/chunks/177.js +0 -120
- package/.next/server/chunks/183.js +0 -94
- package/.next/server/chunks/184.js +0 -61
- package/.next/server/chunks/186.js +0 -113
- package/.next/server/chunks/289.js +0 -239
- package/.next/server/chunks/312.js +0 -697
- package/.next/server/chunks/350.js +0 -143
- package/.next/server/chunks/483.js +0 -650
- package/.next/server/chunks/487.js +0 -9142
- package/.next/server/chunks/53.js +0 -61
- package/.next/server/chunks/530.js +0 -626
- package/.next/server/chunks/576.js +0 -94
- package/.next/server/chunks/650.js +0 -9142
- package/.next/server/chunks/676.js +0 -32
- package/.next/server/chunks/693.js +0 -58
- package/.next/server/chunks/71.js +0 -1254
- package/.next/server/chunks/74.js +0 -4054
- package/.next/server/chunks/753.js +0 -509
- package/.next/server/chunks/779.js +0 -58
- package/.next/server/chunks/825.js +0 -4039
- package/.next/server/chunks/854.js +0 -72
- package/.next/server/chunks/859.js +0 -959
- package/.next/server/chunks/907.js +0 -1911
- package/.next/server/chunks/933.js +0 -517
- package/.next/server/chunks/98.js +0 -124
- package/.next/server/chunks/988.js +0 -211
- package/.next/server/chunks/font-manifest.json +0 -1
- package/.next/server/font-manifest.json +0 -1
- package/.next/server/middleware-build-manifest.js +0 -1
- package/.next/server/middleware-manifest.json +0 -6
- package/.next/server/middleware-react-loadable-manifest.js +0 -1
- package/.next/server/pages/404.js +0 -386
- package/.next/server/pages/404.js.nft.json +0 -1
- package/.next/server/pages/500.js +0 -388
- package/.next/server/pages/500.js.nft.json +0 -1
- package/.next/server/pages/[...slug].js +0 -1005
- package/.next/server/pages/[...slug].js.nft.json +0 -1
- package/.next/server/pages/[slug]/p.js +0 -2269
- package/.next/server/pages/[slug]/p.js.nft.json +0 -1
- package/.next/server/pages/_app.js +0 -280
- package/.next/server/pages/_app.js.nft.json +0 -1
- package/.next/server/pages/_document.js +0 -374
- package/.next/server/pages/_document.js.nft.json +0 -1
- package/.next/server/pages/_error.js +0 -164
- package/.next/server/pages/_error.js.nft.json +0 -1
- package/.next/server/pages/account.js +0 -363
- package/.next/server/pages/account.js.nft.json +0 -1
- package/.next/server/pages/api/graphql.js +0 -365
- package/.next/server/pages/api/graphql.js.nft.json +0 -1
- package/.next/server/pages/api/health/live.js +0 -31
- package/.next/server/pages/api/health/live.js.nft.json +0 -1
- package/.next/server/pages/api/health/ready.js +0 -31
- package/.next/server/pages/api/health/ready.js.nft.json +0 -1
- package/.next/server/pages/api/preview.js +0 -148
- package/.next/server/pages/api/preview.js.nft.json +0 -1
- package/.next/server/pages/checkout.js +0 -363
- package/.next/server/pages/checkout.js.nft.json +0 -1
- package/.next/server/pages/en-US/404.html +0 -81
- package/.next/server/pages/en-US/404.json +0 -1
- package/.next/server/pages/en-US/500.html +0 -81
- package/.next/server/pages/en-US/500.json +0 -1
- package/.next/server/pages/en-US/account.html +0 -81
- package/.next/server/pages/en-US/account.json +0 -1
- package/.next/server/pages/en-US/checkout.html +0 -81
- package/.next/server/pages/en-US/checkout.json +0 -1
- package/.next/server/pages/en-US/login.html +0 -81
- package/.next/server/pages/en-US/login.json +0 -1
- package/.next/server/pages/en-US/s.html +0 -81
- package/.next/server/pages/en-US/s.json +0 -1
- package/.next/server/pages/en-US.html +0 -81
- package/.next/server/pages/en-US.json +0 -1
- package/.next/server/pages/index.js +0 -439
- package/.next/server/pages/index.js.nft.json +0 -1
- package/.next/server/pages/login.js +0 -368
- package/.next/server/pages/login.js.nft.json +0 -1
- package/.next/server/pages/s.js +0 -466
- package/.next/server/pages/s.js.nft.json +0 -1
- package/.next/server/pages-manifest.json +0 -18
- package/.next/server/webpack-api-runtime.js +0 -229
- package/.next/server/webpack-runtime.js +0 -229
- package/.next/static/chunks/143.dd8a556e6957baa1.js +0 -1
- package/.next/static/chunks/148.3bb7e05cc5d1c1c4.js +0 -1
- package/.next/static/chunks/238-e5e4b2094f0e1df8.js +0 -1
- package/.next/static/chunks/243-8f5650ed908aa75c.js +0 -1
- package/.next/static/chunks/530.848b014622932b93.js +0 -1
- package/.next/static/chunks/548-ab84e9e8b49413ab.js +0 -1
- package/.next/static/chunks/603-d1c069aa8a349c86.js +0 -1
- package/.next/static/chunks/651.7142f31ce1e052b3.js +0 -1
- package/.next/static/chunks/709.7bc5a25ce30abda6.js +0 -1
- package/.next/static/chunks/738-67a288ca3569cdbb.js +0 -1
- package/.next/static/chunks/741.52f7fb873418346f.js +0 -1
- package/.next/static/chunks/98.97381d2021f86cd9.js +0 -1
- package/.next/static/chunks/988.d10040040cdfebbb.js +0 -1
- package/.next/static/chunks/framework-dfd14d7ce6600b03.js +0 -1
- package/.next/static/chunks/main-fd466221927468fd.js +0 -1
- package/.next/static/chunks/pages/404-af78f7cd1d3c1f60.js +0 -1
- package/.next/static/chunks/pages/500-f6346ca5f9dc4fef.js +0 -1
- package/.next/static/chunks/pages/[...slug]-ca533c74c22cb787.js +0 -1
- package/.next/static/chunks/pages/[slug]/p-7bb760bb3fcfc0bb.js +0 -1
- package/.next/static/chunks/pages/_app-895781b1c7b5bf56.js +0 -1
- package/.next/static/chunks/pages/_error-a7a0c1d9bfbb4f38.js +0 -1
- package/.next/static/chunks/pages/account-05bd79fb78365e88.js +0 -1
- package/.next/static/chunks/pages/checkout-c973786e68f25a39.js +0 -1
- package/.next/static/chunks/pages/index-d521ce4f4e2b89a6.js +0 -1
- package/.next/static/chunks/pages/login-8deb9243376b6aa1.js +0 -1
- package/.next/static/chunks/pages/s-0e516ab36bb49c99.js +0 -1
- package/.next/static/chunks/polyfills-c67a75d1b6f99dc8.js +0 -1
- package/.next/static/chunks/webpack-062512aedeb4b39e.js +0 -1
- package/.next/static/css/0d056c673d2869bb.css +0 -1
- package/.next/static/css/4b7138899cd07c63.css +0 -1
- package/.next/static/css/527e334fa69cf40a.css +0 -1
- package/.next/static/css/6e1a7434f061d0ef.css +0 -1
- package/.next/static/css/9e76fef1c9ca89af.css +0 -1
- package/.next/static/css/a2eefb25a4608343.css +0 -1
- package/.next/static/css/cb7d1fcea42fab9c.css +0 -1
- package/.next/static/css/df588bb98c0b0ca6.css +0 -1
- package/.next/static/css/e3b039e8f5daf95f.css +0 -1
- package/.next/static/css/f0e2d1b8832e935d.css +0 -1
- package/.next/static/jxv75E0IlXYBYk71TulQP/_buildManifest.js +0 -1
- package/.next/static/jxv75E0IlXYBYk71TulQP/_ssgManifest.js +0 -1
- package/.next/trace +0 -80
- package/public/~partytown/debug/partytown-atomics.js +0 -556
- package/public/~partytown/debug/partytown-media.js +0 -374
- package/public/~partytown/debug/partytown-sandbox-sw.js +0 -543
- package/public/~partytown/debug/partytown-sw.js +0 -59
- package/public/~partytown/debug/partytown-ww-atomics.js +0 -1789
- package/public/~partytown/debug/partytown-ww-sw.js +0 -1781
- package/public/~partytown/debug/partytown.js +0 -72
- package/public/~partytown/partytown-atomics.js +0 -2
- package/public/~partytown/partytown-media.js +0 -2
- package/public/~partytown/partytown-sw.js +0 -2
- package/public/~partytown/partytown.js +0 -2
- package/src/components/ui/ProductGallery/usePageProducts.ts +0 -48
- package/src/customizations/components/overrides/ThirdPartyScripts.tsx +0 -9
- package/src/customizations/scripts/ThirdPartyScripts.tsx +0 -8
package/api/index.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export { gql } from '@faststore/graphql-utils'
|
|
2
|
+
export type {
|
|
3
|
+
StoreAggregateOfferRoot,
|
|
4
|
+
StorePropertyValueRoot,
|
|
5
|
+
StoreCollectionRoot,
|
|
6
|
+
StoreFacetRoot,
|
|
7
|
+
StoreSearchResultRoot,
|
|
8
|
+
StoreSeoRoot,
|
|
9
|
+
StoreShippingSLARoot,
|
|
10
|
+
StoreOfferRoot,
|
|
11
|
+
StoreSkuVariationsRoot,
|
|
12
|
+
StoreProductGroupRoot,
|
|
13
|
+
StoreProductRoot,
|
|
14
|
+
StoreOrganizationRoot,
|
|
15
|
+
} from '@faststore/api'
|
package/codegen.yml
CHANGED
package/generate.sh
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
|
|
3
|
+
# ANSI color codes
|
|
4
|
+
RED='\033[0;31m'
|
|
5
|
+
YELLOW='\033[1;33m'
|
|
6
|
+
PURPLE='\033[0;35m'
|
|
7
|
+
GREEN='\033[0;32m'
|
|
8
|
+
NC='\033[0m' # No Color
|
|
9
|
+
|
|
10
|
+
# Initialize debug flag to false
|
|
11
|
+
DEBUG_FLAG=false
|
|
12
|
+
|
|
13
|
+
# Check for --debug flag
|
|
14
|
+
if [ "$1" = "--debug" ]; then
|
|
15
|
+
DEBUG_FLAG=true
|
|
16
|
+
fi
|
|
17
|
+
|
|
18
|
+
# Function to display errors with readable messages
|
|
19
|
+
show_error() {
|
|
20
|
+
local cmd="$3"
|
|
21
|
+
|
|
22
|
+
echo "${RED}error${NC} $1"
|
|
23
|
+
if [ "$DEBUG_FLAG" = "true" ]; then
|
|
24
|
+
echo "${PURPLE}DEBUG - \$ $cmd ${RED}error root ↓${NC}\n$2"
|
|
25
|
+
fi
|
|
26
|
+
exit 1
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
# Function to display warnings
|
|
30
|
+
show_warning() {
|
|
31
|
+
local cmd="$3"
|
|
32
|
+
|
|
33
|
+
echo "${YELLOW}warn${NC} $1"
|
|
34
|
+
if [ "$DEBUG_FLAG" = "true" ]; then
|
|
35
|
+
echo "${PURPLE}DEBUG - \$ $cmd ${YELLOW}warn root ↓${NC}\n$2"
|
|
36
|
+
fi
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
# Function to run a command and handle errors and warnings
|
|
40
|
+
run_command() {
|
|
41
|
+
local cmd="$1"
|
|
42
|
+
local error_message="$2"
|
|
43
|
+
local warn="$3"
|
|
44
|
+
local output
|
|
45
|
+
|
|
46
|
+
if [ "$DEBUG_FLAG" = "true" ]; then
|
|
47
|
+
output="$($cmd --debug --verbose 2>&1)"
|
|
48
|
+
else
|
|
49
|
+
output="$($cmd 2>&1)"
|
|
50
|
+
fi
|
|
51
|
+
|
|
52
|
+
local exit_code="$?"
|
|
53
|
+
if [ "$warn" = "true" ]; then
|
|
54
|
+
if [ "$exit_code" -ne 0 ]; then
|
|
55
|
+
show_warning "$error_message" "$output" "$cmd"
|
|
56
|
+
fi
|
|
57
|
+
elif [ "$exit_code" -ne 0 ]; then
|
|
58
|
+
show_error "$error_message" "$output" "$cmd"
|
|
59
|
+
fi
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
# Run "yarn generate:schema" without outputting logs and errors
|
|
63
|
+
run_command "yarn generate:schema" "Failed to run 'yarn generate:schema'. Please check your setup." "false"
|
|
64
|
+
|
|
65
|
+
# Run graphql-codegen and capture the output
|
|
66
|
+
run_command "graphql-codegen" "GraphQL was not optimized and TS files were not updated. Changes in the GraphQL layer did not take effect" "false"
|
|
67
|
+
|
|
68
|
+
# Run "yarn format:generated" and display a warning if it produces output
|
|
69
|
+
run_command "yarn format:generated" "Failed to format generated files. 'yarn format:generated' thrown errors" "true"
|
|
70
|
+
|
|
71
|
+
echo "${GREEN}GraphQL schema, types, and optimizations successfully generated 🎉${NC}"
|
package/index.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export {
|
|
2
|
+
usePage,
|
|
3
|
+
usePDP,
|
|
4
|
+
usePLP,
|
|
5
|
+
useSearchPage,
|
|
6
|
+
isPDP,
|
|
7
|
+
isPLP,
|
|
8
|
+
isSearchPage,
|
|
9
|
+
} from './src/sdk/overrides/PageProvider'
|
|
10
|
+
|
|
11
|
+
export type {
|
|
12
|
+
PDPContext,
|
|
13
|
+
PLPContext,
|
|
14
|
+
SearchPageContext,
|
|
15
|
+
} from './src/sdk/overrides/PageProvider'
|
package/jest.config.js
ADDED
package/package.json
CHANGED
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faststore/core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0-alpha.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"browserslist": "supports es6-module and not dead",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": "./index.ts"
|
|
8
|
+
},
|
|
6
9
|
"scripts": {
|
|
7
|
-
"generate": "
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
+
"generate:schema": "tsx src/server/generator/generateGraphQLSchemaFile.ts",
|
|
11
|
+
"generate": "./generate.sh",
|
|
12
|
+
"build": "yarn partytown & yarn generate && next build",
|
|
13
|
+
"dev": "yarn partytown & yarn generate && next dev",
|
|
10
14
|
"clean": "rm -r .next",
|
|
11
15
|
"serve": "next start",
|
|
12
|
-
"test": "cypress open",
|
|
16
|
+
"test:e2e": "cypress open",
|
|
17
|
+
"test": "tsdx test",
|
|
13
18
|
"lhci": "lhci autorun",
|
|
14
19
|
"format": "prettier --write \"**/*.{ts,js,tsx,jsx,json}\"",
|
|
20
|
+
"format:generated": "prettier --write \"@generated/**/*.{ts,js,tsx,jsx,json}\" --loglevel error",
|
|
15
21
|
"lint": "next lint",
|
|
16
22
|
"stylelint": "stylelint \"**/*.scss\"",
|
|
17
23
|
"stylelint:fix": "stylelint \"**/*.scss\" --fix",
|
|
@@ -29,16 +35,24 @@
|
|
|
29
35
|
"@envelop/graphql-jit": "^1.1.1",
|
|
30
36
|
"@envelop/parser-cache": "^2.2.0",
|
|
31
37
|
"@envelop/validation-cache": "^2.2.0",
|
|
32
|
-
"@faststore/api": "^2.
|
|
33
|
-
"@faststore/components": "^2.
|
|
34
|
-
"@faststore/graphql-utils": "^2.
|
|
35
|
-
"@faststore/sdk": "^2.
|
|
36
|
-
"@faststore/ui": "^2.
|
|
38
|
+
"@faststore/api": "^2.2.0-alpha.0",
|
|
39
|
+
"@faststore/components": "^2.2.0-alpha.0",
|
|
40
|
+
"@faststore/graphql-utils": "^2.2.0-alpha.0",
|
|
41
|
+
"@faststore/sdk": "^2.2.0-alpha.0",
|
|
42
|
+
"@faststore/ui": "^2.2.0-alpha.0",
|
|
43
|
+
"@graphql-codegen/cli": "^3.3.1",
|
|
44
|
+
"@graphql-codegen/typescript": "^3.0.4",
|
|
45
|
+
"@graphql-codegen/typescript-operations": "^3.0.4",
|
|
46
|
+
"@graphql-tools/load-files": "^7.0.0",
|
|
47
|
+
"@graphql-tools/merge": "^9.0.0",
|
|
48
|
+
"@graphql-tools/utils": "^9.2.1",
|
|
37
49
|
"@types/react": "^18.0.14",
|
|
38
50
|
"@vtex/client-cms": "^0.2.12",
|
|
51
|
+
"@vtex/prettier-config": "1.0.0",
|
|
39
52
|
"autoprefixer": "^10.4.0",
|
|
40
53
|
"chalk": "^5.2.0",
|
|
41
54
|
"css-loader": "^6.7.1",
|
|
55
|
+
"deepmerge": "^4.3.1",
|
|
42
56
|
"draft-js": "^0.11.7",
|
|
43
57
|
"draft-js-export-html": "^1.4.1",
|
|
44
58
|
"graphql": "^15.0.0",
|
|
@@ -48,6 +62,7 @@
|
|
|
48
62
|
"next-seo": "^5.4.0",
|
|
49
63
|
"nextjs-progressbar": "^0.0.14",
|
|
50
64
|
"postcss": "^8.4.4",
|
|
65
|
+
"prettier": "^2.2.0",
|
|
51
66
|
"react": "^18.2.0",
|
|
52
67
|
"react-dom": "^18.2.0",
|
|
53
68
|
"react-intersection-observer": "^8.32.5",
|
|
@@ -57,15 +72,14 @@
|
|
|
57
72
|
"style-loader": "^3.3.1",
|
|
58
73
|
"swr": "^1.3.0",
|
|
59
74
|
"tsconfig-paths-webpack-plugin": "^3.5.2",
|
|
75
|
+
"tsx": "^3.12.7",
|
|
60
76
|
"typescript": "4.7.3"
|
|
61
77
|
},
|
|
62
78
|
"devDependencies": {
|
|
63
79
|
"@cypress/code-coverage": "^3.9.10",
|
|
64
|
-
"@
|
|
80
|
+
"@envelop/testing": "^6.0.0",
|
|
81
|
+
"@faststore/eslint-config": "^2.2.0-alpha.0",
|
|
65
82
|
"@faststore/lighthouse": "^1.12.32",
|
|
66
|
-
"@graphql-codegen/cli": "^2.6.2",
|
|
67
|
-
"@graphql-codegen/typescript": "^2.5.1",
|
|
68
|
-
"@graphql-codegen/typescript-operations": "^2.4.2",
|
|
69
83
|
"@lhci/cli": "^0.9.0",
|
|
70
84
|
"@storybook/addon-a11y": "^6.5.9",
|
|
71
85
|
"@storybook/addon-actions": "^6.5.9",
|
|
@@ -76,7 +90,7 @@
|
|
|
76
90
|
"@storybook/react": "^6.5.9",
|
|
77
91
|
"@testing-library/cypress": "^8.0.0",
|
|
78
92
|
"@types/cypress": "^1.1.3",
|
|
79
|
-
"@
|
|
93
|
+
"@types/jest": "29.1.0",
|
|
80
94
|
"axe-core": "^4.3.3",
|
|
81
95
|
"cypress": "9.6.0",
|
|
82
96
|
"cypress-axe": "^0.13.0",
|
|
@@ -85,15 +99,16 @@
|
|
|
85
99
|
"eslint": "^7.32.0",
|
|
86
100
|
"husky": "^5.2.0",
|
|
87
101
|
"is-ci": "^3.0.0",
|
|
102
|
+
"jest": "29.1.0",
|
|
88
103
|
"lint-staged": "^10.5.4",
|
|
89
104
|
"msw-storybook-addon": "^1.6.3",
|
|
90
|
-
"prettier": "^2.2.0",
|
|
91
105
|
"stylelint": "^14.6.0",
|
|
92
106
|
"stylelint-config-recess-order": "^3.0.0",
|
|
93
107
|
"stylelint-config-standard": "^24.0.0",
|
|
94
108
|
"stylelint-config-standard-scss": "^3.0.0",
|
|
95
109
|
"stylelint-order": "^5.0.0",
|
|
96
|
-
"stylelint-scss": "^4.0.1"
|
|
110
|
+
"stylelint-scss": "^4.0.1",
|
|
111
|
+
"ts-jest": "29.1.0"
|
|
97
112
|
},
|
|
98
113
|
"lint-staged": {
|
|
99
114
|
"*.{ts,js,tsx,jsx}": [
|
|
@@ -110,5 +125,5 @@
|
|
|
110
125
|
"msw": {
|
|
111
126
|
"workerDirectory": "public"
|
|
112
127
|
},
|
|
113
|
-
"gitHead": "
|
|
128
|
+
"gitHead": "356e52b6eae13cc4000c6915985009d45e7ae0c6"
|
|
114
129
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Partytown } from '@builder.io/partytown/react'
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
import storeConfig from '../../../faststore.config'
|
|
4
4
|
import GoogleTagManager from './GoogleTagManager'
|
|
5
5
|
import VTEX from './vtex'
|
|
@@ -26,7 +26,6 @@ function ThirdPartyScripts() {
|
|
|
26
26
|
<>
|
|
27
27
|
{includeGTM && <GoogleTagManager containerId={gtmContainerId} />}
|
|
28
28
|
{includeVTEX && <VTEX />}
|
|
29
|
-
<OverrideComponents.ThirdPartyScripts />
|
|
30
29
|
<Partytown
|
|
31
30
|
key="partytown"
|
|
32
31
|
// Variables to forward to from main to worker
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import chalk from 'chalk'
|
|
2
|
-
import { ComponentType, PropsWithChildren, useMemo } from 'react'
|
|
2
|
+
import { ComponentType, PropsWithChildren, memo, useMemo } from 'react'
|
|
3
3
|
|
|
4
4
|
import SectionBoundary from './SectionBoundary'
|
|
5
5
|
import { Section } from '@vtex/client-cms'
|
|
@@ -7,7 +7,6 @@ import { Section } from '@vtex/client-cms'
|
|
|
7
7
|
interface Props {
|
|
8
8
|
components: Record<string, ComponentType<any>>
|
|
9
9
|
sections: Array<{ name: string; data: any }>
|
|
10
|
-
context?: unknown
|
|
11
10
|
}
|
|
12
11
|
|
|
13
12
|
const useDividedSections = (sections: Section[]) => {
|
|
@@ -23,7 +22,7 @@ const useDividedSections = (sections: Section[]) => {
|
|
|
23
22
|
}, [sections])
|
|
24
23
|
}
|
|
25
24
|
|
|
26
|
-
const RenderSectionsBase = ({ sections = [],
|
|
25
|
+
const RenderSectionsBase = ({ sections = [], components }: Props) => {
|
|
27
26
|
return (
|
|
28
27
|
<>
|
|
29
28
|
{sections.map(({ name, data }, index) => {
|
|
@@ -42,7 +41,7 @@ const RenderSectionsBase = ({ sections = [], context, components }: Props) => {
|
|
|
42
41
|
|
|
43
42
|
return (
|
|
44
43
|
<SectionBoundary key={`cms-section-${index}`} name={name}>
|
|
45
|
-
<Component {...data}
|
|
44
|
+
<Component {...data} />
|
|
46
45
|
</SectionBoundary>
|
|
47
46
|
)
|
|
48
47
|
})}
|
|
@@ -71,4 +70,4 @@ function RenderSections({
|
|
|
71
70
|
)
|
|
72
71
|
}
|
|
73
72
|
|
|
74
|
-
export default RenderSections
|
|
73
|
+
export default memo(RenderSections)
|
|
@@ -2,18 +2,19 @@ import {
|
|
|
2
2
|
ProductGrid as UIProductGrid,
|
|
3
3
|
ProductGridItem as UIProductGridItem,
|
|
4
4
|
} from '@faststore/ui'
|
|
5
|
-
import type {
|
|
5
|
+
import type { ClientProductsQueryQuery } from '@generated/graphql'
|
|
6
6
|
import ProductGridSkeleton from 'src/components/skeletons/ProductGridSkeleton'
|
|
7
7
|
|
|
8
8
|
import { ProductCardProps } from '../ProductCard'
|
|
9
9
|
|
|
10
10
|
import { __experimentalProductCard as ProductCard } from 'src/components/sections/ProductGallery/Overrides'
|
|
11
|
+
import { memo } from 'react'
|
|
11
12
|
|
|
12
13
|
interface Props {
|
|
13
14
|
/**
|
|
14
15
|
* Products listed on the grid.
|
|
15
16
|
*/
|
|
16
|
-
products:
|
|
17
|
+
products: ClientProductsQueryQuery['search']['products']['edges']
|
|
17
18
|
page: number
|
|
18
19
|
/**
|
|
19
20
|
* Quantity of products listed.
|
|
@@ -64,4 +65,4 @@ function ProductGrid({
|
|
|
64
65
|
)
|
|
65
66
|
}
|
|
66
67
|
|
|
67
|
-
export default ProductGrid
|
|
68
|
+
export default memo(ProductGrid)
|
|
@@ -4,36 +4,31 @@ import Breadcrumb from 'src/components/ui/Breadcrumb'
|
|
|
4
4
|
|
|
5
5
|
import Section from '../Section'
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
ServerCollectionPageQueryQuery,
|
|
9
|
-
ServerProductPageQueryQuery,
|
|
10
|
-
} from '@generated/graphql'
|
|
11
7
|
import styles from './section.module.scss'
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
8
|
+
import {
|
|
9
|
+
PDPContext,
|
|
10
|
+
PLPContext,
|
|
11
|
+
isPDP,
|
|
12
|
+
isPLP,
|
|
13
|
+
usePage,
|
|
14
|
+
} from 'src/sdk/overrides/PageProvider'
|
|
16
15
|
|
|
17
16
|
interface BreadcrumbSectionProps {
|
|
18
|
-
context?: BreadcrumbContext
|
|
19
17
|
icon: string
|
|
20
18
|
alt: string
|
|
21
19
|
}
|
|
22
20
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
x?.seo != undefined && x?.seo != null && x?.sku == undefined
|
|
29
|
-
|
|
30
|
-
function BreadcrumbSection({ context, ...otherProps }: BreadcrumbSectionProps) {
|
|
31
|
-
const title = isCollection(context) ? context?.seo?.title : 'All Products'
|
|
21
|
+
function BreadcrumbSection({ ...otherProps }: BreadcrumbSectionProps) {
|
|
22
|
+
const context = usePage<PDPContext | PLPContext>()
|
|
23
|
+
const title = isPLP(context)
|
|
24
|
+
? context?.data?.collection?.seo?.title
|
|
25
|
+
: 'All Products'
|
|
32
26
|
const fallback = [{ item: '/', name: title, position: 1 }]
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
27
|
+
|
|
28
|
+
const breadcrumbList = isPDP(context)
|
|
29
|
+
? context?.data?.product?.breadcrumbList?.itemListElement
|
|
30
|
+
: isPLP(context)
|
|
31
|
+
? context?.data?.collection?.breadcrumbList?.itemListElement
|
|
37
32
|
: fallback
|
|
38
33
|
|
|
39
34
|
return (
|
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
import { useMemo } from 'react'
|
|
2
2
|
|
|
3
|
-
import type { ProductDetailsFragment_ProductFragment } from '@generated/graphql'
|
|
4
3
|
import UIProductShelf from 'src/components/ui/ProductShelf'
|
|
5
4
|
import { useInView } from 'react-intersection-observer'
|
|
5
|
+
import { useProductsQuery } from 'src/sdk/product/useProductsQuery'
|
|
6
|
+
import { usePDP } from 'src/sdk/overrides/PageProvider'
|
|
6
7
|
import styles from '../ProductShelf/section.module.scss'
|
|
7
8
|
import Section from '../Section'
|
|
8
9
|
|
|
9
10
|
interface Props {
|
|
10
11
|
items: number
|
|
11
12
|
title: string
|
|
12
|
-
context: ProductDetailsFragment_ProductFragment
|
|
13
13
|
kind: 'buy' | 'view'
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
const CrossSellingShelf = ({ items, title,
|
|
16
|
+
const CrossSellingShelf = ({ items: first, title, kind }: Props) => {
|
|
17
17
|
const { ref, inView } = useInView()
|
|
18
|
+
const context = usePDP()
|
|
19
|
+
const productGroupID = context?.data?.product?.isVariantOf?.productGroupID
|
|
18
20
|
|
|
19
21
|
const selectedFacets = useMemo(
|
|
20
|
-
() => [{ key: kind, value:
|
|
21
|
-
[kind,
|
|
22
|
+
() => [{ key: kind, value: productGroupID }],
|
|
23
|
+
[kind, productGroupID]
|
|
22
24
|
)
|
|
23
25
|
|
|
24
26
|
return (
|
|
@@ -28,7 +30,7 @@ const CrossSellingShelf = ({ items, title, context, kind }: Props) => {
|
|
|
28
30
|
>
|
|
29
31
|
<UIProductShelf
|
|
30
32
|
inView={inView}
|
|
31
|
-
first={
|
|
33
|
+
first={first}
|
|
32
34
|
title={title}
|
|
33
35
|
selectedFacets={selectedFacets}
|
|
34
36
|
/>
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { useEffect, useState } from 'react'
|
|
2
2
|
|
|
3
3
|
import { gql } from '@faststore/graphql-utils'
|
|
4
|
-
import { sendAnalyticsEvent } from '@faststore/sdk'
|
|
5
4
|
import type { CurrencyCode, ViewItemEvent } from '@faststore/sdk'
|
|
6
|
-
import
|
|
5
|
+
import { sendAnalyticsEvent } from '@faststore/sdk'
|
|
7
6
|
|
|
8
|
-
import { useSession } from 'src/sdk/session'
|
|
9
|
-
import { useProduct } from 'src/sdk/product/useProduct'
|
|
10
|
-
import { useFormattedPrice } from 'src/sdk/product/useFormattedPrice'
|
|
11
7
|
import type { AnalyticsItem } from 'src/sdk/analytics/types'
|
|
8
|
+
import { useFormattedPrice } from 'src/sdk/product/useFormattedPrice'
|
|
9
|
+
import { useSession } from 'src/sdk/session'
|
|
12
10
|
|
|
13
11
|
import Section from '../Section'
|
|
14
12
|
import ProductDescription from 'src/components/ui/ProductDescription'
|
|
@@ -17,15 +15,13 @@ import { ProductDetailsSettings } from 'src/components/ui/ProductDetails'
|
|
|
17
15
|
import styles from './section.module.scss'
|
|
18
16
|
|
|
19
17
|
import {
|
|
20
|
-
ProductTitle,
|
|
21
18
|
DiscountBadge,
|
|
19
|
+
ProductTitle,
|
|
22
20
|
__experimentalImageGallery as ImageGallery,
|
|
23
21
|
__experimentalShippingSimulation as ShippingSimulation,
|
|
24
22
|
} from 'src/components/sections/ProductDetails/Overrides'
|
|
25
23
|
|
|
26
|
-
|
|
27
|
-
context: ProductDetailsFragment_ProductFragment
|
|
28
|
-
}
|
|
24
|
+
import { usePDP } from 'src/sdk/overrides/PageProvider'
|
|
29
25
|
|
|
30
26
|
export interface ProductDetailsProps {
|
|
31
27
|
productTitle: {
|
|
@@ -59,7 +55,6 @@ export interface ProductDetailsProps {
|
|
|
59
55
|
}
|
|
60
56
|
|
|
61
57
|
function ProductDetails({
|
|
62
|
-
context: staleProduct,
|
|
63
58
|
productTitle: {
|
|
64
59
|
refNumber: showRefNumber,
|
|
65
60
|
discountBadge: {
|
|
@@ -87,36 +82,31 @@ function ProductDetails({
|
|
|
87
82
|
initiallyExpanded: productDescriptionInitiallyExpanded,
|
|
88
83
|
displayDescription: shouldDisplayProductDescription,
|
|
89
84
|
},
|
|
90
|
-
}: ProductDetailsProps
|
|
85
|
+
}: ProductDetailsProps) {
|
|
91
86
|
const { currency } = useSession()
|
|
92
87
|
const [quantity, setQuantity] = useState(1)
|
|
88
|
+
const context = usePDP()
|
|
89
|
+
const { product, isValidating } = context?.data
|
|
93
90
|
|
|
94
|
-
|
|
95
|
-
const { data, isValidating } = useProduct(staleProduct.id, {
|
|
96
|
-
product: staleProduct,
|
|
97
|
-
})
|
|
98
|
-
|
|
99
|
-
if (!data) {
|
|
91
|
+
if (!product) {
|
|
100
92
|
throw new Error('NotFound')
|
|
101
93
|
}
|
|
102
94
|
|
|
103
95
|
const {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
offers: {
|
|
115
|
-
|
|
116
|
-
lowPrice,
|
|
117
|
-
},
|
|
96
|
+
id,
|
|
97
|
+
sku,
|
|
98
|
+
gtin,
|
|
99
|
+
name: variantName,
|
|
100
|
+
brand,
|
|
101
|
+
isVariantOf,
|
|
102
|
+
description,
|
|
103
|
+
isVariantOf: { name, productGroupID: productId },
|
|
104
|
+
image: productImages,
|
|
105
|
+
offers: {
|
|
106
|
+
offers: [{ availability, price, listPrice, seller }],
|
|
107
|
+
lowPrice,
|
|
118
108
|
},
|
|
119
|
-
} =
|
|
109
|
+
} = product
|
|
120
110
|
|
|
121
111
|
useEffect(() => {
|
|
122
112
|
sendAnalyticsEvent<ViewItemEvent<AnalyticsItem>>({
|
|
@@ -191,7 +181,7 @@ function ProductDetails({
|
|
|
191
181
|
>
|
|
192
182
|
{!outOfStock ? (
|
|
193
183
|
<ProductDetailsSettings
|
|
194
|
-
product={
|
|
184
|
+
product={product}
|
|
195
185
|
isValidating={isValidating}
|
|
196
186
|
buyButtonTitle={buyButtonTitle}
|
|
197
187
|
quantity={quantity}
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import { mark } from 'src/sdk/tests/mark'
|
|
2
2
|
|
|
3
|
-
import { ServerCollectionPageQueryQuery } from '@generated/graphql'
|
|
4
3
|
import ProductGallery, {
|
|
5
4
|
ProductGalleryProps,
|
|
6
5
|
} from 'src/components/ui/ProductGallery/ProductGallery'
|
|
7
|
-
import { SearchPageContextType } from 'src/pages/s'
|
|
8
6
|
import Section from '../Section'
|
|
9
7
|
import EmptyGallery from './EmptyGallery'
|
|
10
8
|
import styles from './section.module.scss'
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
import {
|
|
10
|
+
PLPContext,
|
|
11
|
+
SearchPageContext,
|
|
12
|
+
isPLP,
|
|
13
|
+
isSearchPage,
|
|
14
|
+
usePage,
|
|
15
|
+
} from 'src/sdk/overrides/PageProvider'
|
|
14
16
|
|
|
15
17
|
export interface ProductGallerySectionProps {
|
|
16
|
-
context?: ProductGalleryContext
|
|
17
18
|
searchTermLabel?: ProductGalleryProps['searchTermLabel']
|
|
18
19
|
totalCountLabel?: ProductGalleryProps['totalCountLabel']
|
|
19
20
|
filter: ProductGalleryProps['filter']
|
|
@@ -24,28 +25,17 @@ export interface ProductGallerySectionProps {
|
|
|
24
25
|
productCard?: ProductGalleryProps['productCard']
|
|
25
26
|
}
|
|
26
27
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
function ProductGallerySection({
|
|
35
|
-
context,
|
|
36
|
-
...otherProps
|
|
37
|
-
}: ProductGallerySectionProps) {
|
|
38
|
-
const [title, searchTerm] = isSearch(context)
|
|
39
|
-
? [context?.title, context?.searchTerm]
|
|
40
|
-
: isCollection(context)
|
|
41
|
-
? [context?.seo?.title]
|
|
28
|
+
function ProductGallerySection({ ...otherProps }: ProductGallerySectionProps) {
|
|
29
|
+
const context = usePage<SearchPageContext | PLPContext>()
|
|
30
|
+
const [title, searchTerm] = isSearchPage(context)
|
|
31
|
+
? [context?.data?.title, context?.data?.searchTerm]
|
|
32
|
+
: isPLP(context)
|
|
33
|
+
? [context?.data?.collection?.seo?.title]
|
|
42
34
|
: ['']
|
|
43
35
|
|
|
44
|
-
const
|
|
45
|
-
const totalCount =
|
|
46
|
-
productGalleryData?.search.products.pageInfo.totalCount ?? 0
|
|
36
|
+
const totalCount = context?.data?.search?.products?.pageInfo?.totalCount ?? 0
|
|
47
37
|
|
|
48
|
-
if (
|
|
38
|
+
if (context?.data?.search?.products && totalCount === 0) {
|
|
49
39
|
return (
|
|
50
40
|
<Section className={`${styles.section} section-product-gallery`}>
|
|
51
41
|
<section data-testid="product-gallery" data-fs-product-listing>
|
|
@@ -62,7 +52,6 @@ function ProductGallerySection({
|
|
|
62
52
|
<ProductGallery
|
|
63
53
|
title={title}
|
|
64
54
|
searchTerm={searchTerm}
|
|
65
|
-
productGalleryData={productGalleryData}
|
|
66
55
|
totalCount={totalCount}
|
|
67
56
|
{...otherProps}
|
|
68
57
|
/>
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { useInView } from 'react-intersection-observer'
|
|
2
2
|
import Section from '../Section'
|
|
3
3
|
|
|
4
|
-
import styles from './section.module.scss'
|
|
5
4
|
import ProductShelf, { ProductShelfProps } from 'src/components/ui/ProductShelf'
|
|
5
|
+
import styles from './section.module.scss'
|
|
6
6
|
|
|
7
7
|
function ProductShelfSection({
|
|
8
8
|
...otherProps
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useEffect, useRef } from 'react'
|
|
2
2
|
import { useInView } from 'react-intersection-observer'
|
|
3
3
|
|
|
4
|
-
import type {
|
|
4
|
+
import type { ClientProductsQueryQueryVariables } from '@generated/graphql'
|
|
5
5
|
import ProductCard from 'src/components/product/ProductCard'
|
|
6
6
|
import ProductTilesSkeleton from 'src/components/skeletons/ProductTilesSkeleton'
|
|
7
7
|
import Tiles, { Tile } from 'src/components/ui/Tiles'
|
|
@@ -12,7 +12,7 @@ import Section from '../Section'
|
|
|
12
12
|
|
|
13
13
|
import styles from './section.module.scss'
|
|
14
14
|
|
|
15
|
-
interface ProductTilesProps extends Partial<
|
|
15
|
+
interface ProductTilesProps extends Partial<ClientProductsQueryQueryVariables> {
|
|
16
16
|
title: string
|
|
17
17
|
}
|
|
18
18
|
|
|
@@ -56,7 +56,8 @@ const getSizes = (products: number, idx: number) => {
|
|
|
56
56
|
const ProductTiles = ({ title, ...variables }: ProductTilesProps) => {
|
|
57
57
|
const viewedOnce = useRef(false)
|
|
58
58
|
const { ref, inView } = useInView()
|
|
59
|
-
const
|
|
59
|
+
const data = useProductsQuery(variables)
|
|
60
|
+
const products = data?.search?.products
|
|
60
61
|
const productEdges = products?.edges ?? []
|
|
61
62
|
|
|
62
63
|
const { sendViewItemListEvent } = useViewItemListEvent({
|