@akinon/projectzero 2.0.79-beta.1 → 2.0.79-rc.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/CHANGELOG.md +6 -2
- package/app-template/.env.example +1 -10
- package/app-template/AGENTS.md +8 -0
- package/app-template/CHANGELOG.md +81 -65
- package/app-template/README.md +25 -1
- package/app-template/next.config.mjs +7 -1
- package/app-template/package.json +41 -41
- package/app-template/src/app/[pz]/layout.tsx +0 -20
- package/app-template/src/app/api/client-env/route.ts +5 -0
- package/app-template/src/app/global-error.tsx +22 -0
- package/app-template/src/hooks/favourite-product-ids-context.tsx +104 -0
- package/app-template/src/hooks/index.ts +2 -0
- package/app-template/src/hooks/use-fav-button.tsx +35 -13
- package/app-template/src/plugins.js +1 -0
- package/app-template/src/proxy.ts +4 -47
- package/app-template/src/settings.js +0 -17
- package/app-template/src/utils/__tests__/favourite-product-ids-fallback.test.ts +42 -0
- package/app-template/src/utils/favourite-product-ids-fallback.ts +51 -0
- package/app-template/src/views/category/category-info.tsx +25 -17
- package/app-template/src/views/header/search/index.tsx +13 -5
- package/app-template/src/views/product/slider.tsx +85 -38
- package/app-template/src/views/product-item/index.tsx +1 -1
- package/commands/plugins.ts +4 -0
- package/dist/commands/plugins.js +4 -0
- package/package.json +1 -1
- package/app-template/src/app/api/preview/link/route.ts +0 -115
- package/app-template/src/app/api/preview/route.ts +0 -96
- package/app-template/src/utils/__tests__/preview-contract.test.ts +0 -223
package/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
# @akinon/projectzero
|
|
2
2
|
|
|
3
|
-
## 2.0.79-
|
|
3
|
+
## 2.0.79-rc.0
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 143be2b9d: ZERO-3457: Crop styles are customizable and logic improved for rendering similar products modal
|
|
8
|
+
- d99a6a7d5: ZERO-3457_1: Fixed the settings prop and made sure everything is customizable.
|
|
9
|
+
- e18836b20: ZERO-4160: Restore scope in Sentry addon configuration in akinon.json
|
|
6
10
|
|
|
7
11
|
## 2.0.78
|
|
8
12
|
|
|
@@ -7,6 +7,7 @@ NEXT_PUBLIC_URL=http://localhost:3000
|
|
|
7
7
|
SERVICE_BACKEND_URL=https://02fde10fee4440269e695aa10707dfaf.lb.akinoncloud.com
|
|
8
8
|
SITEMAP_S3_BUCKET_NAME=0fb534
|
|
9
9
|
NEXT_PUBLIC_VIRTUAL_TRY_ON_API_URL=https://d2a26507c7094f359aba349b96a96881.lb.akinoncloud.com
|
|
10
|
+
NEXT_PUBLIC_ENABLE_IMAGE_SEARCH=true
|
|
10
11
|
|
|
11
12
|
# PZ Dashboard dataLayer observability (unset = observer disabled)
|
|
12
13
|
# NEXT_PUBLIC_PZ_DASHBOARD_URL=http://localhost:3005
|
|
@@ -21,13 +22,3 @@ NEXT_PUBLIC_VIRTUAL_TRY_ON_API_URL=https://d2a26507c7094f359aba349b96a96881.lb.a
|
|
|
21
22
|
# CACHE_KEY_PREFIX=
|
|
22
23
|
|
|
23
24
|
# BF_CACHE=false
|
|
24
|
-
|
|
25
|
-
# Widget preview (theme editor named previews).
|
|
26
|
-
# PREVIEW_SECRET signs the expiring preview links the editor requests from
|
|
27
|
-
# /api/preview/link; it never travels in a url. Unset = preview disabled.
|
|
28
|
-
# OMNITRON_URL is the Omnitron the editor is signed into — the link endpoint
|
|
29
|
-
# verifies the editor's session token there before minting a link.
|
|
30
|
-
# PREVIEW_LINK_TTL_SECONDS: how long a link stays valid (default 86400 = 24h).
|
|
31
|
-
# PREVIEW_SECRET=
|
|
32
|
-
# OMNITRON_URL=https://<omnitron-host>
|
|
33
|
-
# PREVIEW_LINK_TTL_SECONDS=86400
|
package/app-template/AGENTS.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
<!-- BEGIN:nextjs-agent-rules -->
|
|
2
|
+
|
|
3
|
+
# Next.js: ALWAYS read docs before coding
|
|
4
|
+
|
|
5
|
+
Before any Next.js work, find and read the relevant doc in `node_modules/next/dist/docs/`. Your training data is outdated — the docs are the source of truth.
|
|
6
|
+
|
|
7
|
+
<!-- END:nextjs-agent-rules -->
|
|
8
|
+
|
|
1
9
|
# Project Zero Next.js - Developer Instructions
|
|
2
10
|
|
|
3
11
|
## 📚 Available Instruction Files
|
|
@@ -1,70 +1,86 @@
|
|
|
1
1
|
# projectzeronext
|
|
2
2
|
|
|
3
|
-
## 2.0.79-
|
|
4
|
-
|
|
5
|
-
### Patch Changes
|
|
6
|
-
|
|
7
|
-
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
- Updated dependencies [
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
- @akinon/pz-
|
|
58
|
-
- @akinon/
|
|
59
|
-
- @akinon/pz-
|
|
60
|
-
- @akinon/pz-
|
|
61
|
-
- @akinon/pz-one-click-checkout@2.0.79-
|
|
62
|
-
- @akinon/pz-
|
|
63
|
-
- @akinon/pz-pay-on-delivery@2.0.79-
|
|
64
|
-
- @akinon/pz-
|
|
65
|
-
- @akinon/pz-
|
|
66
|
-
- @akinon/pz-
|
|
67
|
-
- @akinon/pz-
|
|
3
|
+
## 2.0.79-rc.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 1a8622a9b: ZERO-3392: Implemented AI Search functionality and update env
|
|
8
|
+
- 2fea4143: ZERO-4620: Add runtime access to `NEXT_PUBLIC_*` environment variables from Client Components
|
|
9
|
+
- b55acb768: ZERO-2577: Fix pagination bug and update usePagination hook and ensure pagination controls rendering correctly
|
|
10
|
+
- 143be2b9d: ZERO-3457: Crop styles are customizable and logic improved for rendering similar products modal
|
|
11
|
+
- 9f8cd3bc5: ZERO-3449: AI Search Active Filters & Crop Style changes have been implemented
|
|
12
|
+
- d99a6a7d5: ZERO-3457_1: Fixed the settings prop and made sure everything is customizable.
|
|
13
|
+
- 8a0379e6: ZERO-4845: Implement FavouriteProductIds context and provider; enhance fav button logic and add tests for fallback functionality
|
|
14
|
+
- ccf21475d: ZERO-4404: Add Next.js 16.2 AI improvements
|
|
15
|
+
- c0228aff0: ZERO-4159: Upgrade the package versions
|
|
16
|
+
- b05c35435: ZERO-2570: Category filters routes to absolute url
|
|
17
|
+
- e18836b20: ZERO-4160: Restore scope in Sentry addon configuration in akinon.json
|
|
18
|
+
- c3244a310: ZERO-4013: Update runtime version to node:25-alpine in project configuration
|
|
19
|
+
- Updated dependencies [a3e2acbf8]
|
|
20
|
+
- Updated dependencies [86187b1c]
|
|
21
|
+
- Updated dependencies [0cf9ea239]
|
|
22
|
+
- Updated dependencies [324f97d55]
|
|
23
|
+
- Updated dependencies [51ea06888]
|
|
24
|
+
- Updated dependencies
|
|
25
|
+
- Updated dependencies [c97525a31]
|
|
26
|
+
- Updated dependencies [eba125b24]
|
|
27
|
+
- Updated dependencies [2fea4143]
|
|
28
|
+
- Updated dependencies [119f0c11]
|
|
29
|
+
- Updated dependencies [823a4449a]
|
|
30
|
+
- Updated dependencies [b55acb768]
|
|
31
|
+
- Updated dependencies [760258c1c]
|
|
32
|
+
- Updated dependencies [5da13fffc]
|
|
33
|
+
- Updated dependencies [143be2b9d]
|
|
34
|
+
- Updated dependencies [7889b08fe]
|
|
35
|
+
- Updated dependencies [fb4aa9b47]
|
|
36
|
+
- Updated dependencies [9f8cd3bc5]
|
|
37
|
+
- Updated dependencies [bfafa3f49]
|
|
38
|
+
- Updated dependencies [00b9f488f]
|
|
39
|
+
- Updated dependencies [57d7eb305]
|
|
40
|
+
- Updated dependencies [d99a6a7d5]
|
|
41
|
+
- Updated dependencies [9db81a714]
|
|
42
|
+
- Updated dependencies [591e345e1]
|
|
43
|
+
- Updated dependencies [0df6bc1f8]
|
|
44
|
+
- Updated dependencies [4de5303c5]
|
|
45
|
+
- Updated dependencies [63a720003]
|
|
46
|
+
- Updated dependencies [95b139dc1]
|
|
47
|
+
- Updated dependencies [1d00f2d06]
|
|
48
|
+
- Updated dependencies [4ac7b2a1e]
|
|
49
|
+
- Updated dependencies [e9598c71]
|
|
50
|
+
- Updated dependencies [4998a9631]
|
|
51
|
+
- Updated dependencies [804d2bd6c]
|
|
52
|
+
- Updated dependencies [c0228aff0]
|
|
53
|
+
- Updated dependencies [3909d3224]
|
|
54
|
+
- Updated dependencies [6a3d8a631]
|
|
55
|
+
- Updated dependencies [e18836b20]
|
|
56
|
+
- Updated dependencies [b1111d7b]
|
|
57
|
+
- @akinon/pz-tabby-extension@2.0.79-rc.0
|
|
58
|
+
- @akinon/next@2.0.79-rc.0
|
|
59
|
+
- @akinon/pz-checkout-gift-pack@2.0.79-rc.0
|
|
60
|
+
- @akinon/pz-masterpass-rest@2.0.79-rc.0
|
|
61
|
+
- @akinon/pz-one-click-checkout@2.0.79-rc.0
|
|
62
|
+
- @akinon/pz-basket-gift-pack@2.0.79-rc.0
|
|
63
|
+
- @akinon/pz-pay-on-delivery@2.0.79-rc.0
|
|
64
|
+
- @akinon/pz-credit-payment@2.0.79-rc.0
|
|
65
|
+
- @akinon/pz-click-collect@2.0.79-rc.0
|
|
66
|
+
- @akinon/pz-multi-basket@2.0.79-rc.0
|
|
67
|
+
- @akinon/pz-masterpass@2.0.79-rc.0
|
|
68
|
+
- @akinon/pz-gpay@2.0.79-rc.0
|
|
69
|
+
- @akinon/pz-b2b@2.0.79-rc.0
|
|
70
|
+
- @akinon/pz-bkm@2.0.79-rc.0
|
|
71
|
+
- @akinon/pz-otp@2.0.79-rc.0
|
|
72
|
+
- @akinon/pz-similar-products@2.0.79-rc.0
|
|
73
|
+
- @akinon/pz-virtual-try-on@2.0.79-rc.0
|
|
74
|
+
- @akinon/pz-theme@2.0.79-rc.0
|
|
75
|
+
- @akinon/pz-akifast@2.0.79-rc.0
|
|
76
|
+
- @akinon/pz-apple-pay@2.0.79-rc.0
|
|
77
|
+
- @akinon/pz-cybersource-uc@2.0.79-rc.0
|
|
78
|
+
- @akinon/pz-flow-payment@2.0.79-rc.0
|
|
79
|
+
- @akinon/pz-google-pay@2.0.79-rc.0
|
|
80
|
+
- @akinon/pz-haso@2.0.79-rc.0
|
|
81
|
+
- @akinon/pz-hepsipay@2.0.79-rc.0
|
|
82
|
+
- @akinon/pz-saved-card@2.0.79-rc.0
|
|
83
|
+
- @akinon/pz-tamara-extension@2.0.79-rc.0
|
|
68
84
|
|
|
69
85
|
## 2.0.78
|
|
70
86
|
|
package/app-template/README.md
CHANGED
|
@@ -12,6 +12,30 @@ Run `cp .env.example .env && yarn` command at project root and all dependencies
|
|
|
12
12
|
|
|
13
13
|
- `SITEMAP_S3_BUCKET_NAME`: S3 bucket name for XML sitemaps (e.g., "0fb534"). This is required for the sitemap route to function correctly.
|
|
14
14
|
|
|
15
|
+
### Optional Environment Variables
|
|
16
|
+
|
|
17
|
+
- `NEXT_PUBLIC_ENABLE_IMAGE_SEARCH`: Set to `true` to enable image search feature for all users. If not set or `false`, the feature will only be visible to users who have enabled it via localStorage.
|
|
18
|
+
|
|
19
|
+
## Image Search Feature
|
|
20
|
+
|
|
21
|
+
The image search functionality allows users to search for similar products by uploading images or cropping existing product images.
|
|
22
|
+
|
|
23
|
+
### Feature Visibility Control
|
|
24
|
+
|
|
25
|
+
The image search feature can be controlled in two ways:
|
|
26
|
+
|
|
27
|
+
1. **Environment Variable (Global)**: Set `NEXT_PUBLIC_ENABLE_IMAGE_SEARCH=true` to enable for all users
|
|
28
|
+
2. **localStorage (Individual Users)**: Users can enable it locally using browser developer tools
|
|
29
|
+
|
|
30
|
+
````
|
|
31
|
+
|
|
32
|
+
### Feature Locations
|
|
33
|
+
|
|
34
|
+
When enabled, the image search feature appears in:
|
|
35
|
+
|
|
36
|
+
- **Header Search**: Camera icon next to the search input
|
|
37
|
+
- **Product Detail Page**: "View Similar Styles" button on product images
|
|
38
|
+
|
|
15
39
|
### Build
|
|
16
40
|
|
|
17
41
|
To build the app, run the following command:
|
|
@@ -19,7 +43,7 @@ To build the app, run the following command:
|
|
|
19
43
|
```bash
|
|
20
44
|
cd projectzeronext # Project root
|
|
21
45
|
yarn build
|
|
22
|
-
|
|
46
|
+
````
|
|
23
47
|
|
|
24
48
|
### Develop
|
|
25
49
|
|
|
@@ -38,6 +38,9 @@ const nextConfig = {
|
|
|
38
38
|
]
|
|
39
39
|
}
|
|
40
40
|
];
|
|
41
|
+
},
|
|
42
|
+
logging: {
|
|
43
|
+
browserToTerminal: 'error'
|
|
41
44
|
}
|
|
42
45
|
};
|
|
43
46
|
|
|
@@ -50,9 +53,12 @@ const withSerwist = withSerwistInit({
|
|
|
50
53
|
const sentryConfig = {
|
|
51
54
|
silent: true,
|
|
52
55
|
dryRun: !process.env.SENTRY_DSN,
|
|
53
|
-
org: 'akinon'
|
|
56
|
+
org: 'akinon',
|
|
54
57
|
// project: 'enter_your_project_name_here',
|
|
55
58
|
// authToken: 'enter_your_auth_token_here'
|
|
59
|
+
sourcemaps: {
|
|
60
|
+
deleteSourcemapsAfterUpload: true
|
|
61
|
+
}
|
|
56
62
|
};
|
|
57
63
|
|
|
58
64
|
const enhancedConfig = withPzConfig(nextConfig);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "projectzeronext",
|
|
3
|
-
"version": "2.0.79-
|
|
3
|
+
"version": "2.0.79-rc.0",
|
|
4
4
|
"private": true,
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"scripts": {
|
|
@@ -24,33 +24,33 @@
|
|
|
24
24
|
"test:middleware": "jest middleware-matcher.test.ts --bail"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@akinon/next": "2.0.79-
|
|
28
|
-
"@akinon/pz-akifast": "2.0.79-
|
|
29
|
-
"@akinon/pz-apple-pay": "2.0.79-
|
|
30
|
-
"@akinon/pz-b2b": "2.0.79-
|
|
31
|
-
"@akinon/pz-basket-gift-pack": "2.0.79-
|
|
32
|
-
"@akinon/pz-bkm": "2.0.79-
|
|
33
|
-
"@akinon/pz-checkout-gift-pack": "2.0.79-
|
|
34
|
-
"@akinon/pz-click-collect": "2.0.79-
|
|
35
|
-
"@akinon/pz-credit-payment": "2.0.79-
|
|
36
|
-
"@akinon/pz-cybersource-uc": "2.0.79-
|
|
37
|
-
"@akinon/pz-flow-payment": "2.0.79-
|
|
38
|
-
"@akinon/pz-google-pay": "2.0.79-
|
|
39
|
-
"@akinon/pz-gpay": "2.0.79-
|
|
40
|
-
"@akinon/pz-haso": "2.0.79-
|
|
41
|
-
"@akinon/pz-hepsipay": "2.0.79-
|
|
42
|
-
"@akinon/pz-masterpass": "2.0.79-
|
|
43
|
-
"@akinon/pz-masterpass-rest": "2.0.79-
|
|
44
|
-
"@akinon/pz-multi-basket": "2.0.79-
|
|
45
|
-
"@akinon/pz-one-click-checkout": "2.0.79-
|
|
46
|
-
"@akinon/pz-otp": "2.0.79-
|
|
47
|
-
"@akinon/pz-pay-on-delivery": "2.0.79-
|
|
48
|
-
"@akinon/pz-saved-card": "2.0.79-
|
|
49
|
-
"@akinon/pz-similar-products": "2.0.79-
|
|
50
|
-
"@akinon/pz-tabby-extension": "2.0.79-
|
|
51
|
-
"@akinon/pz-tamara-extension": "2.0.79-
|
|
52
|
-
"@akinon/pz-theme": "2.0.79-
|
|
53
|
-
"@akinon/pz-virtual-try-on": "2.0.79-
|
|
27
|
+
"@akinon/next": "2.0.79-rc.0",
|
|
28
|
+
"@akinon/pz-akifast": "2.0.79-rc.0",
|
|
29
|
+
"@akinon/pz-apple-pay": "2.0.79-rc.0",
|
|
30
|
+
"@akinon/pz-b2b": "2.0.79-rc.0",
|
|
31
|
+
"@akinon/pz-basket-gift-pack": "2.0.79-rc.0",
|
|
32
|
+
"@akinon/pz-bkm": "2.0.79-rc.0",
|
|
33
|
+
"@akinon/pz-checkout-gift-pack": "2.0.79-rc.0",
|
|
34
|
+
"@akinon/pz-click-collect": "2.0.79-rc.0",
|
|
35
|
+
"@akinon/pz-credit-payment": "2.0.79-rc.0",
|
|
36
|
+
"@akinon/pz-cybersource-uc": "2.0.79-rc.0",
|
|
37
|
+
"@akinon/pz-flow-payment": "2.0.79-rc.0",
|
|
38
|
+
"@akinon/pz-google-pay": "2.0.79-rc.0",
|
|
39
|
+
"@akinon/pz-gpay": "2.0.79-rc.0",
|
|
40
|
+
"@akinon/pz-haso": "2.0.79-rc.0",
|
|
41
|
+
"@akinon/pz-hepsipay": "2.0.79-rc.0",
|
|
42
|
+
"@akinon/pz-masterpass": "2.0.79-rc.0",
|
|
43
|
+
"@akinon/pz-masterpass-rest": "2.0.79-rc.0",
|
|
44
|
+
"@akinon/pz-multi-basket": "2.0.79-rc.0",
|
|
45
|
+
"@akinon/pz-one-click-checkout": "2.0.79-rc.0",
|
|
46
|
+
"@akinon/pz-otp": "2.0.79-rc.0",
|
|
47
|
+
"@akinon/pz-pay-on-delivery": "2.0.79-rc.0",
|
|
48
|
+
"@akinon/pz-saved-card": "2.0.79-rc.0",
|
|
49
|
+
"@akinon/pz-similar-products": "2.0.79-rc.0",
|
|
50
|
+
"@akinon/pz-tabby-extension": "2.0.79-rc.0",
|
|
51
|
+
"@akinon/pz-tamara-extension": "2.0.79-rc.0",
|
|
52
|
+
"@akinon/pz-theme": "2.0.79-rc.0",
|
|
53
|
+
"@akinon/pz-virtual-try-on": "2.0.79-rc.0",
|
|
54
54
|
"@hookform/resolvers": "2.9.0",
|
|
55
55
|
"@next/third-parties": "16.2.6",
|
|
56
56
|
"@react-google-maps/api": "2.17.1",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"next": "16.2.6",
|
|
60
60
|
"@serwist/next": "9.5.11",
|
|
61
61
|
"next-auth": "5.0.0-beta.30",
|
|
62
|
-
"pino": "8.
|
|
62
|
+
"pino": "8.21.0",
|
|
63
63
|
"serwist": "9.5.11",
|
|
64
64
|
"postcss": "8.4.49",
|
|
65
65
|
"react": "19.2.5",
|
|
@@ -67,14 +67,14 @@
|
|
|
67
67
|
"react-google-recaptcha": "2.1.0",
|
|
68
68
|
"react-hook-form": "7.71.2",
|
|
69
69
|
"react-intersection-observer": "9.4.0",
|
|
70
|
-
"react-multi-carousel": "2.8.
|
|
71
|
-
"react-string-replace": "1.1.
|
|
72
|
-
"start-server-and-test": "2.0.
|
|
73
|
-
"tailwind-merge": "1.
|
|
70
|
+
"react-multi-carousel": "2.8.5",
|
|
71
|
+
"react-string-replace": "1.1.1",
|
|
72
|
+
"start-server-and-test": "2.0.8",
|
|
73
|
+
"tailwind-merge": "1.14.0",
|
|
74
74
|
"yup": "0.32.11"
|
|
75
75
|
},
|
|
76
76
|
"devDependencies": {
|
|
77
|
-
"@akinon/eslint-plugin-projectzero": "2.0.79-
|
|
77
|
+
"@akinon/eslint-plugin-projectzero": "2.0.79-rc.0",
|
|
78
78
|
"@semantic-release/changelog": "6.0.2",
|
|
79
79
|
"@semantic-release/exec": "6.0.3",
|
|
80
80
|
"@semantic-release/git": "10.0.1",
|
|
@@ -89,25 +89,25 @@
|
|
|
89
89
|
"@types/react": "19.2.14",
|
|
90
90
|
"@types/react-dom": "19.2.3",
|
|
91
91
|
"client-only": "0.0.1",
|
|
92
|
-
"clsx": "1.
|
|
92
|
+
"clsx": "1.2.1",
|
|
93
93
|
"currency-symbol-map": "5.1.0",
|
|
94
94
|
"eslint": "9.39.4",
|
|
95
95
|
"eslint-config-next": "16.2.4",
|
|
96
96
|
"eslint-config-prettier": "10.1.1",
|
|
97
97
|
"husky": "8.0.0",
|
|
98
98
|
"jest": "29.7.0",
|
|
99
|
-
"jest-css-modules-transform": "4.
|
|
99
|
+
"jest-css-modules-transform": "4.4.2",
|
|
100
100
|
"jest-environment-jsdom": "29.7.0",
|
|
101
|
-
"lint-staged": "13.
|
|
102
|
-
"prettier": "2.
|
|
101
|
+
"lint-staged": "13.3.0",
|
|
102
|
+
"prettier": "2.8.8",
|
|
103
103
|
"react-number-format": "5.3.4",
|
|
104
|
-
"sass": "1.
|
|
104
|
+
"sass": "1.83.0",
|
|
105
105
|
"semantic-release": "19.0.5",
|
|
106
106
|
"server-only": "0.0.1",
|
|
107
|
-
"stylelint": "14.
|
|
107
|
+
"stylelint": "14.16.1",
|
|
108
108
|
"stylelint-config-sass-guidelines": "9.0.1",
|
|
109
109
|
"stylelint-config-standard": "25.0.0",
|
|
110
|
-
"stylelint-scss": "4.
|
|
110
|
+
"stylelint-scss": "4.7.0",
|
|
111
111
|
"stylelint-selector-bem-pattern": "2.1.1",
|
|
112
112
|
"tailwindcss": "4.2.0",
|
|
113
113
|
"ts-jest": "29.2.6",
|
|
@@ -14,9 +14,6 @@ import pwaTags from '@theme/components/pwa-tags';
|
|
|
14
14
|
import { OfflineFallback } from '@theme/components/offline-fallback';
|
|
15
15
|
import { InstallPrompt } from '@theme/components/install-prompt';
|
|
16
16
|
import type { Viewport } from 'next';
|
|
17
|
-
import { draftMode } from 'next/headers';
|
|
18
|
-
import { PREVIEW_PZ_SEGMENT } from '@akinon/next/utils/preview';
|
|
19
|
-
import { parsePzParams } from '@akinon/next/utils/pz-segments';
|
|
20
17
|
import settings from '@theme/settings';
|
|
21
18
|
import RouteHandler from '@theme/components/route-handler';
|
|
22
19
|
import { PreviewAuthStateReporter } from '@akinon/pz-theme/src/chrome/preview-auth-state';
|
|
@@ -58,15 +55,8 @@ export async function generateMetadata() {
|
|
|
58
55
|
async function RootLayout({
|
|
59
56
|
locale,
|
|
60
57
|
translations,
|
|
61
|
-
params,
|
|
62
58
|
children
|
|
63
59
|
}: ResolvedRootLayoutProps) {
|
|
64
|
-
// Widget preview indicator — reading draftMode does NOT opt the page into
|
|
65
|
-
// dynamic rendering; it is only true behind the /api/preview bypass cookie.
|
|
66
|
-
const { isEnabled: isPreview } = await draftMode();
|
|
67
|
-
// Which named preview is being viewed, so the banner says so — several can
|
|
68
|
-
// exist side by side and they look identical otherwise.
|
|
69
|
-
const previewId = parsePzParams(params, settings)[PREVIEW_PZ_SEGMENT] ?? '';
|
|
70
60
|
// Reconstructed here, above the error boundary, because the boundary is a
|
|
71
61
|
// client component that can neither fetch nor receive server props — see
|
|
72
62
|
// pz-theme's error-composition.tsx. Costs one memoized widget read until a
|
|
@@ -77,16 +67,6 @@ async function RootLayout({
|
|
|
77
67
|
<html lang={locale.isoCode} {...(locale.rtl ? { dir: 'rtl' } : {})}>
|
|
78
68
|
<head />
|
|
79
69
|
<body className="overflow-x-hidden">
|
|
80
|
-
{isPreview && (
|
|
81
|
-
<div className="fixed bottom-3 left-1/2 -translate-x-1/2 z-[9999] flex items-center gap-2 rounded bg-black/80 px-3 py-1.5 text-xs text-white">
|
|
82
|
-
<span>{previewId ? `Preview: ${previewId}` : 'Preview'}</span>
|
|
83
|
-
{/* Relative query-only href: exits preview and returns to the
|
|
84
|
-
SAME page via the middleware ?preview=exit interception. */}
|
|
85
|
-
<a href="?preview=exit" className="underline">
|
|
86
|
-
Exit
|
|
87
|
-
</a>
|
|
88
|
-
</div>
|
|
89
|
-
)}
|
|
90
70
|
<PzRoot translations={translations} locale={locale.value}>
|
|
91
71
|
<ClientRoot>
|
|
92
72
|
<div className="overflow-x-clip">
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useSentryUncaughtErrors } from '@akinon/next/hooks';
|
|
4
|
+
|
|
5
|
+
export default function GlobalError({
|
|
6
|
+
error,
|
|
7
|
+
reset
|
|
8
|
+
}: {
|
|
9
|
+
error: Error & { digest?: string };
|
|
10
|
+
reset: () => void;
|
|
11
|
+
}) {
|
|
12
|
+
useSentryUncaughtErrors(error);
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<html>
|
|
16
|
+
<body>
|
|
17
|
+
<h2>Something went wrong!</h2>
|
|
18
|
+
<button onClick={() => reset()}>Try again</button>
|
|
19
|
+
</body>
|
|
20
|
+
</html>
|
|
21
|
+
);
|
|
22
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
createContext,
|
|
5
|
+
ReactNode,
|
|
6
|
+
useContext,
|
|
7
|
+
useEffect,
|
|
8
|
+
useMemo,
|
|
9
|
+
useState
|
|
10
|
+
} from 'react';
|
|
11
|
+
import { useSession } from 'next-auth/react';
|
|
12
|
+
import { useGetFavouriteProductIdsQuery } from '@akinon/next/data/client/wishlist';
|
|
13
|
+
import {
|
|
14
|
+
isFavouriteProductIdsSuspended,
|
|
15
|
+
suspendFavouriteProductIds
|
|
16
|
+
} from '@theme/utils/favourite-product-ids-fallback';
|
|
17
|
+
|
|
18
|
+
interface FavouriteProductIdsContextValue {
|
|
19
|
+
// False while the batch flow is unavailable (endpoint 404'd or errored), so
|
|
20
|
+
// consumers can fall back to the legacy favourites-list request.
|
|
21
|
+
isActive: boolean;
|
|
22
|
+
getFavouriteId: (productPk: number) => number | undefined;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const FavouriteProductIdsContext =
|
|
26
|
+
createContext<FavouriteProductIdsContextValue | null>(null);
|
|
27
|
+
|
|
28
|
+
export const useFavouriteProductIds = () =>
|
|
29
|
+
useContext(FavouriteProductIdsContext);
|
|
30
|
+
|
|
31
|
+
type Phase = 'init' | 'batch' | 'fallback';
|
|
32
|
+
|
|
33
|
+
interface FavouriteProductIdsProviderProps {
|
|
34
|
+
productIds: Array<number | string>;
|
|
35
|
+
children: ReactNode;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function FavouriteProductIdsProvider({
|
|
39
|
+
productIds,
|
|
40
|
+
children
|
|
41
|
+
}: FavouriteProductIdsProviderProps) {
|
|
42
|
+
const { status } = useSession();
|
|
43
|
+
|
|
44
|
+
// Storage can only be read on the client, so the first render stays neutral
|
|
45
|
+
// to keep SSR and hydration output identical.
|
|
46
|
+
const [phase, setPhase] = useState<Phase>('init');
|
|
47
|
+
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
setPhase(isFavouriteProductIdsSuspended() ? 'fallback' : 'batch');
|
|
50
|
+
}, []);
|
|
51
|
+
|
|
52
|
+
const sortedProductIds = useMemo(() => {
|
|
53
|
+
const unique = Array.from(
|
|
54
|
+
new Set(productIds.map(Number).filter((id) => Number.isFinite(id)))
|
|
55
|
+
);
|
|
56
|
+
// Stable order keeps the RTK Query cache key deterministic for the page.
|
|
57
|
+
return unique.sort((a, b) => a - b);
|
|
58
|
+
}, [productIds]);
|
|
59
|
+
|
|
60
|
+
const { data, error } = useGetFavouriteProductIdsQuery(
|
|
61
|
+
{ productIds: sortedProductIds },
|
|
62
|
+
{
|
|
63
|
+
skip:
|
|
64
|
+
status !== 'authenticated' ||
|
|
65
|
+
phase !== 'batch' ||
|
|
66
|
+
sortedProductIds.length === 0
|
|
67
|
+
}
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
useEffect(() => {
|
|
71
|
+
if (!error) return;
|
|
72
|
+
|
|
73
|
+
if ('status' in error && error.status === 404) {
|
|
74
|
+
suspendFavouriteProductIds();
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
setPhase('fallback');
|
|
78
|
+
}, [error]);
|
|
79
|
+
|
|
80
|
+
const favouriteIdByProductPk = useMemo(() => {
|
|
81
|
+
const map = new Map<number, number>();
|
|
82
|
+
|
|
83
|
+
data?.favourite_products?.forEach((item) => {
|
|
84
|
+
map.set(Number(item.product_id), item.favourite_id);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
return map;
|
|
88
|
+
}, [data]);
|
|
89
|
+
|
|
90
|
+
const value = useMemo<FavouriteProductIdsContextValue>(
|
|
91
|
+
() => ({
|
|
92
|
+
isActive: phase !== 'fallback',
|
|
93
|
+
getFavouriteId: (productPk: number) =>
|
|
94
|
+
favouriteIdByProductPk.get(Number(productPk))
|
|
95
|
+
}),
|
|
96
|
+
[phase, favouriteIdByProductPk]
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
return (
|
|
100
|
+
<FavouriteProductIdsContext.Provider value={value}>
|
|
101
|
+
{children}
|
|
102
|
+
</FavouriteProductIdsContext.Provider>
|
|
103
|
+
);
|
|
104
|
+
}
|