next-recomponents 1.5.94 → 1.5.96
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/dist/index.js +196 -193
- package/dist/index.mjs +197 -194
- package/package.json +1 -1
- package/src/use-resources/index.ts +216 -213
package/dist/index.js
CHANGED
|
@@ -32290,193 +32290,86 @@ function useResources({
|
|
|
32290
32290
|
onError
|
|
32291
32291
|
}) {
|
|
32292
32292
|
const token = useToken();
|
|
32293
|
-
const [info, setInfo] = (0, import_react28.useState)(
|
|
32294
|
-
|
|
32295
|
-
|
|
32296
|
-
|
|
32297
|
-
|
|
32298
|
-
|
|
32299
|
-
const
|
|
32300
|
-
|
|
32301
|
-
url: `${baseURI}/${key}`,
|
|
32302
|
-
params: __spreadValues({ limit, page }, query),
|
|
32303
|
-
headers: { Authorization: token }
|
|
32304
|
-
};
|
|
32305
|
-
const newInfo = __spreadValues({}, info);
|
|
32306
|
-
newInfo[key] = newInfo[key] || {};
|
|
32307
|
-
newInfo[key].state = "loading";
|
|
32308
|
-
newInfo[key].errorMessage = "";
|
|
32309
|
-
newInfo[key].params = query;
|
|
32310
|
-
newInfo[key].loaded = true;
|
|
32311
|
-
setInfo(newInfo);
|
|
32312
|
-
try {
|
|
32313
|
-
const consulta = yield import_axios.default.request(options);
|
|
32314
|
-
const d = consulta.data;
|
|
32315
|
-
newInfo[key].state = "success";
|
|
32316
|
-
newInfo[key].errorMessage = "";
|
|
32317
|
-
if (autoLoad) {
|
|
32318
|
-
} else {
|
|
32319
|
-
newInfo[key].data = merge ? page == 1 ? d.data : [...d.data, ...newInfo[key].data || []] : d.data;
|
|
32320
|
-
newInfo[key].totalItems = d.totalItems;
|
|
32321
|
-
newInfo[key].totalPages = d.totalPages;
|
|
32322
|
-
newInfo[key].currentPage = d.currentPage;
|
|
32323
|
-
}
|
|
32324
|
-
setInfo(__spreadValues({}, newInfo));
|
|
32325
|
-
return d.data;
|
|
32326
|
-
} catch (error) {
|
|
32327
|
-
const item = http_codes_default.find((s) => s.code == error.status);
|
|
32328
|
-
newInfo[key].state = "error";
|
|
32329
|
-
newInfo[key].errorMessage = item == null ? void 0 : item.meaning;
|
|
32330
|
-
if (error.status == 403) {
|
|
32331
|
-
onError == null ? void 0 : onError(__spreadValues({ error }, { errorMessage: item == null ? void 0 : item.meaning }));
|
|
32332
|
-
}
|
|
32333
|
-
setInfo(__spreadValues({}, newInfo));
|
|
32334
|
-
return error;
|
|
32335
|
-
}
|
|
32336
|
-
});
|
|
32337
|
-
const findFunc = (id3, query, autoLoad = false) => __async(null, null, function* () {
|
|
32338
|
-
var _a, _b, _c2;
|
|
32339
|
-
const options = {
|
|
32340
|
-
method: "GET",
|
|
32341
|
-
url: `${baseURI}/${key}/${id3}`,
|
|
32342
|
-
params: __spreadValues({}, query),
|
|
32343
|
-
headers: { Authorization: token }
|
|
32344
|
-
};
|
|
32345
|
-
const newInfo = __spreadValues({}, info);
|
|
32346
|
-
newInfo[key] = newInfo[key] || {};
|
|
32347
|
-
newInfo[key].state = "loading";
|
|
32348
|
-
newInfo[key].errorMessage = "";
|
|
32349
|
-
newInfo[key].params = query;
|
|
32350
|
-
newInfo[key].loader = true;
|
|
32351
|
-
setInfo(newInfo);
|
|
32352
|
-
try {
|
|
32353
|
-
const consulta = yield import_axios.default.request(options);
|
|
32354
|
-
const d = consulta.data;
|
|
32355
|
-
newInfo[key].state = "success";
|
|
32356
|
-
newInfo[key].errorMessage = "";
|
|
32357
|
-
if (autoLoad) {
|
|
32358
|
-
} else {
|
|
32359
|
-
newInfo[key].selectedItem = d;
|
|
32360
|
-
const index = (_b = (_a = newInfo[key]) == null ? void 0 : _a.data) == null ? void 0 : _b.findIndex(
|
|
32361
|
-
(d2) => (d2 == null ? void 0 : d2.id) == (d2 == null ? void 0 : d2.id)
|
|
32362
|
-
);
|
|
32363
|
-
if (index >= 0) {
|
|
32364
|
-
newInfo[key].data[index] = d;
|
|
32365
|
-
} else {
|
|
32366
|
-
if ((_c2 = newInfo[key]) == null ? void 0 : _c2.data) {
|
|
32367
|
-
newInfo[key].data.unshift(d);
|
|
32368
|
-
} else {
|
|
32369
|
-
newInfo[key].data = [d];
|
|
32370
|
-
}
|
|
32371
|
-
}
|
|
32372
|
-
}
|
|
32373
|
-
setInfo(__spreadValues({}, newInfo));
|
|
32374
|
-
return d;
|
|
32375
|
-
} catch (error) {
|
|
32376
|
-
const item = http_codes_default.find((s) => s.code == error.status);
|
|
32377
|
-
newInfo[key].state = "error";
|
|
32378
|
-
newInfo[key].errorMessage = (item == null ? void 0 : item.meaning) || error.message;
|
|
32379
|
-
if (error.status == 403) {
|
|
32380
|
-
onError == null ? void 0 : onError(__spreadValues({ error }, { errorMessage: item == null ? void 0 : item.meaning }));
|
|
32381
|
-
}
|
|
32382
|
-
setInfo(__spreadValues({}, newInfo));
|
|
32383
|
-
return error;
|
|
32384
|
-
}
|
|
32385
|
-
});
|
|
32386
|
-
acc[key] = __spreadProps(__spreadValues({}, endpoint), {
|
|
32387
|
-
loaded: !((_c = acc[key]) == null ? void 0 : _c.loaded) ? ((_d = acc[key]) == null ? void 0 : _d.id) ? findFunc(acc[key].id, (_e = acc[key]) == null ? void 0 : _e.defaultParams) : ((_f = acc[key]) == null ? void 0 : _f.defaultParams) ? showFunc(acc[key].defaultParams) : true : true,
|
|
32388
|
-
show: showFunc,
|
|
32389
|
-
find: findFunc,
|
|
32390
|
-
create: (data) => __async(null, null, function* () {
|
|
32391
|
-
var _a, _b, _c2, _d2, _e2, _f2;
|
|
32293
|
+
const [info, setInfo] = (0, import_react28.useState)({});
|
|
32294
|
+
(0, import_react28.useEffect)(() => {
|
|
32295
|
+
setInfo(
|
|
32296
|
+
Object.keys(endpoints).reduce((acc, key) => {
|
|
32297
|
+
var _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
32298
|
+
const endpoint = endpoints[key];
|
|
32299
|
+
const showFunc = (_a, autoLoad = false) => __async(null, null, function* () {
|
|
32300
|
+
var _b = _a, { limit = 10, page = 1, merge = true } = _b, query = __objRest(_b, ["limit", "page", "merge"]);
|
|
32392
32301
|
const options = {
|
|
32393
|
-
method: "
|
|
32302
|
+
method: "GET",
|
|
32394
32303
|
url: `${baseURI}/${key}`,
|
|
32395
|
-
|
|
32304
|
+
params: __spreadValues({ limit, page }, query),
|
|
32396
32305
|
headers: { Authorization: token }
|
|
32397
32306
|
};
|
|
32398
32307
|
const newInfo = __spreadValues({}, info);
|
|
32399
32308
|
newInfo[key] = newInfo[key] || {};
|
|
32400
32309
|
newInfo[key].state = "loading";
|
|
32401
32310
|
newInfo[key].errorMessage = "";
|
|
32311
|
+
newInfo[key].params = query;
|
|
32312
|
+
newInfo[key].loaded = true;
|
|
32402
32313
|
setInfo(newInfo);
|
|
32403
32314
|
try {
|
|
32404
32315
|
const consulta = yield import_axios.default.request(options);
|
|
32405
32316
|
const d = consulta.data;
|
|
32406
32317
|
newInfo[key].state = "success";
|
|
32407
32318
|
newInfo[key].errorMessage = "";
|
|
32408
|
-
if (
|
|
32409
|
-
for (let datum of data) {
|
|
32410
|
-
const index = (_b = (_a = newInfo[key]) == null ? void 0 : _a.data) == null ? void 0 : _b.findIndex(
|
|
32411
|
-
(d2) => (d2 == null ? void 0 : d2.id) == (datum == null ? void 0 : datum.id)
|
|
32412
|
-
);
|
|
32413
|
-
if (index >= 0) {
|
|
32414
|
-
newInfo[key].data[index] = d;
|
|
32415
|
-
} else {
|
|
32416
|
-
if ((_c2 = newInfo[key]) == null ? void 0 : _c2.data) {
|
|
32417
|
-
newInfo[key].data.unshift(d);
|
|
32418
|
-
} else {
|
|
32419
|
-
newInfo[key].data = [d];
|
|
32420
|
-
}
|
|
32421
|
-
}
|
|
32422
|
-
}
|
|
32319
|
+
if (autoLoad) {
|
|
32423
32320
|
} else {
|
|
32424
|
-
newInfo[key].
|
|
32425
|
-
|
|
32426
|
-
|
|
32427
|
-
|
|
32428
|
-
if (index >= 0) {
|
|
32429
|
-
newInfo[key].data[index] = d;
|
|
32430
|
-
} else {
|
|
32431
|
-
if ((_f2 = newInfo[key]) == null ? void 0 : _f2.data) {
|
|
32432
|
-
newInfo[key].data.unshift(d);
|
|
32433
|
-
} else {
|
|
32434
|
-
newInfo[key].data = [d];
|
|
32435
|
-
}
|
|
32436
|
-
}
|
|
32321
|
+
newInfo[key].data = merge ? page == 1 ? d.data : [...d.data, ...newInfo[key].data || []] : d.data;
|
|
32322
|
+
newInfo[key].totalItems = d.totalItems;
|
|
32323
|
+
newInfo[key].totalPages = d.totalPages;
|
|
32324
|
+
newInfo[key].currentPage = d.currentPage;
|
|
32437
32325
|
}
|
|
32438
32326
|
setInfo(__spreadValues({}, newInfo));
|
|
32439
|
-
return d;
|
|
32327
|
+
return d.data;
|
|
32440
32328
|
} catch (error) {
|
|
32441
32329
|
const item = http_codes_default.find((s) => s.code == error.status);
|
|
32442
32330
|
newInfo[key].state = "error";
|
|
32443
|
-
newInfo[key].errorMessage =
|
|
32331
|
+
newInfo[key].errorMessage = item == null ? void 0 : item.meaning;
|
|
32444
32332
|
if (error.status == 403) {
|
|
32445
32333
|
onError == null ? void 0 : onError(__spreadValues({ error }, { errorMessage: item == null ? void 0 : item.meaning }));
|
|
32446
32334
|
}
|
|
32447
32335
|
setInfo(__spreadValues({}, newInfo));
|
|
32448
32336
|
return error;
|
|
32449
32337
|
}
|
|
32450
|
-
})
|
|
32451
|
-
|
|
32338
|
+
});
|
|
32339
|
+
const findFunc = (id3, query, autoLoad = false) => __async(null, null, function* () {
|
|
32452
32340
|
var _a, _b, _c2;
|
|
32453
32341
|
const options = {
|
|
32454
|
-
method: "
|
|
32342
|
+
method: "GET",
|
|
32455
32343
|
url: `${baseURI}/${key}/${id3}`,
|
|
32456
|
-
|
|
32344
|
+
params: __spreadValues({}, query),
|
|
32457
32345
|
headers: { Authorization: token }
|
|
32458
32346
|
};
|
|
32459
32347
|
const newInfo = __spreadValues({}, info);
|
|
32460
32348
|
newInfo[key] = newInfo[key] || {};
|
|
32461
32349
|
newInfo[key].state = "loading";
|
|
32462
32350
|
newInfo[key].errorMessage = "";
|
|
32351
|
+
newInfo[key].params = query;
|
|
32352
|
+
newInfo[key].loader = true;
|
|
32463
32353
|
setInfo(newInfo);
|
|
32464
32354
|
try {
|
|
32465
32355
|
const consulta = yield import_axios.default.request(options);
|
|
32466
32356
|
const d = consulta.data;
|
|
32467
32357
|
newInfo[key].state = "success";
|
|
32468
32358
|
newInfo[key].errorMessage = "";
|
|
32469
|
-
|
|
32470
|
-
const index = (_b = (_a = newInfo[key]) == null ? void 0 : _a.data) == null ? void 0 : _b.findIndex(
|
|
32471
|
-
(d2) => (d2 == null ? void 0 : d2.id) == (d2 == null ? void 0 : d2.id)
|
|
32472
|
-
);
|
|
32473
|
-
if (index >= 0) {
|
|
32474
|
-
newInfo[key].data[index] = d;
|
|
32359
|
+
if (autoLoad) {
|
|
32475
32360
|
} else {
|
|
32476
|
-
|
|
32477
|
-
|
|
32361
|
+
newInfo[key].selectedItem = d;
|
|
32362
|
+
const index = (_b = (_a = newInfo[key]) == null ? void 0 : _a.data) == null ? void 0 : _b.findIndex(
|
|
32363
|
+
(d2) => (d2 == null ? void 0 : d2.id) == (d2 == null ? void 0 : d2.id)
|
|
32364
|
+
);
|
|
32365
|
+
if (index >= 0) {
|
|
32366
|
+
newInfo[key].data[index] = d;
|
|
32478
32367
|
} else {
|
|
32479
|
-
newInfo[key].data
|
|
32368
|
+
if ((_c2 = newInfo[key]) == null ? void 0 : _c2.data) {
|
|
32369
|
+
newInfo[key].data.unshift(d);
|
|
32370
|
+
} else {
|
|
32371
|
+
newInfo[key].data = [d];
|
|
32372
|
+
}
|
|
32480
32373
|
}
|
|
32481
32374
|
}
|
|
32482
32375
|
setInfo(__spreadValues({}, newInfo));
|
|
@@ -32491,58 +32384,168 @@ function useResources({
|
|
|
32491
32384
|
setInfo(__spreadValues({}, newInfo));
|
|
32492
32385
|
return error;
|
|
32493
32386
|
}
|
|
32494
|
-
})
|
|
32495
|
-
|
|
32496
|
-
|
|
32497
|
-
|
|
32498
|
-
|
|
32499
|
-
|
|
32500
|
-
|
|
32501
|
-
|
|
32502
|
-
|
|
32503
|
-
|
|
32504
|
-
|
|
32505
|
-
|
|
32506
|
-
|
|
32507
|
-
|
|
32508
|
-
|
|
32509
|
-
|
|
32510
|
-
newInfo[key].state = "success";
|
|
32387
|
+
});
|
|
32388
|
+
acc[key] = __spreadProps(__spreadValues({}, endpoint), {
|
|
32389
|
+
loaded: !((_c = acc[key]) == null ? void 0 : _c.loaded) ? ((_d = acc[key]) == null ? void 0 : _d.id) ? findFunc(acc[key].id, (_e = acc[key]) == null ? void 0 : _e.defaultParams) : ((_f = acc[key]) == null ? void 0 : _f.defaultParams) ? showFunc(acc[key].defaultParams) : true : true,
|
|
32390
|
+
show: showFunc,
|
|
32391
|
+
find: findFunc,
|
|
32392
|
+
create: (data) => __async(null, null, function* () {
|
|
32393
|
+
var _a, _b, _c2, _d2, _e2, _f2;
|
|
32394
|
+
const options = {
|
|
32395
|
+
method: "POST",
|
|
32396
|
+
url: `${baseURI}/${key}`,
|
|
32397
|
+
data: Array.isArray(data) ? [...data] : __spreadValues({}, data),
|
|
32398
|
+
headers: { Authorization: token }
|
|
32399
|
+
};
|
|
32400
|
+
const newInfo = __spreadValues({}, info);
|
|
32401
|
+
newInfo[key] = newInfo[key] || {};
|
|
32402
|
+
newInfo[key].state = "loading";
|
|
32511
32403
|
newInfo[key].errorMessage = "";
|
|
32512
|
-
newInfo
|
|
32513
|
-
|
|
32514
|
-
|
|
32515
|
-
|
|
32516
|
-
|
|
32517
|
-
newInfo[key].
|
|
32404
|
+
setInfo(newInfo);
|
|
32405
|
+
try {
|
|
32406
|
+
const consulta = yield import_axios.default.request(options);
|
|
32407
|
+
const d = consulta.data;
|
|
32408
|
+
newInfo[key].state = "success";
|
|
32409
|
+
newInfo[key].errorMessage = "";
|
|
32410
|
+
if (Array.isArray(data)) {
|
|
32411
|
+
for (let datum of data) {
|
|
32412
|
+
const index = (_b = (_a = newInfo[key]) == null ? void 0 : _a.data) == null ? void 0 : _b.findIndex(
|
|
32413
|
+
(d2) => (d2 == null ? void 0 : d2.id) == (datum == null ? void 0 : datum.id)
|
|
32414
|
+
);
|
|
32415
|
+
if (index >= 0) {
|
|
32416
|
+
newInfo[key].data[index] = d;
|
|
32417
|
+
} else {
|
|
32418
|
+
if ((_c2 = newInfo[key]) == null ? void 0 : _c2.data) {
|
|
32419
|
+
newInfo[key].data.unshift(d);
|
|
32420
|
+
} else {
|
|
32421
|
+
newInfo[key].data = [d];
|
|
32422
|
+
}
|
|
32423
|
+
}
|
|
32424
|
+
}
|
|
32425
|
+
} else {
|
|
32426
|
+
newInfo[key].selectedItem = d;
|
|
32427
|
+
const index = (_e2 = (_d2 = newInfo[key]) == null ? void 0 : _d2.data) == null ? void 0 : _e2.findIndex(
|
|
32428
|
+
(d2) => (d2 == null ? void 0 : d2.id) == (d2 == null ? void 0 : d2.id)
|
|
32429
|
+
);
|
|
32430
|
+
if (index >= 0) {
|
|
32431
|
+
newInfo[key].data[index] = d;
|
|
32432
|
+
} else {
|
|
32433
|
+
if ((_f2 = newInfo[key]) == null ? void 0 : _f2.data) {
|
|
32434
|
+
newInfo[key].data.unshift(d);
|
|
32435
|
+
} else {
|
|
32436
|
+
newInfo[key].data = [d];
|
|
32437
|
+
}
|
|
32438
|
+
}
|
|
32439
|
+
}
|
|
32440
|
+
setInfo(__spreadValues({}, newInfo));
|
|
32441
|
+
return d;
|
|
32442
|
+
} catch (error) {
|
|
32443
|
+
const item = http_codes_default.find((s) => s.code == error.status);
|
|
32444
|
+
newInfo[key].state = "error";
|
|
32445
|
+
newInfo[key].errorMessage = (item == null ? void 0 : item.meaning) || error.message;
|
|
32446
|
+
if (error.status == 403) {
|
|
32447
|
+
onError == null ? void 0 : onError(__spreadValues({ error }, { errorMessage: item == null ? void 0 : item.meaning }));
|
|
32448
|
+
}
|
|
32449
|
+
setInfo(__spreadValues({}, newInfo));
|
|
32450
|
+
return error;
|
|
32518
32451
|
}
|
|
32519
|
-
|
|
32520
|
-
|
|
32521
|
-
|
|
32522
|
-
const
|
|
32523
|
-
|
|
32524
|
-
|
|
32525
|
-
|
|
32526
|
-
|
|
32452
|
+
}),
|
|
32453
|
+
update: (id3, data) => __async(null, null, function* () {
|
|
32454
|
+
var _a, _b, _c2;
|
|
32455
|
+
const options = {
|
|
32456
|
+
method: "PATCH",
|
|
32457
|
+
url: `${baseURI}/${key}/${id3}`,
|
|
32458
|
+
data: Array.isArray(data) ? [...data] : __spreadValues({}, data),
|
|
32459
|
+
headers: { Authorization: token }
|
|
32460
|
+
};
|
|
32461
|
+
const newInfo = __spreadValues({}, info);
|
|
32462
|
+
newInfo[key] = newInfo[key] || {};
|
|
32463
|
+
newInfo[key].state = "loading";
|
|
32464
|
+
newInfo[key].errorMessage = "";
|
|
32465
|
+
setInfo(newInfo);
|
|
32466
|
+
try {
|
|
32467
|
+
const consulta = yield import_axios.default.request(options);
|
|
32468
|
+
const d = consulta.data;
|
|
32469
|
+
newInfo[key].state = "success";
|
|
32470
|
+
newInfo[key].errorMessage = "";
|
|
32471
|
+
newInfo[key].selectedItem = d;
|
|
32472
|
+
const index = (_b = (_a = newInfo[key]) == null ? void 0 : _a.data) == null ? void 0 : _b.findIndex(
|
|
32473
|
+
(d2) => (d2 == null ? void 0 : d2.id) == (d2 == null ? void 0 : d2.id)
|
|
32474
|
+
);
|
|
32475
|
+
if (index >= 0) {
|
|
32476
|
+
newInfo[key].data[index] = d;
|
|
32477
|
+
} else {
|
|
32478
|
+
if ((_c2 = newInfo[key]) == null ? void 0 : _c2.data) {
|
|
32479
|
+
newInfo[key].data.unshift(d);
|
|
32480
|
+
} else {
|
|
32481
|
+
newInfo[key].data = [d];
|
|
32482
|
+
}
|
|
32483
|
+
}
|
|
32484
|
+
setInfo(__spreadValues({}, newInfo));
|
|
32485
|
+
return d;
|
|
32486
|
+
} catch (error) {
|
|
32487
|
+
const item = http_codes_default.find((s) => s.code == error.status);
|
|
32488
|
+
newInfo[key].state = "error";
|
|
32489
|
+
newInfo[key].errorMessage = (item == null ? void 0 : item.meaning) || error.message;
|
|
32490
|
+
if (error.status == 403) {
|
|
32491
|
+
onError == null ? void 0 : onError(__spreadValues({ error }, { errorMessage: item == null ? void 0 : item.meaning }));
|
|
32492
|
+
}
|
|
32493
|
+
setInfo(__spreadValues({}, newInfo));
|
|
32494
|
+
return error;
|
|
32527
32495
|
}
|
|
32528
|
-
|
|
32529
|
-
|
|
32530
|
-
|
|
32531
|
-
|
|
32532
|
-
|
|
32533
|
-
|
|
32534
|
-
|
|
32535
|
-
|
|
32536
|
-
|
|
32537
|
-
|
|
32538
|
-
|
|
32539
|
-
|
|
32540
|
-
|
|
32541
|
-
|
|
32542
|
-
|
|
32543
|
-
|
|
32544
|
-
|
|
32545
|
-
|
|
32496
|
+
}),
|
|
32497
|
+
remove: (id3) => __async(null, null, function* () {
|
|
32498
|
+
var _a, _b;
|
|
32499
|
+
const options = {
|
|
32500
|
+
method: "DELETE",
|
|
32501
|
+
url: `${baseURI}/${key}/${id3}`,
|
|
32502
|
+
headers: { Authorization: token }
|
|
32503
|
+
};
|
|
32504
|
+
const newInfo = __spreadValues({}, info);
|
|
32505
|
+
newInfo[key] = newInfo[key] || {};
|
|
32506
|
+
newInfo[key].state = "loading";
|
|
32507
|
+
newInfo[key].errorMessage = "";
|
|
32508
|
+
setInfo(newInfo);
|
|
32509
|
+
try {
|
|
32510
|
+
const consulta = yield import_axios.default.request(options);
|
|
32511
|
+
const d = consulta.data;
|
|
32512
|
+
newInfo[key].state = "success";
|
|
32513
|
+
newInfo[key].errorMessage = "";
|
|
32514
|
+
newInfo[key].selectedItem = d;
|
|
32515
|
+
const index = (_b = (_a = newInfo[key]) == null ? void 0 : _a.data) == null ? void 0 : _b.findIndex(
|
|
32516
|
+
(d2) => (d2 == null ? void 0 : d2.id) == (d2 == null ? void 0 : d2.id)
|
|
32517
|
+
);
|
|
32518
|
+
if (index >= 0) {
|
|
32519
|
+
newInfo[key].data.splice(index, 1);
|
|
32520
|
+
}
|
|
32521
|
+
setInfo(__spreadValues({}, newInfo));
|
|
32522
|
+
return d.data;
|
|
32523
|
+
} catch (error) {
|
|
32524
|
+
const item = http_codes_default.find((s) => s.code == error.status);
|
|
32525
|
+
newInfo[key].state = "error";
|
|
32526
|
+
newInfo[key].errorMessage = (item == null ? void 0 : item.meaning) || error.message;
|
|
32527
|
+
if (error.status == 403) {
|
|
32528
|
+
onError == null ? void 0 : onError(__spreadValues({ error }, { errorMessage: item == null ? void 0 : item.meaning }));
|
|
32529
|
+
}
|
|
32530
|
+
setInfo(__spreadValues({}, newInfo));
|
|
32531
|
+
return error;
|
|
32532
|
+
}
|
|
32533
|
+
}),
|
|
32534
|
+
totalPages: (_g = info[key]) == null ? void 0 : _g.totalPages,
|
|
32535
|
+
currentPage: (_h = info[key]) == null ? void 0 : _h.currentPage,
|
|
32536
|
+
state: ((_i = info[key]) == null ? void 0 : _i.state) || "success",
|
|
32537
|
+
errorMessage: (_j = info[key]) == null ? void 0 : _j.errorMessage,
|
|
32538
|
+
params: (_k = info[key]) == null ? void 0 : _k.params,
|
|
32539
|
+
getAllPages: (limit = 10) => __async(null, null, function* () {
|
|
32540
|
+
console.log("Not aviable");
|
|
32541
|
+
}),
|
|
32542
|
+
data: ((_l = info[key]) == null ? void 0 : _l.data) || [],
|
|
32543
|
+
selectedItem: ((_m = info[key]) == null ? void 0 : _m.selectedItem) || {}
|
|
32544
|
+
});
|
|
32545
|
+
return acc;
|
|
32546
|
+
}, {})
|
|
32547
|
+
);
|
|
32548
|
+
}, []);
|
|
32546
32549
|
return info;
|
|
32547
32550
|
}
|
|
32548
32551
|
|