@akinon/projectzero 2.0.78-beta.0 → 2.0.78-rc.1

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 CHANGED
@@ -1,6 +1,14 @@
1
1
  # @akinon/projectzero
2
2
 
3
- ## 2.0.78-beta.0
3
+ ## 2.0.78-rc.1
4
+
5
+ ## 2.0.78-rc.0
6
+
7
+ ### Patch Changes
8
+
9
+ - 143be2b9d: ZERO-3457: Crop styles are customizable and logic improved for rendering similar products modal
10
+ - d99a6a7d5: ZERO-3457_1: Fixed the settings prop and made sure everything is customizable.
11
+ - e18836b20: ZERO-4160: Restore scope in Sentry addon configuration in akinon.json
4
12
 
5
13
  ## 2.0.77
6
14
 
@@ -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
@@ -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,37 +1,117 @@
1
1
  # projectzeronext
2
2
 
3
- ## 2.0.78-beta.0
4
-
5
- ### Patch Changes
6
-
7
- - Updated dependencies [cbbbfd757]
8
- - @akinon/next@2.0.78-beta.0
9
- - @akinon/pz-theme@2.0.78-beta.0
10
- - @akinon/pz-virtual-try-on@2.0.78-beta.0
11
- - @akinon/pz-akifast@2.0.78-beta.0
12
- - @akinon/pz-apple-pay@2.0.78-beta.0
13
- - @akinon/pz-b2b@2.0.78-beta.0
14
- - @akinon/pz-basket-gift-pack@2.0.78-beta.0
15
- - @akinon/pz-bkm@2.0.78-beta.0
16
- - @akinon/pz-checkout-gift-pack@2.0.78-beta.0
17
- - @akinon/pz-click-collect@2.0.78-beta.0
18
- - @akinon/pz-credit-payment@2.0.78-beta.0
19
- - @akinon/pz-cybersource-uc@2.0.78-beta.0
20
- - @akinon/pz-flow-payment@2.0.78-beta.0
21
- - @akinon/pz-google-pay@2.0.78-beta.0
22
- - @akinon/pz-gpay@2.0.78-beta.0
23
- - @akinon/pz-haso@2.0.78-beta.0
24
- - @akinon/pz-hepsipay@2.0.78-beta.0
25
- - @akinon/pz-masterpass@2.0.78-beta.0
26
- - @akinon/pz-masterpass-rest@2.0.78-beta.0
27
- - @akinon/pz-multi-basket@2.0.78-beta.0
28
- - @akinon/pz-one-click-checkout@2.0.78-beta.0
29
- - @akinon/pz-otp@2.0.78-beta.0
30
- - @akinon/pz-pay-on-delivery@2.0.78-beta.0
31
- - @akinon/pz-saved-card@2.0.78-beta.0
32
- - @akinon/pz-similar-products@2.0.78-beta.0
33
- - @akinon/pz-tabby-extension@2.0.78-beta.0
34
- - @akinon/pz-tamara-extension@2.0.78-beta.0
3
+ ## 2.0.78-rc.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 8a0379e6: ZERO-4845: Implement FavouriteProductIds context and provider; enhance fav button logic and add tests for fallback functionality
8
+ - @akinon/next@2.0.78-rc.1
9
+ - @akinon/pz-akifast@2.0.78-rc.1
10
+ - @akinon/pz-apple-pay@2.0.78-rc.1
11
+ - @akinon/pz-b2b@2.0.78-rc.1
12
+ - @akinon/pz-basket-gift-pack@2.0.78-rc.1
13
+ - @akinon/pz-bkm@2.0.78-rc.1
14
+ - @akinon/pz-checkout-gift-pack@2.0.78-rc.1
15
+ - @akinon/pz-click-collect@2.0.78-rc.1
16
+ - @akinon/pz-credit-payment@2.0.78-rc.1
17
+ - @akinon/pz-cybersource-uc@2.0.78-rc.1
18
+ - @akinon/pz-flow-payment@2.0.78-rc.1
19
+ - @akinon/pz-google-pay@2.0.78-rc.1
20
+ - @akinon/pz-gpay@2.0.78-rc.1
21
+ - @akinon/pz-haso@2.0.78-rc.1
22
+ - @akinon/pz-hepsipay@2.0.78-rc.1
23
+ - @akinon/pz-masterpass@2.0.78-rc.1
24
+ - @akinon/pz-masterpass-rest@2.0.78-rc.1
25
+ - @akinon/pz-multi-basket@2.0.78-rc.1
26
+ - @akinon/pz-one-click-checkout@2.0.78-rc.1
27
+ - @akinon/pz-otp@2.0.78-rc.1
28
+ - @akinon/pz-pay-on-delivery@2.0.78-rc.1
29
+ - @akinon/pz-saved-card@2.0.78-rc.1
30
+ - @akinon/pz-similar-products@2.0.78-rc.1
31
+ - @akinon/pz-tabby-extension@2.0.78-rc.1
32
+ - @akinon/pz-tamara-extension@2.0.78-rc.1
33
+ - @akinon/pz-theme@2.0.78-rc.1
34
+ - @akinon/pz-virtual-try-on@2.0.78-rc.1
35
+
36
+ ## 2.0.78-rc.0
37
+
38
+ ### Patch Changes
39
+
40
+ - 1a8622a9b: ZERO-3392: Implemented AI Search functionality and update env
41
+ - 2fea4143: ZERO-4620: Add runtime access to `NEXT_PUBLIC_*` environment variables from Client Components
42
+ - b55acb768: ZERO-2577: Fix pagination bug and update usePagination hook and ensure pagination controls rendering correctly
43
+ - 143be2b9d: ZERO-3457: Crop styles are customizable and logic improved for rendering similar products modal
44
+ - 9f8cd3bc5: ZERO-3449: AI Search Active Filters & Crop Style changes have been implemented
45
+ - d99a6a7d5: ZERO-3457_1: Fixed the settings prop and made sure everything is customizable.
46
+ - ccf21475d: ZERO-4404: Add Next.js 16.2 AI improvements
47
+ - c0228aff0: ZERO-4159: Upgrade the package versions
48
+ - b05c35435: ZERO-2570: Category filters routes to absolute url
49
+ - e18836b20: ZERO-4160: Restore scope in Sentry addon configuration in akinon.json
50
+ - c3244a310: ZERO-4013: Update runtime version to node:25-alpine in project configuration
51
+ - Updated dependencies [a3e2acbf8]
52
+ - Updated dependencies [0cf9ea239]
53
+ - Updated dependencies [324f97d55]
54
+ - Updated dependencies [51ea06888]
55
+ - Updated dependencies
56
+ - Updated dependencies [c97525a31]
57
+ - Updated dependencies [eba125b24]
58
+ - Updated dependencies [2fea4143]
59
+ - Updated dependencies [119f0c11]
60
+ - Updated dependencies [823a4449a]
61
+ - Updated dependencies [b55acb768]
62
+ - Updated dependencies [760258c1c]
63
+ - Updated dependencies [5da13fffc]
64
+ - Updated dependencies [143be2b9d]
65
+ - Updated dependencies [7889b08fe]
66
+ - Updated dependencies [fb4aa9b47]
67
+ - Updated dependencies [9f8cd3bc5]
68
+ - Updated dependencies [bfafa3f49]
69
+ - Updated dependencies [00b9f488f]
70
+ - Updated dependencies [57d7eb305]
71
+ - Updated dependencies [d99a6a7d5]
72
+ - Updated dependencies [9db81a714]
73
+ - Updated dependencies [591e345e1]
74
+ - Updated dependencies [0df6bc1f8]
75
+ - Updated dependencies [4de5303c5]
76
+ - Updated dependencies [63a720003]
77
+ - Updated dependencies [95b139dc1]
78
+ - Updated dependencies [1d00f2d06]
79
+ - Updated dependencies [4ac7b2a1e]
80
+ - Updated dependencies [e9598c71]
81
+ - Updated dependencies [4998a9631]
82
+ - Updated dependencies [804d2bd6c]
83
+ - Updated dependencies [c0228aff0]
84
+ - Updated dependencies [3909d3224]
85
+ - Updated dependencies [6a3d8a631]
86
+ - Updated dependencies [e18836b20]
87
+ - Updated dependencies [b1111d7b]
88
+ - @akinon/pz-tabby-extension@2.0.78-rc.0
89
+ - @akinon/next@2.0.78-rc.0
90
+ - @akinon/pz-checkout-gift-pack@2.0.78-rc.0
91
+ - @akinon/pz-masterpass-rest@2.0.78-rc.0
92
+ - @akinon/pz-one-click-checkout@2.0.78-rc.0
93
+ - @akinon/pz-basket-gift-pack@2.0.78-rc.0
94
+ - @akinon/pz-pay-on-delivery@2.0.78-rc.0
95
+ - @akinon/pz-credit-payment@2.0.78-rc.0
96
+ - @akinon/pz-click-collect@2.0.78-rc.0
97
+ - @akinon/pz-multi-basket@2.0.78-rc.0
98
+ - @akinon/pz-masterpass@2.0.78-rc.0
99
+ - @akinon/pz-gpay@2.0.78-rc.0
100
+ - @akinon/pz-b2b@2.0.78-rc.0
101
+ - @akinon/pz-bkm@2.0.78-rc.0
102
+ - @akinon/pz-otp@2.0.78-rc.0
103
+ - @akinon/pz-similar-products@2.0.78-rc.0
104
+ - @akinon/pz-virtual-try-on@2.0.78-rc.0
105
+ - @akinon/pz-theme@2.0.78-rc.0
106
+ - @akinon/pz-akifast@2.0.78-rc.0
107
+ - @akinon/pz-apple-pay@2.0.78-rc.0
108
+ - @akinon/pz-cybersource-uc@2.0.78-rc.0
109
+ - @akinon/pz-flow-payment@2.0.78-rc.0
110
+ - @akinon/pz-google-pay@2.0.78-rc.0
111
+ - @akinon/pz-haso@2.0.78-rc.0
112
+ - @akinon/pz-hepsipay@2.0.78-rc.0
113
+ - @akinon/pz-saved-card@2.0.78-rc.0
114
+ - @akinon/pz-tamara-extension@2.0.78-rc.0
35
115
 
36
116
  ## 2.0.77
37
117
 
@@ -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.78-beta.0",
3
+ "version": "2.0.78-rc.1",
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.78-beta.0",
28
- "@akinon/pz-akifast": "2.0.78-beta.0",
29
- "@akinon/pz-apple-pay": "2.0.78-beta.0",
30
- "@akinon/pz-b2b": "2.0.78-beta.0",
31
- "@akinon/pz-basket-gift-pack": "2.0.78-beta.0",
32
- "@akinon/pz-bkm": "2.0.78-beta.0",
33
- "@akinon/pz-checkout-gift-pack": "2.0.78-beta.0",
34
- "@akinon/pz-click-collect": "2.0.78-beta.0",
35
- "@akinon/pz-credit-payment": "2.0.78-beta.0",
36
- "@akinon/pz-cybersource-uc": "2.0.78-beta.0",
37
- "@akinon/pz-flow-payment": "2.0.78-beta.0",
38
- "@akinon/pz-google-pay": "2.0.78-beta.0",
39
- "@akinon/pz-gpay": "2.0.78-beta.0",
40
- "@akinon/pz-haso": "2.0.78-beta.0",
41
- "@akinon/pz-hepsipay": "2.0.78-beta.0",
42
- "@akinon/pz-masterpass": "2.0.78-beta.0",
43
- "@akinon/pz-masterpass-rest": "2.0.78-beta.0",
44
- "@akinon/pz-multi-basket": "2.0.78-beta.0",
45
- "@akinon/pz-one-click-checkout": "2.0.78-beta.0",
46
- "@akinon/pz-otp": "2.0.78-beta.0",
47
- "@akinon/pz-pay-on-delivery": "2.0.78-beta.0",
48
- "@akinon/pz-saved-card": "2.0.78-beta.0",
49
- "@akinon/pz-similar-products": "2.0.78-beta.0",
50
- "@akinon/pz-tabby-extension": "2.0.78-beta.0",
51
- "@akinon/pz-tamara-extension": "2.0.78-beta.0",
52
- "@akinon/pz-theme": "2.0.78-beta.0",
53
- "@akinon/pz-virtual-try-on": "2.0.78-beta.0",
27
+ "@akinon/next": "2.0.78-rc.1",
28
+ "@akinon/pz-akifast": "2.0.78-rc.1",
29
+ "@akinon/pz-apple-pay": "2.0.78-rc.1",
30
+ "@akinon/pz-b2b": "2.0.78-rc.1",
31
+ "@akinon/pz-basket-gift-pack": "2.0.78-rc.1",
32
+ "@akinon/pz-bkm": "2.0.78-rc.1",
33
+ "@akinon/pz-checkout-gift-pack": "2.0.78-rc.1",
34
+ "@akinon/pz-click-collect": "2.0.78-rc.1",
35
+ "@akinon/pz-credit-payment": "2.0.78-rc.1",
36
+ "@akinon/pz-cybersource-uc": "2.0.78-rc.1",
37
+ "@akinon/pz-flow-payment": "2.0.78-rc.1",
38
+ "@akinon/pz-google-pay": "2.0.78-rc.1",
39
+ "@akinon/pz-gpay": "2.0.78-rc.1",
40
+ "@akinon/pz-haso": "2.0.78-rc.1",
41
+ "@akinon/pz-hepsipay": "2.0.78-rc.1",
42
+ "@akinon/pz-masterpass": "2.0.78-rc.1",
43
+ "@akinon/pz-masterpass-rest": "2.0.78-rc.1",
44
+ "@akinon/pz-multi-basket": "2.0.78-rc.1",
45
+ "@akinon/pz-one-click-checkout": "2.0.78-rc.1",
46
+ "@akinon/pz-otp": "2.0.78-rc.1",
47
+ "@akinon/pz-pay-on-delivery": "2.0.78-rc.1",
48
+ "@akinon/pz-saved-card": "2.0.78-rc.1",
49
+ "@akinon/pz-similar-products": "2.0.78-rc.1",
50
+ "@akinon/pz-tabby-extension": "2.0.78-rc.1",
51
+ "@akinon/pz-tamara-extension": "2.0.78-rc.1",
52
+ "@akinon/pz-theme": "2.0.78-rc.1",
53
+ "@akinon/pz-virtual-try-on": "2.0.78-rc.1",
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.11.0",
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.4",
71
- "react-string-replace": "1.1.0",
72
- "start-server-and-test": "2.0.3",
73
- "tailwind-merge": "1.8.0",
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.78-beta.0",
77
+ "@akinon/eslint-plugin-projectzero": "2.0.78-rc.1",
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.1.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.3.0",
99
+ "jest-css-modules-transform": "4.4.2",
100
100
  "jest-environment-jsdom": "29.7.0",
101
- "lint-staged": "13.1.0",
102
- "prettier": "2.6.2",
101
+ "lint-staged": "13.3.0",
102
+ "prettier": "2.8.8",
103
103
  "react-number-format": "5.3.4",
104
- "sass": "1.49.9",
104
+ "sass": "1.83.0",
105
105
  "semantic-release": "19.0.5",
106
106
  "server-only": "0.0.1",
107
- "stylelint": "14.6.0",
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.2.0",
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",
@@ -0,0 +1,5 @@
1
+ export { GET } from '@akinon/next/api/client-env';
2
+
3
+ // NEXT_PUBLIC_* values are read from the server runtime, not the build. Force
4
+ // dynamic so Next never statically caches an (empty) build-time response.
5
+ export const dynamic = 'force-dynamic';
@@ -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
+ }
@@ -1 +1,3 @@
1
+ export * from './use-contract';
2
+ export * from './use-fav-button';
1
3
  export * from './use-add-product-to-basket';
@@ -8,9 +8,11 @@ import {
8
8
  useGetFavoritesQuery,
9
9
  useRemoveFavoriteMutation
10
10
  } from '@akinon/next/data/client/wishlist';
11
+ import { Product } from '@akinon/next/types';
11
12
  import { Icon } from '@theme/components';
12
13
  import { pushAddToWishlist } from '@theme/utils/gtm';
13
14
  import { useToast, useLocalization } from '@akinon/next/hooks';
15
+ import { useFavouriteProductIds } from './favourite-product-ids-context';
14
16
 
15
17
  interface FavButtonProps {
16
18
  label?: string;
@@ -21,16 +23,25 @@ interface FavButtonProps {
21
23
 
22
24
  const FAV_TOAST_OPTIONS = { position: 'bottom-right' as const }
23
25
 
24
- const useFavButton = (productPk: number) => {
26
+ const useFavButton = (
27
+ productPk: number,
28
+ product?: Pick<Product, 'base_code' | 'name' | 'price' | 'currency_type'>
29
+ ) => {
25
30
  const { status } = useSession();
26
31
  const { t } = useLocalization();
27
32
  const { success, error: showError } = useToast();
28
33
 
34
+ // Inside a FavouriteProductIdsProvider (PLP) the favourite state comes from
35
+ // the batched favourite-product-ids request, so the full favourites list is
36
+ // only fetched when that flow is unavailable (no provider, or 404 fallback).
37
+ const favouriteProductIds = useFavouriteProductIds();
38
+ const useBatchFlow = Boolean(favouriteProductIds?.isActive);
39
+
29
40
  const { data: favorites } = useGetFavoritesQuery(
30
41
  {
31
42
  limit: 1000
32
43
  },
33
- { skip: status !== 'authenticated' }
44
+ { skip: status !== 'authenticated' || useBatchFlow }
34
45
  );
35
46
 
36
47
  const favoriteItem = useMemo(
@@ -41,7 +52,11 @@ const useFavButton = (productPk: number) => {
41
52
  [favorites, productPk]
42
53
  );
43
54
 
44
- const isActive = Boolean(favoriteItem);
55
+ const favouriteId = useBatchFlow
56
+ ? favouriteProductIds.getFavouriteId(productPk)
57
+ : favoriteItem?.pk;
58
+
59
+ const isActive = favouriteId !== undefined;
45
60
  const [isPushed, setIsPushed] = useState<boolean>(false);
46
61
 
47
62
  const [addFavorite] = useAddFavoriteMutation();
@@ -49,8 +64,8 @@ const useFavButton = (productPk: number) => {
49
64
 
50
65
  const handleClick = useCallback(async () => {
51
66
  try {
52
- if (favoriteItem) {
53
- await removeFavorite(favoriteItem.pk).unwrap();
67
+ if (favouriteId !== undefined) {
68
+ await removeFavorite(favouriteId).unwrap();
54
69
  success(t('product.removed_from_favorites'), FAV_TOAST_OPTIONS);
55
70
  } else {
56
71
  await addFavorite(productPk).unwrap();
@@ -60,19 +75,26 @@ const useFavButton = (productPk: number) => {
60
75
  } catch (err) {
61
76
  showError(t('product.favorites_error'), FAV_TOAST_OPTIONS);
62
77
  }
63
- }, [favoriteItem, productPk, addFavorite, removeFavorite, success, showError, t]);
78
+ }, [favouriteId, productPk, addFavorite, removeFavorite, success, showError, t]);
64
79
 
65
80
  useEffect(() => {
66
- if (favoriteItem && isPushed) {
81
+ if (!isActive || !isPushed) return;
82
+
83
+ // The batched flow returns ids only, so the analytics payload falls back
84
+ // to the product the card already renders.
85
+ const gtmProduct = favoriteItem?.product ?? product;
86
+
87
+ if (gtmProduct) {
67
88
  pushAddToWishlist({
68
- base_code: favoriteItem?.product?.base_code,
69
- name: favoriteItem?.product?.name,
70
- price: favoriteItem?.product?.price,
71
- currency_type: favoriteItem?.product?.currency_type
89
+ base_code: gtmProduct.base_code,
90
+ name: gtmProduct.name,
91
+ price: gtmProduct.price,
92
+ currency_type: gtmProduct.currency_type
72
93
  });
73
- setIsPushed(false);
74
94
  }
75
- }, [favoriteItem, isPushed]);
95
+
96
+ setIsPushed(false);
97
+ }, [isActive, favoriteItem, product, isPushed]);
76
98
 
77
99
  const FavButton = useMemo(() => {
78
100
  const View = (props: FavButtonProps) => (
@@ -19,6 +19,7 @@ module.exports = [
19
19
  'pz-hepsipay',
20
20
  'pz-flow-payment',
21
21
  'pz-virtual-try-on',
22
+ 'pz-similar-products',
22
23
  'pz-cybersource-uc',
23
24
  'pz-hepsipay',
24
25
  'pz-masterpass-rest',
@@ -14,7 +14,8 @@ export const config = {
14
14
  '/((?!api|_next|[\\w-\\/*]+\\.\\w+).*)',
15
15
  '/(.*sitemap\\.xml)',
16
16
  '/(.+\\.)(html|htm|aspx|asp|php)',
17
- '/(.*orders\\/checkout-with-token.*)'
17
+ '/(.*orders\\/checkout-with-token.*)',
18
+ '/(.*orders\\/post-checkout.*)'
18
19
  ]
19
20
  };
20
21
 
@@ -0,0 +1,42 @@
1
+ import {
2
+ FAVOURITE_PRODUCT_IDS_RETRY_AFTER_MS,
3
+ isFavouriteProductIdsSuspended,
4
+ suspendFavouriteProductIds
5
+ } from '../favourite-product-ids-fallback';
6
+
7
+ const STORAGE_KEY = 'pz-favourite-product-ids-unavailable-until';
8
+
9
+ describe('favourite-product-ids-fallback', () => {
10
+ beforeEach(() => {
11
+ window.localStorage.clear();
12
+ });
13
+
14
+ it('is not suspended by default', () => {
15
+ expect(isFavouriteProductIdsSuspended()).toBe(false);
16
+ });
17
+
18
+ it('suspends after a 404 marker is written', () => {
19
+ suspendFavouriteProductIds();
20
+
21
+ expect(isFavouriteProductIdsSuspended()).toBe(true);
22
+
23
+ const until = Number(window.localStorage.getItem(STORAGE_KEY));
24
+ expect(until).toBeGreaterThan(Date.now());
25
+ expect(until).toBeLessThanOrEqual(
26
+ Date.now() + FAVOURITE_PRODUCT_IDS_RETRY_AFTER_MS
27
+ );
28
+ });
29
+
30
+ it('expires the suspension and clears the marker', () => {
31
+ window.localStorage.setItem(STORAGE_KEY, String(Date.now() - 1000));
32
+
33
+ expect(isFavouriteProductIdsSuspended()).toBe(false);
34
+ expect(window.localStorage.getItem(STORAGE_KEY)).toBeNull();
35
+ });
36
+
37
+ it('treats a corrupt marker as not suspended', () => {
38
+ window.localStorage.setItem(STORAGE_KEY, 'not-a-number');
39
+
40
+ expect(isFavouriteProductIdsSuspended()).toBe(false);
41
+ });
42
+ });
@@ -0,0 +1,51 @@
1
+ const STORAGE_KEY = 'pz-favourite-product-ids-unavailable-until';
2
+
3
+ // Not every brand's backend ships the favourite-product-ids endpoint at the
4
+ // same time, so a 404 suspends the new flow for this long before probing again.
5
+ export const FAVOURITE_PRODUCT_IDS_RETRY_AFTER_MS = 6 * 60 * 60 * 1000;
6
+
7
+ const getStorage = (): Storage | null => {
8
+ try {
9
+ // The property access itself is what throws when storage is blocked, so it
10
+ // has to be inside the try rather than guarded by a typeof check.
11
+ return typeof window === 'undefined' ? null : window.localStorage ?? null;
12
+ } catch {
13
+ return null;
14
+ }
15
+ };
16
+
17
+ // Fails open: when storage is unavailable the endpoint is probed again, which
18
+ // at worst costs one extra 404 per page view.
19
+ export const isFavouriteProductIdsSuspended = (): boolean => {
20
+ const storage = getStorage();
21
+ if (!storage) return false;
22
+
23
+ try {
24
+ const raw = storage.getItem(STORAGE_KEY);
25
+ if (!raw) return false;
26
+
27
+ const until = Number(raw);
28
+ if (!Number.isFinite(until) || Date.now() >= until) {
29
+ storage.removeItem(STORAGE_KEY);
30
+ return false;
31
+ }
32
+
33
+ return true;
34
+ } catch {
35
+ return false;
36
+ }
37
+ };
38
+
39
+ export const suspendFavouriteProductIds = (): void => {
40
+ const storage = getStorage();
41
+ if (!storage) return;
42
+
43
+ try {
44
+ storage.setItem(
45
+ STORAGE_KEY,
46
+ String(Date.now() + FAVOURITE_PRODUCT_IDS_RETRY_AFTER_MS)
47
+ );
48
+ } catch {
49
+ // Fail open; see isFavouriteProductIdsSuspended.
50
+ }
51
+ };
@@ -11,6 +11,7 @@ import { GetCategoryResponse } from '@akinon/next/types';
11
11
  import { useAppDispatch, useAppSelector } from '@akinon/next/redux/hooks';
12
12
  import { setFacets, setMenuOpen } from '@theme/redux/reducers/category';
13
13
  import CategoryActiveFilters from '@theme/views/category/category-active-filters';
14
+ import { FavouriteProductIdsProvider } from '@theme/hooks/favourite-product-ids-context';
14
15
  import { useLocalization } from '@akinon/next/hooks';
15
16
  import { Link, LoaderSpinner } from '@akinon/next/components';
16
17
  import { ROUTES } from '@theme/routes';
@@ -62,6 +63,11 @@ export default function ListPage(props: ListPageProps) {
62
63
 
63
64
  const { t } = useLocalization();
64
65
 
66
+ const productPks = useMemo(
67
+ () => data?.products?.map((product) => product.pk) ?? [],
68
+ [data?.products]
69
+ );
70
+
65
71
  useEffect(() => {
66
72
  dispatch(setFacets(data.facets));
67
73
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -105,23 +111,25 @@ export default function ListPage(props: ListPageProps) {
105
111
 
106
112
  {data.products?.length === 0 && page > 1 && <LoaderSpinner />}
107
113
 
108
- <div
109
- className={clsx('grid gap-x-4 gap-y-12 grid-cols-2', {
110
- 'md:grid-cols-3': layoutSize === 3,
111
- 'lg:grid-cols-2': layoutSize === 2,
112
- 'lg:grid-cols-3': layoutSize === 3
113
- })}
114
- >
115
- {data?.products?.map((product, index) => (
116
- <ProductItem
117
- key={product.pk}
118
- product={product}
119
- width={itemDimensions.width}
120
- height={itemDimensions.height}
121
- index={index}
122
- />
123
- ))}
124
- </div>
114
+ <FavouriteProductIdsProvider productIds={productPks}>
115
+ <div
116
+ className={clsx('grid gap-x-4 gap-y-12 grid-cols-2', {
117
+ 'md:grid-cols-3': layoutSize === 3,
118
+ 'lg:grid-cols-2': layoutSize === 2,
119
+ 'lg:grid-cols-3': layoutSize === 3
120
+ })}
121
+ >
122
+ {data?.products?.map((product, index) => (
123
+ <ProductItem
124
+ key={product.pk}
125
+ product={product}
126
+ width={itemDimensions.width}
127
+ height={itemDimensions.height}
128
+ index={index}
129
+ />
130
+ ))}
131
+ </div>
132
+ </FavouriteProductIdsProvider>
125
133
  {data?.products?.length > 0 && (
126
134
  <Pagination
127
135
  total={data.pagination.total_count}
@@ -4,8 +4,7 @@ import { useEffect, useRef, useState } from 'react';
4
4
  import { useAppDispatch, useAppSelector } from '@akinon/next/redux/hooks';
5
5
  import { closeSearch } from '@akinon/next/redux/reducers/header';
6
6
  import clsx from 'clsx';
7
-
8
- import { Icon } from '@theme/components';
7
+ import { Icon, Input } from '@theme/components';
9
8
  import Results from './results';
10
9
  import { ROUTES } from '@theme/routes';
11
10
  import { useLocalization, useRouter } from '@akinon/next/hooks';
@@ -42,6 +41,14 @@ export default function Search() {
42
41
  };
43
42
  }, [isSearchOpen, dispatch]);
44
43
 
44
+ const handleSearchTextChange = (e: React.ChangeEvent<HTMLInputElement>) => {
45
+ setSearchText(e.target.value);
46
+ };
47
+
48
+ const handleCloseSearch = () => {
49
+ dispatch(closeSearch());
50
+ };
51
+
45
52
  return (
46
53
  <>
47
54
  <div
@@ -67,9 +74,9 @@ export default function Search() {
67
74
  {t('common.search.results_for')}
68
75
  </span>
69
76
  <div className="flex items-center">
70
- <input
77
+ <Input
71
78
  value={searchText}
72
- onChange={(e) => setSearchText(e.target.value)}
79
+ onChange={handleSearchTextChange}
73
80
  onKeyDown={(e) => {
74
81
  if (e.key === 'Enter' && searchText.trim() !== '') {
75
82
  router.push(`${ROUTES.LIST}/?search_text=${searchText}`);
@@ -91,11 +98,12 @@ export default function Search() {
91
98
  <Icon
92
99
  name="close"
93
100
  size={14}
94
- onClick={() => dispatch(closeSearch())}
101
+ onClick={handleCloseSearch}
95
102
  className="cursor-pointer"
96
103
  />
97
104
  </div>
98
105
  </div>
106
+
99
107
  <Results searchText={searchText} />
100
108
  </div>
101
109
  </div>
@@ -36,53 +36,100 @@ export default function ProductInfoSlider({ product }: ProductSliderItem) {
36
36
  carouselRef.current?.next();
37
37
  };
38
38
 
39
- const handleThumbnailClick = (index) => {
39
+ const handleThumbnailClick = (index: number) => {
40
40
  setActiveIndex(index);
41
41
  carouselRef.current?.goToSlide(index);
42
42
  };
43
43
 
44
44
  return (
45
- <div className="lg:grid lg:grid-cols-6">
46
- <div className="lg:col-span-1">
47
- <div className="flex flex-col items-center justify-center md:mr-[6px]">
48
- <button
49
- onClick={goToPrev}
50
- className={twMerge(
51
- 'hidden justify-center p-2 mb-3 border border-gray-100 rounded-full cursor-pointer lg:block',
52
- [activeIndex === 0 && 'cursor-not-allowed opacity-45']
53
- )}
54
- disabled={activeIndex === 0}
45
+ <>
46
+ <div className="lg:grid lg:grid-cols-6">
47
+ <div className="lg:col-span-1">
48
+ <div className="flex flex-col items-center justify-center md:mr-[6px]">
49
+ <button
50
+ onClick={goToPrev}
51
+ className={twMerge(
52
+ 'hidden justify-center p-2 mb-3 border border-gray-100 rounded-full cursor-pointer lg:block',
53
+ [activeIndex === 0 && 'cursor-not-allowed opacity-45']
54
+ )}
55
+ disabled={activeIndex === 0}
56
+ >
57
+ <Icon name="chevron-up" size={15} className="fill-[#000000]" />
58
+ </button>
59
+ <div className="hidden flex-col items-center overflow-scroll w-[80px] max-h-[620px] lg:block">
60
+ {product?.productimage_set?.map((item, index) => (
61
+ <Image
62
+ key={index}
63
+ src={item.image}
64
+ alt={`Thumbnail ${index}`}
65
+ width={80}
66
+ height={128}
67
+ aspectRatio={80 / 128}
68
+ className={twMerge('cursor-pointer', [
69
+ activeIndex === index && 'border-2 border-primary'
70
+ ])}
71
+ onClick={() => handleThumbnailClick(index)}
72
+ />
73
+ ))}
74
+ </div>
75
+ <button
76
+ onClick={goToNext}
77
+ className={twMerge(
78
+ 'hidden justify-center p-2 mt-3 border border-gray-100 rounded-full cursor-pointer lg:block',
79
+ [
80
+ activeIndex === product.productimage_set.length - 1 &&
81
+ 'cursor-not-allowed opacity-45'
82
+ ]
83
+ )}
84
+ disabled={activeIndex === product.productimage_set.length - 1}
85
+ >
86
+ <Icon name="chevron-down" size={15} className="fill-[#000000]" />
87
+ </button>
88
+ </div>
89
+ </div>
90
+
91
+ <div className="relative lg:col-span-5">
92
+ <FavButton className="absolute right-8 top-6 z-[20] sm:hidden" />
93
+
94
+ <PluginModule
95
+ component={Component.ProductImageSearchFeature}
96
+ props={{
97
+ product,
98
+ activeIndex,
99
+ showResetButton: true
100
+ }}
101
+ />
102
+
103
+ <CarouselCore
104
+ responsive={{
105
+ all: {
106
+ breakpoint: { max: 5000, min: 0 },
107
+ items: 1
108
+ }
109
+ }}
110
+ arrows={false}
111
+ swipeable={true}
112
+ ref={carouselRef}
113
+ afterChange={(previousSlide, { currentSlide }) => {
114
+ setActiveIndex(currentSlide);
115
+ }}
116
+ containerAspectRatio={{ mobile: 520 / 798, desktop: 484 / 726 }}
55
117
  >
56
- <Icon name="chevron-up" size={15} className="fill-[#000000]" />
57
- </button>
58
- <div className="hidden flex-col items-center overflow-scroll w-[80px] max-h-[620px] lg:block">
59
- {product?.productimage_set?.map((item, index) => (
118
+ {product?.productimage_set?.map((item, i) => (
60
119
  <Image
61
- key={index}
120
+ key={i}
62
121
  src={item.image}
63
- alt={`Thumbnail ${index}`}
64
- width={80}
65
- height={128}
66
- className={twMerge('cursor-pointer', [
67
- activeIndex === index && 'border-2 border-primary'
68
- ])}
69
- onClick={() => handleThumbnailClick(index)}
122
+ alt={product?.name || 'Product image'}
123
+ draggable={false}
124
+ aspectRatio={484 / 726}
125
+ sizes="(min-width: 425px) 512px,
126
+ (min-width: 601px) 576px,
127
+ (min-width: 768px) 336px,
128
+ (min-width: 1024px) 484px, 368px"
129
+ fill
70
130
  />
71
131
  ))}
72
- </div>
73
- <button
74
- onClick={goToNext}
75
- className={twMerge(
76
- 'hidden justify-center p-2 mt-3 border border-gray-100 rounded-full cursor-pointer lg:block',
77
- [
78
- activeIndex === product.productimage_set.length - 1 &&
79
- 'cursor-not-allowed opacity-45'
80
- ]
81
- )}
82
- disabled={activeIndex === product.productimage_set.length - 1}
83
- >
84
- <Icon name="chevron-down" size={15} className="fill-[#000000]" />
85
- </button>
132
+ </CarouselCore>
86
133
  </div>
87
134
  </div>
88
135
 
@@ -140,6 +187,6 @@ export default function ProductInfoSlider({ product }: ProductSliderItem) {
140
187
  ))}
141
188
  </CarouselCore>
142
189
  </div>
143
- </div>
190
+ </>
144
191
  );
145
192
  }
@@ -22,7 +22,7 @@ export const ProductItem = (props: Props) => {
22
22
  // TODO: Static image will change (TR)
23
23
  const { product, width, height, index } = props;
24
24
  const [viewed, setViewed] = useState(false);
25
- const { FavButton } = useFavButton(product.pk);
25
+ const { FavButton } = useFavButton(product.pk, product);
26
26
  const { ref, inView } = useInView();
27
27
 
28
28
  const image_url = product.productimage_set[0]?.image;
@@ -164,6 +164,10 @@ export default async () => {
164
164
  name: 'Tamara Payment Extension',
165
165
  value: 'pz-tamara-extension'
166
166
  },
167
+ {
168
+ name: 'Similar Products',
169
+ value: 'pz-similar-products'
170
+ },
167
171
  {
168
172
  name: 'Hepsipay',
169
173
  value: 'pz-hepsipay'
@@ -183,6 +183,10 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
183
183
  name: 'Tamara Payment Extension',
184
184
  value: 'pz-tamara-extension'
185
185
  },
186
+ {
187
+ name: 'Similar Products',
188
+ value: 'pz-similar-products'
189
+ },
186
190
  {
187
191
  name: 'Hepsipay',
188
192
  value: 'pz-hepsipay'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akinon/projectzero",
3
- "version": "2.0.78-beta.0",
3
+ "version": "2.0.78-rc.1",
4
4
  "private": false,
5
5
  "description": "CLI tool to manage your Project Zero Next project",
6
6
  "bin": {