@akinon/next 1.63.0 → 1.64.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 +7 -0
- package/data/client/checkout.ts +17 -0
- package/data/urls.ts +2 -0
- package/package.json +2 -2
- package/redux/middlewares/checkout.ts +24 -1
- package/redux/reducers/checkout.ts +8 -1
- package/types/commerce/address.ts +1 -1
- package/types/commerce/checkout.ts +18 -0
package/CHANGELOG.md
CHANGED
package/data/client/checkout.ts
CHANGED
|
@@ -380,6 +380,22 @@ export const checkoutApi = api.injectEndpoints({
|
|
|
380
380
|
dispatch(setShippingStepBusy(false));
|
|
381
381
|
}
|
|
382
382
|
}),
|
|
383
|
+
setDataSourceShippingOptions: build.mutation<CheckoutResponse, number[]>({
|
|
384
|
+
query: (pks) => ({
|
|
385
|
+
url: buildClientRequestUrl(checkout.setDataSourceShippingOption, {
|
|
386
|
+
useFormData: true
|
|
387
|
+
}),
|
|
388
|
+
method: 'POST',
|
|
389
|
+
body: {
|
|
390
|
+
data_source_shipping_options: JSON.stringify(pks)
|
|
391
|
+
}
|
|
392
|
+
}),
|
|
393
|
+
async onQueryStarted(arg, { dispatch, queryFulfilled }) {
|
|
394
|
+
dispatch(setShippingStepBusy(true));
|
|
395
|
+
await queryFulfilled;
|
|
396
|
+
dispatch(setShippingStepBusy(false));
|
|
397
|
+
}
|
|
398
|
+
}),
|
|
383
399
|
setRetailStore: build.mutation<CheckoutResponse, SetRetailStoreParams>({
|
|
384
400
|
query: ({ retailStorePk, billingAddressPk }) => ({
|
|
385
401
|
url: buildClientRequestUrl(
|
|
@@ -712,6 +728,7 @@ export const {
|
|
|
712
728
|
useSetDeliveryOptionMutation,
|
|
713
729
|
useSetAddressesMutation,
|
|
714
730
|
useSetShippingOptionMutation,
|
|
731
|
+
useSetDataSourceShippingOptionsMutation,
|
|
715
732
|
useSetPaymentOptionMutation,
|
|
716
733
|
useSetBinNumberMutation,
|
|
717
734
|
useSetInstallmentOptionMutation,
|
package/data/urls.ts
CHANGED
|
@@ -83,6 +83,8 @@ 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',
|
|
86
88
|
setPaymentOption: '/orders/checkout/?page=PaymentOptionSelectionPage',
|
|
87
89
|
setBinNumber: '/orders/checkout/?page=BinNumberPage',
|
|
88
90
|
setMasterpassBinNumber: '/orders/checkout/?page=MasterpassBinNumberPage',
|
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.
|
|
4
|
+
"version": "1.64.0",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"bin": {
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"set-cookie-parser": "2.6.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@akinon/eslint-plugin-projectzero": "1.
|
|
33
|
+
"@akinon/eslint-plugin-projectzero": "1.64.0",
|
|
34
34
|
"@types/react-redux": "7.1.30",
|
|
35
35
|
"@types/set-cookie-parser": "2.4.7",
|
|
36
36
|
"@typescript-eslint/eslint-plugin": "6.7.4",
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
setPreOrder,
|
|
17
17
|
setRetailStores,
|
|
18
18
|
setShippingOptions,
|
|
19
|
+
setDataSourceShippingOptions,
|
|
19
20
|
setShippingStepCompleted,
|
|
20
21
|
setCreditPaymentOptions
|
|
21
22
|
} from '../../redux/reducers/checkout';
|
|
@@ -73,6 +74,7 @@ export const preOrderMiddleware: Middleware = ({
|
|
|
73
74
|
deliveryOptions,
|
|
74
75
|
addressList: addresses,
|
|
75
76
|
shippingOptions,
|
|
77
|
+
dataSourceShippingOptions,
|
|
76
78
|
paymentOptions,
|
|
77
79
|
installmentOptions
|
|
78
80
|
} = getState().checkout;
|
|
@@ -126,6 +128,22 @@ export const preOrderMiddleware: Middleware = ({
|
|
|
126
128
|
dispatch(apiEndpoints.setShippingOption.initiate(shippingOptions[0].pk));
|
|
127
129
|
}
|
|
128
130
|
|
|
131
|
+
if (
|
|
132
|
+
dataSourceShippingOptions.length > 0 &&
|
|
133
|
+
!preOrder.data_source_shipping_options
|
|
134
|
+
) {
|
|
135
|
+
const selectedDataSourceShippingOptionsPks =
|
|
136
|
+
dataSourceShippingOptions.map(
|
|
137
|
+
(opt) => opt.data_source_shipping_options[0].pk
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
dispatch(
|
|
141
|
+
apiEndpoints.setDataSourceShippingOptions.initiate(
|
|
142
|
+
selectedDataSourceShippingOptionsPks
|
|
143
|
+
)
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
|
|
129
147
|
if (!preOrder.payment_option && paymentOptions.length > 0) {
|
|
130
148
|
dispatch(apiEndpoints.setPaymentOption.initiate(paymentOptions[0].pk));
|
|
131
149
|
}
|
|
@@ -164,7 +182,6 @@ export const contextListMiddleware: Middleware = ({
|
|
|
164
182
|
if (result?.payload?.context_list) {
|
|
165
183
|
result.payload.context_list.forEach((context) => {
|
|
166
184
|
const redirectUrl = context.page_context.redirect_url;
|
|
167
|
-
|
|
168
185
|
if (redirectUrl) {
|
|
169
186
|
const currentLocale = getCookie('pz-locale');
|
|
170
187
|
|
|
@@ -221,6 +238,12 @@ export const contextListMiddleware: Middleware = ({
|
|
|
221
238
|
dispatch(setShippingOptions(context.page_context.shipping_options));
|
|
222
239
|
}
|
|
223
240
|
|
|
241
|
+
if (context.page_context.data_sources) {
|
|
242
|
+
dispatch(
|
|
243
|
+
setDataSourceShippingOptions(context.page_context.data_sources)
|
|
244
|
+
);
|
|
245
|
+
}
|
|
246
|
+
|
|
224
247
|
if (context.page_context.payment_options) {
|
|
225
248
|
dispatch(setPaymentOptions(context.page_context.payment_options));
|
|
226
249
|
}
|
|
@@ -14,7 +14,8 @@ import {
|
|
|
14
14
|
CheckoutCreditPaymentOption,
|
|
15
15
|
PreOrder,
|
|
16
16
|
RetailStore,
|
|
17
|
-
ShippingOption
|
|
17
|
+
ShippingOption,
|
|
18
|
+
DataSource
|
|
18
19
|
} from '../../types';
|
|
19
20
|
|
|
20
21
|
export interface CheckoutState {
|
|
@@ -36,6 +37,7 @@ export interface CheckoutState {
|
|
|
36
37
|
addressList: Address[];
|
|
37
38
|
deliveryOptions: DeliveryOption[];
|
|
38
39
|
shippingOptions: ShippingOption[];
|
|
40
|
+
dataSourceShippingOptions: DataSource[];
|
|
39
41
|
paymentOptions: PaymentOption[];
|
|
40
42
|
creditPaymentOptions: CheckoutCreditPaymentOption[];
|
|
41
43
|
selectedCreditPaymentPk: number;
|
|
@@ -67,6 +69,7 @@ const initialState: CheckoutState = {
|
|
|
67
69
|
addressList: [],
|
|
68
70
|
deliveryOptions: [],
|
|
69
71
|
shippingOptions: [],
|
|
72
|
+
dataSourceShippingOptions: [],
|
|
70
73
|
paymentOptions: [],
|
|
71
74
|
creditPaymentOptions: [],
|
|
72
75
|
selectedCreditPaymentPk: null,
|
|
@@ -121,6 +124,9 @@ const checkoutSlice = createSlice({
|
|
|
121
124
|
setShippingOptions(state, { payload }) {
|
|
122
125
|
state.shippingOptions = payload;
|
|
123
126
|
},
|
|
127
|
+
setDataSourceShippingOptions(state, { payload }) {
|
|
128
|
+
state.dataSourceShippingOptions = payload;
|
|
129
|
+
},
|
|
124
130
|
setPaymentOptions(state, { payload }) {
|
|
125
131
|
state.paymentOptions = payload;
|
|
126
132
|
},
|
|
@@ -168,6 +174,7 @@ export const {
|
|
|
168
174
|
setAddressList,
|
|
169
175
|
setDeliveryOptions,
|
|
170
176
|
setShippingOptions,
|
|
177
|
+
setDataSourceShippingOptions,
|
|
171
178
|
setPaymentOptions,
|
|
172
179
|
setCreditPaymentOptions,
|
|
173
180
|
setSelectedCreditPaymentPk,
|
|
@@ -34,6 +34,23 @@ export interface ShippingOption {
|
|
|
34
34
|
slug: string;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
export interface DataSource {
|
|
38
|
+
pk: number;
|
|
39
|
+
name: string;
|
|
40
|
+
data_source_shipping_options: DataSourceShippingOption[];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface DataSourceShippingOption {
|
|
44
|
+
pk: number;
|
|
45
|
+
shipping_amount: string;
|
|
46
|
+
shipping_option_name: string;
|
|
47
|
+
shipping_option_logo: string | null;
|
|
48
|
+
data_source: {
|
|
49
|
+
pk: number;
|
|
50
|
+
title: string | null;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
37
54
|
export interface CheckoutAddressType {
|
|
38
55
|
label: string;
|
|
39
56
|
text: string;
|
|
@@ -79,6 +96,7 @@ export interface PreOrder {
|
|
|
79
96
|
retail_store?: RetailStore;
|
|
80
97
|
gift_box?: GiftBox;
|
|
81
98
|
credit_payment_option?: CheckoutCreditPaymentOption;
|
|
99
|
+
data_source_shipping_options: any;
|
|
82
100
|
bags?: Product[];
|
|
83
101
|
bags_fee?: string;
|
|
84
102
|
extra_field?: ExtraField;
|