@squonk/account-server-client 0.1.24-rc.1 → 0.1.27-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/{custom-instance-4a108741.d.ts → account-server-api.schemas-e6c5f956.d.ts} +15 -20
- package/{chunk-JR7F532L.js → chunk-GWBPVOL2.js} +2 -23
- package/chunk-GWBPVOL2.js.map +1 -0
- package/chunk-N3RLW53G.cjs +25 -0
- package/chunk-N3RLW53G.cjs.map +1 -0
- package/index.cjs +21 -5
- package/index.cjs.map +1 -1
- package/index.d.ts +20 -2
- package/index.js +21 -5
- package/index.js.map +1 -1
- package/organisation/organisation.cjs +31 -31
- package/organisation/organisation.cjs.map +1 -1
- package/organisation/organisation.d.ts +37 -28
- package/organisation/organisation.js +38 -38
- package/organisation/organisation.js.map +1 -1
- package/package.json +14 -14
- package/product/product.cjs +64 -61
- package/product/product.cjs.map +1 -1
- package/product/product.d.ts +70 -40
- package/product/product.js +75 -72
- package/product/product.js.map +1 -1
- package/service/service.cjs +23 -21
- package/service/service.cjs.map +1 -1
- package/service/service.d.ts +19 -15
- package/service/service.js +26 -24
- package/service/service.js.map +1 -1
- package/src/account-server-api.schemas.ts +14 -1
- package/src/organisation/organisation.ts +86 -83
- package/src/product/product.ts +210 -145
- package/src/service/service.ts +64 -56
- package/src/state/state.ts +31 -32
- package/src/unit/unit.ts +170 -149
- package/src/user/user.ts +171 -160
- package/state/state.cjs +12 -12
- package/state/state.cjs.map +1 -1
- package/state/state.d.ts +12 -10
- package/state/state.js +13 -13
- package/state/state.js.map +1 -1
- package/unit/unit.cjs +54 -58
- package/unit/unit.cjs.map +1 -1
- package/unit/unit.d.ts +64 -49
- package/unit/unit.js +67 -71
- package/unit/unit.js.map +1 -1
- package/user/user.cjs +56 -56
- package/user/user.cjs.map +1 -1
- package/user/user.d.ts +69 -55
- package/user/user.js +69 -69
- package/user/user.js.map +1 -1
- package/chunk-3DXYUDZH.cjs +0 -46
- package/chunk-3DXYUDZH.cjs.map +0 -1
- package/chunk-JR7F532L.js.map +0 -1
package/src/product/product.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Generated by orval v6.
|
|
2
|
+
* Generated by orval v6.7.1 🍺
|
|
3
3
|
* Do not edit manually.
|
|
4
4
|
* Account Server API
|
|
5
5
|
* The Informatics Matters Account Server API.
|
|
@@ -8,6 +8,7 @@ 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";
|
|
11
12
|
import {
|
|
12
13
|
useQuery,
|
|
13
14
|
useMutation,
|
|
@@ -27,7 +28,6 @@ import type {
|
|
|
27
28
|
ProductUnitGetResponse,
|
|
28
29
|
ProductPatchBodyBody,
|
|
29
30
|
} 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,50 +36,45 @@ 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
|
-
|
|
47
39
|
/**
|
|
48
40
|
* Gets product types you can purchase
|
|
49
41
|
|
|
50
42
|
* @summary Gets all Product Types
|
|
51
43
|
*/
|
|
52
|
-
export const
|
|
53
|
-
options?:
|
|
54
|
-
) => {
|
|
55
|
-
return
|
|
56
|
-
{ url: `/product-type`, method: "get" },
|
|
57
|
-
options
|
|
58
|
-
);
|
|
44
|
+
export const appApiProductGetTypes = (
|
|
45
|
+
options?: AxiosRequestConfig
|
|
46
|
+
): Promise<AxiosResponse<ProductsGetTypesResponse>> => {
|
|
47
|
+
return axios.get(`/product-type`, options);
|
|
59
48
|
};
|
|
60
49
|
|
|
61
|
-
export const
|
|
50
|
+
export const getAppApiProductGetTypesQueryKey = () => [`/product-type`];
|
|
62
51
|
|
|
63
|
-
export
|
|
64
|
-
|
|
65
|
-
|
|
52
|
+
export type AppApiProductGetTypesQueryResult = NonNullable<
|
|
53
|
+
AsyncReturnType<typeof appApiProductGetTypes>
|
|
54
|
+
>;
|
|
55
|
+
export type AppApiProductGetTypesQueryError = AxiosError<AsError | void>;
|
|
56
|
+
|
|
57
|
+
export const useAppApiProductGetTypes = <
|
|
58
|
+
TData = AsyncReturnType<typeof appApiProductGetTypes>,
|
|
59
|
+
TError = AxiosError<AsError | void>
|
|
66
60
|
>(options?: {
|
|
67
61
|
query?: UseQueryOptions<
|
|
68
|
-
AsyncReturnType<typeof
|
|
62
|
+
AsyncReturnType<typeof appApiProductGetTypes>,
|
|
69
63
|
TError,
|
|
70
64
|
TData
|
|
71
65
|
>;
|
|
72
|
-
|
|
66
|
+
axios?: AxiosRequestConfig;
|
|
73
67
|
}): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
74
|
-
const { query: queryOptions,
|
|
68
|
+
const { query: queryOptions, axios: axiosOptions } = options || {};
|
|
75
69
|
|
|
76
|
-
const queryKey = queryOptions?.queryKey ??
|
|
70
|
+
const queryKey = queryOptions?.queryKey ?? getAppApiProductGetTypesQueryKey();
|
|
77
71
|
|
|
78
|
-
const queryFn: QueryFunction<
|
|
79
|
-
|
|
72
|
+
const queryFn: QueryFunction<
|
|
73
|
+
AsyncReturnType<typeof appApiProductGetTypes>
|
|
74
|
+
> = () => appApiProductGetTypes(axiosOptions);
|
|
80
75
|
|
|
81
76
|
const query = useQuery<
|
|
82
|
-
AsyncReturnType<typeof
|
|
77
|
+
AsyncReturnType<typeof appApiProductGetTypes>,
|
|
83
78
|
TError,
|
|
84
79
|
TData
|
|
85
80
|
>(queryKey, queryFn, queryOptions);
|
|
@@ -95,36 +90,42 @@ export const useGetProductTypes = <
|
|
|
95
90
|
|
|
96
91
|
* @summary Gets all Products
|
|
97
92
|
*/
|
|
98
|
-
export const
|
|
99
|
-
options?:
|
|
100
|
-
) => {
|
|
101
|
-
return
|
|
102
|
-
{ url: `/product`, method: "get" },
|
|
103
|
-
options
|
|
104
|
-
);
|
|
93
|
+
export const appApiProductGet = (
|
|
94
|
+
options?: AxiosRequestConfig
|
|
95
|
+
): Promise<AxiosResponse<ProductsGetResponse>> => {
|
|
96
|
+
return axios.get(`/product`, options);
|
|
105
97
|
};
|
|
106
98
|
|
|
107
|
-
export const
|
|
99
|
+
export const getAppApiProductGetQueryKey = () => [`/product`];
|
|
108
100
|
|
|
109
|
-
export
|
|
110
|
-
|
|
111
|
-
|
|
101
|
+
export type AppApiProductGetQueryResult = NonNullable<
|
|
102
|
+
AsyncReturnType<typeof appApiProductGet>
|
|
103
|
+
>;
|
|
104
|
+
export type AppApiProductGetQueryError = AxiosError<AsError | void>;
|
|
105
|
+
|
|
106
|
+
export const useAppApiProductGet = <
|
|
107
|
+
TData = AsyncReturnType<typeof appApiProductGet>,
|
|
108
|
+
TError = AxiosError<AsError | void>
|
|
112
109
|
>(options?: {
|
|
113
|
-
query?: UseQueryOptions<
|
|
114
|
-
|
|
110
|
+
query?: UseQueryOptions<
|
|
111
|
+
AsyncReturnType<typeof appApiProductGet>,
|
|
112
|
+
TError,
|
|
113
|
+
TData
|
|
114
|
+
>;
|
|
115
|
+
axios?: AxiosRequestConfig;
|
|
115
116
|
}): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
116
|
-
const { query: queryOptions,
|
|
117
|
+
const { query: queryOptions, axios: axiosOptions } = options || {};
|
|
117
118
|
|
|
118
|
-
const queryKey = queryOptions?.queryKey ??
|
|
119
|
+
const queryKey = queryOptions?.queryKey ?? getAppApiProductGetQueryKey();
|
|
119
120
|
|
|
120
|
-
const queryFn: QueryFunction<AsyncReturnType<typeof
|
|
121
|
-
|
|
121
|
+
const queryFn: QueryFunction<AsyncReturnType<typeof appApiProductGet>> = () =>
|
|
122
|
+
appApiProductGet(axiosOptions);
|
|
122
123
|
|
|
123
|
-
const query = useQuery<
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
);
|
|
124
|
+
const query = useQuery<
|
|
125
|
+
AsyncReturnType<typeof appApiProductGet>,
|
|
126
|
+
TError,
|
|
127
|
+
TData
|
|
128
|
+
>(queryKey, queryFn, queryOptions);
|
|
128
129
|
|
|
129
130
|
return {
|
|
130
131
|
queryKey,
|
|
@@ -135,48 +136,51 @@ export const useGetProducts = <
|
|
|
135
136
|
/**
|
|
136
137
|
* @summary Creates a Product for an Organisational Unit
|
|
137
138
|
*/
|
|
138
|
-
export const
|
|
139
|
-
|
|
139
|
+
export const appApiProductPost = (
|
|
140
|
+
unitId: string,
|
|
140
141
|
unitProductPostBodyBody: UnitProductPostBodyBody,
|
|
141
|
-
options?:
|
|
142
|
-
) => {
|
|
143
|
-
return
|
|
144
|
-
{
|
|
145
|
-
|
|
146
|
-
method: "post",
|
|
147
|
-
data: unitProductPostBodyBody,
|
|
148
|
-
},
|
|
142
|
+
options?: AxiosRequestConfig
|
|
143
|
+
): Promise<AxiosResponse<UnitProductPostResponse>> => {
|
|
144
|
+
return axios.post(
|
|
145
|
+
`/product/unit/${unitId}`,
|
|
146
|
+
unitProductPostBodyBody,
|
|
149
147
|
options
|
|
150
148
|
);
|
|
151
149
|
};
|
|
152
150
|
|
|
153
|
-
export
|
|
154
|
-
|
|
151
|
+
export type AppApiProductPostMutationResult = NonNullable<
|
|
152
|
+
AsyncReturnType<typeof appApiProductPost>
|
|
153
|
+
>;
|
|
154
|
+
export type AppApiProductPostMutationBody = UnitProductPostBodyBody;
|
|
155
|
+
export type AppApiProductPostMutationError = AxiosError<AsError | void>;
|
|
156
|
+
|
|
157
|
+
export const useAppApiProductPost = <
|
|
158
|
+
TError = AxiosError<AsError | void>,
|
|
155
159
|
TContext = unknown
|
|
156
160
|
>(options?: {
|
|
157
161
|
mutation?: UseMutationOptions<
|
|
158
|
-
AsyncReturnType<typeof
|
|
162
|
+
AsyncReturnType<typeof appApiProductPost>,
|
|
159
163
|
TError,
|
|
160
|
-
{
|
|
164
|
+
{ unitId: string; data: UnitProductPostBodyBody },
|
|
161
165
|
TContext
|
|
162
166
|
>;
|
|
163
|
-
|
|
167
|
+
axios?: AxiosRequestConfig;
|
|
164
168
|
}) => {
|
|
165
|
-
const { mutation: mutationOptions,
|
|
169
|
+
const { mutation: mutationOptions, axios: axiosOptions } = options || {};
|
|
166
170
|
|
|
167
171
|
const mutationFn: MutationFunction<
|
|
168
|
-
AsyncReturnType<typeof
|
|
169
|
-
{
|
|
172
|
+
AsyncReturnType<typeof appApiProductPost>,
|
|
173
|
+
{ unitId: string; data: UnitProductPostBodyBody }
|
|
170
174
|
> = (props) => {
|
|
171
|
-
const {
|
|
175
|
+
const { unitId, data } = props || {};
|
|
172
176
|
|
|
173
|
-
return
|
|
177
|
+
return appApiProductPost(unitId, data, axiosOptions);
|
|
174
178
|
};
|
|
175
179
|
|
|
176
180
|
return useMutation<
|
|
177
|
-
AsyncReturnType<typeof
|
|
181
|
+
AsyncReturnType<typeof appApiProductPost>,
|
|
178
182
|
TError,
|
|
179
|
-
{
|
|
183
|
+
{ unitId: string; data: UnitProductPostBodyBody },
|
|
180
184
|
TContext
|
|
181
185
|
>(mutationFn, mutationOptions);
|
|
182
186
|
};
|
|
@@ -185,48 +189,50 @@ export const useCreateUnitProduct = <
|
|
|
185
189
|
|
|
186
190
|
* @summary Gets Products for an Organisational Unit
|
|
187
191
|
*/
|
|
188
|
-
export const
|
|
189
|
-
|
|
190
|
-
options?:
|
|
191
|
-
) => {
|
|
192
|
-
return
|
|
193
|
-
{ url: `/product/unit/${unitid}`, method: "get" },
|
|
194
|
-
options
|
|
195
|
-
);
|
|
192
|
+
export const appApiProductGetForUnit = (
|
|
193
|
+
unitId: string,
|
|
194
|
+
options?: AxiosRequestConfig
|
|
195
|
+
): Promise<AxiosResponse<ProductsGetResponse>> => {
|
|
196
|
+
return axios.get(`/product/unit/${unitId}`, options);
|
|
196
197
|
};
|
|
197
198
|
|
|
198
|
-
export const
|
|
199
|
-
`/product/unit/${
|
|
199
|
+
export const getAppApiProductGetForUnitQueryKey = (unitId: string) => [
|
|
200
|
+
`/product/unit/${unitId}`,
|
|
200
201
|
];
|
|
201
202
|
|
|
202
|
-
export
|
|
203
|
-
|
|
204
|
-
|
|
203
|
+
export type AppApiProductGetForUnitQueryResult = NonNullable<
|
|
204
|
+
AsyncReturnType<typeof appApiProductGetForUnit>
|
|
205
|
+
>;
|
|
206
|
+
export type AppApiProductGetForUnitQueryError = AxiosError<void | AsError>;
|
|
207
|
+
|
|
208
|
+
export const useAppApiProductGetForUnit = <
|
|
209
|
+
TData = AsyncReturnType<typeof appApiProductGetForUnit>,
|
|
210
|
+
TError = AxiosError<void | AsError>
|
|
205
211
|
>(
|
|
206
|
-
|
|
212
|
+
unitId: string,
|
|
207
213
|
options?: {
|
|
208
214
|
query?: UseQueryOptions<
|
|
209
|
-
AsyncReturnType<typeof
|
|
215
|
+
AsyncReturnType<typeof appApiProductGetForUnit>,
|
|
210
216
|
TError,
|
|
211
217
|
TData
|
|
212
218
|
>;
|
|
213
|
-
|
|
219
|
+
axios?: AxiosRequestConfig;
|
|
214
220
|
}
|
|
215
221
|
): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
216
|
-
const { query: queryOptions,
|
|
222
|
+
const { query: queryOptions, axios: axiosOptions } = options || {};
|
|
217
223
|
|
|
218
224
|
const queryKey =
|
|
219
|
-
queryOptions?.queryKey ??
|
|
225
|
+
queryOptions?.queryKey ?? getAppApiProductGetForUnitQueryKey(unitId);
|
|
220
226
|
|
|
221
227
|
const queryFn: QueryFunction<
|
|
222
|
-
AsyncReturnType<typeof
|
|
223
|
-
> = () =>
|
|
228
|
+
AsyncReturnType<typeof appApiProductGetForUnit>
|
|
229
|
+
> = () => appApiProductGetForUnit(unitId, axiosOptions);
|
|
224
230
|
|
|
225
231
|
const query = useQuery<
|
|
226
|
-
AsyncReturnType<typeof
|
|
232
|
+
AsyncReturnType<typeof appApiProductGetForUnit>,
|
|
227
233
|
TError,
|
|
228
234
|
TData
|
|
229
|
-
>(queryKey, queryFn, { enabled: !!
|
|
235
|
+
>(queryKey, queryFn, { enabled: !!unitId, ...queryOptions });
|
|
230
236
|
|
|
231
237
|
return {
|
|
232
238
|
queryKey,
|
|
@@ -239,45 +245,54 @@ export const useGetProductsForUnit = <
|
|
|
239
245
|
|
|
240
246
|
* @summary Gets a Unit's Product
|
|
241
247
|
*/
|
|
242
|
-
export const
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
options?:
|
|
246
|
-
) => {
|
|
247
|
-
return
|
|
248
|
-
{ url: `/product/unit/${unitid}/product/${productid}`, method: "get" },
|
|
249
|
-
options
|
|
250
|
-
);
|
|
248
|
+
export const appApiProductGetUnitProduct = (
|
|
249
|
+
unitId: string,
|
|
250
|
+
productId: string,
|
|
251
|
+
options?: AxiosRequestConfig
|
|
252
|
+
): Promise<AxiosResponse<ProductUnitGetResponse>> => {
|
|
253
|
+
return axios.get(`/product/unit/${unitId}/product/${productId}`, options);
|
|
251
254
|
};
|
|
252
255
|
|
|
253
|
-
export const
|
|
254
|
-
|
|
255
|
-
|
|
256
|
+
export const getAppApiProductGetUnitProductQueryKey = (
|
|
257
|
+
unitId: string,
|
|
258
|
+
productId: string
|
|
259
|
+
) => [`/product/unit/${unitId}/product/${productId}`];
|
|
256
260
|
|
|
257
|
-
export
|
|
258
|
-
|
|
259
|
-
|
|
261
|
+
export type AppApiProductGetUnitProductQueryResult = NonNullable<
|
|
262
|
+
AsyncReturnType<typeof appApiProductGetUnitProduct>
|
|
263
|
+
>;
|
|
264
|
+
export type AppApiProductGetUnitProductQueryError = AxiosError<AsError | void>;
|
|
265
|
+
|
|
266
|
+
export const useAppApiProductGetUnitProduct = <
|
|
267
|
+
TData = AsyncReturnType<typeof appApiProductGetUnitProduct>,
|
|
268
|
+
TError = AxiosError<AsError | void>
|
|
260
269
|
>(
|
|
261
|
-
|
|
262
|
-
|
|
270
|
+
unitId: string,
|
|
271
|
+
productId: string,
|
|
263
272
|
options?: {
|
|
264
|
-
query?: UseQueryOptions<
|
|
265
|
-
|
|
273
|
+
query?: UseQueryOptions<
|
|
274
|
+
AsyncReturnType<typeof appApiProductGetUnitProduct>,
|
|
275
|
+
TError,
|
|
276
|
+
TData
|
|
277
|
+
>;
|
|
278
|
+
axios?: AxiosRequestConfig;
|
|
266
279
|
}
|
|
267
280
|
): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
268
|
-
const { query: queryOptions,
|
|
281
|
+
const { query: queryOptions, axios: axiosOptions } = options || {};
|
|
269
282
|
|
|
270
283
|
const queryKey =
|
|
271
|
-
queryOptions?.queryKey ??
|
|
284
|
+
queryOptions?.queryKey ??
|
|
285
|
+
getAppApiProductGetUnitProductQueryKey(unitId, productId);
|
|
272
286
|
|
|
273
|
-
const queryFn: QueryFunction<
|
|
274
|
-
|
|
287
|
+
const queryFn: QueryFunction<
|
|
288
|
+
AsyncReturnType<typeof appApiProductGetUnitProduct>
|
|
289
|
+
> = () => appApiProductGetUnitProduct(unitId, productId, axiosOptions);
|
|
275
290
|
|
|
276
|
-
const query = useQuery<
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
);
|
|
291
|
+
const query = useQuery<
|
|
292
|
+
AsyncReturnType<typeof appApiProductGetUnitProduct>,
|
|
293
|
+
TError,
|
|
294
|
+
TData
|
|
295
|
+
>(queryKey, queryFn, { enabled: !!(unitId && productId), ...queryOptions });
|
|
281
296
|
|
|
282
297
|
return {
|
|
283
298
|
queryKey,
|
|
@@ -285,54 +300,104 @@ export const useGetProduct = <
|
|
|
285
300
|
};
|
|
286
301
|
};
|
|
287
302
|
|
|
303
|
+
/**
|
|
304
|
+
* @summary Deletes an existing Product
|
|
305
|
+
*/
|
|
306
|
+
export const appApiProductDelete = (
|
|
307
|
+
unitId: string,
|
|
308
|
+
productId: string,
|
|
309
|
+
options?: AxiosRequestConfig
|
|
310
|
+
): Promise<AxiosResponse<void>> => {
|
|
311
|
+
return axios.delete(`/product/unit/${unitId}/product/${productId}`, options);
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
export type AppApiProductDeleteMutationResult = NonNullable<
|
|
315
|
+
AsyncReturnType<typeof appApiProductDelete>
|
|
316
|
+
>;
|
|
317
|
+
|
|
318
|
+
export type AppApiProductDeleteMutationError = AxiosError<AsError>;
|
|
319
|
+
|
|
320
|
+
export const useAppApiProductDelete = <
|
|
321
|
+
TError = AxiosError<AsError>,
|
|
322
|
+
TContext = unknown
|
|
323
|
+
>(options?: {
|
|
324
|
+
mutation?: UseMutationOptions<
|
|
325
|
+
AsyncReturnType<typeof appApiProductDelete>,
|
|
326
|
+
TError,
|
|
327
|
+
{ unitId: string; productId: string },
|
|
328
|
+
TContext
|
|
329
|
+
>;
|
|
330
|
+
axios?: AxiosRequestConfig;
|
|
331
|
+
}) => {
|
|
332
|
+
const { mutation: mutationOptions, axios: axiosOptions } = options || {};
|
|
333
|
+
|
|
334
|
+
const mutationFn: MutationFunction<
|
|
335
|
+
AsyncReturnType<typeof appApiProductDelete>,
|
|
336
|
+
{ unitId: string; productId: string }
|
|
337
|
+
> = (props) => {
|
|
338
|
+
const { unitId, productId } = props || {};
|
|
339
|
+
|
|
340
|
+
return appApiProductDelete(unitId, productId, axiosOptions);
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
return useMutation<
|
|
344
|
+
AsyncReturnType<typeof appApiProductDelete>,
|
|
345
|
+
TError,
|
|
346
|
+
{ unitId: string; productId: string },
|
|
347
|
+
TContext
|
|
348
|
+
>(mutationFn, mutationOptions);
|
|
349
|
+
};
|
|
288
350
|
/**
|
|
289
351
|
* Used to update some adjustable parameters of a Product, i.e. to extend the Allowance or Limit. At the moment Data Manager products can be patched by changing the `name`, it's coin `allowance` or `limit`
|
|
290
352
|
|
|
291
353
|
* @summary Adjust an existing Product
|
|
292
354
|
*/
|
|
293
|
-
export const
|
|
294
|
-
|
|
295
|
-
|
|
355
|
+
export const appApiProductPatch = (
|
|
356
|
+
unitId: string,
|
|
357
|
+
productId: string,
|
|
296
358
|
productPatchBodyBody: ProductPatchBodyBody,
|
|
297
|
-
options?:
|
|
298
|
-
) => {
|
|
299
|
-
return
|
|
300
|
-
{
|
|
301
|
-
|
|
302
|
-
method: "patch",
|
|
303
|
-
data: productPatchBodyBody,
|
|
304
|
-
},
|
|
359
|
+
options?: AxiosRequestConfig
|
|
360
|
+
): Promise<AxiosResponse<void>> => {
|
|
361
|
+
return axios.patch(
|
|
362
|
+
`/product/unit/${unitId}/product/${productId}`,
|
|
363
|
+
productPatchBodyBody,
|
|
305
364
|
options
|
|
306
365
|
);
|
|
307
366
|
};
|
|
308
367
|
|
|
309
|
-
export
|
|
310
|
-
|
|
368
|
+
export type AppApiProductPatchMutationResult = NonNullable<
|
|
369
|
+
AsyncReturnType<typeof appApiProductPatch>
|
|
370
|
+
>;
|
|
371
|
+
export type AppApiProductPatchMutationBody = ProductPatchBodyBody;
|
|
372
|
+
export type AppApiProductPatchMutationError = AxiosError<AsError>;
|
|
373
|
+
|
|
374
|
+
export const useAppApiProductPatch = <
|
|
375
|
+
TError = AxiosError<AsError>,
|
|
311
376
|
TContext = unknown
|
|
312
377
|
>(options?: {
|
|
313
378
|
mutation?: UseMutationOptions<
|
|
314
|
-
AsyncReturnType<typeof
|
|
379
|
+
AsyncReturnType<typeof appApiProductPatch>,
|
|
315
380
|
TError,
|
|
316
|
-
{
|
|
381
|
+
{ unitId: string; productId: string; data: ProductPatchBodyBody },
|
|
317
382
|
TContext
|
|
318
383
|
>;
|
|
319
|
-
|
|
384
|
+
axios?: AxiosRequestConfig;
|
|
320
385
|
}) => {
|
|
321
|
-
const { mutation: mutationOptions,
|
|
386
|
+
const { mutation: mutationOptions, axios: axiosOptions } = options || {};
|
|
322
387
|
|
|
323
388
|
const mutationFn: MutationFunction<
|
|
324
|
-
AsyncReturnType<typeof
|
|
325
|
-
{
|
|
389
|
+
AsyncReturnType<typeof appApiProductPatch>,
|
|
390
|
+
{ unitId: string; productId: string; data: ProductPatchBodyBody }
|
|
326
391
|
> = (props) => {
|
|
327
|
-
const {
|
|
392
|
+
const { unitId, productId, data } = props || {};
|
|
328
393
|
|
|
329
|
-
return
|
|
394
|
+
return appApiProductPatch(unitId, productId, data, axiosOptions);
|
|
330
395
|
};
|
|
331
396
|
|
|
332
397
|
return useMutation<
|
|
333
|
-
AsyncReturnType<typeof
|
|
398
|
+
AsyncReturnType<typeof appApiProductPatch>,
|
|
334
399
|
TError,
|
|
335
|
-
{
|
|
400
|
+
{ unitId: string; productId: string; data: ProductPatchBodyBody },
|
|
336
401
|
TContext
|
|
337
402
|
>(mutationFn, mutationOptions);
|
|
338
403
|
};
|