@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/plugins.d.ts
CHANGED
|
@@ -21,10 +21,4 @@ declare module '@akinon/pz-otp' {
|
|
|
21
21
|
|
|
22
22
|
declare module '@akinon/pz-otp/src/redux/reducer' {
|
|
23
23
|
export const showPopup: any;
|
|
24
|
-
export const hidePopup: any;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
declare module '@akinon/pz-saved-card' {
|
|
28
|
-
export const savedCardReducer: any;
|
|
29
|
-
export const SavedCardOption: any;
|
|
30
24
|
}
|
package/plugins.js
CHANGED
|
@@ -3,12 +3,9 @@
|
|
|
3
3
|
import { Middleware } from '@reduxjs/toolkit';
|
|
4
4
|
import {
|
|
5
5
|
setAddressList,
|
|
6
|
-
setAttributeBasedShippingOptions,
|
|
7
6
|
setBankAccounts,
|
|
8
7
|
setCanGuestPurchase,
|
|
9
8
|
setCardType,
|
|
10
|
-
setCreditPaymentOptions,
|
|
11
|
-
setDataSourceShippingOptions,
|
|
12
9
|
setDeliveryOptions,
|
|
13
10
|
setErrors,
|
|
14
11
|
setHasGiftBox,
|
|
@@ -19,16 +16,16 @@ import {
|
|
|
19
16
|
setPreOrder,
|
|
20
17
|
setRetailStores,
|
|
21
18
|
setShippingOptions,
|
|
22
|
-
setShippingStepCompleted
|
|
19
|
+
setShippingStepCompleted,
|
|
20
|
+
setCreditPaymentOptions
|
|
23
21
|
} from '../../redux/reducers/checkout';
|
|
24
22
|
import { RootState, TypedDispatch } from 'redux/store';
|
|
25
23
|
import { checkoutApi } from '../../data/client/checkout';
|
|
26
24
|
import { CheckoutContext, PreOrder } from '../../types';
|
|
27
|
-
import { getCookie } from '../../utils';
|
|
25
|
+
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
|
|
|
@@ -112,8 +107,7 @@ export const preOrderMiddleware: Middleware = ({
|
|
|
112
107
|
if (
|
|
113
108
|
(!preOrder.shipping_address || !preOrder.billing_address) &&
|
|
114
109
|
addresses.length > 0 &&
|
|
115
|
-
|
|
116
|
-
preOrder.delivery_option.delivery_option_type === 'customer')
|
|
110
|
+
preOrder.delivery_option?.delivery_option_type === 'customer'
|
|
117
111
|
) {
|
|
118
112
|
dispatch(
|
|
119
113
|
apiEndpoints.setAddresses.initiate({
|
|
@@ -131,49 +125,11 @@ export const preOrderMiddleware: Middleware = ({
|
|
|
131
125
|
dispatch(apiEndpoints.setShippingOption.initiate(shippingOptions[0].pk));
|
|
132
126
|
}
|
|
133
127
|
|
|
134
|
-
if (
|
|
135
|
-
dataSourceShippingOptions.length > 0 &&
|
|
136
|
-
!preOrder.data_source_shipping_options
|
|
137
|
-
) {
|
|
138
|
-
const selectedDataSourceShippingOptionsPks =
|
|
139
|
-
dataSourceShippingOptions.map(
|
|
140
|
-
(opt) => opt.data_source_shipping_options[0].pk
|
|
141
|
-
);
|
|
142
|
-
|
|
143
|
-
dispatch(
|
|
144
|
-
apiEndpoints.setDataSourceShippingOptions.initiate(
|
|
145
|
-
selectedDataSourceShippingOptionsPks
|
|
146
|
-
)
|
|
147
|
-
);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
if (
|
|
151
|
-
Object.keys(attributeBasedShippingOptions).length > 0 &&
|
|
152
|
-
!preOrder.attribute_based_shipping_options
|
|
153
|
-
) {
|
|
154
|
-
const initialSelectedOptions: Record<string, number> = Object.fromEntries(
|
|
155
|
-
Object.entries(attributeBasedShippingOptions).map(([key, options]) => [
|
|
156
|
-
key,
|
|
157
|
-
options[0].pk
|
|
158
|
-
])
|
|
159
|
-
);
|
|
160
|
-
|
|
161
|
-
dispatch(
|
|
162
|
-
apiEndpoints.setAttributeBasedShippingOptions.initiate(
|
|
163
|
-
initialSelectedOptions
|
|
164
|
-
)
|
|
165
|
-
);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
128
|
if (!preOrder.payment_option && paymentOptions.length > 0) {
|
|
169
129
|
dispatch(apiEndpoints.setPaymentOption.initiate(paymentOptions[0].pk));
|
|
170
130
|
}
|
|
171
131
|
|
|
172
|
-
if (
|
|
173
|
-
!preOrder.installment &&
|
|
174
|
-
preOrder.payment_option.payment_type !== 'saved_card' &&
|
|
175
|
-
installmentOptions.length > 0
|
|
176
|
-
) {
|
|
132
|
+
if (!preOrder.installment && installmentOptions.length > 0) {
|
|
177
133
|
dispatch(
|
|
178
134
|
apiEndpoints.setInstallmentOption.initiate(installmentOptions[0].pk)
|
|
179
135
|
);
|
|
@@ -207,7 +163,6 @@ export const contextListMiddleware: Middleware = ({
|
|
|
207
163
|
if (result?.payload?.context_list) {
|
|
208
164
|
result.payload.context_list.forEach((context) => {
|
|
209
165
|
const redirectUrl = context.page_context.redirect_url;
|
|
210
|
-
const isIframe = context.page_context.is_frame ?? false;
|
|
211
166
|
|
|
212
167
|
if (redirectUrl) {
|
|
213
168
|
const currentLocale = getCookie('pz-locale');
|
|
@@ -226,19 +181,16 @@ export const contextListMiddleware: Middleware = ({
|
|
|
226
181
|
}
|
|
227
182
|
|
|
228
183
|
const urlObj = new URL(url, window.location.origin);
|
|
229
|
-
const isMobileDevice =
|
|
230
|
-
isMobileApp ||
|
|
231
|
-
/iPad|iPhone|iPod|Android/i.test(navigator.userAgent);
|
|
232
|
-
const isIframePaymentOptionExcluded =
|
|
233
|
-
!settings.checkout?.iframeExcludedPaymentOptions?.includes(
|
|
234
|
-
result.payload?.pre_order?.payment_option?.slug
|
|
235
|
-
);
|
|
236
184
|
urlObj.searchParams.set('t', new Date().getTime().toString());
|
|
237
185
|
|
|
238
|
-
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
|
+
) {
|
|
239
193
|
showMobile3dIframe(urlObj.toString());
|
|
240
|
-
} else if (isIframe && !isIframePaymentOptionExcluded) {
|
|
241
|
-
showRedirectionIframe(urlObj.toString());
|
|
242
194
|
} else {
|
|
243
195
|
window.location.href = urlObj.toString();
|
|
244
196
|
}
|
|
@@ -268,28 +220,12 @@ export const contextListMiddleware: Middleware = ({
|
|
|
268
220
|
dispatch(setShippingOptions(context.page_context.shipping_options));
|
|
269
221
|
}
|
|
270
222
|
|
|
271
|
-
if (context.page_context.data_sources) {
|
|
272
|
-
dispatch(
|
|
273
|
-
setDataSourceShippingOptions(context.page_context.data_sources)
|
|
274
|
-
);
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
if (context.page_context.attribute_based_shipping_options) {
|
|
278
|
-
dispatch(
|
|
279
|
-
setAttributeBasedShippingOptions(
|
|
280
|
-
context.page_context.attribute_based_shipping_options
|
|
281
|
-
)
|
|
282
|
-
);
|
|
283
|
-
}
|
|
284
|
-
|
|
285
223
|
if (context.page_context.payment_options) {
|
|
286
224
|
dispatch(setPaymentOptions(context.page_context.payment_options));
|
|
287
225
|
}
|
|
288
226
|
|
|
289
227
|
if (context.page_context.credit_payment_options) {
|
|
290
|
-
dispatch(
|
|
291
|
-
setCreditPaymentOptions(context.page_context.credit_payment_options)
|
|
292
|
-
);
|
|
228
|
+
dispatch(setCreditPaymentOptions(context.page_context.credit_payment_options));
|
|
293
229
|
}
|
|
294
230
|
|
|
295
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/redux/reducers/index.ts
CHANGED
|
@@ -7,7 +7,6 @@ import { api } from '../../data/client/api';
|
|
|
7
7
|
// Plugin reducers
|
|
8
8
|
import { masterpassReducer } from '@akinon/pz-masterpass';
|
|
9
9
|
import { otpReducer } from '@akinon/pz-otp';
|
|
10
|
-
import { savedCardReducer } from '@akinon/pz-saved-card';
|
|
11
10
|
|
|
12
11
|
const reducers = {
|
|
13
12
|
[api.reducerPath]: api.reducer,
|
|
@@ -16,8 +15,7 @@ const reducers = {
|
|
|
16
15
|
config: configReducer,
|
|
17
16
|
header: headerReducer,
|
|
18
17
|
masterpass: masterpassReducer,
|
|
19
|
-
otp: otpReducer
|
|
20
|
-
savedCard: savedCardReducer
|
|
18
|
+
otp: otpReducer
|
|
21
19
|
};
|
|
22
20
|
|
|
23
21
|
export default reducers;
|
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
|
extra_field?: ExtraField;
|
|
@@ -142,7 +123,6 @@ export interface CheckoutContext {
|
|
|
142
123
|
redirect_url?: string;
|
|
143
124
|
context_data?: any;
|
|
144
125
|
balance?: string;
|
|
145
|
-
attribute_based_shipping_options?: AttributeBasedShippingOption[];
|
|
146
126
|
[key: string]: any;
|
|
147
127
|
};
|
|
148
128
|
}
|
|
@@ -168,13 +148,3 @@ export interface BankAccount {
|
|
|
168
148
|
pk: number;
|
|
169
149
|
sort_order: number;
|
|
170
150
|
}
|
|
171
|
-
|
|
172
|
-
export interface AttributeBasedShippingOption {
|
|
173
|
-
pk: number;
|
|
174
|
-
shipping_amount: string | null;
|
|
175
|
-
shipping_option_name: string | null;
|
|
176
|
-
shipping_option_logo: string | null;
|
|
177
|
-
attribute_value: string | null;
|
|
178
|
-
attribute_key: string;
|
|
179
|
-
[key: string]: any;
|
|
180
|
-
}
|
package/types/commerce/order.ts
CHANGED
package/types/index.ts
CHANGED
|
@@ -68,17 +68,9 @@ 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;
|
|
78
71
|
}
|
|
79
72
|
|
|
80
73
|
export interface Settings {
|
|
81
|
-
usePrettyUrlRoute?: boolean;
|
|
82
74
|
commerceUrl: string;
|
|
83
75
|
redis: {
|
|
84
76
|
defaultExpirationTime: number;
|
|
@@ -191,7 +183,6 @@ export interface Settings {
|
|
|
191
183
|
masterpassJsUrl?: string;
|
|
192
184
|
};
|
|
193
185
|
customNotFoundEnabled: boolean;
|
|
194
|
-
useOptimizedTranslations?: boolean;
|
|
195
186
|
plugins?: Record<string, Record<string, any>>;
|
|
196
187
|
includedProxyHeaders?: string[];
|
|
197
188
|
}
|
|
@@ -225,7 +216,7 @@ export type ImageOptions = CDNOptions & {
|
|
|
225
216
|
export type Translations = { [key: string]: object };
|
|
226
217
|
|
|
227
218
|
export interface PageProps<T = any> {
|
|
228
|
-
params: T
|
|
219
|
+
params: T;
|
|
229
220
|
searchParams: URLSearchParams;
|
|
230
221
|
}
|
|
231
222
|
|
|
@@ -234,11 +225,7 @@ export interface LayoutProps<T = any> extends PageProps<T> {
|
|
|
234
225
|
}
|
|
235
226
|
|
|
236
227
|
export interface RootLayoutProps<
|
|
237
|
-
T = {
|
|
238
|
-
commerce: string;
|
|
239
|
-
locale: string;
|
|
240
|
-
currency: string;
|
|
241
|
-
}
|
|
228
|
+
T = { commerce: string; locale: string; currency: string }
|
|
242
229
|
> extends LayoutProps<T> {
|
|
243
230
|
translations: Translations;
|
|
244
231
|
locale: Locale & {
|
|
@@ -264,8 +251,6 @@ export interface ButtonProps
|
|
|
264
251
|
appearance?: 'filled' | 'outlined' | 'ghost';
|
|
265
252
|
}
|
|
266
253
|
|
|
267
|
-
export type FileInputProps = React.HTMLProps<HTMLInputElement>;
|
|
268
|
-
|
|
269
254
|
export interface PriceProps {
|
|
270
255
|
currencyCode?: string;
|
|
271
256
|
useCurrencySymbol?: boolean;
|
package/utils/app-fetch.ts
CHANGED
|
@@ -1,26 +1,18 @@
|
|
|
1
1
|
import Settings from 'settings';
|
|
2
|
+
import { ServerVariables } from './server-variables';
|
|
2
3
|
import logger from '../utils/log';
|
|
3
4
|
import { headers, cookies } from 'next/headers';
|
|
4
|
-
import { ServerVariables } from './server-variables';
|
|
5
5
|
|
|
6
6
|
export enum FetchResponseType {
|
|
7
7
|
JSON = 'json',
|
|
8
8
|
TEXT = 'text'
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
const appFetch = async <T>(
|
|
12
|
-
url,
|
|
13
|
-
|
|
14
|
-
currency,
|
|
15
|
-
init = {},
|
|
11
|
+
const appFetch = async <T>(
|
|
12
|
+
url: RequestInfo,
|
|
13
|
+
init: RequestInit = {},
|
|
16
14
|
responseType = FetchResponseType.JSON
|
|
17
|
-
|
|
18
|
-
url: RequestInfo;
|
|
19
|
-
locale: string;
|
|
20
|
-
currency: string;
|
|
21
|
-
init?: RequestInit;
|
|
22
|
-
responseType?: FetchResponseType;
|
|
23
|
-
}): Promise<T> => {
|
|
15
|
+
): Promise<T> => {
|
|
24
16
|
let response: T;
|
|
25
17
|
let status: number;
|
|
26
18
|
let ip = '';
|
|
@@ -32,7 +24,7 @@ const appFetch = async <T>({
|
|
|
32
24
|
|
|
33
25
|
const commerceUrl = Settings.commerceUrl;
|
|
34
26
|
const currentLocale = Settings.localization.locales.find(
|
|
35
|
-
(
|
|
27
|
+
(locale) => locale.value === ServerVariables.locale
|
|
36
28
|
);
|
|
37
29
|
|
|
38
30
|
if (commerceUrl === 'default') {
|
|
@@ -46,13 +38,13 @@ const appFetch = async <T>({
|
|
|
46
38
|
...(init.headers ?? {}),
|
|
47
39
|
...(ServerVariables.globalHeaders ?? {}),
|
|
48
40
|
'Accept-Language': currentLocale.apiValue,
|
|
49
|
-
'x-currency': currency,
|
|
41
|
+
'x-currency': ServerVariables.currency,
|
|
50
42
|
'x-forwarded-for': ip,
|
|
51
43
|
cookie: nextCookies.toString()
|
|
52
44
|
};
|
|
53
45
|
|
|
54
46
|
init.next = {
|
|
55
|
-
revalidate:
|
|
47
|
+
revalidate: 60
|
|
56
48
|
};
|
|
57
49
|
|
|
58
50
|
logger.debug(`FETCH START ${url}`, { requestURL, init, ip });
|
package/utils/index.ts
CHANGED
|
@@ -63,33 +63,18 @@ export function getTranslateFn(path: string, translations: any) {
|
|
|
63
63
|
|
|
64
64
|
export function buildClientRequestUrl(
|
|
65
65
|
path: string,
|
|
66
|
-
options?: ClientRequestOptions
|
|
66
|
+
options?: ClientRequestOptions
|
|
67
67
|
) {
|
|
68
68
|
let url = `/api/client${path}`;
|
|
69
69
|
|
|
70
|
-
let hasQuery = url.includes('?');
|
|
71
|
-
|
|
72
70
|
if (options) {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
url += '&';
|
|
78
|
-
} else {
|
|
79
|
-
url += '?';
|
|
80
|
-
hasQuery = true;
|
|
81
|
-
}
|
|
82
|
-
url += `options=${encodeURIComponent(JSON.stringify(otherOptions))}`;
|
|
71
|
+
if (url.includes('?')) {
|
|
72
|
+
url += '&';
|
|
73
|
+
} else {
|
|
74
|
+
url += '?';
|
|
83
75
|
}
|
|
84
76
|
|
|
85
|
-
|
|
86
|
-
if (hasQuery) {
|
|
87
|
-
url += '&';
|
|
88
|
-
} else {
|
|
89
|
-
url += '?';
|
|
90
|
-
}
|
|
91
|
-
url += `t=${Date.now()}`;
|
|
92
|
-
}
|
|
77
|
+
url += `options=${encodeURIComponent(JSON.stringify(options))}`;
|
|
93
78
|
}
|
|
94
79
|
|
|
95
80
|
return url;
|
|
@@ -117,12 +102,6 @@ export function buildCDNUrl(url: string, config?: CDNOptions) {
|
|
|
117
102
|
''
|
|
118
103
|
);
|
|
119
104
|
|
|
120
|
-
const noOptionFileExtension = url?.split('.').pop()?.toLowerCase() ?? '';
|
|
121
|
-
|
|
122
|
-
if (noOptionFileExtension === 'svg' || noOptionFileExtension === 'gif') {
|
|
123
|
-
return url;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
105
|
let options = '';
|
|
127
106
|
|
|
128
107
|
if (config) {
|
|
@@ -8,6 +8,7 @@ import logger from './log';
|
|
|
8
8
|
|
|
9
9
|
export const translations: Translations = {};
|
|
10
10
|
|
|
11
|
+
// TODO: Read translations from cache
|
|
11
12
|
export async function getTranslations(locale_: string) {
|
|
12
13
|
try {
|
|
13
14
|
const locale = settings.localization.locales.find(
|
|
@@ -54,14 +55,3 @@ export async function getTranslations(locale_: string) {
|
|
|
54
55
|
export function t(path: string) {
|
|
55
56
|
return getTranslateFn(path, translations);
|
|
56
57
|
}
|
|
57
|
-
|
|
58
|
-
export async function t_(path: string, locale?: string) {
|
|
59
|
-
let translations_ = translations;
|
|
60
|
-
|
|
61
|
-
if (settings.useOptimizedTranslations && locale) {
|
|
62
|
-
const { getTranslations } = require('translations');
|
|
63
|
-
translations_ = await getTranslations(locale);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return getTranslateFn(path, translations_);
|
|
67
|
-
}
|
package/with-pz-config.js
CHANGED
|
@@ -8,7 +8,6 @@ const defaultConfig = {
|
|
|
8
8
|
transpilePackages: ['@akinon/next', ...pzPlugins.map((p) => `@akinon/${p}`)],
|
|
9
9
|
skipTrailingSlashRedirect: true,
|
|
10
10
|
poweredByHeader: false,
|
|
11
|
-
cacheMaxMemorySize: 0,
|
|
12
11
|
env: {
|
|
13
12
|
NEXT_PUBLIC_SENTRY_DSN: process.env.SENTRY_DSN
|
|
14
13
|
},
|
|
@@ -57,8 +56,7 @@ const defaultConfig = {
|
|
|
57
56
|
...pzPlugins.reduce((acc, plugin) => {
|
|
58
57
|
acc[`@akinon/${plugin}`] = false;
|
|
59
58
|
return acc;
|
|
60
|
-
}, {})
|
|
61
|
-
translations: false
|
|
59
|
+
}, {})
|
|
62
60
|
};
|
|
63
61
|
return config;
|
|
64
62
|
},
|
|
@@ -67,12 +65,7 @@ const defaultConfig = {
|
|
|
67
65
|
}
|
|
68
66
|
};
|
|
69
67
|
|
|
70
|
-
const withPzConfig = (
|
|
71
|
-
myNextConfig = {},
|
|
72
|
-
options = {
|
|
73
|
-
useCacheHandler: false
|
|
74
|
-
}
|
|
75
|
-
) => {
|
|
68
|
+
const withPzConfig = (myNextConfig = {}) => {
|
|
76
69
|
let extendedConfig = deepMerge({}, defaultConfig, myNextConfig);
|
|
77
70
|
|
|
78
71
|
const originalPzHeadersFunction = defaultConfig.headers;
|
|
@@ -98,10 +91,6 @@ const withPzConfig = (
|
|
|
98
91
|
return [...pzRewrites, ...myRewrites];
|
|
99
92
|
};
|
|
100
93
|
|
|
101
|
-
if (options.useCacheHandler && process.env.CACHE_HOST) {
|
|
102
|
-
extendedConfig.cacheHandler = require.resolve('./lib/cache-handler.mjs');
|
|
103
|
-
}
|
|
104
|
-
|
|
105
94
|
return extendedConfig;
|
|
106
95
|
};
|
|
107
96
|
|
package/assets/styles/index.css
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
.checkout-payment-iframe-wrapper {
|
|
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
|
-
}
|
|
11
|
-
.checkout-payment-iframe-wrapper iframe {
|
|
12
|
-
width: 100%;
|
|
13
|
-
height: 100%;
|
|
14
|
-
border: none;
|
|
15
|
-
background-color: white;
|
|
16
|
-
}
|
|
17
|
-
.checkout-payment-iframe-wrapper .close-button {
|
|
18
|
-
position: fixed;
|
|
19
|
-
top: 16px;
|
|
20
|
-
right: 16px;
|
|
21
|
-
width: 32px;
|
|
22
|
-
height: 32px;
|
|
23
|
-
display: flex;
|
|
24
|
-
align-items: center;
|
|
25
|
-
justify-content: center;
|
|
26
|
-
z-index: 1001;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
.checkout-payment-redirection-iframe-wrapper {
|
|
30
|
-
width: 100%;
|
|
31
|
-
position: relative;
|
|
32
|
-
}
|
|
33
|
-
.checkout-payment-redirection-iframe-wrapper iframe {
|
|
34
|
-
width: 100%;
|
|
35
|
-
height: 100%;
|
|
36
|
-
border: none;
|
|
37
|
-
background-color: white;
|
|
38
|
-
}
|
|
39
|
-
.checkout-payment-redirection-iframe-wrapper .close-button {
|
|
40
|
-
position: absolute;
|
|
41
|
-
top: 16px;
|
|
42
|
-
right: 16px;
|
|
43
|
-
width: 32px;
|
|
44
|
-
height: 32px;
|
|
45
|
-
display: flex;
|
|
46
|
-
align-items: center;
|
|
47
|
-
justify-content: center;
|
|
48
|
-
z-index: 1001;
|
|
49
|
-
}/*# sourceMappingURL=index.css.map */
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["index.scss","index.css"],"names":[],"mappings":"AAAA;EACE,eAAA;EACA,MAAA;EACA,OAAA;EACA,WAAA;EACA,YAAA;EACA,YAAA;EACA,aAAA;EACA,uBAAA;ACCF;ADCE;EACE,WAAA;EACA,YAAA;EACA,YAAA;EACA,uBAAA;ACCJ;ADEE;EACE,eAAA;EACA,SAAA;EACA,WAAA;EACA,WAAA;EACA,YAAA;EACA,aAAA;EACA,mBAAA;EACA,uBAAA;EACA,aAAA;ACAJ;;ADIA;EACE,WAAA;EACA,kBAAA;ACDF;ADGE;EACE,WAAA;EACA,YAAA;EACA,YAAA;EACA,uBAAA;ACDJ;ADIE;EACE,kBAAA;EACA,SAAA;EACA,WAAA;EACA,WAAA;EACA,YAAA;EACA,aAAA;EACA,mBAAA;EACA,uBAAA;EACA,aAAA;ACFJ","file":"index.css"}
|