|
1
|
import { FetchError } from "@medusajs/js-sdk" |
|
2
|
import { HttpTypes } from "@medusajs/types" |
|
3
|
import { |
|
4
|
QueryKey, |
|
5
|
useMutation, |
|
6
|
UseMutationOptions, |
|
7
|
useQuery, |
|
8
|
UseQueryOptions, |
|
9
|
} from "@tanstack/react-query" |
|
10
|
|
|
11
|
import { sdk } from "../../lib/client" |
|
12
|
import { queryClient } from "../../lib/query-client" |
|
13
|
import { queryKeysFactory } from "../../lib/query-key-factory" |
|
14
|
import { ordersQueryKeys } from "./orders" |
|
15
|
import { returnsQueryKeys } from "./returns" |
|
16
|
|
|
17
|
const CLAIMS_QUERY_KEY = "claims" as const |
|
18
|
export const claimsQueryKeys = queryKeysFactory(CLAIMS_QUERY_KEY) |
|
19
|
|
|
20
|
export const useClaim = ( |
|
21
|
id: string, |
|
22
|
query?: HttpTypes.AdminClaimListParams, |
|
23
|
options?: Omit< |
|
24
|
UseQueryOptions< |
|
25
|
HttpTypes.AdminClaimResponse, |
|
26
|
FetchError, |
|
27
|
HttpTypes.AdminClaimResponse, |
|
28
|
QueryKey |
|
29
|
>, |
|
30
|
"queryFn" | "queryKey" |
|
31
|
> |
|
32
|
) => { |
|
33
|
const { data, ...rest } = useQuery({ |
|
34
|
queryFn: async () => sdk.admin.claim.retrieve(id, query), |
|
35
|
queryKey: claimsQueryKeys.detail(id, query), |
|
36
|
...options, |
|
37
|
}) |
|
38
|
|
|
39
|
return { ...data, ...rest } |
|
40
|
} |
|
41
|
|
|
42
|
export const useClaims = ( |
|
43
|
query?: HttpTypes.AdminClaimListParams, |
|
44
|
options?: Omit< |
|
45
|
UseQueryOptions< |
|
46
|
HttpTypes.AdminClaimListParams, |
|
47
|
FetchError, |
|
48
|
HttpTypes.AdminClaimListResponse, |
|
49
|
QueryKey |
|
50
|
>, |
|
51
|
"queryFn" | "queryKey" |
|
52
|
> |
|
53
|
) => { |
|
54
|
const { data, ...rest } = useQuery({ |
|
55
|
queryFn: async () => sdk.admin.claim.list(query), |
|
56
|
queryKey: claimsQueryKeys.list(query), |
|
57
|
...options, |
|
58
|
}) |
|
59
|
|
|
60
|
return { ...data, ...rest } |
|
61
|
} |
|
62
|
|
|
63
|
export const useCreateClaim = ( |
|
64
|
orderId: string, |
|
65
|
options?: UseMutationOptions< |
|
66
|
HttpTypes.AdminClaimResponse, |
|
67
|
FetchError, |
|
68
|
HttpTypes.AdminCreateClaim |
|
69
|
> |
|
70
|
) => { |
|
71
|
return useMutation({ |
|
72
|
mutationFn: (payload: HttpTypes.AdminCreateClaim) => |
|
73
|
sdk.admin.claim.create(payload), |
|
74
|
onSuccess: (data: any, variables: any, context: any) => { |
|
75
|
queryClient.invalidateQueries({ |
|
76
|
queryKey: ordersQueryKeys.details(), |
|
77
|
}) |
|
78
|
|
|
79
|
queryClient.invalidateQueries({ |
|
80
|
queryKey: ordersQueryKeys.preview(orderId), |
|
81
|
}) |
|
82
|
|
|
83
|
queryClient.invalidateQueries({ |
|
84
|
queryKey: claimsQueryKeys.lists(), |
|
85
|
}) |
|
86
|
|
|
87
|
options?.onSuccess?.(data, variables, context) |
|
88
|
}, |
|
89
|
...options, |
|
90
|
}) |
|
91
|
} |
|
92
|
|
|
93
|
export const useCancelClaim = ( |
|
94
|
id: string, |
|
95
|
orderId: string, |
|
96
|
options?: UseMutationOptions<HttpTypes.AdminClaimResponse, FetchError> |
|
97
|
) => { |
|
98
|
return useMutation({ |
|
99
|
mutationFn: () => sdk.admin.claim.cancel(id), |
|
100
|
onSuccess: (data: any, variables: any, context: any) => { |
|
101
|
queryClient.invalidateQueries({ |
|
102
|
queryKey: ordersQueryKeys.details(), |
|
103
|
}) |
|
104
|
|
|
105
|
queryClient.invalidateQueries({ |
|
106
|
queryKey: ordersQueryKeys.preview(orderId), |
|
107
|
}) |
|
108
|
|
|
109
|
queryClient.invalidateQueries({ |
|
110
|
queryKey: claimsQueryKeys.details(), |
|
111
|
}) |
|
112
|
|
|
113
|
queryClient.invalidateQueries({ |
|
114
|
queryKey: claimsQueryKeys.lists(), |
|
115
|
}) |
|
116
|
options?.onSuccess?.(data, variables, context) |
|
117
|
}, |
|
118
|
...options, |
|
119
|
}) |
|
120
|
} |
|
121
|
|
|
122
|
export const useAddClaimItems = ( |
|
123
|
id: string, |
|
124
|
orderId: string, |
|
125
|
options?: UseMutationOptions< |
|
126
|
HttpTypes.AdminClaimResponse, |
|
127
|
FetchError, |
|
128
|
HttpTypes.AdminAddClaimItems |
|
129
|
> |
|
130
|
) => { |
|
131
|
return useMutation({ |
|
132
|
mutationFn: (payload: HttpTypes.AdminAddClaimItems) => |
|
133
|
sdk.admin.claim.addItems(id, payload), |
|
134
|
onSuccess: (data: any, variables: any, context: any) => { |
|
135
|
queryClient.invalidateQueries({ |
|
136
|
queryKey: ordersQueryKeys.details(), |
|
137
|
}) |
|
138
|
|
|
139
|
queryClient.invalidateQueries({ |
|
140
|
queryKey: ordersQueryKeys.preview(orderId), |
|
141
|
}) |
|
142
|
|
|
143
|
options?.onSuccess?.(data, variables, context) |
|
144
|
}, |
|
145
|
...options, |
|
146
|
}) |
|
147
|
} |
|
148
|
|
|
149
|
export const useUpdateClaimItems = ( |
|
150
|
id: string, |
|
151
|
orderId: string, |
|
152
|
options?: UseMutationOptions< |
|
153
|
HttpTypes.AdminClaimResponse, |
|
154
|
FetchError, |
|
155
|
HttpTypes.AdminUpdateClaimItem & { actionId: string } |
|
156
|
> |
|
157
|
) => { |
|
158
|
return useMutation({ |
|
159
|
mutationFn: ({ |
|
160
|
actionId, |
|
161
|
...payload |
|
162
|
}: HttpTypes.AdminUpdateClaimItem & { actionId: string }) => { |
|
163
|
return sdk.admin.claim.updateItem(id, actionId, payload) |
|
164
|
}, |
|
165
|
onSuccess: (data: any, variables: any, context: any) => { |
|
166
|
queryClient.invalidateQueries({ |
|
167
|
queryKey: ordersQueryKeys.details(), |
|
168
|
}) |
|
169
|
|
|
170
|
queryClient.invalidateQueries({ |
|
171
|
queryKey: ordersQueryKeys.preview(orderId), |
|
172
|
}) |
|
173
|
|
|
174
|
options?.onSuccess?.(data, variables, context) |
|
175
|
}, |
|
176
|
...options, |
|
177
|
}) |
|
178
|
} |
|
179
|
|
|
180
|
export const useRemoveClaimItem = ( |
|
181
|
id: string, |
|
182
|
orderId: string, |
|
183
|
options?: UseMutationOptions< |
|
184
|
HttpTypes.AdminReturnResponse, |
|
185
|
FetchError, |
|
186
|
string |
|
187
|
> |
|
188
|
) => { |
|
189
|
return useMutation({ |
|
190
|
mutationFn: (actionId: string) => |
|
191
|
sdk.admin.return.removeReturnItem(id, actionId), |
|
192
|
onSuccess: (data: any, variables: any, context: any) => { |
|
193
|
queryClient.invalidateQueries({ |
|
194
|
queryKey: ordersQueryKeys.details(), |
|
195
|
}) |
|
196
|
|
|
197
|
queryClient.invalidateQueries({ |
|
198
|
queryKey: ordersQueryKeys.preview(orderId), |
|
199
|
}) |
|
200
|
|
|
201
|
options?.onSuccess?.(data, variables, context) |
|
202
|
}, |
|
203
|
...options, |
|
204
|
}) |
|
205
|
} |
|
206
|
|
|
207
|
export const useAddClaimInboundItems = ( |
|
208
|
id: string, |
|
209
|
orderId: string, |
|
210
|
options?: UseMutationOptions< |
|
211
|
HttpTypes.AdminClaimReturnPreviewResponse, |
|
212
|
FetchError, |
|
213
|
HttpTypes.AdminAddClaimInboundItems |
|
214
|
> |
|
215
|
) => { |
|
216
|
return useMutation({ |
|
217
|
mutationFn: (payload) => sdk.admin.claim.addInboundItems(id, payload), |
|
218
|
onSuccess: (data: any, variables: any, context: any) => { |
|
219
|
queryClient.invalidateQueries({ |
|
220
|
queryKey: ordersQueryKeys.details(), |
|
221
|
}) |
|
222
|
|
|
223
|
queryClient.invalidateQueries({ |
|
224
|
queryKey: ordersQueryKeys.preview(orderId), |
|
225
|
}) |
|
226
|
|
|
227
|
options?.onSuccess?.(data, variables, context) |
|
228
|
}, |
|
229
|
...options, |
|
230
|
}) |
|
231
|
} |
|
232
|
|
|
233
|
export const useUpdateClaimInboundItem = ( |
|
234
|
id: string, |
|
235
|
orderId: string, |
|
236
|
options?: UseMutationOptions< |
|
237
|
HttpTypes.AdminClaimReturnPreviewResponse, |
|
238
|
FetchError, |
|
239
|
HttpTypes.AdminUpdateClaimInboundItem & { actionId: string } |
|
240
|
> |
|
241
|
) => { |
|
242
|
return useMutation({ |
|
243
|
mutationFn: ({ |
|
244
|
actionId, |
|
245
|
...payload |
|
246
|
}: HttpTypes.AdminUpdateClaimInboundItem & { actionId: string }) => { |
|
247
|
return sdk.admin.claim.updateInboundItem(id, actionId, payload) |
|
248
|
}, |
|
249
|
onSuccess: (data: any, variables: any, context: any) => { |
|
250
|
queryClient.invalidateQueries({ |
|
251
|
queryKey: ordersQueryKeys.details(), |
|
252
|
}) |
|
253
|
|
|
254
|
queryClient.invalidateQueries({ |
|
255
|
queryKey: ordersQueryKeys.preview(orderId), |
|
256
|
}) |
|
257
|
|
|
258
|
options?.onSuccess?.(data, variables, context) |
|
259
|
}, |
|
260
|
...options, |
|
261
|
}) |
|
262
|
} |
|
263
|
|
|
264
|
export const useRemoveClaimInboundItem = ( |
|
265
|
id: string, |
|
266
|
orderId: string, |
|
267
|
options?: UseMutationOptions< |
|
268
|
HttpTypes.AdminClaimReturnPreviewResponse, |
|
269
|
FetchError, |
|
270
|
string |
|
271
|
> |
|
272
|
) => { |
|
273
|
return useMutation({ |
|
274
|
mutationFn: (actionId: string) => |
|
275
|
sdk.admin.claim.removeInboundItem(id, actionId), |
|
276
|
onSuccess: (data: any, variables: any, context: any) => { |
|
277
|
queryClient.invalidateQueries({ |
|
278
|
queryKey: ordersQueryKeys.details(), |
|
279
|
}) |
|
280
|
|
|
281
|
queryClient.invalidateQueries({ |
|
282
|
queryKey: ordersQueryKeys.preview(orderId), |
|
283
|
}) |
|
284
|
|
|
285
|
queryClient.invalidateQueries({ |
|
286
|
queryKey: returnsQueryKeys.details(), |
|
287
|
}) |
|
288
|
|
|
289
|
options?.onSuccess?.(data, variables, context) |
|
290
|
}, |
|
291
|
...options, |
|
292
|
}) |
|
293
|
} |
|
294
|
|
|
295
|
export const useAddClaimInboundShipping = ( |
|
296
|
id: string, |
|
297
|
orderId: string, |
|
298
|
options?: UseMutationOptions< |
|
299
|
HttpTypes.AdminClaimReturnPreviewResponse, |
|
300
|
FetchError, |
|
301
|
HttpTypes.AdminClaimAddInboundShipping |
|
302
|
> |
|
303
|
) => { |
|
304
|
return useMutation({ |
|
305
|
mutationFn: (payload: HttpTypes.AdminClaimAddInboundShipping) => |
|
306
|
sdk.admin.claim.addInboundShipping(id, payload), |
|
307
|
onSuccess: (data: any, variables: any, context: any) => { |
|
308
|
queryClient.invalidateQueries({ |
|
309
|
queryKey: ordersQueryKeys.details(), |
|
310
|
}) |
|
311
|
|
|
312
|
queryClient.invalidateQueries({ |
|
313
|
queryKey: ordersQueryKeys.preview(orderId), |
|
314
|
}) |
|
315
|
|
|
316
|
options?.onSuccess?.(data, variables, context) |
|
317
|
}, |
|
318
|
...options, |
|
319
|
}) |
|
320
|
} |
|
321
|
|
|
322
|
export const useUpdateClaimInboundShipping = ( |
|
323
|
id: string, |
|
324
|
orderId: string, |
|
325
|
options?: UseMutationOptions< |
|
326
|
HttpTypes.AdminClaimPreviewResponse, |
|
327
|
FetchError, |
|
328
|
HttpTypes.AdminClaimUpdateInboundShipping & { actionId: string } |
|
329
|
> |
|
330
|
) => { |
|
331
|
return useMutation({ |
|
332
|
mutationFn: ({ |
|
333
|
actionId, |
|
334
|
...payload |
|
335
|
}: HttpTypes.AdminClaimUpdateInboundShipping & { actionId: string }) => |
|
336
|
sdk.admin.claim.updateInboundShipping(id, actionId, payload), |
|
337
|
onSuccess: (data: any, variables: any, context: any) => { |
|
338
|
queryClient.invalidateQueries({ |
|
339
|
queryKey: ordersQueryKeys.details(), |
|
340
|
}) |
|
341
|
|
|
342
|
queryClient.invalidateQueries({ |
|
343
|
queryKey: ordersQueryKeys.preview(orderId), |
|
344
|
}) |
|
345
|
|
|
346
|
options?.onSuccess?.(data, variables, context) |
|
347
|
}, |
|
348
|
...options, |
|
349
|
}) |
|
350
|
} |
|
351
|
|
|
352
|
export const useDeleteClaimInboundShipping = ( |
|
353
|
id: string, |
|
354
|
orderId: string, |
|
355
|
options?: UseMutationOptions< |
|
356
|
HttpTypes.AdminClaimReturnPreviewResponse, |
|
357
|
FetchError, |
|
358
|
string |
|
359
|
> |
|
360
|
) => { |
|
361
|
return useMutation({ |
|
362
|
mutationFn: (actionId: string) => |
|
363
|
sdk.admin.claim.deleteInboundShipping(id, actionId), |
|
364
|
onSuccess: (data: any, variables: any, context: any) => { |
|
365
|
queryClient.invalidateQueries({ |
|
366
|
queryKey: ordersQueryKeys.details(), |
|
367
|
}) |
|
368
|
|
|
369
|
queryClient.invalidateQueries({ |
|
370
|
queryKey: ordersQueryKeys.preview(orderId), |
|
371
|
}) |
|
372
|
|
|
373
|
options?.onSuccess?.(data, variables, context) |
|
374
|
}, |
|
375
|
...options, |
|
376
|
}) |
|
377
|
} |
|
378
|
|
|
379
|
export const useAddClaimOutboundItems = ( |
|
380
|
id: string, |
|
381
|
orderId: string, |
|
382
|
options?: UseMutationOptions< |
|
383
|
HttpTypes.AdminClaimResponse, |
|
384
|
FetchError, |
|
385
|
HttpTypes.AdminAddClaimOutboundItems |
|
386
|
> |
|
387
|
) => { |
|
388
|
return useMutation({ |
|
389
|
mutationFn: (payload: HttpTypes.AdminAddClaimOutboundItems) => |
|
390
|
sdk.admin.claim.addOutboundItems(id, payload), |
|
391
|
onSuccess: (data: any, variables: any, context: any) => { |
|
392
|
queryClient.invalidateQueries({ |
|
393
|
queryKey: ordersQueryKeys.details(), |
|
394
|
}) |
|
395
|
|
|
396
|
queryClient.invalidateQueries({ |
|
397
|
queryKey: ordersQueryKeys.preview(orderId), |
|
398
|
}) |
|
399
|
|
|
400
|
options?.onSuccess?.(data, variables, context) |
|
401
|
}, |
|
402
|
...options, |
|
403
|
}) |
|
404
|
} |
|
405
|
|
|
406
|
export const useUpdateClaimOutboundItems = ( |
|
407
|
id: string, |
|
408
|
orderId: string, |
|
409
|
options?: UseMutationOptions< |
|
410
|
HttpTypes.AdminClaimResponse, |
|
411
|
FetchError, |
|
412
|
HttpTypes.AdminUpdateClaimOutboundItem & { actionId: string } |
|
413
|
> |
|
414
|
) => { |
|
415
|
return useMutation({ |
|
416
|
mutationFn: ({ |
|
417
|
actionId, |
|
418
|
...payload |
|
419
|
}: HttpTypes.AdminUpdateClaimOutboundItem & { actionId: string }) => { |
|
420
|
return sdk.admin.claim.updateOutboundItem(id, actionId, payload) |
|
421
|
}, |
|
422
|
onSuccess: (data: any, variables: any, context: any) => { |
|
423
|
queryClient.invalidateQueries({ |
|
424
|
queryKey: ordersQueryKeys.details(), |
|
425
|
}) |
|
426
|
|
|
427
|
queryClient.invalidateQueries({ |
|
428
|
queryKey: ordersQueryKeys.preview(orderId), |
|
429
|
}) |
|
430
|
|
|
431
|
options?.onSuccess?.(data, variables, context) |
|
432
|
}, |
|
433
|
...options, |
|
434
|
}) |
|
435
|
} |
|
436
|
|
|
437
|
export const useRemoveClaimOutboundItem = ( |
|
438
|
id: string, |
|
439
|
orderId: string, |
|
440
|
options?: UseMutationOptions<HttpTypes.AdminClaimResponse, FetchError, string> |
|
441
|
) => { |
|
442
|
return useMutation({ |
|
443
|
mutationFn: (actionId: string) => |
|
444
|
sdk.admin.claim.removeOutboundItem(id, actionId), |
|
445
|
onSuccess: (data: any, variables: any, context: any) => { |
|
446
|
queryClient.invalidateQueries({ |
|
447
|
queryKey: ordersQueryKeys.details(), |
|
448
|
}) |
|
449
|
|
|
450
|
queryClient.invalidateQueries({ |
|
451
|
queryKey: ordersQueryKeys.preview(orderId), |
|
452
|
}) |
|
453
|
|
|
454
|
options?.onSuccess?.(data, variables, context) |
|
455
|
}, |
|
456
|
...options, |
|
457
|
}) |
|
458
|
} |
|
459
|
|
|
460
|
export const useAddClaimOutboundShipping = ( |
|
461
|
id: string, |
|
462
|
orderId: string, |
|
463
|
options?: UseMutationOptions< |
|
464
|
HttpTypes.AdminClaimResponse, |
|
465
|
FetchError, |
|
466
|
HttpTypes.AdminClaimAddOutboundShipping |
|
467
|
> |
|
468
|
) => { |
|
469
|
return useMutation({ |
|
470
|
mutationFn: (payload: HttpTypes.AdminClaimAddOutboundShipping) => |
|
471
|
sdk.admin.claim.addOutboundShipping(id, payload), |
|
472
|
onSuccess: (data: any, variables: any, context: any) => { |
|
473
|
queryClient.invalidateQueries({ |
|
474
|
queryKey: ordersQueryKeys.details(), |
|
475
|
}) |
|
476
|
|
|
477
|
queryClient.invalidateQueries({ |
|
478
|
queryKey: ordersQueryKeys.preview(orderId), |
|
479
|
}) |
|
480
|
|
|
481
|
options?.onSuccess?.(data, variables, context) |
|
482
|
}, |
|
483
|
...options, |
|
484
|
}) |
|
485
|
} |
|
486
|
|
|
487
|
export const useUpdateClaimOutboundShipping = ( |
|
488
|
id: string, |
|
489
|
orderId: string, |
|
490
|
options?: UseMutationOptions< |
|
491
|
HttpTypes.AdminClaimPreviewResponse, |
|
492
|
FetchError, |
|
493
|
HttpTypes.AdminClaimUpdateOutboundShipping & { actionId: string } |
|
494
|
> |
|
495
|
) => { |
|
496
|
return useMutation({ |
|
497
|
mutationFn: ({ |
|
498
|
actionId, |
|
499
|
...payload |
|
500
|
}: HttpTypes.AdminClaimUpdateOutboundShipping & { actionId: string }) => |
|
501
|
sdk.admin.claim.updateOutboundShipping(id, actionId, payload), |
|
502
|
onSuccess: (data: any, variables: any, context: any) => { |
|
503
|
queryClient.invalidateQueries({ |
|
504
|
queryKey: ordersQueryKeys.details(), |
|
505
|
}) |
|
506
|
|
|
507
|
queryClient.invalidateQueries({ |
|
508
|
queryKey: ordersQueryKeys.preview(orderId), |
|
509
|
}) |
|
510
|
|
|
511
|
options?.onSuccess?.(data, variables, context) |
|
512
|
}, |
|
513
|
...options, |
|
514
|
}) |
|
515
|
} |
|
516
|
|
|
517
|
export const useDeleteClaimOutboundShipping = ( |
|
518
|
id: string, |
|
519
|
orderId: string, |
|
520
|
options?: UseMutationOptions<HttpTypes.AdminClaimResponse, FetchError, string> |
|
521
|
) => { |
|
522
|
return useMutation({ |
|
523
|
mutationFn: (actionId: string) => |
|
524
|
sdk.admin.claim.deleteOutboundShipping(id, actionId), |
|
525
|
onSuccess: (data: any, variables: any, context: any) => { |
|
526
|
queryClient.invalidateQueries({ |
|
527
|
queryKey: ordersQueryKeys.details(), |
|
528
|
}) |
|
529
|
|
|
530
|
queryClient.invalidateQueries({ |
|
531
|
queryKey: ordersQueryKeys.preview(orderId), |
|
532
|
}) |
|
533
|
|
|
534
|
options?.onSuccess?.(data, variables, context) |
|
535
|
}, |
|
536
|
...options, |
|
537
|
}) |
|
538
|
} |
|
539
|
|
|
540
|
export const useClaimConfirmRequest = ( |
|
541
|
id: string, |
|
542
|
orderId: string, |
|
543
|
options?: UseMutationOptions< |
|
544
|
HttpTypes.AdminClaimResponse, |
|
545
|
FetchError, |
|
546
|
HttpTypes.AdminRequestClaim |
|
547
|
> |
|
548
|
) => { |
|
549
|
return useMutation({ |
|
550
|
mutationFn: (payload: HttpTypes.AdminRequestClaim) => |
|
551
|
sdk.admin.claim.request(id, payload), |
|
552
|
onSuccess: (data: any, variables: any, context: any) => { |
|
553
|
queryClient.invalidateQueries({ |
|
554
|
queryKey: returnsQueryKeys.all, |
|
555
|
}) |
|
556
|
|
|
557
|
queryClient.invalidateQueries({ |
|
558
|
queryKey: ordersQueryKeys.details(), |
|
559
|
}) |
|
560
|
|
|
561
|
queryClient.invalidateQueries({ |
|
562
|
queryKey: ordersQueryKeys.preview(orderId), |
|
563
|
}) |
|
564
|
|
|
565
|
queryClient.invalidateQueries({ |
|
566
|
queryKey: claimsQueryKeys.lists(), |
|
567
|
}) |
|
568
|
|
|
569
|
options?.onSuccess?.(data, variables, context) |
|
570
|
}, |
|
571
|
...options, |
|
572
|
}) |
|
573
|
} |
|
574
|
|
|
575
|
export const useCancelClaimRequest = ( |
|
576
|
id: string, |
|
577
|
orderId: string, |
|
578
|
options?: UseMutationOptions<HttpTypes.AdminClaimDeleteResponse, FetchError> |
|
579
|
) => { |
|
580
|
return useMutation({ |
|
581
|
mutationFn: () => sdk.admin.claim.cancelRequest(id), |
|
582
|
onSuccess: (data: any, variables: any, context: any) => { |
|
583
|
queryClient.invalidateQueries({ |
|
584
|
queryKey: ordersQueryKeys.details(), |
|
585
|
}) |
|
586
|
|
|
587
|
queryClient.invalidateQueries({ |
|
588
|
queryKey: ordersQueryKeys.preview(orderId), |
|
589
|
}) |
|
590
|
|
|
591
|
queryClient.invalidateQueries({ |
|
592
|
queryKey: claimsQueryKeys.details(), |
|
593
|
}) |
|
594
|
queryClient.invalidateQueries({ |
|
595
|
queryKey: claimsQueryKeys.lists(), |
|
596
|
}) |
|
597
|
options?.onSuccess?.(data, variables, context) |
|
598
|
}, |
|
599
|
...options, |
|
600
|
}) |
|
601
|
} |