@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
package/components/link.tsx
CHANGED
|
@@ -19,26 +19,56 @@ export const Link = ({ children, href, ...rest }: LinkProps) => {
|
|
|
19
19
|
return '#';
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
if (
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
if (typeof href === 'string') {
|
|
23
|
+
const trimmedHref = href.trim();
|
|
24
|
+
if (!trimmedHref) {
|
|
25
|
+
return '#';
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (urlSchemes.some((scheme) => trimmedHref.startsWith(scheme))) {
|
|
29
|
+
if (
|
|
30
|
+
trimmedHref.startsWith('mailto:') ||
|
|
31
|
+
trimmedHref.startsWith('tel:')
|
|
32
|
+
) {
|
|
33
|
+
return trimmedHref;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
try {
|
|
37
|
+
new URL(trimmedHref);
|
|
38
|
+
return trimmedHref;
|
|
39
|
+
} catch {
|
|
40
|
+
return '#';
|
|
41
|
+
}
|
|
42
|
+
}
|
|
28
43
|
|
|
29
|
-
|
|
30
|
-
|
|
44
|
+
try {
|
|
45
|
+
new URL(trimmedHref, 'http://localhost');
|
|
46
|
+
} catch {
|
|
47
|
+
return '#';
|
|
48
|
+
}
|
|
31
49
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
50
|
+
const pathnameWithoutLocale = trimmedHref.replace(
|
|
51
|
+
urlLocaleMatcherRegex,
|
|
52
|
+
''
|
|
53
|
+
);
|
|
54
|
+
const hrefWithLocale = `/${locale}${pathnameWithoutLocale}`;
|
|
55
|
+
|
|
56
|
+
if (localeUrlStrategy === LocaleUrlStrategy.ShowAllLocales) {
|
|
57
|
+
return hrefWithLocale;
|
|
58
|
+
} else if (
|
|
59
|
+
localeUrlStrategy === LocaleUrlStrategy.HideDefaultLocale &&
|
|
60
|
+
locale !== defaultLocaleValue
|
|
61
|
+
) {
|
|
62
|
+
return hrefWithLocale;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return trimmedHref || '#';
|
|
39
66
|
}
|
|
40
67
|
|
|
41
|
-
|
|
68
|
+
if (typeof href !== 'string') {
|
|
69
|
+
return href;
|
|
70
|
+
}
|
|
71
|
+
return '#';
|
|
42
72
|
}, [href, defaultLocaleValue, locale, localeUrlStrategy]);
|
|
43
73
|
|
|
44
74
|
return (
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import React, { useState, useCallback, memo, useMemo } from 'react';
|
|
4
|
+
import { LogEntry } from '../hooks/use-logger';
|
|
5
|
+
import { useLoggerContext } from '../hooks/use-logger-context';
|
|
6
|
+
|
|
7
|
+
const LoggerAnimations = ({ color = '#dc2626' }: { color?: string }) => (
|
|
8
|
+
<style jsx global>{`
|
|
9
|
+
@keyframes pulse {
|
|
10
|
+
0% {
|
|
11
|
+
transform: scale(0.95);
|
|
12
|
+
box-shadow: 0 0 0 0 ${color}80;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
70% {
|
|
16
|
+
transform: scale(1.05);
|
|
17
|
+
box-shadow: 0 0 0 10px ${color}00;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
100% {
|
|
21
|
+
transform: scale(0.95);
|
|
22
|
+
box-shadow: 0 0 0 0 ${color}00;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
`}</style>
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
const LogLevelColors = {
|
|
29
|
+
warn: '#ff9800', // orange
|
|
30
|
+
error: '#f44336' // red
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const LoggerTrigger = memo(
|
|
34
|
+
({
|
|
35
|
+
onClick,
|
|
36
|
+
logCount = 0,
|
|
37
|
+
currentColor
|
|
38
|
+
}: {
|
|
39
|
+
onClick: () => void;
|
|
40
|
+
logCount?: number;
|
|
41
|
+
currentColor: string;
|
|
42
|
+
}) => {
|
|
43
|
+
return (
|
|
44
|
+
<button
|
|
45
|
+
onClick={onClick}
|
|
46
|
+
className="fixed bottom-4 right-4 w-14 h-14 border border-white rounded-full flex items-center justify-center shadow-lg z-[9999] hover:opacity-90 transition-colors"
|
|
47
|
+
aria-label="Open Logger"
|
|
48
|
+
style={{
|
|
49
|
+
backgroundColor: currentColor,
|
|
50
|
+
...(logCount > 0 && {
|
|
51
|
+
animation: 'pulse 2s infinite'
|
|
52
|
+
})
|
|
53
|
+
}}
|
|
54
|
+
>
|
|
55
|
+
<svg
|
|
56
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
57
|
+
fill="none"
|
|
58
|
+
viewBox="0 0 24 24"
|
|
59
|
+
strokeWidth="1.5"
|
|
60
|
+
stroke="currentColor"
|
|
61
|
+
className="text-white size-6"
|
|
62
|
+
>
|
|
63
|
+
<path
|
|
64
|
+
strokeLinecap="round"
|
|
65
|
+
strokeLinejoin="round"
|
|
66
|
+
d="M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126ZM12 15.75h.007v.008H12v-.008Z"
|
|
67
|
+
/>
|
|
68
|
+
</svg>
|
|
69
|
+
|
|
70
|
+
{logCount > 0 && (
|
|
71
|
+
<span
|
|
72
|
+
className="absolute w-5 h-5 -bottom-[5px] p-1 -left-[5px] border-2 border-white rounded-full flex items-center justify-center text-[8px] text-white font-bold"
|
|
73
|
+
style={{
|
|
74
|
+
backgroundColor: currentColor
|
|
75
|
+
}}
|
|
76
|
+
>
|
|
77
|
+
{logCount > 99 ? '99+' : logCount}
|
|
78
|
+
</span>
|
|
79
|
+
)}
|
|
80
|
+
</button>
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
LoggerTrigger.displayName = 'LoggerTrigger';
|
|
86
|
+
|
|
87
|
+
const LogItem = memo(({ log }: { log: LogEntry }) => {
|
|
88
|
+
const [expanded, setExpanded] = useState(false);
|
|
89
|
+
const hasPayload = log.payload && Object.keys(log.payload).length > 0;
|
|
90
|
+
|
|
91
|
+
const toggleExpanded = useCallback(() => {
|
|
92
|
+
setExpanded((prev) => !prev);
|
|
93
|
+
}, []);
|
|
94
|
+
|
|
95
|
+
return (
|
|
96
|
+
<div className="border-b border-gray-200 py-2">
|
|
97
|
+
<div className="relative">
|
|
98
|
+
<div
|
|
99
|
+
className="absolute top-0 left-0 w-3 h-3 rounded-full mt-1.5 mr-2 flex-shrink-0"
|
|
100
|
+
style={{
|
|
101
|
+
backgroundColor: LogLevelColors[log.level],
|
|
102
|
+
boxShadow: `0 0 5px ${LogLevelColors[log.level]}`
|
|
103
|
+
}}
|
|
104
|
+
/>
|
|
105
|
+
<div className="ml-6">
|
|
106
|
+
<div className="flex justify-between">
|
|
107
|
+
<span
|
|
108
|
+
className="font-medium capitalize"
|
|
109
|
+
style={{
|
|
110
|
+
color: LogLevelColors[log.level]
|
|
111
|
+
}}
|
|
112
|
+
>
|
|
113
|
+
{log.level}
|
|
114
|
+
</span>
|
|
115
|
+
<span className="text-xs text-gray-500">
|
|
116
|
+
{log.timestamp.toLocaleTimeString()}
|
|
117
|
+
</span>
|
|
118
|
+
</div>
|
|
119
|
+
<p className="text-sm">{log.message}</p>
|
|
120
|
+
{hasPayload && (
|
|
121
|
+
<button
|
|
122
|
+
onClick={toggleExpanded}
|
|
123
|
+
className="text-xs text-blue-500 mt-1 hover:text-blue-700 transition-colors"
|
|
124
|
+
>
|
|
125
|
+
{expanded ? 'Hide Details' : 'Show Details'}
|
|
126
|
+
</button>
|
|
127
|
+
)}
|
|
128
|
+
{expanded && hasPayload && (
|
|
129
|
+
<pre className="text-xs bg-gray-100 p-2 mt-1 rounded overflow-auto max-h-96 max-w-full">
|
|
130
|
+
{JSON.stringify(log.payload, null, 2)}
|
|
131
|
+
</pre>
|
|
132
|
+
)}
|
|
133
|
+
</div>
|
|
134
|
+
</div>
|
|
135
|
+
</div>
|
|
136
|
+
);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
LogItem.displayName = 'LogItem';
|
|
140
|
+
|
|
141
|
+
export const LoggerPopup = () => {
|
|
142
|
+
const {
|
|
143
|
+
logs,
|
|
144
|
+
isVisible,
|
|
145
|
+
toggleVisibility,
|
|
146
|
+
clearLogs,
|
|
147
|
+
isDevelopment,
|
|
148
|
+
hasError,
|
|
149
|
+
hasWarning
|
|
150
|
+
} = useLoggerContext();
|
|
151
|
+
|
|
152
|
+
const currentColor = useMemo(() => {
|
|
153
|
+
if (logs.length === 0) return '#b5afaf';
|
|
154
|
+
if (hasError) return '#dc2626';
|
|
155
|
+
if (hasWarning) return '#ff9800';
|
|
156
|
+
|
|
157
|
+
return '#b5afaf';
|
|
158
|
+
}, [logs.length, hasError, hasWarning]);
|
|
159
|
+
|
|
160
|
+
if (!isDevelopment) {
|
|
161
|
+
return null;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if (!isVisible) {
|
|
165
|
+
return (
|
|
166
|
+
<>
|
|
167
|
+
<LoggerAnimations color={currentColor} />
|
|
168
|
+
<LoggerTrigger
|
|
169
|
+
onClick={toggleVisibility}
|
|
170
|
+
logCount={logs.length}
|
|
171
|
+
currentColor={currentColor}
|
|
172
|
+
/>
|
|
173
|
+
</>
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
return (
|
|
178
|
+
<>
|
|
179
|
+
<LoggerAnimations color={currentColor} />
|
|
180
|
+
<LoggerTrigger
|
|
181
|
+
onClick={toggleVisibility}
|
|
182
|
+
logCount={logs.length}
|
|
183
|
+
currentColor={currentColor}
|
|
184
|
+
/>
|
|
185
|
+
<div className="fixed bottom-20 right-4 w-96 max-w-[calc(100vw-2rem)] bg-white rounded-lg shadow-xl z-50 border-2 border-gray-200 max-h-[70vh] flex flex-col">
|
|
186
|
+
<div className="flex items-center justify-between p-3 border-b border-gray-200">
|
|
187
|
+
<h3 className="font-bold flex items-center">Development Logger</h3>
|
|
188
|
+
<div className="flex space-x-2">
|
|
189
|
+
<button
|
|
190
|
+
onClick={clearLogs}
|
|
191
|
+
className="text-xs bg-gray-200 hover:bg-gray-300 px-2 py-1 rounded transition-colors"
|
|
192
|
+
>
|
|
193
|
+
Clear
|
|
194
|
+
</button>
|
|
195
|
+
<button
|
|
196
|
+
onClick={toggleVisibility}
|
|
197
|
+
className="text-xs bg-gray-200 hover:bg-gray-300 px-2 py-1 rounded transition-colors"
|
|
198
|
+
>
|
|
199
|
+
Close
|
|
200
|
+
</button>
|
|
201
|
+
</div>
|
|
202
|
+
</div>
|
|
203
|
+
<div className="overflow-y-auto flex-grow p-3">
|
|
204
|
+
{logs.length === 0 ? (
|
|
205
|
+
<p className="text-gray-500 text-center py-4">No logs yet</p>
|
|
206
|
+
) : (
|
|
207
|
+
logs.map((log) => <LogItem key={log.id} log={log} />)
|
|
208
|
+
)}
|
|
209
|
+
</div>
|
|
210
|
+
</div>
|
|
211
|
+
</>
|
|
212
|
+
);
|
|
213
|
+
};
|
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,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
|
@@ -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;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { BlockRendererProps } from './block-renderer-registry';
|
|
3
|
+
import ThemeBlock from '../theme-block';
|
|
4
|
+
|
|
5
|
+
const AccordionBlock: React.FC<BlockRendererProps> = ({
|
|
6
|
+
block,
|
|
7
|
+
placeholderId,
|
|
8
|
+
sectionId,
|
|
9
|
+
isDesigner,
|
|
10
|
+
selectedBlockId,
|
|
11
|
+
currentBreakpoint = 'desktop'
|
|
12
|
+
}) => {
|
|
13
|
+
const childBlocks = block.blocks || [];
|
|
14
|
+
|
|
15
|
+
const defaultOpen = block.properties?.defaultOpen === true;
|
|
16
|
+
const [isOpen, setIsOpen] = useState(defaultOpen);
|
|
17
|
+
|
|
18
|
+
const headingBlock = childBlocks.find((b) => b.label === 'Accordion Heading');
|
|
19
|
+
const contentBlock = childBlocks.find((b) => b.label === 'Accordion Content');
|
|
20
|
+
|
|
21
|
+
if (!headingBlock && !contentBlock) {
|
|
22
|
+
return (
|
|
23
|
+
<div className="p-4 text-gray-400 border border-dashed border-gray-300 rounded">
|
|
24
|
+
No accordion content
|
|
25
|
+
</div>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const renderHeading = () => {
|
|
30
|
+
if (!headingBlock) return null;
|
|
31
|
+
|
|
32
|
+
return headingBlock.blocks
|
|
33
|
+
?.filter((childBlock) => (isDesigner ? true : !childBlock.hidden))
|
|
34
|
+
.sort((a, b) => (a.order || 0) - (b.order || 0))
|
|
35
|
+
.map((childBlock, index) => {
|
|
36
|
+
const modifiedBlock =
|
|
37
|
+
childBlock.type === 'icon'
|
|
38
|
+
? {
|
|
39
|
+
...childBlock,
|
|
40
|
+
styles: {
|
|
41
|
+
...childBlock.styles,
|
|
42
|
+
transform: {
|
|
43
|
+
desktop: isOpen ? 'rotate(180deg)' : 'rotate(0deg)',
|
|
44
|
+
mobile: isOpen ? 'rotate(180deg)' : 'rotate(0deg)'
|
|
45
|
+
},
|
|
46
|
+
transition: {
|
|
47
|
+
desktop: 'transform 0.3s ease-in-out',
|
|
48
|
+
mobile: 'transform 0.3s ease-in-out'
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
: childBlock;
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<ThemeBlock
|
|
56
|
+
key={childBlock.id || `heading-block-${index}`}
|
|
57
|
+
block={modifiedBlock}
|
|
58
|
+
placeholderId={placeholderId}
|
|
59
|
+
sectionId={sectionId}
|
|
60
|
+
isDesigner={isDesigner}
|
|
61
|
+
isSelected={selectedBlockId === childBlock.id}
|
|
62
|
+
selectedBlockId={selectedBlockId}
|
|
63
|
+
currentBreakpoint={currentBreakpoint}
|
|
64
|
+
onMoveUp={undefined}
|
|
65
|
+
onMoveDown={undefined}
|
|
66
|
+
onDuplicate={undefined}
|
|
67
|
+
onToggleVisibility={undefined}
|
|
68
|
+
onDelete={undefined}
|
|
69
|
+
onRename={undefined}
|
|
70
|
+
/>
|
|
71
|
+
);
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const renderContent = () => {
|
|
76
|
+
if (!contentBlock) return null;
|
|
77
|
+
|
|
78
|
+
return contentBlock.blocks
|
|
79
|
+
?.filter((childBlock) => (isDesigner ? true : !childBlock.hidden))
|
|
80
|
+
.sort((a, b) => (a.order || 0) - (b.order || 0))
|
|
81
|
+
.map((childBlock, index) => {
|
|
82
|
+
return (
|
|
83
|
+
<ThemeBlock
|
|
84
|
+
key={childBlock.id || `content-block-${index}`}
|
|
85
|
+
block={childBlock}
|
|
86
|
+
placeholderId={placeholderId}
|
|
87
|
+
sectionId={sectionId}
|
|
88
|
+
isDesigner={isDesigner}
|
|
89
|
+
isSelected={selectedBlockId === childBlock.id}
|
|
90
|
+
selectedBlockId={selectedBlockId}
|
|
91
|
+
currentBreakpoint={currentBreakpoint}
|
|
92
|
+
onMoveUp={undefined}
|
|
93
|
+
onMoveDown={undefined}
|
|
94
|
+
onDuplicate={undefined}
|
|
95
|
+
onToggleVisibility={undefined}
|
|
96
|
+
onDelete={undefined}
|
|
97
|
+
onRename={undefined}
|
|
98
|
+
/>
|
|
99
|
+
);
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const toggleAccordion = (e: React.MouseEvent) => {
|
|
104
|
+
if (isDesigner) {
|
|
105
|
+
const target = e.target as HTMLElement;
|
|
106
|
+
if (
|
|
107
|
+
target.closest('[data-action-toolbar]') ||
|
|
108
|
+
target.closest('button') ||
|
|
109
|
+
target.closest('input')
|
|
110
|
+
) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
setIsOpen(!isOpen);
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
return (
|
|
118
|
+
<>
|
|
119
|
+
<div style={{ cursor: 'pointer' }} onClick={toggleAccordion}>
|
|
120
|
+
{renderHeading()}
|
|
121
|
+
</div>
|
|
122
|
+
|
|
123
|
+
<div
|
|
124
|
+
style={{
|
|
125
|
+
display: 'grid',
|
|
126
|
+
gridTemplateRows: isOpen ? '1fr' : '0fr',
|
|
127
|
+
transition: 'grid-template-rows 0.3s ease-in-out'
|
|
128
|
+
}}
|
|
129
|
+
>
|
|
130
|
+
<div style={{ overflow: 'hidden' }}>{renderContent()}</div>
|
|
131
|
+
</div>
|
|
132
|
+
</>
|
|
133
|
+
);
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
export default AccordionBlock;
|