@akinon/next 1.45.0-rc.5 → 1.46.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 +5 -316
- package/api/client.ts +9 -39
- package/assets/styles/index.scss +26 -50
- package/components/index.ts +0 -1
- package/components/input.tsx +7 -21
- package/components/link.tsx +13 -17
- package/components/pagination.tsx +2 -1
- package/components/price.tsx +4 -11
- package/components/selected-payment-option-view.tsx +38 -26
- package/data/client/account.ts +9 -10
- package/data/client/address.ts +8 -32
- package/data/client/api.ts +2 -2
- package/data/client/b2b.ts +2 -35
- package/data/client/basket.ts +5 -6
- package/data/client/checkout.ts +4 -47
- package/data/client/wishlist.ts +2 -70
- package/data/server/category.ts +2 -2
- package/data/server/list.ts +2 -2
- package/data/server/product.ts +13 -15
- package/data/server/special-page.ts +2 -2
- package/data/urls.ts +3 -17
- package/hooks/index.ts +1 -2
- package/hooks/use-payment-options.ts +1 -2
- package/lib/cache.ts +6 -18
- package/middlewares/default.ts +2 -50
- package/middlewares/locale.ts +30 -32
- package/middlewares/pretty-url.ts +0 -4
- package/middlewares/url-redirection.ts +0 -4
- package/package.json +4 -5
- package/plugins.d.ts +0 -1
- package/redux/middlewares/checkout.ts +11 -70
- package/redux/reducers/checkout.ts +5 -24
- package/redux/reducers/config.ts +0 -2
- package/types/commerce/account.ts +0 -1
- package/types/commerce/address.ts +1 -1
- package/types/commerce/b2b.ts +2 -12
- package/types/commerce/checkout.ts +0 -30
- package/types/commerce/misc.ts +0 -2
- package/types/commerce/order.ts +0 -12
- package/types/index.ts +2 -30
- package/utils/app-fetch.ts +1 -1
- package/utils/generate-commerce-search-params.ts +2 -6
- package/utils/index.ts +6 -27
- package/utils/menu-generator.ts +2 -2
- package/utils/server-translation.ts +1 -5
- package/with-pz-config.js +1 -11
- package/assets/styles/index.css +0 -49
- package/assets/styles/index.css.map +0 -1
- package/components/file-input.tsx +0 -8
- package/hooks/use-message-listener.ts +0 -24
- package/lib/cache-handler.mjs +0 -33
- package/routes/pretty-url.tsx +0 -194
- package/utils/redirection-iframe.ts +0 -85
package/lib/cache.ts
CHANGED
|
@@ -20,16 +20,13 @@ const hashCacheKey = (object?: Record<string, string>) => {
|
|
|
20
20
|
return `_${encodeURIComponent(cacheKey)}`;
|
|
21
21
|
};
|
|
22
22
|
export const CacheKey = {
|
|
23
|
-
List: (
|
|
24
|
-
searchParams: { [key: string]: string | string[] | undefined },
|
|
25
|
-
headers?: Record<string, string>
|
|
26
|
-
) =>
|
|
23
|
+
List: (searchParams: URLSearchParams, headers?: Record<string, string>) =>
|
|
27
24
|
`list_${encodeURIComponent(JSON.stringify(searchParams))}${hashCacheKey(
|
|
28
25
|
headers
|
|
29
26
|
)}`,
|
|
30
27
|
Category: (
|
|
31
28
|
pk: number,
|
|
32
|
-
searchParams?:
|
|
29
|
+
searchParams?: URLSearchParams,
|
|
33
30
|
headers?: Record<string, string>
|
|
34
31
|
) =>
|
|
35
32
|
`category_${pk}_${encodeURIComponent(
|
|
@@ -38,20 +35,15 @@ export const CacheKey = {
|
|
|
38
35
|
CategorySlug: (slug: string) => `category_${slug}`,
|
|
39
36
|
SpecialPage: (
|
|
40
37
|
pk: number,
|
|
41
|
-
searchParams:
|
|
38
|
+
searchParams: URLSearchParams,
|
|
42
39
|
headers?: Record<string, string>
|
|
43
40
|
) =>
|
|
44
41
|
`special_page_${pk}_${encodeURIComponent(
|
|
45
42
|
JSON.stringify(searchParams)
|
|
46
43
|
)}${hashCacheKey(headers)}`,
|
|
47
|
-
Product: (
|
|
48
|
-
pk
|
|
49
|
-
|
|
50
|
-
) => `product_${pk}_${encodeURIComponent(JSON.stringify(searchParams))}`,
|
|
51
|
-
GroupProduct: (
|
|
52
|
-
pk: number,
|
|
53
|
-
searchParams: { [key: string]: string | string[] | undefined }
|
|
54
|
-
) =>
|
|
44
|
+
Product: (pk: number, searchParams: URLSearchParams) =>
|
|
45
|
+
`product_${pk}_${encodeURIComponent(JSON.stringify(searchParams))}`,
|
|
46
|
+
GroupProduct: (pk: number, searchParams: URLSearchParams) =>
|
|
55
47
|
`group_product_${pk}_${encodeURIComponent(JSON.stringify(searchParams))}`,
|
|
56
48
|
FlatPage: (pk: number) => `flat_page_${pk}`,
|
|
57
49
|
LandingPage: (pk: number) => `landing_page_${pk}`,
|
|
@@ -166,10 +158,6 @@ export class Cache {
|
|
|
166
158
|
handler: () => Promise<T>,
|
|
167
159
|
options?: CacheOptions
|
|
168
160
|
): Promise<T> {
|
|
169
|
-
if (Settings.usePrettyUrlRoute) {
|
|
170
|
-
return await handler();
|
|
171
|
-
}
|
|
172
|
-
|
|
173
161
|
const requiredVariables = [
|
|
174
162
|
process.env.CACHE_HOST,
|
|
175
163
|
process.env.CACHE_PORT,
|
package/middlewares/default.ts
CHANGED
|
@@ -69,10 +69,6 @@ const withPzDefault =
|
|
|
69
69
|
return NextResponse.json({ status: 'ok' });
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
if (url.pathname.startsWith('/metrics')) {
|
|
73
|
-
return new NextResponse(null, { status: 200 });
|
|
74
|
-
}
|
|
75
|
-
|
|
76
72
|
if (req.nextUrl.pathname.startsWith('/.well-known')) {
|
|
77
73
|
const url = new URL(`${Settings.commerceUrl}${req.nextUrl.pathname}`);
|
|
78
74
|
const req_ = await fetch(url.toString());
|
|
@@ -88,44 +84,14 @@ const withPzDefault =
|
|
|
88
84
|
req.nextUrl.pathname.includes('/orders/hooks/') ||
|
|
89
85
|
req.nextUrl.pathname.includes('/orders/checkout-with-token/')
|
|
90
86
|
) {
|
|
91
|
-
|
|
92
|
-
const currency = url.searchParams.get('currency')?.toLowerCase();
|
|
93
|
-
|
|
94
|
-
const headers = {};
|
|
95
|
-
|
|
96
|
-
if (segment) {
|
|
97
|
-
headers['X-Segment-Id'] = segment;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
if (currency) {
|
|
101
|
-
headers['x-currency'] = currency;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
const response = NextResponse.rewrite(
|
|
87
|
+
return NextResponse.rewrite(
|
|
105
88
|
new URL(
|
|
106
89
|
`${Settings.commerceUrl}${req.nextUrl.pathname.replace(
|
|
107
90
|
urlLocaleMatcherRegex,
|
|
108
91
|
''
|
|
109
92
|
)}`
|
|
110
|
-
)
|
|
111
|
-
{
|
|
112
|
-
headers
|
|
113
|
-
}
|
|
93
|
+
)
|
|
114
94
|
);
|
|
115
|
-
|
|
116
|
-
if (segment) {
|
|
117
|
-
response.cookies.set('pz-segment', segment);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
if (currency) {
|
|
121
|
-
response.cookies.set('pz-currency', currency, {
|
|
122
|
-
sameSite: 'none',
|
|
123
|
-
secure: true,
|
|
124
|
-
expires: new Date(Date.now() + 1000 * 60 * 60 * 24 * 7) // 7 days
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
return response;
|
|
129
95
|
}
|
|
130
96
|
|
|
131
97
|
if (req.nextUrl.pathname.startsWith('/orders/redirection/')) {
|
|
@@ -237,20 +203,6 @@ const withPzDefault =
|
|
|
237
203
|
);
|
|
238
204
|
}
|
|
239
205
|
|
|
240
|
-
if (
|
|
241
|
-
Settings.usePrettyUrlRoute &&
|
|
242
|
-
url.searchParams.toString().length > 0 &&
|
|
243
|
-
!Object.entries(ROUTES).find(([, value]) =>
|
|
244
|
-
new RegExp(`^${value}/?$`).test(
|
|
245
|
-
pathnameWithoutLocale
|
|
246
|
-
)
|
|
247
|
-
)
|
|
248
|
-
) {
|
|
249
|
-
url.pathname =
|
|
250
|
-
url.pathname +
|
|
251
|
-
`searchparams|${url.searchParams.toString()}`;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
206
|
Settings.rewrites.forEach((rewrite) => {
|
|
255
207
|
url.pathname = url.pathname.replace(
|
|
256
208
|
rewrite.source,
|
package/middlewares/locale.ts
CHANGED
|
@@ -5,6 +5,22 @@ import { LocaleUrlStrategy } from '../localization';
|
|
|
5
5
|
import { urlLocaleMatcherRegex } from '../utils';
|
|
6
6
|
import logger from '../utils/log';
|
|
7
7
|
|
|
8
|
+
const getMatchedLocale = (pathname: string) => {
|
|
9
|
+
let matchedLocale = pathname.match(urlLocaleMatcherRegex)?.[0] ?? '';
|
|
10
|
+
matchedLocale = matchedLocale.replace('/', '');
|
|
11
|
+
|
|
12
|
+
if (!matchedLocale.length) {
|
|
13
|
+
if (
|
|
14
|
+
settings.localization.localeUrlStrategy !==
|
|
15
|
+
LocaleUrlStrategy.ShowAllLocales
|
|
16
|
+
) {
|
|
17
|
+
matchedLocale = settings.localization.defaultLocaleValue;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return matchedLocale;
|
|
22
|
+
};
|
|
23
|
+
|
|
8
24
|
const withLocale =
|
|
9
25
|
(middleware: NextMiddleware) =>
|
|
10
26
|
async (req: PzNextRequest, event: NextFetchEvent) => {
|
|
@@ -12,12 +28,12 @@ const withLocale =
|
|
|
12
28
|
|
|
13
29
|
try {
|
|
14
30
|
const url = req.nextUrl.clone();
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
31
|
+
const matchedLocale = getMatchedLocale(url.pathname);
|
|
32
|
+
let { localeUrlStrategy, defaultLocaleValue, redirectToDefaultLocale } =
|
|
33
|
+
settings.localization;
|
|
34
|
+
|
|
35
|
+
localeUrlStrategy =
|
|
36
|
+
localeUrlStrategy ?? LocaleUrlStrategy.HideDefaultLocale;
|
|
21
37
|
|
|
22
38
|
if (!defaultLocaleValue) {
|
|
23
39
|
logger.error('Default locale value is not defined in settings.', {
|
|
@@ -29,34 +45,16 @@ const withLocale =
|
|
|
29
45
|
}
|
|
30
46
|
|
|
31
47
|
if (
|
|
32
|
-
|
|
33
|
-
localeUrlStrategy === LocaleUrlStrategy.ShowAllLocales
|
|
48
|
+
!matchedLocale?.length &&
|
|
49
|
+
localeUrlStrategy === LocaleUrlStrategy.ShowAllLocales &&
|
|
50
|
+
redirectToDefaultLocale &&
|
|
51
|
+
req.method === 'GET'
|
|
34
52
|
) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
if (pathParts[0] === singleLocale) {
|
|
39
|
-
url.pathname = '/' + pathParts.slice(1).join('/');
|
|
40
|
-
return NextResponse.redirect(url);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
req.middlewareParams.rewrites.locale = singleLocale;
|
|
44
|
-
} else {
|
|
45
|
-
const matchedLocale =
|
|
46
|
-
url.pathname.match(urlLocaleMatcherRegex)?.[0]?.replace('/', '') ||
|
|
47
|
-
'';
|
|
48
|
-
if (
|
|
49
|
-
!matchedLocale &&
|
|
50
|
-
localeUrlStrategy === LocaleUrlStrategy.ShowAllLocales &&
|
|
51
|
-
redirectToDefaultLocale &&
|
|
52
|
-
req.method === 'GET'
|
|
53
|
-
) {
|
|
54
|
-
url.pathname = `/${defaultLocaleValue}${url.pathname}`;
|
|
55
|
-
return NextResponse.redirect(url);
|
|
56
|
-
}
|
|
57
|
-
req.middlewareParams.rewrites.locale =
|
|
58
|
-
matchedLocale || defaultLocaleValue;
|
|
53
|
+
url.pathname = `/${defaultLocaleValue}${url.pathname}`;
|
|
54
|
+
return NextResponse.redirect(url);
|
|
59
55
|
}
|
|
56
|
+
|
|
57
|
+
req.middlewareParams.rewrites.locale = matchedLocale;
|
|
60
58
|
} catch (error) {
|
|
61
59
|
logger.error('withLocale error', {
|
|
62
60
|
error,
|
|
@@ -56,10 +56,6 @@ const resolvePrettyUrl = async (pathname: string, ip: string | null) => {
|
|
|
56
56
|
const withPrettyUrl =
|
|
57
57
|
(middleware: NextMiddleware) =>
|
|
58
58
|
async (req: PzNextRequest, event: NextFetchEvent) => {
|
|
59
|
-
if (Settings.usePrettyUrlRoute) {
|
|
60
|
-
return middleware(req, event);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
59
|
const url = req.nextUrl.clone();
|
|
64
60
|
const matchedLanguagePrefix = url.pathname.match(
|
|
65
61
|
urlLocaleMatcherRegex
|
|
@@ -11,10 +11,6 @@ import { ROUTES } from 'routes';
|
|
|
11
11
|
const withUrlRedirection =
|
|
12
12
|
(middleware: NextMiddleware) =>
|
|
13
13
|
async (req: PzNextRequest, event: NextFetchEvent) => {
|
|
14
|
-
if (settings.usePrettyUrlRoute) {
|
|
15
|
-
return middleware(req, event);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
14
|
const url = req.nextUrl.clone();
|
|
19
15
|
const ip = req.headers.get('x-forwarded-for') ?? '';
|
|
20
16
|
const pathnameWithoutLocale = url.pathname.replace(
|
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.46.0",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"bin": {
|
|
@@ -20,22 +20,21 @@
|
|
|
20
20
|
"@opentelemetry/sdk-trace-node": "1.19.0",
|
|
21
21
|
"@opentelemetry/semantic-conventions": "1.19.0",
|
|
22
22
|
"@reduxjs/toolkit": "1.9.7",
|
|
23
|
-
"@neshca/cache-handler": "1.5.1",
|
|
24
23
|
"cross-spawn": "7.0.3",
|
|
25
24
|
"generic-pool": "3.9.0",
|
|
26
25
|
"react-redux": "8.1.3",
|
|
27
26
|
"react-string-replace": "1.1.1",
|
|
28
|
-
"redis": "4.
|
|
29
|
-
"semver": "7.
|
|
27
|
+
"redis": "4.5.1",
|
|
28
|
+
"semver": "7.5.4",
|
|
30
29
|
"set-cookie-parser": "2.6.0"
|
|
31
30
|
},
|
|
32
31
|
"devDependencies": {
|
|
33
|
-
"@akinon/eslint-plugin-projectzero": "1.45.0-rc.5",
|
|
34
32
|
"@types/react-redux": "7.1.30",
|
|
35
33
|
"@types/set-cookie-parser": "2.4.7",
|
|
36
34
|
"@typescript-eslint/eslint-plugin": "6.7.4",
|
|
37
35
|
"@typescript-eslint/parser": "6.7.4",
|
|
38
36
|
"eslint": "^8.14.0",
|
|
37
|
+
"@akinon/eslint-plugin-projectzero": "1.46.0",
|
|
39
38
|
"eslint-config-prettier": "8.5.0"
|
|
40
39
|
}
|
|
41
40
|
}
|
package/plugins.d.ts
CHANGED
|
@@ -12,7 +12,6 @@ declare module '@akinon/pz-masterpass/src/utils' {
|
|
|
12
12
|
declare module '@akinon/pz-masterpass/src/redux/reducer' {
|
|
13
13
|
export const setError: any;
|
|
14
14
|
export const setOtpModalVisible: any;
|
|
15
|
-
export const setCvcRequired: any;
|
|
16
15
|
}
|
|
17
16
|
|
|
18
17
|
declare module '@akinon/pz-otp' {
|
|
@@ -16,10 +16,8 @@ import {
|
|
|
16
16
|
setPreOrder,
|
|
17
17
|
setRetailStores,
|
|
18
18
|
setShippingOptions,
|
|
19
|
-
setDataSourceShippingOptions,
|
|
20
19
|
setShippingStepCompleted,
|
|
21
|
-
setCreditPaymentOptions
|
|
22
|
-
setAttributeBasedShippingOptions
|
|
20
|
+
setCreditPaymentOptions
|
|
23
21
|
} from '../../redux/reducers/checkout';
|
|
24
22
|
import { RootState, TypedDispatch } from 'redux/store';
|
|
25
23
|
import { checkoutApi } from '../../data/client/checkout';
|
|
@@ -28,11 +26,10 @@ import { getCookie, setCookie } from '../../utils';
|
|
|
28
26
|
import settings from 'settings';
|
|
29
27
|
import { LocaleUrlStrategy } from '../../localization';
|
|
30
28
|
import { showMobile3dIframe } from '../../utils/mobile-3d-iframe';
|
|
31
|
-
import { showRedirectionIframe } from '../../utils/redirection-iframe';
|
|
32
29
|
|
|
33
30
|
interface CheckoutResult {
|
|
34
31
|
payload: {
|
|
35
|
-
errors?:
|
|
32
|
+
errors?: any;
|
|
36
33
|
pre_order?: PreOrder;
|
|
37
34
|
context_list?: CheckoutContext[];
|
|
38
35
|
};
|
|
@@ -76,10 +73,8 @@ export const preOrderMiddleware: Middleware = ({
|
|
|
76
73
|
deliveryOptions,
|
|
77
74
|
addressList: addresses,
|
|
78
75
|
shippingOptions,
|
|
79
|
-
dataSourceShippingOptions,
|
|
80
76
|
paymentOptions,
|
|
81
|
-
installmentOptions
|
|
82
|
-
attributeBasedShippingOptions
|
|
77
|
+
installmentOptions
|
|
83
78
|
} = getState().checkout;
|
|
84
79
|
const { endpoints: apiEndpoints } = checkoutApi;
|
|
85
80
|
|
|
@@ -130,40 +125,6 @@ export const preOrderMiddleware: Middleware = ({
|
|
|
130
125
|
dispatch(apiEndpoints.setShippingOption.initiate(shippingOptions[0].pk));
|
|
131
126
|
}
|
|
132
127
|
|
|
133
|
-
if (
|
|
134
|
-
dataSourceShippingOptions.length > 0 &&
|
|
135
|
-
!preOrder.data_source_shipping_options
|
|
136
|
-
) {
|
|
137
|
-
const selectedDataSourceShippingOptionsPks =
|
|
138
|
-
dataSourceShippingOptions.map(
|
|
139
|
-
(opt) => opt.data_source_shipping_options[0].pk
|
|
140
|
-
);
|
|
141
|
-
|
|
142
|
-
dispatch(
|
|
143
|
-
apiEndpoints.setDataSourceShippingOptions.initiate(
|
|
144
|
-
selectedDataSourceShippingOptionsPks
|
|
145
|
-
)
|
|
146
|
-
);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
if (
|
|
150
|
-
Object.keys(attributeBasedShippingOptions).length > 0 &&
|
|
151
|
-
!preOrder.attribute_based_shipping_options
|
|
152
|
-
) {
|
|
153
|
-
const initialSelectedOptions: Record<string, number> = Object.fromEntries(
|
|
154
|
-
Object.entries(attributeBasedShippingOptions).map(([key, options]) => [
|
|
155
|
-
key,
|
|
156
|
-
options[0].pk
|
|
157
|
-
])
|
|
158
|
-
);
|
|
159
|
-
|
|
160
|
-
dispatch(
|
|
161
|
-
apiEndpoints.setAttributeBasedShippingOptions.initiate(
|
|
162
|
-
initialSelectedOptions
|
|
163
|
-
)
|
|
164
|
-
);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
128
|
if (!preOrder.payment_option && paymentOptions.length > 0) {
|
|
168
129
|
dispatch(apiEndpoints.setPaymentOption.initiate(paymentOptions[0].pk));
|
|
169
130
|
}
|
|
@@ -202,7 +163,6 @@ export const contextListMiddleware: Middleware = ({
|
|
|
202
163
|
if (result?.payload?.context_list) {
|
|
203
164
|
result.payload.context_list.forEach((context) => {
|
|
204
165
|
const redirectUrl = context.page_context.redirect_url;
|
|
205
|
-
const isIframe = context.page_context.is_frame ?? false;
|
|
206
166
|
|
|
207
167
|
if (redirectUrl) {
|
|
208
168
|
const currentLocale = getCookie('pz-locale');
|
|
@@ -221,19 +181,16 @@ export const contextListMiddleware: Middleware = ({
|
|
|
221
181
|
}
|
|
222
182
|
|
|
223
183
|
const urlObj = new URL(url, window.location.origin);
|
|
224
|
-
const isMobileDevice =
|
|
225
|
-
isMobileApp ||
|
|
226
|
-
/iPad|iPhone|iPod|Android/i.test(navigator.userAgent);
|
|
227
|
-
const isIframePaymentOptionExcluded =
|
|
228
|
-
!settings.checkout?.iframeExcludedPaymentOptions?.includes(
|
|
229
|
-
result.payload?.pre_order?.payment_option?.slug
|
|
230
|
-
);
|
|
231
184
|
urlObj.searchParams.set('t', new Date().getTime().toString());
|
|
232
185
|
|
|
233
|
-
if (
|
|
186
|
+
if (
|
|
187
|
+
(isMobileApp ||
|
|
188
|
+
/iPad|iPhone|iPod|Android/i.test(navigator.userAgent)) &&
|
|
189
|
+
!settings.checkout?.iframeExcludedPaymentOptions?.includes(
|
|
190
|
+
result.payload?.pre_order?.payment_option?.slug
|
|
191
|
+
)
|
|
192
|
+
) {
|
|
234
193
|
showMobile3dIframe(urlObj.toString());
|
|
235
|
-
} else if (isIframe && !isIframePaymentOptionExcluded) {
|
|
236
|
-
showRedirectionIframe(urlObj.toString());
|
|
237
194
|
} else {
|
|
238
195
|
window.location.href = urlObj.toString();
|
|
239
196
|
}
|
|
@@ -263,28 +220,12 @@ export const contextListMiddleware: Middleware = ({
|
|
|
263
220
|
dispatch(setShippingOptions(context.page_context.shipping_options));
|
|
264
221
|
}
|
|
265
222
|
|
|
266
|
-
if (context.page_context.data_sources) {
|
|
267
|
-
dispatch(
|
|
268
|
-
setDataSourceShippingOptions(context.page_context.data_sources)
|
|
269
|
-
);
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
if (context.page_context.attribute_based_shipping_options) {
|
|
273
|
-
dispatch(
|
|
274
|
-
setAttributeBasedShippingOptions(
|
|
275
|
-
context.page_context.attribute_based_shipping_options
|
|
276
|
-
)
|
|
277
|
-
);
|
|
278
|
-
}
|
|
279
|
-
|
|
280
223
|
if (context.page_context.payment_options) {
|
|
281
224
|
dispatch(setPaymentOptions(context.page_context.payment_options));
|
|
282
225
|
}
|
|
283
226
|
|
|
284
227
|
if (context.page_context.credit_payment_options) {
|
|
285
|
-
dispatch(
|
|
286
|
-
setCreditPaymentOptions(context.page_context.credit_payment_options)
|
|
287
|
-
);
|
|
228
|
+
dispatch(setCreditPaymentOptions(context.page_context.credit_payment_options));
|
|
288
229
|
}
|
|
289
230
|
|
|
290
231
|
if (context.page_context.payment_choices) {
|
|
@@ -14,13 +14,12 @@ import {
|
|
|
14
14
|
CheckoutCreditPaymentOption,
|
|
15
15
|
PreOrder,
|
|
16
16
|
RetailStore,
|
|
17
|
-
ShippingOption
|
|
18
|
-
DataSource,
|
|
19
|
-
AttributeBasedShippingOption
|
|
17
|
+
ShippingOption
|
|
20
18
|
} from '../../types';
|
|
21
19
|
|
|
22
20
|
export interface CheckoutState {
|
|
23
|
-
|
|
21
|
+
// TODO: Add types
|
|
22
|
+
errors: any;
|
|
24
23
|
hasGiftBox: boolean;
|
|
25
24
|
canGuestPurchase: boolean;
|
|
26
25
|
steps: {
|
|
@@ -38,7 +37,6 @@ export interface CheckoutState {
|
|
|
38
37
|
addressList: Address[];
|
|
39
38
|
deliveryOptions: DeliveryOption[];
|
|
40
39
|
shippingOptions: ShippingOption[];
|
|
41
|
-
dataSourceShippingOptions: DataSource[];
|
|
42
40
|
paymentOptions: PaymentOption[];
|
|
43
41
|
creditPaymentOptions: CheckoutCreditPaymentOption[];
|
|
44
42
|
selectedCreditPaymentPk: number;
|
|
@@ -49,8 +47,6 @@ export interface CheckoutState {
|
|
|
49
47
|
selectedBankAccountPk: number;
|
|
50
48
|
loyaltyBalance?: string;
|
|
51
49
|
retailStores: RetailStore[];
|
|
52
|
-
attributeBasedShippingOptions: AttributeBasedShippingOption[];
|
|
53
|
-
selectedShippingOptions: Record<string, number>;
|
|
54
50
|
}
|
|
55
51
|
|
|
56
52
|
const initialState: CheckoutState = {
|
|
@@ -72,7 +68,6 @@ const initialState: CheckoutState = {
|
|
|
72
68
|
addressList: [],
|
|
73
69
|
deliveryOptions: [],
|
|
74
70
|
shippingOptions: [],
|
|
75
|
-
dataSourceShippingOptions: [],
|
|
76
71
|
paymentOptions: [],
|
|
77
72
|
creditPaymentOptions: [],
|
|
78
73
|
selectedCreditPaymentPk: null,
|
|
@@ -81,9 +76,7 @@ const initialState: CheckoutState = {
|
|
|
81
76
|
installmentOptions: [],
|
|
82
77
|
bankAccounts: [],
|
|
83
78
|
selectedBankAccountPk: null,
|
|
84
|
-
retailStores: []
|
|
85
|
-
attributeBasedShippingOptions: [],
|
|
86
|
-
selectedShippingOptions: {}
|
|
79
|
+
retailStores: []
|
|
87
80
|
};
|
|
88
81
|
|
|
89
82
|
const checkoutSlice = createSlice({
|
|
@@ -129,9 +122,6 @@ const checkoutSlice = createSlice({
|
|
|
129
122
|
setShippingOptions(state, { payload }) {
|
|
130
123
|
state.shippingOptions = payload;
|
|
131
124
|
},
|
|
132
|
-
setDataSourceShippingOptions(state, { payload }) {
|
|
133
|
-
state.dataSourceShippingOptions = payload;
|
|
134
|
-
},
|
|
135
125
|
setPaymentOptions(state, { payload }) {
|
|
136
126
|
state.paymentOptions = payload;
|
|
137
127
|
},
|
|
@@ -161,12 +151,6 @@ const checkoutSlice = createSlice({
|
|
|
161
151
|
},
|
|
162
152
|
setRetailStores(state, { payload }) {
|
|
163
153
|
state.retailStores = payload;
|
|
164
|
-
},
|
|
165
|
-
setAttributeBasedShippingOptions(state, { payload }) {
|
|
166
|
-
state.attributeBasedShippingOptions = payload;
|
|
167
|
-
},
|
|
168
|
-
setSelectedShippingOptions: (state, { payload }) => {
|
|
169
|
-
state.selectedShippingOptions = payload;
|
|
170
154
|
}
|
|
171
155
|
}
|
|
172
156
|
});
|
|
@@ -185,7 +169,6 @@ export const {
|
|
|
185
169
|
setAddressList,
|
|
186
170
|
setDeliveryOptions,
|
|
187
171
|
setShippingOptions,
|
|
188
|
-
setDataSourceShippingOptions,
|
|
189
172
|
setPaymentOptions,
|
|
190
173
|
setCreditPaymentOptions,
|
|
191
174
|
setSelectedCreditPaymentPk,
|
|
@@ -195,9 +178,7 @@ export const {
|
|
|
195
178
|
setBankAccounts,
|
|
196
179
|
setSelectedBankAccountPk,
|
|
197
180
|
setLoyaltyBalance,
|
|
198
|
-
setRetailStores
|
|
199
|
-
setAttributeBasedShippingOptions,
|
|
200
|
-
setSelectedShippingOptions
|
|
181
|
+
setRetailStores
|
|
201
182
|
} = checkoutSlice.actions;
|
|
202
183
|
|
|
203
184
|
export default checkoutSlice.reducer;
|
package/redux/reducers/config.ts
CHANGED
package/types/commerce/b2b.ts
CHANGED
|
@@ -72,7 +72,7 @@ export type BasketItemType = {
|
|
|
72
72
|
divisions: BasketItemDivision[];
|
|
73
73
|
product: ProductB2b;
|
|
74
74
|
product_remote_id: number;
|
|
75
|
-
}
|
|
75
|
+
}
|
|
76
76
|
|
|
77
77
|
export type BasketParams = {
|
|
78
78
|
division: string;
|
|
@@ -91,7 +91,7 @@ export type CreateQuotationParams = {
|
|
|
91
91
|
export type UpdateProductParams = {
|
|
92
92
|
product_remote_id: number;
|
|
93
93
|
division: number;
|
|
94
|
-
quantity: number
|
|
94
|
+
quantity: number
|
|
95
95
|
};
|
|
96
96
|
|
|
97
97
|
export type DeleteProductParams = {
|
|
@@ -115,13 +115,3 @@ export type DraftResponse = {
|
|
|
115
115
|
total_amount: number;
|
|
116
116
|
total_quantity: number;
|
|
117
117
|
};
|
|
118
|
-
|
|
119
|
-
export type BasketStatusResponse = {
|
|
120
|
-
is_ready: boolean;
|
|
121
|
-
status: string;
|
|
122
|
-
url: string;
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
export type ExportBasketResponse = {
|
|
126
|
-
cache_key: string;
|
|
127
|
-
};
|
|
@@ -33,23 +33,6 @@ export interface ShippingOption {
|
|
|
33
33
|
slug: string;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
export interface DataSource {
|
|
37
|
-
pk: number;
|
|
38
|
-
name: string;
|
|
39
|
-
data_source_shipping_options: DataSourceShippingOption[];
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export interface DataSourceShippingOption {
|
|
43
|
-
pk: number;
|
|
44
|
-
shipping_amount: string;
|
|
45
|
-
shipping_option_name: string;
|
|
46
|
-
shipping_option_logo: string | null;
|
|
47
|
-
data_source: {
|
|
48
|
-
pk: number;
|
|
49
|
-
title: string | null;
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
|
|
53
36
|
export interface CheckoutAddressType {
|
|
54
37
|
label: string;
|
|
55
38
|
text: string;
|
|
@@ -95,8 +78,6 @@ export interface PreOrder {
|
|
|
95
78
|
retail_store?: RetailStore;
|
|
96
79
|
gift_box?: GiftBox;
|
|
97
80
|
credit_payment_option?: CheckoutCreditPaymentOption;
|
|
98
|
-
data_source_shipping_options: any;
|
|
99
|
-
attribute_based_shipping_options?: AttributeBasedShippingOption[];
|
|
100
81
|
}
|
|
101
82
|
|
|
102
83
|
export interface GuestLoginFormParams {
|
|
@@ -136,7 +117,6 @@ export interface CheckoutContext {
|
|
|
136
117
|
redirect_url?: string;
|
|
137
118
|
context_data?: any;
|
|
138
119
|
balance?: string;
|
|
139
|
-
attribute_based_shipping_options?: AttributeBasedShippingOption[];
|
|
140
120
|
[key: string]: any;
|
|
141
121
|
};
|
|
142
122
|
}
|
|
@@ -162,13 +142,3 @@ export interface BankAccount {
|
|
|
162
142
|
pk: number;
|
|
163
143
|
sort_order: number;
|
|
164
144
|
}
|
|
165
|
-
|
|
166
|
-
export interface AttributeBasedShippingOption {
|
|
167
|
-
pk: number;
|
|
168
|
-
shipping_amount: string | null;
|
|
169
|
-
shipping_option_name: string | null;
|
|
170
|
-
shipping_option_logo: string | null;
|
|
171
|
-
attribute_value: string | null;
|
|
172
|
-
attribute_key: string;
|
|
173
|
-
[key: string]: any;
|
|
174
|
-
}
|
package/types/commerce/misc.ts
CHANGED
package/types/commerce/order.ts
CHANGED
|
@@ -52,10 +52,6 @@ export interface OrderItem {
|
|
|
52
52
|
quantity: string;
|
|
53
53
|
unit_price: string;
|
|
54
54
|
total_amount: string;
|
|
55
|
-
attributes: {
|
|
56
|
-
gift_note: string;
|
|
57
|
-
[key: string]: any;
|
|
58
|
-
};
|
|
59
55
|
}
|
|
60
56
|
|
|
61
57
|
export interface Order {
|
|
@@ -109,14 +105,6 @@ export interface Order {
|
|
|
109
105
|
shipping_option: number;
|
|
110
106
|
tracking_number: string;
|
|
111
107
|
tracking_url: string;
|
|
112
|
-
[key: string]: any;
|
|
113
|
-
bank: {
|
|
114
|
-
pk: number;
|
|
115
|
-
name: string;
|
|
116
|
-
slug: string;
|
|
117
|
-
logo: string;
|
|
118
|
-
[key: string]: any;
|
|
119
|
-
};
|
|
120
108
|
}
|
|
121
109
|
|
|
122
110
|
export interface Quotations {
|