@akinon/projectzero 2.0.123-rc.0 → 2.0.123

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,12 +1,6 @@
1
1
  # @akinon/projectzero
2
2
 
3
- ## 2.0.123-rc.0
4
-
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
3
+ ## 2.0.123
10
4
 
11
5
  ## 2.0.122
12
6
 
@@ -7,7 +7,6 @@ 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
11
10
 
12
11
  # PZ Dashboard dataLayer observability (unset = observer disabled)
13
12
  # NEXT_PUBLIC_PZ_DASHBOARD_URL=http://localhost:3005
@@ -1,11 +1,3 @@
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
-
9
1
  # Project Zero Next.js - Developer Instructions
10
2
 
11
3
  ## 📚 Available Instruction Files
@@ -1,88 +1,37 @@
1
1
  # projectzeronext
2
2
 
3
- ## 2.0.123-rc.0
4
-
5
- ### Patch Changes
6
-
7
- - 1a8622a9b: ZERO-3392: Implemented AI Search functionality and update env
8
- - 2fea41430: 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
- - 8a0379e62: 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 [86187b1c2]
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 [2fea41430]
28
- - Updated dependencies [119f0c110]
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 [e9598c71d]
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 [b1111d7b1]
57
- - Updated dependencies [1595d458]
58
- - Updated dependencies [dca12811]
59
- - @akinon/pz-tabby-extension@2.0.123-rc.0
60
- - @akinon/next@2.0.123-rc.0
61
- - @akinon/pz-checkout-gift-pack@2.0.123-rc.0
62
- - @akinon/pz-masterpass-rest@2.0.123-rc.0
63
- - @akinon/pz-one-click-checkout@2.0.123-rc.0
64
- - @akinon/pz-basket-gift-pack@2.0.123-rc.0
65
- - @akinon/pz-pay-on-delivery@2.0.123-rc.0
66
- - @akinon/pz-credit-payment@2.0.123-rc.0
67
- - @akinon/pz-click-collect@2.0.123-rc.0
68
- - @akinon/pz-multi-basket@2.0.123-rc.0
69
- - @akinon/pz-masterpass@2.0.123-rc.0
70
- - @akinon/pz-gpay@2.0.123-rc.0
71
- - @akinon/pz-b2b@2.0.123-rc.0
72
- - @akinon/pz-bkm@2.0.123-rc.0
73
- - @akinon/pz-otp@2.0.123-rc.0
74
- - @akinon/pz-similar-products@2.0.123-rc.0
75
- - @akinon/pz-virtual-try-on@2.0.123-rc.0
76
- - @akinon/pz-theme@2.0.123-rc.0
77
- - @akinon/pz-akifast@2.0.123-rc.0
78
- - @akinon/pz-apple-pay@2.0.123-rc.0
79
- - @akinon/pz-cybersource-uc@2.0.123-rc.0
80
- - @akinon/pz-flow-payment@2.0.123-rc.0
81
- - @akinon/pz-google-pay@2.0.123-rc.0
82
- - @akinon/pz-haso@2.0.123-rc.0
83
- - @akinon/pz-hepsipay@2.0.123-rc.0
84
- - @akinon/pz-saved-card@2.0.123-rc.0
85
- - @akinon/pz-tamara-extension@2.0.123-rc.0
3
+ ## 2.0.123
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [3007a4d]
8
+ - @akinon/pz-theme@2.0.123
9
+ - @akinon/next@2.0.123
10
+ - @akinon/pz-akifast@2.0.123
11
+ - @akinon/pz-apple-pay@2.0.123
12
+ - @akinon/pz-b2b@2.0.123
13
+ - @akinon/pz-basket-gift-pack@2.0.123
14
+ - @akinon/pz-bkm@2.0.123
15
+ - @akinon/pz-checkout-gift-pack@2.0.123
16
+ - @akinon/pz-click-collect@2.0.123
17
+ - @akinon/pz-credit-payment@2.0.123
18
+ - @akinon/pz-cybersource-uc@2.0.123
19
+ - @akinon/pz-flow-payment@2.0.123
20
+ - @akinon/pz-google-pay@2.0.123
21
+ - @akinon/pz-gpay@2.0.123
22
+ - @akinon/pz-haso@2.0.123
23
+ - @akinon/pz-hepsipay@2.0.123
24
+ - @akinon/pz-masterpass@2.0.123
25
+ - @akinon/pz-masterpass-rest@2.0.123
26
+ - @akinon/pz-multi-basket@2.0.123
27
+ - @akinon/pz-one-click-checkout@2.0.123
28
+ - @akinon/pz-otp@2.0.123
29
+ - @akinon/pz-pay-on-delivery@2.0.123
30
+ - @akinon/pz-saved-card@2.0.123
31
+ - @akinon/pz-similar-products@2.0.123
32
+ - @akinon/pz-tabby-extension@2.0.123
33
+ - @akinon/pz-tamara-extension@2.0.123
34
+ - @akinon/pz-virtual-try-on@2.0.123
86
35
 
87
36
  ## 2.0.122
88
37
 
@@ -12,30 +12,6 @@ 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
-
39
15
  ### Build
40
16
 
41
17
  To build the app, run the following command:
@@ -43,7 +19,7 @@ To build the app, run the following command:
43
19
  ```bash
44
20
  cd projectzeronext # Project root
45
21
  yarn build
46
- ````
22
+ ```
47
23
 
48
24
  ### Develop
49
25
 
@@ -38,9 +38,6 @@ const nextConfig = {
38
38
  ]
39
39
  }
40
40
  ];
41
- },
42
- logging: {
43
- browserToTerminal: 'error'
44
41
  }
45
42
  };
46
43
 
@@ -53,12 +50,9 @@ const withSerwist = withSerwistInit({
53
50
  const sentryConfig = {
54
51
  silent: true,
55
52
  dryRun: !process.env.SENTRY_DSN,
56
- org: 'akinon',
53
+ org: 'akinon'
57
54
  // project: 'enter_your_project_name_here',
58
55
  // authToken: 'enter_your_auth_token_here'
59
- sourcemaps: {
60
- deleteSourcemapsAfterUpload: true
61
- }
62
56
  };
63
57
 
64
58
  const enhancedConfig = withPzConfig(nextConfig);
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "projectzeronext",
3
- "version": "2.0.123-rc.0",
3
+ "version": "2.0.123",
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.123-rc.0",
28
- "@akinon/pz-akifast": "2.0.123-rc.0",
29
- "@akinon/pz-apple-pay": "2.0.123-rc.0",
30
- "@akinon/pz-b2b": "2.0.123-rc.0",
31
- "@akinon/pz-basket-gift-pack": "2.0.123-rc.0",
32
- "@akinon/pz-bkm": "2.0.123-rc.0",
33
- "@akinon/pz-checkout-gift-pack": "2.0.123-rc.0",
34
- "@akinon/pz-click-collect": "2.0.123-rc.0",
35
- "@akinon/pz-credit-payment": "2.0.123-rc.0",
36
- "@akinon/pz-cybersource-uc": "2.0.123-rc.0",
37
- "@akinon/pz-flow-payment": "2.0.123-rc.0",
38
- "@akinon/pz-google-pay": "2.0.123-rc.0",
39
- "@akinon/pz-gpay": "2.0.123-rc.0",
40
- "@akinon/pz-haso": "2.0.123-rc.0",
41
- "@akinon/pz-hepsipay": "2.0.123-rc.0",
42
- "@akinon/pz-masterpass": "2.0.123-rc.0",
43
- "@akinon/pz-masterpass-rest": "2.0.123-rc.0",
44
- "@akinon/pz-multi-basket": "2.0.123-rc.0",
45
- "@akinon/pz-one-click-checkout": "2.0.123-rc.0",
46
- "@akinon/pz-otp": "2.0.123-rc.0",
47
- "@akinon/pz-pay-on-delivery": "2.0.123-rc.0",
48
- "@akinon/pz-saved-card": "2.0.123-rc.0",
49
- "@akinon/pz-similar-products": "2.0.123-rc.0",
50
- "@akinon/pz-tabby-extension": "2.0.123-rc.0",
51
- "@akinon/pz-tamara-extension": "2.0.123-rc.0",
52
- "@akinon/pz-theme": "2.0.123-rc.0",
53
- "@akinon/pz-virtual-try-on": "2.0.123-rc.0",
27
+ "@akinon/next": "2.0.123",
28
+ "@akinon/pz-akifast": "2.0.123",
29
+ "@akinon/pz-apple-pay": "2.0.123",
30
+ "@akinon/pz-b2b": "2.0.123",
31
+ "@akinon/pz-basket-gift-pack": "2.0.123",
32
+ "@akinon/pz-bkm": "2.0.123",
33
+ "@akinon/pz-checkout-gift-pack": "2.0.123",
34
+ "@akinon/pz-click-collect": "2.0.123",
35
+ "@akinon/pz-credit-payment": "2.0.123",
36
+ "@akinon/pz-cybersource-uc": "2.0.123",
37
+ "@akinon/pz-flow-payment": "2.0.123",
38
+ "@akinon/pz-google-pay": "2.0.123",
39
+ "@akinon/pz-gpay": "2.0.123",
40
+ "@akinon/pz-haso": "2.0.123",
41
+ "@akinon/pz-hepsipay": "2.0.123",
42
+ "@akinon/pz-masterpass": "2.0.123",
43
+ "@akinon/pz-masterpass-rest": "2.0.123",
44
+ "@akinon/pz-multi-basket": "2.0.123",
45
+ "@akinon/pz-one-click-checkout": "2.0.123",
46
+ "@akinon/pz-otp": "2.0.123",
47
+ "@akinon/pz-pay-on-delivery": "2.0.123",
48
+ "@akinon/pz-saved-card": "2.0.123",
49
+ "@akinon/pz-similar-products": "2.0.123",
50
+ "@akinon/pz-tabby-extension": "2.0.123",
51
+ "@akinon/pz-tamara-extension": "2.0.123",
52
+ "@akinon/pz-theme": "2.0.123",
53
+ "@akinon/pz-virtual-try-on": "2.0.123",
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.21.0",
62
+ "pino": "8.11.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.5",
71
- "react-string-replace": "1.1.1",
72
- "start-server-and-test": "2.0.8",
73
- "tailwind-merge": "1.14.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",
74
74
  "yup": "0.32.11"
75
75
  },
76
76
  "devDependencies": {
77
- "@akinon/eslint-plugin-projectzero": "2.0.123-rc.0",
77
+ "@akinon/eslint-plugin-projectzero": "2.0.123",
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.2.1",
92
+ "clsx": "1.1.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.4.2",
99
+ "jest-css-modules-transform": "4.3.0",
100
100
  "jest-environment-jsdom": "29.7.0",
101
- "lint-staged": "13.3.0",
102
- "prettier": "2.8.8",
101
+ "lint-staged": "13.1.0",
102
+ "prettier": "2.6.2",
103
103
  "react-number-format": "5.3.4",
104
- "sass": "1.83.0",
104
+ "sass": "1.49.9",
105
105
  "semantic-release": "19.0.5",
106
106
  "server-only": "0.0.1",
107
- "stylelint": "14.16.1",
107
+ "stylelint": "14.6.0",
108
108
  "stylelint-config-sass-guidelines": "9.0.1",
109
109
  "stylelint-config-standard": "25.0.0",
110
- "stylelint-scss": "4.7.0",
110
+ "stylelint-scss": "4.2.0",
111
111
  "stylelint-selector-bem-pattern": "2.1.1",
112
112
  "tailwindcss": "4.2.0",
113
113
  "ts-jest": "29.2.6",
@@ -1,3 +1 @@
1
- export * from './use-contract';
2
- export * from './use-fav-button';
3
1
  export * from './use-add-product-to-basket';
@@ -8,11 +8,9 @@ import {
8
8
  useGetFavoritesQuery,
9
9
  useRemoveFavoriteMutation
10
10
  } from '@akinon/next/data/client/wishlist';
11
- import { Product } from '@akinon/next/types';
12
11
  import { Icon } from '@theme/components';
13
12
  import { pushAddToWishlist } from '@theme/utils/gtm';
14
13
  import { useToast, useLocalization } from '@akinon/next/hooks';
15
- import { useFavouriteProductIds } from './favourite-product-ids-context';
16
14
 
17
15
  interface FavButtonProps {
18
16
  label?: string;
@@ -23,25 +21,16 @@ interface FavButtonProps {
23
21
 
24
22
  const FAV_TOAST_OPTIONS = { position: 'bottom-right' as const }
25
23
 
26
- const useFavButton = (
27
- productPk: number,
28
- product?: Pick<Product, 'base_code' | 'name' | 'price' | 'currency_type'>
29
- ) => {
24
+ const useFavButton = (productPk: number) => {
30
25
  const { status } = useSession();
31
26
  const { t } = useLocalization();
32
27
  const { success, error: showError } = useToast();
33
28
 
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
-
40
29
  const { data: favorites } = useGetFavoritesQuery(
41
30
  {
42
31
  limit: 1000
43
32
  },
44
- { skip: status !== 'authenticated' || useBatchFlow }
33
+ { skip: status !== 'authenticated' }
45
34
  );
46
35
 
47
36
  const favoriteItem = useMemo(
@@ -52,11 +41,7 @@ const useFavButton = (
52
41
  [favorites, productPk]
53
42
  );
54
43
 
55
- const favouriteId = useBatchFlow
56
- ? favouriteProductIds.getFavouriteId(productPk)
57
- : favoriteItem?.pk;
58
-
59
- const isActive = favouriteId !== undefined;
44
+ const isActive = Boolean(favoriteItem);
60
45
  const [isPushed, setIsPushed] = useState<boolean>(false);
61
46
 
62
47
  const [addFavorite] = useAddFavoriteMutation();
@@ -64,8 +49,8 @@ const useFavButton = (
64
49
 
65
50
  const handleClick = useCallback(async () => {
66
51
  try {
67
- if (favouriteId !== undefined) {
68
- await removeFavorite(favouriteId).unwrap();
52
+ if (favoriteItem) {
53
+ await removeFavorite(favoriteItem.pk).unwrap();
69
54
  success(t('product.removed_from_favorites'), FAV_TOAST_OPTIONS);
70
55
  } else {
71
56
  await addFavorite(productPk).unwrap();
@@ -75,26 +60,19 @@ const useFavButton = (
75
60
  } catch (err) {
76
61
  showError(t('product.favorites_error'), FAV_TOAST_OPTIONS);
77
62
  }
78
- }, [favouriteId, productPk, addFavorite, removeFavorite, success, showError, t]);
63
+ }, [favoriteItem, productPk, addFavorite, removeFavorite, success, showError, t]);
79
64
 
80
65
  useEffect(() => {
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) {
66
+ if (favoriteItem && isPushed) {
88
67
  pushAddToWishlist({
89
- base_code: gtmProduct.base_code,
90
- name: gtmProduct.name,
91
- price: gtmProduct.price,
92
- currency_type: gtmProduct.currency_type
68
+ base_code: favoriteItem?.product?.base_code,
69
+ name: favoriteItem?.product?.name,
70
+ price: favoriteItem?.product?.price,
71
+ currency_type: favoriteItem?.product?.currency_type
93
72
  });
73
+ setIsPushed(false);
94
74
  }
95
-
96
- setIsPushed(false);
97
- }, [isActive, favoriteItem, product, isPushed]);
75
+ }, [favoriteItem, isPushed]);
98
76
 
99
77
  const FavButton = useMemo(() => {
100
78
  const View = (props: FavButtonProps) => (
@@ -19,7 +19,6 @@ module.exports = [
19
19
  'pz-hepsipay',
20
20
  'pz-flow-payment',
21
21
  'pz-virtual-try-on',
22
- 'pz-similar-products',
23
22
  'pz-cybersource-uc',
24
23
  'pz-hepsipay',
25
24
  'pz-masterpass-rest',
@@ -15,8 +15,7 @@ export const config = {
15
15
  '/((?!api|_next|[\\w-\\/*]+\\.\\w+).*)',
16
16
  '/(.*sitemap\\.xml)',
17
17
  '/(.+\\.)(html|htm|aspx|asp|php)',
18
- '/(.*orders\\/checkout-with-token.*)',
19
- '/(.*orders\\/post-checkout.*)'
18
+ '/(.*orders\\/checkout-with-token.*)'
20
19
  ]
21
20
  };
22
21
 
@@ -11,7 +11,6 @@ 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';
15
14
  import { useLocalization } from '@akinon/next/hooks';
16
15
  import { Link, LoaderSpinner } from '@akinon/next/components';
17
16
  import { ROUTES } from '@theme/routes';
@@ -63,11 +62,6 @@ export default function ListPage(props: ListPageProps) {
63
62
 
64
63
  const { t } = useLocalization();
65
64
 
66
- const productPks = useMemo(
67
- () => data?.products?.map((product) => product.pk) ?? [],
68
- [data?.products]
69
- );
70
-
71
65
  useEffect(() => {
72
66
  dispatch(setFacets(data.facets));
73
67
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -111,25 +105,23 @@ export default function ListPage(props: ListPageProps) {
111
105
 
112
106
  {data.products?.length === 0 && page > 1 && <LoaderSpinner />}
113
107
 
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>
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>
133
125
  {data?.products?.length > 0 && (
134
126
  <Pagination
135
127
  total={data.pagination.total_count}
@@ -4,7 +4,8 @@ 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
- import { Icon, Input } from '@theme/components';
7
+
8
+ import { Icon } from '@theme/components';
8
9
  import Results from './results';
9
10
  import { ROUTES } from '@theme/routes';
10
11
  import { useLocalization, useRouter } from '@akinon/next/hooks';
@@ -41,14 +42,6 @@ export default function Search() {
41
42
  };
42
43
  }, [isSearchOpen, dispatch]);
43
44
 
44
- const handleSearchTextChange = (e: React.ChangeEvent<HTMLInputElement>) => {
45
- setSearchText(e.target.value);
46
- };
47
-
48
- const handleCloseSearch = () => {
49
- dispatch(closeSearch());
50
- };
51
-
52
45
  return (
53
46
  <>
54
47
  <div
@@ -74,9 +67,9 @@ export default function Search() {
74
67
  {t('common.search.results_for')}
75
68
  </span>
76
69
  <div className="flex items-center">
77
- <Input
70
+ <input
78
71
  value={searchText}
79
- onChange={handleSearchTextChange}
72
+ onChange={(e) => setSearchText(e.target.value)}
80
73
  onKeyDown={(e) => {
81
74
  if (e.key === 'Enter' && searchText.trim() !== '') {
82
75
  router.push(`${ROUTES.LIST}/?search_text=${searchText}`);
@@ -98,12 +91,11 @@ export default function Search() {
98
91
  <Icon
99
92
  name="close"
100
93
  size={14}
101
- onClick={handleCloseSearch}
94
+ onClick={() => dispatch(closeSearch())}
102
95
  className="cursor-pointer"
103
96
  />
104
97
  </div>
105
98
  </div>
106
-
107
99
  <Results searchText={searchText} />
108
100
  </div>
109
101
  </div>
@@ -36,100 +36,53 @@ export default function ProductInfoSlider({ product }: ProductSliderItem) {
36
36
  carouselRef.current?.next();
37
37
  };
38
38
 
39
- const handleThumbnailClick = (index: number) => {
39
+ const handleThumbnailClick = (index) => {
40
40
  setActiveIndex(index);
41
41
  carouselRef.current?.goToSlide(index);
42
42
  };
43
43
 
44
44
  return (
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 }}
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}
117
55
  >
118
- {product?.productimage_set?.map((item, i) => (
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) => (
119
60
  <Image
120
- key={i}
61
+ key={index}
121
62
  src={item.image}
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
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)}
130
70
  />
131
71
  ))}
132
- </CarouselCore>
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>
133
86
  </div>
134
87
  </div>
135
88
 
@@ -187,6 +140,6 @@ export default function ProductInfoSlider({ product }: ProductSliderItem) {
187
140
  ))}
188
141
  </CarouselCore>
189
142
  </div>
190
- </>
143
+ </div>
191
144
  );
192
145
  }
@@ -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, product);
25
+ const { FavButton } = useFavButton(product.pk);
26
26
  const { ref, inView } = useInView();
27
27
 
28
28
  const image_url = product.productimage_set[0]?.image;
@@ -164,10 +164,6 @@ 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
- },
171
167
  {
172
168
  name: 'Hepsipay',
173
169
  value: 'pz-hepsipay'
@@ -183,10 +183,6 @@ 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
- },
190
186
  {
191
187
  name: 'Hepsipay',
192
188
  value: 'pz-hepsipay'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akinon/projectzero",
3
- "version": "2.0.123-rc.0",
3
+ "version": "2.0.123",
4
4
  "private": false,
5
5
  "description": "CLI tool to manage your Project Zero Next project",
6
6
  "bin": {
@@ -1,5 +0,0 @@
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';
@@ -1,22 +0,0 @@
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
- }
@@ -1,104 +0,0 @@
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,42 +0,0 @@
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
- });
@@ -1,51 +0,0 @@
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
- };