shelflife-react-hooks 1.0.16 → 1.0.17

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 CHANGED
@@ -1148,6 +1148,36 @@ var fetchAboutToExpireRequest = async (config, storageId) => runWithRequestState
1148
1148
  }
1149
1149
  return [];
1150
1150
  });
1151
+ var fetchAggregatedExpiredRequest = async (config) => runWithRequestState(config, async () => {
1152
+ const normalizedBaseUrl = normalizeBaseUrl(config.baseUrl);
1153
+ const response = await fetch(`${normalizedBaseUrl}/api/expired`, {
1154
+ headers: buildAuthHeaders(config.token)
1155
+ });
1156
+ if (!response.ok) {
1157
+ throw new Error("Failed to fetch expired items");
1158
+ }
1159
+ const payload = await readJson(response);
1160
+ if (payload) {
1161
+ config.setExpiredItems(payload);
1162
+ return payload;
1163
+ }
1164
+ return [];
1165
+ });
1166
+ var fetchAggregatedAboutToExpireRequest = async (config) => runWithRequestState(config, async () => {
1167
+ const normalizedBaseUrl = normalizeBaseUrl(config.baseUrl);
1168
+ const response = await fetch(`${normalizedBaseUrl}/api/abouttoexpire`, {
1169
+ headers: buildAuthHeaders(config.token)
1170
+ });
1171
+ if (!response.ok) {
1172
+ throw new Error("Failed to fetch items about to expire");
1173
+ }
1174
+ const payload = await readJson(response);
1175
+ if (payload) {
1176
+ config.setAboutToExpireItems(payload);
1177
+ return payload;
1178
+ }
1179
+ return [];
1180
+ });
1151
1181
  var fetchRunningLowRequest = async (config, storageId) => runWithRequestState(config, async () => {
1152
1182
  const normalizedBaseUrl = normalizeBaseUrl(config.baseUrl);
1153
1183
  const response = await fetch(`${normalizedBaseUrl}/api/storages/${storageId}/runninglow`, {
@@ -1163,6 +1193,21 @@ var fetchRunningLowRequest = async (config, storageId) => runWithRequestState(co
1163
1193
  }
1164
1194
  return [];
1165
1195
  });
1196
+ var fetchAggregatedRunningLowRequest = async (config) => runWithRequestState(config, async () => {
1197
+ const normalizedBaseUrl = normalizeBaseUrl(config.baseUrl);
1198
+ const response = await fetch(`${normalizedBaseUrl}/api/runninglow`, {
1199
+ headers: buildAuthHeaders(config.token)
1200
+ });
1201
+ if (!response.ok) {
1202
+ throw new Error("Failed to fetch running low items");
1203
+ }
1204
+ const payload = await readJson(response);
1205
+ if (payload) {
1206
+ config.setRunningLow(payload);
1207
+ return payload;
1208
+ }
1209
+ return [];
1210
+ });
1166
1211
 
1167
1212
  // src/context/StorageItemContext.tsx
1168
1213
  var import_jsx_runtime6 = require("react/jsx-runtime");
@@ -1204,14 +1249,26 @@ var StorageItemProvider = ({ baseUrl, children }) => {
1204
1249
  (storageId) => fetchExpiredRequest(apiConfig, storageId),
1205
1250
  [apiConfig]
1206
1251
  );
1252
+ const fetchExpiredAggregated = (0, import_react6.useCallback)(
1253
+ () => fetchAggregatedExpiredRequest(apiConfig),
1254
+ [apiConfig]
1255
+ );
1207
1256
  const fetchAboutToExpire = (0, import_react6.useCallback)(
1208
1257
  (storageId) => fetchAboutToExpireRequest(apiConfig, storageId),
1209
1258
  [apiConfig]
1210
1259
  );
1260
+ const fetchAboutToExpireAggregated = (0, import_react6.useCallback)(
1261
+ () => fetchAggregatedAboutToExpireRequest(apiConfig),
1262
+ [apiConfig]
1263
+ );
1211
1264
  const fetchRunningLow = (0, import_react6.useCallback)(
1212
1265
  (storageId) => fetchRunningLowRequest(apiConfig, storageId),
1213
1266
  [apiConfig]
1214
1267
  );
1268
+ const fetchRunningLowAggregated = (0, import_react6.useCallback)(
1269
+ () => fetchAggregatedRunningLowRequest(apiConfig),
1270
+ [apiConfig]
1271
+ );
1215
1272
  const value = (0, import_react6.useMemo)(() => ({
1216
1273
  items,
1217
1274
  expiredItems,
@@ -1225,8 +1282,11 @@ var StorageItemProvider = ({ baseUrl, children }) => {
1225
1282
  editItem,
1226
1283
  deleteItem,
1227
1284
  fetchExpired,
1285
+ fetchExpiredAggregated,
1228
1286
  fetchAboutToExpire,
1229
- fetchRunningLow
1287
+ fetchAboutToExpireAggregated,
1288
+ fetchRunningLow,
1289
+ fetchRunningLowAggregated
1230
1290
  }), [
1231
1291
  aboutToExpireItems,
1232
1292
  addItem,
@@ -1539,7 +1599,7 @@ var import_react10 = require("react");
1539
1599
  // src/context/api/toPurchaseApi.ts
1540
1600
  var fetchAggregatedShoppingRequest = async (config) => runWithRequestState(config, async () => {
1541
1601
  const normalizedBaseUrl = normalizeBaseUrl(config.baseUrl);
1542
- const response = await fetch(`${normalizedBaseUrl}/api/tobuy/shopping`, {
1602
+ const response = await fetch(`${normalizedBaseUrl}/api/shoppinglist`, {
1543
1603
  headers: buildAuthHeaders(config.token)
1544
1604
  });
1545
1605
  if (!response.ok) {