@akinon/projectzero 1.123.0-rc.0 → 1.123.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 CHANGED
@@ -1,12 +1,11 @@
1
1
  # @akinon/projectzero
2
2
 
3
- ## 1.123.0-rc.0
3
+ ## 1.123.0
4
4
 
5
5
  ### Minor Changes
6
6
 
7
- - 143be2b9: ZERO-3457: Crop styles are customizable and logic improved for rendering similar products modal
8
- - d99a6a7d: ZERO-3457_1: Fixed the settings prop and made sure everything is customizable.
9
- - e18836b2: ZERO-4160: Restore scope in Sentry addon configuration in akinon.json
7
+ - 2a8ddcf6: ZERO-4111: Add total balance field to store credit localization and update related components
8
+ - c67942a4: ZERO-3423: Updated version control and debug messages for the package
10
9
 
11
10
  ## 1.122.0
12
11
 
@@ -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
  # LOG_LEVEL_DEV=debug # For more details, please refer to the Logging documentation.
13
12
 
@@ -1,75 +1,55 @@
1
1
  # projectzeronext
2
2
 
3
- ## 1.123.0-rc.0
3
+ ## 1.123.0
4
4
 
5
5
  ### Minor Changes
6
6
 
7
- - 1a8622a9: ZERO-3392: Implemented AI Search functionality and update env
8
- - b55acb76: ZERO-2577: Fix pagination bug and update usePagination hook and ensure pagination controls rendering correctly
7
+ - 2a8ddcf6: ZERO-4111: Add total balance field to store credit localization and update related components
9
8
  - 36143125: ZERO-3987: Add barcode scanner functionality with modal and button
10
9
  - f7e0f646: ZERO-4032: Add bfcache-headers middleware, integrate it into the default chain, and introduce a new environment variable for control.
11
- - 143be2b9: ZERO-3457: Crop styles are customizable and logic improved for rendering similar products modal
12
- - 9f8cd3bc: ZERO-3449: AI Search Active Filters & Crop Style changes have been implemented
13
10
  - 5fb34b5c: ZERO-3955: Add aspect ratio validation and error handling for image cropping
14
- - d99a6a7d: ZERO-3457_1: Fixed the settings prop and made sure everything is customizable.
15
11
  - d76d3255: ZERO-4011: Refactor sitemap content generation to append locale suffix based on matched locale
16
- - b05c3543: ZERO-2570: Category filters routes to absolute url
17
- - e18836b2: ZERO-4160: Restore scope in Sentry addon configuration in akinon.json
18
- - c3244a31: ZERO-4013: Update runtime version to node:25-alpine in project configuration
19
12
 
20
13
  ### Patch Changes
21
14
 
22
15
  - Updated dependencies [4798959a]
23
16
  - Updated dependencies [8218dafa]
24
- - Updated dependencies
25
- - Updated dependencies [b55acb76]
17
+ - Updated dependencies [2a8ddcf6]
26
18
  - Updated dependencies [8a7fd0f4]
27
- - Updated dependencies [760258c1]
28
19
  - Updated dependencies [36143125]
29
20
  - Updated dependencies [572f4f7b]
30
21
  - Updated dependencies [f7e0f646]
31
22
  - Updated dependencies [94a86fcc]
32
- - Updated dependencies [143be2b9]
33
23
  - Updated dependencies [bcaad120]
34
- - Updated dependencies [cd68a97a]
35
- - Updated dependencies [9f8cd3bc]
36
- - Updated dependencies [bfafa3f4]
37
24
  - Updated dependencies [5fb34b5c]
38
25
  - Updated dependencies [88cb4f62]
39
- - Updated dependencies [d99a6a7d]
40
- - Updated dependencies [591e345e]
41
- - Updated dependencies [4de5303c]
42
- - Updated dependencies [63a72000]
43
- - Updated dependencies [95b139dc]
44
- - Updated dependencies [3909d322]
45
26
  - Updated dependencies [6b73b050]
46
- - Updated dependencies [e18836b2]
47
- - @akinon/pz-masterpass-rest@1.123.0-rc.0
48
- - @akinon/next@1.123.0-rc.0
49
- - @akinon/pz-virtual-try-on@1.123.0-rc.0
50
- - @akinon/pz-masterpass@1.123.0-rc.0
51
- - @akinon/pz-similar-products@1.123.0-rc.0
52
- - @akinon/pz-akifast@1.123.0-rc.0
53
- - @akinon/pz-apple-pay@1.123.0-rc.0
54
- - @akinon/pz-b2b@1.123.0-rc.0
55
- - @akinon/pz-basket-gift-pack@1.123.0-rc.0
56
- - @akinon/pz-bkm@1.123.0-rc.0
57
- - @akinon/pz-checkout-gift-pack@1.123.0-rc.0
58
- - @akinon/pz-click-collect@1.123.0-rc.0
59
- - @akinon/pz-credit-payment@1.123.0-rc.0
60
- - @akinon/pz-cybersource-uc@1.123.0-rc.0
61
- - @akinon/pz-flow-payment@1.123.0-rc.0
62
- - @akinon/pz-google-pay@1.123.0-rc.0
63
- - @akinon/pz-gpay@1.123.0-rc.0
64
- - @akinon/pz-haso@1.123.0-rc.0
65
- - @akinon/pz-hepsipay@1.123.0-rc.0
66
- - @akinon/pz-multi-basket@1.123.0-rc.0
67
- - @akinon/pz-one-click-checkout@1.123.0-rc.0
68
- - @akinon/pz-otp@1.123.0-rc.0
69
- - @akinon/pz-pay-on-delivery@1.123.0-rc.0
70
- - @akinon/pz-saved-card@1.123.0-rc.0
71
- - @akinon/pz-tabby-extension@1.123.0-rc.0
72
- - @akinon/pz-tamara-extension@1.123.0-rc.0
27
+ - @akinon/pz-masterpass-rest@1.123.0
28
+ - @akinon/next@1.123.0
29
+ - @akinon/pz-virtual-try-on@1.123.0
30
+ - @akinon/pz-masterpass@1.123.0
31
+ - @akinon/pz-akifast@1.123.0
32
+ - @akinon/pz-apple-pay@1.123.0
33
+ - @akinon/pz-b2b@1.123.0
34
+ - @akinon/pz-basket-gift-pack@1.123.0
35
+ - @akinon/pz-bkm@1.123.0
36
+ - @akinon/pz-checkout-gift-pack@1.123.0
37
+ - @akinon/pz-click-collect@1.123.0
38
+ - @akinon/pz-credit-payment@1.123.0
39
+ - @akinon/pz-cybersource-uc@1.123.0
40
+ - @akinon/pz-flow-payment@1.123.0
41
+ - @akinon/pz-google-pay@1.123.0
42
+ - @akinon/pz-gpay@1.123.0
43
+ - @akinon/pz-haso@1.123.0
44
+ - @akinon/pz-hepsipay@1.123.0
45
+ - @akinon/pz-multi-basket@1.123.0
46
+ - @akinon/pz-one-click-checkout@1.123.0
47
+ - @akinon/pz-otp@1.123.0
48
+ - @akinon/pz-pay-on-delivery@1.123.0
49
+ - @akinon/pz-saved-card@1.123.0
50
+ - @akinon/pz-similar-products@1.123.0
51
+ - @akinon/pz-tabby-extension@1.123.0
52
+ - @akinon/pz-tamara-extension@1.123.0
73
53
 
74
54
  ## 1.122.0
75
55
 
@@ -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
 
@@ -13,7 +13,7 @@
13
13
  "healthcheck": "/healthz"
14
14
  }
15
15
  },
16
- "runtime": "node:25-alpine",
16
+ "runtime": "node:22-alpine",
17
17
  "addons": [
18
18
  {
19
19
  "plan": "redis"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "projectzeronext",
3
- "version": "1.123.0-rc.0",
3
+ "version": "1.123.0",
4
4
  "private": true,
5
5
  "license": "MIT",
6
6
  "scripts": {
@@ -24,32 +24,32 @@
24
24
  "test:middleware": "jest middleware-matcher.test.ts --bail"
25
25
  },
26
26
  "dependencies": {
27
- "@akinon/next": "1.123.0-rc.0",
28
- "@akinon/pz-akifast": "1.123.0-rc.0",
29
- "@akinon/pz-apple-pay": "1.123.0-rc.0",
30
- "@akinon/pz-b2b": "1.123.0-rc.0",
31
- "@akinon/pz-basket-gift-pack": "1.123.0-rc.0",
32
- "@akinon/pz-bkm": "1.123.0-rc.0",
33
- "@akinon/pz-checkout-gift-pack": "1.123.0-rc.0",
34
- "@akinon/pz-click-collect": "1.123.0-rc.0",
35
- "@akinon/pz-credit-payment": "1.123.0-rc.0",
36
- "@akinon/pz-cybersource-uc": "1.123.0-rc.0",
37
- "@akinon/pz-flow-payment": "1.123.0-rc.0",
38
- "@akinon/pz-google-pay": "1.123.0-rc.0",
39
- "@akinon/pz-gpay": "1.123.0-rc.0",
40
- "@akinon/pz-haso": "1.123.0-rc.0",
41
- "@akinon/pz-hepsipay": "1.123.0-rc.0",
42
- "@akinon/pz-masterpass": "1.123.0-rc.0",
43
- "@akinon/pz-masterpass-rest": "1.123.0-rc.0",
44
- "@akinon/pz-multi-basket": "1.123.0-rc.0",
45
- "@akinon/pz-one-click-checkout": "1.123.0-rc.0",
46
- "@akinon/pz-otp": "1.123.0-rc.0",
47
- "@akinon/pz-pay-on-delivery": "1.123.0-rc.0",
48
- "@akinon/pz-saved-card": "1.123.0-rc.0",
49
- "@akinon/pz-similar-products": "1.123.0-rc.0",
50
- "@akinon/pz-tabby-extension": "1.123.0-rc.0",
51
- "@akinon/pz-tamara-extension": "1.123.0-rc.0",
52
- "@akinon/pz-virtual-try-on": "1.123.0-rc.0",
27
+ "@akinon/next": "1.123.0",
28
+ "@akinon/pz-akifast": "1.123.0",
29
+ "@akinon/pz-apple-pay": "1.123.0",
30
+ "@akinon/pz-b2b": "1.123.0",
31
+ "@akinon/pz-basket-gift-pack": "1.123.0",
32
+ "@akinon/pz-bkm": "1.123.0",
33
+ "@akinon/pz-checkout-gift-pack": "1.123.0",
34
+ "@akinon/pz-click-collect": "1.123.0",
35
+ "@akinon/pz-credit-payment": "1.123.0",
36
+ "@akinon/pz-cybersource-uc": "1.123.0",
37
+ "@akinon/pz-flow-payment": "1.123.0",
38
+ "@akinon/pz-google-pay": "1.123.0",
39
+ "@akinon/pz-gpay": "1.123.0",
40
+ "@akinon/pz-haso": "1.123.0",
41
+ "@akinon/pz-hepsipay": "1.123.0",
42
+ "@akinon/pz-masterpass": "1.123.0",
43
+ "@akinon/pz-masterpass-rest": "1.123.0",
44
+ "@akinon/pz-multi-basket": "1.123.0",
45
+ "@akinon/pz-one-click-checkout": "1.123.0",
46
+ "@akinon/pz-otp": "1.123.0",
47
+ "@akinon/pz-pay-on-delivery": "1.123.0",
48
+ "@akinon/pz-saved-card": "1.123.0",
49
+ "@akinon/pz-similar-products": "1.123.0",
50
+ "@akinon/pz-tabby-extension": "1.123.0",
51
+ "@akinon/pz-tamara-extension": "1.123.0",
52
+ "@akinon/pz-virtual-try-on": "1.123.0",
53
53
  "@hookform/resolvers": "2.9.0",
54
54
  "@next/third-parties": "14.1.0",
55
55
  "@react-google-maps/api": "2.17.1",
@@ -72,7 +72,7 @@
72
72
  "yup": "0.32.11"
73
73
  },
74
74
  "devDependencies": {
75
- "@akinon/eslint-plugin-projectzero": "1.123.0-rc.0",
75
+ "@akinon/eslint-plugin-projectzero": "1.123.0",
76
76
  "@semantic-release/changelog": "6.0.2",
77
77
  "@semantic-release/exec": "6.0.3",
78
78
  "@semantic-release/git": "10.0.1",
@@ -143,6 +143,7 @@
143
143
  "store_credit": {
144
144
  "use_my_store_credits": "Use my pz-zero credits",
145
145
  "available_balance": "Available Balance",
146
+ "total_balance": "Total Balance",
146
147
  "insufficient_balance": "Your pz-zero credits are not sufficient to pay for the order, please select an additional payment method to cover the balance of <Amount/>"
147
148
  }
148
149
  },
@@ -1,3 +1 @@
1
- export * from './use-contract';
2
- export * from './use-fav-button';
3
1
  export * from './use-add-product-to-basket';
@@ -14,8 +14,7 @@ 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.*)',
18
- '/(.*orders\\/post-checkout.*)'
17
+ '/(.*orders\\/checkout-with-token.*)'
19
18
  ]
20
19
  };
21
20
 
@@ -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',
@@ -4,46 +4,198 @@ import {
4
4
  usePayWithLoyaltyBalanceMutation
5
5
  } from '@akinon/next/data/client/checkout';
6
6
  import { useAppSelector } from '@akinon/next/redux/hooks';
7
- import { useMemo, useState } from 'react';
7
+ import { useEffect, useMemo, useState } from 'react';
8
8
  import { useLocalization } from '@akinon/next/hooks';
9
9
  import { twMerge } from 'tailwind-merge';
10
10
  import { Icon, Price } from '@theme/components';
11
11
  import { Trans } from '@akinon/next/components';
12
12
  import { LoaderSpinner } from '@theme/components';
13
+ import { AccountUsage, LoyaltyBalanceItem } from '@akinon/next/types';
13
14
 
14
15
  export const StoreCredits = () => {
15
16
  const { t } = useLocalization();
16
17
 
17
- const [payWithLoyaltyBalance, { isLoading: isPayWithLoyaltyBalanceLoading }] =
18
+ const [payWithLoyaltyBalance, { isLoading: isPayLoading }] =
18
19
  usePayWithLoyaltyBalanceMutation();
19
20
 
20
- const { loyaltyBalance, preOrder } = useAppSelector(
21
+ const { loyaltyBalance, loyaltyBalances, preOrder } = useAppSelector(
21
22
  (state) => state.checkout
22
23
  );
23
24
 
24
- const { isLoading: isLoyaltyBalanceLoading } =
25
+ const { data: checkoutLoyaltyData, isLoading: isLoyaltyBalanceLoading } =
25
26
  useGetCheckoutLoyaltyBalanceQuery(undefined, {
26
27
  refetchOnMountOrArgChange: true,
27
28
  skip: !preOrder?.payment_option
28
29
  });
29
30
 
31
+ // New approach: read accounts from LoyaltyMoneyUsagePage context
32
+ const loyaltyAccounts: LoyaltyBalanceItem[] = useMemo(() => {
33
+ const loyaltyContext = checkoutLoyaltyData?.context_list?.find(
34
+ (ctx) => ctx.page_name === 'LoyaltyMoneyUsagePage'
35
+ );
36
+ return (
37
+ (loyaltyContext?.page_context?.accounts as LoyaltyBalanceItem[]) ?? []
38
+ );
39
+ }, [checkoutLoyaltyData]);
40
+
41
+ const selectableAccounts = useMemo(() => {
42
+ return loyaltyAccounts.filter((account) => parseFloat(account.balance) > 0);
43
+ }, [loyaltyAccounts]);
44
+
45
+ // Determine which mode to use:
46
+ // - "accounts" mode: backend returns page_context.accounts (new)
47
+ // - "legacy" mode: Redux loyaltyBalance/loyaltyBalances from page_context.balance/balances (old)
48
+ const hasAccounts = selectableAccounts.length > 0;
49
+ const hasLegacyGrouped = !hasAccounts && loyaltyBalances?.length > 0;
50
+ const hasLegacySingle =
51
+ !hasAccounts && !hasLegacyGrouped && parseFloat(loyaltyBalance || '0') > 0;
52
+
30
53
  const isLoyaltyBalanceUsed = useMemo(() => {
31
54
  return parseFloat(preOrder?.loyalty_money ?? '0') > 0;
32
55
  }, [preOrder?.loyalty_money]);
33
56
 
57
+ // --- Accounts mode state ---
58
+ const [selectedAccountIds, setSelectedAccountIds] = useState<Set<string>>(
59
+ new Set()
60
+ );
61
+
62
+ useEffect(() => {
63
+ if (!hasAccounts) return;
64
+ const usages = preOrder?.loyalty_account_usages;
65
+ if (usages && Array.isArray(usages)) {
66
+ setSelectedAccountIds(
67
+ new Set(
68
+ usages
69
+ .filter((u) => parseFloat(String(u.amount)) > 0)
70
+ .map((u) => String(u.label_id))
71
+ )
72
+ );
73
+ } else if (
74
+ parseFloat(preOrder?.loyalty_money ?? '0') > 0 &&
75
+ selectableAccounts.length > 0
76
+ ) {
77
+ setSelectedAccountIds(
78
+ new Set(selectableAccounts.map((a) => String(a.label_id)))
79
+ );
80
+ } else {
81
+ setSelectedAccountIds(new Set());
82
+ }
83
+ }, [
84
+ hasAccounts,
85
+ preOrder?.loyalty_account_usages,
86
+ preOrder?.loyalty_money,
87
+ selectableAccounts
88
+ ]);
89
+
90
+ // --- Legacy grouped mode state ---
91
+ const [selectedLabels, setSelectedLabels] = useState<Record<string, boolean>>(
92
+ {}
93
+ );
94
+
34
95
  const [isLoading, setIsLoading] = useState(false);
35
96
 
36
- const handleClick = async () => {
97
+ const totalGroupedBalance = useMemo(() => {
98
+ if (!loyaltyBalances) return 0;
99
+ return loyaltyBalances.reduce(
100
+ (sum, item) => sum + parseFloat(item.balance || '0'),
101
+ 0
102
+ );
103
+ }, [loyaltyBalances]);
104
+
105
+ // --- Handlers ---
106
+ const handleToggleAccount = async (account: LoyaltyBalanceItem) => {
107
+ if (isLoading) return;
108
+ setIsLoading(true);
109
+
110
+ try {
111
+ const key = String(account.label_id);
112
+ const newSelected = new Set(selectedAccountIds);
113
+
114
+ if (newSelected.has(key)) {
115
+ newSelected.delete(key);
116
+ } else {
117
+ newSelected.add(key);
118
+ }
119
+
120
+ setSelectedAccountIds(newSelected);
121
+
122
+ const accountUsages: AccountUsage[] = selectableAccounts
123
+ .filter((acc) => newSelected.has(String(acc.label_id)))
124
+ .map((acc) => ({
125
+ label_id: acc.label_id,
126
+ amount: parseFloat(acc.balance)
127
+ }));
128
+
129
+ await payWithLoyaltyBalance({ account_usages: accountUsages });
130
+ } finally {
131
+ setIsLoading(false);
132
+ }
133
+ };
134
+
135
+ const handleToggleLegacyAll = async () => {
136
+ if (isLoading) return;
137
+ setIsLoading(true);
138
+
139
+ try {
140
+ if (isLoyaltyBalanceUsed) {
141
+ if (hasLegacyGrouped) {
142
+ const accountUsages: AccountUsage[] = loyaltyBalances.map((item) => ({
143
+ label_id: item.label_id,
144
+ amount: 0
145
+ }));
146
+ await payWithLoyaltyBalance({ account_usages: accountUsages });
147
+ setSelectedLabels({});
148
+ } else {
149
+ await payWithLoyaltyBalance('0');
150
+ }
151
+ } else {
152
+ if (hasLegacyGrouped) {
153
+ const accountUsages: AccountUsage[] = loyaltyBalances.map((item) => ({
154
+ label_id: item.label_id,
155
+ amount: parseFloat(item.balance)
156
+ }));
157
+ await payWithLoyaltyBalance({ account_usages: accountUsages });
158
+ const allSelected = loyaltyBalances.reduce(
159
+ (acc, item) => ({ ...acc, [String(item.label_id)]: true }),
160
+ {} as Record<string, boolean>
161
+ );
162
+ setSelectedLabels(allSelected);
163
+ } else {
164
+ await payWithLoyaltyBalance(loyaltyBalance);
165
+ }
166
+ }
167
+ } finally {
168
+ setIsLoading(false);
169
+ }
170
+ };
171
+
172
+ const handleToggleLegacyLabel = async (item: LoyaltyBalanceItem) => {
37
173
  if (isLoading) return;
38
174
  setIsLoading(true);
39
175
 
40
176
  try {
41
- await payWithLoyaltyBalance(isLoyaltyBalanceUsed ? '0' : loyaltyBalance);
177
+ const key = String(item.label_id);
178
+ const isCurrentlySelected = selectedLabels[key] ?? false;
179
+ const newSelectedLabels = {
180
+ ...selectedLabels,
181
+ [key]: !isCurrentlySelected
182
+ };
183
+
184
+ const accountUsages: AccountUsage[] = loyaltyBalances.map((b) => ({
185
+ label_id: b.label_id,
186
+ amount: newSelectedLabels[String(b.label_id)]
187
+ ? parseFloat(b.balance)
188
+ : 0
189
+ }));
190
+
191
+ await payWithLoyaltyBalance({ account_usages: accountUsages });
192
+ setSelectedLabels(newSelectedLabels);
42
193
  } finally {
43
194
  setIsLoading(false);
44
195
  }
45
196
  };
46
197
 
198
+ // --- Early returns ---
47
199
  if (preOrder?.is_guest) {
48
200
  return null;
49
201
  }
@@ -56,19 +208,207 @@ export const StoreCredits = () => {
56
208
  );
57
209
  }
58
210
 
59
- if (parseFloat(loyaltyBalance) <= 0) {
211
+ if (!hasAccounts && !hasLegacyGrouped && !hasLegacySingle) {
60
212
  return null;
61
213
  }
214
+
215
+ // --- Accounts mode render (new: from page_context.accounts) ---
216
+ if (hasAccounts) {
217
+ return (
218
+ <div
219
+ className={twMerge(
220
+ 'flex flex-col w-full mb-4 border border-solid border-gray-400 px-0 md:p-4',
221
+ isPayLoading && 'pointer-events-none opacity-30'
222
+ )}
223
+ >
224
+ {selectableAccounts.map((account) => {
225
+ const isSelected = selectedAccountIds.has(String(account.label_id));
226
+
227
+ return (
228
+ <div
229
+ key={String(account.label_id) ?? 'default'}
230
+ className="mb-3 flex w-full items-center"
231
+ >
232
+ <button onClick={() => handleToggleAccount(account)}>
233
+ <span
234
+ className={clsx(
235
+ 'flex h-5 w-5 items-center justify-center rounded border border-solid border-primary',
236
+ isSelected ? 'bg-primary' : 'bg-white'
237
+ )}
238
+ >
239
+ <Icon
240
+ name={isSelected ? 'check' : ''}
241
+ size={10}
242
+ className={clsx({ 'text-white': isSelected })}
243
+ />
244
+ </span>
245
+ </button>
246
+
247
+ <div className="w-full pl-4 rtl:pr-4">
248
+ <p
249
+ className="cursor-pointer text-sm"
250
+ onClick={() => handleToggleAccount(account)}
251
+ >
252
+ {account.label ??
253
+ t('checkout.payment.store_credit.use_my_store_credits')}
254
+ </p>
255
+ <p className="flex text-sm text-[#606060]">
256
+ {t('checkout.payment.store_credit.available_balance')}:
257
+ <Price
258
+ value={account.balance}
259
+ currencyCode={
260
+ account.currency?.toUpperCase() ||
261
+ preOrder?.currency_type_label
262
+ }
263
+ className="pe-1 font-bold"
264
+ />
265
+ </p>
266
+ </div>
267
+ </div>
268
+ );
269
+ })}
270
+
271
+ {isLoyaltyBalanceUsed && parseFloat(preOrder?.unpaid_amount) > 0 && (
272
+ <p className="my-4 text-[15px] font-light italic text-[#707070] max-xs:text-xs">
273
+ <Trans
274
+ i18nKey="checkout.payment.store_credit.insufficient_balance"
275
+ components={{
276
+ Amount: (
277
+ <div className="inline-flex">
278
+ <Price
279
+ value={preOrder?.unpaid_amount}
280
+ currencyCode={preOrder?.currency_type_label}
281
+ className="text-primary"
282
+ />
283
+ </div>
284
+ )
285
+ }}
286
+ />
287
+ </p>
288
+ )}
289
+ </div>
290
+ );
291
+ }
292
+
293
+ // --- Legacy grouped mode render (from Redux loyaltyBalances) ---
294
+ if (hasLegacyGrouped) {
295
+ return (
296
+ <div
297
+ className={twMerge(
298
+ 'flex flex-col w-full mb-4 border border-solid border-gray-400 px-0 md:p-4',
299
+ isPayLoading && 'pointer-events-none opacity-30'
300
+ )}
301
+ >
302
+ <div className="flex w-full items-center mb-3">
303
+ <button onClick={handleToggleLegacyAll}>
304
+ <span
305
+ className={clsx(
306
+ 'flex h-5 w-5 items-center justify-center rounded border border-solid border-primary',
307
+ isLoyaltyBalanceUsed ? 'bg-primary' : 'bg-white'
308
+ )}
309
+ >
310
+ <Icon
311
+ name={isLoyaltyBalanceUsed ? 'check' : ''}
312
+ size={10}
313
+ className={clsx({ 'text-white': isLoyaltyBalanceUsed })}
314
+ />
315
+ </span>
316
+ </button>
317
+
318
+ <div className="w-full pl-4">
319
+ <p
320
+ className="cursor-pointer text-sm"
321
+ onClick={handleToggleLegacyAll}
322
+ >
323
+ {t('checkout.payment.store_credit.use_my_store_credits')}
324
+ </p>
325
+ <p className="flex text-sm text-[#606060]">
326
+ {t('checkout.payment.store_credit.total_balance')}:
327
+ <Price
328
+ value={String(totalGroupedBalance)}
329
+ currencyCode={preOrder?.currency_type_label}
330
+ className="pe-1 font-bold"
331
+ />
332
+ </p>
333
+ </div>
334
+ </div>
335
+
336
+ <div className="ml-9 flex flex-col gap-2">
337
+ {loyaltyBalances.map((item) => {
338
+ const isSelected = selectedLabels[String(item.label_id)] ?? false;
339
+ return (
340
+ <div
341
+ key={String(item.label_id)}
342
+ className="flex items-center border border-solid border-gray-200 rounded p-2"
343
+ >
344
+ <button onClick={() => handleToggleLegacyLabel(item)}>
345
+ <span
346
+ className={clsx(
347
+ 'flex h-4 w-4 items-center justify-center rounded border border-solid border-primary',
348
+ isSelected ? 'bg-primary' : 'bg-white'
349
+ )}
350
+ >
351
+ <Icon
352
+ name={isSelected ? 'check' : ''}
353
+ size={8}
354
+ className={clsx({ 'text-white': isSelected })}
355
+ />
356
+ </span>
357
+ </button>
358
+ <div className="flex w-full items-center justify-between pl-3">
359
+ <span
360
+ className="cursor-pointer text-sm"
361
+ onClick={() => handleToggleLegacyLabel(item)}
362
+ >
363
+ {item.label ??
364
+ t('checkout.payment.store_credit.use_my_store_credits')}
365
+ </span>
366
+ <Price
367
+ value={item.balance}
368
+ currencyCode={
369
+ item.currency?.toUpperCase() ||
370
+ preOrder?.currency_type_label
371
+ }
372
+ className="text-sm font-bold"
373
+ />
374
+ </div>
375
+ </div>
376
+ );
377
+ })}
378
+ </div>
379
+
380
+ {isLoyaltyBalanceUsed && parseFloat(preOrder?.unpaid_amount) > 0 && (
381
+ <p className="my-4 text-[15px] font-light italic text-[#707070] max-xs:text-xs">
382
+ <Trans
383
+ i18nKey="checkout.payment.store_credit.insufficient_balance"
384
+ components={{
385
+ Amount: (
386
+ <div className="inline-flex">
387
+ <Price
388
+ value={preOrder?.unpaid_amount}
389
+ currencyCode={preOrder?.currency_type_label}
390
+ className="text-primary"
391
+ />
392
+ </div>
393
+ )
394
+ }}
395
+ />
396
+ </p>
397
+ )}
398
+ </div>
399
+ );
400
+ }
401
+
402
+ // --- Legacy single balance mode render (from Redux loyaltyBalance) ---
62
403
  return (
63
404
  <div
64
405
  className={twMerge(
65
- 'hidden flex-col w-full mb-4 border border-solid border-gray-400 px-0 md:p-4',
66
- isPayWithLoyaltyBalanceLoading && 'pointer-events-none opacity-30',
67
- parseFloat(loyaltyBalance) > 0 && 'block'
406
+ 'flex flex-col w-full mb-4 border border-solid border-gray-400 px-0 md:p-4',
407
+ isPayLoading && 'pointer-events-none opacity-30'
68
408
  )}
69
409
  >
70
410
  <div className="flex w-full items-center">
71
- <button onClick={handleClick}>
411
+ <button onClick={handleToggleLegacyAll}>
72
412
  <span
73
413
  className={clsx(
74
414
  'flex h-5 w-5 items-center justify-center rounded border border-solid border-primary',
@@ -84,7 +424,10 @@ export const StoreCredits = () => {
84
424
  </button>
85
425
 
86
426
  <div className="w-full pl-4">
87
- <p className="cursor-pointer text-sm" onClick={handleClick}>
427
+ <p
428
+ className="cursor-pointer text-sm"
429
+ onClick={handleToggleLegacyAll}
430
+ >
88
431
  {t('checkout.payment.store_credit.use_my_store_credits')}
89
432
  </p>
90
433
  <p className="flex text-sm text-[#606060]">
@@ -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
  }
@@ -29,7 +29,14 @@ async function checkVersion(pkg: PackageJson) {
29
29
 
30
30
  if (!semver.satisfies(pkg.dependencies['@akinon/next'], latestVersion)) {
31
31
  console.warn(
32
- `\x1b[43mWarning: The "${packageName}" package is currently at version ${pkg.dependencies['@akinon/next']}. Please upgrade it to the latest version (${latestVersion}) to ensure plugin compatibility.`,
32
+ `\x1b[43m Warning: The "${packageName}" package is currently at`,
33
+ `\x1b[41m version ${pkg.dependencies['@akinon/next']}`,
34
+ `\x1b[43m Please upgrade it to the latest version (${latestVersion}) to ensure plugin compatibility.`,
35
+ '\x1b[0m\n'
36
+ );
37
+ } else {
38
+ console.log(
39
+ `\x1b[42m Info: The package "${packageName}" is currently in the current version (${latestVersion}).`,
33
40
  '\x1b[0m\n'
34
41
  );
35
42
  }
@@ -54,7 +61,27 @@ export default async () => {
54
61
  }
55
62
  }
56
63
 
57
- const pkg: PackageJson = require(path.resolve(rootDir, './package.json'));
64
+ function findPackageJson(): PackageJson {
65
+ const packageJsonPaths = [
66
+ path.resolve(rootDir, './package.json'),
67
+ path.resolve(rootDir, './apps/projectzeronext/package.json')
68
+ ];
69
+
70
+ for (const packageJsonPath of packageJsonPaths) {
71
+ try {
72
+ const pkg = require(packageJsonPath);
73
+ if (pkg.dependencies['@akinon/next']) {
74
+ return pkg;
75
+ }
76
+ } catch (error) {
77
+ continue;
78
+ }
79
+ }
80
+
81
+ throw new Error('Could not find package.json with @akinon/next dependency');
82
+ }
83
+
84
+ const pkg = findPackageJson();
58
85
  await checkVersion(pkg);
59
86
 
60
87
  const pluginsFilePath = findPluginsFilePath();
@@ -137,10 +164,6 @@ export default async () => {
137
164
  name: 'Tamara Payment Extension',
138
165
  value: 'pz-tamara-extension'
139
166
  },
140
- {
141
- name: 'Similar Products',
142
- value: 'pz-similar-products'
143
- },
144
167
  {
145
168
  name: 'Hepsipay',
146
169
  value: 'pz-hepsipay'
@@ -152,10 +152,6 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
152
152
  name: 'Tamara Payment Extension',
153
153
  value: 'pz-tamara-extension'
154
154
  },
155
- {
156
- name: 'Similar Products',
157
- value: 'pz-similar-products'
158
- },
159
155
  {
160
156
  name: 'Hepsipay',
161
157
  value: 'pz-hepsipay'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akinon/projectzero",
3
- "version": "1.123.0-rc.0",
3
+ "version": "1.123.0",
4
4
  "private": false,
5
5
  "description": "CLI tool to manage your Project Zero Next project",
6
6
  "bin": {