@akinon/next 1.112.0-snapshot-ZERO-3855-20251124131245 → 1.112.0-snapshot-ZERO-3792-20251202082030

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,10 +1,10 @@
1
1
  # @akinon/next
2
2
 
3
- ## 1.112.0-snapshot-ZERO-3855-20251124131245
3
+ ## 1.112.0-snapshot-ZERO-3792-20251202082030
4
4
 
5
5
  ### Minor Changes
6
6
 
7
- - 591e345: ZERO-3855: Enhance credit card payment handling in checkout middlewares
7
+ - 888fdec: ZERO-3792: Virtual Try On new features are implemented and also basket support implemented.
8
8
 
9
9
  ## 1.111.0
10
10
 
@@ -122,6 +122,57 @@ export async function GET(request: NextRequest) {
122
122
  'X-Virtual-Try-On-Cache-Status': 'MISS'
123
123
  }
124
124
  });
125
+ } else if (endpoint === 'job-status') {
126
+ const referenceUrl = searchParams.get('reference_url');
127
+ if (!referenceUrl) {
128
+ return NextResponse.json(
129
+ { error: 'reference_url is required' },
130
+ { status: 400 }
131
+ );
132
+ }
133
+
134
+ const externalUrl = `${VIRTUAL_TRY_ON_API_URL}/api/async/v1/job-status?reference_url=${encodeURIComponent(
135
+ referenceUrl
136
+ )}`;
137
+ const clientIP = getClientIP(request);
138
+ const locale = getLocaleFromRequest(request);
139
+
140
+ const headersToSend = {
141
+ Accept: 'application/json',
142
+ ...(locale && { 'Accept-Language': locale }),
143
+ ...(request.headers.get('authorization') && {
144
+ Authorization: request.headers.get('authorization')!
145
+ }),
146
+ ...(clientIP && {
147
+ 'X-Forwarded-For': clientIP
148
+ })
149
+ };
150
+
151
+ const response = await fetch(externalUrl, {
152
+ method: 'GET',
153
+ headers: headersToSend
154
+ });
155
+
156
+ let responseData: any;
157
+ const responseText = await response.text();
158
+
159
+ try {
160
+ responseData = responseText ? JSON.parse(responseText) : {};
161
+ } catch (parseError) {
162
+ return NextResponse.json(
163
+ { error: 'Invalid JSON response from job status API' },
164
+ { status: 500 }
165
+ );
166
+ }
167
+
168
+ return NextResponse.json(responseData, {
169
+ status: response.status,
170
+ headers: {
171
+ 'Access-Control-Allow-Origin': '*',
172
+ 'Access-Control-Allow-Methods': 'GET, POST, PUT, OPTIONS',
173
+ 'Access-Control-Allow-Headers': 'Content-Type, Accept, Authorization'
174
+ }
175
+ });
125
176
  }
126
177
 
127
178
  return NextResponse.json(
@@ -141,13 +192,32 @@ export async function POST(request: NextRequest) {
141
192
  const body = await request.json();
142
193
 
143
194
  let externalUrl: string;
195
+ let httpMethod = 'POST';
196
+
144
197
  if (endpoint === 'feedback') {
198
+ if (!body.url || typeof body.url !== 'string' || !body.url.trim()) {
199
+ return NextResponse.json(
200
+ { status: 'error', message: 'URL is required for feedback' },
201
+ { status: 400 }
202
+ );
203
+ }
204
+ if (typeof body.feedback !== 'boolean') {
205
+ return NextResponse.json(
206
+ { status: 'error', message: 'Feedback must be a boolean value' },
207
+ { status: 400 }
208
+ );
209
+ }
145
210
  externalUrl = `${VIRTUAL_TRY_ON_API_URL}/api/v1/feedback`;
211
+ httpMethod = 'PUT';
212
+ } else if (endpoint === 'async-multiple-try-on') {
213
+ externalUrl = `${VIRTUAL_TRY_ON_API_URL}/api/async/v1/multiple-virtual-try-on`;
146
214
  } else {
147
- externalUrl = `${VIRTUAL_TRY_ON_API_URL}/api/v1/virtual-try-on`;
215
+ return NextResponse.json(
216
+ { error: 'Invalid endpoint specified' },
217
+ { status: 400 }
218
+ );
148
219
  }
149
220
 
150
- const httpMethod = endpoint === 'feedback' ? 'PUT' : 'POST';
151
221
  const clientIP = getClientIP(request);
152
222
  const locale = getLocaleFromRequest(request);
153
223
 
@@ -163,13 +233,18 @@ export async function POST(request: NextRequest) {
163
233
  })
164
234
  };
165
235
 
166
- const response = await fetch(externalUrl, {
236
+ const fetchOptions: RequestInit = {
167
237
  method: httpMethod,
168
- headers: headersToSend,
169
- body: JSON.stringify(body)
170
- });
238
+ headers: headersToSend
239
+ };
240
+
241
+ if (httpMethod !== 'GET') {
242
+ fetchOptions.body = JSON.stringify(body);
243
+ }
244
+
245
+ const response = await fetch(externalUrl, fetchOptions);
171
246
 
172
- let responseData: any;
247
+ let responseData: Record<string, any>;
173
248
  const responseText = await response.text();
174
249
 
175
250
  if (endpoint === 'feedback') {
@@ -273,7 +348,7 @@ export async function PUT(request: NextRequest) {
273
348
  body: JSON.stringify(body)
274
349
  });
275
350
 
276
- const responseData = await response.json();
351
+ const responseData = response?.json() || {};
277
352
 
278
353
  return NextResponse.json(responseData, {
279
354
  status: response.status,
@@ -287,7 +362,8 @@ export async function PUT(request: NextRequest) {
287
362
  return NextResponse.json(
288
363
  {
289
364
  status: 'error',
290
- message: 'Internal server error occurred during feedback submission'
365
+ message: 'Internal server error occurred during feedback submission',
366
+ error: (error as Error).message
291
367
  },
292
368
  { status: 500 }
293
369
  );
@@ -51,6 +51,7 @@ export enum Component {
51
51
  MultiBasket = 'MultiBasket',
52
52
  SavedCard = 'SavedCardOption',
53
53
  VirtualTryOnPlugin = 'VirtualTryOnPlugin',
54
+ BasketVirtualTryOn = 'BasketVirtualTryOn',
54
55
  IyzicoSavedCard = 'IyzicoSavedCardOption',
55
56
  Hepsipay = 'Hepsipay',
56
57
  FlowPayment = 'FlowPayment',
@@ -90,7 +91,11 @@ const PluginComponents = new Map([
90
91
  [Plugin.SavedCard, [Component.SavedCard, Component.IyzicoSavedCard]],
91
92
  [Plugin.SavedCard, [Component.SavedCard]],
92
93
  [Plugin.FlowPayment, [Component.FlowPayment]],
93
- [Plugin.VirtualTryOn, [Component.VirtualTryOnPlugin]],
94
+ [
95
+ Plugin.VirtualTryOn,
96
+ [Component.VirtualTryOnPlugin, Component.BasketVirtualTryOn]
97
+ ],
98
+ [Plugin.Hepsipay, [Component.Hepsipay]],
94
99
  [Plugin.Hepsipay, [Component.Hepsipay]],
95
100
  [Plugin.MasterpassRest, [Component.MasterpassRest]]
96
101
  ]);
@@ -104,10 +109,10 @@ const getPlugin = (component: Component) => {
104
109
  };
105
110
 
106
111
  export default function PluginModule({
107
- component,
108
- props,
109
- children
110
- }: {
112
+ component,
113
+ props,
114
+ children
115
+ }: {
111
116
  component: Component;
112
117
  props?: any;
113
118
  children?: React.ReactNode;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@akinon/next",
3
3
  "description": "Core package for Project Zero Next",
4
- "version": "1.112.0-snapshot-ZERO-3855-20251124131245",
4
+ "version": "1.112.0-snapshot-ZERO-3792-20251202082030",
5
5
  "private": false,
6
6
  "license": "MIT",
7
7
  "bin": {
@@ -35,7 +35,7 @@
35
35
  "set-cookie-parser": "2.6.0"
36
36
  },
37
37
  "devDependencies": {
38
- "@akinon/eslint-plugin-projectzero": "1.112.0-snapshot-ZERO-3855-20251124131245",
38
+ "@akinon/eslint-plugin-projectzero": "1.112.0-snapshot-ZERO-3792-20251202082030",
39
39
  "@babel/core": "7.26.10",
40
40
  "@babel/preset-env": "7.26.9",
41
41
  "@babel/preset-typescript": "7.27.0",
@@ -204,25 +204,15 @@ export const contextListMiddleware: Middleware = ({
204
204
  (ctx) => ctx.page_name === 'DeliveryOptionSelectionPage'
205
205
  )
206
206
  ) {
207
- const isCreditCardPayment =
208
- preOrder?.payment_option?.payment_type === 'credit_card' ||
209
- preOrder?.payment_option?.payment_type === 'masterpass';
210
-
211
207
  if (context.page_context.card_type) {
212
208
  dispatch(setCardType(context.page_context.card_type));
213
- } else if (isCreditCardPayment) {
214
- dispatch(setCardType(null));
215
209
  }
216
210
 
217
211
  if (
218
212
  context.page_context.installments &&
219
213
  preOrder?.payment_option?.payment_type !== 'masterpass_rest'
220
214
  ) {
221
- if (!isCreditCardPayment || context.page_context.card_type) {
222
- dispatch(
223
- setInstallmentOptions(context.page_context.installments)
224
- );
225
- }
215
+ dispatch(setInstallmentOptions(context.page_context.installments));
226
216
  }
227
217
  }
228
218
 
@@ -14,17 +14,9 @@ export const installmentOptionMiddleware: Middleware = ({
14
14
  return result;
15
15
  }
16
16
 
17
- const { installmentOptions, cardType } = getState().checkout;
17
+ const { installmentOptions } = getState().checkout;
18
18
  const { endpoints: apiEndpoints } = checkoutApi;
19
19
 
20
- const isCreditCardPayment =
21
- preOrder?.payment_option?.payment_type === 'credit_card' ||
22
- preOrder?.payment_option?.payment_type === 'masterpass';
23
-
24
- if (isCreditCardPayment && !cardType) {
25
- return result;
26
- }
27
-
28
20
  if (
29
21
  !preOrder?.installment &&
30
22
  preOrder?.payment_option?.payment_type !== 'saved_card' &&