@akinon/next 1.45.0-rc.1 → 1.45.0-rc.2

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 CHANGED
@@ -1,5 +1,12 @@
1
1
  # @akinon/next
2
2
 
3
+ ## 1.45.0-rc.2
4
+
5
+ ### Minor Changes
6
+
7
+ - c45b62c: ZERO-2818: Add upload and download support for b2b package
8
+ - f2c325c: ZERO-2838: Move file input component into @akinon/next
9
+
3
10
  ## 1.45.0-rc.1
4
11
 
5
12
  ### Minor Changes
@@ -0,0 +1,8 @@
1
+ import { forwardRef } from 'react';
2
+ import { FileInputProps } from '../types/index';
3
+
4
+ export const FileInput = forwardRef<HTMLInputElement, FileInputProps>(
5
+ function fileInput(props, ref) {
6
+ return <input type="file" {...props} ref={ref} />;
7
+ }
8
+ );
@@ -19,3 +19,4 @@ export * from './trans';
19
19
  export * from './link';
20
20
  export * from './pagination';
21
21
  export * from './live-commerce';
22
+ export * from './file-input';
@@ -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
@@ -191,7 +191,10 @@ export const b2b = {
191
191
  draftBaskets: '/b2b/basket/drafts/',
192
192
  divisions: '/b2b/my-divisions/',
193
193
  myQuotations: '/b2b/my-quotations/',
194
- loadBasket: (id) => `/b2b/basket/${id}/load/`
194
+ loadBasket: (id) => `/b2b/basket/${id}/load/`,
195
+ statusBasket: (cacheKey) => `/b2b/basket/?status_cache_key=${cacheKey}`,
196
+ basketExport: (queryString) => `/b2b/basket/?upload=true&${queryString}`,
197
+ basketImport: '/b2b/basket/bulk-import/'
195
198
  };
196
199
 
197
200
  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.45.0-rc.1",
4
+ "version": "1.45.0-rc.2",
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.45.0-rc.1",
33
+ "@akinon/eslint-plugin-projectzero": "1.45.0-rc.2",
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",
@@ -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
@@ -258,6 +258,8 @@ export interface ButtonProps
258
258
  appearance?: 'filled' | 'outlined' | 'ghost';
259
259
  }
260
260
 
261
+ export type FileInputProps = React.HTMLProps<HTMLInputElement>;
262
+
261
263
  export interface PriceProps {
262
264
  currencyCode?: string;
263
265
  useCurrencySymbol?: boolean;