@akinon/next 1.81.0-rc.7 → 1.81.0-rc.8
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 +6 -0
- package/data/client/checkout.ts +24 -2
- package/data/urls.ts +3 -1
- package/package.json +2 -2
- package/redux/middlewares/checkout.ts +16 -2
- package/redux/reducers/checkout.ts +8 -2
- package/redux/reducers/root.ts +7 -2
- package/types/commerce/checkout.ts +9 -0
package/CHANGELOG.md
CHANGED
package/data/client/checkout.ts
CHANGED
|
@@ -13,7 +13,9 @@ import {
|
|
|
13
13
|
ExtraField,
|
|
14
14
|
GuestLoginFormParams,
|
|
15
15
|
Order,
|
|
16
|
-
PreOrder
|
|
16
|
+
PreOrder,
|
|
17
|
+
SendSmsType,
|
|
18
|
+
VerifySmsType
|
|
17
19
|
} from '../../types';
|
|
18
20
|
import { buildClientRequestUrl } from '../../utils';
|
|
19
21
|
import { api } from './api';
|
|
@@ -847,6 +849,24 @@ export const checkoutApi = api.injectEndpoints({
|
|
|
847
849
|
selected_loyalty_amount: amount
|
|
848
850
|
}
|
|
849
851
|
})
|
|
852
|
+
}),
|
|
853
|
+
sendSms: build.mutation<CheckoutResponse, SendSmsType>({
|
|
854
|
+
query: (body) => ({
|
|
855
|
+
url: buildClientRequestUrl(checkout.sendSmsPage, {
|
|
856
|
+
useFormData: true
|
|
857
|
+
}),
|
|
858
|
+
method: 'POST',
|
|
859
|
+
body
|
|
860
|
+
})
|
|
861
|
+
}),
|
|
862
|
+
verifySms: build.mutation<CheckoutResponse, VerifySmsType>({
|
|
863
|
+
query: (body) => ({
|
|
864
|
+
url: buildClientRequestUrl(checkout.verifySmsPage, {
|
|
865
|
+
useFormData: true
|
|
866
|
+
}),
|
|
867
|
+
method: 'POST',
|
|
868
|
+
body
|
|
869
|
+
})
|
|
850
870
|
})
|
|
851
871
|
}),
|
|
852
872
|
overrideExisting: false
|
|
@@ -892,5 +912,7 @@ export const {
|
|
|
892
912
|
useSetWalletSelectionPageMutation,
|
|
893
913
|
useSetWalletPaymentPageMutation,
|
|
894
914
|
useSetWalletCompletePageMutation,
|
|
895
|
-
useResetCheckoutStateQuery
|
|
915
|
+
useResetCheckoutStateQuery,
|
|
916
|
+
useSendSmsMutation,
|
|
917
|
+
useVerifySmsMutation
|
|
896
918
|
} = checkoutApi;
|
package/data/urls.ts
CHANGED
|
@@ -137,7 +137,9 @@ export const checkout = {
|
|
|
137
137
|
'/orders/checkout/?page=AttributeBasedShippingOptionSelectionPage',
|
|
138
138
|
deliveryBagsPage: '/orders/checkout/?page=DeliveryBagsPage',
|
|
139
139
|
setOrderSelectionPage: '/orders/checkout/?page=OrderSelectionPage',
|
|
140
|
-
loyaltyCardPage: '/orders/checkout/?page=LoyaltyCardPage'
|
|
140
|
+
loyaltyCardPage: '/orders/checkout/?page=LoyaltyCardPage',
|
|
141
|
+
sendSmsPage: '/orders/checkout/?page=SendSmsPage',
|
|
142
|
+
verifySmsPage: '/orders/checkout/?page=VerifySmsPage'
|
|
141
143
|
};
|
|
142
144
|
|
|
143
145
|
export const flatpage = {
|
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.81.0-rc.
|
|
4
|
+
"version": "1.81.0-rc.8",
|
|
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.81.0-rc.
|
|
33
|
+
"@akinon/eslint-plugin-projectzero": "1.81.0-rc.8",
|
|
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",
|
|
@@ -21,7 +21,8 @@ import {
|
|
|
21
21
|
setShippingOptions,
|
|
22
22
|
setShippingStepCompleted,
|
|
23
23
|
setHepsipayAvailability,
|
|
24
|
-
setWalletPaymentData
|
|
24
|
+
setWalletPaymentData,
|
|
25
|
+
setPayOnDeliveryOtpModalActive
|
|
25
26
|
} from '../../redux/reducers/checkout';
|
|
26
27
|
import { RootState, TypedDispatch } from 'redux/store';
|
|
27
28
|
import { checkoutApi } from '../../data/client/checkout';
|
|
@@ -203,8 +204,9 @@ export const contextListMiddleware: Middleware = ({
|
|
|
203
204
|
getState
|
|
204
205
|
}: MiddlewareParams) => {
|
|
205
206
|
return (next) => (action) => {
|
|
206
|
-
const { isMobileApp } = getState().root;
|
|
207
|
+
const { isMobileApp, userPhoneNumber } = getState().root;
|
|
207
208
|
const result: CheckoutResult = next(action);
|
|
209
|
+
const preOrder = result?.payload?.pre_order;
|
|
208
210
|
|
|
209
211
|
if (result?.payload?.context_list) {
|
|
210
212
|
result.payload.context_list.forEach((context) => {
|
|
@@ -323,6 +325,18 @@ export const contextListMiddleware: Middleware = ({
|
|
|
323
325
|
if (context.page_context.retail_stores) {
|
|
324
326
|
dispatch(setRetailStores(context.page_context.retail_stores));
|
|
325
327
|
}
|
|
328
|
+
|
|
329
|
+
if (context.page_name === 'SendSmsPage' && !preOrder?.phone_number) {
|
|
330
|
+
dispatch(
|
|
331
|
+
checkoutApi.endpoints.sendSms.initiate({
|
|
332
|
+
phone_number: userPhoneNumber ?? preOrder?.user_phone_number
|
|
333
|
+
})
|
|
334
|
+
);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
if (context.page_name === 'VerifySmsPage') {
|
|
338
|
+
dispatch(setPayOnDeliveryOtpModalActive(true));
|
|
339
|
+
}
|
|
326
340
|
});
|
|
327
341
|
}
|
|
328
342
|
|
|
@@ -70,6 +70,7 @@ export interface CheckoutState {
|
|
|
70
70
|
};
|
|
71
71
|
supportedMethods: string;
|
|
72
72
|
};
|
|
73
|
+
payOnDeliveryOtpModalActive: boolean;
|
|
73
74
|
}
|
|
74
75
|
|
|
75
76
|
const initialState: CheckoutState = {
|
|
@@ -103,7 +104,8 @@ const initialState: CheckoutState = {
|
|
|
103
104
|
retailStores: [],
|
|
104
105
|
attributeBasedShippingOptions: [],
|
|
105
106
|
selectedShippingOptions: {},
|
|
106
|
-
hepsipayAvailability: false
|
|
107
|
+
hepsipayAvailability: false,
|
|
108
|
+
payOnDeliveryOtpModalActive: false
|
|
107
109
|
};
|
|
108
110
|
|
|
109
111
|
const checkoutSlice = createSlice({
|
|
@@ -193,6 +195,9 @@ const checkoutSlice = createSlice({
|
|
|
193
195
|
},
|
|
194
196
|
setWalletPaymentData(state, { payload }) {
|
|
195
197
|
state.walletPaymentData = payload;
|
|
198
|
+
},
|
|
199
|
+
setPayOnDeliveryOtpModalActive(state, { payload }) {
|
|
200
|
+
state.payOnDeliveryOtpModalActive = payload;
|
|
196
201
|
}
|
|
197
202
|
}
|
|
198
203
|
});
|
|
@@ -225,7 +230,8 @@ export const {
|
|
|
225
230
|
setAttributeBasedShippingOptions,
|
|
226
231
|
setSelectedShippingOptions,
|
|
227
232
|
setHepsipayAvailability,
|
|
228
|
-
setWalletPaymentData
|
|
233
|
+
setWalletPaymentData,
|
|
234
|
+
setPayOnDeliveryOtpModalActive
|
|
229
235
|
} = checkoutSlice.actions;
|
|
230
236
|
|
|
231
237
|
export default checkoutSlice.reducer;
|
package/redux/reducers/root.ts
CHANGED
|
@@ -14,7 +14,8 @@ const initialState = {
|
|
|
14
14
|
open: false,
|
|
15
15
|
title: null,
|
|
16
16
|
content: null
|
|
17
|
-
}
|
|
17
|
+
},
|
|
18
|
+
userPhoneNumber: null
|
|
18
19
|
};
|
|
19
20
|
|
|
20
21
|
const rootSlice = createSlice({
|
|
@@ -45,6 +46,9 @@ const rootSlice = createSlice({
|
|
|
45
46
|
state.rootModal.open = false;
|
|
46
47
|
state.rootModal.title = null;
|
|
47
48
|
state.rootModal.content = null;
|
|
49
|
+
},
|
|
50
|
+
setUserPhoneNumber(state, { payload }) {
|
|
51
|
+
state.userPhoneNumber = payload;
|
|
48
52
|
}
|
|
49
53
|
}
|
|
50
54
|
});
|
|
@@ -55,7 +59,8 @@ export const {
|
|
|
55
59
|
toggleMiniBasket,
|
|
56
60
|
setHighlightedItem,
|
|
57
61
|
openRootModal,
|
|
58
|
-
closeRootModal
|
|
62
|
+
closeRootModal,
|
|
63
|
+
setUserPhoneNumber
|
|
59
64
|
} = rootSlice.actions;
|
|
60
65
|
|
|
61
66
|
export default rootSlice.reducer;
|
|
@@ -107,6 +107,7 @@ export interface PreOrder {
|
|
|
107
107
|
context_extras?: ExtraField;
|
|
108
108
|
token?: string;
|
|
109
109
|
agreement_confirmed?: boolean;
|
|
110
|
+
phone_number?: string;
|
|
110
111
|
}
|
|
111
112
|
|
|
112
113
|
export type ExtraField = Record<string, any>;
|
|
@@ -199,3 +200,11 @@ export interface MiddlewareParams {
|
|
|
199
200
|
getState: () => RootState;
|
|
200
201
|
dispatch: TypedDispatch;
|
|
201
202
|
}
|
|
203
|
+
|
|
204
|
+
export type SendSmsType = {
|
|
205
|
+
phone_number: string;
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
export type VerifySmsType = {
|
|
209
|
+
verify_code: string;
|
|
210
|
+
};
|