@akinon/next 1.14.0 → 1.14.1
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/.eslintrc.js +40 -40
- package/.prettierrc +13 -13
- package/CHANGELOG.md +6 -0
- package/api/auth.ts +231 -231
- package/api/cache.ts +44 -44
- package/api/client.ts +174 -174
- package/api/logout.ts +42 -42
- package/bin/pz-check-dependencies.js +98 -98
- package/bin/pz-install-plugins.js +33 -33
- package/bin/pz-install-theme.js +58 -58
- package/bin/pz-postbuild.js +1 -1
- package/bin/pz-postdev.js +1 -1
- package/bin/pz-postinstall.js +6 -6
- package/bin/pz-poststart.js +1 -1
- package/bin/pz-prebuild.js +4 -4
- package/bin/pz-predev.js +4 -4
- package/bin/pz-prestart.js +1 -1
- package/bin/run-script.js +44 -44
- package/components/accordion.tsx +52 -52
- package/components/button.tsx +46 -46
- package/components/client-root.tsx +19 -19
- package/components/icon.tsx +18 -18
- package/components/image.tsx +133 -133
- package/components/index.ts +17 -17
- package/components/input.tsx +110 -110
- package/components/lazy-component.tsx +33 -33
- package/components/loader-spinner.tsx +23 -23
- package/components/mobile-app-toggler.tsx +26 -26
- package/components/oauth-login.tsx +24 -24
- package/components/price.tsx +55 -55
- package/components/pz-providers.tsx +24 -24
- package/components/pz-root.tsx +21 -21
- package/components/radio.tsx +18 -18
- package/components/react-portal.tsx +45 -45
- package/components/redirect-three-d/content/index.tsx +74 -74
- package/components/redirect-three-d/index.tsx +17 -17
- package/components/trans.tsx +39 -39
- package/data/client/account.ts +208 -208
- package/data/client/api.ts +85 -85
- package/data/client/basket.ts +82 -82
- package/data/client/misc.ts +101 -101
- package/data/client/product.ts +89 -89
- package/data/client/user.ts +99 -99
- package/data/client/wishlist.ts +118 -118
- package/data/server/category.ts +132 -132
- package/data/server/flatpage.ts +21 -21
- package/data/server/form.ts +22 -22
- package/data/server/index.ts +10 -10
- package/data/server/landingpage.ts +24 -24
- package/data/server/list.ts +67 -67
- package/data/server/menu.ts +35 -35
- package/data/server/product.ts +86 -86
- package/data/server/seo.ts +48 -48
- package/data/server/special-page.ts +47 -47
- package/data/server/widget.ts +27 -27
- package/data/urls.ts +221 -221
- package/hocs/client/index.ts +1 -1
- package/hocs/client/with-segment-defaults.tsx +25 -25
- package/hocs/server/index.ts +1 -1
- package/hocs/server/with-segment-defaults.tsx +85 -85
- package/hooks/index.ts +10 -10
- package/hooks/use-captcha.tsx +76 -76
- package/hooks/use-common-product-attributes.ts +36 -36
- package/hooks/use-debounce.ts +20 -20
- package/hooks/use-localization.ts +78 -78
- package/hooks/use-media-query.ts +36 -36
- package/hooks/use-mobile-iframe-handler.ts +23 -23
- package/hooks/use-on-click-outside.tsx +28 -28
- package/hooks/use-router.ts +45 -45
- package/hooks/use-translation.ts +14 -14
- package/lib/cache.ts +215 -215
- package/localization/index.ts +5 -5
- package/localization/provider.tsx +58 -58
- package/middlewares/currency.ts +100 -100
- package/middlewares/default.ts +256 -256
- package/middlewares/index.ts +29 -29
- package/middlewares/locale.ts +68 -68
- package/middlewares/oauth-login.ts +79 -79
- package/middlewares/pretty-url.ts +104 -104
- package/middlewares/redirection-payment.ts +160 -160
- package/middlewares/three-d-redirection.ts +159 -159
- package/middlewares/url-redirection.ts +65 -65
- package/package.json +2 -2
- package/redux/hooks.ts +7 -7
- package/redux/middlewares/index.ts +50 -50
- package/redux/reducers/checkout.ts +184 -184
- package/redux/reducers/config.ts +28 -28
- package/redux/reducers/header.ts +59 -59
- package/redux/reducers/root.ts +61 -61
- package/sentry/index.ts +27 -27
- package/tailwind/rtl.js +137 -137
- package/types/commerce/account.ts +64 -64
- package/types/commerce/address.ts +94 -94
- package/types/commerce/basket.ts +43 -43
- package/types/commerce/category.ts +114 -114
- package/types/commerce/checkout.ts +143 -143
- package/types/commerce/flatpage.ts +7 -7
- package/types/commerce/form.ts +66 -66
- package/types/commerce/index.ts +12 -12
- package/types/commerce/landingpage.ts +7 -7
- package/types/commerce/misc.ts +127 -127
- package/types/commerce/order.ts +119 -119
- package/types/commerce/product.ts +109 -109
- package/types/commerce/widget.ts +28 -28
- package/types/gtm.ts +16 -16
- package/types/index.ts +274 -274
- package/types/metadata.ts +7 -7
- package/types/next-auth.d.ts +24 -24
- package/utils/app-fetch.ts +69 -69
- package/utils/deep-merge.js +24 -24
- package/utils/image-loader.ts +31 -31
- package/utils/index.ts +150 -150
- package/utils/localization.ts +29 -29
- package/utils/log.ts +138 -138
- package/utils/menu-generator.ts +27 -27
- package/utils/mobile-3d-iframe.ts +77 -77
- package/utils/server-translation.ts +57 -57
- package/utils/server-variables.ts +9 -9
- package/with-pz-config.js +94 -94
package/types/index.ts
CHANGED
|
@@ -1,274 +1,274 @@
|
|
|
1
|
-
import { LocaleUrlStrategy } from '../localization';
|
|
2
|
-
import { PzNextRequest } from '../middlewares';
|
|
3
|
-
import { Control, FieldError } from 'react-hook-form';
|
|
4
|
-
import { ReactNode } from 'react';
|
|
5
|
-
|
|
6
|
-
declare global {
|
|
7
|
-
export interface Window {
|
|
8
|
-
dataLayer: Record<string, any>[];
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export * from './commerce';
|
|
13
|
-
export * from './gtm';
|
|
14
|
-
export * from './metadata';
|
|
15
|
-
|
|
16
|
-
export interface Locale {
|
|
17
|
-
label: string;
|
|
18
|
-
/**
|
|
19
|
-
* Lowercased locale value in `ISO 639-1` format or including country code in `ISO 3166-1 alpha-2` format.
|
|
20
|
-
*
|
|
21
|
-
* -- If you use uppercase characters, it will be considered as lowercase.
|
|
22
|
-
*
|
|
23
|
-
* ***
|
|
24
|
-
* @example
|
|
25
|
-
* value: 'en'
|
|
26
|
-
* value: 'en-us'
|
|
27
|
-
* value: 'tr'
|
|
28
|
-
*
|
|
29
|
-
* @see https://en.wikipedia.org/wiki/ISO_639-1
|
|
30
|
-
* @see https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
|
|
31
|
-
*/
|
|
32
|
-
value: string;
|
|
33
|
-
localePath?: string;
|
|
34
|
-
/**
|
|
35
|
-
* Corresponding Commerce API value for fetching data. It will be used in `Accept-Language` header.
|
|
36
|
-
*/
|
|
37
|
-
apiValue: string;
|
|
38
|
-
rtl?: boolean;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export interface Currency {
|
|
42
|
-
/**
|
|
43
|
-
* It will be used for displaying currency in currency switcher.
|
|
44
|
-
* Can be symbol, code, etc.
|
|
45
|
-
*
|
|
46
|
-
* @example
|
|
47
|
-
* label: '$'
|
|
48
|
-
* label: '€'
|
|
49
|
-
* label: 'USD'
|
|
50
|
-
* label: 'US Dollar'
|
|
51
|
-
* label: '$ - USD'
|
|
52
|
-
*/
|
|
53
|
-
label: string;
|
|
54
|
-
/**
|
|
55
|
-
* Lowercased currency code in `ISO 4217` format.
|
|
56
|
-
*
|
|
57
|
-
* It should match with one of the values returned from Commerce API.
|
|
58
|
-
*
|
|
59
|
-
* @example
|
|
60
|
-
* code: 'usd'
|
|
61
|
-
* code: 'eur'
|
|
62
|
-
* code: 'try'
|
|
63
|
-
*
|
|
64
|
-
* @see https://en.wikipedia.org/wiki/ISO_4217
|
|
65
|
-
*/
|
|
66
|
-
code: string;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export interface Settings {
|
|
70
|
-
commerceUrl: string;
|
|
71
|
-
redis: {
|
|
72
|
-
defaultExpirationTime: number;
|
|
73
|
-
};
|
|
74
|
-
commonProductAttributes: Array<{
|
|
75
|
-
translationKey: string;
|
|
76
|
-
key: string;
|
|
77
|
-
}>;
|
|
78
|
-
localization: {
|
|
79
|
-
locales: Locale[];
|
|
80
|
-
currencies: Array<Currency>;
|
|
81
|
-
/**
|
|
82
|
-
* Default locale value in `ISO 639-1` format or including country code in `ISO 3166-1 alpha-2` format.
|
|
83
|
-
*
|
|
84
|
-
* It will be used for redirections and fallbacks.
|
|
85
|
-
*
|
|
86
|
-
* It should be one of the values in `locales` array.
|
|
87
|
-
*/
|
|
88
|
-
defaultLocaleValue: string;
|
|
89
|
-
/**
|
|
90
|
-
* Determines url behavior according to locale.
|
|
91
|
-
*
|
|
92
|
-
* Available options:
|
|
93
|
-
* - LocaleUrlStrategy.HideDefaultLocale
|
|
94
|
-
* - LocaleUrlStrategy.HideAllLocales
|
|
95
|
-
* - LocaleUrlStrategy.ShowAllLocales
|
|
96
|
-
*
|
|
97
|
-
* @default LocaleUrlStrategy.HideDefaultLocale
|
|
98
|
-
*
|
|
99
|
-
* @example
|
|
100
|
-
* // Example configuration
|
|
101
|
-
* locales: [{ value: 'en'}, { value: 'tr' }]
|
|
102
|
-
* defaultLocaleValue: 'en'
|
|
103
|
-
* // -------------------------------
|
|
104
|
-
*
|
|
105
|
-
* LocaleUrlStrategy.HideDefaultLocale:
|
|
106
|
-
* en -> "/women"
|
|
107
|
-
* tr -> "/tr/women"
|
|
108
|
-
*
|
|
109
|
-
* LocaleUrlStrategy.ShowAllLocales:
|
|
110
|
-
* en -> "/en/women"
|
|
111
|
-
* tr -> "/tr/women"
|
|
112
|
-
*
|
|
113
|
-
* LocaleUrlStrategy.HideAllLocales:
|
|
114
|
-
* en -> "/women"
|
|
115
|
-
* tr -> "/women"
|
|
116
|
-
*/
|
|
117
|
-
localeUrlStrategy?: LocaleUrlStrategy;
|
|
118
|
-
redirectToDefaultLocale?: boolean;
|
|
119
|
-
defaultCurrencyCode: string;
|
|
120
|
-
/**
|
|
121
|
-
* The default behavior of `getActiveCurrencyCode` function is to get active currency code from cookie named `pz-currency`.
|
|
122
|
-
*
|
|
123
|
-
* You can use this function to override existing and get currency code from cookie, header, url, etc.
|
|
124
|
-
*
|
|
125
|
-
* If return value does not match with any currency code in `currencies` array, default currency code will be used.
|
|
126
|
-
*
|
|
127
|
-
* @param req - Incoming request. You can use this to get cookie, header, url, etc.
|
|
128
|
-
* @param locale - Active locale value. E.g. 'en', 'tr', 'en-us', 'tr-tr'
|
|
129
|
-
* @param defaultCurrencyCode - Default currency code in `ISO 4217` format. E.g. 'usd', 'eur', 'try'
|
|
130
|
-
* @returns Currency code in `ISO 4217` format. E.g. 'usd', 'eur', 'try'
|
|
131
|
-
*
|
|
132
|
-
* @example
|
|
133
|
-
* getActiveCurrencyCode: ({ req, locale, defaultCurrencyCode }) => {
|
|
134
|
-
* const [, countryCode] = locale.split('-');
|
|
135
|
-
*
|
|
136
|
-
* if (countryCode === 'ae') {
|
|
137
|
-
* return 'aed';
|
|
138
|
-
* } else if (countryCode === 'qa') {
|
|
139
|
-
* return 'qar';
|
|
140
|
-
* }
|
|
141
|
-
*
|
|
142
|
-
* return defaultCurrencyCode;
|
|
143
|
-
* }
|
|
144
|
-
*/
|
|
145
|
-
getActiveCurrencyCode?: ({
|
|
146
|
-
req,
|
|
147
|
-
locale,
|
|
148
|
-
defaultCurrencyCode
|
|
149
|
-
}: {
|
|
150
|
-
req: PzNextRequest;
|
|
151
|
-
locale: string;
|
|
152
|
-
defaultCurrencyCode: string;
|
|
153
|
-
}) => string;
|
|
154
|
-
/**
|
|
155
|
-
* By default, pretty url resolver excludes locale from url.
|
|
156
|
-
* In some cases, you may want to create flatpages and include locale in urls.
|
|
157
|
-
* This is useful if you want to manage your flatpages for different countries by using locale value.
|
|
158
|
-
*
|
|
159
|
-
* @example
|
|
160
|
-
* // URL entered in Omnitron: /en-us/pages/about-us
|
|
161
|
-
* // Locale Strategy: LocaleUrlStrategy.ShowAllLocales
|
|
162
|
-
*
|
|
163
|
-
* // If you don't use this option, pretty url resolver will remove the locale and it will be resolved as '/pages/about-us' and you will get 404. Because there is no page with this url. But if you use this option, it will be resolved as '/en-us/pages/about-us' and you will get the page.
|
|
164
|
-
* // Following pattern will include locale for all urls including '/pages/'.
|
|
165
|
-
* localeIncludedPrettyUrlPattern: new RegExp('.+/pages/.+$')
|
|
166
|
-
*/
|
|
167
|
-
localeIncludedPrettyUrlPattern?: RegExp;
|
|
168
|
-
};
|
|
169
|
-
rewrites?: Array<{
|
|
170
|
-
source: string;
|
|
171
|
-
destination: string;
|
|
172
|
-
}>;
|
|
173
|
-
checkout?: {
|
|
174
|
-
/**
|
|
175
|
-
* If there is a need to exclude certain payment options from the iframe, for instance, due to CORS issues, this option can be utilized by passing the slugs associated with the desired payment options.
|
|
176
|
-
*/
|
|
177
|
-
iframeExcludedPaymentOptions?: string[];
|
|
178
|
-
extraPaymentTypes?: string[];
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
export interface CacheOptions {
|
|
183
|
-
cache?: boolean;
|
|
184
|
-
expire?: number;
|
|
185
|
-
useProxy?: boolean;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
export interface ClientRequestOptions {
|
|
189
|
-
useTrailingSlash?: boolean;
|
|
190
|
-
useFormData?: boolean;
|
|
191
|
-
accept?: string;
|
|
192
|
-
contentType?: string;
|
|
193
|
-
responseType?: 'json' | 'text';
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
export type CDNOptions = {
|
|
197
|
-
width?: number;
|
|
198
|
-
height?: number;
|
|
199
|
-
quality?: number;
|
|
200
|
-
crop?: 'center' | 'top' | 'bottom' | 'left' | 'right';
|
|
201
|
-
upscale?: boolean;
|
|
202
|
-
};
|
|
203
|
-
|
|
204
|
-
export type ImageOptions = CDNOptions & {
|
|
205
|
-
sources?: Array<{ media: string; options: CDNOptions }>;
|
|
206
|
-
};
|
|
207
|
-
|
|
208
|
-
export type Translations = { [key: string]: object };
|
|
209
|
-
|
|
210
|
-
export interface PageProps<T = any> {
|
|
211
|
-
params: T;
|
|
212
|
-
searchParams: URLSearchParams;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
export interface LayoutProps<T = any> extends PageProps<T> {
|
|
216
|
-
children: React.ReactNode;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
export interface RootLayoutProps<
|
|
220
|
-
T = { commerce: string; locale: string; currency: string }
|
|
221
|
-
> extends LayoutProps<T> {
|
|
222
|
-
translations: Translations;
|
|
223
|
-
locale: Locale & {
|
|
224
|
-
isoCode: string;
|
|
225
|
-
};
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
export type RadioProps = React.HTMLProps<HTMLInputElement>;
|
|
229
|
-
|
|
230
|
-
export interface AuthError {
|
|
231
|
-
type: string;
|
|
232
|
-
data?: any;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
export interface IconProps extends React.ComponentPropsWithRef<'i'> {
|
|
236
|
-
name: string;
|
|
237
|
-
size?: number;
|
|
238
|
-
className?: string;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
export interface ButtonProps
|
|
242
|
-
extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
243
|
-
appearance?: 'filled' | 'outlined' | 'ghost';
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
export interface PriceProps {
|
|
247
|
-
currencyCode?: string;
|
|
248
|
-
useCurrencySymbol?: boolean;
|
|
249
|
-
useCurrencyAfterPrice?: boolean;
|
|
250
|
-
useCurrencySpace?: boolean;
|
|
251
|
-
useNegative?: boolean;
|
|
252
|
-
useNegativeSpace?: boolean;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
export interface InputProps extends React.HTMLProps<HTMLInputElement> {
|
|
256
|
-
label?: string;
|
|
257
|
-
labelStyle?: 'default' | 'floating';
|
|
258
|
-
error?: FieldError | undefined;
|
|
259
|
-
control?: Control<any, any>;
|
|
260
|
-
required?: boolean;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
export interface AccordionProps {
|
|
264
|
-
isCollapse?: boolean;
|
|
265
|
-
title?: string;
|
|
266
|
-
subTitle?: string;
|
|
267
|
-
icons?: string[];
|
|
268
|
-
iconSize?: number;
|
|
269
|
-
iconColor?: string;
|
|
270
|
-
children?: ReactNode;
|
|
271
|
-
className?: string;
|
|
272
|
-
titleClassName?: string;
|
|
273
|
-
dataTestId?: string;
|
|
274
|
-
}
|
|
1
|
+
import { LocaleUrlStrategy } from '../localization';
|
|
2
|
+
import { PzNextRequest } from '../middlewares';
|
|
3
|
+
import { Control, FieldError } from 'react-hook-form';
|
|
4
|
+
import { ReactNode } from 'react';
|
|
5
|
+
|
|
6
|
+
declare global {
|
|
7
|
+
export interface Window {
|
|
8
|
+
dataLayer: Record<string, any>[];
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export * from './commerce';
|
|
13
|
+
export * from './gtm';
|
|
14
|
+
export * from './metadata';
|
|
15
|
+
|
|
16
|
+
export interface Locale {
|
|
17
|
+
label: string;
|
|
18
|
+
/**
|
|
19
|
+
* Lowercased locale value in `ISO 639-1` format or including country code in `ISO 3166-1 alpha-2` format.
|
|
20
|
+
*
|
|
21
|
+
* -- If you use uppercase characters, it will be considered as lowercase.
|
|
22
|
+
*
|
|
23
|
+
* ***
|
|
24
|
+
* @example
|
|
25
|
+
* value: 'en'
|
|
26
|
+
* value: 'en-us'
|
|
27
|
+
* value: 'tr'
|
|
28
|
+
*
|
|
29
|
+
* @see https://en.wikipedia.org/wiki/ISO_639-1
|
|
30
|
+
* @see https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
|
|
31
|
+
*/
|
|
32
|
+
value: string;
|
|
33
|
+
localePath?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Corresponding Commerce API value for fetching data. It will be used in `Accept-Language` header.
|
|
36
|
+
*/
|
|
37
|
+
apiValue: string;
|
|
38
|
+
rtl?: boolean;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface Currency {
|
|
42
|
+
/**
|
|
43
|
+
* It will be used for displaying currency in currency switcher.
|
|
44
|
+
* Can be symbol, code, etc.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* label: '$'
|
|
48
|
+
* label: '€'
|
|
49
|
+
* label: 'USD'
|
|
50
|
+
* label: 'US Dollar'
|
|
51
|
+
* label: '$ - USD'
|
|
52
|
+
*/
|
|
53
|
+
label: string;
|
|
54
|
+
/**
|
|
55
|
+
* Lowercased currency code in `ISO 4217` format.
|
|
56
|
+
*
|
|
57
|
+
* It should match with one of the values returned from Commerce API.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* code: 'usd'
|
|
61
|
+
* code: 'eur'
|
|
62
|
+
* code: 'try'
|
|
63
|
+
*
|
|
64
|
+
* @see https://en.wikipedia.org/wiki/ISO_4217
|
|
65
|
+
*/
|
|
66
|
+
code: string;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface Settings {
|
|
70
|
+
commerceUrl: string;
|
|
71
|
+
redis: {
|
|
72
|
+
defaultExpirationTime: number;
|
|
73
|
+
};
|
|
74
|
+
commonProductAttributes: Array<{
|
|
75
|
+
translationKey: string;
|
|
76
|
+
key: string;
|
|
77
|
+
}>;
|
|
78
|
+
localization: {
|
|
79
|
+
locales: Locale[];
|
|
80
|
+
currencies: Array<Currency>;
|
|
81
|
+
/**
|
|
82
|
+
* Default locale value in `ISO 639-1` format or including country code in `ISO 3166-1 alpha-2` format.
|
|
83
|
+
*
|
|
84
|
+
* It will be used for redirections and fallbacks.
|
|
85
|
+
*
|
|
86
|
+
* It should be one of the values in `locales` array.
|
|
87
|
+
*/
|
|
88
|
+
defaultLocaleValue: string;
|
|
89
|
+
/**
|
|
90
|
+
* Determines url behavior according to locale.
|
|
91
|
+
*
|
|
92
|
+
* Available options:
|
|
93
|
+
* - LocaleUrlStrategy.HideDefaultLocale
|
|
94
|
+
* - LocaleUrlStrategy.HideAllLocales
|
|
95
|
+
* - LocaleUrlStrategy.ShowAllLocales
|
|
96
|
+
*
|
|
97
|
+
* @default LocaleUrlStrategy.HideDefaultLocale
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* // Example configuration
|
|
101
|
+
* locales: [{ value: 'en'}, { value: 'tr' }]
|
|
102
|
+
* defaultLocaleValue: 'en'
|
|
103
|
+
* // -------------------------------
|
|
104
|
+
*
|
|
105
|
+
* LocaleUrlStrategy.HideDefaultLocale:
|
|
106
|
+
* en -> "/women"
|
|
107
|
+
* tr -> "/tr/women"
|
|
108
|
+
*
|
|
109
|
+
* LocaleUrlStrategy.ShowAllLocales:
|
|
110
|
+
* en -> "/en/women"
|
|
111
|
+
* tr -> "/tr/women"
|
|
112
|
+
*
|
|
113
|
+
* LocaleUrlStrategy.HideAllLocales:
|
|
114
|
+
* en -> "/women"
|
|
115
|
+
* tr -> "/women"
|
|
116
|
+
*/
|
|
117
|
+
localeUrlStrategy?: LocaleUrlStrategy;
|
|
118
|
+
redirectToDefaultLocale?: boolean;
|
|
119
|
+
defaultCurrencyCode: string;
|
|
120
|
+
/**
|
|
121
|
+
* The default behavior of `getActiveCurrencyCode` function is to get active currency code from cookie named `pz-currency`.
|
|
122
|
+
*
|
|
123
|
+
* You can use this function to override existing and get currency code from cookie, header, url, etc.
|
|
124
|
+
*
|
|
125
|
+
* If return value does not match with any currency code in `currencies` array, default currency code will be used.
|
|
126
|
+
*
|
|
127
|
+
* @param req - Incoming request. You can use this to get cookie, header, url, etc.
|
|
128
|
+
* @param locale - Active locale value. E.g. 'en', 'tr', 'en-us', 'tr-tr'
|
|
129
|
+
* @param defaultCurrencyCode - Default currency code in `ISO 4217` format. E.g. 'usd', 'eur', 'try'
|
|
130
|
+
* @returns Currency code in `ISO 4217` format. E.g. 'usd', 'eur', 'try'
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* getActiveCurrencyCode: ({ req, locale, defaultCurrencyCode }) => {
|
|
134
|
+
* const [, countryCode] = locale.split('-');
|
|
135
|
+
*
|
|
136
|
+
* if (countryCode === 'ae') {
|
|
137
|
+
* return 'aed';
|
|
138
|
+
* } else if (countryCode === 'qa') {
|
|
139
|
+
* return 'qar';
|
|
140
|
+
* }
|
|
141
|
+
*
|
|
142
|
+
* return defaultCurrencyCode;
|
|
143
|
+
* }
|
|
144
|
+
*/
|
|
145
|
+
getActiveCurrencyCode?: ({
|
|
146
|
+
req,
|
|
147
|
+
locale,
|
|
148
|
+
defaultCurrencyCode
|
|
149
|
+
}: {
|
|
150
|
+
req: PzNextRequest;
|
|
151
|
+
locale: string;
|
|
152
|
+
defaultCurrencyCode: string;
|
|
153
|
+
}) => string;
|
|
154
|
+
/**
|
|
155
|
+
* By default, pretty url resolver excludes locale from url.
|
|
156
|
+
* In some cases, you may want to create flatpages and include locale in urls.
|
|
157
|
+
* This is useful if you want to manage your flatpages for different countries by using locale value.
|
|
158
|
+
*
|
|
159
|
+
* @example
|
|
160
|
+
* // URL entered in Omnitron: /en-us/pages/about-us
|
|
161
|
+
* // Locale Strategy: LocaleUrlStrategy.ShowAllLocales
|
|
162
|
+
*
|
|
163
|
+
* // If you don't use this option, pretty url resolver will remove the locale and it will be resolved as '/pages/about-us' and you will get 404. Because there is no page with this url. But if you use this option, it will be resolved as '/en-us/pages/about-us' and you will get the page.
|
|
164
|
+
* // Following pattern will include locale for all urls including '/pages/'.
|
|
165
|
+
* localeIncludedPrettyUrlPattern: new RegExp('.+/pages/.+$')
|
|
166
|
+
*/
|
|
167
|
+
localeIncludedPrettyUrlPattern?: RegExp;
|
|
168
|
+
};
|
|
169
|
+
rewrites?: Array<{
|
|
170
|
+
source: string;
|
|
171
|
+
destination: string;
|
|
172
|
+
}>;
|
|
173
|
+
checkout?: {
|
|
174
|
+
/**
|
|
175
|
+
* If there is a need to exclude certain payment options from the iframe, for instance, due to CORS issues, this option can be utilized by passing the slugs associated with the desired payment options.
|
|
176
|
+
*/
|
|
177
|
+
iframeExcludedPaymentOptions?: string[];
|
|
178
|
+
extraPaymentTypes?: string[];
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export interface CacheOptions {
|
|
183
|
+
cache?: boolean;
|
|
184
|
+
expire?: number;
|
|
185
|
+
useProxy?: boolean;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export interface ClientRequestOptions {
|
|
189
|
+
useTrailingSlash?: boolean;
|
|
190
|
+
useFormData?: boolean;
|
|
191
|
+
accept?: string;
|
|
192
|
+
contentType?: string;
|
|
193
|
+
responseType?: 'json' | 'text';
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export type CDNOptions = {
|
|
197
|
+
width?: number;
|
|
198
|
+
height?: number;
|
|
199
|
+
quality?: number;
|
|
200
|
+
crop?: 'center' | 'top' | 'bottom' | 'left' | 'right';
|
|
201
|
+
upscale?: boolean;
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
export type ImageOptions = CDNOptions & {
|
|
205
|
+
sources?: Array<{ media: string; options: CDNOptions }>;
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
export type Translations = { [key: string]: object };
|
|
209
|
+
|
|
210
|
+
export interface PageProps<T = any> {
|
|
211
|
+
params: T;
|
|
212
|
+
searchParams: URLSearchParams;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
export interface LayoutProps<T = any> extends PageProps<T> {
|
|
216
|
+
children: React.ReactNode;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export interface RootLayoutProps<
|
|
220
|
+
T = { commerce: string; locale: string; currency: string }
|
|
221
|
+
> extends LayoutProps<T> {
|
|
222
|
+
translations: Translations;
|
|
223
|
+
locale: Locale & {
|
|
224
|
+
isoCode: string;
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export type RadioProps = React.HTMLProps<HTMLInputElement>;
|
|
229
|
+
|
|
230
|
+
export interface AuthError {
|
|
231
|
+
type: string;
|
|
232
|
+
data?: any;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
export interface IconProps extends React.ComponentPropsWithRef<'i'> {
|
|
236
|
+
name: string;
|
|
237
|
+
size?: number;
|
|
238
|
+
className?: string;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export interface ButtonProps
|
|
242
|
+
extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
243
|
+
appearance?: 'filled' | 'outlined' | 'ghost';
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
export interface PriceProps {
|
|
247
|
+
currencyCode?: string;
|
|
248
|
+
useCurrencySymbol?: boolean;
|
|
249
|
+
useCurrencyAfterPrice?: boolean;
|
|
250
|
+
useCurrencySpace?: boolean;
|
|
251
|
+
useNegative?: boolean;
|
|
252
|
+
useNegativeSpace?: boolean;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
export interface InputProps extends React.HTMLProps<HTMLInputElement> {
|
|
256
|
+
label?: string;
|
|
257
|
+
labelStyle?: 'default' | 'floating';
|
|
258
|
+
error?: FieldError | undefined;
|
|
259
|
+
control?: Control<any, any>;
|
|
260
|
+
required?: boolean;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
export interface AccordionProps {
|
|
264
|
+
isCollapse?: boolean;
|
|
265
|
+
title?: string;
|
|
266
|
+
subTitle?: string;
|
|
267
|
+
icons?: string[];
|
|
268
|
+
iconSize?: number;
|
|
269
|
+
iconColor?: string;
|
|
270
|
+
children?: ReactNode;
|
|
271
|
+
className?: string;
|
|
272
|
+
titleClassName?: string;
|
|
273
|
+
dataTestId?: string;
|
|
274
|
+
}
|
package/types/metadata.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Metadata as NextMetaData } from 'next';
|
|
2
|
-
|
|
3
|
-
export interface Metadata extends NextMetaData {
|
|
4
|
-
alternates?: NextMetaData['alternates'] & {
|
|
5
|
-
languages?: Record<string, string>;
|
|
6
|
-
};
|
|
7
|
-
}
|
|
1
|
+
import { Metadata as NextMetaData } from 'next';
|
|
2
|
+
|
|
3
|
+
export interface Metadata extends NextMetaData {
|
|
4
|
+
alternates?: NextMetaData['alternates'] & {
|
|
5
|
+
languages?: Record<string, string>;
|
|
6
|
+
};
|
|
7
|
+
}
|
package/types/next-auth.d.ts
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import NextAuth from 'next-auth';
|
|
2
|
-
|
|
3
|
-
declare module 'next-auth' {
|
|
4
|
-
interface User {
|
|
5
|
-
id?: number;
|
|
6
|
-
pk: number;
|
|
7
|
-
firstName: string;
|
|
8
|
-
lastName: string;
|
|
9
|
-
email: string;
|
|
10
|
-
phone: string;
|
|
11
|
-
emailAllowed: boolean;
|
|
12
|
-
smsAllowed: boolean;
|
|
13
|
-
dateJoined: string;
|
|
14
|
-
lastLogin: string;
|
|
15
|
-
dateOfBirth: string;
|
|
16
|
-
token: string;
|
|
17
|
-
hashedEmail: string;
|
|
18
|
-
gender: string;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
interface Session {
|
|
22
|
-
user: User;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
1
|
+
import NextAuth from 'next-auth';
|
|
2
|
+
|
|
3
|
+
declare module 'next-auth' {
|
|
4
|
+
interface User {
|
|
5
|
+
id?: number;
|
|
6
|
+
pk: number;
|
|
7
|
+
firstName: string;
|
|
8
|
+
lastName: string;
|
|
9
|
+
email: string;
|
|
10
|
+
phone: string;
|
|
11
|
+
emailAllowed: boolean;
|
|
12
|
+
smsAllowed: boolean;
|
|
13
|
+
dateJoined: string;
|
|
14
|
+
lastLogin: string;
|
|
15
|
+
dateOfBirth: string;
|
|
16
|
+
token: string;
|
|
17
|
+
hashedEmail: string;
|
|
18
|
+
gender: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface Session {
|
|
22
|
+
user: User;
|
|
23
|
+
}
|
|
24
|
+
}
|