@akinon/next 1.83.0 → 1.84.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 +8 -0
- package/data/client/checkout.ts +23 -1
- package/data/client/misc.ts +25 -1
- package/data/client/product.ts +17 -1
- package/data/urls.ts +8 -3
- package/middlewares/default.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
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @akinon/next
|
|
2
2
|
|
|
3
|
+
## 1.84.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 757ee53: ZERO-3207: Add SMS send & verify endpoints with state management
|
|
8
|
+
- c0c1962: ZERO-3258: Add new API endpoints for fetching Bukalemun image URL and bundle product data
|
|
9
|
+
- 0e05135: ZERO-3244: Encode URL search parameters
|
|
10
|
+
|
|
3
11
|
## 1.83.0
|
|
4
12
|
|
|
5
13
|
## 1.82.0
|
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,
|
|
915
|
+
useSendSmsMutation,
|
|
916
|
+
useVerifySmsMutation,
|
|
895
917
|
useResetCheckoutStateQuery
|
|
896
918
|
} = checkoutApi;
|
package/data/client/misc.ts
CHANGED
|
@@ -92,6 +92,29 @@ export const miscApi = api.injectEndpoints({
|
|
|
92
92
|
transformResponse: (response: { menu: MenuItemType[] }) => {
|
|
93
93
|
return response.menu;
|
|
94
94
|
}
|
|
95
|
+
}),
|
|
96
|
+
getBukalemunImageUrl: builder.query<
|
|
97
|
+
any,
|
|
98
|
+
{ current_chapter: string; sku: string; selected_attributes: any }
|
|
99
|
+
>({
|
|
100
|
+
query: ({ current_chapter, sku, selected_attributes }) => {
|
|
101
|
+
const data = {
|
|
102
|
+
...selected_attributes,
|
|
103
|
+
current_chapter,
|
|
104
|
+
sku
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const params = new URLSearchParams(data);
|
|
108
|
+
|
|
109
|
+
return {
|
|
110
|
+
url: buildClientRequestUrl(
|
|
111
|
+
misc.bukalemunImageUrl(params.toString()),
|
|
112
|
+
{
|
|
113
|
+
responseType: 'json'
|
|
114
|
+
}
|
|
115
|
+
)
|
|
116
|
+
};
|
|
117
|
+
}
|
|
95
118
|
})
|
|
96
119
|
}),
|
|
97
120
|
overrideExisting: true
|
|
@@ -102,5 +125,6 @@ export const {
|
|
|
102
125
|
useEmailSubscriptionMutation,
|
|
103
126
|
useSetLanguageMutation,
|
|
104
127
|
useGetWidgetQuery,
|
|
105
|
-
useGetMenuQuery
|
|
128
|
+
useGetMenuQuery,
|
|
129
|
+
useGetBukalemunImageUrlQuery
|
|
106
130
|
} = miscApi;
|
package/data/client/product.ts
CHANGED
|
@@ -75,6 +75,21 @@ export const productApi = api.injectEndpoints({
|
|
|
75
75
|
query: (productPk) => ({
|
|
76
76
|
url: buildClientRequestUrl(product.installments(productPk))
|
|
77
77
|
})
|
|
78
|
+
}),
|
|
79
|
+
getBundleProductData: build.query<
|
|
80
|
+
any,
|
|
81
|
+
{ productPk: string; queryString: string }
|
|
82
|
+
>({
|
|
83
|
+
query: ({ productPk, queryString }) => {
|
|
84
|
+
return {
|
|
85
|
+
url: buildClientRequestUrl(
|
|
86
|
+
product.bundleProduct(productPk, queryString),
|
|
87
|
+
{
|
|
88
|
+
responseType: 'json'
|
|
89
|
+
}
|
|
90
|
+
)
|
|
91
|
+
};
|
|
92
|
+
}
|
|
78
93
|
})
|
|
79
94
|
}),
|
|
80
95
|
overrideExisting: true
|
|
@@ -85,5 +100,6 @@ export const {
|
|
|
85
100
|
useGetProductByPkQuery,
|
|
86
101
|
useGetRetailStoreStockMutation,
|
|
87
102
|
useGetInstallmentsQuery,
|
|
88
|
-
useGetProductByParamsQuery
|
|
103
|
+
useGetProductByParamsQuery,
|
|
104
|
+
useGetBundleProductDataQuery
|
|
89
105
|
} = productApi;
|
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 = {
|
|
@@ -160,7 +162,8 @@ export const misc = {
|
|
|
160
162
|
parent ? `&parent=${parent}` : ''
|
|
161
163
|
}`,
|
|
162
164
|
cmsSeo: (slug: string | string[]) => `/cms/seo/?url=${slug ? slug : '/'}`,
|
|
163
|
-
setCurrency: '/users/activate-currency/'
|
|
165
|
+
setCurrency: '/users/activate-currency/',
|
|
166
|
+
bukalemunImageUrl: (params: string) => `/bukalemun/?${params}`
|
|
164
167
|
};
|
|
165
168
|
|
|
166
169
|
export const product = {
|
|
@@ -174,7 +177,9 @@ export const product = {
|
|
|
174
177
|
slug: (slug: string) => `/${slug}/`,
|
|
175
178
|
categoryUrl: (pk: number) => `/products/${pk}/category_nodes/?limit=1`,
|
|
176
179
|
breadcrumbUrl: (menuitemmodel: string) =>
|
|
177
|
-
`/menus/generate_breadcrumb/?item=${menuitemmodel}&generator_name=menu_item
|
|
180
|
+
`/menus/generate_breadcrumb/?item=${menuitemmodel}&generator_name=menu_item`,
|
|
181
|
+
bundleProduct: (productPk: string, queryString: string) =>
|
|
182
|
+
`/bundle-product/${productPk}/?${queryString}`
|
|
178
183
|
};
|
|
179
184
|
|
|
180
185
|
export const wishlist = {
|
package/middlewares/default.ts
CHANGED
|
@@ -285,7 +285,9 @@ const withPzDefault =
|
|
|
285
285
|
url.pathname =
|
|
286
286
|
url.pathname +
|
|
287
287
|
(/\/$/.test(url.pathname) ? '' : '/') +
|
|
288
|
-
`searchparams|${
|
|
288
|
+
`searchparams|${encodeURIComponent(
|
|
289
|
+
url.searchParams.toString()
|
|
290
|
+
)}`;
|
|
289
291
|
}
|
|
290
292
|
|
|
291
293
|
if (
|
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.84.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.84.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",
|
|
@@ -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
|
+
};
|