@refinedev/core 4.46.1 → 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 +69 -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/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/package.json +1 -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 -227
- package/src/hooks/data/useDeleteMany.ts +230 -248
- 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 -315
- package/src/hooks/data/useUpdateMany.ts +294 -325
- 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
|
@@ -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,293 +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
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
274
|
+
const {
|
|
275
|
+
gqlMutation: _,
|
|
276
|
+
gqlQuery: __,
|
|
277
|
+
...preferredMeta
|
|
278
|
+
} = pickNotDeprecated(meta, metaData) ?? {};
|
|
280
279
|
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
280
|
+
const queryKey = queryKeysReplacement(preferLegacyKeys)(
|
|
281
|
+
identifier,
|
|
282
|
+
pickDataProvider(identifier, dataProviderName, resources),
|
|
283
|
+
preferredMeta,
|
|
284
|
+
);
|
|
286
285
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
identifier,
|
|
291
|
-
dataProviderName,
|
|
292
|
-
resources,
|
|
293
|
-
),
|
|
294
|
-
)
|
|
295
|
-
.resource(identifier);
|
|
286
|
+
const resourceKeys = keys()
|
|
287
|
+
.data(pickDataProvider(identifier, dataProviderName, resources))
|
|
288
|
+
.resource(identifier);
|
|
296
289
|
|
|
297
|
-
|
|
298
|
-
|
|
290
|
+
const mutationModePropOrContext =
|
|
291
|
+
mutationMode ?? mutationModeContext;
|
|
299
292
|
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
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
|
+
};
|
|
305
326
|
},
|
|
306
327
|
);
|
|
307
328
|
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
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
|
+
);
|
|
312
351
|
|
|
313
|
-
|
|
314
|
-
// Set the previous queries to the new ones:
|
|
352
|
+
for (const id of ids) {
|
|
315
353
|
queryClient.setQueriesData(
|
|
316
354
|
resourceKeys
|
|
317
|
-
.action("
|
|
318
|
-
.
|
|
355
|
+
.action("one")
|
|
356
|
+
.id(id)
|
|
357
|
+
.params(preferredMeta)
|
|
319
358
|
.get(preferLegacyKeys),
|
|
320
|
-
(previous?:
|
|
321
|
-
if (!previous) {
|
|
359
|
+
(previous?: any | null) => {
|
|
360
|
+
if (!previous || previous.data.id == id) {
|
|
322
361
|
return null;
|
|
323
362
|
}
|
|
324
|
-
|
|
325
|
-
const data = previous.data.filter(
|
|
326
|
-
(item) =>
|
|
327
|
-
item.id &&
|
|
328
|
-
!ids
|
|
329
|
-
.map(String)
|
|
330
|
-
.includes(item.id.toString()),
|
|
331
|
-
);
|
|
332
|
-
|
|
333
363
|
return {
|
|
334
|
-
|
|
335
|
-
total: previous.total - 1,
|
|
364
|
+
...previous,
|
|
336
365
|
};
|
|
337
366
|
},
|
|
338
367
|
);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
339
370
|
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
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);
|
|
346
388
|
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
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
|
+
});
|
|
357
399
|
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
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);
|
|
364
418
|
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
.params(preferredMeta)
|
|
371
|
-
.get(preferLegacyKeys),
|
|
372
|
-
(previous?: any | null) => {
|
|
373
|
-
if (!previous || previous.data.id == id) {
|
|
374
|
-
return null;
|
|
375
|
-
}
|
|
376
|
-
return {
|
|
377
|
-
...previous,
|
|
378
|
-
};
|
|
379
|
-
},
|
|
380
|
-
);
|
|
381
|
-
}
|
|
382
|
-
}
|
|
419
|
+
const dataProviderName = pickDataProvider(
|
|
420
|
+
identifier,
|
|
421
|
+
dataProviderNameFromProp,
|
|
422
|
+
resources,
|
|
423
|
+
);
|
|
383
424
|
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
//
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
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,
|
|
396
463
|
dataProviderName,
|
|
397
|
-
invalidates = ["list", "many"],
|
|
398
464
|
},
|
|
399
|
-
)
|
|
400
|
-
const { identifier } = select(resourceName);
|
|
401
|
-
|
|
402
|
-
// invalidate the cache for the list and many queries:
|
|
403
|
-
invalidateStore({
|
|
404
|
-
resource: identifier,
|
|
405
|
-
dataProviderName: pickDataProvider(
|
|
406
|
-
identifier,
|
|
407
|
-
dataProviderName,
|
|
408
|
-
resources,
|
|
409
|
-
),
|
|
410
|
-
invalidates,
|
|
411
|
-
});
|
|
465
|
+
});
|
|
412
466
|
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
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: {
|
|
421
477
|
ids,
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
metaData,
|
|
425
|
-
dataProviderName: dataProviderNameFromProp,
|
|
426
|
-
successNotification,
|
|
478
|
+
dataProviderName,
|
|
479
|
+
...rest,
|
|
427
480
|
},
|
|
428
|
-
|
|
429
|
-
) => {
|
|
430
|
-
const { resource, identifier } = select(resourceName);
|
|
431
|
-
|
|
432
|
-
const dataProviderName = pickDataProvider(
|
|
433
|
-
identifier,
|
|
434
|
-
dataProviderNameFromProp,
|
|
435
|
-
resources,
|
|
436
|
-
);
|
|
481
|
+
});
|
|
437
482
|
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
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
|
+
}
|
|
442
501
|
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
);
|
|
502
|
+
if (err.message !== "mutationCancelled") {
|
|
503
|
+
checkError(err);
|
|
504
|
+
const resourceSingular = textTransformers.singular(identifier);
|
|
447
505
|
|
|
448
506
|
const notificationConfig =
|
|
449
|
-
typeof
|
|
450
|
-
?
|
|
451
|
-
:
|
|
507
|
+
typeof errorNotification === "function"
|
|
508
|
+
? errorNotification(err, ids, identifier)
|
|
509
|
+
: errorNotification;
|
|
452
510
|
|
|
453
511
|
handleNotification(notificationConfig, {
|
|
454
512
|
key: `${ids}-${identifier}-notification`,
|
|
455
|
-
description: translate("notifications.success", "Success"),
|
|
456
513
|
message: translate(
|
|
457
|
-
"notifications.
|
|
514
|
+
"notifications.deleteError",
|
|
458
515
|
{
|
|
459
|
-
resource:
|
|
460
|
-
|
|
461
|
-
identifier,
|
|
462
|
-
),
|
|
516
|
+
resource: resourceSingular,
|
|
517
|
+
statusCode: err.statusCode,
|
|
463
518
|
},
|
|
464
|
-
`
|
|
519
|
+
`Error (status code: ${err.statusCode})`,
|
|
465
520
|
),
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
publish?.({
|
|
470
|
-
channel: `resources/${resource.name}`,
|
|
471
|
-
type: "deleted",
|
|
472
|
-
payload: { ids },
|
|
473
|
-
date: new Date(),
|
|
474
|
-
meta: {
|
|
475
|
-
...combinedMeta,
|
|
476
|
-
dataProviderName,
|
|
477
|
-
},
|
|
478
|
-
});
|
|
479
|
-
|
|
480
|
-
const {
|
|
481
|
-
fields: _fields,
|
|
482
|
-
operation: _operation,
|
|
483
|
-
variables: _variables,
|
|
484
|
-
...rest
|
|
485
|
-
} = combinedMeta || {};
|
|
486
|
-
log?.mutate({
|
|
487
|
-
action: "deleteMany",
|
|
488
|
-
resource: resource.name,
|
|
489
|
-
meta: {
|
|
490
|
-
ids,
|
|
491
|
-
dataProviderName,
|
|
492
|
-
...rest,
|
|
493
|
-
},
|
|
521
|
+
description: err.message,
|
|
522
|
+
type: "error",
|
|
494
523
|
});
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
err,
|
|
503
|
-
{ ids, resource: resourceName, errorNotification },
|
|
504
|
-
context,
|
|
505
|
-
) => {
|
|
506
|
-
const { identifier } = select(resourceName);
|
|
507
|
-
|
|
508
|
-
// set back the queries to the context:
|
|
509
|
-
if (context) {
|
|
510
|
-
for (const query of context.previousQueries) {
|
|
511
|
-
queryClient.setQueryData(query[0], query[1]);
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
if (err.message !== "mutationCancelled") {
|
|
516
|
-
checkError(err);
|
|
517
|
-
const resourceSingular =
|
|
518
|
-
textTransformers.singular(identifier);
|
|
519
|
-
|
|
520
|
-
const notificationConfig =
|
|
521
|
-
typeof errorNotification === "function"
|
|
522
|
-
? errorNotification(err, ids, identifier)
|
|
523
|
-
: errorNotification;
|
|
524
|
-
|
|
525
|
-
handleNotification(notificationConfig, {
|
|
526
|
-
key: `${ids}-${identifier}-notification`,
|
|
527
|
-
message: translate(
|
|
528
|
-
"notifications.deleteError",
|
|
529
|
-
{
|
|
530
|
-
resource: resourceSingular,
|
|
531
|
-
statusCode: err.statusCode,
|
|
532
|
-
},
|
|
533
|
-
`Error (status code: ${err.statusCode})`,
|
|
534
|
-
),
|
|
535
|
-
description: err.message,
|
|
536
|
-
type: "error",
|
|
537
|
-
});
|
|
538
|
-
}
|
|
539
|
-
},
|
|
540
|
-
mutationKey: keys()
|
|
541
|
-
.data()
|
|
542
|
-
.mutation("deleteMany")
|
|
543
|
-
.get(preferLegacyKeys),
|
|
544
|
-
...mutationOptions,
|
|
545
|
-
meta: {
|
|
546
|
-
...mutationOptions?.meta,
|
|
547
|
-
...getXRay("useDeleteMany", preferLegacyKeys),
|
|
548
|
-
},
|
|
524
|
+
}
|
|
525
|
+
},
|
|
526
|
+
mutationKey: keys().data().mutation("deleteMany").get(preferLegacyKeys),
|
|
527
|
+
...mutationOptions,
|
|
528
|
+
meta: {
|
|
529
|
+
...mutationOptions?.meta,
|
|
530
|
+
...getXRay("useDeleteMany", preferLegacyKeys),
|
|
549
531
|
},
|
|
550
|
-
);
|
|
532
|
+
});
|
|
551
533
|
|
|
552
534
|
const { elapsedTime } = useLoadingOvertime({
|
|
553
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,
|