@akinon/next 1.50.0 → 1.52.0-rc.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 +500 -0
- package/api/client.ts +50 -17
- package/assets/styles/index.css +49 -0
- package/assets/styles/index.css.map +1 -0
- package/assets/styles/index.scss +50 -26
- package/bin/pz-generate-translations.js +41 -0
- package/bin/pz-prebuild.js +1 -0
- package/bin/pz-predev.js +1 -0
- package/components/file-input.tsx +8 -0
- package/components/index.ts +1 -0
- package/components/input.tsx +21 -7
- package/components/link.tsx +17 -13
- package/components/pagination.tsx +1 -2
- package/components/price.tsx +11 -4
- package/components/pz-root.tsx +15 -3
- package/components/selected-payment-option-view.tsx +26 -38
- package/data/client/account.ts +10 -9
- package/data/client/address.ts +32 -8
- package/data/client/api.ts +2 -2
- package/data/client/b2b.ts +35 -2
- package/data/client/basket.ts +6 -5
- package/data/client/checkout.ts +47 -4
- package/data/client/user.ts +3 -2
- package/data/server/category.ts +43 -19
- package/data/server/flatpage.ts +29 -7
- package/data/server/form.ts +29 -11
- package/data/server/landingpage.ts +26 -7
- package/data/server/list.ts +16 -6
- package/data/server/menu.ts +15 -2
- package/data/server/product.ts +46 -21
- package/data/server/seo.ts +17 -24
- package/data/server/special-page.ts +15 -5
- package/data/server/widget.ts +14 -7
- package/data/urls.ts +8 -1
- package/hocs/server/with-segment-defaults.tsx +4 -1
- package/hooks/index.ts +2 -1
- package/hooks/use-message-listener.ts +24 -0
- package/hooks/use-pagination.ts +2 -2
- package/hooks/use-payment-options.ts +2 -1
- package/lib/cache-handler.mjs +33 -0
- package/lib/cache.ts +8 -6
- package/middlewares/default.ts +91 -8
- package/middlewares/pretty-url.ts +11 -1
- package/middlewares/url-redirection.ts +6 -1
- package/package.json +5 -4
- package/plugins.d.ts +1 -0
- package/redux/middlewares/checkout.ts +70 -11
- package/redux/reducers/checkout.ts +24 -5
- package/redux/reducers/config.ts +2 -0
- package/routes/pretty-url.tsx +192 -0
- package/types/commerce/account.ts +1 -0
- package/types/commerce/address.ts +1 -1
- package/types/commerce/b2b.ts +12 -2
- package/types/commerce/checkout.ts +30 -0
- package/types/commerce/misc.ts +2 -0
- package/types/commerce/order.ts +12 -0
- package/types/index.ts +37 -3
- package/utils/app-fetch.ts +21 -10
- package/utils/generate-commerce-search-params.ts +3 -1
- package/utils/index.ts +27 -6
- package/utils/menu-generator.ts +2 -2
- package/utils/redirection-iframe.ts +85 -0
- package/utils/server-translation.ts +11 -1
- package/utils/server-variables.ts +2 -1
- package/with-pz-config.js +13 -2
|
@@ -16,8 +16,10 @@ import {
|
|
|
16
16
|
setPreOrder,
|
|
17
17
|
setRetailStores,
|
|
18
18
|
setShippingOptions,
|
|
19
|
+
setDataSourceShippingOptions,
|
|
19
20
|
setShippingStepCompleted,
|
|
20
|
-
setCreditPaymentOptions
|
|
21
|
+
setCreditPaymentOptions,
|
|
22
|
+
setAttributeBasedShippingOptions
|
|
21
23
|
} from '../../redux/reducers/checkout';
|
|
22
24
|
import { RootState, TypedDispatch } from 'redux/store';
|
|
23
25
|
import { checkoutApi } from '../../data/client/checkout';
|
|
@@ -26,10 +28,11 @@ import { getCookie, setCookie } from '../../utils';
|
|
|
26
28
|
import settings from 'settings';
|
|
27
29
|
import { LocaleUrlStrategy } from '../../localization';
|
|
28
30
|
import { showMobile3dIframe } from '../../utils/mobile-3d-iframe';
|
|
31
|
+
import { showRedirectionIframe } from '../../utils/redirection-iframe';
|
|
29
32
|
|
|
30
33
|
interface CheckoutResult {
|
|
31
34
|
payload: {
|
|
32
|
-
errors?:
|
|
35
|
+
errors?: Record<string, string[]>;
|
|
33
36
|
pre_order?: PreOrder;
|
|
34
37
|
context_list?: CheckoutContext[];
|
|
35
38
|
};
|
|
@@ -73,8 +76,10 @@ export const preOrderMiddleware: Middleware = ({
|
|
|
73
76
|
deliveryOptions,
|
|
74
77
|
addressList: addresses,
|
|
75
78
|
shippingOptions,
|
|
79
|
+
dataSourceShippingOptions,
|
|
76
80
|
paymentOptions,
|
|
77
|
-
installmentOptions
|
|
81
|
+
installmentOptions,
|
|
82
|
+
attributeBasedShippingOptions
|
|
78
83
|
} = getState().checkout;
|
|
79
84
|
const { endpoints: apiEndpoints } = checkoutApi;
|
|
80
85
|
|
|
@@ -125,6 +130,40 @@ export const preOrderMiddleware: Middleware = ({
|
|
|
125
130
|
dispatch(apiEndpoints.setShippingOption.initiate(shippingOptions[0].pk));
|
|
126
131
|
}
|
|
127
132
|
|
|
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
|
+
|
|
128
167
|
if (!preOrder.payment_option && paymentOptions.length > 0) {
|
|
129
168
|
dispatch(apiEndpoints.setPaymentOption.initiate(paymentOptions[0].pk));
|
|
130
169
|
}
|
|
@@ -163,6 +202,7 @@ export const contextListMiddleware: Middleware = ({
|
|
|
163
202
|
if (result?.payload?.context_list) {
|
|
164
203
|
result.payload.context_list.forEach((context) => {
|
|
165
204
|
const redirectUrl = context.page_context.redirect_url;
|
|
205
|
+
const isIframe = context.page_context.is_frame ?? false;
|
|
166
206
|
|
|
167
207
|
if (redirectUrl) {
|
|
168
208
|
const currentLocale = getCookie('pz-locale');
|
|
@@ -181,16 +221,19 @@ export const contextListMiddleware: Middleware = ({
|
|
|
181
221
|
}
|
|
182
222
|
|
|
183
223
|
const urlObj = new URL(url, window.location.origin);
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
/iPad|iPhone|iPod|Android/i.test(navigator.userAgent)) &&
|
|
224
|
+
const isMobileDevice =
|
|
225
|
+
isMobileApp ||
|
|
226
|
+
/iPad|iPhone|iPod|Android/i.test(navigator.userAgent);
|
|
227
|
+
const isIframePaymentOptionExcluded =
|
|
189
228
|
!settings.checkout?.iframeExcludedPaymentOptions?.includes(
|
|
190
229
|
result.payload?.pre_order?.payment_option?.slug
|
|
191
|
-
)
|
|
192
|
-
)
|
|
230
|
+
);
|
|
231
|
+
urlObj.searchParams.set('t', new Date().getTime().toString());
|
|
232
|
+
|
|
233
|
+
if (isMobileDevice && !isIframePaymentOptionExcluded) {
|
|
193
234
|
showMobile3dIframe(urlObj.toString());
|
|
235
|
+
} else if (isIframe && !isIframePaymentOptionExcluded) {
|
|
236
|
+
showRedirectionIframe(urlObj.toString());
|
|
194
237
|
} else {
|
|
195
238
|
window.location.href = urlObj.toString();
|
|
196
239
|
}
|
|
@@ -220,12 +263,28 @@ export const contextListMiddleware: Middleware = ({
|
|
|
220
263
|
dispatch(setShippingOptions(context.page_context.shipping_options));
|
|
221
264
|
}
|
|
222
265
|
|
|
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
|
+
|
|
223
280
|
if (context.page_context.payment_options) {
|
|
224
281
|
dispatch(setPaymentOptions(context.page_context.payment_options));
|
|
225
282
|
}
|
|
226
283
|
|
|
227
284
|
if (context.page_context.credit_payment_options) {
|
|
228
|
-
dispatch(
|
|
285
|
+
dispatch(
|
|
286
|
+
setCreditPaymentOptions(context.page_context.credit_payment_options)
|
|
287
|
+
);
|
|
229
288
|
}
|
|
230
289
|
|
|
231
290
|
if (context.page_context.payment_choices) {
|
|
@@ -14,12 +14,13 @@ import {
|
|
|
14
14
|
CheckoutCreditPaymentOption,
|
|
15
15
|
PreOrder,
|
|
16
16
|
RetailStore,
|
|
17
|
-
ShippingOption
|
|
17
|
+
ShippingOption,
|
|
18
|
+
DataSource,
|
|
19
|
+
AttributeBasedShippingOption
|
|
18
20
|
} from '../../types';
|
|
19
21
|
|
|
20
22
|
export interface CheckoutState {
|
|
21
|
-
|
|
22
|
-
errors: any;
|
|
23
|
+
errors: Record<string, string[]>;
|
|
23
24
|
hasGiftBox: boolean;
|
|
24
25
|
canGuestPurchase: boolean;
|
|
25
26
|
steps: {
|
|
@@ -37,6 +38,7 @@ export interface CheckoutState {
|
|
|
37
38
|
addressList: Address[];
|
|
38
39
|
deliveryOptions: DeliveryOption[];
|
|
39
40
|
shippingOptions: ShippingOption[];
|
|
41
|
+
dataSourceShippingOptions: DataSource[];
|
|
40
42
|
paymentOptions: PaymentOption[];
|
|
41
43
|
creditPaymentOptions: CheckoutCreditPaymentOption[];
|
|
42
44
|
selectedCreditPaymentPk: number;
|
|
@@ -47,6 +49,8 @@ export interface CheckoutState {
|
|
|
47
49
|
selectedBankAccountPk: number;
|
|
48
50
|
loyaltyBalance?: string;
|
|
49
51
|
retailStores: RetailStore[];
|
|
52
|
+
attributeBasedShippingOptions: AttributeBasedShippingOption[];
|
|
53
|
+
selectedShippingOptions: Record<string, number>;
|
|
50
54
|
}
|
|
51
55
|
|
|
52
56
|
const initialState: CheckoutState = {
|
|
@@ -68,6 +72,7 @@ const initialState: CheckoutState = {
|
|
|
68
72
|
addressList: [],
|
|
69
73
|
deliveryOptions: [],
|
|
70
74
|
shippingOptions: [],
|
|
75
|
+
dataSourceShippingOptions: [],
|
|
71
76
|
paymentOptions: [],
|
|
72
77
|
creditPaymentOptions: [],
|
|
73
78
|
selectedCreditPaymentPk: null,
|
|
@@ -76,7 +81,9 @@ const initialState: CheckoutState = {
|
|
|
76
81
|
installmentOptions: [],
|
|
77
82
|
bankAccounts: [],
|
|
78
83
|
selectedBankAccountPk: null,
|
|
79
|
-
retailStores: []
|
|
84
|
+
retailStores: [],
|
|
85
|
+
attributeBasedShippingOptions: [],
|
|
86
|
+
selectedShippingOptions: {}
|
|
80
87
|
};
|
|
81
88
|
|
|
82
89
|
const checkoutSlice = createSlice({
|
|
@@ -122,6 +129,9 @@ const checkoutSlice = createSlice({
|
|
|
122
129
|
setShippingOptions(state, { payload }) {
|
|
123
130
|
state.shippingOptions = payload;
|
|
124
131
|
},
|
|
132
|
+
setDataSourceShippingOptions(state, { payload }) {
|
|
133
|
+
state.dataSourceShippingOptions = payload;
|
|
134
|
+
},
|
|
125
135
|
setPaymentOptions(state, { payload }) {
|
|
126
136
|
state.paymentOptions = payload;
|
|
127
137
|
},
|
|
@@ -151,6 +161,12 @@ const checkoutSlice = createSlice({
|
|
|
151
161
|
},
|
|
152
162
|
setRetailStores(state, { payload }) {
|
|
153
163
|
state.retailStores = payload;
|
|
164
|
+
},
|
|
165
|
+
setAttributeBasedShippingOptions(state, { payload }) {
|
|
166
|
+
state.attributeBasedShippingOptions = payload;
|
|
167
|
+
},
|
|
168
|
+
setSelectedShippingOptions: (state, { payload }) => {
|
|
169
|
+
state.selectedShippingOptions = payload;
|
|
154
170
|
}
|
|
155
171
|
}
|
|
156
172
|
});
|
|
@@ -169,6 +185,7 @@ export const {
|
|
|
169
185
|
setAddressList,
|
|
170
186
|
setDeliveryOptions,
|
|
171
187
|
setShippingOptions,
|
|
188
|
+
setDataSourceShippingOptions,
|
|
172
189
|
setPaymentOptions,
|
|
173
190
|
setCreditPaymentOptions,
|
|
174
191
|
setSelectedCreditPaymentPk,
|
|
@@ -178,7 +195,9 @@ export const {
|
|
|
178
195
|
setBankAccounts,
|
|
179
196
|
setSelectedBankAccountPk,
|
|
180
197
|
setLoyaltyBalance,
|
|
181
|
-
setRetailStores
|
|
198
|
+
setRetailStores,
|
|
199
|
+
setAttributeBasedShippingOptions,
|
|
200
|
+
setSelectedShippingOptions
|
|
182
201
|
} = checkoutSlice.actions;
|
|
183
202
|
|
|
184
203
|
export default checkoutSlice.reducer;
|
package/redux/reducers/config.ts
CHANGED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { URLS } from '@akinon/next/data/urls';
|
|
2
|
+
import { Metadata, PageProps } from '@akinon/next/types';
|
|
3
|
+
import logger from '@akinon/next/utils/log';
|
|
4
|
+
import { notFound } from 'next/navigation';
|
|
5
|
+
|
|
6
|
+
type PrettyUrlResult = {
|
|
7
|
+
matched: boolean;
|
|
8
|
+
path?: string;
|
|
9
|
+
pk?: number;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const resolvePrettyUrlHandler =
|
|
13
|
+
(pathname: string, ip: string | null) => async () => {
|
|
14
|
+
let results = [] as { old_path: string }[];
|
|
15
|
+
let prettyUrlResult: PrettyUrlResult = {
|
|
16
|
+
matched: false
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
try {
|
|
20
|
+
const requestUrl = URLS.misc.prettyUrls(`/${pathname}/`);
|
|
21
|
+
|
|
22
|
+
logger.debug(`Resolving pretty url`, { pathname, requestUrl, ip });
|
|
23
|
+
|
|
24
|
+
const start = Date.now();
|
|
25
|
+
const apiResponse = await fetch(requestUrl, {
|
|
26
|
+
next: {
|
|
27
|
+
revalidate: 0
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
const data = await apiResponse.json();
|
|
31
|
+
({ results } = data);
|
|
32
|
+
const end = Date.now();
|
|
33
|
+
console.warn('Pretty url response time', end - start, requestUrl);
|
|
34
|
+
|
|
35
|
+
const matched = results.length > 0;
|
|
36
|
+
const [{ old_path: path } = { old_path: '' }] = results;
|
|
37
|
+
let pk;
|
|
38
|
+
|
|
39
|
+
if (matched) {
|
|
40
|
+
const pkRegex = /\/(\d+)\/$/;
|
|
41
|
+
const match = path.match(pkRegex);
|
|
42
|
+
pk = match ? parseInt(match[1]) : undefined;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
prettyUrlResult = {
|
|
46
|
+
matched,
|
|
47
|
+
path,
|
|
48
|
+
pk
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
logger.trace('Pretty url result', { prettyUrlResult, ip });
|
|
52
|
+
} catch (error) {
|
|
53
|
+
logger.error('Error resolving pretty url', { error, pathname, ip });
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return prettyUrlResult;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export async function generateMetadata({ params }: PageProps) {
|
|
60
|
+
let result: Metadata = {};
|
|
61
|
+
const { prettyurl } = params;
|
|
62
|
+
const pageSlug = prettyurl
|
|
63
|
+
.filter((x) => !x.startsWith('searchparams'))
|
|
64
|
+
.join('/');
|
|
65
|
+
|
|
66
|
+
const searchParams = new URLSearchParams(
|
|
67
|
+
decodeURIComponent(
|
|
68
|
+
prettyurl
|
|
69
|
+
.find((x) => x.startsWith('searchparams'))
|
|
70
|
+
?.replace('searchparams%7C', '')
|
|
71
|
+
) ?? {}
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
const prettyUrlResult = await resolvePrettyUrlHandler(pageSlug, null)();
|
|
75
|
+
|
|
76
|
+
if (!prettyUrlResult.matched) {
|
|
77
|
+
return notFound();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const commonProps = {
|
|
81
|
+
params: {
|
|
82
|
+
...params,
|
|
83
|
+
pk: prettyUrlResult.pk
|
|
84
|
+
},
|
|
85
|
+
searchParams
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
try {
|
|
89
|
+
if (prettyUrlResult.path.startsWith('/product/')) {
|
|
90
|
+
await import('@product/[pk]/page').then(async (module) => {
|
|
91
|
+
result = await module['generateMetadata']?.(commonProps);
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (prettyUrlResult.path.startsWith('/group-product/')) {
|
|
96
|
+
await import('@group-product/[pk]/page').then(async (module) => {
|
|
97
|
+
result = await module['generateMetadata']?.(commonProps);
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (prettyUrlResult.path.startsWith('/category/')) {
|
|
102
|
+
await import('@category/[pk]/page').then(async (module) => {
|
|
103
|
+
result = await module['generateMetadata']?.(commonProps);
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (prettyUrlResult.path.startsWith('/special-page/')) {
|
|
108
|
+
await import('@special-page/[pk]/page').then(async (module) => {
|
|
109
|
+
result = await module['generateMetadata']?.(commonProps);
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (prettyUrlResult.path.startsWith('/flat-page/')) {
|
|
114
|
+
await import('@flat-page/[pk]/page').then(async (module) => {
|
|
115
|
+
result = await module['generateMetadata']?.(commonProps);
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
// eslint-disable-next-line no-empty
|
|
119
|
+
} catch (error) {}
|
|
120
|
+
|
|
121
|
+
return result;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export const dynamic = 'force-static';
|
|
125
|
+
export const revalidate = 300;
|
|
126
|
+
|
|
127
|
+
export default async function Page({ params }) {
|
|
128
|
+
const { prettyurl } = params;
|
|
129
|
+
const pageSlug = prettyurl
|
|
130
|
+
.filter((x) => !x.startsWith('searchparams'))
|
|
131
|
+
.join('/');
|
|
132
|
+
|
|
133
|
+
const urlSearchParams = new URLSearchParams(
|
|
134
|
+
decodeURIComponent(
|
|
135
|
+
prettyurl
|
|
136
|
+
.find((x) => x.startsWith('searchparams'))
|
|
137
|
+
?.replace('searchparams%7C', '')
|
|
138
|
+
) ?? {}
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
const searchParams = {};
|
|
142
|
+
|
|
143
|
+
for (const [key, value] of urlSearchParams.entries() as unknown as Array<
|
|
144
|
+
[string, string]
|
|
145
|
+
>) {
|
|
146
|
+
if (!searchParams[key]) {
|
|
147
|
+
searchParams[key] = [];
|
|
148
|
+
}
|
|
149
|
+
searchParams[key].push(value);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const result = await resolvePrettyUrlHandler(pageSlug, null)();
|
|
153
|
+
|
|
154
|
+
if (!result.matched) {
|
|
155
|
+
return notFound();
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const commonProps = {
|
|
159
|
+
params: {
|
|
160
|
+
...params,
|
|
161
|
+
pk: result.pk
|
|
162
|
+
},
|
|
163
|
+
searchParams: new URLSearchParams(searchParams)
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
if (result.path.startsWith('/category/')) {
|
|
167
|
+
const CategoryPage = (await import('@category/[pk]/page')).default;
|
|
168
|
+
return <CategoryPage {...commonProps} />;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if (result.path.startsWith('/product/')) {
|
|
172
|
+
const ProductPage = (await import('@product/[pk]/page')).default;
|
|
173
|
+
return <ProductPage {...commonProps} />;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (result.path.startsWith('/group-product/')) {
|
|
177
|
+
const GroupProduct = (await import('@group-product/[pk]/page')).default;
|
|
178
|
+
return <GroupProduct {...commonProps} />;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
if (result.path.startsWith('/special-page/')) {
|
|
182
|
+
const SpecialPage = (await import('@special-page/[pk]/page')).default;
|
|
183
|
+
return <SpecialPage {...commonProps} />;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
if (result.path.startsWith('/flat-page/')) {
|
|
187
|
+
const FlatPage = (await import('@flat-page/[pk]/page')).default;
|
|
188
|
+
return <FlatPage {...commonProps} />;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
return null;
|
|
192
|
+
}
|
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,3 +115,13 @@ 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,6 +34,23 @@ 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
|
+
|
|
37
54
|
export interface CheckoutAddressType {
|
|
38
55
|
label: string;
|
|
39
56
|
text: string;
|
|
@@ -79,6 +96,8 @@ export interface PreOrder {
|
|
|
79
96
|
retail_store?: RetailStore;
|
|
80
97
|
gift_box?: GiftBox;
|
|
81
98
|
credit_payment_option?: CheckoutCreditPaymentOption;
|
|
99
|
+
data_source_shipping_options: any;
|
|
100
|
+
attribute_based_shipping_options?: AttributeBasedShippingOption[];
|
|
82
101
|
bags?: Product[];
|
|
83
102
|
bags_fee?: string;
|
|
84
103
|
}
|
|
@@ -120,6 +139,7 @@ export interface CheckoutContext {
|
|
|
120
139
|
redirect_url?: string;
|
|
121
140
|
context_data?: any;
|
|
122
141
|
balance?: string;
|
|
142
|
+
attribute_based_shipping_options?: AttributeBasedShippingOption[];
|
|
123
143
|
[key: string]: any;
|
|
124
144
|
};
|
|
125
145
|
}
|
|
@@ -145,3 +165,13 @@ export interface BankAccount {
|
|
|
145
165
|
pk: number;
|
|
146
166
|
sort_order: number;
|
|
147
167
|
}
|
|
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
|
+
}
|
package/types/commerce/misc.ts
CHANGED
package/types/commerce/order.ts
CHANGED
|
@@ -52,6 +52,10 @@ 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
|
+
};
|
|
55
59
|
}
|
|
56
60
|
|
|
57
61
|
export interface Order {
|
|
@@ -105,6 +109,14 @@ export interface Order {
|
|
|
105
109
|
shipping_option: number;
|
|
106
110
|
tracking_number: string;
|
|
107
111
|
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
|
+
};
|
|
108
120
|
}
|
|
109
121
|
|
|
110
122
|
export interface Quotations {
|
package/types/index.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { LocaleUrlStrategy } from '../localization';
|
|
|
2
2
|
import { PzNextRequest } from '../middlewares';
|
|
3
3
|
import { Control, FieldError } from 'react-hook-form';
|
|
4
4
|
import { ReactNode } from 'react';
|
|
5
|
-
|
|
5
|
+
import { UsePaginationType } from '../hooks/use-pagination';
|
|
6
6
|
declare global {
|
|
7
7
|
interface Window {
|
|
8
8
|
// we did it like this because declare types needs to be identical, if not it will fail
|
|
@@ -68,9 +68,17 @@ export interface Currency {
|
|
|
68
68
|
* @see https://en.wikipedia.org/wiki/ISO_4217
|
|
69
69
|
*/
|
|
70
70
|
code: string;
|
|
71
|
+
/**
|
|
72
|
+
* Number of decimal places to display.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* decimalScale: 3
|
|
76
|
+
*/
|
|
77
|
+
decimalScale?: number;
|
|
71
78
|
}
|
|
72
79
|
|
|
73
80
|
export interface Settings {
|
|
81
|
+
usePrettyUrlRoute?: boolean;
|
|
74
82
|
commerceUrl: string;
|
|
75
83
|
redis: {
|
|
76
84
|
defaultExpirationTime: number;
|
|
@@ -183,7 +191,9 @@ export interface Settings {
|
|
|
183
191
|
masterpassJsUrl?: string;
|
|
184
192
|
};
|
|
185
193
|
customNotFoundEnabled: boolean;
|
|
194
|
+
useOptimizedTranslations?: boolean;
|
|
186
195
|
plugins?: Record<string, Record<string, any>>;
|
|
196
|
+
includedProxyHeaders?: string[];
|
|
187
197
|
}
|
|
188
198
|
|
|
189
199
|
export interface CacheOptions {
|
|
@@ -215,7 +225,7 @@ export type ImageOptions = CDNOptions & {
|
|
|
215
225
|
export type Translations = { [key: string]: object };
|
|
216
226
|
|
|
217
227
|
export interface PageProps<T = any> {
|
|
218
|
-
params: T;
|
|
228
|
+
params: T & { locale: string; currency: string };
|
|
219
229
|
searchParams: URLSearchParams;
|
|
220
230
|
}
|
|
221
231
|
|
|
@@ -224,7 +234,11 @@ export interface LayoutProps<T = any> extends PageProps<T> {
|
|
|
224
234
|
}
|
|
225
235
|
|
|
226
236
|
export interface RootLayoutProps<
|
|
227
|
-
T = {
|
|
237
|
+
T = {
|
|
238
|
+
commerce: string;
|
|
239
|
+
locale: string;
|
|
240
|
+
currency: string;
|
|
241
|
+
}
|
|
228
242
|
> extends LayoutProps<T> {
|
|
229
243
|
translations: Translations;
|
|
230
244
|
locale: Locale & {
|
|
@@ -250,6 +264,8 @@ export interface ButtonProps
|
|
|
250
264
|
appearance?: 'filled' | 'outlined' | 'ghost';
|
|
251
265
|
}
|
|
252
266
|
|
|
267
|
+
export type FileInputProps = React.HTMLProps<HTMLInputElement>;
|
|
268
|
+
|
|
253
269
|
export interface PriceProps {
|
|
254
270
|
currencyCode?: string;
|
|
255
271
|
useCurrencySymbol?: boolean;
|
|
@@ -283,3 +299,21 @@ export interface AccordionProps {
|
|
|
283
299
|
export interface PluginModuleComponentProps {
|
|
284
300
|
settings?: Record<string, any>;
|
|
285
301
|
}
|
|
302
|
+
|
|
303
|
+
export interface PaginationProps {
|
|
304
|
+
total: number | undefined;
|
|
305
|
+
limit?: number | undefined;
|
|
306
|
+
currentPage: number | undefined;
|
|
307
|
+
numberOfPages?: number | undefined;
|
|
308
|
+
containerClassName?: string;
|
|
309
|
+
moreButtonClassName?: string;
|
|
310
|
+
prevClassName?: string;
|
|
311
|
+
nextClassName?: string;
|
|
312
|
+
pageClassName?: string;
|
|
313
|
+
threshold?: number | undefined;
|
|
314
|
+
delta?: number | undefined;
|
|
315
|
+
render?: (pagination: UsePaginationType) => ReactNode;
|
|
316
|
+
type?: 'infinite' | 'list' | 'more';
|
|
317
|
+
onPageChange?: (page: number) => void;
|
|
318
|
+
direction?: 'next' | 'prev';
|
|
319
|
+
}
|