@akinon/next 2.0.0-beta.2 → 2.0.0-beta.20
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/.eslintrc.js +12 -0
- package/CHANGELOG.md +377 -7
- package/__tests__/next-config.test.ts +83 -0
- package/__tests__/tsconfig.json +23 -0
- package/api/auth.ts +133 -44
- package/api/barcode-search.ts +59 -0
- package/api/cache.ts +41 -5
- package/api/client.ts +21 -4
- package/api/form.ts +85 -0
- package/api/image-proxy.ts +75 -0
- package/api/product-categories.ts +53 -0
- package/api/similar-product-list.ts +63 -0
- package/api/similar-products.ts +111 -0
- package/api/virtual-try-on.ts +382 -0
- package/assets/styles/index.scss +84 -0
- package/babel.config.js +6 -0
- package/bin/pz-generate-routes.js +115 -0
- package/bin/pz-prebuild.js +1 -0
- package/bin/pz-predev.js +1 -0
- package/bin/pz-run-tests.js +99 -0
- package/bin/run-prebuild-tests.js +46 -0
- package/components/accordion.tsx +20 -5
- package/components/button.tsx +51 -36
- package/components/client-root.tsx +138 -2
- package/components/file-input.tsx +65 -3
- package/components/index.ts +1 -0
- package/components/input.tsx +1 -1
- package/components/link.tsx +46 -16
- package/components/logger-popup.tsx +213 -0
- package/components/modal.tsx +32 -16
- package/components/plugin-module.tsx +62 -3
- package/components/price.tsx +2 -2
- package/components/select.tsx +1 -1
- package/components/selected-payment-option-view.tsx +21 -0
- package/components/theme-editor/blocks/accordion-block.tsx +136 -0
- package/components/theme-editor/blocks/block-renderer-registry.tsx +77 -0
- package/components/theme-editor/blocks/button-block.tsx +593 -0
- package/components/theme-editor/blocks/counter-block.tsx +348 -0
- package/components/theme-editor/blocks/divider-block.tsx +20 -0
- package/components/theme-editor/blocks/embed-block.tsx +208 -0
- package/components/theme-editor/blocks/group-block.tsx +116 -0
- package/components/theme-editor/blocks/hotspot-block.tsx +147 -0
- package/components/theme-editor/blocks/icon-block.tsx +230 -0
- package/components/theme-editor/blocks/image-block.tsx +137 -0
- package/components/theme-editor/blocks/image-gallery-block.tsx +269 -0
- package/components/theme-editor/blocks/input-block.tsx +123 -0
- package/components/theme-editor/blocks/link-block.tsx +216 -0
- package/components/theme-editor/blocks/lottie-block.tsx +325 -0
- package/components/theme-editor/blocks/map-block.tsx +89 -0
- package/components/theme-editor/blocks/slider-block.tsx +595 -0
- package/components/theme-editor/blocks/tab-block.tsx +10 -0
- package/components/theme-editor/blocks/text-block.tsx +52 -0
- package/components/theme-editor/blocks/video-block.tsx +122 -0
- package/components/theme-editor/components/action-toolbar.tsx +305 -0
- package/components/theme-editor/components/designer-overlay.tsx +74 -0
- package/components/theme-editor/components/with-designer-features.tsx +142 -0
- package/components/theme-editor/dynamic-font-loader.tsx +79 -0
- package/components/theme-editor/hooks/use-designer-features.tsx +100 -0
- package/components/theme-editor/hooks/use-external-designer.tsx +95 -0
- package/components/theme-editor/hooks/use-native-widget-data.ts +188 -0
- package/components/theme-editor/hooks/use-visibility-context.ts +27 -0
- package/components/theme-editor/placeholder-registry.ts +31 -0
- package/components/theme-editor/sections/before-after-section.tsx +245 -0
- package/components/theme-editor/sections/contact-form-section.tsx +563 -0
- package/components/theme-editor/sections/countdown-campaign-banner-section.tsx +433 -0
- package/components/theme-editor/sections/coupon-banner-section.tsx +710 -0
- package/components/theme-editor/sections/divider-section.tsx +62 -0
- package/components/theme-editor/sections/featured-product-spotlight-section.tsx +507 -0
- package/components/theme-editor/sections/find-in-store-section.tsx +1995 -0
- package/components/theme-editor/sections/hover-showcase-section.tsx +326 -0
- package/components/theme-editor/sections/image-hotspot-section.tsx +142 -0
- package/components/theme-editor/sections/installment-options-section.tsx +1065 -0
- package/components/theme-editor/sections/notification-banner-section.tsx +173 -0
- package/components/theme-editor/sections/order-tracking-lookup-section.tsx +1379 -0
- package/components/theme-editor/sections/posts-slider-section.tsx +472 -0
- package/components/theme-editor/sections/pre-order-launch-banner-section.tsx +663 -0
- package/components/theme-editor/sections/section-renderer-registry.tsx +89 -0
- package/components/theme-editor/sections/section-wrapper.tsx +135 -0
- package/components/theme-editor/sections/shipping-threshold-progress-section.tsx +586 -0
- package/components/theme-editor/sections/stats-counter-section.tsx +486 -0
- package/components/theme-editor/sections/tabs-section.tsx +578 -0
- package/components/theme-editor/theme-block.tsx +102 -0
- package/components/theme-editor/theme-placeholder-client.tsx +218 -0
- package/components/theme-editor/theme-placeholder-wrapper.tsx +732 -0
- package/components/theme-editor/theme-placeholder.tsx +288 -0
- package/components/theme-editor/theme-section.tsx +1224 -0
- package/components/theme-editor/theme-settings-context.tsx +13 -0
- package/components/theme-editor/utils/index.ts +792 -0
- package/components/theme-editor/utils/iterator-utils.ts +234 -0
- package/components/theme-editor/utils/publish-window.ts +86 -0
- package/components/theme-editor/utils/visibility-rules.ts +188 -0
- package/data/client/account.ts +17 -2
- package/data/client/api.ts +2 -0
- package/data/client/basket.ts +66 -5
- package/data/client/checkout.ts +391 -99
- package/data/client/misc.ts +38 -2
- package/data/client/product.ts +19 -2
- package/data/client/user.ts +16 -8
- package/data/server/category.ts +11 -9
- package/data/server/flatpage.ts +11 -4
- package/data/server/form.ts +15 -4
- package/data/server/landingpage.ts +11 -4
- package/data/server/list.ts +5 -4
- package/data/server/menu.ts +11 -3
- package/data/server/product.ts +111 -55
- package/data/server/seo.ts +14 -4
- package/data/server/special-page.ts +5 -4
- package/data/server/widget.ts +90 -5
- package/data/urls.ts +16 -5
- package/hocs/client/with-segment-defaults.tsx +2 -2
- package/hocs/server/with-segment-defaults.tsx +65 -20
- package/hooks/index.ts +4 -0
- package/hooks/use-localization.ts +24 -10
- package/hooks/use-logger-context.tsx +114 -0
- package/hooks/use-logger.ts +92 -0
- package/hooks/use-loyalty-availability.ts +21 -0
- package/hooks/use-payment-options.ts +2 -1
- package/hooks/use-pz-params.ts +37 -0
- package/hooks/use-router.ts +51 -14
- package/hooks/use-sentry-uncaught-errors.ts +24 -0
- package/instrumentation/index.ts +10 -1
- package/instrumentation/node.ts +2 -20
- package/jest.config.js +25 -0
- package/lib/cache-handler.mjs +534 -16
- package/lib/cache.ts +272 -37
- package/localization/index.ts +2 -1
- package/localization/provider.tsx +2 -5
- package/middlewares/bfcache-headers.ts +18 -0
- package/middlewares/checkout-provider.ts +1 -1
- package/middlewares/complete-gpay.ts +32 -26
- package/middlewares/complete-masterpass.ts +33 -26
- package/middlewares/complete-wallet.ts +182 -0
- package/middlewares/default.ts +360 -215
- package/middlewares/index.ts +10 -2
- package/middlewares/locale.ts +34 -11
- package/middlewares/masterpass-rest-callback.ts +230 -0
- package/middlewares/oauth-login.ts +200 -57
- package/middlewares/pretty-url.ts +21 -8
- package/middlewares/redirection-payment.ts +32 -26
- package/middlewares/saved-card-redirection.ts +33 -26
- package/middlewares/three-d-redirection.ts +32 -26
- package/middlewares/url-redirection.ts +11 -1
- package/middlewares/wallet-complete-redirection.ts +206 -0
- package/package.json +25 -10
- package/plugins.d.ts +19 -4
- package/plugins.js +10 -1
- package/redux/actions.ts +47 -0
- package/redux/middlewares/checkout.ts +63 -138
- package/redux/middlewares/index.ts +14 -10
- package/redux/middlewares/pre-order/address.ts +7 -2
- package/redux/middlewares/pre-order/attribute-based-shipping-option.ts +7 -1
- package/redux/middlewares/pre-order/data-source-shipping-option.ts +7 -1
- package/redux/middlewares/pre-order/delivery-option.ts +7 -1
- package/redux/middlewares/pre-order/index.ts +16 -10
- package/redux/middlewares/pre-order/installment-option.ts +8 -1
- package/redux/middlewares/pre-order/payment-option-reset.ts +37 -0
- package/redux/middlewares/pre-order/payment-option.ts +7 -1
- package/redux/middlewares/pre-order/pre-order-validation.ts +8 -3
- package/redux/middlewares/pre-order/redirection.ts +8 -2
- package/redux/middlewares/pre-order/set-pre-order.ts +6 -2
- package/redux/middlewares/pre-order/shipping-option.ts +7 -1
- package/redux/middlewares/pre-order/shipping-step.ts +5 -1
- package/redux/reducers/checkout.ts +23 -3
- package/redux/reducers/index.ts +11 -3
- package/redux/reducers/root.ts +7 -2
- package/redux/reducers/widget.ts +80 -0
- package/sentry/index.ts +69 -13
- package/tailwind/content.js +16 -0
- package/types/commerce/account.ts +5 -1
- package/types/commerce/checkout.ts +35 -1
- package/types/commerce/widget.ts +33 -0
- package/types/index.ts +101 -6
- package/types/next-auth.d.ts +2 -2
- package/types/widget.ts +80 -0
- package/utils/app-fetch.ts +7 -2
- package/utils/generate-commerce-search-params.ts +3 -2
- package/utils/get-checkout-path.ts +3 -0
- package/utils/get-root-hostname.ts +28 -0
- package/utils/index.ts +64 -10
- package/utils/localization.ts +4 -0
- package/utils/mobile-3d-iframe.ts +8 -2
- package/utils/override-middleware.ts +7 -12
- package/utils/pz-segments.ts +92 -0
- package/utils/redirect-ignore.ts +35 -0
- package/utils/redirect.ts +9 -3
- package/utils/redirection-iframe.ts +8 -2
- package/utils/widget-styles.ts +107 -0
- package/views/error-page.tsx +93 -0
- package/with-pz-config.js +13 -6
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { Middleware } from '@reduxjs/toolkit';
|
|
2
|
-
import { CheckoutResult } from '../../../types';
|
|
2
|
+
import { CheckoutResult, MiddlewareAction } from '../../../types';
|
|
3
3
|
|
|
4
4
|
export const preOrderValidationMiddleware: Middleware = () => {
|
|
5
5
|
return (next) => (action) => {
|
|
6
|
-
const result
|
|
6
|
+
const result = next(action) as CheckoutResult;
|
|
7
7
|
const preOrder = result?.payload?.pre_order;
|
|
8
|
+
const act = action as MiddlewareAction;
|
|
8
9
|
|
|
9
10
|
if (
|
|
10
11
|
!preOrder ||
|
|
11
12
|
['guestLogin', 'getCheckoutLoyaltyBalance'].includes(
|
|
12
|
-
|
|
13
|
+
act?.meta?.arg?.endpointName
|
|
13
14
|
)
|
|
14
15
|
) {
|
|
15
16
|
return result;
|
|
@@ -18,3 +19,7 @@ export const preOrderValidationMiddleware: Middleware = () => {
|
|
|
18
19
|
return result;
|
|
19
20
|
};
|
|
20
21
|
};
|
|
22
|
+
|
|
23
|
+
Object.defineProperty(preOrderValidationMiddleware, 'name', {
|
|
24
|
+
value: 'preOrderValidationMiddleware'
|
|
25
|
+
});
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Middleware } from '@reduxjs/toolkit';
|
|
2
|
-
import { MiddlewareParams } from '../../../types';
|
|
2
|
+
import { CheckoutResult, MiddlewareParams } from '../../../types';
|
|
3
3
|
import { checkoutApi } from '../../../data/client/checkout';
|
|
4
4
|
|
|
5
5
|
export const redirectionMiddleware: Middleware = ({
|
|
6
6
|
dispatch
|
|
7
7
|
}: MiddlewareParams) => {
|
|
8
8
|
return (next) => (action) => {
|
|
9
|
-
const result = next(action);
|
|
9
|
+
const result = next(action) as CheckoutResult;
|
|
10
10
|
const preOrder = result?.payload?.pre_order;
|
|
11
11
|
|
|
12
12
|
if (!preOrder) {
|
|
@@ -26,9 +26,15 @@ export const redirectionMiddleware: Middleware = ({
|
|
|
26
26
|
preOrder.payment_option?.pk
|
|
27
27
|
)
|
|
28
28
|
);
|
|
29
|
+
|
|
30
|
+
return null;
|
|
29
31
|
}
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
return result;
|
|
33
35
|
};
|
|
34
36
|
};
|
|
37
|
+
|
|
38
|
+
Object.defineProperty(redirectionMiddleware, 'name', {
|
|
39
|
+
value: 'redirectionMiddleware'
|
|
40
|
+
});
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Middleware } from '@reduxjs/toolkit';
|
|
2
|
-
import { MiddlewareParams } from '../../../types';
|
|
2
|
+
import { CheckoutResult, MiddlewareParams } from '../../../types';
|
|
3
3
|
import { setPreOrder } from '../../../redux/reducers/checkout';
|
|
4
4
|
|
|
5
5
|
export const setPreOrderMiddleware: Middleware = ({
|
|
6
6
|
dispatch
|
|
7
7
|
}: MiddlewareParams) => {
|
|
8
8
|
return (next) => (action) => {
|
|
9
|
-
const result = next(action);
|
|
9
|
+
const result = next(action) as CheckoutResult;
|
|
10
10
|
const preOrder = result?.payload?.pre_order;
|
|
11
11
|
|
|
12
12
|
if (preOrder) {
|
|
@@ -16,3 +16,7 @@ export const setPreOrderMiddleware: Middleware = ({
|
|
|
16
16
|
return result;
|
|
17
17
|
};
|
|
18
18
|
};
|
|
19
|
+
|
|
20
|
+
Object.defineProperty(setPreOrderMiddleware, 'name', {
|
|
21
|
+
value: 'setPreOrderMiddleware'
|
|
22
|
+
});
|
|
@@ -7,7 +7,7 @@ export const shippingOptionMiddleware: Middleware = ({
|
|
|
7
7
|
dispatch
|
|
8
8
|
}: MiddlewareParams) => {
|
|
9
9
|
return (next) => (action) => {
|
|
10
|
-
const result
|
|
10
|
+
const result = next(action) as CheckoutResult;
|
|
11
11
|
const preOrder = result?.payload?.pre_order;
|
|
12
12
|
|
|
13
13
|
if (!preOrder) {
|
|
@@ -30,9 +30,15 @@ export const shippingOptionMiddleware: Middleware = ({
|
|
|
30
30
|
dispatch(
|
|
31
31
|
apiEndpoints.setShippingOption.initiate(defaultShippingOption)
|
|
32
32
|
);
|
|
33
|
+
|
|
34
|
+
return null;
|
|
33
35
|
}
|
|
34
36
|
}
|
|
35
37
|
|
|
36
38
|
return result;
|
|
37
39
|
};
|
|
38
40
|
};
|
|
41
|
+
|
|
42
|
+
Object.defineProperty(shippingOptionMiddleware, 'name', {
|
|
43
|
+
value: 'shippingOptionMiddleware'
|
|
44
|
+
});
|
|
@@ -7,7 +7,7 @@ export const shippingStepMiddleware: Middleware = ({
|
|
|
7
7
|
dispatch
|
|
8
8
|
}: MiddlewareParams) => {
|
|
9
9
|
return (next) => (action) => {
|
|
10
|
-
const result
|
|
10
|
+
const result = next(action) as CheckoutResult;
|
|
11
11
|
const preOrder = result?.payload?.pre_order;
|
|
12
12
|
|
|
13
13
|
if (!preOrder) {
|
|
@@ -32,3 +32,7 @@ export const shippingStepMiddleware: Middleware = ({
|
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
34
|
};
|
|
35
|
+
|
|
36
|
+
Object.defineProperty(shippingStepMiddleware, 'name', {
|
|
37
|
+
value: 'shippingStepMiddleware'
|
|
38
|
+
});
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
CreditCardType,
|
|
10
10
|
DeliveryOption,
|
|
11
11
|
InstallmentOption,
|
|
12
|
+
LoyaltyBalanceItem,
|
|
12
13
|
PaymentChoice,
|
|
13
14
|
PaymentOption,
|
|
14
15
|
CheckoutCreditPaymentOption,
|
|
@@ -40,6 +41,7 @@ export interface CheckoutState {
|
|
|
40
41
|
shippingOptions: ShippingOption[];
|
|
41
42
|
dataSourceShippingOptions: DataSource[];
|
|
42
43
|
paymentOptions: PaymentOption[];
|
|
44
|
+
unavailablePaymentOptions: PaymentOption[];
|
|
43
45
|
creditPaymentOptions: CheckoutCreditPaymentOption[];
|
|
44
46
|
selectedCreditPaymentPk: number;
|
|
45
47
|
paymentChoices: PaymentChoice[];
|
|
@@ -48,6 +50,7 @@ export interface CheckoutState {
|
|
|
48
50
|
bankAccounts: BankAccount[];
|
|
49
51
|
selectedBankAccountPk: number;
|
|
50
52
|
loyaltyBalance?: string;
|
|
53
|
+
loyaltyBalances?: LoyaltyBalanceItem[];
|
|
51
54
|
retailStores: RetailStore[];
|
|
52
55
|
attributeBasedShippingOptions: AttributeBasedShippingOption[];
|
|
53
56
|
selectedShippingOptions: Record<string, number>;
|
|
@@ -60,6 +63,8 @@ export interface CheckoutState {
|
|
|
60
63
|
countryCode: string;
|
|
61
64
|
currencyCode: string;
|
|
62
65
|
version: string;
|
|
66
|
+
public_key: string;
|
|
67
|
+
[key: string]: any;
|
|
63
68
|
};
|
|
64
69
|
detail: {
|
|
65
70
|
label: string;
|
|
@@ -70,6 +75,7 @@ export interface CheckoutState {
|
|
|
70
75
|
};
|
|
71
76
|
supportedMethods: string;
|
|
72
77
|
};
|
|
78
|
+
payOnDeliveryOtpModalActive: boolean;
|
|
73
79
|
}
|
|
74
80
|
|
|
75
81
|
const initialState: CheckoutState = {
|
|
@@ -93,6 +99,7 @@ const initialState: CheckoutState = {
|
|
|
93
99
|
shippingOptions: [],
|
|
94
100
|
dataSourceShippingOptions: [],
|
|
95
101
|
paymentOptions: [],
|
|
102
|
+
unavailablePaymentOptions: [],
|
|
96
103
|
creditPaymentOptions: [],
|
|
97
104
|
selectedCreditPaymentPk: null,
|
|
98
105
|
paymentChoices: [],
|
|
@@ -103,7 +110,8 @@ const initialState: CheckoutState = {
|
|
|
103
110
|
retailStores: [],
|
|
104
111
|
attributeBasedShippingOptions: [],
|
|
105
112
|
selectedShippingOptions: {},
|
|
106
|
-
hepsipayAvailability: false
|
|
113
|
+
hepsipayAvailability: false,
|
|
114
|
+
payOnDeliveryOtpModalActive: false
|
|
107
115
|
};
|
|
108
116
|
|
|
109
117
|
const checkoutSlice = createSlice({
|
|
@@ -155,6 +163,9 @@ const checkoutSlice = createSlice({
|
|
|
155
163
|
setPaymentOptions(state, { payload }) {
|
|
156
164
|
state.paymentOptions = payload;
|
|
157
165
|
},
|
|
166
|
+
setUnavailablePaymentOptions(state, { payload }) {
|
|
167
|
+
state.unavailablePaymentOptions = payload;
|
|
168
|
+
},
|
|
158
169
|
setPaymentChoices(state, { payload }) {
|
|
159
170
|
state.paymentChoices = payload;
|
|
160
171
|
},
|
|
@@ -179,6 +190,9 @@ const checkoutSlice = createSlice({
|
|
|
179
190
|
setLoyaltyBalance(state, { payload }) {
|
|
180
191
|
state.loyaltyBalance = payload;
|
|
181
192
|
},
|
|
193
|
+
setLoyaltyBalances(state, { payload }) {
|
|
194
|
+
state.loyaltyBalances = payload;
|
|
195
|
+
},
|
|
182
196
|
setRetailStores(state, { payload }) {
|
|
183
197
|
state.retailStores = payload;
|
|
184
198
|
},
|
|
@@ -193,6 +207,9 @@ const checkoutSlice = createSlice({
|
|
|
193
207
|
},
|
|
194
208
|
setWalletPaymentData(state, { payload }) {
|
|
195
209
|
state.walletPaymentData = payload;
|
|
210
|
+
},
|
|
211
|
+
setPayOnDeliveryOtpModalActive(state, { payload }) {
|
|
212
|
+
state.payOnDeliveryOtpModalActive = payload;
|
|
196
213
|
}
|
|
197
214
|
}
|
|
198
215
|
});
|
|
@@ -213,19 +230,22 @@ export const {
|
|
|
213
230
|
setShippingOptions,
|
|
214
231
|
setDataSourceShippingOptions,
|
|
215
232
|
setPaymentOptions,
|
|
233
|
+
setUnavailablePaymentOptions,
|
|
234
|
+
setPaymentChoices,
|
|
216
235
|
setCreditPaymentOptions,
|
|
217
236
|
setSelectedCreditPaymentPk,
|
|
218
|
-
setPaymentChoices,
|
|
219
237
|
setCardType,
|
|
220
238
|
setInstallmentOptions,
|
|
221
239
|
setBankAccounts,
|
|
222
240
|
setSelectedBankAccountPk,
|
|
223
241
|
setLoyaltyBalance,
|
|
242
|
+
setLoyaltyBalances,
|
|
224
243
|
setRetailStores,
|
|
225
244
|
setAttributeBasedShippingOptions,
|
|
226
245
|
setSelectedShippingOptions,
|
|
227
246
|
setHepsipayAvailability,
|
|
228
|
-
setWalletPaymentData
|
|
247
|
+
setWalletPaymentData,
|
|
248
|
+
setPayOnDeliveryOtpModalActive
|
|
229
249
|
} = checkoutSlice.actions;
|
|
230
250
|
|
|
231
251
|
export default checkoutSlice.reducer;
|
package/redux/reducers/index.ts
CHANGED
|
@@ -2,12 +2,17 @@ import rootReducer from './root';
|
|
|
2
2
|
import checkoutReducer from './checkout';
|
|
3
3
|
import configReducer from './config';
|
|
4
4
|
import headerReducer from './header';
|
|
5
|
+
import widgetReducer from './widget';
|
|
5
6
|
import { api } from '../../data/client/api';
|
|
6
7
|
|
|
7
8
|
// Plugin reducers
|
|
8
9
|
import { masterpassReducer } from '@akinon/pz-masterpass';
|
|
9
10
|
import { otpReducer } from '@akinon/pz-otp';
|
|
10
11
|
import { savedCardReducer } from '@akinon/pz-saved-card';
|
|
12
|
+
import cyberSourceUcReducer from '@akinon/pz-cybersource-uc/src/redux/reducer';
|
|
13
|
+
import { masterpassRestReducer } from '@akinon/pz-masterpass-rest';
|
|
14
|
+
|
|
15
|
+
const fallbackReducer = (state = {}) => state;
|
|
11
16
|
|
|
12
17
|
const reducers = {
|
|
13
18
|
[api.reducerPath]: api.reducer,
|
|
@@ -15,9 +20,12 @@ const reducers = {
|
|
|
15
20
|
checkout: checkoutReducer,
|
|
16
21
|
config: configReducer,
|
|
17
22
|
header: headerReducer,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
23
|
+
widget: widgetReducer,
|
|
24
|
+
masterpass: masterpassReducer || fallbackReducer,
|
|
25
|
+
otp: otpReducer || fallbackReducer,
|
|
26
|
+
savedCard: savedCardReducer || fallbackReducer,
|
|
27
|
+
cybersource_uc: cyberSourceUcReducer || fallbackReducer,
|
|
28
|
+
masterpassRest: masterpassRestReducer || fallbackReducer
|
|
21
29
|
};
|
|
22
30
|
|
|
23
31
|
export default reducers;
|
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;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { createSlice, PayloadAction } from '@reduxjs/toolkit';
|
|
2
|
+
import { WidgetComponentData, WidgetDataSource } from '../../types/widget';
|
|
3
|
+
|
|
4
|
+
export interface WidgetState {
|
|
5
|
+
designMode: boolean;
|
|
6
|
+
responsive: string;
|
|
7
|
+
components: WidgetComponentData[];
|
|
8
|
+
placeholders: {
|
|
9
|
+
slug: string;
|
|
10
|
+
widgetSlugs: string[];
|
|
11
|
+
}[];
|
|
12
|
+
selectedPlaceholder?: string;
|
|
13
|
+
selectedWidget?: string;
|
|
14
|
+
selectedComponentId?: string;
|
|
15
|
+
draggingActive?: boolean;
|
|
16
|
+
dataSources: WidgetDataSource[];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const initialState: WidgetState = {
|
|
20
|
+
designMode: true,
|
|
21
|
+
responsive: 'mobile',
|
|
22
|
+
components: [],
|
|
23
|
+
placeholders: [],
|
|
24
|
+
selectedPlaceholder: undefined,
|
|
25
|
+
selectedWidget: undefined,
|
|
26
|
+
selectedComponentId: undefined,
|
|
27
|
+
draggingActive: false,
|
|
28
|
+
dataSources: []
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const widgetSlice = createSlice({
|
|
32
|
+
name: 'widget',
|
|
33
|
+
initialState,
|
|
34
|
+
reducers: {
|
|
35
|
+
setDesignMode(state, { payload }: PayloadAction<boolean>) {
|
|
36
|
+
state.designMode = payload;
|
|
37
|
+
},
|
|
38
|
+
setResponsive(state, { payload }: PayloadAction<string>) {
|
|
39
|
+
state.responsive = payload;
|
|
40
|
+
},
|
|
41
|
+
setComponents(state, { payload }: PayloadAction<WidgetComponentData[]>) {
|
|
42
|
+
state.components = payload;
|
|
43
|
+
},
|
|
44
|
+
setPlaceholders(
|
|
45
|
+
state,
|
|
46
|
+
{ payload }: PayloadAction<WidgetState['placeholders']>
|
|
47
|
+
) {
|
|
48
|
+
state.placeholders = payload;
|
|
49
|
+
},
|
|
50
|
+
setSelectedPlaceholder(state, { payload }: PayloadAction<string>) {
|
|
51
|
+
state.selectedPlaceholder = payload;
|
|
52
|
+
},
|
|
53
|
+
setSelectedWidget(state, { payload }: PayloadAction<string>) {
|
|
54
|
+
state.selectedWidget = payload;
|
|
55
|
+
},
|
|
56
|
+
setSelectedComponentId(state, { payload }: PayloadAction<string>) {
|
|
57
|
+
state.selectedComponentId = payload;
|
|
58
|
+
},
|
|
59
|
+
setDraggingActive(state, { payload }: PayloadAction<boolean>) {
|
|
60
|
+
state.draggingActive = payload;
|
|
61
|
+
},
|
|
62
|
+
setDataSources(state, { payload }: PayloadAction<WidgetDataSource[]>) {
|
|
63
|
+
state.dataSources = payload;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
export const {
|
|
69
|
+
setDesignMode,
|
|
70
|
+
setResponsive,
|
|
71
|
+
setComponents,
|
|
72
|
+
setPlaceholders,
|
|
73
|
+
setSelectedPlaceholder,
|
|
74
|
+
setSelectedWidget,
|
|
75
|
+
setSelectedComponentId,
|
|
76
|
+
setDraggingActive,
|
|
77
|
+
setDataSources
|
|
78
|
+
} = widgetSlice.actions;
|
|
79
|
+
|
|
80
|
+
export default widgetSlice.reducer;
|
package/sentry/index.ts
CHANGED
|
@@ -1,29 +1,85 @@
|
|
|
1
1
|
import * as Sentry from '@sentry/nextjs';
|
|
2
2
|
|
|
3
|
-
const SENTRY_DSN: string =
|
|
3
|
+
const SENTRY_DSN: string | undefined =
|
|
4
4
|
process.env.SENTRY_DSN || process.env.NEXT_PUBLIC_SENTRY_DSN;
|
|
5
5
|
|
|
6
|
+
export enum ClientLogType {
|
|
7
|
+
UNCAUGHT_ERROR_PAGE = 'UNCAUGHT_ERROR_PAGE',
|
|
8
|
+
CHECKOUT = 'CHECKOUT'
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const ALLOWED_CLIENT_LOG_TYPES: ClientLogType[] = [
|
|
12
|
+
ClientLogType.UNCAUGHT_ERROR_PAGE,
|
|
13
|
+
ClientLogType.CHECKOUT
|
|
14
|
+
];
|
|
15
|
+
|
|
16
|
+
const isNetworkError = (exception: unknown): boolean => {
|
|
17
|
+
if (!(exception instanceof Error)) return false;
|
|
18
|
+
|
|
19
|
+
const networkErrorPatterns = [
|
|
20
|
+
'networkerror',
|
|
21
|
+
'failed to fetch',
|
|
22
|
+
'network request failed',
|
|
23
|
+
'network error',
|
|
24
|
+
'loading chunk',
|
|
25
|
+
'chunk load failed'
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
if (exception.name === 'NetworkError') return true;
|
|
29
|
+
|
|
30
|
+
if (exception.name === 'TypeError') {
|
|
31
|
+
return networkErrorPatterns.some((pattern) =>
|
|
32
|
+
exception.message.toLowerCase().includes(pattern)
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return networkErrorPatterns.some((pattern) =>
|
|
37
|
+
exception.message.toLowerCase().includes(pattern)
|
|
38
|
+
);
|
|
39
|
+
};
|
|
40
|
+
|
|
6
41
|
export const initSentry = (
|
|
7
42
|
type: 'Server' | 'Client' | 'Edge',
|
|
8
43
|
options: Sentry.BrowserOptions | Sentry.NodeOptions | Sentry.EdgeOptions = {}
|
|
9
44
|
) => {
|
|
10
|
-
// TODO: Handle options with ESLint rules
|
|
11
|
-
|
|
12
45
|
// TODO: Remove Zero Project DSN
|
|
13
46
|
|
|
47
|
+
const baseConfig = {
|
|
48
|
+
dsn:
|
|
49
|
+
SENTRY_DSN ||
|
|
50
|
+
options.dsn ||
|
|
51
|
+
'https://d8558ef8997543deacf376c7d8d7cf4b@o64293.ingest.sentry.io/4504338423742464',
|
|
52
|
+
initialScope: {
|
|
53
|
+
tags: {
|
|
54
|
+
APP_TYPE: 'ProjectZeroNext',
|
|
55
|
+
TYPE: type,
|
|
56
|
+
...((options.initialScope as any)?.tags || {})
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
tracesSampleRate: 0,
|
|
60
|
+
integrations: []
|
|
61
|
+
};
|
|
62
|
+
|
|
14
63
|
if (type === 'Server' || type === 'Edge') {
|
|
64
|
+
Sentry.init(baseConfig);
|
|
65
|
+
} else if (type === 'Client') {
|
|
15
66
|
Sentry.init({
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
67
|
+
...baseConfig,
|
|
68
|
+
beforeSend: (event, hint) => {
|
|
69
|
+
if (
|
|
70
|
+
!ALLOWED_CLIENT_LOG_TYPES.includes(
|
|
71
|
+
event.tags?.LOG_TYPE as ClientLogType
|
|
72
|
+
)
|
|
73
|
+
) {
|
|
74
|
+
return null;
|
|
23
75
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
76
|
+
|
|
77
|
+
if (isNetworkError(hint?.originalException)) {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return event;
|
|
82
|
+
}
|
|
27
83
|
});
|
|
28
84
|
}
|
|
29
85
|
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const defaultPlugins = require('../plugins');
|
|
2
|
+
|
|
3
|
+
const getAkinonNextContent = (plugins = defaultPlugins) => {
|
|
4
|
+
return [
|
|
5
|
+
`./node_modules/@akinon/next/components/**/*.{js,ts,jsx,tsx}`,
|
|
6
|
+
`../../node_modules/@akinon/next/components/**/*.{js,ts,jsx,tsx}`,
|
|
7
|
+
...plugins
|
|
8
|
+
.map((plugin) => [
|
|
9
|
+
`./node_modules/@akinon/${plugin}/**/*.{js,ts,jsx,tsx}`,
|
|
10
|
+
`../../node_modules/@akinon/${plugin}/**/*.{js,ts,jsx,tsx}`
|
|
11
|
+
])
|
|
12
|
+
.flat()
|
|
13
|
+
];
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
module.exports = getAkinonNextContent;
|
|
@@ -19,6 +19,10 @@ export type AccountOrderCancellation = {
|
|
|
19
19
|
description: string;
|
|
20
20
|
order_item: string;
|
|
21
21
|
reason: string;
|
|
22
|
+
cancellation_request_image_set?: Array<{
|
|
23
|
+
image: string;
|
|
24
|
+
description: string;
|
|
25
|
+
}>;
|
|
22
26
|
}>;
|
|
23
27
|
};
|
|
24
28
|
|
|
@@ -61,5 +65,5 @@ export type ContactFormType = {
|
|
|
61
65
|
order?: string;
|
|
62
66
|
country_code?: string;
|
|
63
67
|
order_needed?: boolean;
|
|
64
|
-
file?: FileList
|
|
68
|
+
file?: FileList;
|
|
65
69
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import type { JSX } from 'react';
|
|
1
2
|
import { Address } from './address';
|
|
2
3
|
import { Basket } from './basket';
|
|
3
4
|
import { RetailStore } from './misc';
|
|
4
5
|
import { PaymentOption } from './order';
|
|
5
6
|
import { Product } from './product';
|
|
6
|
-
import { JSX } from 'react';
|
|
7
7
|
import { RootState, TypedDispatch } from 'redux/store';
|
|
8
8
|
|
|
9
9
|
export enum CheckoutStep {
|
|
@@ -68,6 +68,18 @@ export interface CheckoutPaymentOption {
|
|
|
68
68
|
viewProps?: any;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
+
export interface LoyaltyBalanceItem {
|
|
72
|
+
label_id: number | null;
|
|
73
|
+
label: string | null;
|
|
74
|
+
balance: string;
|
|
75
|
+
currency?: string;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface AccountUsage {
|
|
79
|
+
label_id: number | null;
|
|
80
|
+
amount: number;
|
|
81
|
+
}
|
|
82
|
+
|
|
71
83
|
export interface GiftBox {
|
|
72
84
|
note: string;
|
|
73
85
|
gift_video: boolean;
|
|
@@ -91,6 +103,7 @@ export interface PreOrder {
|
|
|
91
103
|
notes?: string;
|
|
92
104
|
user_phone_number?: string;
|
|
93
105
|
loyalty_money?: string;
|
|
106
|
+
loyalty_account_usages?: AccountUsage[];
|
|
94
107
|
currency_type_label?: string;
|
|
95
108
|
is_guest?: boolean;
|
|
96
109
|
is_post_order?: boolean;
|
|
@@ -108,6 +121,8 @@ export interface PreOrder {
|
|
|
108
121
|
context_extras?: ExtraField;
|
|
109
122
|
token?: string;
|
|
110
123
|
agreement_confirmed?: boolean;
|
|
124
|
+
phone_number?: string;
|
|
125
|
+
number?: string;
|
|
111
126
|
}
|
|
112
127
|
|
|
113
128
|
export type ExtraField = Record<string, any>;
|
|
@@ -149,6 +164,8 @@ export interface CheckoutContext {
|
|
|
149
164
|
redirect_url?: string;
|
|
150
165
|
context_data?: any;
|
|
151
166
|
balance?: string;
|
|
167
|
+
balances?: LoyaltyBalanceItem[];
|
|
168
|
+
accounts?: LoyaltyBalanceItem[];
|
|
152
169
|
attribute_based_shipping_options?: AttributeBasedShippingOption[];
|
|
153
170
|
paymentData?: any;
|
|
154
171
|
paymentMethod?: string;
|
|
@@ -200,3 +217,20 @@ export interface MiddlewareParams {
|
|
|
200
217
|
getState: () => RootState;
|
|
201
218
|
dispatch: TypedDispatch;
|
|
202
219
|
}
|
|
220
|
+
|
|
221
|
+
export interface MiddlewareAction {
|
|
222
|
+
type: string;
|
|
223
|
+
payload?: { status?: number; [key: string]: unknown };
|
|
224
|
+
meta?: {
|
|
225
|
+
arg?: { endpointName?: string };
|
|
226
|
+
baseQueryMeta?: { request?: { url?: string } };
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
export type SendSmsType = {
|
|
231
|
+
phone_number: string;
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
export type VerifySmsType = {
|
|
235
|
+
verify_code: string;
|
|
236
|
+
};
|
package/types/commerce/widget.ts
CHANGED
|
@@ -26,3 +26,36 @@ export type WidgetResultType<T> = {
|
|
|
26
26
|
slug?: string;
|
|
27
27
|
template?: string;
|
|
28
28
|
};
|
|
29
|
+
|
|
30
|
+
export type WidgetSchemaType<T> = {
|
|
31
|
+
pk?: number;
|
|
32
|
+
name?: string;
|
|
33
|
+
schema?: T;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export type DynamicWidgetResultType = WidgetResultType<{
|
|
37
|
+
[key: string]: {
|
|
38
|
+
value: string;
|
|
39
|
+
kwargs: {
|
|
40
|
+
data_type: string;
|
|
41
|
+
value?: string;
|
|
42
|
+
url?: string;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
}>;
|
|
46
|
+
|
|
47
|
+
export type DynamicWidgetSchemaType = WidgetSchemaType<{
|
|
48
|
+
[key: string]: {
|
|
49
|
+
key: string;
|
|
50
|
+
data_type: string;
|
|
51
|
+
label: string;
|
|
52
|
+
properties: {
|
|
53
|
+
parent_id?: string;
|
|
54
|
+
style?: {
|
|
55
|
+
[key: string]: any;
|
|
56
|
+
};
|
|
57
|
+
tag?: string;
|
|
58
|
+
type?: string;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
}>;
|