@burdenoff/microfe-movethewheels 2026.920.3 → 2026.923.1

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.
Files changed (79) hide show
  1. package/dist/components/CarbonFootprintPanel.js +1 -1
  2. package/dist/components/CustomerPicker.js +76 -65
  3. package/dist/components/DataTable.js +140 -139
  4. package/dist/components/DocumentsCard.js +14 -8
  5. package/dist/generated/wspace-types.d.ts +2719 -8
  6. package/dist/hooks/index.js +1 -1
  7. package/dist/hooks/useAnalytics.js +21 -1
  8. package/dist/hooks/useCustomers.js +94 -78
  9. package/dist/hooks/useDebouncedValue.js +11 -0
  10. package/dist/hooks/useEntityDocuments.js +28 -18
  11. package/dist/hooks/useEpod.js +24 -17
  12. package/dist/hooks/useFleet.js +148 -125
  13. package/dist/hooks/useInventory.js +255 -186
  14. package/dist/hooks/useMultiModalShipments.js +35 -27
  15. package/dist/hooks/useOrders.js +139 -134
  16. package/dist/hooks/useRoutes.js +97 -75
  17. package/dist/hooks/useTracking.js +100 -88
  18. package/dist/index.js +6 -6
  19. package/dist/movethewheels/components/CustomerPicker.d.ts +3 -1
  20. package/dist/movethewheels/components/DataTable.d.ts +5 -1
  21. package/dist/movethewheels/hooks/useCustomers.d.ts +0 -1
  22. package/dist/movethewheels/hooks/useDebouncedValue.d.ts +1 -0
  23. package/dist/movethewheels/hooks/useEntityDocuments.d.ts +2 -0
  24. package/dist/movethewheels/hooks/useEpod.d.ts +6 -1
  25. package/dist/movethewheels/hooks/useFleet.d.ts +49 -5
  26. package/dist/movethewheels/hooks/useInventory.d.ts +24 -17
  27. package/dist/movethewheels/hooks/useMultiModalShipments.d.ts +6 -1
  28. package/dist/movethewheels/hooks/useOrders.d.ts +48 -5
  29. package/dist/movethewheels/hooks/useRoutes.d.ts +18 -1
  30. package/dist/movethewheels/hooks/useTracking.d.ts +12 -11
  31. package/dist/movethewheels/types/index.d.ts +12 -5
  32. package/dist/pages/CreateOrderPage.js +191 -129
  33. package/dist/pages/CustomersPage.js +61 -54
  34. package/dist/pages/DeliveryCapturePage.js +131 -109
  35. package/dist/pages/DriversPage.js +100 -92
  36. package/dist/pages/InventoryPage.js +239 -236
  37. package/dist/pages/MultiModalShipmentPage.js +163 -130
  38. package/dist/pages/OrderDetailsPage.js +190 -106
  39. package/dist/pages/OrdersListPage.js +66 -60
  40. package/dist/pages/ProductDetailsPage.js +241 -200
  41. package/dist/pages/ProductsPage.js +59 -52
  42. package/dist/pages/RouteDetailsPage.js +324 -293
  43. package/dist/pages/RoutesPage.js +55 -48
  44. package/dist/pages/VehiclesPage.js +63 -56
  45. package/dist/pages/WarehousesPage.js +60 -53
  46. package/package.json +1 -1
  47. package/src/generated/wspace-types.ts +3136 -8
  48. package/src/movethewheels/components/CarbonFootprintPanel.tsx +0 -1
  49. package/src/movethewheels/components/CustomerPicker.tsx +14 -0
  50. package/src/movethewheels/components/DataTable.tsx +34 -18
  51. package/src/movethewheels/components/DocumentsCard.tsx +6 -1
  52. package/src/movethewheels/components/maps/leaflet-setup.ts +1 -8
  53. package/src/movethewheels/hooks/useAnalytics.ts +27 -0
  54. package/src/movethewheels/hooks/useCustomers.ts +64 -24
  55. package/src/movethewheels/hooks/useDebouncedValue.ts +12 -0
  56. package/src/movethewheels/hooks/useEntityDocuments.ts +43 -25
  57. package/src/movethewheels/hooks/useEpod.ts +14 -7
  58. package/src/movethewheels/hooks/useFleet.ts +66 -38
  59. package/src/movethewheels/hooks/useFleetIntelligence.ts +1 -4
  60. package/src/movethewheels/hooks/useInventory.ts +211 -90
  61. package/src/movethewheels/hooks/useMultiModalShipments.ts +15 -11
  62. package/src/movethewheels/hooks/useOrders.ts +48 -14
  63. package/src/movethewheels/hooks/useRoutes.ts +81 -24
  64. package/src/movethewheels/hooks/useTracking.ts +130 -98
  65. package/src/movethewheels/pages/CreateOrderPage.tsx +93 -2
  66. package/src/movethewheels/pages/CustomersPage.tsx +11 -1
  67. package/src/movethewheels/pages/DeliveryCapturePage.tsx +31 -1
  68. package/src/movethewheels/pages/DriversPage.tsx +24 -12
  69. package/src/movethewheels/pages/InventoryPage.tsx +57 -32
  70. package/src/movethewheels/pages/MultiModalShipmentPage.tsx +52 -3
  71. package/src/movethewheels/pages/OrderDetailsPage.tsx +91 -6
  72. package/src/movethewheels/pages/OrdersListPage.tsx +20 -3
  73. package/src/movethewheels/pages/ProductDetailsPage.tsx +52 -3
  74. package/src/movethewheels/pages/ProductsPage.tsx +11 -1
  75. package/src/movethewheels/pages/RouteDetailsPage.tsx +45 -5
  76. package/src/movethewheels/pages/RoutesPage.tsx +11 -1
  77. package/src/movethewheels/pages/VehiclesPage.tsx +19 -2
  78. package/src/movethewheels/pages/WarehousesPage.tsx +11 -1
  79. package/src/movethewheels/types/index.ts +12 -5
@@ -2,7 +2,7 @@ import { useMoveTheWheels as e } from "../providers/MoveTheWheelsProvider.js";
2
2
  import { executeGraphQL as t } from "../utils/graphqlClient.js";
3
3
  import { useCallback as n, useEffect as r, useMemo as i, useState as a } from "react";
4
4
  //#region src/movethewheels/hooks/useInventory.ts
5
- var o = "\n query ListInventoryItems($filter: InventoryFilterInput, $pagination: PaginationInput) {\n inventoryItems(filter: $filter, pagination: $pagination) {\n id\n cargoItemId\n warehouseId\n onHand\n available\n allocated\n damaged\n reorderPoint\n createdAt\n updatedAt\n }\n }\n", s = "\n query ListCargoItems($filter: CargoItemFilterInput, $pagination: PaginationInput) {\n cargoItems(filter: $filter, pagination: $pagination) {\n id\n sku\n name\n description\n category\n brand\n dimensions\n weight\n value\n hazardous\n fragile\n temperatureControlled\n createdAt\n updatedAt\n }\n }\n", c = "\n query ListWarehouses($filter: WarehouseFilterInput, $pagination: PaginationInput) {\n warehouses(filter: $filter, pagination: $pagination) {\n id\n name\n code\n type\n address\n totalCapacity\n usedCapacity\n createdAt\n }\n }\n", l = "\n query GetCargoItem($id: ID!) {\n cargoItem(id: $id) {\n id\n sku\n name\n description\n category\n brand\n dimensions\n weight\n value\n hazardous\n fragile\n temperatureControlled\n createdAt\n updatedAt\n }\n }\n", u = "\n query GetWarehouse($id: ID!) {\n warehouse(id: $id) {\n id\n name\n code\n type\n address\n totalCapacity\n usedCapacity\n createdAt\n }\n }\n", d = "\n query GetInventoryStats {\n inventoryStats {\n totalOnHand\n totalAvailable\n totalAllocated\n totalDamaged\n lowStockCount\n }\n cargoItemsCount\n warehousesCount\n }\n", f = "\n query ListInventoryTransactions($filter: InventoryFilterInput, $pagination: PaginationInput) {\n inventoryTransactions(filter: $filter, pagination: $pagination) {\n id\n transactionNumber\n type\n quantity\n cargoItemId\n warehouseId\n notes\n referenceType\n referenceId\n createdAt\n }\n }\n", p = "\n mutation CreateCargoItem($input: CreateCargoItemInput!) {\n createCargoItem(input: $input) {\n id\n sku\n name\n description\n category\n brand\n dimensions\n weight\n value\n hazardous\n fragile\n temperatureControlled\n createdAt\n updatedAt\n }\n }\n", m = "\n mutation UpdateCargoItem($id: ID!, $input: UpdateCargoItemInput!) {\n updateCargoItem(id: $id, input: $input) {\n id\n sku\n name\n description\n category\n brand\n dimensions\n weight\n value\n hazardous\n fragile\n temperatureControlled\n createdAt\n updatedAt\n }\n }\n", h = "\n mutation CreateWarehouse($input: CreateWarehouseInput!) {\n createWarehouse(input: $input) {\n id\n name\n code\n type\n address\n totalCapacity\n usedCapacity\n createdAt\n }\n }\n", g = "\n mutation UpdateWarehouse($id: ID!, $input: UpdateWarehouseInput!) {\n updateWarehouse(id: $id, input: $input) {\n id\n name\n code\n type\n address\n totalCapacity\n usedCapacity\n createdAt\n }\n }\n", _ = "\n mutation AdjustInventoryStock($input: AdjustInventoryStockInput!) {\n adjustInventoryStock(input: $input) {\n id\n cargoItemId\n warehouseId\n onHand\n available\n allocated\n damaged\n reorderPoint\n createdAt\n updatedAt\n }\n }\n";
5
+ var o = "\n query ListInventoryItems($filter: InventoryFilterInput, $pagination: PaginationInput) {\n inventoryItems(filter: $filter, pagination: $pagination) {\n id\n cargoItemId\n warehouseId\n onHand\n available\n allocated\n damaged\n reorderPoint\n createdAt\n updatedAt\n cargoItem {\n id\n name\n sku\n }\n warehouse {\n id\n name\n code\n }\n }\n inventoryItemsCount(filter: $filter)\n }\n", s = "\n query ListCargoItems($filter: CargoItemFilterInput, $pagination: PaginationInput) {\n cargoItems(filter: $filter, pagination: $pagination) {\n id\n sku\n name\n description\n category\n brand\n dimensions\n weight\n value\n hazardous\n fragile\n temperatureControlled\n createdAt\n updatedAt\n }\n cargoItemsCount(filter: $filter)\n }\n", c = "\n query ListWarehouses($filter: WarehouseFilterInput, $pagination: PaginationInput) {\n warehouses(filter: $filter, pagination: $pagination) {\n id\n name\n code\n type\n address\n totalCapacity\n usedCapacity\n createdAt\n }\n warehousesCount(filter: $filter)\n }\n", l = "\n query GetCargoItem($id: ID!) {\n cargoItem(id: $id) {\n id\n sku\n name\n description\n category\n brand\n dimensions\n weight\n value\n hazardous\n fragile\n temperatureControlled\n createdAt\n updatedAt\n }\n }\n", u = "\n query GetWarehouse($id: ID!) {\n warehouse(id: $id) {\n id\n name\n code\n type\n address\n totalCapacity\n usedCapacity\n createdAt\n }\n }\n", d = "\n query GetInventoryStats {\n inventoryStats {\n totalOnHand\n totalAvailable\n totalAllocated\n totalDamaged\n lowStockCount\n }\n cargoItemsCount\n warehousesCount\n }\n", f = "\n query ListInventoryTransactions($filter: InventoryFilterInput, $pagination: PaginationInput) {\n inventoryTransactions(filter: $filter, pagination: $pagination) {\n id\n transactionNumber\n type\n quantity\n cargoItemId\n warehouseId\n notes\n referenceType\n referenceId\n createdAt\n }\n }\n", p = "\n mutation CreateCargoItem($input: CreateCargoItemInput!) {\n createCargoItem(input: $input) {\n id\n sku\n name\n description\n category\n brand\n dimensions\n weight\n value\n hazardous\n fragile\n temperatureControlled\n createdAt\n updatedAt\n }\n }\n", m = "\n mutation UpdateCargoItem($id: ID!, $input: UpdateCargoItemInput!) {\n updateCargoItem(id: $id, input: $input) {\n id\n sku\n name\n description\n category\n brand\n dimensions\n weight\n value\n hazardous\n fragile\n temperatureControlled\n createdAt\n updatedAt\n }\n }\n", h = "\n mutation CreateWarehouse($input: CreateWarehouseInput!) {\n createWarehouse(input: $input) {\n id\n name\n code\n type\n address\n totalCapacity\n usedCapacity\n createdAt\n }\n }\n", g = "\n mutation UpdateWarehouse($id: ID!, $input: UpdateWarehouseInput!) {\n updateWarehouse(id: $id, input: $input) {\n id\n name\n code\n type\n address\n totalCapacity\n usedCapacity\n createdAt\n }\n }\n", _ = "\n mutation AdjustInventoryStock($input: AdjustInventoryStockInput!) {\n adjustInventoryStock(input: $input) {\n id\n cargoItemId\n warehouseId\n onHand\n available\n allocated\n damaged\n reorderPoint\n createdAt\n updatedAt\n }\n }\n";
6
6
  function v(e) {
7
7
  return {
8
8
  id: e.id,
@@ -74,7 +74,10 @@ function b(e) {
74
74
  return {
75
75
  id: e.id,
76
76
  productId: e.cargoItemId,
77
+ productName: e.cargoItem?.name,
78
+ productSku: e.cargoItem?.sku,
77
79
  warehouseId: e.warehouseId,
80
+ warehouseName: e.warehouse?.name,
78
81
  zoneId: "",
79
82
  quantity: e.onHand,
80
83
  reservedQuantity: e.allocated,
@@ -112,167 +115,206 @@ function x() {
112
115
  ]);
113
116
  }
114
117
  function S(e = {}) {
115
- let { filters: l } = e, u = i(() => l, [
118
+ let { filters: l, search: u, limit: d = 10, offset: f = 0 } = e, S = i(() => l, [
116
119
  l?.lowStock,
117
120
  l?.productId,
121
+ l?.search,
118
122
  l?.warehouseId
119
- ]), d = x(), [f, S] = a([]), [C, w] = a([]), [T, E] = a([]), [D, O] = a(!1), [k, A] = a(null), j = n(async () => {
120
- O(!0), A(null);
123
+ ]), C = x(), [w, T] = a([]), [E, D] = a([]), [O, k] = a([]), [A, j] = a([]), [M, N] = a(0), [P, F] = a(!1), [I, L] = a(!1), [R, z] = a(null), B = n(async () => {
124
+ L(!0), z(null);
121
125
  try {
122
- let [e, n, r] = await Promise.all([
123
- t(d, o, {
126
+ let e = {
127
+ warehouseId: S?.warehouseId,
128
+ cargoItemId: S?.productId,
129
+ search: u || S?.search || void 0,
130
+ lowStock: S?.lowStock || void 0
131
+ }, [n, r, i, a] = await Promise.all([
132
+ t(C, o, {
133
+ filter: e,
134
+ pagination: {
135
+ limit: d,
136
+ offset: f
137
+ }
138
+ }),
139
+ t(C, o, {
124
140
  filter: {
125
- warehouseId: u?.warehouseId,
126
- cargoItemId: u?.productId
141
+ warehouseId: S?.warehouseId,
142
+ cargoItemId: S?.productId,
143
+ lowStock: !0
127
144
  },
128
145
  pagination: {
129
- limit: 500,
146
+ limit: 5,
130
147
  offset: 0
131
148
  }
132
149
  }),
133
- t(d, s, { pagination: {
134
- limit: 500,
150
+ t(C, s, { pagination: {
151
+ limit: 5,
135
152
  offset: 0
136
153
  } }),
137
- t(d, c, { pagination: {
138
- limit: 500,
154
+ t(C, c, { pagination: {
155
+ limit: 5,
139
156
  offset: 0
140
157
  } })
141
- ]), i = e.inventoryItems.map(b);
142
- u?.lowStock && (i = i.filter((e) => e.availableQuantity <= e.reorderLevel)), S(i), w(n.cargoItems.map(v)), E(r.warehouses.map(y));
158
+ ]);
159
+ T(n.inventoryItems.map(b)), D(r.inventoryItems.map(b)), N(n.inventoryItemsCount), F(f + n.inventoryItems.length < n.inventoryItemsCount), k(i.cargoItems.map(v)), j(a.warehouses.map(y));
143
160
  } catch (e) {
144
- A(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load inventory data"));
161
+ z(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load inventory data"));
145
162
  } finally {
146
- O(!1);
163
+ L(!1);
147
164
  }
148
- }, [u, d]);
165
+ }, [
166
+ S,
167
+ C,
168
+ d,
169
+ f,
170
+ u
171
+ ]);
149
172
  r(() => {
150
- j();
151
- }, [j]);
152
- let M = n(() => {
153
- j();
154
- }, [j]), N = n(async (e, n, r) => {
155
- let i = f.find((t) => t.id === e);
173
+ B();
174
+ }, [B]);
175
+ let V = n(() => {
176
+ B();
177
+ }, [B]), H = n(async (e, n, r) => {
178
+ let i = w.find((t) => t.id === e);
156
179
  if (!i) throw Error("Inventory item not found");
157
- let a = b((await t(d, _, { input: {
180
+ let a = b((await t(C, _, { input: {
158
181
  id: e,
159
182
  onHand: i.quantity + n,
160
183
  available: i.availableQuantity + n,
161
184
  allocated: i.reservedQuantity,
162
185
  damaged: 0
163
186
  } })).adjustInventoryStock);
164
- return S((t) => t.map((t) => t.id === e ? a : t)), a;
165
- }, [d, f]), P = n(async (e, t, n, r) => {
166
- let i = f.find((t) => t.warehouseId === e && t.productId === n);
167
- if (!i) throw Error("Source inventory not found");
168
- await N(i.id, -Math.abs(r), "transfer out");
169
- let a = f.find((e) => e.warehouseId === t && e.productId === n);
170
- a && await N(a.id, Math.abs(r), "transfer in");
171
- }, [f, N]), F = n(async (e) => {
172
- let n = v((await t(d, p, { input: {
173
- name: e.name,
174
- sku: e.sku,
175
- category: e.category,
176
- brand: e.brand,
177
- weight: e.weight
178
- } })).createCargoItem);
179
- return w((e) => [n, ...e]), n;
180
- }, [d]), I = n(async (e) => {
181
- let n = y((await t(d, h, { input: {
182
- code: e.code,
183
- name: e.name,
184
- type: e.type,
185
- address: e.address,
186
- totalCapacity: e.totalCapacity
187
- } })).createWarehouse);
188
- return E((e) => [n, ...e]), n;
189
- }, [d]), L = n(async (e, n) => {
190
- let r = v((await t(d, m, {
191
- id: e,
192
- input: {
193
- name: n.name,
194
- sku: n.sku,
195
- category: n.category,
196
- brand: n.brand,
197
- weight: n.weight
198
- }
199
- })).updateCargoItem);
200
- return w((t) => t.map((t) => t.id === e ? r : t)), r;
201
- }, [d]), R = n(async (e, n) => {
202
- let r = y((await t(d, g, {
203
- id: e,
204
- input: {
205
- code: n.code,
206
- name: n.name,
207
- type: n.type,
208
- address: n.address,
209
- totalCapacity: n.totalCapacity
210
- }
211
- })).updateWarehouse);
212
- return E((t) => t.map((t) => t.id === e ? r : t)), r;
213
- }, [d]);
187
+ return T((t) => t.map((t) => t.id === e ? a : t)), a;
188
+ }, [C, w]);
214
189
  return {
215
- inventory: f,
216
- products: C,
217
- warehouses: T,
218
- totalItems: f.length,
219
- isLoading: D,
220
- error: k,
221
- refetch: M,
222
- updateStock: N,
223
- transferStock: P,
224
- createProduct: F,
225
- createWarehouse: I,
226
- updateProduct: L,
227
- updateWarehouse: R
190
+ inventory: w,
191
+ lowStockItems: E,
192
+ products: O,
193
+ warehouses: A,
194
+ totalItems: M,
195
+ hasMore: P,
196
+ isLoading: I,
197
+ error: R,
198
+ refetch: V,
199
+ updateStock: H,
200
+ transferStock: n(async (e, t, n, r) => {
201
+ let i = w.find((t) => t.warehouseId === e && t.productId === n);
202
+ if (!i) throw Error("Source inventory not found");
203
+ await H(i.id, -Math.abs(r), "transfer out");
204
+ let a = w.find((e) => e.warehouseId === t && e.productId === n);
205
+ a && await H(a.id, Math.abs(r), "transfer in");
206
+ }, [w, H]),
207
+ createProduct: n(async (e) => {
208
+ let n = v((await t(C, p, { input: {
209
+ name: e.name,
210
+ sku: e.sku,
211
+ category: e.category,
212
+ brand: e.brand,
213
+ weight: e.weight
214
+ } })).createCargoItem);
215
+ return k((e) => [n, ...e]), n;
216
+ }, [C]),
217
+ createWarehouse: n(async (e) => {
218
+ let n = y((await t(C, h, { input: {
219
+ code: e.code,
220
+ name: e.name,
221
+ type: e.type,
222
+ address: e.address,
223
+ totalCapacity: e.totalCapacity
224
+ } })).createWarehouse);
225
+ return j((e) => [n, ...e]), n;
226
+ }, [C]),
227
+ updateProduct: n(async (e, n) => {
228
+ let r = v((await t(C, m, {
229
+ id: e,
230
+ input: {
231
+ name: n.name,
232
+ sku: n.sku,
233
+ category: n.category,
234
+ brand: n.brand,
235
+ weight: n.weight
236
+ }
237
+ })).updateCargoItem);
238
+ return k((t) => t.map((t) => t.id === e ? r : t)), r;
239
+ }, [C]),
240
+ updateWarehouse: n(async (e, n) => {
241
+ let r = y((await t(C, g, {
242
+ id: e,
243
+ input: {
244
+ code: n.code,
245
+ name: n.name,
246
+ type: n.type,
247
+ address: n.address,
248
+ totalCapacity: n.totalCapacity
249
+ }
250
+ })).updateWarehouse);
251
+ return j((t) => t.map((t) => t.id === e ? r : t)), r;
252
+ }, [C])
228
253
  };
229
254
  }
230
255
  function C(e = {}) {
231
- let { limit: i = 500, offset: o = 0 } = e, c = x(), [l, u] = a([]), [d, f] = a(!1), [p, m] = a(!1), [h, g] = a(null), _ = n(async () => {
232
- m(!0), g(null);
256
+ let { limit: i = 20, offset: o = 0, search: c, category: l } = e, u = x(), [d, f] = a([]), [p, m] = a(0), [h, g] = a(!1), [_, y] = a(!1), [b, S] = a(null), C = n(async () => {
257
+ y(!0), S(null);
233
258
  try {
234
- let e = await t(c, s, { pagination: {
235
- limit: i,
236
- offset: o
237
- } });
238
- f(e.cargoItems.length === i), u(e.cargoItems.map(v));
259
+ let e = await t(u, s, {
260
+ filter: {
261
+ search: c || void 0,
262
+ category: l || void 0
263
+ },
264
+ pagination: {
265
+ limit: i,
266
+ offset: o
267
+ }
268
+ });
269
+ g(o + e.cargoItems.length < e.cargoItemsCount), m(e.cargoItemsCount), f(e.cargoItems.map(v));
239
270
  } catch (e) {
240
- g(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load products"));
271
+ S(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load products"));
241
272
  } finally {
242
- m(!1);
273
+ y(!1);
243
274
  }
244
275
  }, [
245
- c,
276
+ u,
246
277
  i,
247
- o
278
+ o,
279
+ c,
280
+ l
248
281
  ]);
249
282
  return r(() => {
250
- _();
251
- }, [_]), {
252
- products: l,
253
- totalProducts: l.length,
254
- hasMore: d,
255
- isLoading: p,
256
- error: h,
257
- refetch: () => void _()
283
+ C();
284
+ }, [C]), {
285
+ products: d,
286
+ totalProducts: p,
287
+ hasMore: h,
288
+ isLoading: _,
289
+ error: b,
290
+ refetch: () => void C()
258
291
  };
259
292
  }
260
- function w(e = 500) {
261
- let { products: t, isLoading: n, error: r } = C({
262
- limit: e,
263
- offset: 0
264
- });
265
- return {
266
- stats: i(() => ({
267
- total: t.length,
268
- specialHandling: t.filter((e) => e.fragile || e.hazardous).length,
269
- temperatureControlled: t.filter((e) => e.temperatureControlled).length
270
- }), [t]),
271
- isLoading: n,
272
- error: r
293
+ var w = "\n query CargoItemStats {\n cargoItemStats {\n total\n specialHandling\n temperatureControlled\n }\n }\n";
294
+ function T() {
295
+ let e = x(), [n, i] = a({
296
+ total: 0,
297
+ specialHandling: 0,
298
+ temperatureControlled: 0
299
+ }), [o, s] = a(!1), [c, l] = a(null);
300
+ return r(() => {
301
+ (async () => {
302
+ s(!0), l(null);
303
+ try {
304
+ i((await t(e, w)).cargoItemStats);
305
+ } catch (e) {
306
+ l(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load product stats"));
307
+ } finally {
308
+ s(!1);
309
+ }
310
+ })();
311
+ }, [e]), {
312
+ stats: n,
313
+ isLoading: o,
314
+ error: c
273
315
  };
274
316
  }
275
- function T(e) {
317
+ function E(e) {
276
318
  let i = x(), [o, s] = a(null), [c, u] = a(!1), [d, f] = a(null), p = n(async () => {
277
319
  if (!e) {
278
320
  s(null);
@@ -297,55 +339,65 @@ function T(e) {
297
339
  refetch: () => void p()
298
340
  };
299
341
  }
300
- function E(e = {}) {
301
- let { limit: i = 500, offset: o = 0 } = e, s = x(), [l, u] = a([]), [d, f] = a(!1), [p, m] = a(!1), [h, g] = a(null), _ = n(async () => {
302
- m(!0), g(null);
342
+ function D(e = {}) {
343
+ let { limit: i = 20, offset: o = 0, search: s } = e, l = x(), [u, d] = a([]), [f, p] = a(0), [m, h] = a(!1), [g, _] = a(!1), [v, b] = a(null), S = n(async () => {
344
+ _(!0), b(null);
303
345
  try {
304
- let e = await t(s, c, { pagination: {
305
- limit: i,
306
- offset: o
307
- } });
308
- f(e.warehouses.length === i), u(e.warehouses.map(y));
346
+ let e = await t(l, c, {
347
+ filter: { search: s || void 0 },
348
+ pagination: {
349
+ limit: i,
350
+ offset: o
351
+ }
352
+ });
353
+ p(e.warehousesCount), h(o + e.warehouses.length < e.warehousesCount), d(e.warehouses.map(y));
309
354
  } catch (e) {
310
- g(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load warehouses"));
355
+ b(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load warehouses"));
311
356
  } finally {
312
- m(!1);
357
+ _(!1);
313
358
  }
314
359
  }, [
315
- s,
360
+ l,
316
361
  i,
317
- o
362
+ o,
363
+ s
318
364
  ]);
319
365
  return r(() => {
320
- _();
321
- }, [_]), {
322
- warehouses: l,
323
- totalWarehouses: l.length,
324
- hasMore: d,
325
- isLoading: p,
326
- error: h,
327
- refetch: () => void _()
366
+ S();
367
+ }, [S]), {
368
+ warehouses: u,
369
+ totalWarehouses: f,
370
+ hasMore: m,
371
+ isLoading: g,
372
+ error: v,
373
+ refetch: () => void S()
328
374
  };
329
375
  }
330
- function D(e = 500) {
331
- let { warehouses: t, isLoading: n, error: r } = E({
332
- limit: e,
333
- offset: 0
334
- });
335
- return {
336
- stats: i(() => {
337
- let e = t.length;
338
- return {
339
- total: e,
340
- active: t.filter((e) => e.isActive).length,
341
- avgUtilization: e > 0 ? t.reduce((e, t) => e + (t.capacity.totalSpace > 0 ? t.capacity.usedSpace / t.capacity.totalSpace : 0), 0) / e : 0
342
- };
343
- }, [t]),
344
- isLoading: n,
345
- error: r
376
+ var O = "\n query WarehouseStats {\n warehouseStats {\n total\n active\n avgUtilization\n }\n }\n";
377
+ function k() {
378
+ let e = x(), [n, i] = a({
379
+ total: 0,
380
+ active: 0,
381
+ avgUtilization: 0
382
+ }), [o, s] = a(!1), [c, l] = a(null);
383
+ return r(() => {
384
+ (async () => {
385
+ s(!0), l(null);
386
+ try {
387
+ i((await t(e, O)).warehouseStats);
388
+ } catch (e) {
389
+ l(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load warehouse stats"));
390
+ } finally {
391
+ s(!1);
392
+ }
393
+ })();
394
+ }, [e]), {
395
+ stats: n,
396
+ isLoading: o,
397
+ error: c
346
398
  };
347
399
  }
348
- function O(e) {
400
+ function A(e) {
349
401
  let i = x(), [o, s] = a(null), [c, l] = a(!1), [d, f] = a(null), p = n(async () => {
350
402
  if (!e) {
351
403
  s(null);
@@ -370,7 +422,7 @@ function O(e) {
370
422
  refetch: () => void p()
371
423
  };
372
424
  }
373
- function k() {
425
+ function j() {
374
426
  let e = x(), [n, i] = a({
375
427
  totalOnHand: 0,
376
428
  totalAvailable: 0,
@@ -406,16 +458,23 @@ function k() {
406
458
  error: c
407
459
  };
408
460
  }
409
- var A = "\n query GetCargoItemStockLevels($cargoItemId: ID!) {\n inventoryItems(filter: { cargoItemId: $cargoItemId }, pagination: { limit: 200, offset: 0 }) {\n id\n onHand\n available\n allocated\n damaged\n reorderPoint\n warehouse {\n id\n name\n code\n }\n }\n }\n";
410
- function j(e) {
411
- let i = x(), [o, s] = a([]), [c, l] = a(!1), [u, d] = a(null), f = n(async () => {
461
+ var M = "\n query GetCargoItemStockLevels($cargoItemId: ID!, $pagination: PaginationInput) {\n inventoryItems(filter: { cargoItemId: $cargoItemId }, pagination: $pagination) {\n id\n onHand\n available\n allocated\n damaged\n reorderPoint\n warehouse {\n id\n name\n code\n }\n }\n inventoryItemsCount(filter: { cargoItemId: $cargoItemId })\n inventoryStats(filter: { cargoItemId: $cargoItemId }) {\n totalAvailable\n }\n }\n";
462
+ function N(e, i = {}) {
463
+ let { limit: o = 20, offset: s = 0 } = i, c = x(), [l, u] = a([]), [d, f] = a(0), [p, m] = a(0), [h, g] = a(!1), [_, v] = a(null), y = n(async () => {
412
464
  if (!e) {
413
- s([]);
465
+ u([]), f(0), m(0);
414
466
  return;
415
467
  }
416
- l(!0), d(null);
468
+ g(!0), v(null);
417
469
  try {
418
- s((await t(i, A, { cargoItemId: e })).inventoryItems.map((e) => ({
470
+ let n = await t(c, M, {
471
+ cargoItemId: e,
472
+ pagination: {
473
+ limit: o,
474
+ offset: s
475
+ }
476
+ });
477
+ u((n.inventoryItems ?? []).map((e) => ({
419
478
  inventoryItemId: e.id,
420
479
  warehouseId: e.warehouse?.id ?? "",
421
480
  warehouseName: e.warehouse?.name ?? "Unknown warehouse",
@@ -425,40 +484,50 @@ function j(e) {
425
484
  allocated: e.allocated,
426
485
  damaged: e.damaged,
427
486
  reorderPoint: e.reorderPoint ?? void 0
428
- })));
487
+ }))), f(n.inventoryItemsCount ?? 0), m(n.inventoryStats?.totalAvailable ?? 0);
429
488
  } catch (e) {
430
- d(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load stock levels"));
489
+ v(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load stock levels"));
431
490
  } finally {
432
- l(!1);
491
+ g(!1);
433
492
  }
434
- }, [i, e]);
435
- return r(() => {
436
- f();
437
- }, [f]), {
438
- levels: o,
439
- isLoading: c,
440
- error: u,
441
- refetch: n(() => {
442
- f();
443
- }, [f])
493
+ }, [
494
+ c,
495
+ o,
496
+ s,
497
+ e
498
+ ]);
499
+ r(() => {
500
+ y();
501
+ }, [y]);
502
+ let b = n(() => {
503
+ y();
504
+ }, [y]);
505
+ return {
506
+ levels: l,
507
+ totalLevels: d,
508
+ totalAvailable: p,
509
+ hasMore: s + l.length < d,
510
+ isLoading: h,
511
+ error: _,
512
+ refetch: b
444
513
  };
445
514
  }
446
- var M = [
515
+ var P = [
447
516
  "RECEIPT",
448
517
  "ISSUE",
449
518
  "TRANSFER",
450
519
  "ADJUSTMENT",
451
520
  "RETURN"
452
521
  ];
453
- function N(e) {
522
+ function F(e) {
454
523
  let t = e.toUpperCase();
455
- return M.find((e) => e === t) ?? "ADJUSTMENT";
524
+ return P.find((e) => e === t) ?? "ADJUSTMENT";
456
525
  }
457
- function P(e) {
526
+ function I(e) {
458
527
  return {
459
528
  id: e.id,
460
529
  transactionNumber: e.transactionNumber,
461
- type: N(e.type),
530
+ type: F(e.type),
462
531
  quantity: e.quantity,
463
532
  productId: e.cargoItemId,
464
533
  warehouseId: e.warehouseId,
@@ -468,7 +537,7 @@ function P(e) {
468
537
  createdAt: new Date(e.createdAt)
469
538
  };
470
539
  }
471
- function F(e = {}) {
540
+ function L(e = {}) {
472
541
  let { limit: i = 10, productId: o, warehouseId: s } = e, c = x(), [l, u] = a([]), [d, p] = a(!1), [m, h] = a(null), g = n(async () => {
473
542
  p(!0), h(null);
474
543
  try {
@@ -481,7 +550,7 @@ function F(e = {}) {
481
550
  limit: i,
482
551
  offset: 0
483
552
  }
484
- })).inventoryTransactions.map(P));
553
+ })).inventoryTransactions.map(I));
485
554
  } catch (e) {
486
555
  h(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load inventory transactions"));
487
556
  } finally {
@@ -505,4 +574,4 @@ function F(e = {}) {
505
574
  };
506
575
  }
507
576
  //#endregion
508
- export { S as useInventory, k as useInventoryStats, F as useInventoryTransactions, T as useProduct, w as useProductStats, j as useProductStockLevels, C as useProducts, O as useWarehouse, D as useWarehouseStats, E as useWarehouses };
577
+ export { S as useInventory, j as useInventoryStats, L as useInventoryTransactions, E as useProduct, T as useProductStats, N as useProductStockLevels, C as useProducts, A as useWarehouse, k as useWarehouseStats, D as useWarehouses };