@akinon/next 1.45.0-rc.5 → 1.46.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 +5 -316
- package/api/client.ts +9 -39
- package/assets/styles/index.scss +26 -50
- package/components/index.ts +0 -1
- package/components/input.tsx +7 -21
- package/components/link.tsx +13 -17
- package/components/pagination.tsx +2 -1
- package/components/price.tsx +4 -11
- package/components/selected-payment-option-view.tsx +38 -26
- package/data/client/account.ts +9 -10
- package/data/client/address.ts +8 -32
- package/data/client/api.ts +2 -2
- package/data/client/b2b.ts +2 -35
- package/data/client/basket.ts +5 -6
- package/data/client/checkout.ts +4 -47
- package/data/client/wishlist.ts +2 -70
- package/data/server/category.ts +2 -2
- package/data/server/list.ts +2 -2
- package/data/server/product.ts +13 -15
- package/data/server/special-page.ts +2 -2
- package/data/urls.ts +3 -17
- package/hooks/index.ts +1 -2
- package/hooks/use-payment-options.ts +1 -2
- package/lib/cache.ts +6 -18
- package/middlewares/default.ts +2 -50
- package/middlewares/locale.ts +30 -32
- package/middlewares/pretty-url.ts +0 -4
- package/middlewares/url-redirection.ts +0 -4
- package/package.json +4 -5
- package/plugins.d.ts +0 -1
- package/redux/middlewares/checkout.ts +11 -70
- package/redux/reducers/checkout.ts +5 -24
- package/redux/reducers/config.ts +0 -2
- package/types/commerce/account.ts +0 -1
- package/types/commerce/address.ts +1 -1
- package/types/commerce/b2b.ts +2 -12
- package/types/commerce/checkout.ts +0 -30
- package/types/commerce/misc.ts +0 -2
- package/types/commerce/order.ts +0 -12
- package/types/index.ts +2 -30
- package/utils/app-fetch.ts +1 -1
- package/utils/generate-commerce-search-params.ts +2 -6
- package/utils/index.ts +6 -27
- package/utils/menu-generator.ts +2 -2
- package/utils/server-translation.ts +1 -5
- package/with-pz-config.js +1 -11
- package/assets/styles/index.css +0 -49
- package/assets/styles/index.css.map +0 -1
- package/components/file-input.tsx +0 -8
- package/hooks/use-message-listener.ts +0 -24
- package/lib/cache-handler.mjs +0 -33
- package/routes/pretty-url.tsx +0 -194
- package/utils/redirection-iframe.ts +0 -85
|
@@ -6,21 +6,6 @@ import dynamic from 'next/dynamic';
|
|
|
6
6
|
import { PaymentOptionViews } from 'views/checkout/steps/payment';
|
|
7
7
|
import { useMemo } from 'react';
|
|
8
8
|
|
|
9
|
-
const fallbackView = () => <div />;
|
|
10
|
-
|
|
11
|
-
const paymentTypeToView = {
|
|
12
|
-
bkm_express: 'bkm',
|
|
13
|
-
credit_card: 'credit-card',
|
|
14
|
-
credit_payment: 'credit-payment',
|
|
15
|
-
funds_transfer: 'funds-transfer',
|
|
16
|
-
gpay: 'gpay',
|
|
17
|
-
loyalty_money: 'loyalty',
|
|
18
|
-
masterpass: 'credit-card',
|
|
19
|
-
pay_on_delivery: 'pay-on-delivery',
|
|
20
|
-
redirection: 'redirection'
|
|
21
|
-
// Add other mappings as needed
|
|
22
|
-
};
|
|
23
|
-
|
|
24
9
|
export default function SelectedPaymentOptionView() {
|
|
25
10
|
const { payment_option } = useAppSelector(
|
|
26
11
|
(state: RootState) => state.checkout.preOrder
|
|
@@ -29,7 +14,7 @@ export default function SelectedPaymentOptionView() {
|
|
|
29
14
|
const Component = useMemo(
|
|
30
15
|
() =>
|
|
31
16
|
dynamic(
|
|
32
|
-
|
|
17
|
+
() => {
|
|
33
18
|
const customOption = PaymentOptionViews.find(
|
|
34
19
|
(opt) => opt.slug === payment_option.slug
|
|
35
20
|
);
|
|
@@ -44,19 +29,46 @@ export default function SelectedPaymentOptionView() {
|
|
|
44
29
|
});
|
|
45
30
|
}
|
|
46
31
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
32
|
+
let promise: any;
|
|
33
|
+
|
|
34
|
+
try {
|
|
35
|
+
if (payment_option.payment_type === 'credit_card') {
|
|
36
|
+
promise = import(
|
|
37
|
+
`views/checkout/steps/payment/options/credit-card`
|
|
38
|
+
);
|
|
39
|
+
} else if (payment_option.payment_type === 'funds_transfer') {
|
|
40
|
+
promise = import(
|
|
41
|
+
`views/checkout/steps/payment/options/funds-transfer`
|
|
42
|
+
);
|
|
43
|
+
} else if (payment_option.payment_type === 'redirection') {
|
|
44
|
+
promise = import(
|
|
45
|
+
`views/checkout/steps/payment/options/redirection`
|
|
46
|
+
);
|
|
47
|
+
} else if (payment_option.payment_type === 'pay_on_delivery') {
|
|
48
|
+
promise = import(
|
|
49
|
+
`views/checkout/steps/payment/options/pay-on-delivery`
|
|
50
|
+
);
|
|
51
|
+
} else if (payment_option.payment_type === 'loyalty_money') {
|
|
52
|
+
promise = import(`views/checkout/steps/payment/options/loyalty`);
|
|
53
|
+
} else if (payment_option.payment_type === 'masterpass') {
|
|
54
|
+
promise = import(
|
|
55
|
+
`views/checkout/steps/payment/options/credit-card`
|
|
52
56
|
);
|
|
53
|
-
return mod.default || fallbackView;
|
|
54
|
-
} catch (error) {
|
|
55
|
-
return fallbackView;
|
|
56
57
|
}
|
|
57
|
-
|
|
58
|
+
// else if (payment_option.payment_type === 'credit_payment') {
|
|
59
|
+
// promise = import(`views/checkout/steps/payment/options/credit-payment`);
|
|
60
|
+
// }
|
|
61
|
+
// else if (payment_option.payment_type === 'gpay') {
|
|
62
|
+
// promise = import(`views/checkout/steps/payment/options/gpay`);
|
|
63
|
+
// }
|
|
64
|
+
// else if (payment_option.payment_type === 'bkm_express') {
|
|
65
|
+
// promise = import(`views/checkout/steps/payment/options/bkm`);
|
|
66
|
+
// }
|
|
67
|
+
} catch (error) {}
|
|
58
68
|
|
|
59
|
-
return
|
|
69
|
+
return promise
|
|
70
|
+
? promise.then((mod) => mod.default).catch(() => () => null)
|
|
71
|
+
: new Promise<any>((resolve) => resolve(() => null));
|
|
60
72
|
},
|
|
61
73
|
{ ssr: false }
|
|
62
74
|
),
|
package/data/client/account.ts
CHANGED
|
@@ -123,16 +123,15 @@ const accountApi = api.injectEndpoints({
|
|
|
123
123
|
query: ({ page, status, limit }) =>
|
|
124
124
|
buildClientRequestUrl(account.getQuotations(page, status, limit))
|
|
125
125
|
}),
|
|
126
|
-
sendContact: builder.mutation<void,
|
|
127
|
-
query: (body) => {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
}
|
|
126
|
+
sendContact: builder.mutation<void, ContactFormType>({
|
|
127
|
+
query: (body) => ({
|
|
128
|
+
url: buildClientRequestUrl(account.sendContact, {
|
|
129
|
+
contentType: 'application/json',
|
|
130
|
+
responseType: 'text'
|
|
131
|
+
}),
|
|
132
|
+
method: 'POST',
|
|
133
|
+
body
|
|
134
|
+
})
|
|
136
135
|
}),
|
|
137
136
|
cancelOrder: builder.mutation<void, AccountOrderCancellation>({
|
|
138
137
|
query: ({ id, ...body }) => ({
|
package/data/client/address.ts
CHANGED
|
@@ -39,10 +39,7 @@ const addressApi = api.injectEndpoints({
|
|
|
39
39
|
query: (city) =>
|
|
40
40
|
buildClientRequestUrl(address.getRetailStoreTownships(city))
|
|
41
41
|
}),
|
|
42
|
-
addAddress: builder.mutation<
|
|
43
|
-
Address,
|
|
44
|
-
Partial<Address> & { invalidateTag?: 'Addresses' | 'Checkout' }
|
|
45
|
-
>({
|
|
42
|
+
addAddress: builder.mutation<Address, Partial<Address>>({
|
|
46
43
|
query: (body) => ({
|
|
47
44
|
url: buildClientRequestUrl(address.base, {
|
|
48
45
|
contentType: 'application/json'
|
|
@@ -53,16 +50,9 @@ const addressApi = api.injectEndpoints({
|
|
|
53
50
|
type: body.is_corporate === 'true' ? 'corporate' : 'personal'
|
|
54
51
|
}
|
|
55
52
|
}),
|
|
56
|
-
invalidatesTags: (_, error
|
|
57
|
-
if (error) return [];
|
|
58
|
-
if (arg.invalidateTag) return [arg.invalidateTag];
|
|
59
|
-
return ['Addresses', 'Checkout'];
|
|
60
|
-
}
|
|
53
|
+
invalidatesTags: (_, error) => (error ? [] : ['Addresses', 'Checkout'])
|
|
61
54
|
}),
|
|
62
|
-
editAddress: builder.mutation<
|
|
63
|
-
Address,
|
|
64
|
-
Partial<Address> & { invalidateTag?: 'Addresses' | 'Checkout' }
|
|
65
|
-
>({
|
|
55
|
+
editAddress: builder.mutation<Address, Partial<Address>>({
|
|
66
56
|
query: ({ pk, ...body }) => ({
|
|
67
57
|
url: buildClientRequestUrl(address.editAddress(pk), {
|
|
68
58
|
contentType: 'application/json'
|
|
@@ -74,28 +64,14 @@ const addressApi = api.injectEndpoints({
|
|
|
74
64
|
type: body.is_corporate === 'true' ? 'corporate' : 'personal'
|
|
75
65
|
}
|
|
76
66
|
}),
|
|
77
|
-
invalidatesTags: (_, error,
|
|
78
|
-
if (error) return [];
|
|
79
|
-
if (arg.invalidateTag) return [arg.invalidateTag];
|
|
80
|
-
return ['Addresses', 'Checkout'];
|
|
81
|
-
}
|
|
67
|
+
invalidatesTags: (_, error) => (error ? [] : ['Addresses', 'Checkout']) // TODO: Invalidate one of these tags when necessary (e.g. Address page invalidates Addresses tag, Checkout page invalidates Checkout tag)
|
|
82
68
|
}),
|
|
83
|
-
removeAddress: builder.mutation<
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
>({
|
|
87
|
-
query: (arg) => ({
|
|
88
|
-
url: buildClientRequestUrl(
|
|
89
|
-
address.removeAddress(typeof arg === 'number' ? arg : arg.id)
|
|
90
|
-
),
|
|
69
|
+
removeAddress: builder.mutation<void, number>({
|
|
70
|
+
query: (id) => ({
|
|
71
|
+
url: buildClientRequestUrl(address.removeAddress(id)),
|
|
91
72
|
method: 'DELETE'
|
|
92
73
|
}),
|
|
93
|
-
invalidatesTags: (_, error,
|
|
94
|
-
if (error) return [];
|
|
95
|
-
if (typeof arg === 'object' && arg.invalidateTag)
|
|
96
|
-
return [arg.invalidateTag];
|
|
97
|
-
return ['Addresses', 'Checkout'];
|
|
98
|
-
}
|
|
74
|
+
invalidatesTags: (_, error) => (error ? [] : ['Addresses', 'Checkout']) // TODO: Invalidate one of these tags when necessary (e.g. Address page invalidates Addresses tag, Checkout page invalidates Checkout tag)
|
|
99
75
|
}),
|
|
100
76
|
setDefaultAddress: builder.mutation<Address, Partial<Address>>({
|
|
101
77
|
query: ({ pk, primary }) => ({
|
package/data/client/api.ts
CHANGED
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
} from '@reduxjs/toolkit/query/react';
|
|
10
10
|
import settings from 'settings';
|
|
11
11
|
import { getCookie } from '../../utils';
|
|
12
|
-
import { RootState } from 'redux/store';
|
|
12
|
+
import { RootState } from '@theme/redux/store';
|
|
13
13
|
|
|
14
14
|
interface CustomBaseQueryApi extends BaseQueryApi {
|
|
15
15
|
getState: () => RootState;
|
|
@@ -67,7 +67,7 @@ export const api = createApi({
|
|
|
67
67
|
baseQuery: customBaseQuery,
|
|
68
68
|
tagTypes: [
|
|
69
69
|
'Basket',
|
|
70
|
-
'
|
|
70
|
+
'AllBaskets',
|
|
71
71
|
'BasketB2b',
|
|
72
72
|
'DraftsB2b',
|
|
73
73
|
'Product',
|
package/data/client/b2b.ts
CHANGED
|
@@ -12,9 +12,7 @@ import {
|
|
|
12
12
|
SaveBasketParams,
|
|
13
13
|
UpdateProductParams,
|
|
14
14
|
DeleteProductParams,
|
|
15
|
-
CreateQuotationParams
|
|
16
|
-
BasketStatusResponse,
|
|
17
|
-
ExportBasketResponse
|
|
15
|
+
CreateQuotationParams
|
|
18
16
|
} from '../../types';
|
|
19
17
|
|
|
20
18
|
const b2bApi = api.injectEndpoints({
|
|
@@ -91,34 +89,6 @@ const b2bApi = api.injectEndpoints({
|
|
|
91
89
|
}),
|
|
92
90
|
invalidatesTags: ['BasketB2b', 'DraftsB2b']
|
|
93
91
|
}),
|
|
94
|
-
exportBasket: build.mutation<ExportBasketResponse, string>({
|
|
95
|
-
query: (queryString) => {
|
|
96
|
-
return {
|
|
97
|
-
url: buildClientRequestUrl(b2b.basketExport(queryString)),
|
|
98
|
-
method: 'GET'
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
}),
|
|
102
|
-
getBasketStatus: build.mutation<BasketStatusResponse, string>({
|
|
103
|
-
query: (cacheKey) => {
|
|
104
|
-
return {
|
|
105
|
-
url: buildClientRequestUrl(b2b.statusBasket(cacheKey)),
|
|
106
|
-
method: 'GET'
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
}),
|
|
110
|
-
uploadFile: build.mutation<void, FormData>({
|
|
111
|
-
query: (body) => {
|
|
112
|
-
return {
|
|
113
|
-
url: buildClientRequestUrl(b2b.basketImport, {
|
|
114
|
-
useFormData: true
|
|
115
|
-
}),
|
|
116
|
-
method: 'POST',
|
|
117
|
-
body
|
|
118
|
-
};
|
|
119
|
-
},
|
|
120
|
-
invalidatesTags: ['BasketB2b']
|
|
121
|
-
})
|
|
122
92
|
}),
|
|
123
93
|
overrideExisting: true
|
|
124
94
|
});
|
|
@@ -132,8 +102,5 @@ export const {
|
|
|
132
102
|
useLoadBasketMutation,
|
|
133
103
|
useUpdateProductMutation,
|
|
134
104
|
useDeleteProductMutation,
|
|
135
|
-
useCreateQuotationMutation
|
|
136
|
-
useGetBasketStatusMutation,
|
|
137
|
-
useExportBasketMutation,
|
|
138
|
-
useUploadFileMutation
|
|
105
|
+
useCreateQuotationMutation
|
|
139
106
|
} = b2bApi;
|
package/data/client/basket.ts
CHANGED
|
@@ -28,7 +28,7 @@ export const basketApi = api.injectEndpoints({
|
|
|
28
28
|
query: ({ namespace }) =>
|
|
29
29
|
buildClientRequestUrl(basket.getBasketDetail(namespace)),
|
|
30
30
|
transformResponse: (response: { basket: Basket }) => response.basket,
|
|
31
|
-
providesTags: ['
|
|
31
|
+
providesTags: ['AllBaskets']
|
|
32
32
|
}),
|
|
33
33
|
getAllBaskets: build.query<Basket[], void>({
|
|
34
34
|
query: () =>
|
|
@@ -36,7 +36,7 @@ export const basketApi = api.injectEndpoints({
|
|
|
36
36
|
contentType: 'application/json'
|
|
37
37
|
}),
|
|
38
38
|
transformResponse: (response: { baskets: Basket[] }) => response.baskets,
|
|
39
|
-
providesTags: ['
|
|
39
|
+
providesTags: ['AllBaskets']
|
|
40
40
|
}),
|
|
41
41
|
removeBasket: build.mutation<Basket, { pk: number }>({
|
|
42
42
|
query: ({ pk }) => ({
|
|
@@ -46,7 +46,7 @@ export const basketApi = api.injectEndpoints({
|
|
|
46
46
|
method: 'DELETE',
|
|
47
47
|
body: { pk }
|
|
48
48
|
}),
|
|
49
|
-
invalidatesTags: ['
|
|
49
|
+
invalidatesTags: ['AllBaskets', 'Basket']
|
|
50
50
|
}),
|
|
51
51
|
selectMainBasket: build.mutation<Basket, { pk: number }>({
|
|
52
52
|
query: ({ pk }) => ({
|
|
@@ -57,7 +57,7 @@ export const basketApi = api.injectEndpoints({
|
|
|
57
57
|
body: { pk }
|
|
58
58
|
}),
|
|
59
59
|
transformResponse: (response: { baskets: Basket }) => response.baskets,
|
|
60
|
-
invalidatesTags: ['
|
|
60
|
+
invalidatesTags: ['AllBaskets', 'Basket']
|
|
61
61
|
}),
|
|
62
62
|
updateQuantity: build.mutation<
|
|
63
63
|
UpdateQuantityResponse,
|
|
@@ -69,8 +69,7 @@ export const basketApi = api.injectEndpoints({
|
|
|
69
69
|
}),
|
|
70
70
|
method: 'PUT',
|
|
71
71
|
body
|
|
72
|
-
})
|
|
73
|
-
invalidatesTags: ['MultiBasket', 'Basket']
|
|
72
|
+
})
|
|
74
73
|
}),
|
|
75
74
|
clearBasket: build.mutation<Basket, void>({
|
|
76
75
|
query: (body) => ({
|
package/data/client/checkout.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
setBankAccounts,
|
|
3
|
-
setCardType,
|
|
4
3
|
setInstallmentOptions,
|
|
5
4
|
setPaymentStepBusy,
|
|
6
5
|
setSelectedBankAccountPk,
|
|
7
6
|
setSelectedCreditPaymentPk,
|
|
8
|
-
setShippingStepBusy
|
|
7
|
+
setShippingStepBusy,
|
|
8
|
+
setCardType
|
|
9
9
|
} from '../../redux/reducers/checkout';
|
|
10
10
|
import {
|
|
11
11
|
CheckoutContext,
|
|
@@ -20,7 +20,6 @@ import { AppDispatch, AppStore, store } from 'redux/store';
|
|
|
20
20
|
import settings from 'settings';
|
|
21
21
|
import { showMobile3dIframe } from '../../utils/mobile-3d-iframe';
|
|
22
22
|
import {
|
|
23
|
-
setCvcRequired,
|
|
24
23
|
setError,
|
|
25
24
|
setOtpModalVisible
|
|
26
25
|
} from '@akinon/pz-masterpass/src/redux/reducer';
|
|
@@ -114,8 +113,7 @@ const completeMasterpassPayment = async (
|
|
|
114
113
|
? await buildDirectPurchaseForm(commonFormValues, params)
|
|
115
114
|
: await buildPurchaseForm({
|
|
116
115
|
...commonFormValues,
|
|
117
|
-
selectedCard
|
|
118
|
-
cardCvc: params?.card_cvv
|
|
116
|
+
selectedCard
|
|
119
117
|
});
|
|
120
118
|
|
|
121
119
|
window.MFS?.[
|
|
@@ -153,10 +151,6 @@ const completeMasterpassPayment = async (
|
|
|
153
151
|
return;
|
|
154
152
|
}
|
|
155
153
|
|
|
156
|
-
if (['5013', '5182'].includes(response.responseCode)) {
|
|
157
|
-
dispatch(setCvcRequired(true));
|
|
158
|
-
}
|
|
159
|
-
|
|
160
154
|
if (
|
|
161
155
|
response.token &&
|
|
162
156
|
(response.responseCode == '0000' || response.responseCode == '')
|
|
@@ -379,22 +373,6 @@ export const checkoutApi = api.injectEndpoints({
|
|
|
379
373
|
dispatch(setShippingStepBusy(false));
|
|
380
374
|
}
|
|
381
375
|
}),
|
|
382
|
-
setDataSourceShippingOptions: build.mutation<CheckoutResponse, number[]>({
|
|
383
|
-
query: (pks) => ({
|
|
384
|
-
url: buildClientRequestUrl(checkout.setDataSourceShippingOption, {
|
|
385
|
-
useFormData: true
|
|
386
|
-
}),
|
|
387
|
-
method: 'POST',
|
|
388
|
-
body: {
|
|
389
|
-
data_source_shipping_options: JSON.stringify(pks)
|
|
390
|
-
}
|
|
391
|
-
}),
|
|
392
|
-
async onQueryStarted(arg, { dispatch, queryFulfilled }) {
|
|
393
|
-
dispatch(setShippingStepBusy(true));
|
|
394
|
-
await queryFulfilled;
|
|
395
|
-
dispatch(setShippingStepBusy(false));
|
|
396
|
-
}
|
|
397
|
-
}),
|
|
398
376
|
setRetailStore: build.mutation<CheckoutResponse, SetRetailStoreParams>({
|
|
399
377
|
query: ({ retailStorePk, billingAddressPk }) => ({
|
|
400
378
|
url: buildClientRequestUrl(
|
|
@@ -676,25 +654,6 @@ export const checkoutApi = api.injectEndpoints({
|
|
|
676
654
|
notes
|
|
677
655
|
}
|
|
678
656
|
})
|
|
679
|
-
}),
|
|
680
|
-
setAttributeBasedShippingOptions: build.mutation<
|
|
681
|
-
CheckoutResponse,
|
|
682
|
-
Record<string, number>
|
|
683
|
-
>({
|
|
684
|
-
query: (options) => ({
|
|
685
|
-
url: buildClientRequestUrl(checkout.setAttributeBasedShippingOption, {
|
|
686
|
-
useFormData: true
|
|
687
|
-
}),
|
|
688
|
-
method: 'POST',
|
|
689
|
-
body: {
|
|
690
|
-
attribute_based_shipping_options: JSON.stringify(options)
|
|
691
|
-
}
|
|
692
|
-
}),
|
|
693
|
-
async onQueryStarted(arg, { dispatch, queryFulfilled }) {
|
|
694
|
-
dispatch(setShippingStepBusy(true));
|
|
695
|
-
await queryFulfilled;
|
|
696
|
-
dispatch(setShippingStepBusy(false));
|
|
697
|
-
}
|
|
698
657
|
})
|
|
699
658
|
}),
|
|
700
659
|
overrideExisting: false
|
|
@@ -713,7 +672,6 @@ export const {
|
|
|
713
672
|
useSetDeliveryOptionMutation,
|
|
714
673
|
useSetAddressesMutation,
|
|
715
674
|
useSetShippingOptionMutation,
|
|
716
|
-
useSetDataSourceShippingOptionsMutation,
|
|
717
675
|
useSetPaymentOptionMutation,
|
|
718
676
|
useSetBinNumberMutation,
|
|
719
677
|
useSetInstallmentOptionMutation,
|
|
@@ -730,6 +688,5 @@ export const {
|
|
|
730
688
|
useCompleteLoyaltyPaymentMutation,
|
|
731
689
|
useGetCheckoutLoyaltyBalanceQuery,
|
|
732
690
|
usePayWithLoyaltyBalanceMutation,
|
|
733
|
-
useSetOrderNoteMutation
|
|
734
|
-
useSetAttributeBasedShippingOptionsMutation
|
|
691
|
+
useSetOrderNoteMutation
|
|
735
692
|
} = checkoutApi;
|
package/data/client/wishlist.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FavoriteItem
|
|
1
|
+
import { FavoriteItem } from '../../types';
|
|
2
2
|
import { buildClientRequestUrl } from '../../utils';
|
|
3
3
|
import { api } from './api';
|
|
4
4
|
import { wishlist } from '../urls';
|
|
@@ -55,25 +55,6 @@ interface GetStockAlertsResponse {
|
|
|
55
55
|
interface DeleteStockAlertResponse {
|
|
56
56
|
success: boolean;
|
|
57
57
|
}
|
|
58
|
-
interface GetCollectionOOSResponse {
|
|
59
|
-
count: number;
|
|
60
|
-
results: CollectionItem[];
|
|
61
|
-
next?: string | null;
|
|
62
|
-
previous?: string | null;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export interface CollectionItem {
|
|
66
|
-
pk: number;
|
|
67
|
-
status: string;
|
|
68
|
-
name: string;
|
|
69
|
-
slug: string;
|
|
70
|
-
items: Product[];
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export interface CollectionItemsResponse {
|
|
74
|
-
pk: number;
|
|
75
|
-
product: Product;
|
|
76
|
-
}
|
|
77
58
|
|
|
78
59
|
export const wishlistApi = api.injectEndpoints({
|
|
79
60
|
endpoints: (build) => ({
|
|
@@ -124,50 +105,6 @@ export const wishlistApi = api.injectEndpoints({
|
|
|
124
105
|
method: 'DELETE'
|
|
125
106
|
}),
|
|
126
107
|
invalidatesTags: ['StockAlert']
|
|
127
|
-
}),
|
|
128
|
-
setCollectionOOS: build.mutation<
|
|
129
|
-
CollectionItem,
|
|
130
|
-
{ name: string; status: string }
|
|
131
|
-
>({
|
|
132
|
-
query: ({ name, status = 'private' }) => ({
|
|
133
|
-
url: buildClientRequestUrl(wishlist.setCollection(), {
|
|
134
|
-
contentType: 'application/json'
|
|
135
|
-
}),
|
|
136
|
-
method: 'POST',
|
|
137
|
-
body: {
|
|
138
|
-
name,
|
|
139
|
-
status
|
|
140
|
-
}
|
|
141
|
-
})
|
|
142
|
-
}),
|
|
143
|
-
setCollectionItems: build.mutation<
|
|
144
|
-
CollectionItemsResponse,
|
|
145
|
-
{ usercollection_id: number; product_id: number | number[] }
|
|
146
|
-
>({
|
|
147
|
-
query: ({ usercollection_id, product_id }) => ({
|
|
148
|
-
url: buildClientRequestUrl(wishlist.setCollectionItems, {
|
|
149
|
-
contentType: 'application/json'
|
|
150
|
-
}),
|
|
151
|
-
method: 'POST',
|
|
152
|
-
body: {
|
|
153
|
-
usercollection_id,
|
|
154
|
-
product_id
|
|
155
|
-
}
|
|
156
|
-
})
|
|
157
|
-
}),
|
|
158
|
-
getCollectionsOOS: build.query<
|
|
159
|
-
GetCollectionOOSResponse,
|
|
160
|
-
{ search?: string; product_id?: number }
|
|
161
|
-
>({
|
|
162
|
-
query: ({ search, product_id }) => ({
|
|
163
|
-
url: buildClientRequestUrl(wishlist.getCollections(search, product_id))
|
|
164
|
-
})
|
|
165
|
-
}),
|
|
166
|
-
deleteCollection: build.query<void, number>({
|
|
167
|
-
query: (pk: number) => ({
|
|
168
|
-
url: buildClientRequestUrl(wishlist.deleteCollection(pk)),
|
|
169
|
-
method: 'DELETE'
|
|
170
|
-
})
|
|
171
108
|
})
|
|
172
109
|
}),
|
|
173
110
|
overrideExisting: true
|
|
@@ -179,10 +116,5 @@ export const {
|
|
|
179
116
|
useRemoveFavoriteMutation,
|
|
180
117
|
useAddStockAlertMutation,
|
|
181
118
|
useGetStockAlertsQuery,
|
|
182
|
-
useDeleteStockAlertMutation
|
|
183
|
-
useSetCollectionOOSMutation,
|
|
184
|
-
useSetCollectionItemsMutation,
|
|
185
|
-
useGetCollectionsOOSQuery,
|
|
186
|
-
useLazyGetCollectionsOOSQuery,
|
|
187
|
-
useLazyDeleteCollectionQuery
|
|
119
|
+
useDeleteStockAlertMutation
|
|
188
120
|
} = wishlistApi;
|
package/data/server/category.ts
CHANGED
|
@@ -8,7 +8,7 @@ import logger from '../../utils/log';
|
|
|
8
8
|
|
|
9
9
|
function getCategoryDataHandler(
|
|
10
10
|
pk: number,
|
|
11
|
-
searchParams?:
|
|
11
|
+
searchParams?: URLSearchParams,
|
|
12
12
|
headers?: Record<string, string>
|
|
13
13
|
) {
|
|
14
14
|
return async function () {
|
|
@@ -78,7 +78,7 @@ export const getCategoryData = ({
|
|
|
78
78
|
headers
|
|
79
79
|
}: {
|
|
80
80
|
pk: number;
|
|
81
|
-
searchParams?:
|
|
81
|
+
searchParams?: URLSearchParams;
|
|
82
82
|
headers?: Record<string, string>;
|
|
83
83
|
}) => {
|
|
84
84
|
return Cache.wrap(
|
package/data/server/list.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { parse } from 'lossless-json';
|
|
|
7
7
|
import logger from '../../utils/log';
|
|
8
8
|
|
|
9
9
|
const getListDataHandler = (
|
|
10
|
-
searchParams:
|
|
10
|
+
searchParams: URLSearchParams,
|
|
11
11
|
headers?: Record<string, string>
|
|
12
12
|
) => {
|
|
13
13
|
return async function () {
|
|
@@ -54,7 +54,7 @@ export const getListData = async ({
|
|
|
54
54
|
searchParams,
|
|
55
55
|
headers
|
|
56
56
|
}: {
|
|
57
|
-
searchParams:
|
|
57
|
+
searchParams: URLSearchParams;
|
|
58
58
|
headers?: Record<string, string>;
|
|
59
59
|
}) => {
|
|
60
60
|
return Cache.wrap(
|
package/data/server/product.ts
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { Cache, CacheKey } from '../../lib/cache';
|
|
2
2
|
import { product } from '../urls';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
BreadcrumbResultType,
|
|
5
|
+
ProductCategoryResult,
|
|
6
|
+
ProductResult
|
|
7
|
+
} from '../../types';
|
|
4
8
|
import appFetch from '../../utils/app-fetch';
|
|
5
|
-
import logger from '../../utils/log';
|
|
6
9
|
|
|
7
10
|
type GetProduct = {
|
|
8
11
|
pk: number;
|
|
9
|
-
searchParams?:
|
|
12
|
+
searchParams?: URLSearchParams;
|
|
10
13
|
groupProduct?: boolean;
|
|
11
14
|
};
|
|
12
15
|
|
|
@@ -47,17 +50,9 @@ const getProductDataHandler = ({
|
|
|
47
50
|
}
|
|
48
51
|
);
|
|
49
52
|
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
logger.warn('menuItemModel is undefined, skipping breadcrumbData fetch', {
|
|
54
|
-
handler: 'getProductDataHandler',
|
|
55
|
-
pk
|
|
56
|
-
});
|
|
57
|
-
return { data, breadcrumbData: undefined };
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const breadcrumbUrl = product.breadcrumbUrl(menuItemModel);
|
|
53
|
+
const breadcrumbUrl = product.breadcrumbUrl(
|
|
54
|
+
productCategoryData.results[0].menuitemmodel
|
|
55
|
+
);
|
|
61
56
|
|
|
62
57
|
const breadcrumbData = await appFetch<any>(breadcrumbUrl, {
|
|
63
58
|
headers: {
|
|
@@ -79,7 +74,10 @@ export const getProductData = async ({
|
|
|
79
74
|
groupProduct
|
|
80
75
|
}: GetProduct) => {
|
|
81
76
|
return Cache.wrap(
|
|
82
|
-
CacheKey[groupProduct ? 'GroupProduct' : 'Product'](
|
|
77
|
+
CacheKey[groupProduct ? 'GroupProduct' : 'Product'](
|
|
78
|
+
pk,
|
|
79
|
+
searchParams ?? new URLSearchParams()
|
|
80
|
+
),
|
|
83
81
|
getProductDataHandler({ pk, searchParams, groupProduct }),
|
|
84
82
|
{
|
|
85
83
|
expire: 300
|
|
@@ -7,7 +7,7 @@ import header from '../../redux/reducers/header';
|
|
|
7
7
|
|
|
8
8
|
const getSpecialPageDataHandler = (
|
|
9
9
|
pk: number,
|
|
10
|
-
searchParams:
|
|
10
|
+
searchParams: URLSearchParams,
|
|
11
11
|
headers?: Record<string, string>
|
|
12
12
|
) => {
|
|
13
13
|
return async function () {
|
|
@@ -34,7 +34,7 @@ export const getSpecialPageData = async ({
|
|
|
34
34
|
headers
|
|
35
35
|
}: {
|
|
36
36
|
pk: number;
|
|
37
|
-
searchParams:
|
|
37
|
+
searchParams: URLSearchParams;
|
|
38
38
|
headers?: Record<string, string>;
|
|
39
39
|
}) => {
|
|
40
40
|
return Cache.wrap(
|
package/data/urls.ts
CHANGED
|
@@ -83,8 +83,6 @@ export const checkout = {
|
|
|
83
83
|
setDeliveryOption: '/orders/checkout/?page=DeliveryOptionSelectionPage',
|
|
84
84
|
setAddresses: '/orders/checkout/?page=AddressSelectionPage',
|
|
85
85
|
setShippingOption: '/orders/checkout/?page=ShippingOptionSelectionPage',
|
|
86
|
-
setDataSourceShippingOption:
|
|
87
|
-
'/orders/checkout/?page=DataSourceShippingOptionSelectionPage',
|
|
88
86
|
setPaymentOption: '/orders/checkout/?page=PaymentOptionSelectionPage',
|
|
89
87
|
setBinNumber: '/orders/checkout/?page=BinNumberPage',
|
|
90
88
|
setMasterpassBinNumber: '/orders/checkout/?page=MasterpassBinNumberPage',
|
|
@@ -110,9 +108,7 @@ export const checkout = {
|
|
|
110
108
|
completeLoyaltyPayment: '/orders/checkout/?page=LoyaltyPaymentSelectedPage',
|
|
111
109
|
loyaltyMoneyUsage: '/orders/checkout/?page=LoyaltyMoneyUsagePage',
|
|
112
110
|
setOrderNote: '/orders/checkout/?page=OrderNotePage',
|
|
113
|
-
couponSelectionPage: '/orders/checkout/?page=CouponSelectionPage'
|
|
114
|
-
setAttributeBasedShippingOption:
|
|
115
|
-
'/orders/checkout/?page=AttributeBasedShippingOptionSelectionPage'
|
|
111
|
+
couponSelectionPage: '/orders/checkout/?page=CouponSelectionPage'
|
|
116
112
|
};
|
|
117
113
|
|
|
118
114
|
export const flatpage = {
|
|
@@ -165,14 +161,7 @@ export const wishlist = {
|
|
|
165
161
|
page?: number;
|
|
166
162
|
limit?: number;
|
|
167
163
|
}) => `/wishlists/product-alerts/?limit=${limit}&page=${page}`,
|
|
168
|
-
deleteStockAlert: (pk: number) => `/wishlists/product-alerts/${pk}
|
|
169
|
-
setCollection: () => '/wishlists/user-collections/',
|
|
170
|
-
setCollectionItems: '/wishlists/user-collection-items/',
|
|
171
|
-
getCollections: (search?: string, product_id?: number) =>
|
|
172
|
-
`/wishlists/user-collections/?search=${search ? search : ''}&product_id=${
|
|
173
|
-
product_id ? product_id : ''
|
|
174
|
-
}`,
|
|
175
|
-
deleteCollection: (pk: number) => `/wishlists/user-collections/${pk}/`
|
|
164
|
+
deleteStockAlert: (pk: number) => `/wishlists/product-alerts/${pk}/`
|
|
176
165
|
};
|
|
177
166
|
|
|
178
167
|
export const user = {
|
|
@@ -198,10 +187,7 @@ export const b2b = {
|
|
|
198
187
|
draftBaskets: '/b2b/basket/drafts/',
|
|
199
188
|
divisions: '/b2b/my-divisions/',
|
|
200
189
|
myQuotations: '/b2b/my-quotations/',
|
|
201
|
-
loadBasket: (id) => `/b2b/basket/${id}/load
|
|
202
|
-
statusBasket: (cacheKey) => `/b2b/basket/?status_cache_key=${cacheKey}`,
|
|
203
|
-
basketExport: (queryString) => `/b2b/basket/?upload=true&${queryString}`,
|
|
204
|
-
basketImport: '/b2b/basket/bulk-import/'
|
|
190
|
+
loadBasket: (id) => `/b2b/basket/${id}/load/`
|
|
205
191
|
};
|
|
206
192
|
|
|
207
193
|
export const widgets = {
|
package/hooks/index.ts
CHANGED
|
@@ -8,5 +8,4 @@ export * from './use-media-query';
|
|
|
8
8
|
export * from './use-on-click-outside';
|
|
9
9
|
export * from './use-mobile-iframe-handler';
|
|
10
10
|
export * from './use-payment-options';
|
|
11
|
-
export * from './use-pagination';
|
|
12
|
-
export * from './use-message-listener';
|
|
11
|
+
export * from './use-pagination';
|
|
@@ -18,8 +18,7 @@ export const usePaymentOptions = () => {
|
|
|
18
18
|
pay_on_delivery: 'pz-pay-on-delivery',
|
|
19
19
|
bkm_express: 'pz-bkm',
|
|
20
20
|
credit_payment: 'pz-credit-payment',
|
|
21
|
-
masterpass: 'pz-masterpass'
|
|
22
|
-
gpay: 'pz-gpay'
|
|
21
|
+
masterpass: 'pz-masterpass'
|
|
23
22
|
};
|
|
24
23
|
|
|
25
24
|
const isInitialTypeIncluded = (type: string) => initialTypes.has(type);
|