@akinon/next 1.96.0-rc.57 → 1.96.0-snapshot-ZERO-35861-20250908151109
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 +41 -1246
- package/__tests__/next-config.test.ts +10 -1
- package/api/cache.ts +39 -5
- package/components/accordion.tsx +5 -20
- package/components/file-input.tsx +3 -65
- package/components/input.tsx +0 -2
- package/components/link.tsx +12 -16
- package/components/modal.tsx +16 -32
- package/components/plugin-module.tsx +3 -30
- package/data/client/checkout.ts +4 -5
- package/data/server/category.ts +32 -50
- package/data/server/flatpage.ts +16 -17
- package/data/server/form.ts +4 -1
- package/data/server/landingpage.ts +12 -16
- package/data/server/list.ts +15 -24
- package/data/server/menu.ts +5 -2
- package/data/server/product.ts +41 -67
- package/data/server/special-page.ts +12 -16
- package/data/server/widget.ts +4 -1
- package/data/urls.ts +1 -5
- package/hocs/server/with-segment-defaults.tsx +2 -5
- package/hooks/use-localization.ts +3 -2
- package/jest.config.js +1 -7
- package/lib/cache-handler.mjs +365 -87
- package/lib/cache.ts +252 -25
- package/middlewares/complete-gpay.ts +1 -2
- package/middlewares/complete-masterpass.ts +1 -2
- package/middlewares/default.ts +13 -50
- package/middlewares/locale.ts +1 -9
- package/middlewares/pretty-url.ts +2 -1
- package/middlewares/redirection-payment.ts +1 -2
- package/middlewares/saved-card-redirection.ts +1 -2
- package/middlewares/three-d-redirection.ts +1 -2
- package/middlewares/url-redirection.ts +14 -8
- package/package.json +4 -3
- package/plugins.d.ts +0 -8
- package/plugins.js +1 -3
- package/redux/middlewares/checkout.ts +1 -5
- package/types/commerce/order.ts +0 -1
- package/types/index.ts +2 -34
- package/utils/app-fetch.ts +2 -7
- package/utils/redirect.ts +6 -31
- package/with-pz-config.js +5 -1
- package/__tests__/redirect.test.ts +0 -319
- package/api/image-proxy.ts +0 -75
- package/api/similar-product-list.ts +0 -84
- package/api/similar-products.ts +0 -120
- package/data/server/basket.ts +0 -72
- package/utils/redirect-ignore.ts +0 -35
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import { resolve } from 'path';
|
|
2
2
|
import type { NextConfig } from 'next';
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
function findBaseDir() {
|
|
5
|
+
const insideNodeModules = __dirname.includes('node_modules');
|
|
6
|
+
|
|
7
|
+
if (insideNodeModules) {
|
|
8
|
+
return resolve(__dirname, '../../../../');
|
|
9
|
+
} else {
|
|
10
|
+
return resolve(__dirname, '../../../apps/projectzeronext');
|
|
11
|
+
}
|
|
12
|
+
}
|
|
4
13
|
|
|
5
14
|
const baseDir = findBaseDir();
|
|
6
15
|
|
package/api/cache.ts
CHANGED
|
@@ -21,20 +21,54 @@ async function handleRequest(...args) {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
const formData = await req.formData();
|
|
24
|
-
const body = {} as {
|
|
24
|
+
const body = {} as {
|
|
25
|
+
key: string;
|
|
26
|
+
value?: string;
|
|
27
|
+
expire?: number;
|
|
28
|
+
keyValuePairs?: string;
|
|
29
|
+
compressed?: string;
|
|
30
|
+
};
|
|
25
31
|
|
|
26
32
|
formData.forEach((value, key) => {
|
|
27
33
|
body[key] = value;
|
|
28
34
|
});
|
|
29
35
|
|
|
30
|
-
const { key, value, expire } = body;
|
|
31
|
-
let response:
|
|
36
|
+
const { key, value, expire, keyValuePairs, compressed } = body;
|
|
37
|
+
let response: any;
|
|
32
38
|
|
|
33
39
|
try {
|
|
34
40
|
if (req.method === 'POST') {
|
|
35
|
-
|
|
41
|
+
if (compressed === 'true') {
|
|
42
|
+
response = await Cache.getCompressed(key);
|
|
43
|
+
} else {
|
|
44
|
+
response = await Cache.get(key);
|
|
45
|
+
}
|
|
36
46
|
} else if (req.method === 'PUT') {
|
|
37
|
-
|
|
47
|
+
if (keyValuePairs) {
|
|
48
|
+
try {
|
|
49
|
+
const parsedKeyValuePairs = JSON.parse(keyValuePairs);
|
|
50
|
+
if (
|
|
51
|
+
typeof parsedKeyValuePairs !== 'object' ||
|
|
52
|
+
parsedKeyValuePairs === null ||
|
|
53
|
+
Array.isArray(parsedKeyValuePairs)
|
|
54
|
+
) {
|
|
55
|
+
throw new Error('Invalid keyValuePairs format - must be an object');
|
|
56
|
+
}
|
|
57
|
+
response = await Cache.mset(parsedKeyValuePairs, expire);
|
|
58
|
+
} catch (error) {
|
|
59
|
+
logger.error('Invalid keyValuePairs in mset request', { error });
|
|
60
|
+
return NextResponse.json(
|
|
61
|
+
{ error: 'Invalid keyValuePairs format' },
|
|
62
|
+
{ status: 400 }
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
} else {
|
|
66
|
+
if (compressed === 'true') {
|
|
67
|
+
response = await Cache.setCompressed(key, value, expire);
|
|
68
|
+
} else {
|
|
69
|
+
response = await Cache.set(key, value, expire);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
38
72
|
}
|
|
39
73
|
} catch (error) {
|
|
40
74
|
logger.error(error);
|
package/components/accordion.tsx
CHANGED
|
@@ -7,19 +7,15 @@ import { AccordionProps } from '../types';
|
|
|
7
7
|
|
|
8
8
|
export const Accordion = ({
|
|
9
9
|
isCollapse = false,
|
|
10
|
-
collapseClassName,
|
|
11
10
|
title,
|
|
12
11
|
subTitle,
|
|
13
12
|
icons = ['chevron-up', 'chevron-down'],
|
|
14
13
|
iconSize = 16,
|
|
15
14
|
iconColor = 'fill-[#000000]',
|
|
16
15
|
children,
|
|
17
|
-
headerClassName,
|
|
18
16
|
className,
|
|
19
17
|
titleClassName,
|
|
20
|
-
|
|
21
|
-
dataTestId,
|
|
22
|
-
contentClassName
|
|
18
|
+
dataTestId
|
|
23
19
|
}: AccordionProps) => {
|
|
24
20
|
const [collapse, setCollapse] = useState(isCollapse);
|
|
25
21
|
|
|
@@ -31,22 +27,15 @@ export const Accordion = ({
|
|
|
31
27
|
)}
|
|
32
28
|
>
|
|
33
29
|
<div
|
|
34
|
-
className=
|
|
35
|
-
'flex items-center justify-between cursor-pointer',
|
|
36
|
-
headerClassName
|
|
37
|
-
)}
|
|
30
|
+
className="flex items-center justify-between cursor-pointer"
|
|
38
31
|
onClick={() => setCollapse(!collapse)}
|
|
39
32
|
data-testid={dataTestId}
|
|
40
33
|
>
|
|
41
|
-
<div className=
|
|
34
|
+
<div className="flex flex-col">
|
|
42
35
|
{title && (
|
|
43
36
|
<h3 className={twMerge('text-sm', titleClassName)}>{title}</h3>
|
|
44
37
|
)}
|
|
45
|
-
{subTitle &&
|
|
46
|
-
<h4 className={twMerge('text-xs text-gray-700', subTitleClassName)}>
|
|
47
|
-
{subTitle}
|
|
48
|
-
</h4>
|
|
49
|
-
)}
|
|
38
|
+
{subTitle && <h4 className="text-xs text-gray-700">{subTitle}</h4>}
|
|
50
39
|
</div>
|
|
51
40
|
|
|
52
41
|
{icons && (
|
|
@@ -57,11 +46,7 @@ export const Accordion = ({
|
|
|
57
46
|
/>
|
|
58
47
|
)}
|
|
59
48
|
</div>
|
|
60
|
-
{collapse &&
|
|
61
|
-
<div className={twMerge('mt-3 text-sm', collapseClassName)}>
|
|
62
|
-
{children}
|
|
63
|
-
</div>
|
|
64
|
-
)}
|
|
49
|
+
{collapse && <div className="mt-3 text-sm">{children}</div>}
|
|
65
50
|
</div>
|
|
66
51
|
);
|
|
67
52
|
};
|
|
@@ -1,70 +1,8 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
2
1
|
import { forwardRef } from 'react';
|
|
3
|
-
import {
|
|
4
|
-
import { twMerge } from 'tailwind-merge';
|
|
5
|
-
import { FileInputProps } from '../types';
|
|
2
|
+
import { FileInputProps } from '../types/index';
|
|
6
3
|
|
|
7
4
|
export const FileInput = forwardRef<HTMLInputElement, FileInputProps>(
|
|
8
|
-
function
|
|
9
|
-
{
|
|
10
|
-
buttonClassName,
|
|
11
|
-
onChange,
|
|
12
|
-
fileClassName,
|
|
13
|
-
fileNameWrapperClassName,
|
|
14
|
-
fileInputClassName,
|
|
15
|
-
...props
|
|
16
|
-
},
|
|
17
|
-
ref
|
|
18
|
-
) {
|
|
19
|
-
const { t } = useLocalization();
|
|
20
|
-
const [fileNames, setFileNames] = useState<string[]>([]);
|
|
21
|
-
|
|
22
|
-
const handleFileChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
23
|
-
const files = Array.from(event.target.files || []);
|
|
24
|
-
setFileNames(files.map((file) => file.name));
|
|
25
|
-
|
|
26
|
-
if (onChange) {
|
|
27
|
-
onChange(event);
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
return (
|
|
32
|
-
<div className="relative">
|
|
33
|
-
<input
|
|
34
|
-
type="file"
|
|
35
|
-
{...props}
|
|
36
|
-
ref={ref}
|
|
37
|
-
className={twMerge(
|
|
38
|
-
'absolute inset-0 w-full h-full opacity-0 cursor-pointer',
|
|
39
|
-
fileInputClassName
|
|
40
|
-
)}
|
|
41
|
-
onChange={handleFileChange}
|
|
42
|
-
/>
|
|
43
|
-
<button
|
|
44
|
-
type="button"
|
|
45
|
-
className={twMerge(
|
|
46
|
-
'bg-primary text-white py-2 px-4 text-sm',
|
|
47
|
-
buttonClassName
|
|
48
|
-
)}
|
|
49
|
-
>
|
|
50
|
-
{t('common.file_input.select_file')}
|
|
51
|
-
</button>
|
|
52
|
-
<div
|
|
53
|
-
className={twMerge('mt-1 text-gray-500', fileNameWrapperClassName)}
|
|
54
|
-
>
|
|
55
|
-
{fileNames.length > 0 ? (
|
|
56
|
-
<ul className={twMerge('list-disc pl-4 text-xs', fileClassName)}>
|
|
57
|
-
{fileNames.map((name, index) => (
|
|
58
|
-
<li key={index}>{name}</li>
|
|
59
|
-
))}
|
|
60
|
-
</ul>
|
|
61
|
-
) : (
|
|
62
|
-
<span className={twMerge('text-xs', fileClassName)}>
|
|
63
|
-
{t('common.file_input.no_file')}
|
|
64
|
-
</span>
|
|
65
|
-
)}
|
|
66
|
-
</div>
|
|
67
|
-
</div>
|
|
68
|
-
);
|
|
5
|
+
function fileInput(props, ref) {
|
|
6
|
+
return <input type="file" {...props} ref={ref} />;
|
|
69
7
|
}
|
|
70
8
|
);
|
package/components/input.tsx
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import clsx from 'clsx';
|
|
2
2
|
import { forwardRef, FocusEvent, useState, Ref } from 'react';
|
|
3
3
|
import { Controller } from 'react-hook-form';
|
|
4
|
-
|
|
5
|
-
// @ts-ignore
|
|
6
4
|
import { PatternFormat, PatternFormatProps } from 'react-number-format';
|
|
7
5
|
import { InputProps } from '../types';
|
|
8
6
|
import { twMerge } from 'tailwind-merge';
|
package/components/link.tsx
CHANGED
|
@@ -10,9 +10,7 @@ type LinkProps = Omit<
|
|
|
10
10
|
React.AnchorHTMLAttributes<HTMLAnchorElement>,
|
|
11
11
|
keyof NextLinkProps
|
|
12
12
|
> &
|
|
13
|
-
NextLinkProps
|
|
14
|
-
href: string;
|
|
15
|
-
};
|
|
13
|
+
NextLinkProps;
|
|
16
14
|
|
|
17
15
|
export const Link = ({ children, href, ...rest }: LinkProps) => {
|
|
18
16
|
const { locale, defaultLocaleValue, localeUrlStrategy } = useLocalization();
|
|
@@ -28,21 +26,19 @@ export const Link = ({ children, href, ...rest }: LinkProps) => {
|
|
|
28
26
|
return href;
|
|
29
27
|
}
|
|
30
28
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return hrefWithLocale;
|
|
42
|
-
}
|
|
29
|
+
const pathnameWithoutLocale = href.replace(urlLocaleMatcherRegex, '');
|
|
30
|
+
const hrefWithLocale = `/${locale}${pathnameWithoutLocale}`;
|
|
31
|
+
|
|
32
|
+
if (localeUrlStrategy === LocaleUrlStrategy.ShowAllLocales) {
|
|
33
|
+
return hrefWithLocale;
|
|
34
|
+
} else if (
|
|
35
|
+
localeUrlStrategy === LocaleUrlStrategy.HideDefaultLocale &&
|
|
36
|
+
locale !== defaultLocaleValue
|
|
37
|
+
) {
|
|
38
|
+
return hrefWithLocale;
|
|
43
39
|
}
|
|
44
40
|
|
|
45
|
-
return href;
|
|
41
|
+
return href || '#';
|
|
46
42
|
}, [href, defaultLocaleValue, locale, localeUrlStrategy]);
|
|
47
43
|
|
|
48
44
|
return (
|
package/components/modal.tsx
CHANGED
|
@@ -4,7 +4,16 @@ 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
|
-
|
|
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
|
+
}
|
|
8
17
|
|
|
9
18
|
export const Modal = (props: ModalProps) => {
|
|
10
19
|
const {
|
|
@@ -14,14 +23,7 @@ export const Modal = (props: ModalProps) => {
|
|
|
14
23
|
setOpen,
|
|
15
24
|
title = '',
|
|
16
25
|
showCloseButton = true,
|
|
17
|
-
className
|
|
18
|
-
overlayClassName,
|
|
19
|
-
headerWrapperClassName,
|
|
20
|
-
titleClassName,
|
|
21
|
-
closeButtonClassName,
|
|
22
|
-
iconName = 'close',
|
|
23
|
-
iconSize = 16,
|
|
24
|
-
iconClassName
|
|
26
|
+
className
|
|
25
27
|
} = props;
|
|
26
28
|
|
|
27
29
|
useEffect(() => {
|
|
@@ -36,12 +38,7 @@ export const Modal = (props: ModalProps) => {
|
|
|
36
38
|
|
|
37
39
|
return (
|
|
38
40
|
<ReactPortal wrapperId={portalId}>
|
|
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
|
-
/>
|
|
41
|
+
<div className="fixed top-0 left-0 w-screen h-screen bg-primary bg-opacity-60 z-50" />
|
|
45
42
|
<section
|
|
46
43
|
className={twMerge(
|
|
47
44
|
'fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 z-50 bg-white',
|
|
@@ -49,28 +46,15 @@ export const Modal = (props: ModalProps) => {
|
|
|
49
46
|
)}
|
|
50
47
|
>
|
|
51
48
|
{(showCloseButton || title) && (
|
|
52
|
-
<div
|
|
53
|
-
className={
|
|
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
|
-
)}
|
|
49
|
+
<div className="flex px-6 py-4 border-b border-gray-400">
|
|
50
|
+
{title && <h3 className="text-lg font-light">{title}</h3>}
|
|
63
51
|
{showCloseButton && (
|
|
64
52
|
<button
|
|
65
53
|
type="button"
|
|
66
54
|
onClick={() => setOpen(false)}
|
|
67
|
-
className=
|
|
55
|
+
className="ml-auto"
|
|
68
56
|
>
|
|
69
|
-
<Icon
|
|
70
|
-
name={iconName}
|
|
71
|
-
size={iconSize}
|
|
72
|
-
className={iconClassName}
|
|
73
|
-
/>
|
|
57
|
+
<Icon name="close" size={16} />
|
|
74
58
|
</button>
|
|
75
59
|
)}
|
|
76
60
|
</div>
|
|
@@ -21,9 +21,7 @@ enum Plugin {
|
|
|
21
21
|
Akifast = 'pz-akifast',
|
|
22
22
|
MultiBasket = 'pz-multi-basket',
|
|
23
23
|
SavedCard = 'pz-saved-card',
|
|
24
|
-
|
|
25
|
-
FlowPayment = 'pz-flow-payment',
|
|
26
|
-
SimilarProducts = 'pz-similar-products'
|
|
24
|
+
FlowPayment = 'pz-flow-payment'
|
|
27
25
|
}
|
|
28
26
|
|
|
29
27
|
export enum Component {
|
|
@@ -49,15 +47,7 @@ export enum Component {
|
|
|
49
47
|
AkifastCheckoutButton = 'CheckoutButton',
|
|
50
48
|
MultiBasket = 'MultiBasket',
|
|
51
49
|
SavedCard = 'SavedCardOption',
|
|
52
|
-
|
|
53
|
-
FlowPayment = 'FlowPayment',
|
|
54
|
-
SimilarProductsModal = 'SimilarProductsModal',
|
|
55
|
-
SimilarProductsFilterSidebar = 'SimilarProductsFilterSidebar',
|
|
56
|
-
SimilarProductsResultsGrid = 'SimilarProductsResultsGrid',
|
|
57
|
-
SimilarProductsPlugin = 'SimilarProductsPlugin',
|
|
58
|
-
ProductImageSearchFeature = 'ProductImageSearchFeature',
|
|
59
|
-
ImageSearchButton = 'ImageSearchButton',
|
|
60
|
-
HeaderImageSearchFeature = 'HeaderImageSearchFeature'
|
|
50
|
+
FlowPayment = 'FlowPayment'
|
|
61
51
|
}
|
|
62
52
|
|
|
63
53
|
const PluginComponents = new Map([
|
|
@@ -91,20 +81,7 @@ const PluginComponents = new Map([
|
|
|
91
81
|
],
|
|
92
82
|
[Plugin.MultiBasket, [Component.MultiBasket]],
|
|
93
83
|
[Plugin.SavedCard, [Component.SavedCard]],
|
|
94
|
-
[Plugin.
|
|
95
|
-
[Plugin.FlowPayment, [Component.FlowPayment]],
|
|
96
|
-
[
|
|
97
|
-
Plugin.SimilarProducts,
|
|
98
|
-
[
|
|
99
|
-
Component.SimilarProductsModal,
|
|
100
|
-
Component.SimilarProductsFilterSidebar,
|
|
101
|
-
Component.SimilarProductsResultsGrid,
|
|
102
|
-
Component.SimilarProductsPlugin,
|
|
103
|
-
Component.ProductImageSearchFeature,
|
|
104
|
-
Component.ImageSearchButton,
|
|
105
|
-
Component.HeaderImageSearchFeature
|
|
106
|
-
]
|
|
107
|
-
]
|
|
84
|
+
[Plugin.FlowPayment, [Component.FlowPayment]]
|
|
108
85
|
]);
|
|
109
86
|
|
|
110
87
|
const getPlugin = (component: Component) => {
|
|
@@ -169,12 +146,8 @@ export default function PluginModule({
|
|
|
169
146
|
promise = import(`${'@akinon/pz-multi-basket'}`);
|
|
170
147
|
} else if (plugin === Plugin.SavedCard) {
|
|
171
148
|
promise = import(`${'@akinon/pz-saved-card'}`);
|
|
172
|
-
} else if (plugin === Plugin.Hepsipay) {
|
|
173
|
-
promise = import(`${'@akinon/pz-hepsipay'}`);
|
|
174
149
|
} else if (plugin === Plugin.FlowPayment) {
|
|
175
150
|
promise = import(`${'@akinon/pz-flow-payment'}`);
|
|
176
|
-
} else if (plugin === Plugin.SimilarProducts) {
|
|
177
|
-
promise = import(`${'@akinon/pz-similar-products'}`);
|
|
178
151
|
}
|
|
179
152
|
} catch (error) {
|
|
180
153
|
logger.error(error);
|
package/data/client/checkout.ts
CHANGED
|
@@ -35,10 +35,8 @@ import {
|
|
|
35
35
|
|
|
36
36
|
interface CheckoutResponse {
|
|
37
37
|
pre_order?: PreOrder;
|
|
38
|
-
errors
|
|
39
|
-
non_field_errors
|
|
40
|
-
sample_products?: string[];
|
|
41
|
-
[key: string]: string | string[] | undefined;
|
|
38
|
+
errors: {
|
|
39
|
+
non_field_errors: string;
|
|
42
40
|
};
|
|
43
41
|
context_list?: CheckoutContext[];
|
|
44
42
|
template_name?: string;
|
|
@@ -886,7 +884,8 @@ export const checkoutApi = api.injectEndpoints({
|
|
|
886
884
|
method: 'POST',
|
|
887
885
|
body: formData
|
|
888
886
|
};
|
|
889
|
-
}
|
|
887
|
+
},
|
|
888
|
+
invalidatesTags: ['Checkout']
|
|
890
889
|
})
|
|
891
890
|
}),
|
|
892
891
|
overrideExisting: false
|
package/data/server/category.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { category, product } from '../urls';
|
|
|
5
5
|
import { Cache, CacheKey } from '../../lib/cache';
|
|
6
6
|
import { parse } from 'lossless-json';
|
|
7
7
|
import logger from '../../utils/log';
|
|
8
|
+
import { headers as nHeaders } from 'next/headers';
|
|
8
9
|
import { ServerVariables } from '../../utils/server-variables';
|
|
9
10
|
|
|
10
11
|
function getCategoryDataHandler(
|
|
@@ -17,30 +18,19 @@ function getCategoryDataHandler(
|
|
|
17
18
|
return async function () {
|
|
18
19
|
const params = generateCommerceSearchParams(searchParams);
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
headers
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
},
|
|
34
|
-
responseType: FetchResponseType.TEXT
|
|
35
|
-
});
|
|
36
|
-
} catch (error) {
|
|
37
|
-
logger.error('Failed to fetch category data', {
|
|
38
|
-
handler: 'getCategoryDataHandler',
|
|
39
|
-
pk,
|
|
40
|
-
error: error.message
|
|
41
|
-
});
|
|
42
|
-
return null;
|
|
43
|
-
}
|
|
21
|
+
const rawData = await appFetch<string>({
|
|
22
|
+
url: `${category.getCategoryByPk(pk)}${params ? params : ''}`,
|
|
23
|
+
locale,
|
|
24
|
+
currency,
|
|
25
|
+
init: {
|
|
26
|
+
headers: {
|
|
27
|
+
Accept: 'application/json',
|
|
28
|
+
'Content-Type': 'application/json',
|
|
29
|
+
...(headers ?? {})
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
responseType: FetchResponseType.TEXT
|
|
33
|
+
});
|
|
44
34
|
|
|
45
35
|
let data: GetCategoryResponse;
|
|
46
36
|
|
|
@@ -58,8 +48,8 @@ function getCategoryDataHandler(
|
|
|
58
48
|
logger.fatal('Error while parsing category data', {
|
|
59
49
|
handler: 'getCategoryDataHandler',
|
|
60
50
|
error,
|
|
61
|
-
rawData: rawData
|
|
62
|
-
? `${rawData
|
|
51
|
+
rawData: rawData.startsWith('<!DOCTYPE html>')
|
|
52
|
+
? `${rawData.substring(0, 50)}...`
|
|
63
53
|
: rawData
|
|
64
54
|
});
|
|
65
55
|
}
|
|
@@ -74,27 +64,17 @@ function getCategoryDataHandler(
|
|
|
74
64
|
return { data, breadcrumbData: undefined };
|
|
75
65
|
}
|
|
76
66
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
headers: {
|
|
86
|
-
Accept: 'application/json',
|
|
87
|
-
'Content-Type': 'application/json'
|
|
88
|
-
}
|
|
67
|
+
const breadcrumbData = await appFetch<any>({
|
|
68
|
+
url: product.breadcrumbUrl(menuItemModel),
|
|
69
|
+
locale,
|
|
70
|
+
currency,
|
|
71
|
+
init: {
|
|
72
|
+
headers: {
|
|
73
|
+
Accept: 'application/json',
|
|
74
|
+
'Content-Type': 'application/json'
|
|
89
75
|
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
logger.warn('Failed to fetch breadcrumb data', {
|
|
93
|
-
handler: 'getCategoryDataHandler',
|
|
94
|
-
pk,
|
|
95
|
-
error: error.message
|
|
96
|
-
});
|
|
97
|
-
}
|
|
76
|
+
}
|
|
77
|
+
});
|
|
98
78
|
|
|
99
79
|
return { data, breadcrumbData: breadcrumbData?.menu };
|
|
100
80
|
};
|
|
@@ -118,7 +98,8 @@ export const getCategoryData = ({
|
|
|
118
98
|
locale,
|
|
119
99
|
getCategoryDataHandler(pk, locale, currency, searchParams, headers),
|
|
120
100
|
{
|
|
121
|
-
expire: 300
|
|
101
|
+
expire: 300,
|
|
102
|
+
compressed: true
|
|
122
103
|
}
|
|
123
104
|
);
|
|
124
105
|
};
|
|
@@ -158,8 +139,8 @@ function getCategoryBySlugDataHandler(
|
|
|
158
139
|
logger.fatal('Error while parsing category data', {
|
|
159
140
|
handler: 'getCategoryBySlugDataHandler',
|
|
160
141
|
error,
|
|
161
|
-
rawData: rawData
|
|
162
|
-
? `${rawData
|
|
142
|
+
rawData: rawData.startsWith('<!DOCTYPE html>')
|
|
143
|
+
? `${rawData.substring(0, 50)}...`
|
|
163
144
|
: rawData
|
|
164
145
|
});
|
|
165
146
|
}
|
|
@@ -178,7 +159,8 @@ export const getCategoryBySlugData = async ({
|
|
|
178
159
|
locale,
|
|
179
160
|
getCategoryBySlugDataHandler(slug, locale, currency),
|
|
180
161
|
{
|
|
181
|
-
expire: 300
|
|
162
|
+
expire: 300,
|
|
163
|
+
compressed: true
|
|
182
164
|
}
|
|
183
165
|
);
|
|
184
166
|
};
|
package/data/server/flatpage.ts
CHANGED
|
@@ -11,24 +11,20 @@ const getFlatPageDataHandler = (
|
|
|
11
11
|
headers?: Record<string, string>
|
|
12
12
|
) => {
|
|
13
13
|
return async function () {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
...(headers ?? {})
|
|
24
|
-
}
|
|
14
|
+
const data = await appFetch<FlatPage>({
|
|
15
|
+
url: flatpage.getFlatPageByPk(pk),
|
|
16
|
+
locale,
|
|
17
|
+
currency,
|
|
18
|
+
init: {
|
|
19
|
+
headers: {
|
|
20
|
+
Accept: 'application/json',
|
|
21
|
+
'Content-Type': 'application/json',
|
|
22
|
+
...(headers ?? {})
|
|
25
23
|
}
|
|
26
|
-
}
|
|
24
|
+
}
|
|
25
|
+
});
|
|
27
26
|
|
|
28
|
-
|
|
29
|
-
} catch (error) {
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
27
|
+
return data;
|
|
32
28
|
};
|
|
33
29
|
};
|
|
34
30
|
|
|
@@ -46,6 +42,9 @@ export const getFlatPageData = ({
|
|
|
46
42
|
return Cache.wrap(
|
|
47
43
|
CacheKey.FlatPage(pk),
|
|
48
44
|
locale,
|
|
49
|
-
getFlatPageDataHandler(pk, locale, currency, headers)
|
|
45
|
+
getFlatPageDataHandler(pk, locale, currency, headers),
|
|
46
|
+
{
|
|
47
|
+
compressed: true
|
|
48
|
+
}
|
|
50
49
|
);
|
|
51
50
|
};
|
package/data/server/form.ts
CHANGED
|
@@ -11,24 +11,20 @@ const getLandingPageHandler = (
|
|
|
11
11
|
headers?: Record<string, string>
|
|
12
12
|
) => {
|
|
13
13
|
return async function () {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
...(headers ?? {})
|
|
24
|
-
}
|
|
14
|
+
const data = await appFetch<LandingPage>({
|
|
15
|
+
url: landingpage.getLandingPageByPk(pk),
|
|
16
|
+
locale,
|
|
17
|
+
currency,
|
|
18
|
+
init: {
|
|
19
|
+
headers: {
|
|
20
|
+
Accept: 'application/json',
|
|
21
|
+
'Content-Type': 'application/json',
|
|
22
|
+
...(headers ?? {})
|
|
25
23
|
}
|
|
26
|
-
}
|
|
24
|
+
}
|
|
25
|
+
});
|
|
27
26
|
|
|
28
|
-
|
|
29
|
-
} catch (error) {
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
27
|
+
return data;
|
|
32
28
|
};
|
|
33
29
|
};
|
|
34
30
|
|