@akinon/next 1.62.0 → 1.63.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 +11 -0
- package/components/price.tsx +10 -4
- package/data/client/b2b.ts +35 -2
- package/data/urls.ts +4 -1
- package/package.json +2 -2
- package/types/commerce/b2b.ts +12 -2
- package/types/index.ts +7 -0
- package/utils/index.ts +27 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @akinon/next
|
|
2
2
|
|
|
3
|
+
## 1.63.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- a4c8d6a: ZERO-2663: Fix the image url for gif and svgs and return them without options
|
|
8
|
+
- fda5b92: ZERO-2725: fix invalid import
|
|
9
|
+
- 0d3a913: ZERO-2725: Update decimal scale in Price component
|
|
10
|
+
- c45b62c: ZERO-2818: Add upload and download support for b2b package
|
|
11
|
+
- d409996: ZERO-2781: Refactor buildClientRequestUrl function to support caching and options
|
|
12
|
+
- dcc8a15: ZERO-2694: added build step to RC branch pipeline
|
|
13
|
+
|
|
3
14
|
## 1.62.0
|
|
4
15
|
|
|
5
16
|
### Minor Changes
|
package/components/price.tsx
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
|
-
|
|
2
|
+
// @ts-ignore
|
|
3
|
+
import { NumericFormat, NumericFormatProps } from 'react-number-format';
|
|
3
4
|
import { getCurrency } from '@akinon/next/utils';
|
|
4
5
|
|
|
5
6
|
import { useLocalization } from '@akinon/next/hooks';
|
|
6
7
|
import { PriceProps } from '../types';
|
|
8
|
+
import Settings from 'settings';
|
|
7
9
|
|
|
8
|
-
export const Price = (props:
|
|
10
|
+
export const Price = (props: NumericFormatProps & PriceProps) => {
|
|
9
11
|
const {
|
|
10
12
|
value,
|
|
11
13
|
currencyCode,
|
|
@@ -27,6 +29,10 @@ export const Price = (props: NumberFormatProps & PriceProps) => {
|
|
|
27
29
|
// TODO: This is very bad practice. It broke decimalScale.
|
|
28
30
|
const _value = value?.toString().replace('.', ',');
|
|
29
31
|
|
|
32
|
+
const currentCurrencyDecimalScale = Settings.localization.currencies.find(
|
|
33
|
+
(currency) => currency.code === currencyCode_
|
|
34
|
+
).decimalScale;
|
|
35
|
+
|
|
30
36
|
const currency = useMemo(
|
|
31
37
|
() =>
|
|
32
38
|
getCurrency({
|
|
@@ -39,14 +45,14 @@ export const Price = (props: NumberFormatProps & PriceProps) => {
|
|
|
39
45
|
);
|
|
40
46
|
|
|
41
47
|
return (
|
|
42
|
-
<
|
|
48
|
+
<NumericFormat
|
|
43
49
|
value={useNegative ? `-${useNegativeSpace}${_value}` : _value}
|
|
44
50
|
{...{
|
|
45
51
|
[useCurrencyAfterPrice ? 'suffix' : 'prefix']: currency
|
|
46
52
|
}}
|
|
47
53
|
displayType={displayType}
|
|
48
54
|
thousandSeparator={thousandSeparator}
|
|
49
|
-
decimalScale={decimalScale}
|
|
55
|
+
decimalScale={currentCurrencyDecimalScale ?? decimalScale}
|
|
50
56
|
decimalSeparator={decimalSeparator}
|
|
51
57
|
fixedDecimalScale={fixedDecimalScale}
|
|
52
58
|
{...rest}
|
package/data/client/b2b.ts
CHANGED
|
@@ -12,7 +12,9 @@ import {
|
|
|
12
12
|
SaveBasketParams,
|
|
13
13
|
UpdateProductParams,
|
|
14
14
|
DeleteProductParams,
|
|
15
|
-
CreateQuotationParams
|
|
15
|
+
CreateQuotationParams,
|
|
16
|
+
BasketStatusResponse,
|
|
17
|
+
ExportBasketResponse
|
|
16
18
|
} from '../../types';
|
|
17
19
|
|
|
18
20
|
const b2bApi = api.injectEndpoints({
|
|
@@ -89,6 +91,34 @@ const b2bApi = api.injectEndpoints({
|
|
|
89
91
|
}),
|
|
90
92
|
invalidatesTags: ['BasketB2b', 'DraftsB2b']
|
|
91
93
|
}),
|
|
94
|
+
exportBasket: build.mutation<ExportBasketResponse, string>({
|
|
95
|
+
query: (queryString) => {
|
|
96
|
+
return {
|
|
97
|
+
url: buildClientRequestUrl(b2b.basketExport(queryString)),
|
|
98
|
+
method: 'GET'
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
}),
|
|
102
|
+
getBasketStatus: build.mutation<BasketStatusResponse, string>({
|
|
103
|
+
query: (cacheKey) => {
|
|
104
|
+
return {
|
|
105
|
+
url: buildClientRequestUrl(b2b.statusBasket(cacheKey)),
|
|
106
|
+
method: 'GET'
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
}),
|
|
110
|
+
uploadFile: build.mutation<void, FormData>({
|
|
111
|
+
query: (body) => {
|
|
112
|
+
return {
|
|
113
|
+
url: buildClientRequestUrl(b2b.basketImport, {
|
|
114
|
+
useFormData: true
|
|
115
|
+
}),
|
|
116
|
+
method: 'POST',
|
|
117
|
+
body
|
|
118
|
+
};
|
|
119
|
+
},
|
|
120
|
+
invalidatesTags: ['BasketB2b']
|
|
121
|
+
})
|
|
92
122
|
}),
|
|
93
123
|
overrideExisting: true
|
|
94
124
|
});
|
|
@@ -102,5 +132,8 @@ export const {
|
|
|
102
132
|
useLoadBasketMutation,
|
|
103
133
|
useUpdateProductMutation,
|
|
104
134
|
useDeleteProductMutation,
|
|
105
|
-
useCreateQuotationMutation
|
|
135
|
+
useCreateQuotationMutation,
|
|
136
|
+
useGetBasketStatusMutation,
|
|
137
|
+
useExportBasketMutation,
|
|
138
|
+
useUploadFileMutation
|
|
106
139
|
} = b2bApi;
|
package/data/urls.ts
CHANGED
|
@@ -199,7 +199,10 @@ export const b2b = {
|
|
|
199
199
|
draftBaskets: '/b2b/basket/drafts/',
|
|
200
200
|
divisions: '/b2b/my-divisions/',
|
|
201
201
|
myQuotations: '/b2b/my-quotations/',
|
|
202
|
-
loadBasket: (id) => `/b2b/basket/${id}/load
|
|
202
|
+
loadBasket: (id) => `/b2b/basket/${id}/load/`,
|
|
203
|
+
statusBasket: (cacheKey) => `/b2b/basket/?status_cache_key=${cacheKey}`,
|
|
204
|
+
basketExport: (queryString) => `/b2b/basket/?upload=true&${queryString}`,
|
|
205
|
+
basketImport: '/b2b/basket/bulk-import/'
|
|
203
206
|
};
|
|
204
207
|
|
|
205
208
|
export const widgets = {
|
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.
|
|
4
|
+
"version": "1.63.0",
|
|
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.
|
|
33
|
+
"@akinon/eslint-plugin-projectzero": "1.63.0",
|
|
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/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
|
+
};
|
package/types/index.ts
CHANGED
|
@@ -68,6 +68,13 @@ 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 {
|
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;
|
|
@@ -102,6 +117,12 @@ export function buildCDNUrl(url: string, config?: CDNOptions) {
|
|
|
102
117
|
''
|
|
103
118
|
);
|
|
104
119
|
|
|
120
|
+
const noOptionFileExtension = url?.split('.').pop()?.toLowerCase() ?? '';
|
|
121
|
+
|
|
122
|
+
if (noOptionFileExtension === 'svg' || noOptionFileExtension === 'gif') {
|
|
123
|
+
return url;
|
|
124
|
+
}
|
|
125
|
+
|
|
105
126
|
let options = '';
|
|
106
127
|
|
|
107
128
|
if (config) {
|