shelflife-react-hooks 1.0.13 → 1.0.14
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.cjs.js +11 -16
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.cts +34 -16
- package/dist/index.d.ts +34 -16
- package/dist/index.esm.js +11 -16
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -498,19 +498,11 @@ var updateById2 = (items, updated) => {
|
|
|
498
498
|
next[index] = updated;
|
|
499
499
|
return next;
|
|
500
500
|
};
|
|
501
|
-
var fetchProductsRequest = async (config,
|
|
501
|
+
var fetchProductsRequest = async (config, search, size, page) => runWithRequestState(config, async () => {
|
|
502
502
|
const normalizedBaseUrl = normalizeBaseUrl(config.baseUrl);
|
|
503
|
-
|
|
504
|
-
if (
|
|
505
|
-
|
|
506
|
-
}
|
|
507
|
-
if (query?.name) {
|
|
508
|
-
params.set("name", query.name);
|
|
509
|
-
}
|
|
510
|
-
if (query?.category) {
|
|
511
|
-
params.set("category", query.category);
|
|
512
|
-
}
|
|
513
|
-
const url = params.toString() ? `${normalizedBaseUrl}/api/products?${params.toString()}` : `${normalizedBaseUrl}/api/products`;
|
|
503
|
+
let url = `${normalizedBaseUrl}/api/products?search=${search}`;
|
|
504
|
+
if (size > 0)
|
|
505
|
+
url += `&page=${page}&size=${size}`;
|
|
514
506
|
const response = await fetch(url, {
|
|
515
507
|
headers: buildAuthHeaders(config.token)
|
|
516
508
|
});
|
|
@@ -648,7 +640,7 @@ var ProductProvider = ({ baseUrl, children }) => {
|
|
|
648
640
|
setError
|
|
649
641
|
}), [baseUrl, token]);
|
|
650
642
|
const fetchProducts = (0, import_react3.useCallback)(
|
|
651
|
-
(
|
|
643
|
+
(search = "", size = 0, page = 0) => fetchProductsRequest(apiConfig, search, size, page),
|
|
652
644
|
[apiConfig]
|
|
653
645
|
);
|
|
654
646
|
const fetchProduct = (0, import_react3.useCallback)((id) => fetchProductRequest(apiConfig, id), [apiConfig]);
|
|
@@ -876,11 +868,14 @@ var updateById4 = (items, updated) => {
|
|
|
876
868
|
next[index] = updated;
|
|
877
869
|
return next;
|
|
878
870
|
};
|
|
879
|
-
var fetchStoragesRequest = async (config) => runWithRequestState(
|
|
871
|
+
var fetchStoragesRequest = async (config, search, size, page) => runWithRequestState(
|
|
880
872
|
config,
|
|
881
873
|
async () => {
|
|
882
874
|
const normalizedBaseUrl = normalizeBaseUrl(config.baseUrl);
|
|
883
|
-
|
|
875
|
+
let url = `${normalizedBaseUrl}/api/storages?search=${search}`;
|
|
876
|
+
if (size > 0)
|
|
877
|
+
url += `&page=${page}&size=${size}`;
|
|
878
|
+
const response = await fetch(url, {
|
|
884
879
|
headers: buildAuthHeaders(config.token)
|
|
885
880
|
});
|
|
886
881
|
if (!response.ok) {
|
|
@@ -994,7 +989,7 @@ var StorageProvider = ({ baseUrl, children }) => {
|
|
|
994
989
|
setIsError,
|
|
995
990
|
setError
|
|
996
991
|
}), [baseUrl, token]);
|
|
997
|
-
const fetchStorages = (0, import_react5.useCallback)(() => fetchStoragesRequest(apiConfig), [apiConfig]);
|
|
992
|
+
const fetchStorages = (0, import_react5.useCallback)((search = "", size = 0, page = 0) => fetchStoragesRequest(apiConfig, search, page, size), [apiConfig]);
|
|
998
993
|
const fetchStorage = (0, import_react5.useCallback)((id) => fetchStorageRequest(apiConfig, id), [apiConfig]);
|
|
999
994
|
const createStorage = (0, import_react5.useCallback)(
|
|
1000
995
|
(dto) => createStorageRequest(apiConfig, dto),
|