@akinon/next 1.13.1 → 1.14.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/.editorconfig +7 -0
- package/.eslintrc.js +40 -40
- package/.prettierrc +13 -13
- package/CHANGELOG.md +13 -0
- package/api/auth.ts +231 -231
- package/api/cache.ts +44 -44
- package/api/client.ts +174 -174
- package/api/logout.ts +42 -42
- package/assets/styles/index.scss +28 -28
- package/bin/pz-check-dependencies.js +98 -98
- package/bin/pz-install-plugins.js +33 -33
- package/bin/pz-install-theme.js +58 -58
- package/bin/pz-postbuild.js +1 -1
- package/bin/pz-postdev.js +1 -1
- package/bin/pz-postinstall.js +6 -6
- package/bin/pz-poststart.js +1 -1
- package/bin/pz-prebuild.js +4 -4
- package/bin/pz-predev.js +4 -4
- package/bin/pz-prestart.js +1 -1
- package/bin/run-script.js +44 -44
- package/components/accordion.tsx +52 -0
- package/components/button.tsx +46 -0
- package/components/client-root.tsx +19 -19
- package/components/icon.tsx +18 -18
- package/components/image.tsx +133 -133
- package/components/index.ts +17 -1
- package/components/input.tsx +110 -0
- package/components/lazy-component.tsx +33 -33
- package/components/loader-spinner.tsx +23 -23
- package/components/mobile-app-toggler.tsx +26 -26
- package/components/oauth-login.tsx +24 -24
- package/components/plugin-module.tsx +11 -8
- package/components/price.tsx +55 -0
- package/components/pz-providers.tsx +24 -24
- package/components/pz-root.tsx +21 -21
- package/components/radio.tsx +18 -18
- package/components/react-portal.tsx +45 -45
- package/components/redirect-three-d/content/index.tsx +74 -74
- package/components/redirect-three-d/index.tsx +17 -17
- package/components/selected-payment-option-view.tsx +7 -0
- package/components/trans.tsx +39 -39
- package/data/client/account.ts +208 -208
- package/data/client/address.ts +107 -107
- package/data/client/api.ts +85 -84
- package/data/client/b2b.ts +106 -106
- package/data/client/basket.ts +82 -82
- package/data/client/checkout.ts +516 -479
- package/data/client/misc.ts +101 -101
- package/data/client/product.ts +89 -89
- package/data/client/user.ts +99 -99
- package/data/client/wishlist.ts +118 -88
- package/data/server/category.ts +132 -128
- package/data/server/flatpage.ts +21 -21
- package/data/server/form.ts +22 -22
- package/data/server/index.ts +10 -10
- package/data/server/landingpage.ts +24 -24
- package/data/server/list.ts +67 -62
- package/data/server/menu.ts +35 -35
- package/data/server/product.ts +86 -86
- package/data/server/seo.ts +48 -48
- package/data/server/special-page.ts +47 -47
- package/data/server/widget.ts +27 -27
- package/data/urls.ts +221 -210
- package/hocs/client/index.ts +1 -1
- package/hocs/client/with-segment-defaults.tsx +25 -25
- package/hocs/server/index.ts +1 -1
- package/hocs/server/with-segment-defaults.tsx +85 -85
- package/hooks/index.ts +10 -10
- package/hooks/use-captcha.tsx +76 -76
- package/hooks/use-common-product-attributes.ts +36 -36
- package/hooks/use-debounce.ts +20 -20
- package/hooks/use-localization.ts +78 -78
- package/hooks/use-media-query.ts +36 -36
- package/hooks/use-mobile-iframe-handler.ts +23 -23
- package/hooks/use-on-click-outside.tsx +28 -28
- package/hooks/use-payment-options.ts +2 -1
- package/hooks/use-router.ts +45 -45
- package/hooks/use-translation.ts +14 -14
- package/lib/cache.ts +215 -215
- package/localization/index.ts +5 -5
- package/localization/provider.tsx +58 -58
- package/middlewares/currency.ts +100 -100
- package/middlewares/default.ts +256 -256
- package/middlewares/index.ts +29 -29
- package/middlewares/locale.ts +68 -68
- package/middlewares/oauth-login.ts +79 -79
- package/middlewares/pretty-url.ts +104 -104
- package/middlewares/redirection-payment.ts +160 -160
- package/middlewares/three-d-redirection.ts +159 -159
- package/middlewares/url-redirection.ts +65 -65
- package/package.json +2 -2
- package/plugins.js +2 -1
- package/redux/hooks.ts +7 -7
- package/redux/middlewares/checkout.ts +265 -260
- package/redux/middlewares/index.ts +50 -50
- package/redux/reducers/checkout.ts +184 -171
- package/redux/reducers/config.ts +28 -28
- package/redux/reducers/header.ts +59 -59
- package/redux/reducers/index.ts +14 -14
- package/redux/reducers/root.ts +61 -61
- package/sentry/index.ts +27 -27
- package/tailwind/rtl.js +137 -137
- package/types/commerce/account.ts +64 -64
- package/types/commerce/address.ts +94 -94
- package/types/commerce/b2b.ts +117 -117
- package/types/commerce/basket.ts +43 -43
- package/types/commerce/category.ts +114 -114
- package/types/commerce/checkout.ts +143 -136
- package/types/commerce/flatpage.ts +7 -7
- package/types/commerce/form.ts +66 -66
- package/types/commerce/index.ts +12 -12
- package/types/commerce/landingpage.ts +7 -7
- package/types/commerce/misc.ts +127 -127
- package/types/commerce/order.ts +119 -119
- package/types/commerce/product.ts +109 -109
- package/types/commerce/widget.ts +28 -28
- package/types/gtm.ts +16 -16
- package/types/index.ts +274 -237
- package/types/metadata.ts +7 -7
- package/types/next-auth.d.ts +24 -24
- package/utils/app-fetch.ts +69 -69
- package/utils/deep-merge.js +24 -24
- package/utils/generate-commerce-search-params.ts +22 -22
- package/utils/get-currency.ts +29 -29
- package/utils/image-loader.ts +31 -31
- package/utils/index.ts +150 -150
- package/utils/localization.ts +29 -29
- package/utils/log.ts +138 -138
- package/utils/menu-generator.ts +27 -27
- package/utils/mobile-3d-iframe.ts +77 -77
- package/utils/server-translation.ts +57 -57
- package/utils/server-variables.ts +9 -9
- package/with-pz-config.js +94 -94
|
@@ -1,260 +1,265 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { Middleware } from '@reduxjs/toolkit';
|
|
4
|
-
import {
|
|
5
|
-
setAddressList,
|
|
6
|
-
setBankAccounts,
|
|
7
|
-
setCanGuestPurchase,
|
|
8
|
-
setCardType,
|
|
9
|
-
setDeliveryOptions,
|
|
10
|
-
setErrors,
|
|
11
|
-
setHasGiftBox,
|
|
12
|
-
setInstallmentOptions,
|
|
13
|
-
setLoyaltyBalance,
|
|
14
|
-
setPaymentChoices,
|
|
15
|
-
setPaymentOptions,
|
|
16
|
-
setPreOrder,
|
|
17
|
-
setRetailStores,
|
|
18
|
-
setShippingOptions,
|
|
19
|
-
setShippingStepCompleted
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import
|
|
26
|
-
import
|
|
27
|
-
import {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
action?.meta?.arg?.endpointName === '
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
preOrder.
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
const
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
urlObj
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
};
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { Middleware } from '@reduxjs/toolkit';
|
|
4
|
+
import {
|
|
5
|
+
setAddressList,
|
|
6
|
+
setBankAccounts,
|
|
7
|
+
setCanGuestPurchase,
|
|
8
|
+
setCardType,
|
|
9
|
+
setDeliveryOptions,
|
|
10
|
+
setErrors,
|
|
11
|
+
setHasGiftBox,
|
|
12
|
+
setInstallmentOptions,
|
|
13
|
+
setLoyaltyBalance,
|
|
14
|
+
setPaymentChoices,
|
|
15
|
+
setPaymentOptions,
|
|
16
|
+
setPreOrder,
|
|
17
|
+
setRetailStores,
|
|
18
|
+
setShippingOptions,
|
|
19
|
+
setShippingStepCompleted,
|
|
20
|
+
setCreditPaymentOptions
|
|
21
|
+
} from '../../redux/reducers/checkout';
|
|
22
|
+
import { RootState, TypedDispatch } from 'redux/store';
|
|
23
|
+
import { checkoutApi } from '../../data/client/checkout';
|
|
24
|
+
import { CheckoutContext, PreOrder } from '../../types';
|
|
25
|
+
import { getCookie, setCookie } from '../../utils';
|
|
26
|
+
import settings from 'settings';
|
|
27
|
+
import { LocaleUrlStrategy } from '../../localization';
|
|
28
|
+
import { showMobile3dIframe } from '../../utils/mobile-3d-iframe';
|
|
29
|
+
|
|
30
|
+
interface CheckoutResult {
|
|
31
|
+
payload: {
|
|
32
|
+
errors?: any;
|
|
33
|
+
pre_order?: PreOrder;
|
|
34
|
+
context_list?: CheckoutContext[];
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
interface MiddlewareParams {
|
|
39
|
+
getState: () => RootState;
|
|
40
|
+
dispatch: TypedDispatch;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export const errorMiddleware: Middleware = ({ dispatch }: MiddlewareParams) => {
|
|
44
|
+
return (next) => (action) => {
|
|
45
|
+
const result: CheckoutResult = next(action);
|
|
46
|
+
const errors = result?.payload?.errors;
|
|
47
|
+
|
|
48
|
+
if (errors) {
|
|
49
|
+
dispatch(setErrors(errors));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return result;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export const preOrderMiddleware: Middleware = ({
|
|
57
|
+
getState,
|
|
58
|
+
dispatch
|
|
59
|
+
}: MiddlewareParams) => {
|
|
60
|
+
return (next) => (action) => {
|
|
61
|
+
const result: CheckoutResult = next(action);
|
|
62
|
+
const preOrder = result?.payload?.pre_order;
|
|
63
|
+
|
|
64
|
+
if (
|
|
65
|
+
!preOrder ||
|
|
66
|
+
action?.meta?.arg?.endpointName === 'guestLogin' ||
|
|
67
|
+
action?.meta?.arg?.endpointName === 'getCheckoutLoyaltyBalance'
|
|
68
|
+
) {
|
|
69
|
+
return result;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const {
|
|
73
|
+
deliveryOptions,
|
|
74
|
+
addressList: addresses,
|
|
75
|
+
shippingOptions,
|
|
76
|
+
paymentOptions,
|
|
77
|
+
installmentOptions
|
|
78
|
+
} = getState().checkout;
|
|
79
|
+
const { endpoints: apiEndpoints } = checkoutApi;
|
|
80
|
+
|
|
81
|
+
if (preOrder.is_redirected) {
|
|
82
|
+
const contextList = result?.payload?.context_list;
|
|
83
|
+
|
|
84
|
+
if (
|
|
85
|
+
contextList.find(
|
|
86
|
+
(ctx) => ctx.page_name === 'RedirectionPaymentSelectedPage'
|
|
87
|
+
)
|
|
88
|
+
) {
|
|
89
|
+
dispatch(
|
|
90
|
+
apiEndpoints.setPaymentOption.initiate(preOrder.payment_option?.pk)
|
|
91
|
+
);
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
dispatch(setPreOrder(preOrder));
|
|
97
|
+
|
|
98
|
+
if (!preOrder.delivery_option && deliveryOptions.length > 0) {
|
|
99
|
+
dispatch(
|
|
100
|
+
apiEndpoints.setDeliveryOption.initiate(
|
|
101
|
+
deliveryOptions.find((opt) => opt.delivery_option_type === 'customer')
|
|
102
|
+
?.pk
|
|
103
|
+
)
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (
|
|
108
|
+
(!preOrder.shipping_address || !preOrder.billing_address) &&
|
|
109
|
+
addresses.length > 0 &&
|
|
110
|
+
preOrder.delivery_option?.delivery_option_type === 'customer'
|
|
111
|
+
) {
|
|
112
|
+
dispatch(
|
|
113
|
+
apiEndpoints.setAddresses.initiate({
|
|
114
|
+
shippingAddressPk: addresses[0].pk,
|
|
115
|
+
billingAddressPk: addresses[0].pk
|
|
116
|
+
})
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (
|
|
121
|
+
shippingOptions.length > 0 &&
|
|
122
|
+
(!preOrder.shipping_option ||
|
|
123
|
+
!shippingOptions.find((opt) => opt.pk === preOrder.shipping_option?.pk))
|
|
124
|
+
) {
|
|
125
|
+
dispatch(apiEndpoints.setShippingOption.initiate(shippingOptions[0].pk));
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (!preOrder.payment_option && paymentOptions.length > 0) {
|
|
129
|
+
dispatch(apiEndpoints.setPaymentOption.initiate(paymentOptions[0].pk));
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (!preOrder.installment && installmentOptions.length > 0) {
|
|
133
|
+
dispatch(
|
|
134
|
+
apiEndpoints.setInstallmentOption.initiate(installmentOptions[0].pk)
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
dispatch(
|
|
139
|
+
setShippingStepCompleted(
|
|
140
|
+
[
|
|
141
|
+
preOrder.delivery_option?.delivery_option_type === 'retail_store'
|
|
142
|
+
? true
|
|
143
|
+
: preOrder.shipping_address?.pk,
|
|
144
|
+
preOrder.billing_address?.pk,
|
|
145
|
+
preOrder.shipping_option?.pk,
|
|
146
|
+
addresses.length > 0
|
|
147
|
+
].every(Boolean)
|
|
148
|
+
)
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
return result;
|
|
152
|
+
};
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
export const contextListMiddleware: Middleware = ({
|
|
156
|
+
dispatch,
|
|
157
|
+
getState
|
|
158
|
+
}: MiddlewareParams) => {
|
|
159
|
+
return (next) => (action) => {
|
|
160
|
+
const { isMobileApp } = getState().root;
|
|
161
|
+
const result: CheckoutResult = next(action);
|
|
162
|
+
|
|
163
|
+
if (result?.payload?.context_list) {
|
|
164
|
+
result.payload.context_list.forEach((context) => {
|
|
165
|
+
const redirectUrl = context.page_context.redirect_url;
|
|
166
|
+
|
|
167
|
+
if (redirectUrl) {
|
|
168
|
+
const currentLocale = getCookie('pz-locale');
|
|
169
|
+
|
|
170
|
+
let url = redirectUrl;
|
|
171
|
+
|
|
172
|
+
if (currentLocale && !redirectUrl.includes('/orders/redirection')) {
|
|
173
|
+
const { defaultLocaleValue, localeUrlStrategy } =
|
|
174
|
+
settings.localization;
|
|
175
|
+
|
|
176
|
+
url =
|
|
177
|
+
currentLocale === defaultLocaleValue &&
|
|
178
|
+
localeUrlStrategy !== LocaleUrlStrategy.ShowAllLocales
|
|
179
|
+
? redirectUrl
|
|
180
|
+
: `/${currentLocale}${redirectUrl}`;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const urlObj = new URL(url, window.location.origin);
|
|
184
|
+
urlObj.searchParams.set('t', new Date().getTime().toString());
|
|
185
|
+
|
|
186
|
+
if (
|
|
187
|
+
(isMobileApp ||
|
|
188
|
+
/iPad|iPhone|iPod|Android/i.test(navigator.userAgent)) &&
|
|
189
|
+
!settings.checkout?.iframeExcludedPaymentOptions?.includes(
|
|
190
|
+
result.payload?.pre_order?.payment_option?.slug
|
|
191
|
+
)
|
|
192
|
+
) {
|
|
193
|
+
showMobile3dIframe(urlObj.toString());
|
|
194
|
+
} else {
|
|
195
|
+
window.location.href = urlObj.toString();
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
if (context.page_context.has_gift_box) {
|
|
202
|
+
dispatch(setHasGiftBox(context.page_context.has_gift_box));
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
if (typeof context.page_context.can_guest_purchase === 'boolean') {
|
|
206
|
+
dispatch(
|
|
207
|
+
setCanGuestPurchase(context.page_context.can_guest_purchase)
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
if (context.page_context.delivery_options) {
|
|
212
|
+
dispatch(setDeliveryOptions(context.page_context.delivery_options));
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
if (context.page_context.addresses) {
|
|
216
|
+
dispatch(setAddressList(context.page_context.addresses));
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
if (context.page_context.shipping_options) {
|
|
220
|
+
dispatch(setShippingOptions(context.page_context.shipping_options));
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
if (context.page_context.payment_options) {
|
|
224
|
+
dispatch(setPaymentOptions(context.page_context.payment_options));
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
if (context.page_context.credit_payment_options) {
|
|
228
|
+
dispatch(setCreditPaymentOptions(context.page_context.credit_payment_options));
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
if (context.page_context.payment_choices) {
|
|
232
|
+
dispatch(setPaymentChoices(context.page_context.payment_choices));
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
if (context.page_context.bank_accounts) {
|
|
236
|
+
dispatch(setBankAccounts(context.page_context.bank_accounts));
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
if (
|
|
240
|
+
!result.payload.context_list.find(
|
|
241
|
+
(ctx) => ctx.page_name === 'DeliveryOptionSelectionPage'
|
|
242
|
+
)
|
|
243
|
+
) {
|
|
244
|
+
if (context.page_context.card_type) {
|
|
245
|
+
dispatch(setCardType(context.page_context.card_type));
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
if (context.page_context.installments) {
|
|
249
|
+
dispatch(setInstallmentOptions(context.page_context.installments));
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
if (context.page_context.balance) {
|
|
254
|
+
dispatch(setLoyaltyBalance(context.page_context.balance));
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
if (context.page_context.retail_stores) {
|
|
258
|
+
dispatch(setRetailStores(context.page_context.retail_stores));
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
return result;
|
|
264
|
+
};
|
|
265
|
+
};
|
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { signOut } from 'next-auth/react';
|
|
4
|
-
import { ROUTES } from 'routes';
|
|
5
|
-
import type { Middleware } from '@reduxjs/toolkit';
|
|
6
|
-
import {
|
|
7
|
-
errorMiddleware,
|
|
8
|
-
contextListMiddleware,
|
|
9
|
-
preOrderMiddleware
|
|
10
|
-
} from './checkout';
|
|
11
|
-
import { api } from '../../data/client/api';
|
|
12
|
-
import logger from '@akinon/next/utils/log';
|
|
13
|
-
|
|
14
|
-
export const rtkQueryResponseHandler: Middleware =
|
|
15
|
-
({ dispatch }) =>
|
|
16
|
-
(next) =>
|
|
17
|
-
(action) => {
|
|
18
|
-
return next(action);
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export const rtkQueryErrorHandler: Middleware =
|
|
22
|
-
() => (next) => async (action) => {
|
|
23
|
-
if (action?.payload?.status === 401) {
|
|
24
|
-
await signOut({
|
|
25
|
-
callbackUrl: `${ROUTES.AUTH}?callbackUrl=${window.location.pathname}`
|
|
26
|
-
});
|
|
27
|
-
logger.debug('Session expired: 401');
|
|
28
|
-
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (action?.payload?.status === 404) {
|
|
33
|
-
logger.warn(
|
|
34
|
-
`404 - Not Found. Endpoint: ${action.meta.arg.endpointName}, url: ${action.meta.baseQueryMeta.request.url}`
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return next(action);
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
const middlewares = [
|
|
42
|
-
api.middleware,
|
|
43
|
-
rtkQueryResponseHandler,
|
|
44
|
-
rtkQueryErrorHandler,
|
|
45
|
-
errorMiddleware,
|
|
46
|
-
preOrderMiddleware,
|
|
47
|
-
contextListMiddleware
|
|
48
|
-
];
|
|
49
|
-
|
|
50
|
-
export default middlewares;
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { signOut } from 'next-auth/react';
|
|
4
|
+
import { ROUTES } from 'routes';
|
|
5
|
+
import type { Middleware } from '@reduxjs/toolkit';
|
|
6
|
+
import {
|
|
7
|
+
errorMiddleware,
|
|
8
|
+
contextListMiddleware,
|
|
9
|
+
preOrderMiddleware
|
|
10
|
+
} from './checkout';
|
|
11
|
+
import { api } from '../../data/client/api';
|
|
12
|
+
import logger from '@akinon/next/utils/log';
|
|
13
|
+
|
|
14
|
+
export const rtkQueryResponseHandler: Middleware =
|
|
15
|
+
({ dispatch }) =>
|
|
16
|
+
(next) =>
|
|
17
|
+
(action) => {
|
|
18
|
+
return next(action);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const rtkQueryErrorHandler: Middleware =
|
|
22
|
+
() => (next) => async (action) => {
|
|
23
|
+
if (action?.payload?.status === 401) {
|
|
24
|
+
await signOut({
|
|
25
|
+
callbackUrl: `${ROUTES.AUTH}?callbackUrl=${window.location.pathname}`
|
|
26
|
+
});
|
|
27
|
+
logger.debug('Session expired: 401');
|
|
28
|
+
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (action?.payload?.status === 404) {
|
|
33
|
+
logger.warn(
|
|
34
|
+
`404 - Not Found. Endpoint: ${action.meta.arg.endpointName}, url: ${action.meta.baseQueryMeta.request.url}`
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return next(action);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const middlewares = [
|
|
42
|
+
api.middleware,
|
|
43
|
+
rtkQueryResponseHandler,
|
|
44
|
+
rtkQueryErrorHandler,
|
|
45
|
+
errorMiddleware,
|
|
46
|
+
preOrderMiddleware,
|
|
47
|
+
contextListMiddleware
|
|
48
|
+
];
|
|
49
|
+
|
|
50
|
+
export default middlewares;
|