@squonk/account-server-client 0.1.27-rc.1 → 0.1.28-rc.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/{chunk-GWBPVOL2.js → chunk-6EEIAH4R.js} +23 -2
- package/chunk-6EEIAH4R.js.map +1 -0
- package/chunk-NGBTCJWS.cjs +46 -0
- package/chunk-NGBTCJWS.cjs.map +1 -0
- package/{account-server-api.schemas-e6c5f956.d.ts → custom-instance-13412a15.d.ts} +19 -1
- package/index.cjs +5 -21
- package/index.cjs.map +1 -1
- package/index.d.ts +2 -20
- package/index.js +5 -21
- package/index.js.map +1 -1
- package/organisation/organisation.cjs +35 -30
- package/organisation/organisation.cjs.map +1 -1
- package/organisation/organisation.d.ts +33 -32
- package/organisation/organisation.js +42 -37
- package/organisation/organisation.js.map +1 -1
- package/package.json +1 -1
- package/product/product.cjs +65 -53
- package/product/product.cjs.map +1 -1
- package/product/product.d.ts +55 -54
- package/product/product.js +76 -64
- package/product/product.js.map +1 -1
- package/service/service.cjs +21 -23
- package/service/service.cjs.map +1 -1
- package/service/service.d.ts +18 -17
- package/service/service.js +23 -25
- package/service/service.js.map +1 -1
- package/src/organisation/organisation.ts +93 -69
- package/src/product/product.ts +165 -146
- package/src/service/service.ts +59 -57
- package/src/state/state.ts +34 -28
- package/src/unit/unit.ts +145 -130
- package/src/user/user.ts +148 -120
- package/state/state.cjs +12 -12
- package/state/state.cjs.map +1 -1
- package/state/state.d.ts +11 -10
- package/state/state.js +13 -13
- package/state/state.js.map +1 -1
- package/unit/unit.cjs +55 -50
- package/unit/unit.cjs.map +1 -1
- package/unit/unit.d.ts +54 -53
- package/unit/unit.js +66 -61
- package/unit/unit.js.map +1 -1
- package/user/user.cjs +50 -50
- package/user/user.cjs.map +1 -1
- package/user/user.d.ts +53 -52
- package/user/user.js +61 -61
- package/user/user.js.map +1 -1
- package/chunk-GWBPVOL2.js.map +0 -1
- package/chunk-N3RLW53G.cjs +0 -25
- package/chunk-N3RLW53G.cjs.map +0 -1
package/src/product/product.ts
CHANGED
|
@@ -8,7 +8,6 @@ A service that provides access to the Account Server, which gives *registered* u
|
|
|
8
8
|
|
|
9
9
|
* OpenAPI spec version: 0.1
|
|
10
10
|
*/
|
|
11
|
-
import axios, { AxiosRequestConfig, AxiosResponse, AxiosError } from "axios";
|
|
12
11
|
import {
|
|
13
12
|
useQuery,
|
|
14
13
|
useMutation,
|
|
@@ -28,6 +27,7 @@ import type {
|
|
|
28
27
|
ProductUnitGetResponse,
|
|
29
28
|
ProductPatchBodyBody,
|
|
30
29
|
} from "../account-server-api.schemas";
|
|
30
|
+
import { customInstance, ErrorType } from ".././custom-instance";
|
|
31
31
|
|
|
32
32
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
33
33
|
type AsyncReturnType<T extends (...args: any) => Promise<any>> = T extends (
|
|
@@ -36,45 +36,55 @@ type AsyncReturnType<T extends (...args: any) => Promise<any>> = T extends (
|
|
|
36
36
|
? R
|
|
37
37
|
: any;
|
|
38
38
|
|
|
39
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
40
|
+
type SecondParameter<T extends (...args: any) => any> = T extends (
|
|
41
|
+
config: any,
|
|
42
|
+
args: infer P
|
|
43
|
+
) => any
|
|
44
|
+
? P
|
|
45
|
+
: never;
|
|
46
|
+
|
|
39
47
|
/**
|
|
40
48
|
* Gets product types you can purchase
|
|
41
49
|
|
|
42
50
|
* @summary Gets all Product Types
|
|
43
51
|
*/
|
|
44
|
-
export const
|
|
45
|
-
options?:
|
|
46
|
-
)
|
|
47
|
-
return
|
|
52
|
+
export const getProductTypes = (
|
|
53
|
+
options?: SecondParameter<typeof customInstance>
|
|
54
|
+
) => {
|
|
55
|
+
return customInstance<ProductsGetTypesResponse>(
|
|
56
|
+
{ url: `/product-type`, method: "get" },
|
|
57
|
+
options
|
|
58
|
+
);
|
|
48
59
|
};
|
|
49
60
|
|
|
50
|
-
export const
|
|
61
|
+
export const getGetProductTypesQueryKey = () => [`/product-type`];
|
|
51
62
|
|
|
52
|
-
export type
|
|
53
|
-
AsyncReturnType<typeof
|
|
63
|
+
export type GetProductTypesQueryResult = NonNullable<
|
|
64
|
+
AsyncReturnType<typeof getProductTypes>
|
|
54
65
|
>;
|
|
55
|
-
export type
|
|
66
|
+
export type GetProductTypesQueryError = ErrorType<AsError | void>;
|
|
56
67
|
|
|
57
|
-
export const
|
|
58
|
-
TData = AsyncReturnType<typeof
|
|
59
|
-
TError =
|
|
68
|
+
export const useGetProductTypes = <
|
|
69
|
+
TData = AsyncReturnType<typeof getProductTypes>,
|
|
70
|
+
TError = ErrorType<AsError | void>
|
|
60
71
|
>(options?: {
|
|
61
72
|
query?: UseQueryOptions<
|
|
62
|
-
AsyncReturnType<typeof
|
|
73
|
+
AsyncReturnType<typeof getProductTypes>,
|
|
63
74
|
TError,
|
|
64
75
|
TData
|
|
65
76
|
>;
|
|
66
|
-
|
|
77
|
+
request?: SecondParameter<typeof customInstance>;
|
|
67
78
|
}): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
68
|
-
const { query: queryOptions,
|
|
79
|
+
const { query: queryOptions, request: requestOptions } = options || {};
|
|
69
80
|
|
|
70
|
-
const queryKey = queryOptions?.queryKey ??
|
|
81
|
+
const queryKey = queryOptions?.queryKey ?? getGetProductTypesQueryKey();
|
|
71
82
|
|
|
72
|
-
const queryFn: QueryFunction<
|
|
73
|
-
|
|
74
|
-
> = () => appApiProductGetTypes(axiosOptions);
|
|
83
|
+
const queryFn: QueryFunction<AsyncReturnType<typeof getProductTypes>> = () =>
|
|
84
|
+
getProductTypes(requestOptions);
|
|
75
85
|
|
|
76
86
|
const query = useQuery<
|
|
77
|
-
AsyncReturnType<typeof
|
|
87
|
+
AsyncReturnType<typeof getProductTypes>,
|
|
78
88
|
TError,
|
|
79
89
|
TData
|
|
80
90
|
>(queryKey, queryFn, queryOptions);
|
|
@@ -90,42 +100,41 @@ export const useAppApiProductGetTypes = <
|
|
|
90
100
|
|
|
91
101
|
* @summary Gets all Products
|
|
92
102
|
*/
|
|
93
|
-
export const
|
|
94
|
-
options?:
|
|
95
|
-
)
|
|
96
|
-
return
|
|
103
|
+
export const getProducts = (
|
|
104
|
+
options?: SecondParameter<typeof customInstance>
|
|
105
|
+
) => {
|
|
106
|
+
return customInstance<ProductsGetResponse>(
|
|
107
|
+
{ url: `/product`, method: "get" },
|
|
108
|
+
options
|
|
109
|
+
);
|
|
97
110
|
};
|
|
98
111
|
|
|
99
|
-
export const
|
|
112
|
+
export const getGetProductsQueryKey = () => [`/product`];
|
|
100
113
|
|
|
101
|
-
export type
|
|
102
|
-
AsyncReturnType<typeof
|
|
114
|
+
export type GetProductsQueryResult = NonNullable<
|
|
115
|
+
AsyncReturnType<typeof getProducts>
|
|
103
116
|
>;
|
|
104
|
-
export type
|
|
117
|
+
export type GetProductsQueryError = ErrorType<AsError | void>;
|
|
105
118
|
|
|
106
|
-
export const
|
|
107
|
-
TData = AsyncReturnType<typeof
|
|
108
|
-
TError =
|
|
119
|
+
export const useGetProducts = <
|
|
120
|
+
TData = AsyncReturnType<typeof getProducts>,
|
|
121
|
+
TError = ErrorType<AsError | void>
|
|
109
122
|
>(options?: {
|
|
110
|
-
query?: UseQueryOptions<
|
|
111
|
-
|
|
112
|
-
TError,
|
|
113
|
-
TData
|
|
114
|
-
>;
|
|
115
|
-
axios?: AxiosRequestConfig;
|
|
123
|
+
query?: UseQueryOptions<AsyncReturnType<typeof getProducts>, TError, TData>;
|
|
124
|
+
request?: SecondParameter<typeof customInstance>;
|
|
116
125
|
}): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
117
|
-
const { query: queryOptions,
|
|
126
|
+
const { query: queryOptions, request: requestOptions } = options || {};
|
|
118
127
|
|
|
119
|
-
const queryKey = queryOptions?.queryKey ??
|
|
128
|
+
const queryKey = queryOptions?.queryKey ?? getGetProductsQueryKey();
|
|
120
129
|
|
|
121
|
-
const queryFn: QueryFunction<AsyncReturnType<typeof
|
|
122
|
-
|
|
130
|
+
const queryFn: QueryFunction<AsyncReturnType<typeof getProducts>> = () =>
|
|
131
|
+
getProducts(requestOptions);
|
|
123
132
|
|
|
124
|
-
const query = useQuery<
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
133
|
+
const query = useQuery<AsyncReturnType<typeof getProducts>, TError, TData>(
|
|
134
|
+
queryKey,
|
|
135
|
+
queryFn,
|
|
136
|
+
queryOptions
|
|
137
|
+
);
|
|
129
138
|
|
|
130
139
|
return {
|
|
131
140
|
queryKey,
|
|
@@ -136,49 +145,53 @@ export const useAppApiProductGet = <
|
|
|
136
145
|
/**
|
|
137
146
|
* @summary Creates a Product for an Organisational Unit
|
|
138
147
|
*/
|
|
139
|
-
export const
|
|
148
|
+
export const createUnitProduct = (
|
|
140
149
|
unitId: string,
|
|
141
150
|
unitProductPostBodyBody: UnitProductPostBodyBody,
|
|
142
|
-
options?:
|
|
143
|
-
)
|
|
144
|
-
return
|
|
145
|
-
|
|
146
|
-
|
|
151
|
+
options?: SecondParameter<typeof customInstance>
|
|
152
|
+
) => {
|
|
153
|
+
return customInstance<UnitProductPostResponse>(
|
|
154
|
+
{
|
|
155
|
+
url: `/product/unit/${unitId}`,
|
|
156
|
+
method: "post",
|
|
157
|
+
headers: { "Content-Type": "application/json" },
|
|
158
|
+
data: unitProductPostBodyBody,
|
|
159
|
+
},
|
|
147
160
|
options
|
|
148
161
|
);
|
|
149
162
|
};
|
|
150
163
|
|
|
151
|
-
export type
|
|
152
|
-
AsyncReturnType<typeof
|
|
164
|
+
export type CreateUnitProductMutationResult = NonNullable<
|
|
165
|
+
AsyncReturnType<typeof createUnitProduct>
|
|
153
166
|
>;
|
|
154
|
-
export type
|
|
155
|
-
export type
|
|
167
|
+
export type CreateUnitProductMutationBody = UnitProductPostBodyBody;
|
|
168
|
+
export type CreateUnitProductMutationError = ErrorType<AsError | void>;
|
|
156
169
|
|
|
157
|
-
export const
|
|
158
|
-
TError =
|
|
170
|
+
export const useCreateUnitProduct = <
|
|
171
|
+
TError = ErrorType<AsError | void>,
|
|
159
172
|
TContext = unknown
|
|
160
173
|
>(options?: {
|
|
161
174
|
mutation?: UseMutationOptions<
|
|
162
|
-
AsyncReturnType<typeof
|
|
175
|
+
AsyncReturnType<typeof createUnitProduct>,
|
|
163
176
|
TError,
|
|
164
177
|
{ unitId: string; data: UnitProductPostBodyBody },
|
|
165
178
|
TContext
|
|
166
179
|
>;
|
|
167
|
-
|
|
180
|
+
request?: SecondParameter<typeof customInstance>;
|
|
168
181
|
}) => {
|
|
169
|
-
const { mutation: mutationOptions,
|
|
182
|
+
const { mutation: mutationOptions, request: requestOptions } = options || {};
|
|
170
183
|
|
|
171
184
|
const mutationFn: MutationFunction<
|
|
172
|
-
AsyncReturnType<typeof
|
|
185
|
+
AsyncReturnType<typeof createUnitProduct>,
|
|
173
186
|
{ unitId: string; data: UnitProductPostBodyBody }
|
|
174
187
|
> = (props) => {
|
|
175
188
|
const { unitId, data } = props || {};
|
|
176
189
|
|
|
177
|
-
return
|
|
190
|
+
return createUnitProduct(unitId, data, requestOptions);
|
|
178
191
|
};
|
|
179
192
|
|
|
180
193
|
return useMutation<
|
|
181
|
-
AsyncReturnType<typeof
|
|
194
|
+
AsyncReturnType<typeof createUnitProduct>,
|
|
182
195
|
TError,
|
|
183
196
|
{ unitId: string; data: UnitProductPostBodyBody },
|
|
184
197
|
TContext
|
|
@@ -189,47 +202,50 @@ export const useAppApiProductPost = <
|
|
|
189
202
|
|
|
190
203
|
* @summary Gets Products for an Organisational Unit
|
|
191
204
|
*/
|
|
192
|
-
export const
|
|
205
|
+
export const getProductsForUnit = (
|
|
193
206
|
unitId: string,
|
|
194
|
-
options?:
|
|
195
|
-
)
|
|
196
|
-
return
|
|
207
|
+
options?: SecondParameter<typeof customInstance>
|
|
208
|
+
) => {
|
|
209
|
+
return customInstance<ProductsGetResponse>(
|
|
210
|
+
{ url: `/product/unit/${unitId}`, method: "get" },
|
|
211
|
+
options
|
|
212
|
+
);
|
|
197
213
|
};
|
|
198
214
|
|
|
199
|
-
export const
|
|
215
|
+
export const getGetProductsForUnitQueryKey = (unitId: string) => [
|
|
200
216
|
`/product/unit/${unitId}`,
|
|
201
217
|
];
|
|
202
218
|
|
|
203
|
-
export type
|
|
204
|
-
AsyncReturnType<typeof
|
|
219
|
+
export type GetProductsForUnitQueryResult = NonNullable<
|
|
220
|
+
AsyncReturnType<typeof getProductsForUnit>
|
|
205
221
|
>;
|
|
206
|
-
export type
|
|
222
|
+
export type GetProductsForUnitQueryError = ErrorType<void | AsError>;
|
|
207
223
|
|
|
208
|
-
export const
|
|
209
|
-
TData = AsyncReturnType<typeof
|
|
210
|
-
TError =
|
|
224
|
+
export const useGetProductsForUnit = <
|
|
225
|
+
TData = AsyncReturnType<typeof getProductsForUnit>,
|
|
226
|
+
TError = ErrorType<void | AsError>
|
|
211
227
|
>(
|
|
212
228
|
unitId: string,
|
|
213
229
|
options?: {
|
|
214
230
|
query?: UseQueryOptions<
|
|
215
|
-
AsyncReturnType<typeof
|
|
231
|
+
AsyncReturnType<typeof getProductsForUnit>,
|
|
216
232
|
TError,
|
|
217
233
|
TData
|
|
218
234
|
>;
|
|
219
|
-
|
|
235
|
+
request?: SecondParameter<typeof customInstance>;
|
|
220
236
|
}
|
|
221
237
|
): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
222
|
-
const { query: queryOptions,
|
|
238
|
+
const { query: queryOptions, request: requestOptions } = options || {};
|
|
223
239
|
|
|
224
240
|
const queryKey =
|
|
225
|
-
queryOptions?.queryKey ??
|
|
241
|
+
queryOptions?.queryKey ?? getGetProductsForUnitQueryKey(unitId);
|
|
226
242
|
|
|
227
243
|
const queryFn: QueryFunction<
|
|
228
|
-
AsyncReturnType<typeof
|
|
229
|
-
> = () =>
|
|
244
|
+
AsyncReturnType<typeof getProductsForUnit>
|
|
245
|
+
> = () => getProductsForUnit(unitId, requestOptions);
|
|
230
246
|
|
|
231
247
|
const query = useQuery<
|
|
232
|
-
AsyncReturnType<typeof
|
|
248
|
+
AsyncReturnType<typeof getProductsForUnit>,
|
|
233
249
|
TError,
|
|
234
250
|
TData
|
|
235
251
|
>(queryKey, queryFn, { enabled: !!unitId, ...queryOptions });
|
|
@@ -245,54 +261,50 @@ export const useAppApiProductGetForUnit = <
|
|
|
245
261
|
|
|
246
262
|
* @summary Gets a Unit's Product
|
|
247
263
|
*/
|
|
248
|
-
export const
|
|
264
|
+
export const getProduct = (
|
|
249
265
|
unitId: string,
|
|
250
266
|
productId: string,
|
|
251
|
-
options?:
|
|
252
|
-
)
|
|
253
|
-
return
|
|
267
|
+
options?: SecondParameter<typeof customInstance>
|
|
268
|
+
) => {
|
|
269
|
+
return customInstance<ProductUnitGetResponse>(
|
|
270
|
+
{ url: `/product/unit/${unitId}/product/${productId}`, method: "get" },
|
|
271
|
+
options
|
|
272
|
+
);
|
|
254
273
|
};
|
|
255
274
|
|
|
256
|
-
export const
|
|
257
|
-
unitId
|
|
258
|
-
|
|
259
|
-
) => [`/product/unit/${unitId}/product/${productId}`];
|
|
275
|
+
export const getGetProductQueryKey = (unitId: string, productId: string) => [
|
|
276
|
+
`/product/unit/${unitId}/product/${productId}`,
|
|
277
|
+
];
|
|
260
278
|
|
|
261
|
-
export type
|
|
262
|
-
AsyncReturnType<typeof
|
|
279
|
+
export type GetProductQueryResult = NonNullable<
|
|
280
|
+
AsyncReturnType<typeof getProduct>
|
|
263
281
|
>;
|
|
264
|
-
export type
|
|
282
|
+
export type GetProductQueryError = ErrorType<AsError | void>;
|
|
265
283
|
|
|
266
|
-
export const
|
|
267
|
-
TData = AsyncReturnType<typeof
|
|
268
|
-
TError =
|
|
284
|
+
export const useGetProduct = <
|
|
285
|
+
TData = AsyncReturnType<typeof getProduct>,
|
|
286
|
+
TError = ErrorType<AsError | void>
|
|
269
287
|
>(
|
|
270
288
|
unitId: string,
|
|
271
289
|
productId: string,
|
|
272
290
|
options?: {
|
|
273
|
-
query?: UseQueryOptions<
|
|
274
|
-
|
|
275
|
-
TError,
|
|
276
|
-
TData
|
|
277
|
-
>;
|
|
278
|
-
axios?: AxiosRequestConfig;
|
|
291
|
+
query?: UseQueryOptions<AsyncReturnType<typeof getProduct>, TError, TData>;
|
|
292
|
+
request?: SecondParameter<typeof customInstance>;
|
|
279
293
|
}
|
|
280
294
|
): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
281
|
-
const { query: queryOptions,
|
|
295
|
+
const { query: queryOptions, request: requestOptions } = options || {};
|
|
282
296
|
|
|
283
297
|
const queryKey =
|
|
284
|
-
queryOptions?.queryKey ??
|
|
285
|
-
getAppApiProductGetUnitProductQueryKey(unitId, productId);
|
|
298
|
+
queryOptions?.queryKey ?? getGetProductQueryKey(unitId, productId);
|
|
286
299
|
|
|
287
|
-
const queryFn: QueryFunction<
|
|
288
|
-
|
|
289
|
-
> = () => appApiProductGetUnitProduct(unitId, productId, axiosOptions);
|
|
300
|
+
const queryFn: QueryFunction<AsyncReturnType<typeof getProduct>> = () =>
|
|
301
|
+
getProduct(unitId, productId, requestOptions);
|
|
290
302
|
|
|
291
|
-
const query = useQuery<
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
303
|
+
const query = useQuery<AsyncReturnType<typeof getProduct>, TError, TData>(
|
|
304
|
+
queryKey,
|
|
305
|
+
queryFn,
|
|
306
|
+
{ enabled: !!(unitId && productId), ...queryOptions }
|
|
307
|
+
);
|
|
296
308
|
|
|
297
309
|
return {
|
|
298
310
|
queryKey,
|
|
@@ -303,45 +315,48 @@ export const useAppApiProductGetUnitProduct = <
|
|
|
303
315
|
/**
|
|
304
316
|
* @summary Deletes an existing Product
|
|
305
317
|
*/
|
|
306
|
-
export const
|
|
318
|
+
export const deleteProduct = (
|
|
307
319
|
unitId: string,
|
|
308
320
|
productId: string,
|
|
309
|
-
options?:
|
|
310
|
-
)
|
|
311
|
-
return
|
|
321
|
+
options?: SecondParameter<typeof customInstance>
|
|
322
|
+
) => {
|
|
323
|
+
return customInstance<void>(
|
|
324
|
+
{ url: `/product/unit/${unitId}/product/${productId}`, method: "delete" },
|
|
325
|
+
options
|
|
326
|
+
);
|
|
312
327
|
};
|
|
313
328
|
|
|
314
|
-
export type
|
|
315
|
-
AsyncReturnType<typeof
|
|
329
|
+
export type DeleteProductMutationResult = NonNullable<
|
|
330
|
+
AsyncReturnType<typeof deleteProduct>
|
|
316
331
|
>;
|
|
317
332
|
|
|
318
|
-
export type
|
|
333
|
+
export type DeleteProductMutationError = ErrorType<AsError>;
|
|
319
334
|
|
|
320
|
-
export const
|
|
321
|
-
TError =
|
|
335
|
+
export const useDeleteProduct = <
|
|
336
|
+
TError = ErrorType<AsError>,
|
|
322
337
|
TContext = unknown
|
|
323
338
|
>(options?: {
|
|
324
339
|
mutation?: UseMutationOptions<
|
|
325
|
-
AsyncReturnType<typeof
|
|
340
|
+
AsyncReturnType<typeof deleteProduct>,
|
|
326
341
|
TError,
|
|
327
342
|
{ unitId: string; productId: string },
|
|
328
343
|
TContext
|
|
329
344
|
>;
|
|
330
|
-
|
|
345
|
+
request?: SecondParameter<typeof customInstance>;
|
|
331
346
|
}) => {
|
|
332
|
-
const { mutation: mutationOptions,
|
|
347
|
+
const { mutation: mutationOptions, request: requestOptions } = options || {};
|
|
333
348
|
|
|
334
349
|
const mutationFn: MutationFunction<
|
|
335
|
-
AsyncReturnType<typeof
|
|
350
|
+
AsyncReturnType<typeof deleteProduct>,
|
|
336
351
|
{ unitId: string; productId: string }
|
|
337
352
|
> = (props) => {
|
|
338
353
|
const { unitId, productId } = props || {};
|
|
339
354
|
|
|
340
|
-
return
|
|
355
|
+
return deleteProduct(unitId, productId, requestOptions);
|
|
341
356
|
};
|
|
342
357
|
|
|
343
358
|
return useMutation<
|
|
344
|
-
AsyncReturnType<typeof
|
|
359
|
+
AsyncReturnType<typeof deleteProduct>,
|
|
345
360
|
TError,
|
|
346
361
|
{ unitId: string; productId: string },
|
|
347
362
|
TContext
|
|
@@ -352,50 +367,54 @@ export const useAppApiProductDelete = <
|
|
|
352
367
|
|
|
353
368
|
* @summary Adjust an existing Product
|
|
354
369
|
*/
|
|
355
|
-
export const
|
|
370
|
+
export const patchProduct = (
|
|
356
371
|
unitId: string,
|
|
357
372
|
productId: string,
|
|
358
373
|
productPatchBodyBody: ProductPatchBodyBody,
|
|
359
|
-
options?:
|
|
360
|
-
)
|
|
361
|
-
return
|
|
362
|
-
|
|
363
|
-
|
|
374
|
+
options?: SecondParameter<typeof customInstance>
|
|
375
|
+
) => {
|
|
376
|
+
return customInstance<void>(
|
|
377
|
+
{
|
|
378
|
+
url: `/product/unit/${unitId}/product/${productId}`,
|
|
379
|
+
method: "patch",
|
|
380
|
+
headers: { "Content-Type": "application/json" },
|
|
381
|
+
data: productPatchBodyBody,
|
|
382
|
+
},
|
|
364
383
|
options
|
|
365
384
|
);
|
|
366
385
|
};
|
|
367
386
|
|
|
368
|
-
export type
|
|
369
|
-
AsyncReturnType<typeof
|
|
387
|
+
export type PatchProductMutationResult = NonNullable<
|
|
388
|
+
AsyncReturnType<typeof patchProduct>
|
|
370
389
|
>;
|
|
371
|
-
export type
|
|
372
|
-
export type
|
|
390
|
+
export type PatchProductMutationBody = ProductPatchBodyBody;
|
|
391
|
+
export type PatchProductMutationError = ErrorType<AsError>;
|
|
373
392
|
|
|
374
|
-
export const
|
|
375
|
-
TError =
|
|
393
|
+
export const usePatchProduct = <
|
|
394
|
+
TError = ErrorType<AsError>,
|
|
376
395
|
TContext = unknown
|
|
377
396
|
>(options?: {
|
|
378
397
|
mutation?: UseMutationOptions<
|
|
379
|
-
AsyncReturnType<typeof
|
|
398
|
+
AsyncReturnType<typeof patchProduct>,
|
|
380
399
|
TError,
|
|
381
400
|
{ unitId: string; productId: string; data: ProductPatchBodyBody },
|
|
382
401
|
TContext
|
|
383
402
|
>;
|
|
384
|
-
|
|
403
|
+
request?: SecondParameter<typeof customInstance>;
|
|
385
404
|
}) => {
|
|
386
|
-
const { mutation: mutationOptions,
|
|
405
|
+
const { mutation: mutationOptions, request: requestOptions } = options || {};
|
|
387
406
|
|
|
388
407
|
const mutationFn: MutationFunction<
|
|
389
|
-
AsyncReturnType<typeof
|
|
408
|
+
AsyncReturnType<typeof patchProduct>,
|
|
390
409
|
{ unitId: string; productId: string; data: ProductPatchBodyBody }
|
|
391
410
|
> = (props) => {
|
|
392
411
|
const { unitId, productId, data } = props || {};
|
|
393
412
|
|
|
394
|
-
return
|
|
413
|
+
return patchProduct(unitId, productId, data, requestOptions);
|
|
395
414
|
};
|
|
396
415
|
|
|
397
416
|
return useMutation<
|
|
398
|
-
AsyncReturnType<typeof
|
|
417
|
+
AsyncReturnType<typeof patchProduct>,
|
|
399
418
|
TError,
|
|
400
419
|
{ unitId: string; productId: string; data: ProductPatchBodyBody },
|
|
401
420
|
TContext
|