@akinon/next 1.95.0 → 1.96.0-rc.56
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 +1259 -49
- package/__tests__/next-config.test.ts +1 -10
- package/__tests__/redirect.test.ts +319 -0
- package/api/image-proxy.ts +75 -0
- package/api/similar-product-list.ts +84 -0
- package/api/similar-products.ts +120 -0
- package/components/accordion.tsx +20 -5
- package/components/file-input.tsx +65 -3
- package/components/input.tsx +2 -0
- package/components/link.tsx +16 -12
- package/components/modal.tsx +32 -16
- package/components/plugin-module.tsx +30 -3
- package/data/client/checkout.ts +5 -4
- package/data/server/basket.ts +72 -0
- package/data/server/category.ts +48 -28
- package/data/server/flatpage.ts +16 -12
- package/data/server/landingpage.ts +16 -12
- package/data/server/list.ts +23 -13
- package/data/server/product.ts +66 -39
- package/data/server/special-page.ts +16 -12
- package/data/urls.ts +5 -1
- package/hocs/server/with-segment-defaults.tsx +5 -2
- package/hooks/use-localization.ts +2 -3
- package/jest.config.js +7 -1
- package/lib/cache.ts +2 -0
- package/middlewares/complete-gpay.ts +2 -1
- package/middlewares/complete-masterpass.ts +2 -1
- package/middlewares/default.ts +50 -13
- package/middlewares/locale.ts +9 -1
- package/middlewares/redirection-payment.ts +2 -1
- package/middlewares/saved-card-redirection.ts +2 -1
- package/middlewares/three-d-redirection.ts +2 -1
- package/middlewares/url-redirection.ts +8 -14
- package/package.json +3 -3
- package/plugins.d.ts +8 -0
- package/plugins.js +3 -1
- package/redux/middlewares/checkout.ts +5 -1
- package/types/commerce/order.ts +1 -0
- package/types/index.ts +34 -1
- package/utils/app-fetch.ts +7 -2
- package/utils/redirect-ignore.ts +35 -0
- package/utils/redirect.ts +31 -6
- package/with-pz-config.js +1 -5
package/data/server/product.ts
CHANGED
|
@@ -35,57 +35,84 @@ const getProductDataHandler = ({
|
|
|
35
35
|
.join('&');
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
38
|
+
let data: ProductResult;
|
|
39
|
+
|
|
40
|
+
try {
|
|
41
|
+
data = await appFetch<ProductResult>({
|
|
42
|
+
url,
|
|
43
|
+
locale,
|
|
44
|
+
currency,
|
|
45
|
+
init: {
|
|
46
|
+
headers: {
|
|
47
|
+
Accept: 'application/json',
|
|
48
|
+
'Content-Type': 'application/json',
|
|
49
|
+
...(headers ?? {})
|
|
50
|
+
}
|
|
47
51
|
}
|
|
48
|
-
}
|
|
49
|
-
})
|
|
52
|
+
});
|
|
53
|
+
} catch (error) {
|
|
54
|
+
logger.error('Failed to fetch product data', {
|
|
55
|
+
handler: 'getProductDataHandler',
|
|
56
|
+
pk,
|
|
57
|
+
error: error.message,
|
|
58
|
+
url
|
|
59
|
+
});
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
50
62
|
|
|
51
63
|
const categoryUrl = product.categoryUrl(data.product.pk);
|
|
52
64
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
65
|
+
let productCategoryData: ProductCategoryResult;
|
|
66
|
+
let breadcrumbData: { menu?: unknown } = {};
|
|
67
|
+
|
|
68
|
+
try {
|
|
69
|
+
productCategoryData = await appFetch<ProductCategoryResult>({
|
|
70
|
+
url: categoryUrl,
|
|
71
|
+
locale,
|
|
72
|
+
currency,
|
|
73
|
+
init: {
|
|
74
|
+
headers: {
|
|
75
|
+
Accept: 'application/json',
|
|
76
|
+
'Content-Type': 'application/json'
|
|
77
|
+
}
|
|
61
78
|
}
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
const menuItemModel = productCategoryData?.results[0]?.menuitemmodel;
|
|
82
|
+
|
|
83
|
+
if (!menuItemModel) {
|
|
84
|
+
logger.warn(
|
|
85
|
+
'menuItemModel is undefined, skipping breadcrumbData fetch',
|
|
86
|
+
{
|
|
87
|
+
handler: 'getProductDataHandler',
|
|
88
|
+
pk
|
|
89
|
+
}
|
|
90
|
+
);
|
|
91
|
+
return { data, breadcrumbData: undefined };
|
|
62
92
|
}
|
|
63
|
-
});
|
|
64
93
|
|
|
65
|
-
|
|
94
|
+
const breadcrumbUrl = product.breadcrumbUrl(menuItemModel);
|
|
66
95
|
|
|
67
|
-
|
|
68
|
-
|
|
96
|
+
breadcrumbData = await appFetch<{ menu?: unknown }>({
|
|
97
|
+
url: breadcrumbUrl,
|
|
98
|
+
locale,
|
|
99
|
+
currency,
|
|
100
|
+
init: {
|
|
101
|
+
headers: {
|
|
102
|
+
Accept: 'application/json',
|
|
103
|
+
'Content-Type': 'application/json'
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
} catch (error) {
|
|
108
|
+
logger.warn('Failed to fetch breadcrumb data', {
|
|
69
109
|
handler: 'getProductDataHandler',
|
|
70
|
-
pk
|
|
110
|
+
pk,
|
|
111
|
+
error: error.message
|
|
71
112
|
});
|
|
72
|
-
|
|
113
|
+
// Continue without breadcrumb data
|
|
73
114
|
}
|
|
74
115
|
|
|
75
|
-
const breadcrumbUrl = product.breadcrumbUrl(menuItemModel);
|
|
76
|
-
|
|
77
|
-
const breadcrumbData = await appFetch<any>({
|
|
78
|
-
url: breadcrumbUrl,
|
|
79
|
-
locale,
|
|
80
|
-
currency,
|
|
81
|
-
init: {
|
|
82
|
-
headers: {
|
|
83
|
-
Accept: 'application/json',
|
|
84
|
-
'Content-Type': 'application/json'
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
|
|
89
116
|
return {
|
|
90
117
|
data,
|
|
91
118
|
breadcrumbData: breadcrumbData?.menu
|
|
@@ -15,20 +15,24 @@ const getSpecialPageDataHandler = (
|
|
|
15
15
|
return async function () {
|
|
16
16
|
const params = generateCommerceSearchParams(searchParams);
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
18
|
+
try {
|
|
19
|
+
const data: GetCategoryResponse = await appFetch({
|
|
20
|
+
url: `${category.getSpecialPageByPk(pk)}${params}`,
|
|
21
|
+
locale,
|
|
22
|
+
currency,
|
|
23
|
+
init: {
|
|
24
|
+
headers: {
|
|
25
|
+
Accept: 'application/json',
|
|
26
|
+
'Content-Type': 'application/json',
|
|
27
|
+
...(headers ?? {})
|
|
28
|
+
}
|
|
27
29
|
}
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
+
});
|
|
30
31
|
|
|
31
|
-
|
|
32
|
+
return data;
|
|
33
|
+
} catch (error) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
32
36
|
};
|
|
33
37
|
};
|
|
34
38
|
|
package/data/urls.ts
CHANGED
|
@@ -183,7 +183,11 @@ export const product = {
|
|
|
183
183
|
breadcrumbUrl: (menuitemmodel: string) =>
|
|
184
184
|
`/menus/generate_breadcrumb/?item=${menuitemmodel}&generator_name=menu_item`,
|
|
185
185
|
bundleProduct: (productPk: string, queryString: string) =>
|
|
186
|
-
`/bundle-product/${productPk}/?${queryString}
|
|
186
|
+
`/bundle-product/${productPk}/?${queryString}`,
|
|
187
|
+
similarProducts: (params?: string) =>
|
|
188
|
+
`/similar-products${params ? `?${params}` : ''}`,
|
|
189
|
+
similarProductsList: (params?: string) =>
|
|
190
|
+
`/similar-product-list${params ? `?${params}` : ''}`
|
|
187
191
|
};
|
|
188
192
|
|
|
189
193
|
export const wishlist = {
|
|
@@ -72,10 +72,13 @@ const addRootLayoutProps = async (componentProps: RootLayoutProps) => {
|
|
|
72
72
|
const checkRedisVariables = () => {
|
|
73
73
|
const requiredVariableValues = [
|
|
74
74
|
process.env.CACHE_HOST,
|
|
75
|
-
process.env.CACHE_PORT
|
|
76
|
-
process.env.CACHE_SECRET
|
|
75
|
+
process.env.CACHE_PORT
|
|
77
76
|
];
|
|
78
77
|
|
|
78
|
+
if (!settings.usePrettyUrlRoute) {
|
|
79
|
+
requiredVariableValues.push(process.env.CACHE_SECRET);
|
|
80
|
+
}
|
|
81
|
+
|
|
79
82
|
if (
|
|
80
83
|
!requiredVariableValues.every((v) => v) &&
|
|
81
84
|
process.env.NODE_ENV === 'production'
|
|
@@ -4,7 +4,6 @@ import { LocalizationContext } from '../localization/provider';
|
|
|
4
4
|
import { useContext } from 'react';
|
|
5
5
|
import { setCookie, urlLocaleMatcherRegex } from '../utils';
|
|
6
6
|
import { LocaleUrlStrategy } from '../localization';
|
|
7
|
-
import { useRouter } from 'next/navigation';
|
|
8
7
|
|
|
9
8
|
export const useLocalization = () => {
|
|
10
9
|
const {
|
|
@@ -18,8 +17,6 @@ export const useLocalization = () => {
|
|
|
18
17
|
localeUrlStrategy
|
|
19
18
|
} = useContext(LocalizationContext);
|
|
20
19
|
|
|
21
|
-
const router = useRouter();
|
|
22
|
-
|
|
23
20
|
/**
|
|
24
21
|
* Sets the locale in the URL.
|
|
25
22
|
* @param locale Locale value defined in the settings.
|
|
@@ -30,6 +27,8 @@ export const useLocalization = () => {
|
|
|
30
27
|
|
|
31
28
|
let targetUrl;
|
|
32
29
|
|
|
30
|
+
setCookie('pz-locale', locale);
|
|
31
|
+
|
|
33
32
|
if (localeUrlStrategy === LocaleUrlStrategy.Subdomain) {
|
|
34
33
|
const hostParts = hostname.split('.');
|
|
35
34
|
const subDomain = hostParts[0];
|
package/jest.config.js
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
|
+
const findBaseDir = require('./utils/find-base-dir');
|
|
3
|
+
|
|
4
|
+
const baseDir = findBaseDir();
|
|
2
5
|
|
|
3
6
|
module.exports = {
|
|
4
7
|
preset: 'ts-jest',
|
|
5
8
|
testEnvironment: 'node',
|
|
6
9
|
rootDir: path.resolve(__dirname),
|
|
7
|
-
roots: [],
|
|
8
10
|
testMatch: ['**/*.test.ts'],
|
|
9
11
|
testPathIgnorePatterns: [],
|
|
12
|
+
roots: [path.resolve(__dirname)],
|
|
10
13
|
transformIgnorePatterns: [],
|
|
14
|
+
moduleNameMapper: {
|
|
15
|
+
'^settings$': path.resolve(baseDir, 'src/settings.js')
|
|
16
|
+
},
|
|
11
17
|
transform: {
|
|
12
18
|
'^.+\\.(tsx?|jsx?|mjs?)$': [
|
|
13
19
|
'ts-jest',
|
package/lib/cache.ts
CHANGED
|
@@ -31,6 +31,8 @@ export const CacheKey = {
|
|
|
31
31
|
`category_${pk}_${encodeURIComponent(
|
|
32
32
|
JSON.stringify(searchParams)
|
|
33
33
|
)}${hashCacheKey(headers)}`,
|
|
34
|
+
Basket: (namespace?: string) => `basket${namespace ? `_${namespace}` : ''}`,
|
|
35
|
+
AllBaskets: () => 'all_baskets',
|
|
34
36
|
CategorySlug: (slug: string) => `category_${slug}`,
|
|
35
37
|
SpecialPage: (
|
|
36
38
|
pk: number,
|
|
@@ -148,7 +148,8 @@ const withCompleteGpay =
|
|
|
148
148
|
logger.info('Redirecting to order success page', {
|
|
149
149
|
middleware: 'complete-gpay',
|
|
150
150
|
redirectUrlWithLocale,
|
|
151
|
-
ip
|
|
151
|
+
ip,
|
|
152
|
+
setCookie: request.headers.get('set-cookie')
|
|
152
153
|
});
|
|
153
154
|
|
|
154
155
|
// Using POST method while redirecting causes an error,
|
|
@@ -149,7 +149,8 @@ const withCompleteMasterpass =
|
|
|
149
149
|
logger.info('Redirecting to order success page', {
|
|
150
150
|
middleware: 'complete-masterpass',
|
|
151
151
|
redirectUrlWithLocale,
|
|
152
|
-
ip
|
|
152
|
+
ip,
|
|
153
|
+
setCookie: request.headers.get('set-cookie')
|
|
153
154
|
});
|
|
154
155
|
|
|
155
156
|
// Using POST method while redirecting causes an error,
|
package/middlewares/default.ts
CHANGED
|
@@ -302,19 +302,6 @@ const withPzDefault =
|
|
|
302
302
|
)}`;
|
|
303
303
|
}
|
|
304
304
|
|
|
305
|
-
if (
|
|
306
|
-
!req.middlewareParams.found &&
|
|
307
|
-
Settings.customNotFoundEnabled
|
|
308
|
-
) {
|
|
309
|
-
const pathname = url.pathname
|
|
310
|
-
.replace(/\/+$/, '')
|
|
311
|
-
.split('/');
|
|
312
|
-
url.pathname = url.pathname.replace(
|
|
313
|
-
pathname.pop(),
|
|
314
|
-
'pz-not-found'
|
|
315
|
-
);
|
|
316
|
-
}
|
|
317
|
-
|
|
318
305
|
Settings.rewrites.forEach((rewrite) => {
|
|
319
306
|
url.pathname = url.pathname.replace(
|
|
320
307
|
rewrite.source,
|
|
@@ -352,6 +339,24 @@ const withPzDefault =
|
|
|
352
339
|
middlewareResult = NextResponse.rewrite(url);
|
|
353
340
|
}
|
|
354
341
|
|
|
342
|
+
if (
|
|
343
|
+
!req.middlewareParams.found &&
|
|
344
|
+
Settings.customNotFoundEnabled
|
|
345
|
+
) {
|
|
346
|
+
const pathSegments = url.pathname
|
|
347
|
+
.replace(/\/+$/, '')
|
|
348
|
+
.split('/');
|
|
349
|
+
if (pathSegments.length >= 3) {
|
|
350
|
+
url.pathname = `/${pathSegments[1]}/${pathSegments[2]}/pz-not-found`;
|
|
351
|
+
} else {
|
|
352
|
+
url.pathname = '/pz-not-found';
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
middlewareResult = NextResponse.rewrite(url, {
|
|
356
|
+
status: 404
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
|
|
355
360
|
const { localeUrlStrategy } =
|
|
356
361
|
Settings.localization;
|
|
357
362
|
|
|
@@ -401,6 +406,38 @@ const withPzDefault =
|
|
|
401
406
|
}
|
|
402
407
|
);
|
|
403
408
|
|
|
409
|
+
if (
|
|
410
|
+
!url.pathname.startsWith(
|
|
411
|
+
`/${currency}/orders`
|
|
412
|
+
)
|
|
413
|
+
) {
|
|
414
|
+
const currentCookieLocale =
|
|
415
|
+
req.cookies.get('pz-locale')?.value;
|
|
416
|
+
|
|
417
|
+
const urlHasExplicitLocale =
|
|
418
|
+
url.pathname.match(urlLocaleMatcherRegex);
|
|
419
|
+
const shouldUpdateCookie =
|
|
420
|
+
!currentCookieLocale ||
|
|
421
|
+
urlHasExplicitLocale;
|
|
422
|
+
|
|
423
|
+
if (shouldUpdateCookie) {
|
|
424
|
+
middlewareResult.cookies.set(
|
|
425
|
+
'pz-locale',
|
|
426
|
+
locale?.length > 0
|
|
427
|
+
? locale
|
|
428
|
+
: defaultLocaleValue,
|
|
429
|
+
{
|
|
430
|
+
domain: rootHostname,
|
|
431
|
+
sameSite: 'none',
|
|
432
|
+
secure: true,
|
|
433
|
+
expires: new Date(
|
|
434
|
+
Date.now() + 1000 * 60 * 60 * 24 * 7
|
|
435
|
+
) // 7 days
|
|
436
|
+
}
|
|
437
|
+
);
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
|
|
404
441
|
if (
|
|
405
442
|
req.cookies.get('pz-locale') &&
|
|
406
443
|
req.cookies.get('pz-locale').value !== locale
|
package/middlewares/locale.ts
CHANGED
|
@@ -23,7 +23,15 @@ const getMatchedLocale = (pathname: string, req: PzNextRequest) => {
|
|
|
23
23
|
);
|
|
24
24
|
|
|
25
25
|
if (subDomainLocaleMatched && subDomainLocaleMatched[0]) {
|
|
26
|
-
|
|
26
|
+
const subdomainLocale = subDomainLocaleMatched[0].slice(1);
|
|
27
|
+
|
|
28
|
+
const isValidSubdomainLocale = settings.localization.locales.find(
|
|
29
|
+
(l) => l.value === subdomainLocale
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
if (isValidSubdomainLocale) {
|
|
33
|
+
matchedLocale = subdomainLocale;
|
|
34
|
+
}
|
|
27
35
|
}
|
|
28
36
|
}
|
|
29
37
|
}
|
|
@@ -149,7 +149,8 @@ const withRedirectionPayment =
|
|
|
149
149
|
logger.info('Redirecting to order success page', {
|
|
150
150
|
middleware: 'redirection-payment',
|
|
151
151
|
redirectUrlWithLocale,
|
|
152
|
-
ip
|
|
152
|
+
ip,
|
|
153
|
+
setCookie: request.headers.get('set-cookie')
|
|
153
154
|
});
|
|
154
155
|
|
|
155
156
|
// Using POST method while redirecting causes an error,
|
|
@@ -149,7 +149,8 @@ const withSavedCardRedirection =
|
|
|
149
149
|
logger.info('Redirecting to order success page', {
|
|
150
150
|
middleware: 'saved-card-redirection',
|
|
151
151
|
redirectUrlWithLocale,
|
|
152
|
-
ip
|
|
152
|
+
ip,
|
|
153
|
+
setCookie: request.headers.get('set-cookie')
|
|
153
154
|
});
|
|
154
155
|
|
|
155
156
|
// Using POST method while redirecting causes an error,
|
|
@@ -149,7 +149,8 @@ const withThreeDRedirection =
|
|
|
149
149
|
logger.info('Redirecting to order success page', {
|
|
150
150
|
middleware: 'three-d-redirection',
|
|
151
151
|
redirectUrlWithLocale,
|
|
152
|
-
ip
|
|
152
|
+
ip,
|
|
153
|
+
setCookie: request.headers.get('set-cookie')
|
|
153
154
|
});
|
|
154
155
|
|
|
155
156
|
// Using POST method while redirecting causes an error,
|
|
@@ -4,6 +4,7 @@ import { PzNextRequest } from '.';
|
|
|
4
4
|
import logger from '../utils/log';
|
|
5
5
|
import { urlLocaleMatcherRegex } from '../utils';
|
|
6
6
|
import { getUrlPathWithLocale } from '../utils/localization';
|
|
7
|
+
import { shouldIgnoreRedirect } from '../utils/redirect-ignore';
|
|
7
8
|
import { ROUTES } from 'routes';
|
|
8
9
|
|
|
9
10
|
// This middleware is used to handle url redirections set in Omnitron
|
|
@@ -60,20 +61,13 @@ const withUrlRedirection =
|
|
|
60
61
|
|
|
61
62
|
const setCookies = request.headers.getSetCookie();
|
|
62
63
|
|
|
63
|
-
if (
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
)
|
|
71
|
-
)
|
|
72
|
-
);
|
|
73
|
-
|
|
74
|
-
if (shouldIgnoreRedirect) {
|
|
75
|
-
return middleware(req, event);
|
|
76
|
-
}
|
|
64
|
+
if (
|
|
65
|
+
shouldIgnoreRedirect(
|
|
66
|
+
url.pathname,
|
|
67
|
+
req.middlewareParams.rewrites.locale
|
|
68
|
+
)
|
|
69
|
+
) {
|
|
70
|
+
return middleware(req, event);
|
|
77
71
|
}
|
|
78
72
|
|
|
79
73
|
const response = NextResponse.redirect(redirectUrl.toString(), {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akinon/next",
|
|
3
3
|
"description": "Core package for Project Zero Next",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.96.0-rc.56",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"bin": {
|
|
@@ -17,13 +17,13 @@
|
|
|
17
17
|
"test": "jest"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@neshca/cache-handler": "1.5.1",
|
|
21
20
|
"@opentelemetry/exporter-trace-otlp-http": "0.46.0",
|
|
22
21
|
"@opentelemetry/resources": "1.19.0",
|
|
23
22
|
"@opentelemetry/sdk-node": "0.46.0",
|
|
24
23
|
"@opentelemetry/sdk-trace-node": "1.19.0",
|
|
25
24
|
"@opentelemetry/semantic-conventions": "1.19.0",
|
|
26
25
|
"@reduxjs/toolkit": "1.9.7",
|
|
26
|
+
"@neshca/cache-handler": "1.9.0",
|
|
27
27
|
"@sentry/nextjs": "9.5.0",
|
|
28
28
|
"cross-spawn": "7.0.3",
|
|
29
29
|
"generic-pool": "3.9.0",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"set-cookie-parser": "2.6.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@akinon/eslint-plugin-projectzero": "1.
|
|
37
|
+
"@akinon/eslint-plugin-projectzero": "1.96.0-rc.56",
|
|
38
38
|
"@babel/core": "7.26.10",
|
|
39
39
|
"@babel/preset-env": "7.26.9",
|
|
40
40
|
"@babel/preset-typescript": "7.27.0",
|
package/plugins.d.ts
CHANGED
|
@@ -38,3 +38,11 @@ declare module '@akinon/pz-iyzico-saved-card' {
|
|
|
38
38
|
declare module '@akinon/pz-apple-pay' {}
|
|
39
39
|
|
|
40
40
|
declare module '@akinon/pz-flow-payment' {}
|
|
41
|
+
|
|
42
|
+
declare module '@akinon/pz-similar-products' {
|
|
43
|
+
export const SimilarProductsModal: any;
|
|
44
|
+
export const SimilarProductsFilterSidebar: any;
|
|
45
|
+
export const SimilarProductsResultsGrid: any;
|
|
46
|
+
export const SimilarProductsPlugin: any;
|
|
47
|
+
export const SimilarProductsButtonPlugin: any;
|
|
48
|
+
}
|
package/plugins.js
CHANGED
|
@@ -51,7 +51,11 @@ export const errorMiddleware: Middleware = ({ dispatch }: MiddlewareParams) => {
|
|
|
51
51
|
const result: CheckoutResult = next(action);
|
|
52
52
|
const errors = result?.payload?.errors;
|
|
53
53
|
|
|
54
|
-
if (
|
|
54
|
+
if (
|
|
55
|
+
!!errors &&
|
|
56
|
+
((typeof errors === 'object' && Object.keys(errors).length > 0) ||
|
|
57
|
+
(Array.isArray(errors) && errors.length > 0))
|
|
58
|
+
) {
|
|
55
59
|
dispatch(setErrors(errors));
|
|
56
60
|
}
|
|
57
61
|
|
package/types/commerce/order.ts
CHANGED
package/types/index.ts
CHANGED
|
@@ -83,6 +83,12 @@ export interface Settings {
|
|
|
83
83
|
};
|
|
84
84
|
usePrettyUrlRoute?: boolean;
|
|
85
85
|
commerceUrl: string;
|
|
86
|
+
/**
|
|
87
|
+
* This option allows you to track Sentry events on the client side, in addition to server and edge environments.
|
|
88
|
+
*
|
|
89
|
+
* It overrides process.env.NEXT_PUBLIC_SENTRY_DSN and process.env.SENTRY_DSN.
|
|
90
|
+
*/
|
|
91
|
+
sentryDsn?: string;
|
|
86
92
|
redis: {
|
|
87
93
|
defaultExpirationTime: number;
|
|
88
94
|
};
|
|
@@ -291,7 +297,13 @@ export interface ButtonProps
|
|
|
291
297
|
target?: '_blank' | '_self' | '_parent' | '_top';
|
|
292
298
|
}
|
|
293
299
|
|
|
294
|
-
export
|
|
300
|
+
export interface FileInputProps extends React.HTMLProps<HTMLInputElement> {
|
|
301
|
+
fileClassName?: string;
|
|
302
|
+
fileNameWrapperClassName?: string;
|
|
303
|
+
fileInputClassName?: string;
|
|
304
|
+
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
305
|
+
buttonClassName?: string;
|
|
306
|
+
}
|
|
295
307
|
|
|
296
308
|
export interface PriceProps {
|
|
297
309
|
currencyCode?: string;
|
|
@@ -312,15 +324,19 @@ export interface InputProps extends React.HTMLProps<HTMLInputElement> {
|
|
|
312
324
|
|
|
313
325
|
export interface AccordionProps {
|
|
314
326
|
isCollapse?: boolean;
|
|
327
|
+
collapseClassName?: string;
|
|
315
328
|
title?: string;
|
|
316
329
|
subTitle?: string;
|
|
317
330
|
icons?: string[];
|
|
318
331
|
iconSize?: number;
|
|
319
332
|
iconColor?: string;
|
|
320
333
|
children?: ReactNode;
|
|
334
|
+
headerClassName?: string;
|
|
321
335
|
className?: string;
|
|
322
336
|
titleClassName?: string;
|
|
337
|
+
subTitleClassName?: string;
|
|
323
338
|
dataTestId?: string;
|
|
339
|
+
contentClassName?: string;
|
|
324
340
|
}
|
|
325
341
|
|
|
326
342
|
export interface PluginModuleComponentProps {
|
|
@@ -345,3 +361,20 @@ export interface PaginationProps {
|
|
|
345
361
|
direction?: 'next' | 'prev';
|
|
346
362
|
isLoading?: boolean;
|
|
347
363
|
}
|
|
364
|
+
|
|
365
|
+
export interface ModalProps {
|
|
366
|
+
portalId: string;
|
|
367
|
+
children?: React.ReactNode;
|
|
368
|
+
open?: boolean;
|
|
369
|
+
setOpen?: (open: boolean) => void;
|
|
370
|
+
title?: React.ReactNode;
|
|
371
|
+
showCloseButton?: React.ReactNode;
|
|
372
|
+
className?: string;
|
|
373
|
+
overlayClassName?: string;
|
|
374
|
+
headerWrapperClassName?: string;
|
|
375
|
+
titleClassName?: string;
|
|
376
|
+
closeButtonClassName?: string;
|
|
377
|
+
iconName?: string;
|
|
378
|
+
iconSize?: number;
|
|
379
|
+
iconClassName?: string;
|
|
380
|
+
}
|
package/utils/app-fetch.ts
CHANGED
|
@@ -43,12 +43,12 @@ const appFetch = async <T>({
|
|
|
43
43
|
const requestURL = `${decodeURIComponent(commerceUrl)}${url}`;
|
|
44
44
|
|
|
45
45
|
init.headers = {
|
|
46
|
+
cookie: nextCookies.toString(),
|
|
46
47
|
...(init.headers ?? {}),
|
|
47
48
|
...(ServerVariables.globalHeaders ?? {}),
|
|
48
49
|
'Accept-Language': currentLocale.apiValue,
|
|
49
50
|
'x-currency': currency,
|
|
50
|
-
'x-forwarded-for': ip
|
|
51
|
-
cookie: nextCookies.toString()
|
|
51
|
+
'x-forwarded-for': ip
|
|
52
52
|
};
|
|
53
53
|
|
|
54
54
|
init.next = {
|
|
@@ -60,6 +60,11 @@ const appFetch = async <T>({
|
|
|
60
60
|
status = req.status;
|
|
61
61
|
logger.debug(`FETCH END ${url}`, { status: req.status, ip });
|
|
62
62
|
|
|
63
|
+
if (!req.ok) {
|
|
64
|
+
const errorMessage = `HTTP ${req.status}: ${req.statusText}`;
|
|
65
|
+
throw new Error(errorMessage);
|
|
66
|
+
}
|
|
67
|
+
|
|
63
68
|
if (responseType === FetchResponseType.JSON) {
|
|
64
69
|
response = (await req.json()) as T;
|
|
65
70
|
} else {
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import settings from 'settings';
|
|
2
|
+
import { getUrlPathWithLocale } from './localization';
|
|
3
|
+
|
|
4
|
+
type IgnorePath = string | RegExp;
|
|
5
|
+
|
|
6
|
+
const defaultIgnoreList: string[] = [];
|
|
7
|
+
|
|
8
|
+
const extraIgnores: IgnorePath[] = Array.isArray(
|
|
9
|
+
settings.commerceRedirectionIgnoreList
|
|
10
|
+
)
|
|
11
|
+
? settings.commerceRedirectionIgnoreList.map((path) => {
|
|
12
|
+
if (path === '/users/reset') {
|
|
13
|
+
return /^\/users\/reset\/[^/]+\/[^/]+\/$/;
|
|
14
|
+
}
|
|
15
|
+
return path;
|
|
16
|
+
})
|
|
17
|
+
: [];
|
|
18
|
+
|
|
19
|
+
export function shouldIgnoreRedirect(
|
|
20
|
+
pathname: string,
|
|
21
|
+
locale: string
|
|
22
|
+
): boolean {
|
|
23
|
+
if (!pathname) return false;
|
|
24
|
+
|
|
25
|
+
const rawIgnoreList: IgnorePath[] = [...defaultIgnoreList, ...extraIgnores];
|
|
26
|
+
|
|
27
|
+
return rawIgnoreList.some((ignorePath) => {
|
|
28
|
+
if (ignorePath instanceof RegExp) {
|
|
29
|
+
return ignorePath.test(pathname);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const localized = getUrlPathWithLocale(ignorePath, locale);
|
|
33
|
+
return localized === pathname;
|
|
34
|
+
});
|
|
35
|
+
}
|