@akinon/next 2.0.0-beta.11 → 2.0.0-beta.13
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 +286 -27
- package/api/auth.ts +99 -77
- package/api/cache.ts +41 -5
- package/api/client.ts +3 -3
- package/api/form.ts +85 -0
- package/api/image-proxy.ts +75 -0
- package/api/product-categories.ts +53 -0
- package/api/similar-product-list.ts +63 -0
- package/api/similar-products.ts +111 -0
- package/api/virtual-try-on.ts +382 -0
- package/bin/pz-generate-routes.js +105 -0
- package/bin/pz-prebuild.js +1 -1
- package/bin/pz-predev.js +1 -0
- package/components/accordion.tsx +21 -6
- package/components/button.tsx +1 -1
- package/components/file-input.tsx +65 -3
- package/components/input.tsx +2 -2
- package/components/modal.tsx +32 -16
- package/components/plugin-module.tsx +61 -3
- package/components/select.tsx +2 -2
- package/components/selected-payment-option-view.tsx +21 -0
- package/data/client/checkout.ts +130 -74
- package/data/server/category.ts +11 -9
- package/data/server/flatpage.ts +4 -1
- package/data/server/form.ts +4 -1
- package/data/server/landingpage.ts +4 -1
- package/data/server/list.ts +5 -4
- package/data/server/menu.ts +4 -1
- package/data/server/product.ts +97 -52
- package/data/server/seo.ts +4 -1
- package/data/server/special-page.ts +5 -4
- package/data/server/widget.ts +4 -1
- package/data/urls.ts +3 -2
- package/hocs/client/with-segment-defaults.tsx +2 -2
- package/hocs/server/with-segment-defaults.tsx +65 -20
- package/hooks/index.ts +1 -0
- package/hooks/use-loyalty-availability.ts +21 -0
- package/hooks/use-payment-options.ts +2 -1
- package/hooks/use-pz-params.ts +37 -0
- package/instrumentation/index.ts +0 -1
- package/instrumentation/node.ts +2 -20
- package/jest.config.js +7 -1
- package/lib/cache-handler.mjs +527 -15
- package/lib/cache.ts +260 -31
- package/localization/provider.tsx +2 -5
- package/middlewares/checkout-provider.ts +1 -1
- package/middlewares/complete-gpay.ts +33 -26
- package/middlewares/complete-masterpass.ts +34 -26
- package/middlewares/complete-wallet.ts +183 -0
- package/middlewares/default.ts +346 -235
- package/middlewares/index.ts +8 -2
- package/middlewares/locale.ts +0 -1
- package/middlewares/masterpass-rest-callback.ts +220 -0
- package/middlewares/pretty-url.ts +21 -8
- package/middlewares/redirection-payment.ts +33 -26
- package/middlewares/saved-card-redirection.ts +34 -26
- package/middlewares/three-d-redirection.ts +33 -26
- package/middlewares/url-redirection.ts +9 -15
- package/middlewares/wallet-complete-redirection.ts +207 -0
- package/package.json +20 -11
- package/plugins.d.ts +19 -4
- package/plugins.js +9 -1
- package/redux/actions.ts +47 -0
- package/redux/middlewares/checkout.ts +20 -8
- package/redux/middlewares/index.ts +12 -10
- package/redux/middlewares/pre-order/address.ts +1 -1
- package/redux/middlewares/pre-order/attribute-based-shipping-option.ts +1 -1
- package/redux/middlewares/pre-order/data-source-shipping-option.ts +1 -1
- package/redux/middlewares/pre-order/delivery-option.ts +1 -1
- package/redux/middlewares/pre-order/index.ts +3 -1
- package/redux/middlewares/pre-order/installment-option.ts +2 -1
- package/redux/middlewares/pre-order/payment-option-reset.ts +37 -0
- package/redux/middlewares/pre-order/payment-option.ts +1 -1
- package/redux/middlewares/pre-order/pre-order-validation.ts +4 -3
- package/redux/middlewares/pre-order/redirection.ts +2 -2
- package/redux/middlewares/pre-order/set-pre-order.ts +2 -2
- package/redux/middlewares/pre-order/shipping-option.ts +1 -1
- package/redux/middlewares/pre-order/shipping-step.ts +1 -1
- package/redux/reducers/checkout.ts +9 -1
- package/redux/reducers/index.ts +5 -1
- package/sentry/index.ts +54 -17
- package/types/commerce/checkout.ts +11 -1
- package/types/index.ts +96 -6
- package/types/next-auth.d.ts +2 -2
- package/utils/app-fetch.ts +2 -2
- package/utils/generate-commerce-search-params.ts +3 -2
- package/utils/get-checkout-path.ts +3 -0
- package/utils/index.ts +38 -11
- package/utils/override-middleware.ts +1 -0
- package/utils/pz-segments.ts +92 -0
- package/utils/redirect-ignore.ts +35 -0
- package/utils/redirect.ts +9 -3
- package/with-pz-config.js +10 -4
package/data/client/checkout.ts
CHANGED
|
@@ -17,10 +17,10 @@ import {
|
|
|
17
17
|
SendSmsType,
|
|
18
18
|
VerifySmsType
|
|
19
19
|
} from '../../types';
|
|
20
|
-
import { buildClientRequestUrl } from '../../utils';
|
|
20
|
+
import { buildClientRequestUrl, getCookie } from '../../utils';
|
|
21
21
|
import { api } from './api';
|
|
22
22
|
import { checkout } from '../urls';
|
|
23
|
-
import { AppDispatch, AppStore
|
|
23
|
+
import type { AppDispatch, AppStore } from 'redux/store';
|
|
24
24
|
import settings from 'settings';
|
|
25
25
|
import { showMobile3dIframe } from '../../utils/mobile-3d-iframe';
|
|
26
26
|
import {
|
|
@@ -33,6 +33,11 @@ import {
|
|
|
33
33
|
buildPurchaseForm
|
|
34
34
|
} from '@akinon/pz-masterpass/src/utils';
|
|
35
35
|
|
|
36
|
+
const getStore = async (): Promise<AppStore> => {
|
|
37
|
+
const { store } = await import('redux/store');
|
|
38
|
+
return store;
|
|
39
|
+
};
|
|
40
|
+
|
|
36
41
|
interface CheckoutResponse {
|
|
37
42
|
pre_order?: PreOrder;
|
|
38
43
|
errors: {
|
|
@@ -82,6 +87,18 @@ export interface PayOnDeliveryParams {
|
|
|
82
87
|
paymentType: string;
|
|
83
88
|
}
|
|
84
89
|
|
|
90
|
+
const buildCheckoutRequestUrl = (
|
|
91
|
+
path: string,
|
|
92
|
+
options?: Parameters<typeof buildClientRequestUrl>[1]
|
|
93
|
+
) => {
|
|
94
|
+
const effectivePath =
|
|
95
|
+
getCookie('pz-post-checkout-flow') === 'true' &&
|
|
96
|
+
/^\/orders\/checkout(\/|\?|$)/.test(path)
|
|
97
|
+
? path.replace('/orders/checkout', '/orders/post-checkout')
|
|
98
|
+
: path;
|
|
99
|
+
return buildClientRequestUrl(effectivePath, options);
|
|
100
|
+
};
|
|
101
|
+
|
|
85
102
|
const completeMasterpassPayment = async (
|
|
86
103
|
params: CompleteCreditCardParams,
|
|
87
104
|
dispatch: AppDispatch,
|
|
@@ -181,41 +198,41 @@ export const checkoutApi = api.injectEndpoints({
|
|
|
181
198
|
endpoints: (build) => ({
|
|
182
199
|
fetchCheckout: build.query<CheckoutResponse, void>({
|
|
183
200
|
query: () => ({
|
|
184
|
-
url:
|
|
201
|
+
url: buildCheckoutRequestUrl(checkout.fetchCheckout, {})
|
|
185
202
|
}),
|
|
186
203
|
providesTags: ['Checkout']
|
|
187
204
|
}),
|
|
188
205
|
resetCheckoutState: build.query<CheckoutResponse, void>({
|
|
189
206
|
query: () => ({
|
|
190
|
-
url:
|
|
207
|
+
url: buildCheckoutRequestUrl(checkout.guestLogin, {})
|
|
191
208
|
})
|
|
192
209
|
}),
|
|
193
210
|
fetchCheckoutResult: build.query<{ order: Order }, string>({
|
|
194
211
|
query: (token: string) =>
|
|
195
|
-
|
|
212
|
+
buildCheckoutRequestUrl(checkout.fetchCheckoutResult(token))
|
|
196
213
|
}),
|
|
197
214
|
get3dRedirectForm: build.query<{ result: string }, void>({
|
|
198
215
|
query: () =>
|
|
199
|
-
|
|
216
|
+
buildCheckoutRequestUrl(checkout.get3dRedirectForm, {
|
|
200
217
|
responseType: 'text'
|
|
201
218
|
})
|
|
202
219
|
}),
|
|
203
220
|
getContract: build.query<GetContractResponse, string>({
|
|
204
221
|
query: (slug: string) =>
|
|
205
|
-
|
|
222
|
+
buildCheckoutRequestUrl(checkout.getContract(slug), {
|
|
206
223
|
responseType: 'text'
|
|
207
224
|
})
|
|
208
225
|
}),
|
|
209
226
|
getCoupons: build.query<CheckoutResponse, void>({
|
|
210
227
|
query: () => ({
|
|
211
|
-
url:
|
|
228
|
+
url: buildCheckoutRequestUrl(checkout.couponSelectionPage)
|
|
212
229
|
})
|
|
213
230
|
}),
|
|
214
231
|
|
|
215
232
|
setCoupon: build.mutation<CheckoutResponse, { pk: number; action: string }>(
|
|
216
233
|
{
|
|
217
234
|
query: ({ pk, action }) => ({
|
|
218
|
-
url:
|
|
235
|
+
url: buildCheckoutRequestUrl(checkout.couponSelectionPage, {
|
|
219
236
|
useFormData: true
|
|
220
237
|
}),
|
|
221
238
|
method: 'POST',
|
|
@@ -231,25 +248,32 @@ export const checkoutApi = api.injectEndpoints({
|
|
|
231
248
|
CheckoutResponse,
|
|
232
249
|
CompleteCreditCardParams
|
|
233
250
|
>({
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
251
|
+
async queryFn(
|
|
252
|
+
{
|
|
253
|
+
card_holder,
|
|
254
|
+
card_cvv,
|
|
255
|
+
card_number,
|
|
256
|
+
card_month,
|
|
257
|
+
card_year,
|
|
258
|
+
use_three_d = true,
|
|
259
|
+
save = undefined
|
|
260
|
+
},
|
|
261
|
+
_queryApi,
|
|
262
|
+
_extraOptions,
|
|
263
|
+
baseQuery
|
|
264
|
+
) {
|
|
265
|
+
const reduxStore = await getStore();
|
|
243
266
|
const paymentOption =
|
|
244
|
-
|
|
267
|
+
reduxStore.getState().checkout?.preOrder?.payment_option;
|
|
245
268
|
|
|
246
269
|
if (paymentOption?.payment_type === 'masterpass') {
|
|
247
|
-
|
|
248
|
-
url:
|
|
270
|
+
const result = await baseQuery({
|
|
271
|
+
url: buildCheckoutRequestUrl(checkout.getMasterpassOrderNo, {
|
|
249
272
|
useFormData: true
|
|
250
273
|
}),
|
|
251
274
|
method: 'POST'
|
|
252
|
-
};
|
|
275
|
+
});
|
|
276
|
+
return result as { data: CheckoutResponse } | { error: any };
|
|
253
277
|
}
|
|
254
278
|
|
|
255
279
|
const body: Record<string, string> = {
|
|
@@ -266,18 +290,19 @@ export const checkoutApi = api.injectEndpoints({
|
|
|
266
290
|
body.save = save ? '1' : '0';
|
|
267
291
|
}
|
|
268
292
|
|
|
269
|
-
|
|
270
|
-
url:
|
|
293
|
+
const result = await baseQuery({
|
|
294
|
+
url: buildCheckoutRequestUrl(checkout.completeCreditCardPayment, {
|
|
271
295
|
useFormData: true
|
|
272
296
|
}),
|
|
273
297
|
method: 'POST',
|
|
274
298
|
body
|
|
275
|
-
};
|
|
299
|
+
});
|
|
300
|
+
return result as { data: CheckoutResponse } | { error: any };
|
|
276
301
|
},
|
|
277
302
|
async onQueryStarted(args, { dispatch, queryFulfilled }) {
|
|
278
303
|
dispatch(setPaymentStepBusy(true));
|
|
279
304
|
const { data } = await queryFulfilled;
|
|
280
|
-
const reduxStore =
|
|
305
|
+
const reduxStore = await getStore();
|
|
281
306
|
const completePaymentContext = data?.context_list?.find(
|
|
282
307
|
(context) => context?.page_name === 'MasterpassCompletePage'
|
|
283
308
|
);
|
|
@@ -302,7 +327,7 @@ export const checkoutApi = api.injectEndpoints({
|
|
|
302
327
|
}
|
|
303
328
|
>({
|
|
304
329
|
query: ({ token }) => ({
|
|
305
|
-
url:
|
|
330
|
+
url: buildCheckoutRequestUrl(checkout.completeMasterpassPayment, {
|
|
306
331
|
useFormData: true
|
|
307
332
|
}),
|
|
308
333
|
method: 'POST',
|
|
@@ -319,7 +344,7 @@ export const checkoutApi = api.injectEndpoints({
|
|
|
319
344
|
}),
|
|
320
345
|
completeFundsTransfer: build.mutation<CheckoutResponse, void>({
|
|
321
346
|
query: () => ({
|
|
322
|
-
url:
|
|
347
|
+
url: buildCheckoutRequestUrl(checkout.completeFundsTransfer, {
|
|
323
348
|
useFormData: true
|
|
324
349
|
}),
|
|
325
350
|
method: 'POST',
|
|
@@ -336,7 +361,7 @@ export const checkoutApi = api.injectEndpoints({
|
|
|
336
361
|
}),
|
|
337
362
|
guestLogin: build.mutation<CheckoutResponse, GuestLoginFormParams>({
|
|
338
363
|
query: ({ user_email, phone_number }) => ({
|
|
339
|
-
url:
|
|
364
|
+
url: buildCheckoutRequestUrl(checkout.guestLogin, {
|
|
340
365
|
useFormData: true
|
|
341
366
|
}),
|
|
342
367
|
method: 'POST',
|
|
@@ -349,7 +374,7 @@ export const checkoutApi = api.injectEndpoints({
|
|
|
349
374
|
}),
|
|
350
375
|
setDeliveryOption: build.mutation<CheckoutResponse, number>({
|
|
351
376
|
query: (pk: number) => ({
|
|
352
|
-
url:
|
|
377
|
+
url: buildCheckoutRequestUrl(checkout.setDeliveryOption, {
|
|
353
378
|
useFormData: true
|
|
354
379
|
}),
|
|
355
380
|
method: 'POST',
|
|
@@ -365,7 +390,7 @@ export const checkoutApi = api.injectEndpoints({
|
|
|
365
390
|
}),
|
|
366
391
|
setAddresses: build.mutation<CheckoutResponse, SetAddressesParams>({
|
|
367
392
|
query: ({ shippingAddressPk, billingAddressPk }) => ({
|
|
368
|
-
url:
|
|
393
|
+
url: buildCheckoutRequestUrl(checkout.setAddresses, {
|
|
369
394
|
useFormData: true
|
|
370
395
|
}),
|
|
371
396
|
method: 'POST',
|
|
@@ -382,7 +407,7 @@ export const checkoutApi = api.injectEndpoints({
|
|
|
382
407
|
}),
|
|
383
408
|
setShippingOption: build.mutation<CheckoutResponse, number>({
|
|
384
409
|
query: (pk: number) => ({
|
|
385
|
-
url:
|
|
410
|
+
url: buildCheckoutRequestUrl(checkout.setShippingOption, {
|
|
386
411
|
useFormData: true
|
|
387
412
|
}),
|
|
388
413
|
method: 'POST',
|
|
@@ -398,7 +423,7 @@ export const checkoutApi = api.injectEndpoints({
|
|
|
398
423
|
}),
|
|
399
424
|
setDataSourceShippingOptions: build.mutation<CheckoutResponse, number[]>({
|
|
400
425
|
query: (pks) => ({
|
|
401
|
-
url:
|
|
426
|
+
url: buildCheckoutRequestUrl(checkout.setDataSourceShippingOption, {
|
|
402
427
|
useFormData: true
|
|
403
428
|
}),
|
|
404
429
|
method: 'POST',
|
|
@@ -414,7 +439,7 @@ export const checkoutApi = api.injectEndpoints({
|
|
|
414
439
|
}),
|
|
415
440
|
setRetailStore: build.mutation<CheckoutResponse, SetRetailStoreParams>({
|
|
416
441
|
query: ({ retailStorePk, billingAddressPk }) => ({
|
|
417
|
-
url:
|
|
442
|
+
url: buildCheckoutRequestUrl(
|
|
418
443
|
'/orders/checkout?page=RetailStoreSelectionPage',
|
|
419
444
|
{
|
|
420
445
|
useFormData: true
|
|
@@ -429,13 +454,13 @@ export const checkoutApi = api.injectEndpoints({
|
|
|
429
454
|
}),
|
|
430
455
|
fetchPaymentOptions: build.query<CheckoutResponse, void>({
|
|
431
456
|
query: () => ({
|
|
432
|
-
url:
|
|
457
|
+
url: buildCheckoutRequestUrl(checkout.setPaymentOption)
|
|
433
458
|
}),
|
|
434
459
|
providesTags: ['PaymentOptions']
|
|
435
460
|
}),
|
|
436
461
|
setPaymentOption: build.mutation<CheckoutResponse, number>({
|
|
437
462
|
query: (pk: number) => ({
|
|
438
|
-
url:
|
|
463
|
+
url: buildCheckoutRequestUrl(checkout.setPaymentOption, {
|
|
439
464
|
useFormData: true
|
|
440
465
|
}),
|
|
441
466
|
method: 'POST',
|
|
@@ -461,7 +486,7 @@ export const checkoutApi = api.injectEndpoints({
|
|
|
461
486
|
}
|
|
462
487
|
>({
|
|
463
488
|
query: ({ payment_option: pk, validationURL }) => ({
|
|
464
|
-
url:
|
|
489
|
+
url: buildCheckoutRequestUrl(checkout.setWalletSelectionPage, {
|
|
465
490
|
useFormData: true
|
|
466
491
|
}),
|
|
467
492
|
method: 'POST',
|
|
@@ -485,7 +510,7 @@ export const checkoutApi = api.injectEndpoints({
|
|
|
485
510
|
}
|
|
486
511
|
>({
|
|
487
512
|
query: (requestBody) => ({
|
|
488
|
-
url:
|
|
513
|
+
url: buildCheckoutRequestUrl(checkout.setWalletPaymentPage, {
|
|
489
514
|
useFormData: true
|
|
490
515
|
}),
|
|
491
516
|
method: 'POST',
|
|
@@ -497,12 +522,22 @@ export const checkoutApi = api.injectEndpoints({
|
|
|
497
522
|
dispatch(setPaymentStepBusy(false));
|
|
498
523
|
}
|
|
499
524
|
}),
|
|
500
|
-
setWalletCompletePage: build.mutation<
|
|
501
|
-
|
|
502
|
-
|
|
525
|
+
setWalletCompletePage: build.mutation<
|
|
526
|
+
CheckoutResponse,
|
|
527
|
+
{
|
|
528
|
+
success: boolean;
|
|
529
|
+
cko_payment_id?: string;
|
|
530
|
+
[key: string]: any;
|
|
531
|
+
}
|
|
532
|
+
>({
|
|
533
|
+
query: ({ success, ...additionalParams }) => ({
|
|
534
|
+
url: buildCheckoutRequestUrl(checkout.setWalletCompletePage, {
|
|
535
|
+
useFormData: true
|
|
536
|
+
}),
|
|
503
537
|
method: 'POST',
|
|
504
538
|
body: {
|
|
505
|
-
success
|
|
539
|
+
success,
|
|
540
|
+
...additionalParams
|
|
506
541
|
}
|
|
507
542
|
}),
|
|
508
543
|
async onQueryStarted(arg, { dispatch, queryFulfilled }) {
|
|
@@ -512,23 +547,25 @@ export const checkoutApi = api.injectEndpoints({
|
|
|
512
547
|
}
|
|
513
548
|
}),
|
|
514
549
|
setBinNumber: build.mutation<CheckoutResponse, string>({
|
|
515
|
-
|
|
550
|
+
async queryFn(binNumber, _queryApi, _extraOptions, baseQuery) {
|
|
551
|
+
const reduxStore = await getStore();
|
|
516
552
|
const paymentOption =
|
|
517
|
-
|
|
553
|
+
reduxStore.getState().checkout?.preOrder?.payment_option;
|
|
518
554
|
const binNumberUrl =
|
|
519
555
|
paymentOption?.payment_type === 'masterpass'
|
|
520
556
|
? checkout.setMasterpassBinNumber
|
|
521
557
|
: checkout.setBinNumber;
|
|
522
558
|
|
|
523
|
-
|
|
524
|
-
url:
|
|
559
|
+
const result = await baseQuery({
|
|
560
|
+
url: buildCheckoutRequestUrl(binNumberUrl, {
|
|
525
561
|
useFormData: true
|
|
526
562
|
}),
|
|
527
563
|
method: 'POST',
|
|
528
564
|
body: {
|
|
529
565
|
bin_number: binNumber
|
|
530
566
|
}
|
|
531
|
-
};
|
|
567
|
+
});
|
|
568
|
+
return result as { data: CheckoutResponse } | { error: any };
|
|
532
569
|
},
|
|
533
570
|
async onQueryStarted(arg, { dispatch, queryFulfilled }) {
|
|
534
571
|
dispatch(setPaymentStepBusy(true));
|
|
@@ -538,22 +575,25 @@ export const checkoutApi = api.injectEndpoints({
|
|
|
538
575
|
}
|
|
539
576
|
}),
|
|
540
577
|
setInstallmentOption: build.mutation<CheckoutResponse, number>({
|
|
541
|
-
|
|
578
|
+
async queryFn(pk, _queryApi, _extraOptions, baseQuery) {
|
|
579
|
+
const reduxStore = await getStore();
|
|
542
580
|
const paymentOption =
|
|
543
|
-
|
|
581
|
+
reduxStore.getState().checkout?.preOrder?.payment_option;
|
|
544
582
|
const installmentOption =
|
|
545
583
|
paymentOption?.payment_type === 'masterpass'
|
|
546
584
|
? checkout.setMasterPassInstallmentOption
|
|
547
585
|
: checkout.setInstallmentOption;
|
|
548
|
-
|
|
549
|
-
|
|
586
|
+
|
|
587
|
+
const result = await baseQuery({
|
|
588
|
+
url: buildCheckoutRequestUrl(installmentOption, {
|
|
550
589
|
useFormData: true
|
|
551
590
|
}),
|
|
552
591
|
method: 'POST',
|
|
553
592
|
body: {
|
|
554
593
|
installment: String(pk)
|
|
555
594
|
}
|
|
556
|
-
};
|
|
595
|
+
});
|
|
596
|
+
return result as { data: CheckoutResponse } | { error: any };
|
|
557
597
|
},
|
|
558
598
|
async onQueryStarted(arg, { dispatch, queryFulfilled }) {
|
|
559
599
|
dispatch(setPaymentStepBusy(true));
|
|
@@ -563,7 +603,7 @@ export const checkoutApi = api.injectEndpoints({
|
|
|
563
603
|
}),
|
|
564
604
|
setFundsTransferOption: build.mutation<CheckoutResponse, number>({
|
|
565
605
|
query: (pk: number) => ({
|
|
566
|
-
url:
|
|
606
|
+
url: buildCheckoutRequestUrl(checkout.setFundsTransferOption, {
|
|
567
607
|
useFormData: true
|
|
568
608
|
}),
|
|
569
609
|
method: 'POST',
|
|
@@ -580,7 +620,7 @@ export const checkoutApi = api.injectEndpoints({
|
|
|
580
620
|
}),
|
|
581
621
|
setCreditPaymentOption: build.mutation<CheckoutResponse, number>({
|
|
582
622
|
query: (pk: number) => ({
|
|
583
|
-
url:
|
|
623
|
+
url: buildCheckoutRequestUrl(checkout.setCreditPaymentOption, {
|
|
584
624
|
useFormData: true
|
|
585
625
|
}),
|
|
586
626
|
method: 'POST',
|
|
@@ -597,7 +637,7 @@ export const checkoutApi = api.injectEndpoints({
|
|
|
597
637
|
}),
|
|
598
638
|
confirmationCreditPayment: build.mutation<CheckoutResponse, void>({
|
|
599
639
|
query: () => ({
|
|
600
|
-
url:
|
|
640
|
+
url: buildCheckoutRequestUrl(checkout.confirmationCreditPayment, {
|
|
601
641
|
useFormData: true
|
|
602
642
|
}),
|
|
603
643
|
method: 'POST',
|
|
@@ -613,7 +653,7 @@ export const checkoutApi = api.injectEndpoints({
|
|
|
613
653
|
}),
|
|
614
654
|
completeRedirectionPayment: build.mutation<CheckoutResponse, void>({
|
|
615
655
|
query: () => ({
|
|
616
|
-
url:
|
|
656
|
+
url: buildCheckoutRequestUrl(checkout.completeRedirectionPayment, {
|
|
617
657
|
useFormData: true
|
|
618
658
|
}),
|
|
619
659
|
method: 'POST',
|
|
@@ -629,7 +669,7 @@ export const checkoutApi = api.injectEndpoints({
|
|
|
629
669
|
}),
|
|
630
670
|
applePaymentSelect: build.mutation<CheckoutResponse, ApplePaySelectParams>({
|
|
631
671
|
query: ({ agreement, validationURL }) => ({
|
|
632
|
-
url:
|
|
672
|
+
url: buildCheckoutRequestUrl(checkout.confirmationPaymentSelect, {
|
|
633
673
|
useFormData: true
|
|
634
674
|
}),
|
|
635
675
|
method: 'POST',
|
|
@@ -646,7 +686,7 @@ export const checkoutApi = api.injectEndpoints({
|
|
|
646
686
|
}),
|
|
647
687
|
appleQuery: build.mutation<CheckoutResponse, ApplePayQueryParams>({
|
|
648
688
|
query: ({ agreement, paymentToken }) => ({
|
|
649
|
-
url:
|
|
689
|
+
url: buildCheckoutRequestUrl(checkout.confirmationQuery, {
|
|
650
690
|
useFormData: true
|
|
651
691
|
}),
|
|
652
692
|
method: 'POST',
|
|
@@ -663,7 +703,7 @@ export const checkoutApi = api.injectEndpoints({
|
|
|
663
703
|
}),
|
|
664
704
|
completeConfirmation: build.mutation<CheckoutResponse, void>({
|
|
665
705
|
query: () => ({
|
|
666
|
-
url:
|
|
706
|
+
url: buildCheckoutRequestUrl(checkout.confirmationComplete, {
|
|
667
707
|
useFormData: true
|
|
668
708
|
}),
|
|
669
709
|
method: 'POST',
|
|
@@ -682,7 +722,7 @@ export const checkoutApi = api.injectEndpoints({
|
|
|
682
722
|
PayOnDeliveryParams
|
|
683
723
|
>({
|
|
684
724
|
query: ({ paymentType }) => ({
|
|
685
|
-
url:
|
|
725
|
+
url: buildCheckoutRequestUrl(
|
|
686
726
|
`${checkout.fetchCheckout}?page=PayOnDeliveryPage`,
|
|
687
727
|
{ useFormData: true }
|
|
688
728
|
),
|
|
@@ -700,7 +740,7 @@ export const checkoutApi = api.injectEndpoints({
|
|
|
700
740
|
}),
|
|
701
741
|
setPayOnDeliveryChoice: build.mutation<CheckoutResponse, string>({
|
|
702
742
|
query: (body) => ({
|
|
703
|
-
url:
|
|
743
|
+
url: buildCheckoutRequestUrl(
|
|
704
744
|
`${checkout.fetchCheckout}?page=PayOnDeliveryPaymentChoicePage`,
|
|
705
745
|
{ useFormData: true }
|
|
706
746
|
),
|
|
@@ -717,7 +757,7 @@ export const checkoutApi = api.injectEndpoints({
|
|
|
717
757
|
}),
|
|
718
758
|
completeLoyaltyPayment: build.mutation<CheckoutResponse, void>({
|
|
719
759
|
query: () => ({
|
|
720
|
-
url:
|
|
760
|
+
url: buildCheckoutRequestUrl(checkout.completeLoyaltyPayment, {
|
|
721
761
|
useFormData: true
|
|
722
762
|
}),
|
|
723
763
|
method: 'POST',
|
|
@@ -733,12 +773,12 @@ export const checkoutApi = api.injectEndpoints({
|
|
|
733
773
|
}),
|
|
734
774
|
getCheckoutLoyaltyBalance: build.query<CheckoutResponse, void>({
|
|
735
775
|
query: () => ({
|
|
736
|
-
url:
|
|
776
|
+
url: buildCheckoutRequestUrl(checkout.loyaltyMoneyUsage)
|
|
737
777
|
})
|
|
738
778
|
}),
|
|
739
779
|
payWithLoyaltyBalance: build.mutation<any, string>({
|
|
740
780
|
query: (amount) => ({
|
|
741
|
-
url:
|
|
781
|
+
url: buildCheckoutRequestUrl(checkout.loyaltyMoneyUsage, {
|
|
742
782
|
useFormData: true
|
|
743
783
|
}),
|
|
744
784
|
method: 'POST',
|
|
@@ -769,7 +809,7 @@ export const checkoutApi = api.injectEndpoints({
|
|
|
769
809
|
}),
|
|
770
810
|
setOrderNote: build.mutation<CheckoutResponse, string>({
|
|
771
811
|
query: (notes) => ({
|
|
772
|
-
url:
|
|
812
|
+
url: buildCheckoutRequestUrl(checkout.setOrderNote, {
|
|
773
813
|
useFormData: true
|
|
774
814
|
}),
|
|
775
815
|
method: 'POST',
|
|
@@ -789,7 +829,7 @@ export const checkoutApi = api.injectEndpoints({
|
|
|
789
829
|
};
|
|
790
830
|
|
|
791
831
|
return {
|
|
792
|
-
url:
|
|
832
|
+
url: buildCheckoutRequestUrl(checkout.deliveryBagsPage, {
|
|
793
833
|
useFormData: true
|
|
794
834
|
}),
|
|
795
835
|
method: 'POST',
|
|
@@ -802,7 +842,7 @@ export const checkoutApi = api.injectEndpoints({
|
|
|
802
842
|
Record<string, number>
|
|
803
843
|
>({
|
|
804
844
|
query: (options) => ({
|
|
805
|
-
url:
|
|
845
|
+
url: buildCheckoutRequestUrl(checkout.setAttributeBasedShippingOption, {
|
|
806
846
|
useFormData: true
|
|
807
847
|
}),
|
|
808
848
|
method: 'POST',
|
|
@@ -821,7 +861,7 @@ export const checkoutApi = api.injectEndpoints({
|
|
|
821
861
|
{ extra_field: ExtraField }
|
|
822
862
|
>({
|
|
823
863
|
query: ({ extra_field }) => ({
|
|
824
|
-
url:
|
|
864
|
+
url: buildCheckoutRequestUrl(checkout.setOrderSelectionPage, {
|
|
825
865
|
useFormData: true
|
|
826
866
|
}),
|
|
827
867
|
method: 'POST',
|
|
@@ -832,16 +872,16 @@ export const checkoutApi = api.injectEndpoints({
|
|
|
832
872
|
}),
|
|
833
873
|
fetchLoyaltyData: build.query<CheckoutResponse, void>({
|
|
834
874
|
query: () => ({
|
|
835
|
-
url:
|
|
875
|
+
url: buildCheckoutRequestUrl(checkout.loyaltyCardPage, {
|
|
836
876
|
accept: 'application/json',
|
|
837
877
|
contentType: 'application/json'
|
|
838
878
|
}),
|
|
839
879
|
method: 'GET'
|
|
840
880
|
})
|
|
841
881
|
}),
|
|
842
|
-
setLoyaltyData: build.mutation<CheckoutResponse, number>({
|
|
882
|
+
setLoyaltyData: build.mutation<CheckoutResponse, number | string>({
|
|
843
883
|
query: (amount) => ({
|
|
844
|
-
url:
|
|
884
|
+
url: buildCheckoutRequestUrl(checkout.loyaltyCardPage, {
|
|
845
885
|
useFormData: true
|
|
846
886
|
}),
|
|
847
887
|
method: 'POST',
|
|
@@ -852,7 +892,7 @@ export const checkoutApi = api.injectEndpoints({
|
|
|
852
892
|
}),
|
|
853
893
|
sendSms: build.mutation<CheckoutResponse, SendSmsType>({
|
|
854
894
|
query: (body) => ({
|
|
855
|
-
url:
|
|
895
|
+
url: buildCheckoutRequestUrl(checkout.sendSmsPage, {
|
|
856
896
|
useFormData: true
|
|
857
897
|
}),
|
|
858
898
|
method: 'POST',
|
|
@@ -861,12 +901,27 @@ export const checkoutApi = api.injectEndpoints({
|
|
|
861
901
|
}),
|
|
862
902
|
verifySms: build.mutation<CheckoutResponse, VerifySmsType>({
|
|
863
903
|
query: (body) => ({
|
|
864
|
-
url:
|
|
904
|
+
url: buildCheckoutRequestUrl(checkout.verifySmsPage, {
|
|
865
905
|
useFormData: true
|
|
866
906
|
}),
|
|
867
907
|
method: 'POST',
|
|
868
908
|
body
|
|
869
909
|
})
|
|
910
|
+
}),
|
|
911
|
+
saveSampleProducts: build.mutation<CheckoutResponse, number[] | undefined>({
|
|
912
|
+
query: (products = []) => {
|
|
913
|
+
const formData = new FormData();
|
|
914
|
+
|
|
915
|
+
products.forEach((product) => {
|
|
916
|
+
formData.append('sample_products', String(product));
|
|
917
|
+
});
|
|
918
|
+
|
|
919
|
+
return {
|
|
920
|
+
url: buildCheckoutRequestUrl(checkout.saveSampleProducts),
|
|
921
|
+
method: 'POST',
|
|
922
|
+
body: formData
|
|
923
|
+
};
|
|
924
|
+
}
|
|
870
925
|
})
|
|
871
926
|
}),
|
|
872
927
|
overrideExisting: false
|
|
@@ -914,5 +969,6 @@ export const {
|
|
|
914
969
|
useSetWalletCompletePageMutation,
|
|
915
970
|
useSendSmsMutation,
|
|
916
971
|
useVerifySmsMutation,
|
|
917
|
-
useResetCheckoutStateQuery
|
|
972
|
+
useResetCheckoutStateQuery,
|
|
973
|
+
useSaveSampleProductsMutation
|
|
918
974
|
} = checkoutApi;
|
package/data/server/category.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GetCategoryResponse } from '../../types';
|
|
1
|
+
import { GetCategoryResponse, SearchParams } from '../../types';
|
|
2
2
|
import { generateCommerceSearchParams } from '../../utils';
|
|
3
3
|
import appFetch, { FetchResponseType } from '../../utils/app-fetch';
|
|
4
4
|
import { category, product } from '../urls';
|
|
@@ -12,7 +12,7 @@ function getCategoryDataHandler(
|
|
|
12
12
|
pk: number,
|
|
13
13
|
locale: string,
|
|
14
14
|
currency: string,
|
|
15
|
-
searchParams?:
|
|
15
|
+
searchParams?: SearchParams,
|
|
16
16
|
headers?: Record<string, string>
|
|
17
17
|
) {
|
|
18
18
|
return async function () {
|
|
@@ -48,8 +48,8 @@ function getCategoryDataHandler(
|
|
|
48
48
|
logger.fatal('Error while parsing category data', {
|
|
49
49
|
handler: 'getCategoryDataHandler',
|
|
50
50
|
error,
|
|
51
|
-
rawData: rawData
|
|
52
|
-
? `${rawData
|
|
51
|
+
rawData: rawData?.startsWith?.('<!DOCTYPE html>')
|
|
52
|
+
? `${rawData?.substring(0, 50)}...`
|
|
53
53
|
: rawData
|
|
54
54
|
});
|
|
55
55
|
}
|
|
@@ -90,7 +90,7 @@ export const getCategoryData = ({
|
|
|
90
90
|
pk: number;
|
|
91
91
|
locale?: string;
|
|
92
92
|
currency?: string;
|
|
93
|
-
searchParams?:
|
|
93
|
+
searchParams?: SearchParams;
|
|
94
94
|
headers?: Record<string, string>;
|
|
95
95
|
}) => {
|
|
96
96
|
return Cache.wrap(
|
|
@@ -98,7 +98,8 @@ export const getCategoryData = ({
|
|
|
98
98
|
locale,
|
|
99
99
|
getCategoryDataHandler(pk, locale, currency, searchParams, headers),
|
|
100
100
|
{
|
|
101
|
-
expire: 300
|
|
101
|
+
expire: 300,
|
|
102
|
+
compressed: true
|
|
102
103
|
}
|
|
103
104
|
);
|
|
104
105
|
};
|
|
@@ -138,8 +139,8 @@ function getCategoryBySlugDataHandler(
|
|
|
138
139
|
logger.fatal('Error while parsing category data', {
|
|
139
140
|
handler: 'getCategoryBySlugDataHandler',
|
|
140
141
|
error,
|
|
141
|
-
rawData: rawData
|
|
142
|
-
? `${rawData
|
|
142
|
+
rawData: rawData?.startsWith?.('<!DOCTYPE html>')
|
|
143
|
+
? `${rawData?.substring(0, 50)}...`
|
|
143
144
|
: rawData
|
|
144
145
|
});
|
|
145
146
|
}
|
|
@@ -158,7 +159,8 @@ export const getCategoryBySlugData = async ({
|
|
|
158
159
|
locale,
|
|
159
160
|
getCategoryBySlugDataHandler(slug, locale, currency),
|
|
160
161
|
{
|
|
161
|
-
expire: 300
|
|
162
|
+
expire: 300,
|
|
163
|
+
compressed: true
|
|
162
164
|
}
|
|
163
165
|
);
|
|
164
166
|
};
|
package/data/server/flatpage.ts
CHANGED
package/data/server/form.ts
CHANGED
package/data/server/list.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Cache, CacheKey } from '../../lib/cache';
|
|
2
2
|
import { category } from '../urls';
|
|
3
|
-
import { GetCategoryResponse } from '../../types';
|
|
3
|
+
import { GetCategoryResponse, SearchParams } from '../../types';
|
|
4
4
|
import { generateCommerceSearchParams } from '../../utils';
|
|
5
5
|
import appFetch, { FetchResponseType } from '../../utils/app-fetch';
|
|
6
6
|
import { parse } from 'lossless-json';
|
|
@@ -10,7 +10,7 @@ import { ServerVariables } from '../../utils/server-variables';
|
|
|
10
10
|
const getListDataHandler = (
|
|
11
11
|
locale,
|
|
12
12
|
currency,
|
|
13
|
-
searchParams:
|
|
13
|
+
searchParams: SearchParams,
|
|
14
14
|
headers?: Record<string, string>
|
|
15
15
|
) => {
|
|
16
16
|
return async function () {
|
|
@@ -63,7 +63,7 @@ export const getListData = async ({
|
|
|
63
63
|
}: {
|
|
64
64
|
locale?: string;
|
|
65
65
|
currency?: string;
|
|
66
|
-
searchParams:
|
|
66
|
+
searchParams: SearchParams;
|
|
67
67
|
headers?: Record<string, string>;
|
|
68
68
|
}) => {
|
|
69
69
|
return Cache.wrap(
|
|
@@ -71,7 +71,8 @@ export const getListData = async ({
|
|
|
71
71
|
locale,
|
|
72
72
|
getListDataHandler(locale, currency, searchParams, headers),
|
|
73
73
|
{
|
|
74
|
-
expire: 300
|
|
74
|
+
expire: 300,
|
|
75
|
+
compressed: true
|
|
75
76
|
}
|
|
76
77
|
);
|
|
77
78
|
};
|