@akinon/next 1.59.0-rc.4 → 1.59.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -669
- package/api/client.ts +2 -23
- package/assets/styles/index.scss +26 -50
- package/bin/pz-prebuild.js +0 -1
- package/bin/pz-predev.js +0 -1
- package/components/index.ts +0 -1
- package/components/input.tsx +17 -32
- package/components/link.tsx +13 -17
- package/components/plugin-module.tsx +3 -8
- package/components/price.tsx +4 -11
- package/components/pz-root.tsx +3 -15
- package/components/selected-payment-option-view.tsx +1 -2
- package/data/client/api.ts +1 -1
- package/data/client/b2b.ts +2 -35
- package/data/client/basket.ts +5 -6
- package/data/client/checkout.ts +10 -55
- package/data/client/user.ts +2 -3
- package/data/server/category.ts +19 -43
- package/data/server/flatpage.ts +7 -29
- package/data/server/form.ts +11 -29
- package/data/server/landingpage.ts +7 -26
- package/data/server/list.ts +6 -16
- package/data/server/menu.ts +2 -15
- package/data/server/product.ts +13 -33
- package/data/server/seo.ts +24 -17
- package/data/server/special-page.ts +5 -15
- package/data/server/widget.ts +7 -14
- package/data/urls.ts +1 -8
- package/hocs/server/with-segment-defaults.tsx +1 -4
- package/hooks/index.ts +1 -2
- package/hooks/use-pagination.ts +2 -2
- package/hooks/use-payment-options.ts +1 -2
- package/lib/cache.ts +6 -8
- package/middlewares/currency.ts +1 -2
- package/middlewares/default.ts +152 -226
- package/middlewares/index.ts +1 -3
- package/middlewares/pretty-url.ts +1 -11
- package/middlewares/url-redirection.ts +0 -4
- package/package.json +3 -4
- package/plugins.d.ts +0 -6
- package/plugins.js +1 -2
- package/redux/middlewares/checkout.ts +14 -78
- package/redux/reducers/checkout.ts +3 -23
- package/redux/reducers/index.ts +1 -3
- package/types/commerce/address.ts +1 -1
- package/types/commerce/b2b.ts +2 -12
- package/types/commerce/checkout.ts +0 -30
- package/types/commerce/order.ts +0 -1
- package/types/index.ts +2 -17
- package/utils/app-fetch.ts +8 -16
- package/utils/generate-commerce-search-params.ts +1 -3
- package/utils/index.ts +6 -27
- package/utils/server-translation.ts +1 -11
- package/with-pz-config.js +2 -13
- package/assets/styles/index.css +0 -49
- package/assets/styles/index.css.map +0 -1
- package/bin/pz-generate-translations.js +0 -41
- package/components/file-input.tsx +0 -8
- package/hooks/use-message-listener.ts +0 -24
- package/lib/cache-handler.mjs +0 -33
- package/middlewares/saved-card-redirection.ts +0 -179
- package/routes/pretty-url.tsx +0 -192
- package/utils/redirection-iframe.ts +0 -85
package/api/client.ts
CHANGED
|
@@ -4,7 +4,6 @@ import settings from 'settings';
|
|
|
4
4
|
import logger from '../utils/log';
|
|
5
5
|
import formatCookieString from '../utils/format-cookie-string';
|
|
6
6
|
import cookieParser from 'set-cookie-parser';
|
|
7
|
-
import { cookies } from 'next/headers';
|
|
8
7
|
|
|
9
8
|
interface RouteParams {
|
|
10
9
|
params: {
|
|
@@ -81,27 +80,11 @@ async function proxyRequest(...args) {
|
|
|
81
80
|
}
|
|
82
81
|
} as RequestInit;
|
|
83
82
|
|
|
84
|
-
const nextCookies = cookies();
|
|
85
|
-
const segment = nextCookies.get('pz-segment')?.value;
|
|
86
|
-
const currency = nextCookies.get('pz-external-currency')?.value;
|
|
87
|
-
|
|
88
|
-
if (segment) {
|
|
89
|
-
fetchOptions.headers['X-Segment-Id'] = segment;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
if (currency) {
|
|
93
|
-
fetchOptions.headers = Object.assign({}, fetchOptions.headers, {
|
|
94
|
-
'x-currency': currency
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
|
|
98
83
|
if (options.contentType) {
|
|
99
84
|
fetchOptions.headers['Content-Type'] = options.contentType;
|
|
100
85
|
}
|
|
101
86
|
|
|
102
|
-
const isMultipartFormData = req.headers
|
|
103
|
-
.get('content-type')
|
|
104
|
-
?.includes('multipart/form-data;');
|
|
87
|
+
const isMultipartFormData = req.headers.get('content-type')?.includes('multipart/form-data;');
|
|
105
88
|
|
|
106
89
|
if (req.method !== 'GET') {
|
|
107
90
|
let body: Record<string, any> | FormData = {};
|
|
@@ -125,11 +108,7 @@ async function proxyRequest(...args) {
|
|
|
125
108
|
|
|
126
109
|
Object.keys(body ?? {}).forEach((key) => {
|
|
127
110
|
if (body[key]) {
|
|
128
|
-
|
|
129
|
-
formData.append(key, JSON.stringify(body[key]));
|
|
130
|
-
} else {
|
|
131
|
-
formData.append(key, body[key]);
|
|
132
|
-
}
|
|
111
|
+
formData.append(key, body[key]);
|
|
133
112
|
}
|
|
134
113
|
});
|
|
135
114
|
|
package/assets/styles/index.scss
CHANGED
|
@@ -1,53 +1,29 @@
|
|
|
1
1
|
.checkout-payment-iframe-wrapper {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
position: fixed;
|
|
3
|
+
top: 0;
|
|
4
|
+
left: 0;
|
|
5
|
+
width: 100%;
|
|
6
|
+
height: 100%;
|
|
7
|
+
border: none;
|
|
8
|
+
z-index: 1000;
|
|
9
|
+
background-color: white;
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
iframe {
|
|
12
|
+
width: 100%;
|
|
13
|
+
height: 100%;
|
|
14
|
+
border: none;
|
|
15
|
+
background-color: white;
|
|
16
|
+
}
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
.checkout-payment-redirection-iframe-wrapper {
|
|
32
|
-
width: 100%;
|
|
33
|
-
position: relative;
|
|
34
|
-
|
|
35
|
-
iframe {
|
|
36
|
-
width: 100%;
|
|
37
|
-
height: 100%;
|
|
38
|
-
border: none;
|
|
39
|
-
background-color: white;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
.close-button {
|
|
43
|
-
position: absolute;
|
|
44
|
-
top: 16px;
|
|
45
|
-
right: 16px;
|
|
46
|
-
width: 32px;
|
|
47
|
-
height: 32px;
|
|
48
|
-
display: flex;
|
|
49
|
-
align-items: center;
|
|
50
|
-
justify-content: center;
|
|
51
|
-
z-index: 1001;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
18
|
+
.close-button {
|
|
19
|
+
position: fixed;
|
|
20
|
+
top: 16px;
|
|
21
|
+
right: 16px;
|
|
22
|
+
width: 32px;
|
|
23
|
+
height: 32px;
|
|
24
|
+
display: flex;
|
|
25
|
+
align-items: center;
|
|
26
|
+
justify-content: center;
|
|
27
|
+
z-index: 1001;
|
|
28
|
+
}
|
|
29
|
+
}
|
package/bin/pz-prebuild.js
CHANGED
package/bin/pz-predev.js
CHANGED
package/components/index.ts
CHANGED
package/components/input.tsx
CHANGED
|
@@ -1,30 +1,17 @@
|
|
|
1
1
|
import clsx from 'clsx';
|
|
2
|
-
import { forwardRef, FocusEvent, useState
|
|
2
|
+
import { forwardRef, FocusEvent, useState } from 'react';
|
|
3
3
|
import { Controller } from 'react-hook-form';
|
|
4
|
-
|
|
5
|
-
// @ts-ignore
|
|
6
|
-
import { PatternFormat, PatternFormatProps } from 'react-number-format';
|
|
4
|
+
import NumberFormat, { NumberFormatProps } from 'react-number-format';
|
|
7
5
|
import { InputProps } from '../types';
|
|
8
6
|
import { twMerge } from 'tailwind-merge';
|
|
9
7
|
|
|
10
|
-
const PatternFormatWithRef = forwardRef(
|
|
11
|
-
(props: PatternFormatProps, ref: Ref<HTMLInputElement>) => {
|
|
12
|
-
return <PatternFormat {...props} getInputRef={ref} />;
|
|
13
|
-
}
|
|
14
|
-
);
|
|
15
|
-
PatternFormatWithRef.displayName = 'PatternFormatWithRef';
|
|
16
|
-
|
|
17
8
|
export const Input = forwardRef<
|
|
18
9
|
HTMLInputElement,
|
|
19
10
|
InputProps &
|
|
20
11
|
Pick<
|
|
21
|
-
|
|
22
|
-
'mask' | 'allowEmptyFormatting' | 'onValueChange'
|
|
23
|
-
>
|
|
24
|
-
format?: string;
|
|
25
|
-
defaultValue?: string;
|
|
26
|
-
type?: string;
|
|
27
|
-
}
|
|
12
|
+
NumberFormatProps,
|
|
13
|
+
'format' | 'mask' | 'allowEmptyFormatting' | 'onValueChange'
|
|
14
|
+
>
|
|
28
15
|
>((props, ref) => {
|
|
29
16
|
const [focused, setFocused] = useState(false);
|
|
30
17
|
const [hasValue, setHasValue] = useState(false);
|
|
@@ -41,16 +28,14 @@ export const Input = forwardRef<
|
|
|
41
28
|
const hasFloatingLabel = label && labelStyle === 'floating';
|
|
42
29
|
const inputClass = twMerge(
|
|
43
30
|
clsx(
|
|
44
|
-
'text-xs border px-2.5 h-10 placeholder:text-gray-600',
|
|
31
|
+
'text-xs border px-2.5 h-10 placeholder:text-gray-600 peer',
|
|
45
32
|
'focus-visible:outline-none', // disable outline on focus
|
|
46
|
-
{ 'pt-3': hasFloatingLabel },
|
|
47
33
|
error
|
|
48
34
|
? 'border-error focus:border-error'
|
|
49
35
|
: 'border-gray-500 hover:border-black focus:border-black'
|
|
50
36
|
),
|
|
51
37
|
props.className
|
|
52
38
|
);
|
|
53
|
-
|
|
54
39
|
const inputProps: any = {
|
|
55
40
|
id,
|
|
56
41
|
ref,
|
|
@@ -68,15 +53,15 @@ export const Input = forwardRef<
|
|
|
68
53
|
return (
|
|
69
54
|
<label
|
|
70
55
|
htmlFor={id}
|
|
71
|
-
className={
|
|
72
|
-
'text-xs text-gray-800',
|
|
73
|
-
{
|
|
74
|
-
'absolute left-2.5 pointer-events-none
|
|
75
|
-
hasFloatingLabel
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
56
|
+
className={twMerge(
|
|
57
|
+
'text-xs text-gray-800 transition-all',
|
|
58
|
+
clsx({
|
|
59
|
+
'absolute left-2.5 pointer-events-none transform flex items-center h-full !top-0 peer-placeholder-shown:-translate-y-2 peer-placeholder-shown:bg-white peer-placeholder-shown:inline-flex peer-placeholder-shown:h-auto':
|
|
60
|
+
hasFloatingLabel,
|
|
61
|
+
'mb-2': !hasFloatingLabel,
|
|
62
|
+
'-translate-y-2 bg-white inline-flex h-auto':
|
|
63
|
+
hasFloatingLabel && (focused || hasValue)
|
|
64
|
+
})
|
|
80
65
|
)}
|
|
81
66
|
>
|
|
82
67
|
{label} {required && <span className="text-secondary">*</span>}
|
|
@@ -93,14 +78,14 @@ export const Input = forwardRef<
|
|
|
93
78
|
<Controller
|
|
94
79
|
name={props.name ?? ''}
|
|
95
80
|
control={props.control}
|
|
81
|
+
defaultValue={false}
|
|
96
82
|
render={({ field }) => (
|
|
97
|
-
<
|
|
83
|
+
<NumberFormat
|
|
98
84
|
format={format}
|
|
99
85
|
mask={mask ?? ''}
|
|
100
86
|
{...rest}
|
|
101
87
|
{...field}
|
|
102
88
|
{...inputProps}
|
|
103
|
-
type={props.type as 'text' | 'password' | 'tel'}
|
|
104
89
|
/>
|
|
105
90
|
)}
|
|
106
91
|
/>
|
package/components/link.tsx
CHANGED
|
@@ -10,32 +10,28 @@ 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();
|
|
19
17
|
const formattedHref = useMemo(() => {
|
|
20
|
-
if (
|
|
21
|
-
return
|
|
18
|
+
if (typeof href !== 'string' || href.startsWith('http')) {
|
|
19
|
+
return href;
|
|
22
20
|
}
|
|
23
21
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const hrefWithLocale = `/${locale}${pathnameWithoutLocale}`;
|
|
22
|
+
const pathnameWithoutLocale = href.replace(urlLocaleMatcherRegex, '');
|
|
23
|
+
const hrefWithLocale = `/${locale}${pathnameWithoutLocale}`;
|
|
27
24
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
25
|
+
if (localeUrlStrategy === LocaleUrlStrategy.ShowAllLocales) {
|
|
26
|
+
return hrefWithLocale;
|
|
27
|
+
} else if (
|
|
28
|
+
localeUrlStrategy === LocaleUrlStrategy.HideDefaultLocale &&
|
|
29
|
+
locale !== defaultLocaleValue
|
|
30
|
+
) {
|
|
31
|
+
return hrefWithLocale;
|
|
36
32
|
}
|
|
37
33
|
|
|
38
|
-
return href;
|
|
34
|
+
return href || '#';
|
|
39
35
|
}, [href, defaultLocaleValue, locale, localeUrlStrategy]);
|
|
40
36
|
|
|
41
37
|
return (
|
|
@@ -19,8 +19,7 @@ enum Plugin {
|
|
|
19
19
|
Masterpass = 'pz-masterpass',
|
|
20
20
|
B2B = 'pz-b2b',
|
|
21
21
|
Akifast = 'pz-akifast',
|
|
22
|
-
MultiBasket = 'pz-multi-basket'
|
|
23
|
-
SavedCard = 'pz-saved-card'
|
|
22
|
+
MultiBasket = 'pz-multi-basket'
|
|
24
23
|
}
|
|
25
24
|
|
|
26
25
|
export enum Component {
|
|
@@ -44,8 +43,7 @@ export enum Component {
|
|
|
44
43
|
BasketB2B = 'BasketB2b',
|
|
45
44
|
AkifastQuickLoginButton = 'QuickLoginButton',
|
|
46
45
|
AkifastCheckoutButton = 'CheckoutButton',
|
|
47
|
-
MultiBasket = 'MultiBasket'
|
|
48
|
-
SavedCard = 'SavedCardOption'
|
|
46
|
+
MultiBasket = 'MultiBasket'
|
|
49
47
|
}
|
|
50
48
|
|
|
51
49
|
const PluginComponents = new Map([
|
|
@@ -77,8 +75,7 @@ const PluginComponents = new Map([
|
|
|
77
75
|
Plugin.Akifast,
|
|
78
76
|
[Component.AkifastQuickLoginButton, Component.AkifastCheckoutButton]
|
|
79
77
|
],
|
|
80
|
-
[Plugin.MultiBasket, [Component.MultiBasket]]
|
|
81
|
-
[Plugin.SavedCard, [Component.SavedCard]]
|
|
78
|
+
[Plugin.MultiBasket, [Component.MultiBasket]]
|
|
82
79
|
]);
|
|
83
80
|
|
|
84
81
|
const getPlugin = (component: Component) => {
|
|
@@ -141,8 +138,6 @@ export default function PluginModule({
|
|
|
141
138
|
promise = import(`${'@akinon/pz-akifast'}`);
|
|
142
139
|
} else if (plugin === Plugin.MultiBasket) {
|
|
143
140
|
promise = import(`${'@akinon/pz-multi-basket'}`);
|
|
144
|
-
} else if (plugin === Plugin.SavedCard) {
|
|
145
|
-
promise = import(`${'@akinon/pz-saved-card'}`);
|
|
146
141
|
}
|
|
147
142
|
} catch (error) {
|
|
148
143
|
logger.error(error);
|
package/components/price.tsx
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
|
-
|
|
3
|
-
// @ts-ignore
|
|
4
|
-
import { NumericFormat, NumericFormatProps } from 'react-number-format';
|
|
2
|
+
import NumberFormat, { NumberFormatProps } from 'react-number-format';
|
|
5
3
|
import { getCurrency } from '@akinon/next/utils';
|
|
6
4
|
|
|
7
5
|
import { useLocalization } from '@akinon/next/hooks';
|
|
8
6
|
import { PriceProps } from '../types';
|
|
9
|
-
import Settings from 'settings';
|
|
10
7
|
|
|
11
|
-
export const Price = (props:
|
|
8
|
+
export const Price = (props: NumberFormatProps & PriceProps) => {
|
|
12
9
|
const {
|
|
13
10
|
value,
|
|
14
11
|
currencyCode,
|
|
@@ -30,10 +27,6 @@ export const Price = (props: NumericFormatProps & PriceProps) => {
|
|
|
30
27
|
// TODO: This is very bad practice. It broke decimalScale.
|
|
31
28
|
const _value = value?.toString().replace('.', ',');
|
|
32
29
|
|
|
33
|
-
const currentCurrencyDecimalScale = Settings.localization.currencies.find(
|
|
34
|
-
(currency) => currency.code === currencyCode_
|
|
35
|
-
).decimalScale;
|
|
36
|
-
|
|
37
30
|
const currency = useMemo(
|
|
38
31
|
() =>
|
|
39
32
|
getCurrency({
|
|
@@ -46,14 +39,14 @@ export const Price = (props: NumericFormatProps & PriceProps) => {
|
|
|
46
39
|
);
|
|
47
40
|
|
|
48
41
|
return (
|
|
49
|
-
<
|
|
42
|
+
<NumberFormat
|
|
50
43
|
value={useNegative ? `-${useNegativeSpace}${_value}` : _value}
|
|
51
44
|
{...{
|
|
52
45
|
[useCurrencyAfterPrice ? 'suffix' : 'prefix']: currency
|
|
53
46
|
}}
|
|
54
47
|
displayType={displayType}
|
|
55
48
|
thousandSeparator={thousandSeparator}
|
|
56
|
-
decimalScale={
|
|
49
|
+
decimalScale={decimalScale}
|
|
57
50
|
decimalSeparator={decimalSeparator}
|
|
58
51
|
fixedDecimalScale={fixedDecimalScale}
|
|
59
52
|
{...rest}
|
package/components/pz-root.tsx
CHANGED
|
@@ -3,29 +3,17 @@ import ClientRoot from './client-root';
|
|
|
3
3
|
import { cookies } from 'next/headers';
|
|
4
4
|
import PzProviders from './pz-providers';
|
|
5
5
|
import { WebVitals } from './web-vitals';
|
|
6
|
-
import settings from 'settings';
|
|
7
6
|
|
|
8
|
-
export default
|
|
7
|
+
export default function PzRoot({
|
|
9
8
|
translations,
|
|
10
|
-
children
|
|
11
|
-
locale
|
|
9
|
+
children
|
|
12
10
|
}: {
|
|
13
|
-
translations
|
|
11
|
+
translations: any;
|
|
14
12
|
children: React.ReactNode;
|
|
15
|
-
locale?: string;
|
|
16
13
|
}) {
|
|
17
14
|
const nextCookies = cookies();
|
|
18
15
|
const sessionid = nextCookies.get('osessionid')?.value;
|
|
19
16
|
|
|
20
|
-
if (!translations) {
|
|
21
|
-
const { getTranslations } =
|
|
22
|
-
settings.useOptimizedTranslations && locale
|
|
23
|
-
? require('translations')
|
|
24
|
-
: require('../utils/server-translation');
|
|
25
|
-
|
|
26
|
-
translations = await getTranslations(locale);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
17
|
return (
|
|
30
18
|
<PzProviders translations={translations}>
|
|
31
19
|
<WebVitals />
|
|
@@ -17,8 +17,7 @@ const paymentTypeToView = {
|
|
|
17
17
|
loyalty_money: 'loyalty',
|
|
18
18
|
masterpass: 'credit-card',
|
|
19
19
|
pay_on_delivery: 'pay-on-delivery',
|
|
20
|
-
redirection: 'redirection'
|
|
21
|
-
saved_card: 'saved-card'
|
|
20
|
+
redirection: 'redirection'
|
|
22
21
|
// Add other mappings as needed
|
|
23
22
|
};
|
|
24
23
|
|
package/data/client/api.ts
CHANGED
package/data/client/b2b.ts
CHANGED
|
@@ -12,9 +12,7 @@ import {
|
|
|
12
12
|
SaveBasketParams,
|
|
13
13
|
UpdateProductParams,
|
|
14
14
|
DeleteProductParams,
|
|
15
|
-
CreateQuotationParams
|
|
16
|
-
BasketStatusResponse,
|
|
17
|
-
ExportBasketResponse
|
|
15
|
+
CreateQuotationParams
|
|
18
16
|
} from '../../types';
|
|
19
17
|
|
|
20
18
|
const b2bApi = api.injectEndpoints({
|
|
@@ -91,34 +89,6 @@ const b2bApi = api.injectEndpoints({
|
|
|
91
89
|
}),
|
|
92
90
|
invalidatesTags: ['BasketB2b', 'DraftsB2b']
|
|
93
91
|
}),
|
|
94
|
-
exportBasket: build.mutation<ExportBasketResponse, string>({
|
|
95
|
-
query: (queryString) => {
|
|
96
|
-
return {
|
|
97
|
-
url: buildClientRequestUrl(b2b.basketExport(queryString)),
|
|
98
|
-
method: 'GET'
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
}),
|
|
102
|
-
getBasketStatus: build.mutation<BasketStatusResponse, string>({
|
|
103
|
-
query: (cacheKey) => {
|
|
104
|
-
return {
|
|
105
|
-
url: buildClientRequestUrl(b2b.statusBasket(cacheKey)),
|
|
106
|
-
method: 'GET'
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
}),
|
|
110
|
-
uploadFile: build.mutation<void, FormData>({
|
|
111
|
-
query: (body) => {
|
|
112
|
-
return {
|
|
113
|
-
url: buildClientRequestUrl(b2b.basketImport, {
|
|
114
|
-
useFormData: true
|
|
115
|
-
}),
|
|
116
|
-
method: 'POST',
|
|
117
|
-
body
|
|
118
|
-
};
|
|
119
|
-
},
|
|
120
|
-
invalidatesTags: ['BasketB2b']
|
|
121
|
-
})
|
|
122
92
|
}),
|
|
123
93
|
overrideExisting: true
|
|
124
94
|
});
|
|
@@ -132,8 +102,5 @@ export const {
|
|
|
132
102
|
useLoadBasketMutation,
|
|
133
103
|
useUpdateProductMutation,
|
|
134
104
|
useDeleteProductMutation,
|
|
135
|
-
useCreateQuotationMutation
|
|
136
|
-
useGetBasketStatusMutation,
|
|
137
|
-
useExportBasketMutation,
|
|
138
|
-
useUploadFileMutation
|
|
105
|
+
useCreateQuotationMutation
|
|
139
106
|
} = b2bApi;
|
package/data/client/basket.ts
CHANGED
|
@@ -28,7 +28,7 @@ export const basketApi = api.injectEndpoints({
|
|
|
28
28
|
query: ({ namespace }) =>
|
|
29
29
|
buildClientRequestUrl(basket.getBasketDetail(namespace)),
|
|
30
30
|
transformResponse: (response: { basket: Basket }) => response.basket,
|
|
31
|
-
providesTags: ['
|
|
31
|
+
providesTags: ['AllBaskets']
|
|
32
32
|
}),
|
|
33
33
|
getAllBaskets: build.query<Basket[], void>({
|
|
34
34
|
query: () =>
|
|
@@ -36,7 +36,7 @@ export const basketApi = api.injectEndpoints({
|
|
|
36
36
|
contentType: 'application/json'
|
|
37
37
|
}),
|
|
38
38
|
transformResponse: (response: { baskets: Basket[] }) => response.baskets,
|
|
39
|
-
providesTags: ['
|
|
39
|
+
providesTags: ['AllBaskets']
|
|
40
40
|
}),
|
|
41
41
|
removeBasket: build.mutation<Basket, { pk: number }>({
|
|
42
42
|
query: ({ pk }) => ({
|
|
@@ -46,7 +46,7 @@ export const basketApi = api.injectEndpoints({
|
|
|
46
46
|
method: 'DELETE',
|
|
47
47
|
body: { pk }
|
|
48
48
|
}),
|
|
49
|
-
invalidatesTags: ['
|
|
49
|
+
invalidatesTags: ['AllBaskets', 'Basket']
|
|
50
50
|
}),
|
|
51
51
|
selectMainBasket: build.mutation<Basket, { pk: number }>({
|
|
52
52
|
query: ({ pk }) => ({
|
|
@@ -57,7 +57,7 @@ export const basketApi = api.injectEndpoints({
|
|
|
57
57
|
body: { pk }
|
|
58
58
|
}),
|
|
59
59
|
transformResponse: (response: { baskets: Basket }) => response.baskets,
|
|
60
|
-
invalidatesTags: ['
|
|
60
|
+
invalidatesTags: ['AllBaskets', 'Basket']
|
|
61
61
|
}),
|
|
62
62
|
updateQuantity: build.mutation<
|
|
63
63
|
UpdateQuantityResponse,
|
|
@@ -69,8 +69,7 @@ export const basketApi = api.injectEndpoints({
|
|
|
69
69
|
}),
|
|
70
70
|
method: 'PUT',
|
|
71
71
|
body
|
|
72
|
-
})
|
|
73
|
-
invalidatesTags: ['MultiBasket', 'Basket']
|
|
72
|
+
})
|
|
74
73
|
}),
|
|
75
74
|
clearBasket: build.mutation<Basket, void>({
|
|
76
75
|
query: (body) => ({
|
package/data/client/checkout.ts
CHANGED
|
@@ -57,7 +57,6 @@ export interface CompleteCreditCardParams {
|
|
|
57
57
|
card_month: string;
|
|
58
58
|
card_year: string;
|
|
59
59
|
use_three_d?: boolean;
|
|
60
|
-
save?: boolean;
|
|
61
60
|
}
|
|
62
61
|
|
|
63
62
|
interface GetContractResponse {
|
|
@@ -229,8 +228,7 @@ export const checkoutApi = api.injectEndpoints({
|
|
|
229
228
|
card_number,
|
|
230
229
|
card_month,
|
|
231
230
|
card_year,
|
|
232
|
-
use_three_d = true
|
|
233
|
-
save = undefined
|
|
231
|
+
use_three_d = true
|
|
234
232
|
}) => {
|
|
235
233
|
const paymentOption =
|
|
236
234
|
store.getState().checkout?.preOrder?.payment_option;
|
|
@@ -244,26 +242,20 @@ export const checkoutApi = api.injectEndpoints({
|
|
|
244
242
|
};
|
|
245
243
|
}
|
|
246
244
|
|
|
247
|
-
const body: Record<string, string> = {
|
|
248
|
-
agreement: '1',
|
|
249
|
-
use_three_d: use_three_d ? '1' : '0',
|
|
250
|
-
card_cvv,
|
|
251
|
-
card_holder,
|
|
252
|
-
card_month,
|
|
253
|
-
card_number,
|
|
254
|
-
card_year
|
|
255
|
-
};
|
|
256
|
-
|
|
257
|
-
if (save !== undefined) {
|
|
258
|
-
body.save = save ? '1' : '0';
|
|
259
|
-
}
|
|
260
|
-
|
|
261
245
|
return {
|
|
262
246
|
url: buildClientRequestUrl(checkout.completeCreditCardPayment, {
|
|
263
247
|
useFormData: true
|
|
264
248
|
}),
|
|
265
249
|
method: 'POST',
|
|
266
|
-
body
|
|
250
|
+
body: {
|
|
251
|
+
agreement: '1',
|
|
252
|
+
use_three_d: use_three_d ? '1' : '0',
|
|
253
|
+
card_cvv,
|
|
254
|
+
card_holder,
|
|
255
|
+
card_month,
|
|
256
|
+
card_number,
|
|
257
|
+
card_year
|
|
258
|
+
}
|
|
267
259
|
};
|
|
268
260
|
},
|
|
269
261
|
async onQueryStarted(args, { dispatch, queryFulfilled }) {
|
|
@@ -388,22 +380,6 @@ export const checkoutApi = api.injectEndpoints({
|
|
|
388
380
|
dispatch(setShippingStepBusy(false));
|
|
389
381
|
}
|
|
390
382
|
}),
|
|
391
|
-
setDataSourceShippingOptions: build.mutation<CheckoutResponse, number[]>({
|
|
392
|
-
query: (pks) => ({
|
|
393
|
-
url: buildClientRequestUrl(checkout.setDataSourceShippingOption, {
|
|
394
|
-
useFormData: true
|
|
395
|
-
}),
|
|
396
|
-
method: 'POST',
|
|
397
|
-
body: {
|
|
398
|
-
data_source_shipping_options: JSON.stringify(pks)
|
|
399
|
-
}
|
|
400
|
-
}),
|
|
401
|
-
async onQueryStarted(arg, { dispatch, queryFulfilled }) {
|
|
402
|
-
dispatch(setShippingStepBusy(true));
|
|
403
|
-
await queryFulfilled;
|
|
404
|
-
dispatch(setShippingStepBusy(false));
|
|
405
|
-
}
|
|
406
|
-
}),
|
|
407
383
|
setRetailStore: build.mutation<CheckoutResponse, SetRetailStoreParams>({
|
|
408
384
|
query: ({ retailStorePk, billingAddressPk }) => ({
|
|
409
385
|
url: buildClientRequestUrl(
|
|
@@ -705,25 +681,6 @@ export const checkoutApi = api.injectEndpoints({
|
|
|
705
681
|
};
|
|
706
682
|
}
|
|
707
683
|
}),
|
|
708
|
-
setAttributeBasedShippingOptions: build.mutation<
|
|
709
|
-
CheckoutResponse,
|
|
710
|
-
Record<string, number>
|
|
711
|
-
>({
|
|
712
|
-
query: (options) => ({
|
|
713
|
-
url: buildClientRequestUrl(checkout.setAttributeBasedShippingOption, {
|
|
714
|
-
useFormData: true
|
|
715
|
-
}),
|
|
716
|
-
method: 'POST',
|
|
717
|
-
body: {
|
|
718
|
-
attribute_based_shipping_options: JSON.stringify(options)
|
|
719
|
-
}
|
|
720
|
-
}),
|
|
721
|
-
async onQueryStarted(arg, { dispatch, queryFulfilled }) {
|
|
722
|
-
dispatch(setShippingStepBusy(true));
|
|
723
|
-
await queryFulfilled;
|
|
724
|
-
dispatch(setShippingStepBusy(false));
|
|
725
|
-
}
|
|
726
|
-
}),
|
|
727
684
|
setOrderSelectionPage: build.mutation<
|
|
728
685
|
CheckoutResponse,
|
|
729
686
|
{ extra_field: ExtraField }
|
|
@@ -755,7 +712,6 @@ export const {
|
|
|
755
712
|
useSetDeliveryOptionMutation,
|
|
756
713
|
useSetAddressesMutation,
|
|
757
714
|
useSetShippingOptionMutation,
|
|
758
|
-
useSetDataSourceShippingOptionsMutation,
|
|
759
715
|
useSetPaymentOptionMutation,
|
|
760
716
|
useSetBinNumberMutation,
|
|
761
717
|
useSetInstallmentOptionMutation,
|
|
@@ -774,6 +730,5 @@ export const {
|
|
|
774
730
|
usePayWithLoyaltyBalanceMutation,
|
|
775
731
|
useSetOrderNoteMutation,
|
|
776
732
|
useSetDeliveryBagsMutation,
|
|
777
|
-
useSetAttributeBasedShippingOptionsMutation,
|
|
778
733
|
useSetOrderSelectionPageMutation
|
|
779
734
|
} = checkoutApi;
|
package/data/client/user.ts
CHANGED
|
@@ -22,12 +22,11 @@ const userApi = api.injectEndpoints({
|
|
|
22
22
|
getCaptcha: build.query<GetCaptchaResponse, void>({
|
|
23
23
|
query: () => buildClientRequestUrl(user.captcha),
|
|
24
24
|
transformResponse: (response: { html: string }) => {
|
|
25
|
-
const
|
|
26
|
-
|
|
25
|
+
const siteKeyMatch = response.html.match(/sitekey=["|'][^"']+/gi);
|
|
27
26
|
const csrfTokenMatch = response.html.match(
|
|
28
27
|
/name=['|"]csrfmiddlewaretoken['|"] value=['|"][^'"]+/gi
|
|
29
28
|
);
|
|
30
|
-
|
|
29
|
+
const siteKey = siteKeyMatch?.[0].replace(/sitekey=["|']/, '') || '';
|
|
31
30
|
const csrfToken =
|
|
32
31
|
csrfTokenMatch?.[0].replace(
|
|
33
32
|
/name=['|"]csrfmiddlewaretoken['|"] value=['|"]/gi,
|