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.d.ts CHANGED
@@ -335,8 +335,11 @@ type StorageItemContextValue = {
335
335
  editItem: (storageId: number, itemId: number, dto: EditItemRequest) => Promise<StorageItem>;
336
336
  deleteItem: (storageId: number, itemId: number) => Promise<void>;
337
337
  fetchExpired: (storageId: number) => Promise<StorageItem[]>;
338
+ fetchExpiredAggregated: () => Promise<StorageItem[]>;
338
339
  fetchAboutToExpire: (storageId: number) => Promise<StorageItem[]>;
340
+ fetchAboutToExpireAggregated: () => Promise<StorageItem[]>;
339
341
  fetchRunningLow: (storageId: number) => Promise<RunningLowNotification[]>;
342
+ fetchRunningLowAggregated: () => Promise<RunningLowNotification[]>;
340
343
  };
341
344
  type StorageItemProviderProps = {
342
345
  baseUrl: string;
package/dist/index.esm.js CHANGED
@@ -1136,6 +1136,36 @@ var fetchAboutToExpireRequest = async (config, storageId) => runWithRequestState
1136
1136
  }
1137
1137
  return [];
1138
1138
  });
1139
+ var fetchAggregatedExpiredRequest = async (config) => runWithRequestState(config, async () => {
1140
+ const normalizedBaseUrl = normalizeBaseUrl(config.baseUrl);
1141
+ const response = await fetch(`${normalizedBaseUrl}/api/expired`, {
1142
+ headers: buildAuthHeaders(config.token)
1143
+ });
1144
+ if (!response.ok) {
1145
+ throw new Error("Failed to fetch expired items");
1146
+ }
1147
+ const payload = await readJson(response);
1148
+ if (payload) {
1149
+ config.setExpiredItems(payload);
1150
+ return payload;
1151
+ }
1152
+ return [];
1153
+ });
1154
+ var fetchAggregatedAboutToExpireRequest = async (config) => runWithRequestState(config, async () => {
1155
+ const normalizedBaseUrl = normalizeBaseUrl(config.baseUrl);
1156
+ const response = await fetch(`${normalizedBaseUrl}/api/abouttoexpire`, {
1157
+ headers: buildAuthHeaders(config.token)
1158
+ });
1159
+ if (!response.ok) {
1160
+ throw new Error("Failed to fetch items about to expire");
1161
+ }
1162
+ const payload = await readJson(response);
1163
+ if (payload) {
1164
+ config.setAboutToExpireItems(payload);
1165
+ return payload;
1166
+ }
1167
+ return [];
1168
+ });
1139
1169
  var fetchRunningLowRequest = async (config, storageId) => runWithRequestState(config, async () => {
1140
1170
  const normalizedBaseUrl = normalizeBaseUrl(config.baseUrl);
1141
1171
  const response = await fetch(`${normalizedBaseUrl}/api/storages/${storageId}/runninglow`, {
@@ -1151,6 +1181,21 @@ var fetchRunningLowRequest = async (config, storageId) => runWithRequestState(co
1151
1181
  }
1152
1182
  return [];
1153
1183
  });
1184
+ var fetchAggregatedRunningLowRequest = async (config) => runWithRequestState(config, async () => {
1185
+ const normalizedBaseUrl = normalizeBaseUrl(config.baseUrl);
1186
+ const response = await fetch(`${normalizedBaseUrl}/api/runninglow`, {
1187
+ headers: buildAuthHeaders(config.token)
1188
+ });
1189
+ if (!response.ok) {
1190
+ throw new Error("Failed to fetch running low items");
1191
+ }
1192
+ const payload = await readJson(response);
1193
+ if (payload) {
1194
+ config.setRunningLow(payload);
1195
+ return payload;
1196
+ }
1197
+ return [];
1198
+ });
1154
1199
 
1155
1200
  // src/context/StorageItemContext.tsx
1156
1201
  import { jsx as jsx6 } from "react/jsx-runtime";
@@ -1192,14 +1237,26 @@ var StorageItemProvider = ({ baseUrl, children }) => {
1192
1237
  (storageId) => fetchExpiredRequest(apiConfig, storageId),
1193
1238
  [apiConfig]
1194
1239
  );
1240
+ const fetchExpiredAggregated = useCallback6(
1241
+ () => fetchAggregatedExpiredRequest(apiConfig),
1242
+ [apiConfig]
1243
+ );
1195
1244
  const fetchAboutToExpire = useCallback6(
1196
1245
  (storageId) => fetchAboutToExpireRequest(apiConfig, storageId),
1197
1246
  [apiConfig]
1198
1247
  );
1248
+ const fetchAboutToExpireAggregated = useCallback6(
1249
+ () => fetchAggregatedAboutToExpireRequest(apiConfig),
1250
+ [apiConfig]
1251
+ );
1199
1252
  const fetchRunningLow = useCallback6(
1200
1253
  (storageId) => fetchRunningLowRequest(apiConfig, storageId),
1201
1254
  [apiConfig]
1202
1255
  );
1256
+ const fetchRunningLowAggregated = useCallback6(
1257
+ () => fetchAggregatedRunningLowRequest(apiConfig),
1258
+ [apiConfig]
1259
+ );
1203
1260
  const value = useMemo6(() => ({
1204
1261
  items,
1205
1262
  expiredItems,
@@ -1213,8 +1270,11 @@ var StorageItemProvider = ({ baseUrl, children }) => {
1213
1270
  editItem,
1214
1271
  deleteItem,
1215
1272
  fetchExpired,
1273
+ fetchExpiredAggregated,
1216
1274
  fetchAboutToExpire,
1217
- fetchRunningLow
1275
+ fetchAboutToExpireAggregated,
1276
+ fetchRunningLow,
1277
+ fetchRunningLowAggregated
1218
1278
  }), [
1219
1279
  aboutToExpireItems,
1220
1280
  addItem,
@@ -1539,7 +1599,7 @@ import { createContext as createContext10, useCallback as useCallback10, useCont
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) {