@akinon/next 2.0.0-beta.8 → 2.0.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 +438 -21
- package/__tests__/next-config.test.ts +83 -0
- package/__tests__/tsconfig.json +23 -0
- package/api/auth.ts +367 -63
- 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-install-plugins.js +1 -1
- package/bin/pz-prebuild.js +1 -0
- package/bin/pz-predev.js +1 -0
- package/bin/pz-run-tests.js +99 -0
- package/components/accordion.tsx +21 -6
- package/components/client-root.tsx +119 -3
- package/components/file-input.tsx +65 -3
- package/components/index.ts +1 -0
- package/components/input.tsx +2 -2
- 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 +3 -3
- package/components/selected-payment-option-view.tsx +21 -0
- package/data/client/account.ts +17 -2
- package/data/client/basket.ts +39 -0
- package/data/client/checkout.ts +336 -99
- package/data/client/misc.ts +13 -1
- package/data/server/category.ts +11 -9
- package/data/server/flatpage.ts +4 -1
- package/data/server/form.ts +4 -1
- package/data/server/landingpage.ts +4 -1
- package/data/server/list.ts +5 -4
- package/data/server/menu.ts +4 -1
- package/data/server/product.ts +97 -52
- package/data/server/seo.ts +4 -1
- package/data/server/special-page.ts +5 -4
- package/data/server/widget.ts +71 -1
- package/data/urls.ts +6 -3
- package/hocs/client/with-segment-defaults.tsx +2 -2
- package/hocs/server/with-segment-defaults.tsx +81 -20
- package/hooks/index.ts +3 -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 +53 -19
- package/instrumentation/index.ts +0 -1
- package/instrumentation/node.ts +2 -20
- package/jest.config.js +25 -0
- package/lib/cache-handler.mjs +534 -16
- package/lib/cache.ts +269 -34
- 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 +357 -203
- package/middlewares/index.ts +10 -2
- package/middlewares/locale.ts +5 -3
- 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 +9 -15
- package/middlewares/wallet-complete-redirection.ts +206 -0
- package/package.json +24 -10
- package/plugins.d.ts +19 -4
- package/plugins.js +9 -1
- package/redux/actions.ts +47 -0
- package/redux/middlewares/checkout.ts +61 -8
- package/redux/middlewares/index.ts +14 -10
- package/redux/middlewares/pre-order/address.ts +1 -1
- package/redux/middlewares/pre-order/attribute-based-shipping-option.ts +1 -1
- package/redux/middlewares/pre-order/data-source-shipping-option.ts +1 -1
- package/redux/middlewares/pre-order/delivery-option.ts +1 -1
- package/redux/middlewares/pre-order/index.ts +3 -1
- package/redux/middlewares/pre-order/installment-option.ts +2 -1
- package/redux/middlewares/pre-order/payment-option-reset.ts +37 -0
- package/redux/middlewares/pre-order/payment-option.ts +1 -1
- package/redux/middlewares/pre-order/pre-order-validation.ts +4 -3
- package/redux/middlewares/pre-order/redirection.ts +2 -2
- package/redux/middlewares/pre-order/set-pre-order.ts +2 -2
- package/redux/middlewares/pre-order/shipping-option.ts +1 -1
- package/redux/middlewares/pre-order/shipping-step.ts +1 -1
- package/redux/reducers/checkout.ts +15 -1
- package/redux/reducers/index.ts +7 -1
- package/redux/reducers/widget.ts +80 -0
- package/sentry/index.ts +54 -17
- package/tailwind/content.js +16 -0
- package/types/commerce/checkout.ts +26 -1
- package/types/commerce/widget.ts +33 -0
- package/types/index.ts +114 -5
- 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 +69 -18
- package/utils/mobile-3d-iframe.ts +8 -2
- package/utils/override-middleware.ts +1 -0
- 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/with-pz-config.js +20 -7
|
@@ -20,7 +20,14 @@ enum Plugin {
|
|
|
20
20
|
B2B = 'pz-b2b',
|
|
21
21
|
Akifast = 'pz-akifast',
|
|
22
22
|
MultiBasket = 'pz-multi-basket',
|
|
23
|
-
SavedCard = 'pz-saved-card'
|
|
23
|
+
SavedCard = 'pz-saved-card',
|
|
24
|
+
FlowPayment = 'pz-flow-payment',
|
|
25
|
+
VirtualTryOn = 'pz-virtual-try-on',
|
|
26
|
+
Hepsipay = 'pz-hepsipay',
|
|
27
|
+
MasterpassRest = 'pz-masterpass-rest',
|
|
28
|
+
SimilarProducts = 'pz-similar-products',
|
|
29
|
+
Haso = 'pz-haso',
|
|
30
|
+
GooglePay = 'pz-google-pay'
|
|
24
31
|
}
|
|
25
32
|
|
|
26
33
|
export enum Component {
|
|
@@ -45,7 +52,23 @@ export enum Component {
|
|
|
45
52
|
AkifastQuickLoginButton = 'QuickLoginButton',
|
|
46
53
|
AkifastCheckoutButton = 'CheckoutButton',
|
|
47
54
|
MultiBasket = 'MultiBasket',
|
|
48
|
-
SavedCard = 'SavedCardOption'
|
|
55
|
+
SavedCard = 'SavedCardOption',
|
|
56
|
+
VirtualTryOnPlugin = 'VirtualTryOnPlugin',
|
|
57
|
+
BasketVirtualTryOn = 'BasketVirtualTryOn',
|
|
58
|
+
BarcodeScannerPlugin = 'BarcodeScannerPlugin',
|
|
59
|
+
IyzicoSavedCard = 'IyzicoSavedCardOption',
|
|
60
|
+
Hepsipay = 'Hepsipay',
|
|
61
|
+
FlowPayment = 'FlowPayment',
|
|
62
|
+
MasterpassRest = 'MasterpassRestOption',
|
|
63
|
+
SimilarProductsModal = 'SimilarProductsModal',
|
|
64
|
+
SimilarProductsFilterSidebar = 'SimilarProductsFilterSidebar',
|
|
65
|
+
SimilarProductsResultsGrid = 'SimilarProductsResultsGrid',
|
|
66
|
+
SimilarProductsPlugin = 'SimilarProductsPlugin',
|
|
67
|
+
ProductImageSearchFeature = 'ProductImageSearchFeature',
|
|
68
|
+
ImageSearchButton = 'ImageSearchButton',
|
|
69
|
+
HeaderImageSearchFeature = 'HeaderImageSearchFeature',
|
|
70
|
+
HasoPaymentGateway = 'HasoPaymentGateway',
|
|
71
|
+
GooglePay = 'GooglePay'
|
|
49
72
|
}
|
|
50
73
|
|
|
51
74
|
const PluginComponents = new Map([
|
|
@@ -78,7 +101,29 @@ const PluginComponents = new Map([
|
|
|
78
101
|
[Component.AkifastQuickLoginButton, Component.AkifastCheckoutButton]
|
|
79
102
|
],
|
|
80
103
|
[Plugin.MultiBasket, [Component.MultiBasket]],
|
|
81
|
-
[
|
|
104
|
+
[
|
|
105
|
+
Plugin.SimilarProducts,
|
|
106
|
+
[
|
|
107
|
+
Component.SimilarProductsModal,
|
|
108
|
+
Component.SimilarProductsFilterSidebar,
|
|
109
|
+
Component.SimilarProductsResultsGrid,
|
|
110
|
+
Component.SimilarProductsPlugin,
|
|
111
|
+
Component.ProductImageSearchFeature,
|
|
112
|
+
Component.ImageSearchButton,
|
|
113
|
+
Component.HeaderImageSearchFeature
|
|
114
|
+
]
|
|
115
|
+
],
|
|
116
|
+
[Plugin.SavedCard, [Component.SavedCard, Component.IyzicoSavedCard]],
|
|
117
|
+
[Plugin.SavedCard, [Component.SavedCard]],
|
|
118
|
+
[Plugin.FlowPayment, [Component.FlowPayment]],
|
|
119
|
+
[
|
|
120
|
+
Plugin.VirtualTryOn,
|
|
121
|
+
[Component.VirtualTryOnPlugin, Component.BasketVirtualTryOn, Component.BarcodeScannerPlugin]
|
|
122
|
+
],
|
|
123
|
+
[Plugin.Hepsipay, [Component.Hepsipay]],
|
|
124
|
+
[Plugin.MasterpassRest, [Component.MasterpassRest]],
|
|
125
|
+
[Plugin.Haso, [Component.HasoPaymentGateway]],
|
|
126
|
+
[Plugin.GooglePay, [Component.GooglePay]]
|
|
82
127
|
]);
|
|
83
128
|
|
|
84
129
|
const getPlugin = (component: Component) => {
|
|
@@ -143,6 +188,20 @@ export default function PluginModule({
|
|
|
143
188
|
promise = import(`${'@akinon/pz-multi-basket'}`);
|
|
144
189
|
} else if (plugin === Plugin.SavedCard) {
|
|
145
190
|
promise = import(`${'@akinon/pz-saved-card'}`);
|
|
191
|
+
} else if (plugin === Plugin.Hepsipay) {
|
|
192
|
+
promise = import(`${'@akinon/pz-hepsipay'}`);
|
|
193
|
+
} else if (plugin === Plugin.FlowPayment) {
|
|
194
|
+
promise = import(`${'@akinon/pz-flow-payment'}`);
|
|
195
|
+
} else if (plugin === Plugin.VirtualTryOn) {
|
|
196
|
+
promise = import(`${'@akinon/pz-virtual-try-on'}`);
|
|
197
|
+
} else if (plugin === Plugin.MasterpassRest) {
|
|
198
|
+
promise = import(`${'@akinon/pz-masterpass-rest'}`);
|
|
199
|
+
} else if (plugin === Plugin.SimilarProducts) {
|
|
200
|
+
promise = import(`${'@akinon/pz-similar-products'}`);
|
|
201
|
+
} else if (plugin === Plugin.Haso) {
|
|
202
|
+
promise = import(`${'@akinon/pz-haso'}`);
|
|
203
|
+
} else if (plugin === Plugin.GooglePay) {
|
|
204
|
+
promise = import(`${'@akinon/pz-google-pay'}`);
|
|
146
205
|
}
|
|
147
206
|
} catch (error) {
|
|
148
207
|
logger.error(error);
|
package/components/price.tsx
CHANGED
|
@@ -55,8 +55,8 @@ export const Price = (props: NumericFormatProps & PriceProps) => {
|
|
|
55
55
|
: formattedValue;
|
|
56
56
|
|
|
57
57
|
const currentCurrencyDecimalScale = Settings.localization.currencies.find(
|
|
58
|
-
(currency) => currency
|
|
59
|
-
)
|
|
58
|
+
(currency) => currency?.code === currencyCode_
|
|
59
|
+
)?.decimalScale;
|
|
60
60
|
|
|
61
61
|
return (
|
|
62
62
|
<NumericFormat
|
package/components/select.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { forwardRef } from 'react';
|
|
2
|
-
import { SelectProps } from '@theme/components/types';
|
|
2
|
+
import type { SelectProps } from '@theme/components/types';
|
|
3
3
|
import clsx from 'clsx';
|
|
4
4
|
import { Icon } from './icon';
|
|
5
5
|
import { twMerge } from 'tailwind-merge';
|
|
@@ -41,7 +41,7 @@ const Select = forwardRef<HTMLSelectElement, SelectProps>((props, ref) => {
|
|
|
41
41
|
ref={ref}
|
|
42
42
|
className={twMerge(
|
|
43
43
|
clsx(
|
|
44
|
-
'cursor-pointer truncate h-10 w-40 px-2.5 shrink-0 outline-
|
|
44
|
+
'cursor-pointer truncate h-10 w-40 px-2.5 shrink-0 outline-none',
|
|
45
45
|
!borderless &&
|
|
46
46
|
'border border-gray-200 transition-all duration-150 hover:border-primary'
|
|
47
47
|
),
|
|
@@ -59,7 +59,7 @@ const Select = forwardRef<HTMLSelectElement, SelectProps>((props, ref) => {
|
|
|
59
59
|
))}
|
|
60
60
|
</select>
|
|
61
61
|
{error && (
|
|
62
|
-
<span className="mt-1 text-sm text-error">{error.message}</span>
|
|
62
|
+
<span className="mt-1 text-sm text-error">{String(error.message)}</span>
|
|
63
63
|
)}
|
|
64
64
|
</label>
|
|
65
65
|
);
|
|
@@ -16,6 +16,7 @@ const paymentTypeToView = {
|
|
|
16
16
|
gpay: 'gpay',
|
|
17
17
|
loyalty_money: 'loyalty',
|
|
18
18
|
masterpass: 'credit-card',
|
|
19
|
+
masterpass_rest: 'masterpass-rest',
|
|
19
20
|
pay_on_delivery: 'pay-on-delivery',
|
|
20
21
|
redirection: 'redirection',
|
|
21
22
|
saved_card: 'saved-card'
|
|
@@ -57,6 +58,26 @@ export default function SelectedPaymentOptionView({
|
|
|
57
58
|
) {
|
|
58
59
|
const mod = await import('@akinon/pz-apple-pay');
|
|
59
60
|
|
|
61
|
+
return typeof mod?.default === 'function'
|
|
62
|
+
? mod.default
|
|
63
|
+
: fallbackView;
|
|
64
|
+
} else if (
|
|
65
|
+
payment_option?.payment_type === 'wallet' &&
|
|
66
|
+
wallet_method === 'cybersource_uc'
|
|
67
|
+
) {
|
|
68
|
+
const mod = await import('@akinon/pz-cybersource-uc');
|
|
69
|
+
|
|
70
|
+
return typeof mod?.CyberSourceUcPaymentOption === 'function'
|
|
71
|
+
? mod.CyberSourceUcPaymentOption
|
|
72
|
+
: fallbackView;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (
|
|
76
|
+
payment_option?.payment_type === 'wallet' &&
|
|
77
|
+
wallet_method === 'checkout_flow'
|
|
78
|
+
) {
|
|
79
|
+
const mod = await import('@akinon/pz-flow-payment');
|
|
80
|
+
|
|
60
81
|
return typeof mod?.default === 'function'
|
|
61
82
|
? mod.default
|
|
62
83
|
: fallbackView;
|
package/data/client/account.ts
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
AccountOrderCancellation,
|
|
8
8
|
AccountOrderCancellationReason,
|
|
9
9
|
ContactFormType,
|
|
10
|
+
LoyaltyBalanceItem,
|
|
10
11
|
Order,
|
|
11
12
|
Quotations
|
|
12
13
|
} from '../../types';
|
|
@@ -77,6 +78,10 @@ interface LoyaltyTransactions {
|
|
|
77
78
|
}[];
|
|
78
79
|
}
|
|
79
80
|
|
|
81
|
+
interface PasswordResetValidateResponse {
|
|
82
|
+
validlink: boolean;
|
|
83
|
+
}
|
|
84
|
+
|
|
80
85
|
const accountApi = api.injectEndpoints({
|
|
81
86
|
endpoints: (builder) => ({
|
|
82
87
|
updatePassword: builder.mutation<void, AccountChangePasswordFormType>({
|
|
@@ -216,11 +221,20 @@ const accountApi = api.injectEndpoints({
|
|
|
216
221
|
method: 'PATCH'
|
|
217
222
|
})
|
|
218
223
|
}),
|
|
219
|
-
getLoyaltyBalance: builder.query<
|
|
224
|
+
getLoyaltyBalance: builder.query<
|
|
225
|
+
{ balance: number; balances?: LoyaltyBalanceItem[] },
|
|
226
|
+
void
|
|
227
|
+
>({
|
|
220
228
|
query: () => buildClientRequestUrl(account.loyaltyBalance)
|
|
221
229
|
}),
|
|
222
230
|
getLoyaltyTransactions: builder.query<LoyaltyTransactions, void>({
|
|
223
231
|
query: () => buildClientRequestUrl(account.loyaltyTransactions)
|
|
232
|
+
}),
|
|
233
|
+
getValidatePasswordResetToken: builder.query<
|
|
234
|
+
PasswordResetValidateResponse,
|
|
235
|
+
string
|
|
236
|
+
>({
|
|
237
|
+
query: (slug) => buildClientRequestUrl(account.passwordReset(slug))
|
|
224
238
|
})
|
|
225
239
|
}),
|
|
226
240
|
overrideExisting: true
|
|
@@ -247,5 +261,6 @@ export const {
|
|
|
247
261
|
usePasswordResetMutation,
|
|
248
262
|
useAnonymizeMutation,
|
|
249
263
|
useGetLoyaltyBalanceQuery,
|
|
250
|
-
useGetLoyaltyTransactionsQuery
|
|
264
|
+
useGetLoyaltyTransactionsQuery,
|
|
265
|
+
useGetValidatePasswordResetTokenQuery
|
|
251
266
|
} = accountApi;
|
package/data/client/basket.ts
CHANGED
|
@@ -104,6 +104,45 @@ export const basketApi = api.injectEndpoints({
|
|
|
104
104
|
method: 'PUT',
|
|
105
105
|
body
|
|
106
106
|
}),
|
|
107
|
+
async onQueryStarted(_, { dispatch, queryFulfilled }) {
|
|
108
|
+
try {
|
|
109
|
+
const { data } = await queryFulfilled;
|
|
110
|
+
|
|
111
|
+
dispatch(
|
|
112
|
+
basketApi.util.updateQueryData(
|
|
113
|
+
'getBasket',
|
|
114
|
+
undefined,
|
|
115
|
+
() => data.basket
|
|
116
|
+
)
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
if (data.basket.namespace) {
|
|
120
|
+
dispatch(
|
|
121
|
+
basketApi.util.updateQueryData(
|
|
122
|
+
'getBasketDetail',
|
|
123
|
+
{ namespace: data.basket.namespace },
|
|
124
|
+
() => data.basket
|
|
125
|
+
)
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
dispatch(
|
|
130
|
+
basketApi.util.updateQueryData(
|
|
131
|
+
'getAllBaskets',
|
|
132
|
+
undefined,
|
|
133
|
+
(baskets) => {
|
|
134
|
+
if (!baskets) return baskets;
|
|
135
|
+
|
|
136
|
+
return baskets.map((basket) =>
|
|
137
|
+
basket.pk === data.basket.pk ? data.basket : basket
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
)
|
|
141
|
+
);
|
|
142
|
+
} catch (error) {
|
|
143
|
+
console.error('Error updating quantity:', error);
|
|
144
|
+
}
|
|
145
|
+
},
|
|
107
146
|
invalidatesTags: ['MultiBasket', 'Basket', 'MiniBasket']
|
|
108
147
|
}),
|
|
109
148
|
clearBasket: build.mutation<Basket, void>({
|