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

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,18 @@
1
1
  # @akinon/next
2
2
 
3
+ ## 1.45.0-rc.3
4
+
5
+ ### Minor Changes
6
+
7
+ - 948eb42: ZERO-2852: Add out of stock endpoints
8
+
9
+ ## 1.45.0-rc.2
10
+
11
+ ### Minor Changes
12
+
13
+ - c45b62c: ZERO-2818: Add upload and download support for b2b package
14
+ - f2c325c: ZERO-2838: Move file input component into @akinon/next
15
+
3
16
  ## 1.45.0-rc.1
4
17
 
5
18
  ### 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;
@@ -1,4 +1,4 @@
1
- import { FavoriteItem } from '../../types';
1
+ import { FavoriteItem, Product } from '../../types';
2
2
  import { buildClientRequestUrl } from '../../utils';
3
3
  import { api } from './api';
4
4
  import { wishlist } from '../urls';
@@ -55,6 +55,25 @@ interface GetStockAlertsResponse {
55
55
  interface DeleteStockAlertResponse {
56
56
  success: boolean;
57
57
  }
58
+ interface GetCollectionOOSResponse {
59
+ count: number;
60
+ results: CollectionItem[];
61
+ next?: string | null;
62
+ previous?: string | null;
63
+ }
64
+
65
+ export interface CollectionItem {
66
+ pk: number;
67
+ status: string;
68
+ name: string;
69
+ slug: string;
70
+ items: Product[];
71
+ }
72
+
73
+ export interface CollectionItemsResponse {
74
+ pk: number;
75
+ product: Product;
76
+ }
58
77
 
59
78
  export const wishlistApi = api.injectEndpoints({
60
79
  endpoints: (build) => ({
@@ -105,6 +124,50 @@ export const wishlistApi = api.injectEndpoints({
105
124
  method: 'DELETE'
106
125
  }),
107
126
  invalidatesTags: ['StockAlert']
127
+ }),
128
+ setCollectionOOS: build.mutation<
129
+ CollectionItem,
130
+ { name: string; status: string }
131
+ >({
132
+ query: ({ name, status = 'private' }) => ({
133
+ url: buildClientRequestUrl(wishlist.setCollection(), {
134
+ contentType: 'application/json'
135
+ }),
136
+ method: 'POST',
137
+ body: {
138
+ name,
139
+ status
140
+ }
141
+ })
142
+ }),
143
+ setCollectionItems: build.mutation<
144
+ CollectionItemsResponse,
145
+ { usercollection_id: number; product_id: number | number[] }
146
+ >({
147
+ query: ({ usercollection_id, product_id }) => ({
148
+ url: buildClientRequestUrl(wishlist.setCollectionItems, {
149
+ contentType: 'application/json'
150
+ }),
151
+ method: 'POST',
152
+ body: {
153
+ usercollection_id,
154
+ product_id
155
+ }
156
+ })
157
+ }),
158
+ getCollectionsOOS: build.query<
159
+ GetCollectionOOSResponse,
160
+ { search?: string; product_id?: number }
161
+ >({
162
+ query: ({ search, product_id }) => ({
163
+ url: buildClientRequestUrl(wishlist.getCollections(search, product_id))
164
+ })
165
+ }),
166
+ deleteCollection: build.query<void, number>({
167
+ query: (pk: number) => ({
168
+ url: buildClientRequestUrl(wishlist.deleteCollection(pk)),
169
+ method: 'DELETE'
170
+ })
108
171
  })
109
172
  }),
110
173
  overrideExisting: true
@@ -116,5 +179,10 @@ export const {
116
179
  useRemoveFavoriteMutation,
117
180
  useAddStockAlertMutation,
118
181
  useGetStockAlertsQuery,
119
- useDeleteStockAlertMutation
182
+ useDeleteStockAlertMutation,
183
+ useSetCollectionOOSMutation,
184
+ useSetCollectionItemsMutation,
185
+ useGetCollectionsOOSQuery,
186
+ useLazyGetCollectionsOOSQuery,
187
+ useLazyDeleteCollectionQuery
120
188
  } = wishlistApi;
package/data/urls.ts CHANGED
@@ -165,7 +165,14 @@ export const wishlist = {
165
165
  page?: number;
166
166
  limit?: number;
167
167
  }) => `/wishlists/product-alerts/?limit=${limit}&page=${page}`,
168
- deleteStockAlert: (pk: number) => `/wishlists/product-alerts/${pk}/`
168
+ deleteStockAlert: (pk: number) => `/wishlists/product-alerts/${pk}/`,
169
+ setCollection: () => '/wishlists/user-collections/',
170
+ setCollectionItems: '/wishlists/user-collection-items/',
171
+ getCollections: (search?: string, product_id?: number) =>
172
+ `/wishlists/user-collections/?search=${search ? search : ''}&product_id=${
173
+ product_id ? product_id : ''
174
+ }`,
175
+ deleteCollection: (pk: number) => `/wishlists/user-collections/${pk}/`
169
176
  };
170
177
 
171
178
  export const user = {
@@ -191,7 +198,10 @@ export const b2b = {
191
198
  draftBaskets: '/b2b/basket/drafts/',
192
199
  divisions: '/b2b/my-divisions/',
193
200
  myQuotations: '/b2b/my-quotations/',
194
- loadBasket: (id) => `/b2b/basket/${id}/load/`
201
+ loadBasket: (id) => `/b2b/basket/${id}/load/`,
202
+ statusBasket: (cacheKey) => `/b2b/basket/?status_cache_key=${cacheKey}`,
203
+ basketExport: (queryString) => `/b2b/basket/?upload=true&${queryString}`,
204
+ basketImport: '/b2b/basket/bulk-import/'
195
205
  };
196
206
 
197
207
  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.3",
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.3",
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;