@akinon/next 1.42.0-rc.1 → 1.42.0-rc.11
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 +40 -0
- package/components/input.tsx +1 -0
- package/components/pagination.tsx +1 -2
- package/components/price.tsx +2 -1
- package/data/client/api.ts +1 -1
- package/data/server/product.ts +13 -8
- package/package.json +2 -2
- package/types/commerce/order.ts +5 -0
- package/types/index.ts +19 -1
- package/utils/index.ts +21 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,45 @@
|
|
|
1
1
|
# @akinon/next
|
|
2
2
|
|
|
3
|
+
## 1.42.0-rc.11
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 8d9ac9a: ZERO-2794: Add field to order type
|
|
8
|
+
|
|
9
|
+
## 1.42.0-rc.10
|
|
10
|
+
|
|
11
|
+
## 1.42.0-rc.9
|
|
12
|
+
|
|
13
|
+
## 1.42.0-rc.8
|
|
14
|
+
|
|
15
|
+
### Minor Changes
|
|
16
|
+
|
|
17
|
+
- d409996: ZERO-2781: Refactor buildClientRequestUrl function to support caching and options
|
|
18
|
+
|
|
19
|
+
## 1.42.0-rc.7
|
|
20
|
+
|
|
21
|
+
## 1.42.0-rc.6
|
|
22
|
+
|
|
23
|
+
### Minor Changes
|
|
24
|
+
|
|
25
|
+
- 146ea39: ZERO-2774: Update imports
|
|
26
|
+
|
|
27
|
+
## 1.42.0-rc.5
|
|
28
|
+
|
|
29
|
+
## 1.42.0-rc.4
|
|
30
|
+
|
|
31
|
+
### Minor Changes
|
|
32
|
+
|
|
33
|
+
- 46b7aad: ZERO-2775: Add condition and logger for menuitemmodel data
|
|
34
|
+
|
|
35
|
+
## 1.42.0-rc.3
|
|
36
|
+
|
|
37
|
+
### Minor Changes
|
|
38
|
+
|
|
39
|
+
- fda5b92: ZERO-2725: fix invalid import
|
|
40
|
+
|
|
41
|
+
## 1.42.0-rc.2
|
|
42
|
+
|
|
3
43
|
## 1.42.0-rc.1
|
|
4
44
|
|
|
5
45
|
## 1.42.0-rc.0
|
package/components/input.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import clsx from 'clsx';
|
|
2
2
|
import { forwardRef, FocusEvent, useState, Ref } from 'react';
|
|
3
3
|
import { Controller } from 'react-hook-form';
|
|
4
|
+
|
|
4
5
|
// @ts-ignore
|
|
5
6
|
import { PatternFormat, PatternFormatProps } from 'react-number-format';
|
|
6
7
|
import { InputProps } from '../types';
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { MouseEvent, useCallback, useEffect, useState } from 'react';
|
|
4
|
-
import { PaginationProps } from '
|
|
4
|
+
import { PaginationProps } from '../types';
|
|
5
5
|
import { twMerge } from 'tailwind-merge';
|
|
6
6
|
import clsx from 'clsx';
|
|
7
|
-
|
|
8
7
|
import usePagination from '@akinon/next/hooks/use-pagination';
|
|
9
8
|
import { useLocalization } from '@akinon/next/hooks';
|
|
10
9
|
import { useRouter } from '@akinon/next/hooks';
|
package/components/price.tsx
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
|
+
|
|
2
3
|
// @ts-ignore
|
|
3
4
|
import { NumericFormat, NumericFormatProps } from 'react-number-format';
|
|
4
5
|
import { getCurrency } from '@akinon/next/utils';
|
|
5
6
|
|
|
6
7
|
import { useLocalization } from '@akinon/next/hooks';
|
|
7
8
|
import { PriceProps } from '../types';
|
|
8
|
-
import Settings from '
|
|
9
|
+
import Settings from 'settings';
|
|
9
10
|
|
|
10
11
|
export const Price = (props: NumericFormatProps & PriceProps) => {
|
|
11
12
|
const {
|
package/data/client/api.ts
CHANGED
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
} from '@reduxjs/toolkit/query/react';
|
|
10
10
|
import settings from 'settings';
|
|
11
11
|
import { getCookie } from '../../utils';
|
|
12
|
-
import { RootState } from '
|
|
12
|
+
import { RootState } from 'redux/store';
|
|
13
13
|
|
|
14
14
|
interface CustomBaseQueryApi extends BaseQueryApi {
|
|
15
15
|
getState: () => RootState;
|
package/data/server/product.ts
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { Cache, CacheKey } from '../../lib/cache';
|
|
2
2
|
import { product } from '../urls';
|
|
3
|
-
import {
|
|
4
|
-
BreadcrumbResultType,
|
|
5
|
-
ProductCategoryResult,
|
|
6
|
-
ProductResult
|
|
7
|
-
} from '../../types';
|
|
3
|
+
import { ProductCategoryResult, ProductResult } from '../../types';
|
|
8
4
|
import appFetch from '../../utils/app-fetch';
|
|
5
|
+
import logger from '../../utils/log';
|
|
9
6
|
|
|
10
7
|
type GetProduct = {
|
|
11
8
|
pk: number;
|
|
@@ -50,9 +47,17 @@ const getProductDataHandler = ({
|
|
|
50
47
|
}
|
|
51
48
|
);
|
|
52
49
|
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
)
|
|
50
|
+
const menuItemModel = productCategoryData?.results[0]?.menuitemmodel;
|
|
51
|
+
|
|
52
|
+
if (!menuItemModel) {
|
|
53
|
+
logger.warn('menuItemModel is undefined, skipping breadcrumbData fetch', {
|
|
54
|
+
handler: 'getProductDataHandler',
|
|
55
|
+
pk
|
|
56
|
+
});
|
|
57
|
+
return { data, breadcrumbData: undefined };
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const breadcrumbUrl = product.breadcrumbUrl(menuItemModel);
|
|
56
61
|
|
|
57
62
|
const breadcrumbData = await appFetch<any>(breadcrumbUrl, {
|
|
58
63
|
headers: {
|
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.42.0-rc.
|
|
4
|
+
"version": "1.42.0-rc.11",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"bin": {
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"set-cookie-parser": "2.6.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@akinon/eslint-plugin-projectzero": "1.42.0-rc.
|
|
33
|
+
"@akinon/eslint-plugin-projectzero": "1.42.0-rc.11",
|
|
34
34
|
"@types/react-redux": "7.1.30",
|
|
35
35
|
"@types/set-cookie-parser": "2.4.7",
|
|
36
36
|
"@typescript-eslint/eslint-plugin": "6.7.4",
|
package/types/commerce/order.ts
CHANGED
|
@@ -109,8 +109,13 @@ export interface Order {
|
|
|
109
109
|
shipping_option: number;
|
|
110
110
|
tracking_number: string;
|
|
111
111
|
tracking_url: string;
|
|
112
|
+
[key: string]: any;
|
|
112
113
|
bank: {
|
|
114
|
+
pk: number;
|
|
115
|
+
name: string;
|
|
116
|
+
slug: string;
|
|
113
117
|
logo: string;
|
|
118
|
+
[key: string]: any;
|
|
114
119
|
};
|
|
115
120
|
}
|
|
116
121
|
|
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
|
|
@@ -291,3 +291,21 @@ export interface AccordionProps {
|
|
|
291
291
|
export interface PluginModuleComponentProps {
|
|
292
292
|
settings?: Record<string, any>;
|
|
293
293
|
}
|
|
294
|
+
|
|
295
|
+
export interface PaginationProps {
|
|
296
|
+
total: number | undefined;
|
|
297
|
+
limit?: number | undefined;
|
|
298
|
+
currentPage: number | undefined;
|
|
299
|
+
numberOfPages?: number | undefined;
|
|
300
|
+
containerClassName?: string;
|
|
301
|
+
moreButtonClassName?: string;
|
|
302
|
+
prevClassName?: string;
|
|
303
|
+
nextClassName?: string;
|
|
304
|
+
pageClassName?: string;
|
|
305
|
+
threshold?: number | undefined;
|
|
306
|
+
delta?: number | undefined;
|
|
307
|
+
render?: (pagination: UsePaginationType) => ReactNode;
|
|
308
|
+
type?: 'infinite' | 'list' | 'more';
|
|
309
|
+
onPageChange?: (page: number) => void;
|
|
310
|
+
direction?: 'next' | 'prev';
|
|
311
|
+
}
|
package/utils/index.ts
CHANGED
|
@@ -63,18 +63,33 @@ export function getTranslateFn(path: string, translations: any) {
|
|
|
63
63
|
|
|
64
64
|
export function buildClientRequestUrl(
|
|
65
65
|
path: string,
|
|
66
|
-
options?: ClientRequestOptions
|
|
66
|
+
options?: ClientRequestOptions & { cache?: boolean }
|
|
67
67
|
) {
|
|
68
68
|
let url = `/api/client${path}`;
|
|
69
69
|
|
|
70
|
+
let hasQuery = url.includes('?');
|
|
71
|
+
|
|
70
72
|
if (options) {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
const { cache, ...otherOptions } = options;
|
|
74
|
+
|
|
75
|
+
if (Object.keys(otherOptions).length > 0) {
|
|
76
|
+
if (hasQuery) {
|
|
77
|
+
url += '&';
|
|
78
|
+
} else {
|
|
79
|
+
url += '?';
|
|
80
|
+
hasQuery = true;
|
|
81
|
+
}
|
|
82
|
+
url += `options=${encodeURIComponent(JSON.stringify(otherOptions))}`;
|
|
75
83
|
}
|
|
76
84
|
|
|
77
|
-
|
|
85
|
+
if (cache === false) {
|
|
86
|
+
if (hasQuery) {
|
|
87
|
+
url += '&';
|
|
88
|
+
} else {
|
|
89
|
+
url += '?';
|
|
90
|
+
}
|
|
91
|
+
url += `t=${Date.now()}`;
|
|
92
|
+
}
|
|
78
93
|
}
|
|
79
94
|
|
|
80
95
|
return url;
|