@refinedev/core 4.46.0 → 4.46.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 +109 -0
- package/dist/definitions/helpers/flatten-object-keys/index.d.ts.map +1 -1
- package/dist/esm/index.js +6 -6
- package/dist/esm/index.js.map +1 -1
- package/dist/hooks/accessControl/useCan/index.d.ts.map +1 -1
- package/dist/hooks/auditLog/useLogList/index.d.ts.map +1 -1
- package/dist/hooks/auth/useOnError/index.d.ts.map +1 -1
- package/dist/hooks/data/useCreate.d.ts.map +1 -1
- package/dist/hooks/data/useCreateMany.d.ts.map +1 -1
- package/dist/hooks/data/useDelete.d.ts.map +1 -1
- package/dist/hooks/data/useDeleteMany.d.ts.map +1 -1
- package/dist/hooks/data/useInfiniteList.d.ts.map +1 -1
- package/dist/hooks/data/useList.d.ts.map +1 -1
- package/dist/hooks/data/useMany.d.ts.map +1 -1
- package/dist/hooks/data/useOne.d.ts.map +1 -1
- package/dist/hooks/data/useUpdate.d.ts.map +1 -1
- package/dist/hooks/data/useUpdateMany.d.ts.map +1 -1
- package/dist/hooks/router/use-go/index.d.ts +2 -0
- package/dist/hooks/router/use-go/index.d.ts.map +1 -1
- package/dist/hooks/useMeta/index.d.ts +2 -0
- package/dist/hooks/useMeta/index.d.ts.map +1 -1
- package/dist/iife/index.js +6 -6
- package/dist/iife/index.js.map +1 -1
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/dist/interfaces/auth.d.ts +6 -6
- package/dist/interfaces/auth.d.ts.map +1 -1
- package/dist/interfaces/metaData/graphqlQueryOptions.d.ts +6 -0
- package/dist/interfaces/metaData/graphqlQueryOptions.d.ts.map +1 -0
- package/dist/interfaces/metaData/metaQuery.d.ts +2 -1
- package/dist/interfaces/metaData/metaQuery.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/definitions/helpers/flatten-object-keys/index.ts +2 -0
- package/src/hooks/accessControl/useCan/index.ts +10 -12
- package/src/hooks/auditLog/useLogList/index.ts +10 -12
- package/src/hooks/auth/useForgotPassword/index.ts +51 -54
- package/src/hooks/auth/useGetIdentity/index.ts +23 -26
- package/src/hooks/auth/useIsAuthenticated/index.ts +20 -20
- package/src/hooks/auth/useLogin/index.ts +33 -35
- package/src/hooks/auth/useLogout/index.ts +32 -34
- package/src/hooks/auth/useOnError/index.ts +29 -33
- package/src/hooks/auth/usePermissions/index.ts +19 -22
- package/src/hooks/auth/useRegister/index.ts +60 -66
- package/src/hooks/auth/useUpdatePassword/index.ts +51 -54
- package/src/hooks/data/useCreate.ts +115 -117
- package/src/hooks/data/useCreateMany.ts +113 -118
- package/src/hooks/data/useDelete.ts +212 -223
- package/src/hooks/data/useDeleteMany.ts +230 -244
- package/src/hooks/data/useInfiniteList.ts +36 -42
- package/src/hooks/data/useList.ts +56 -62
- package/src/hooks/data/useMany.ts +36 -37
- package/src/hooks/data/useOne.ts +54 -55
- package/src/hooks/data/useUpdate.ts +288 -311
- package/src/hooks/data/useUpdateMany.ts +294 -320
- package/src/hooks/menu/useMenu.tsx +1 -1
- package/src/hooks/router/use-go/index.tsx +3 -0
- package/src/interfaces/auth.tsx +6 -6
- package/src/interfaces/metaData/graphqlQueryOptions.ts +6 -0
- package/src/interfaces/metaData/metaQuery.ts +3 -1
|
@@ -173,8 +173,8 @@ export const useDeleteMany = <
|
|
|
173
173
|
TError,
|
|
174
174
|
DeleteManyParams<TData, TError, TVariables>,
|
|
175
175
|
DeleteContext<TData>
|
|
176
|
-
>(
|
|
177
|
-
({
|
|
176
|
+
>({
|
|
177
|
+
mutationFn: ({
|
|
178
178
|
resource: resourceName,
|
|
179
179
|
ids,
|
|
180
180
|
mutationMode,
|
|
@@ -261,289 +261,275 @@ export const useDeleteMany = <
|
|
|
261
261
|
);
|
|
262
262
|
return updatePromise;
|
|
263
263
|
},
|
|
264
|
-
{
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
}
|
|
273
|
-
const { identifier } = select(resourceName);
|
|
264
|
+
onMutate: async ({
|
|
265
|
+
ids,
|
|
266
|
+
resource: resourceName,
|
|
267
|
+
mutationMode,
|
|
268
|
+
dataProviderName,
|
|
269
|
+
meta,
|
|
270
|
+
metaData,
|
|
271
|
+
}) => {
|
|
272
|
+
const { identifier } = select(resourceName);
|
|
274
273
|
|
|
275
|
-
|
|
274
|
+
const {
|
|
275
|
+
gqlMutation: _,
|
|
276
|
+
gqlQuery: __,
|
|
277
|
+
...preferredMeta
|
|
278
|
+
} = pickNotDeprecated(meta, metaData) ?? {};
|
|
276
279
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
280
|
+
const queryKey = queryKeysReplacement(preferLegacyKeys)(
|
|
281
|
+
identifier,
|
|
282
|
+
pickDataProvider(identifier, dataProviderName, resources),
|
|
283
|
+
preferredMeta,
|
|
284
|
+
);
|
|
282
285
|
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
identifier,
|
|
287
|
-
dataProviderName,
|
|
288
|
-
resources,
|
|
289
|
-
),
|
|
290
|
-
)
|
|
291
|
-
.resource(identifier);
|
|
286
|
+
const resourceKeys = keys()
|
|
287
|
+
.data(pickDataProvider(identifier, dataProviderName, resources))
|
|
288
|
+
.resource(identifier);
|
|
292
289
|
|
|
293
|
-
|
|
294
|
-
|
|
290
|
+
const mutationModePropOrContext =
|
|
291
|
+
mutationMode ?? mutationModeContext;
|
|
295
292
|
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
293
|
+
await queryClient.cancelQueries(
|
|
294
|
+
resourceKeys.get(preferLegacyKeys),
|
|
295
|
+
undefined,
|
|
296
|
+
{
|
|
297
|
+
silent: true,
|
|
298
|
+
},
|
|
299
|
+
);
|
|
300
|
+
|
|
301
|
+
const previousQueries: PreviousQuery<TData>[] =
|
|
302
|
+
queryClient.getQueriesData(resourceKeys.get(preferLegacyKeys));
|
|
303
|
+
|
|
304
|
+
if (mutationModePropOrContext !== "pessimistic") {
|
|
305
|
+
// Set the previous queries to the new ones:
|
|
306
|
+
queryClient.setQueriesData(
|
|
307
|
+
resourceKeys
|
|
308
|
+
.action("list")
|
|
309
|
+
.params(preferredMeta ?? {})
|
|
310
|
+
.get(preferLegacyKeys),
|
|
311
|
+
(previous?: GetListResponse<TData> | null) => {
|
|
312
|
+
if (!previous) {
|
|
313
|
+
return null;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
const data = previous.data.filter(
|
|
317
|
+
(item) =>
|
|
318
|
+
item.id &&
|
|
319
|
+
!ids.map(String).includes(item.id.toString()),
|
|
320
|
+
);
|
|
321
|
+
|
|
322
|
+
return {
|
|
323
|
+
data,
|
|
324
|
+
total: previous.total - 1,
|
|
325
|
+
};
|
|
301
326
|
},
|
|
302
327
|
);
|
|
303
328
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
329
|
+
queryClient.setQueriesData(
|
|
330
|
+
resourceKeys.action("many").get(preferLegacyKeys),
|
|
331
|
+
(previous?: GetListResponse<TData> | null) => {
|
|
332
|
+
if (!previous) {
|
|
333
|
+
return null;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
const data = previous.data.filter((record: TData) => {
|
|
337
|
+
if (record.id) {
|
|
338
|
+
return !ids
|
|
339
|
+
.map(String)
|
|
340
|
+
.includes(record.id.toString());
|
|
341
|
+
}
|
|
342
|
+
return false;
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
return {
|
|
346
|
+
...previous,
|
|
347
|
+
data,
|
|
348
|
+
};
|
|
349
|
+
},
|
|
350
|
+
);
|
|
308
351
|
|
|
309
|
-
|
|
310
|
-
// Set the previous queries to the new ones:
|
|
352
|
+
for (const id of ids) {
|
|
311
353
|
queryClient.setQueriesData(
|
|
312
354
|
resourceKeys
|
|
313
|
-
.action("
|
|
314
|
-
.
|
|
355
|
+
.action("one")
|
|
356
|
+
.id(id)
|
|
357
|
+
.params(preferredMeta)
|
|
315
358
|
.get(preferLegacyKeys),
|
|
316
|
-
(previous?:
|
|
317
|
-
if (!previous) {
|
|
359
|
+
(previous?: any | null) => {
|
|
360
|
+
if (!previous || previous.data.id == id) {
|
|
318
361
|
return null;
|
|
319
362
|
}
|
|
320
|
-
|
|
321
|
-
const data = previous.data.filter(
|
|
322
|
-
(item) =>
|
|
323
|
-
item.id &&
|
|
324
|
-
!ids
|
|
325
|
-
.map(String)
|
|
326
|
-
.includes(item.id.toString()),
|
|
327
|
-
);
|
|
328
|
-
|
|
329
363
|
return {
|
|
330
|
-
|
|
331
|
-
total: previous.total - 1,
|
|
364
|
+
...previous,
|
|
332
365
|
};
|
|
333
366
|
},
|
|
334
367
|
);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
335
370
|
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
371
|
+
return {
|
|
372
|
+
previousQueries,
|
|
373
|
+
queryKey,
|
|
374
|
+
};
|
|
375
|
+
},
|
|
376
|
+
// Always refetch after error or success:
|
|
377
|
+
onSettled: (
|
|
378
|
+
_data,
|
|
379
|
+
_error,
|
|
380
|
+
{
|
|
381
|
+
resource: resourceName,
|
|
382
|
+
ids,
|
|
383
|
+
dataProviderName,
|
|
384
|
+
invalidates = ["list", "many"],
|
|
385
|
+
},
|
|
386
|
+
) => {
|
|
387
|
+
const { identifier } = select(resourceName);
|
|
342
388
|
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
389
|
+
// invalidate the cache for the list and many queries:
|
|
390
|
+
invalidateStore({
|
|
391
|
+
resource: identifier,
|
|
392
|
+
dataProviderName: pickDataProvider(
|
|
393
|
+
identifier,
|
|
394
|
+
dataProviderName,
|
|
395
|
+
resources,
|
|
396
|
+
),
|
|
397
|
+
invalidates,
|
|
398
|
+
});
|
|
353
399
|
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
400
|
+
notificationDispatch({
|
|
401
|
+
type: ActionTypes.REMOVE,
|
|
402
|
+
payload: { id: ids, resource: identifier },
|
|
403
|
+
});
|
|
404
|
+
},
|
|
405
|
+
onSuccess: (
|
|
406
|
+
_data,
|
|
407
|
+
{
|
|
408
|
+
ids,
|
|
409
|
+
resource: resourceName,
|
|
410
|
+
meta,
|
|
411
|
+
metaData,
|
|
412
|
+
dataProviderName: dataProviderNameFromProp,
|
|
413
|
+
successNotification,
|
|
414
|
+
},
|
|
415
|
+
context,
|
|
416
|
+
) => {
|
|
417
|
+
const { resource, identifier } = select(resourceName);
|
|
360
418
|
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
.params(preferredMeta)
|
|
367
|
-
.get(preferLegacyKeys),
|
|
368
|
-
(previous?: any | null) => {
|
|
369
|
-
if (!previous || previous.data.id == id) {
|
|
370
|
-
return null;
|
|
371
|
-
}
|
|
372
|
-
return {
|
|
373
|
-
...previous,
|
|
374
|
-
};
|
|
375
|
-
},
|
|
376
|
-
);
|
|
377
|
-
}
|
|
378
|
-
}
|
|
419
|
+
const dataProviderName = pickDataProvider(
|
|
420
|
+
identifier,
|
|
421
|
+
dataProviderNameFromProp,
|
|
422
|
+
resources,
|
|
423
|
+
);
|
|
379
424
|
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
//
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
425
|
+
const combinedMeta = getMeta({
|
|
426
|
+
resource,
|
|
427
|
+
meta: pickNotDeprecated(meta, metaData),
|
|
428
|
+
});
|
|
429
|
+
|
|
430
|
+
// Remove the queries from the cache:
|
|
431
|
+
ids.forEach((id) =>
|
|
432
|
+
queryClient.removeQueries(context?.queryKey.detail(id)),
|
|
433
|
+
);
|
|
434
|
+
|
|
435
|
+
const notificationConfig =
|
|
436
|
+
typeof successNotification === "function"
|
|
437
|
+
? successNotification(_data, ids, identifier)
|
|
438
|
+
: successNotification;
|
|
439
|
+
|
|
440
|
+
handleNotification(notificationConfig, {
|
|
441
|
+
key: `${ids}-${identifier}-notification`,
|
|
442
|
+
description: translate("notifications.success", "Success"),
|
|
443
|
+
message: translate(
|
|
444
|
+
"notifications.deleteSuccess",
|
|
445
|
+
{
|
|
446
|
+
resource: translate(
|
|
447
|
+
`${identifier}.${identifier}`,
|
|
448
|
+
identifier,
|
|
449
|
+
),
|
|
450
|
+
},
|
|
451
|
+
`Successfully deleted ${identifier}`,
|
|
452
|
+
),
|
|
453
|
+
type: "success",
|
|
454
|
+
});
|
|
455
|
+
|
|
456
|
+
publish?.({
|
|
457
|
+
channel: `resources/${resource.name}`,
|
|
458
|
+
type: "deleted",
|
|
459
|
+
payload: { ids },
|
|
460
|
+
date: new Date(),
|
|
461
|
+
meta: {
|
|
462
|
+
...combinedMeta,
|
|
392
463
|
dataProviderName,
|
|
393
|
-
invalidates = ["list", "many"],
|
|
394
464
|
},
|
|
395
|
-
)
|
|
396
|
-
const { identifier } = select(resourceName);
|
|
397
|
-
|
|
398
|
-
// invalidate the cache for the list and many queries:
|
|
399
|
-
invalidateStore({
|
|
400
|
-
resource: identifier,
|
|
401
|
-
dataProviderName: pickDataProvider(
|
|
402
|
-
identifier,
|
|
403
|
-
dataProviderName,
|
|
404
|
-
resources,
|
|
405
|
-
),
|
|
406
|
-
invalidates,
|
|
407
|
-
});
|
|
465
|
+
});
|
|
408
466
|
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
467
|
+
const {
|
|
468
|
+
fields: _fields,
|
|
469
|
+
operation: _operation,
|
|
470
|
+
variables: _variables,
|
|
471
|
+
...rest
|
|
472
|
+
} = combinedMeta || {};
|
|
473
|
+
log?.mutate({
|
|
474
|
+
action: "deleteMany",
|
|
475
|
+
resource: resource.name,
|
|
476
|
+
meta: {
|
|
417
477
|
ids,
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
metaData,
|
|
421
|
-
dataProviderName: dataProviderNameFromProp,
|
|
422
|
-
successNotification,
|
|
478
|
+
dataProviderName,
|
|
479
|
+
...rest,
|
|
423
480
|
},
|
|
424
|
-
|
|
425
|
-
) => {
|
|
426
|
-
const { resource, identifier } = select(resourceName);
|
|
427
|
-
|
|
428
|
-
const dataProviderName = pickDataProvider(
|
|
429
|
-
identifier,
|
|
430
|
-
dataProviderNameFromProp,
|
|
431
|
-
resources,
|
|
432
|
-
);
|
|
481
|
+
});
|
|
433
482
|
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
483
|
+
// Remove the queries from the cache:
|
|
484
|
+
ids.forEach((id) =>
|
|
485
|
+
queryClient.removeQueries(context?.queryKey.detail(id)),
|
|
486
|
+
);
|
|
487
|
+
},
|
|
488
|
+
onError: (
|
|
489
|
+
err,
|
|
490
|
+
{ ids, resource: resourceName, errorNotification },
|
|
491
|
+
context,
|
|
492
|
+
) => {
|
|
493
|
+
const { identifier } = select(resourceName);
|
|
494
|
+
|
|
495
|
+
// set back the queries to the context:
|
|
496
|
+
if (context) {
|
|
497
|
+
for (const query of context.previousQueries) {
|
|
498
|
+
queryClient.setQueryData(query[0], query[1]);
|
|
499
|
+
}
|
|
500
|
+
}
|
|
438
501
|
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
);
|
|
502
|
+
if (err.message !== "mutationCancelled") {
|
|
503
|
+
checkError(err);
|
|
504
|
+
const resourceSingular = textTransformers.singular(identifier);
|
|
443
505
|
|
|
444
506
|
const notificationConfig =
|
|
445
|
-
typeof
|
|
446
|
-
?
|
|
447
|
-
:
|
|
507
|
+
typeof errorNotification === "function"
|
|
508
|
+
? errorNotification(err, ids, identifier)
|
|
509
|
+
: errorNotification;
|
|
448
510
|
|
|
449
511
|
handleNotification(notificationConfig, {
|
|
450
512
|
key: `${ids}-${identifier}-notification`,
|
|
451
|
-
description: translate("notifications.success", "Success"),
|
|
452
513
|
message: translate(
|
|
453
|
-
"notifications.
|
|
514
|
+
"notifications.deleteError",
|
|
454
515
|
{
|
|
455
|
-
resource:
|
|
456
|
-
|
|
457
|
-
identifier,
|
|
458
|
-
),
|
|
516
|
+
resource: resourceSingular,
|
|
517
|
+
statusCode: err.statusCode,
|
|
459
518
|
},
|
|
460
|
-
`
|
|
519
|
+
`Error (status code: ${err.statusCode})`,
|
|
461
520
|
),
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
publish?.({
|
|
466
|
-
channel: `resources/${resource.name}`,
|
|
467
|
-
type: "deleted",
|
|
468
|
-
payload: { ids },
|
|
469
|
-
date: new Date(),
|
|
470
|
-
meta: {
|
|
471
|
-
...combinedMeta,
|
|
472
|
-
dataProviderName,
|
|
473
|
-
},
|
|
474
|
-
});
|
|
475
|
-
|
|
476
|
-
const {
|
|
477
|
-
fields: _fields,
|
|
478
|
-
operation: _operation,
|
|
479
|
-
variables: _variables,
|
|
480
|
-
...rest
|
|
481
|
-
} = combinedMeta || {};
|
|
482
|
-
log?.mutate({
|
|
483
|
-
action: "deleteMany",
|
|
484
|
-
resource: resource.name,
|
|
485
|
-
meta: {
|
|
486
|
-
ids,
|
|
487
|
-
dataProviderName,
|
|
488
|
-
...rest,
|
|
489
|
-
},
|
|
521
|
+
description: err.message,
|
|
522
|
+
type: "error",
|
|
490
523
|
});
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
err,
|
|
499
|
-
{ ids, resource: resourceName, errorNotification },
|
|
500
|
-
context,
|
|
501
|
-
) => {
|
|
502
|
-
const { identifier } = select(resourceName);
|
|
503
|
-
|
|
504
|
-
// set back the queries to the context:
|
|
505
|
-
if (context) {
|
|
506
|
-
for (const query of context.previousQueries) {
|
|
507
|
-
queryClient.setQueryData(query[0], query[1]);
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
if (err.message !== "mutationCancelled") {
|
|
512
|
-
checkError(err);
|
|
513
|
-
const resourceSingular =
|
|
514
|
-
textTransformers.singular(identifier);
|
|
515
|
-
|
|
516
|
-
const notificationConfig =
|
|
517
|
-
typeof errorNotification === "function"
|
|
518
|
-
? errorNotification(err, ids, identifier)
|
|
519
|
-
: errorNotification;
|
|
520
|
-
|
|
521
|
-
handleNotification(notificationConfig, {
|
|
522
|
-
key: `${ids}-${identifier}-notification`,
|
|
523
|
-
message: translate(
|
|
524
|
-
"notifications.deleteError",
|
|
525
|
-
{
|
|
526
|
-
resource: resourceSingular,
|
|
527
|
-
statusCode: err.statusCode,
|
|
528
|
-
},
|
|
529
|
-
`Error (status code: ${err.statusCode})`,
|
|
530
|
-
),
|
|
531
|
-
description: err.message,
|
|
532
|
-
type: "error",
|
|
533
|
-
});
|
|
534
|
-
}
|
|
535
|
-
},
|
|
536
|
-
mutationKey: keys()
|
|
537
|
-
.data()
|
|
538
|
-
.mutation("deleteMany")
|
|
539
|
-
.get(preferLegacyKeys),
|
|
540
|
-
...mutationOptions,
|
|
541
|
-
meta: {
|
|
542
|
-
...mutationOptions?.meta,
|
|
543
|
-
...getXRay("useDeleteMany", preferLegacyKeys),
|
|
544
|
-
},
|
|
524
|
+
}
|
|
525
|
+
},
|
|
526
|
+
mutationKey: keys().data().mutation("deleteMany").get(preferLegacyKeys),
|
|
527
|
+
...mutationOptions,
|
|
528
|
+
meta: {
|
|
529
|
+
...mutationOptions?.meta,
|
|
530
|
+
...getXRay("useDeleteMany", preferLegacyKeys),
|
|
545
531
|
},
|
|
546
|
-
);
|
|
532
|
+
});
|
|
547
533
|
|
|
548
534
|
const { elapsedTime } = useLoadingOvertime({
|
|
549
535
|
isLoading: mutation.isLoading,
|
|
@@ -230,8 +230,8 @@ export const useInfiniteList = <
|
|
|
230
230
|
GetListResponse<TQueryFnData>,
|
|
231
231
|
TError,
|
|
232
232
|
GetListResponse<TData>
|
|
233
|
-
>(
|
|
234
|
-
keys()
|
|
233
|
+
>({
|
|
234
|
+
queryKey: keys()
|
|
235
235
|
.data(pickedDataProvider)
|
|
236
236
|
.resource(identifier)
|
|
237
237
|
.action("infinite")
|
|
@@ -250,7 +250,7 @@ export const useInfiniteList = <
|
|
|
250
250
|
}),
|
|
251
251
|
})
|
|
252
252
|
.get(preferLegacyKeys),
|
|
253
|
-
({ queryKey, pageParam, signal }) => {
|
|
253
|
+
queryFn: ({ queryKey, pageParam, signal }) => {
|
|
254
254
|
const paginationProperties = {
|
|
255
255
|
...prefferedPagination,
|
|
256
256
|
current: pageParam,
|
|
@@ -288,50 +288,44 @@ export const useInfiniteList = <
|
|
|
288
288
|
};
|
|
289
289
|
});
|
|
290
290
|
},
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
onSuccess
|
|
296
|
-
queryOptions?.onSuccess?.(data);
|
|
291
|
+
getNextPageParam: (lastPage) => getNextPageParam(lastPage),
|
|
292
|
+
getPreviousPageParam: (lastPage) => getPreviousPageParam(lastPage),
|
|
293
|
+
...queryOptions,
|
|
294
|
+
onSuccess: (data) => {
|
|
295
|
+
queryOptions?.onSuccess?.(data);
|
|
297
296
|
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
notificationValues,
|
|
303
|
-
identifier,
|
|
304
|
-
)
|
|
305
|
-
: successNotification;
|
|
297
|
+
const notificationConfig =
|
|
298
|
+
typeof successNotification === "function"
|
|
299
|
+
? successNotification(data, notificationValues, identifier)
|
|
300
|
+
: successNotification;
|
|
306
301
|
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
302
|
+
handleNotification(notificationConfig);
|
|
303
|
+
},
|
|
304
|
+
onError: (err: TError) => {
|
|
305
|
+
checkError(err);
|
|
306
|
+
queryOptions?.onError?.(err);
|
|
312
307
|
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
308
|
+
const notificationConfig =
|
|
309
|
+
typeof errorNotification === "function"
|
|
310
|
+
? errorNotification(err, notificationValues, identifier)
|
|
311
|
+
: errorNotification;
|
|
317
312
|
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
},
|
|
329
|
-
meta: {
|
|
330
|
-
...queryOptions?.meta,
|
|
331
|
-
...getXRay("useInfiniteList", preferLegacyKeys),
|
|
332
|
-
},
|
|
313
|
+
handleNotification(notificationConfig, {
|
|
314
|
+
key: `${identifier}-useInfiniteList-notification`,
|
|
315
|
+
message: translate(
|
|
316
|
+
"notifications.error",
|
|
317
|
+
{ statusCode: err.statusCode },
|
|
318
|
+
`Error (status code: ${err.statusCode})`,
|
|
319
|
+
),
|
|
320
|
+
description: err.message,
|
|
321
|
+
type: "error",
|
|
322
|
+
});
|
|
333
323
|
},
|
|
334
|
-
|
|
324
|
+
meta: {
|
|
325
|
+
...queryOptions?.meta,
|
|
326
|
+
...getXRay("useInfiniteList", preferLegacyKeys),
|
|
327
|
+
},
|
|
328
|
+
});
|
|
335
329
|
|
|
336
330
|
const { elapsedTime } = useLoadingOvertime({
|
|
337
331
|
isLoading: queryResponse.isFetching,
|