@akinon/next 1.55.0-rc.0 → 1.55.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 +6 -483
- package/api/client.ts +17 -50
- 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 +7 -21
- package/components/link.tsx +13 -17
- package/components/price.tsx +4 -11
- package/components/pz-root.tsx +3 -15
- package/components/selected-payment-option-view.tsx +38 -26
- package/data/client/account.ts +9 -10
- 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 +1 -38
- 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/default.ts +8 -87
- package/middlewares/pretty-url.ts +1 -11
- package/middlewares/url-redirection.ts +0 -4
- package/package.json +3 -4
- package/redux/middlewares/checkout.ts +10 -69
- package/redux/reducers/checkout.ts +3 -23
- 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/order.ts +0 -1
- package/types/index.ts +2 -18
- package/utils/app-fetch.ts +8 -17
- package/utils/generate-commerce-search-params.ts +1 -3
- package/utils/index.ts +6 -27
- package/utils/server-translation.ts +1 -11
- package/utils/server-variables.ts +1 -2
- 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/routes/pretty-url.tsx +0 -192
- package/utils/redirection-iframe.ts +0 -85
|
@@ -2,6 +2,7 @@ import settings from 'settings';
|
|
|
2
2
|
import { LayoutProps, PageProps, RootLayoutProps } from '../../types';
|
|
3
3
|
import { redirect } from 'next/navigation';
|
|
4
4
|
import { ServerVariables } from '../../utils/server-variables';
|
|
5
|
+
import { getTranslations } from '../../utils/server-translation';
|
|
5
6
|
import { ROUTES } from 'routes';
|
|
6
7
|
import logger from '../../utils/log';
|
|
7
8
|
|
|
@@ -49,11 +50,7 @@ const addRootLayoutProps = async (componentProps: RootLayoutProps) => {
|
|
|
49
50
|
return redirect(ROUTES.HOME);
|
|
50
51
|
}
|
|
51
52
|
|
|
52
|
-
const { getTranslations } = settings.useOptimizedTranslations
|
|
53
|
-
? require('translations')
|
|
54
|
-
: require('../../utils/server-translation');
|
|
55
53
|
const translations = await getTranslations(params.locale);
|
|
56
|
-
|
|
57
54
|
componentProps.translations = translations;
|
|
58
55
|
|
|
59
56
|
const locale = settings.localization.locales.find(
|
package/hooks/index.ts
CHANGED
|
@@ -8,5 +8,4 @@ export * from './use-media-query';
|
|
|
8
8
|
export * from './use-on-click-outside';
|
|
9
9
|
export * from './use-mobile-iframe-handler';
|
|
10
10
|
export * from './use-payment-options';
|
|
11
|
-
export * from './use-pagination';
|
|
12
|
-
export * from './use-message-listener';
|
|
11
|
+
export * from './use-pagination';
|
package/hooks/use-pagination.ts
CHANGED
|
@@ -116,7 +116,7 @@ export default function usePagination(
|
|
|
116
116
|
urlSearchParams.set('page', (Number(state.page) - 1).toString());
|
|
117
117
|
return `${pathname}?${urlSearchParams.toString()}`;
|
|
118
118
|
}
|
|
119
|
-
return
|
|
119
|
+
return '#';
|
|
120
120
|
}, [state.page, pathname, urlSearchParams]);
|
|
121
121
|
|
|
122
122
|
const next = useMemo(() => {
|
|
@@ -124,7 +124,7 @@ export default function usePagination(
|
|
|
124
124
|
urlSearchParams.set('page', (Number(state.page) + 1).toString());
|
|
125
125
|
return `${pathname}?${urlSearchParams.toString()}`;
|
|
126
126
|
}
|
|
127
|
-
return
|
|
127
|
+
return '#';
|
|
128
128
|
}, [state.page, state.last, pathname, urlSearchParams]);
|
|
129
129
|
|
|
130
130
|
return {
|
|
@@ -18,8 +18,7 @@ export const usePaymentOptions = () => {
|
|
|
18
18
|
pay_on_delivery: 'pz-pay-on-delivery',
|
|
19
19
|
bkm_express: 'pz-bkm',
|
|
20
20
|
credit_payment: 'pz-credit-payment',
|
|
21
|
-
masterpass: 'pz-masterpass'
|
|
22
|
-
gpay: 'pz-gpay'
|
|
21
|
+
masterpass: 'pz-masterpass'
|
|
23
22
|
};
|
|
24
23
|
|
|
25
24
|
const isInitialTypeIncluded = (type: string) => initialTypes.has(type);
|
package/lib/cache.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { RedisClientType } from 'redis';
|
|
|
3
3
|
import Settings from 'settings';
|
|
4
4
|
import { CacheOptions } from '../types';
|
|
5
5
|
import logger from '../utils/log';
|
|
6
|
+
import { ServerVariables } from '../utils/server-variables';
|
|
6
7
|
|
|
7
8
|
const hashCacheKey = (object?: Record<string, string>) => {
|
|
8
9
|
if (!object) {
|
|
@@ -58,8 +59,10 @@ export const CacheKey = {
|
|
|
58
59
|
export class Cache {
|
|
59
60
|
static PROXY_URL = `${process.env.NEXT_PUBLIC_URL}/api/cache`;
|
|
60
61
|
|
|
61
|
-
static formatKey(key: string
|
|
62
|
-
return encodeURIComponent(
|
|
62
|
+
static formatKey(key: string) {
|
|
63
|
+
return encodeURIComponent(
|
|
64
|
+
`${Settings.commerceUrl}_${ServerVariables.locale}_${key}`
|
|
65
|
+
);
|
|
63
66
|
}
|
|
64
67
|
|
|
65
68
|
static clientPool: Pool<RedisClientType> = createPool(
|
|
@@ -152,14 +155,9 @@ export class Cache {
|
|
|
152
155
|
|
|
153
156
|
static async wrap<T = any>(
|
|
154
157
|
key: string,
|
|
155
|
-
locale: string,
|
|
156
158
|
handler: () => Promise<T>,
|
|
157
159
|
options?: CacheOptions
|
|
158
160
|
): Promise<T> {
|
|
159
|
-
if (Settings.usePrettyUrlRoute) {
|
|
160
|
-
return await handler();
|
|
161
|
-
}
|
|
162
|
-
|
|
163
161
|
const requiredVariables = [
|
|
164
162
|
process.env.CACHE_HOST,
|
|
165
163
|
process.env.CACHE_PORT,
|
|
@@ -176,7 +174,7 @@ export class Cache {
|
|
|
176
174
|
};
|
|
177
175
|
|
|
178
176
|
const _options = Object.assign(defaultOptions, options);
|
|
179
|
-
const formattedKey = Cache.formatKey(key
|
|
177
|
+
const formattedKey = Cache.formatKey(key);
|
|
180
178
|
|
|
181
179
|
logger.debug('Cache wrap', { key, formattedKey, _options });
|
|
182
180
|
|
package/middlewares/default.ts
CHANGED
|
@@ -88,44 +88,14 @@ const withPzDefault =
|
|
|
88
88
|
req.nextUrl.pathname.includes('/orders/hooks/') ||
|
|
89
89
|
req.nextUrl.pathname.includes('/orders/checkout-with-token/')
|
|
90
90
|
) {
|
|
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(
|
|
91
|
+
return NextResponse.rewrite(
|
|
105
92
|
new URL(
|
|
106
93
|
`${Settings.commerceUrl}${req.nextUrl.pathname.replace(
|
|
107
94
|
urlLocaleMatcherRegex,
|
|
108
95
|
''
|
|
109
96
|
)}`
|
|
110
|
-
)
|
|
111
|
-
{
|
|
112
|
-
headers
|
|
113
|
-
}
|
|
97
|
+
)
|
|
114
98
|
);
|
|
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
99
|
}
|
|
130
100
|
|
|
131
101
|
if (req.nextUrl.pathname.startsWith('/orders/redirection/')) {
|
|
@@ -219,41 +189,10 @@ const withPzDefault =
|
|
|
219
189
|
''
|
|
220
190
|
);
|
|
221
191
|
|
|
222
|
-
middlewareResult = (await middleware(
|
|
223
|
-
req,
|
|
224
|
-
event
|
|
225
|
-
)) as NextResponse | void;
|
|
226
|
-
|
|
227
|
-
let customRewriteUrlDiff = '';
|
|
228
|
-
|
|
229
|
-
if (
|
|
230
|
-
middlewareResult instanceof NextResponse &&
|
|
231
|
-
middlewareResult.headers.get(
|
|
232
|
-
'pz-override-response'
|
|
233
|
-
) &&
|
|
234
|
-
middlewareResult.headers.get(
|
|
235
|
-
'x-middleware-rewrite'
|
|
236
|
-
)
|
|
237
|
-
) {
|
|
238
|
-
const rewriteUrl = new URL(
|
|
239
|
-
middlewareResult.headers.get(
|
|
240
|
-
'x-middleware-rewrite'
|
|
241
|
-
)
|
|
242
|
-
);
|
|
243
|
-
const originalUrl = new URL(req.url);
|
|
244
|
-
customRewriteUrlDiff =
|
|
245
|
-
rewriteUrl.pathname.replace(
|
|
246
|
-
originalUrl.pathname,
|
|
247
|
-
''
|
|
248
|
-
);
|
|
249
|
-
}
|
|
250
|
-
|
|
251
192
|
url.basePath = `/${commerceUrl}`;
|
|
252
193
|
url.pathname = `/${
|
|
253
194
|
locale.length ? `${locale}/` : ''
|
|
254
|
-
}${currency}
|
|
255
|
-
prettyUrl ?? pathnameWithoutLocale
|
|
256
|
-
}`.replace(/\/+/g, '/');
|
|
195
|
+
}${currency}${prettyUrl ?? pathnameWithoutLocale}`;
|
|
257
196
|
|
|
258
197
|
if (
|
|
259
198
|
!req.middlewareParams.found &&
|
|
@@ -268,20 +207,6 @@ const withPzDefault =
|
|
|
268
207
|
);
|
|
269
208
|
}
|
|
270
209
|
|
|
271
|
-
if (
|
|
272
|
-
Settings.usePrettyUrlRoute &&
|
|
273
|
-
url.searchParams.toString().length > 0 &&
|
|
274
|
-
!Object.entries(ROUTES).find(([, value]) =>
|
|
275
|
-
new RegExp(`^${value}/?$`).test(
|
|
276
|
-
pathnameWithoutLocale
|
|
277
|
-
)
|
|
278
|
-
)
|
|
279
|
-
) {
|
|
280
|
-
url.pathname =
|
|
281
|
-
url.pathname +
|
|
282
|
-
`searchparams|${url.searchParams.toString()}`;
|
|
283
|
-
}
|
|
284
|
-
|
|
285
210
|
Settings.rewrites.forEach((rewrite) => {
|
|
286
211
|
url.pathname = url.pathname.replace(
|
|
287
212
|
rewrite.source,
|
|
@@ -289,6 +214,11 @@ const withPzDefault =
|
|
|
289
214
|
);
|
|
290
215
|
});
|
|
291
216
|
|
|
217
|
+
middlewareResult = (await middleware(
|
|
218
|
+
req,
|
|
219
|
+
event
|
|
220
|
+
)) as NextResponse | void;
|
|
221
|
+
|
|
292
222
|
// if middleware.ts has a return value for current url
|
|
293
223
|
if (middlewareResult instanceof NextResponse) {
|
|
294
224
|
// pz-override-response header is used to prevent 404 page for custom responses.
|
|
@@ -301,15 +231,6 @@ const withPzDefault =
|
|
|
301
231
|
'x-middleware-rewrite',
|
|
302
232
|
url.href
|
|
303
233
|
);
|
|
304
|
-
} else if (
|
|
305
|
-
middlewareResult.headers.get(
|
|
306
|
-
'x-middleware-rewrite'
|
|
307
|
-
) &&
|
|
308
|
-
middlewareResult.headers.get(
|
|
309
|
-
'pz-override-response'
|
|
310
|
-
) === 'true'
|
|
311
|
-
) {
|
|
312
|
-
middlewareResult = NextResponse.rewrite(url);
|
|
313
234
|
}
|
|
314
235
|
} else {
|
|
315
236
|
// if middleware.ts doesn't have a return value.
|
|
@@ -43,14 +43,9 @@ const resolvePrettyUrlHandler =
|
|
|
43
43
|
return prettyUrlResult;
|
|
44
44
|
};
|
|
45
45
|
|
|
46
|
-
const resolvePrettyUrl = async (
|
|
47
|
-
pathname: string,
|
|
48
|
-
locale: string,
|
|
49
|
-
ip: string | null
|
|
50
|
-
) => {
|
|
46
|
+
const resolvePrettyUrl = async (pathname: string, ip: string | null) => {
|
|
51
47
|
return Cache.wrap(
|
|
52
48
|
CacheKey.PrettyUrl(pathname),
|
|
53
|
-
locale,
|
|
54
49
|
resolvePrettyUrlHandler(pathname, ip),
|
|
55
50
|
{
|
|
56
51
|
useProxy: true
|
|
@@ -61,10 +56,6 @@ const resolvePrettyUrl = async (
|
|
|
61
56
|
const withPrettyUrl =
|
|
62
57
|
(middleware: NextMiddleware) =>
|
|
63
58
|
async (req: PzNextRequest, event: NextFetchEvent) => {
|
|
64
|
-
if (Settings.usePrettyUrlRoute) {
|
|
65
|
-
return middleware(req, event);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
59
|
const url = req.nextUrl.clone();
|
|
69
60
|
const matchedLanguagePrefix = url.pathname.match(
|
|
70
61
|
urlLocaleMatcherRegex
|
|
@@ -93,7 +84,6 @@ const withPrettyUrl =
|
|
|
93
84
|
)
|
|
94
85
|
? url.pathname
|
|
95
86
|
: prettyUrlPathname,
|
|
96
|
-
matchedLanguagePrefix,
|
|
97
87
|
ip
|
|
98
88
|
);
|
|
99
89
|
|
|
@@ -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.55.0
|
|
4
|
+
"version": "1.55.0",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"bin": {
|
|
@@ -20,17 +20,16 @@
|
|
|
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.
|
|
27
|
+
"redis": "4.5.1",
|
|
29
28
|
"semver": "7.6.2",
|
|
30
29
|
"set-cookie-parser": "2.6.0"
|
|
31
30
|
},
|
|
32
31
|
"devDependencies": {
|
|
33
|
-
"@akinon/eslint-plugin-projectzero": "1.55.0
|
|
32
|
+
"@akinon/eslint-plugin-projectzero": "1.55.0",
|
|
34
33
|
"@types/react-redux": "7.1.30",
|
|
35
34
|
"@types/set-cookie-parser": "2.4.7",
|
|
36
35
|
"@typescript-eslint/eslint-plugin": "6.7.4",
|
|
@@ -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,7 +26,6 @@ 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: {
|
|
@@ -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,9 +14,7 @@ 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 {
|
|
@@ -38,7 +36,6 @@ export interface CheckoutState {
|
|
|
38
36
|
addressList: Address[];
|
|
39
37
|
deliveryOptions: DeliveryOption[];
|
|
40
38
|
shippingOptions: ShippingOption[];
|
|
41
|
-
dataSourceShippingOptions: DataSource[];
|
|
42
39
|
paymentOptions: PaymentOption[];
|
|
43
40
|
creditPaymentOptions: CheckoutCreditPaymentOption[];
|
|
44
41
|
selectedCreditPaymentPk: number;
|
|
@@ -49,8 +46,6 @@ export interface CheckoutState {
|
|
|
49
46
|
selectedBankAccountPk: number;
|
|
50
47
|
loyaltyBalance?: string;
|
|
51
48
|
retailStores: RetailStore[];
|
|
52
|
-
attributeBasedShippingOptions: AttributeBasedShippingOption[];
|
|
53
|
-
selectedShippingOptions: Record<string, number>;
|
|
54
49
|
}
|
|
55
50
|
|
|
56
51
|
const initialState: CheckoutState = {
|
|
@@ -72,7 +67,6 @@ const initialState: CheckoutState = {
|
|
|
72
67
|
addressList: [],
|
|
73
68
|
deliveryOptions: [],
|
|
74
69
|
shippingOptions: [],
|
|
75
|
-
dataSourceShippingOptions: [],
|
|
76
70
|
paymentOptions: [],
|
|
77
71
|
creditPaymentOptions: [],
|
|
78
72
|
selectedCreditPaymentPk: null,
|
|
@@ -81,9 +75,7 @@ const initialState: CheckoutState = {
|
|
|
81
75
|
installmentOptions: [],
|
|
82
76
|
bankAccounts: [],
|
|
83
77
|
selectedBankAccountPk: null,
|
|
84
|
-
retailStores: []
|
|
85
|
-
attributeBasedShippingOptions: [],
|
|
86
|
-
selectedShippingOptions: {}
|
|
78
|
+
retailStores: []
|
|
87
79
|
};
|
|
88
80
|
|
|
89
81
|
const checkoutSlice = createSlice({
|
|
@@ -129,9 +121,6 @@ const checkoutSlice = createSlice({
|
|
|
129
121
|
setShippingOptions(state, { payload }) {
|
|
130
122
|
state.shippingOptions = payload;
|
|
131
123
|
},
|
|
132
|
-
setDataSourceShippingOptions(state, { payload }) {
|
|
133
|
-
state.dataSourceShippingOptions = payload;
|
|
134
|
-
},
|
|
135
124
|
setPaymentOptions(state, { payload }) {
|
|
136
125
|
state.paymentOptions = payload;
|
|
137
126
|
},
|
|
@@ -161,12 +150,6 @@ const checkoutSlice = createSlice({
|
|
|
161
150
|
},
|
|
162
151
|
setRetailStores(state, { payload }) {
|
|
163
152
|
state.retailStores = payload;
|
|
164
|
-
},
|
|
165
|
-
setAttributeBasedShippingOptions(state, { payload }) {
|
|
166
|
-
state.attributeBasedShippingOptions = payload;
|
|
167
|
-
},
|
|
168
|
-
setSelectedShippingOptions: (state, { payload }) => {
|
|
169
|
-
state.selectedShippingOptions = payload;
|
|
170
153
|
}
|
|
171
154
|
}
|
|
172
155
|
});
|
|
@@ -185,7 +168,6 @@ export const {
|
|
|
185
168
|
setAddressList,
|
|
186
169
|
setDeliveryOptions,
|
|
187
170
|
setShippingOptions,
|
|
188
|
-
setDataSourceShippingOptions,
|
|
189
171
|
setPaymentOptions,
|
|
190
172
|
setCreditPaymentOptions,
|
|
191
173
|
setSelectedCreditPaymentPk,
|
|
@@ -195,9 +177,7 @@ export const {
|
|
|
195
177
|
setBankAccounts,
|
|
196
178
|
setSelectedBankAccountPk,
|
|
197
179
|
setLoyaltyBalance,
|
|
198
|
-
setRetailStores
|
|
199
|
-
setAttributeBasedShippingOptions,
|
|
200
|
-
setSelectedShippingOptions
|
|
180
|
+
setRetailStores
|
|
201
181
|
} = checkoutSlice.actions;
|
|
202
182
|
|
|
203
183
|
export default checkoutSlice.reducer;
|
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
|
-
};
|
|
@@ -34,23 +34,6 @@ export interface ShippingOption {
|
|
|
34
34
|
slug: string;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
export interface DataSource {
|
|
38
|
-
pk: number;
|
|
39
|
-
name: string;
|
|
40
|
-
data_source_shipping_options: DataSourceShippingOption[];
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export interface DataSourceShippingOption {
|
|
44
|
-
pk: number;
|
|
45
|
-
shipping_amount: string;
|
|
46
|
-
shipping_option_name: string;
|
|
47
|
-
shipping_option_logo: string | null;
|
|
48
|
-
data_source: {
|
|
49
|
-
pk: number;
|
|
50
|
-
title: string | null;
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
|
|
54
37
|
export interface CheckoutAddressType {
|
|
55
38
|
label: string;
|
|
56
39
|
text: string;
|
|
@@ -96,8 +79,6 @@ export interface PreOrder {
|
|
|
96
79
|
retail_store?: RetailStore;
|
|
97
80
|
gift_box?: GiftBox;
|
|
98
81
|
credit_payment_option?: CheckoutCreditPaymentOption;
|
|
99
|
-
data_source_shipping_options: any;
|
|
100
|
-
attribute_based_shipping_options?: AttributeBasedShippingOption[];
|
|
101
82
|
bags?: Product[];
|
|
102
83
|
bags_fee?: string;
|
|
103
84
|
}
|
|
@@ -139,7 +120,6 @@ export interface CheckoutContext {
|
|
|
139
120
|
redirect_url?: string;
|
|
140
121
|
context_data?: any;
|
|
141
122
|
balance?: string;
|
|
142
|
-
attribute_based_shipping_options?: AttributeBasedShippingOption[];
|
|
143
123
|
[key: string]: any;
|
|
144
124
|
};
|
|
145
125
|
}
|
|
@@ -165,13 +145,3 @@ export interface BankAccount {
|
|
|
165
145
|
pk: number;
|
|
166
146
|
sort_order: number;
|
|
167
147
|
}
|
|
168
|
-
|
|
169
|
-
export interface AttributeBasedShippingOption {
|
|
170
|
-
pk: number;
|
|
171
|
-
shipping_amount: string | null;
|
|
172
|
-
shipping_option_name: string | null;
|
|
173
|
-
shipping_option_logo: string | null;
|
|
174
|
-
attribute_value: string | null;
|
|
175
|
-
attribute_key: string;
|
|
176
|
-
[key: string]: any;
|
|
177
|
-
}
|