@akinon/next 2.0.0-beta.11 → 2.0.0-beta.13
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 +286 -27
- package/api/auth.ts +99 -77
- package/api/cache.ts +41 -5
- package/api/client.ts +3 -3
- 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/bin/pz-generate-routes.js +105 -0
- package/bin/pz-prebuild.js +1 -1
- package/bin/pz-predev.js +1 -0
- package/components/accordion.tsx +21 -6
- package/components/button.tsx +1 -1
- package/components/file-input.tsx +65 -3
- package/components/input.tsx +2 -2
- package/components/modal.tsx +32 -16
- package/components/plugin-module.tsx +61 -3
- package/components/select.tsx +2 -2
- package/components/selected-payment-option-view.tsx +21 -0
- package/data/client/checkout.ts +130 -74
- 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 +4 -1
- package/data/urls.ts +3 -2
- package/hocs/client/with-segment-defaults.tsx +2 -2
- package/hocs/server/with-segment-defaults.tsx +65 -20
- package/hooks/index.ts +1 -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/instrumentation/index.ts +0 -1
- package/instrumentation/node.ts +2 -20
- package/jest.config.js +7 -1
- package/lib/cache-handler.mjs +527 -15
- package/lib/cache.ts +260 -31
- package/localization/provider.tsx +2 -5
- package/middlewares/checkout-provider.ts +1 -1
- package/middlewares/complete-gpay.ts +33 -26
- package/middlewares/complete-masterpass.ts +34 -26
- package/middlewares/complete-wallet.ts +183 -0
- package/middlewares/default.ts +346 -235
- package/middlewares/index.ts +8 -2
- package/middlewares/locale.ts +0 -1
- package/middlewares/masterpass-rest-callback.ts +220 -0
- package/middlewares/pretty-url.ts +21 -8
- package/middlewares/redirection-payment.ts +33 -26
- package/middlewares/saved-card-redirection.ts +34 -26
- package/middlewares/three-d-redirection.ts +33 -26
- package/middlewares/url-redirection.ts +9 -15
- package/middlewares/wallet-complete-redirection.ts +207 -0
- package/package.json +20 -11
- package/plugins.d.ts +19 -4
- package/plugins.js +9 -1
- package/redux/actions.ts +47 -0
- package/redux/middlewares/checkout.ts +20 -8
- package/redux/middlewares/index.ts +12 -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 +9 -1
- package/redux/reducers/index.ts +5 -1
- package/sentry/index.ts +54 -17
- package/types/commerce/checkout.ts +11 -1
- package/types/index.ts +96 -6
- package/types/next-auth.d.ts +2 -2
- package/utils/app-fetch.ts +2 -2
- package/utils/generate-commerce-search-params.ts +3 -2
- package/utils/get-checkout-path.ts +3 -0
- package/utils/index.ts +38 -11
- 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/with-pz-config.js +10 -4
package/components/modal.tsx
CHANGED
|
@@ -4,16 +4,7 @@ import { ReactPortal } from './react-portal';
|
|
|
4
4
|
import { Icon } from './icon';
|
|
5
5
|
import { twMerge } from 'tailwind-merge';
|
|
6
6
|
import { useEffect } from 'react';
|
|
7
|
-
|
|
8
|
-
export interface ModalProps {
|
|
9
|
-
portalId: string;
|
|
10
|
-
children?: React.ReactNode;
|
|
11
|
-
open?: boolean;
|
|
12
|
-
setOpen?: (open: boolean) => void;
|
|
13
|
-
title?: React.ReactNode;
|
|
14
|
-
showCloseButton?: React.ReactNode;
|
|
15
|
-
className?: string;
|
|
16
|
-
}
|
|
7
|
+
import { ModalProps } from '../types';
|
|
17
8
|
|
|
18
9
|
export const Modal = (props: ModalProps) => {
|
|
19
10
|
const {
|
|
@@ -23,7 +14,14 @@ export const Modal = (props: ModalProps) => {
|
|
|
23
14
|
setOpen,
|
|
24
15
|
title = '',
|
|
25
16
|
showCloseButton = true,
|
|
26
|
-
className
|
|
17
|
+
className,
|
|
18
|
+
overlayClassName,
|
|
19
|
+
headerWrapperClassName,
|
|
20
|
+
titleClassName,
|
|
21
|
+
closeButtonClassName,
|
|
22
|
+
iconName = 'close',
|
|
23
|
+
iconSize = 16,
|
|
24
|
+
iconClassName
|
|
27
25
|
} = props;
|
|
28
26
|
|
|
29
27
|
useEffect(() => {
|
|
@@ -38,7 +36,12 @@ export const Modal = (props: ModalProps) => {
|
|
|
38
36
|
|
|
39
37
|
return (
|
|
40
38
|
<ReactPortal wrapperId={portalId}>
|
|
41
|
-
<div
|
|
39
|
+
<div
|
|
40
|
+
className={twMerge(
|
|
41
|
+
'fixed top-0 left-0 w-screen h-screen bg-primary bg-opacity-60 z-50',
|
|
42
|
+
overlayClassName
|
|
43
|
+
)}
|
|
44
|
+
/>
|
|
42
45
|
<section
|
|
43
46
|
className={twMerge(
|
|
44
47
|
'fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 z-50 bg-white',
|
|
@@ -46,15 +49,28 @@ export const Modal = (props: ModalProps) => {
|
|
|
46
49
|
)}
|
|
47
50
|
>
|
|
48
51
|
{(showCloseButton || title) && (
|
|
49
|
-
<div
|
|
50
|
-
|
|
52
|
+
<div
|
|
53
|
+
className={twMerge(
|
|
54
|
+
'flex px-6 py-4 border-b border-gray-400',
|
|
55
|
+
headerWrapperClassName
|
|
56
|
+
)}
|
|
57
|
+
>
|
|
58
|
+
{title && (
|
|
59
|
+
<h3 className={twMerge('text-lg font-light', titleClassName)}>
|
|
60
|
+
{title}
|
|
61
|
+
</h3>
|
|
62
|
+
)}
|
|
51
63
|
{showCloseButton && (
|
|
52
64
|
<button
|
|
53
65
|
type="button"
|
|
54
66
|
onClick={() => setOpen(false)}
|
|
55
|
-
className=
|
|
67
|
+
className={twMerge('ml-auto', closeButtonClassName)}
|
|
56
68
|
>
|
|
57
|
-
<Icon
|
|
69
|
+
<Icon
|
|
70
|
+
name={iconName}
|
|
71
|
+
size={iconSize}
|
|
72
|
+
className={iconClassName}
|
|
73
|
+
/>
|
|
58
74
|
</button>
|
|
59
75
|
)}
|
|
60
76
|
</div>
|
|
@@ -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,22 @@ 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
|
+
IyzicoSavedCard = 'IyzicoSavedCardOption',
|
|
59
|
+
Hepsipay = 'Hepsipay',
|
|
60
|
+
FlowPayment = 'FlowPayment',
|
|
61
|
+
MasterpassRest = 'MasterpassRestOption',
|
|
62
|
+
SimilarProductsModal = 'SimilarProductsModal',
|
|
63
|
+
SimilarProductsFilterSidebar = 'SimilarProductsFilterSidebar',
|
|
64
|
+
SimilarProductsResultsGrid = 'SimilarProductsResultsGrid',
|
|
65
|
+
SimilarProductsPlugin = 'SimilarProductsPlugin',
|
|
66
|
+
ProductImageSearchFeature = 'ProductImageSearchFeature',
|
|
67
|
+
ImageSearchButton = 'ImageSearchButton',
|
|
68
|
+
HeaderImageSearchFeature = 'HeaderImageSearchFeature',
|
|
69
|
+
HasoPaymentGateway = 'HasoPaymentGateway',
|
|
70
|
+
GooglePay = 'GooglePay'
|
|
49
71
|
}
|
|
50
72
|
|
|
51
73
|
const PluginComponents = new Map([
|
|
@@ -78,7 +100,29 @@ const PluginComponents = new Map([
|
|
|
78
100
|
[Component.AkifastQuickLoginButton, Component.AkifastCheckoutButton]
|
|
79
101
|
],
|
|
80
102
|
[Plugin.MultiBasket, [Component.MultiBasket]],
|
|
81
|
-
[
|
|
103
|
+
[
|
|
104
|
+
Plugin.SimilarProducts,
|
|
105
|
+
[
|
|
106
|
+
Component.SimilarProductsModal,
|
|
107
|
+
Component.SimilarProductsFilterSidebar,
|
|
108
|
+
Component.SimilarProductsResultsGrid,
|
|
109
|
+
Component.SimilarProductsPlugin,
|
|
110
|
+
Component.ProductImageSearchFeature,
|
|
111
|
+
Component.ImageSearchButton,
|
|
112
|
+
Component.HeaderImageSearchFeature
|
|
113
|
+
]
|
|
114
|
+
],
|
|
115
|
+
[Plugin.SavedCard, [Component.SavedCard, Component.IyzicoSavedCard]],
|
|
116
|
+
[Plugin.SavedCard, [Component.SavedCard]],
|
|
117
|
+
[Plugin.FlowPayment, [Component.FlowPayment]],
|
|
118
|
+
[
|
|
119
|
+
Plugin.VirtualTryOn,
|
|
120
|
+
[Component.VirtualTryOnPlugin, Component.BasketVirtualTryOn]
|
|
121
|
+
],
|
|
122
|
+
[Plugin.Hepsipay, [Component.Hepsipay]],
|
|
123
|
+
[Plugin.MasterpassRest, [Component.MasterpassRest]],
|
|
124
|
+
[Plugin.Haso, [Component.HasoPaymentGateway]],
|
|
125
|
+
[Plugin.GooglePay, [Component.GooglePay]]
|
|
82
126
|
]);
|
|
83
127
|
|
|
84
128
|
const getPlugin = (component: Component) => {
|
|
@@ -143,6 +187,20 @@ export default function PluginModule({
|
|
|
143
187
|
promise = import(`${'@akinon/pz-multi-basket'}`);
|
|
144
188
|
} else if (plugin === Plugin.SavedCard) {
|
|
145
189
|
promise = import(`${'@akinon/pz-saved-card'}`);
|
|
190
|
+
} else if (plugin === Plugin.Hepsipay) {
|
|
191
|
+
promise = import(`${'@akinon/pz-hepsipay'}`);
|
|
192
|
+
} else if (plugin === Plugin.FlowPayment) {
|
|
193
|
+
promise = import(`${'@akinon/pz-flow-payment'}`);
|
|
194
|
+
} else if (plugin === Plugin.VirtualTryOn) {
|
|
195
|
+
promise = import(`${'@akinon/pz-virtual-try-on'}`);
|
|
196
|
+
} else if (plugin === Plugin.MasterpassRest) {
|
|
197
|
+
promise = import(`${'@akinon/pz-masterpass-rest'}`);
|
|
198
|
+
} else if (plugin === Plugin.SimilarProducts) {
|
|
199
|
+
promise = import(`${'@akinon/pz-similar-products'}`);
|
|
200
|
+
} else if (plugin === Plugin.Haso) {
|
|
201
|
+
promise = import(`${'@akinon/pz-haso'}`);
|
|
202
|
+
} else if (plugin === Plugin.GooglePay) {
|
|
203
|
+
promise = import(`${'@akinon/pz-google-pay'}`);
|
|
146
204
|
}
|
|
147
205
|
} catch (error) {
|
|
148
206
|
logger.error(error);
|
package/components/select.tsx
CHANGED
|
@@ -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;
|