@burdenoff/microfe-movethewheels 2026.822.1 → 2026.828.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 (71) hide show
  1. package/dist/generated/wspace-operations.d.ts +168 -912
  2. package/dist/generated/wspace-types.d.ts +78432 -35831
  3. package/dist/hooks/useFleet.js +142 -74
  4. package/dist/hooks/useImportExport.js +22 -51
  5. package/dist/hooks/useInventory.js +163 -70
  6. package/dist/hooks/useOrders.js +2 -2
  7. package/dist/hooks/useReports.js +63 -73
  8. package/dist/hooks/useSettings.js +52 -44
  9. package/dist/hooks/useTracking.js +5 -5
  10. package/dist/index.js +33 -33
  11. package/dist/movethewheels/hooks/index.d.ts +2 -2
  12. package/dist/movethewheels/hooks/useFleet.d.ts +32 -1
  13. package/dist/movethewheels/hooks/useImportExport.d.ts +10 -0
  14. package/dist/movethewheels/hooks/useInventory.d.ts +67 -12
  15. package/dist/movethewheels/hooks/useOrders.d.ts +25 -2
  16. package/dist/movethewheels/pages/MarketplacePage.d.ts +7 -4
  17. package/dist/movethewheels/types/index.d.ts +2 -0
  18. package/dist/node_modules/lucide-react/dist/esm/icons/arrow-down-right.js +11 -0
  19. package/dist/node_modules/lucide-react/dist/esm/icons/arrow-left-right.js +22 -0
  20. package/dist/node_modules/lucide-react/dist/esm/icons/arrow-up-right.js +11 -0
  21. package/dist/node_modules/lucide-react/dist/esm/icons/calendar-clock.js +32 -0
  22. package/dist/node_modules/lucide-react/dist/esm/icons/history.js +18 -0
  23. package/dist/node_modules/lucide-react/dist/esm/icons/lock.js +16 -0
  24. package/dist/node_modules/lucide-react/dist/esm/icons/user-round.js +13 -0
  25. package/dist/pages/CreateOrderPage.js +246 -195
  26. package/dist/pages/DeliveryCapturePage.js +91 -78
  27. package/dist/pages/DriversPage.js +202 -108
  28. package/dist/pages/InventoryPage.js +356 -131
  29. package/dist/pages/MarketplacePage.js +11 -432
  30. package/dist/pages/ProductDetailsPage.js +212 -156
  31. package/dist/pages/ReportsPage.js +120 -109
  32. package/dist/pages/VehicleDetailsPage.js +257 -193
  33. package/dist/utils/formatters.js +4 -1
  34. package/package.json +2 -2
  35. package/src/generated/wspace-operations.ts +134 -929
  36. package/src/generated/wspace-types.ts +91730 -40059
  37. package/src/movethewheels/hooks/index.ts +9 -0
  38. package/src/movethewheels/hooks/useFleet.ts +133 -3
  39. package/src/movethewheels/hooks/useImportExport.ts +36 -72
  40. package/src/movethewheels/hooks/useInventory.ts +311 -53
  41. package/src/movethewheels/hooks/useOrders.ts +31 -7
  42. package/src/movethewheels/hooks/useReports.ts +73 -87
  43. package/src/movethewheels/hooks/useSettings.ts +50 -53
  44. package/src/movethewheels/hooks/useTracking.ts +14 -14
  45. package/src/movethewheels/pages/CreateOrderPage.tsx +67 -10
  46. package/src/movethewheels/pages/DeliveryCapturePage.tsx +8 -0
  47. package/src/movethewheels/pages/DriversPage.tsx +181 -31
  48. package/src/movethewheels/pages/InventoryPage.tsx +299 -19
  49. package/src/movethewheels/pages/MarketplacePage.tsx +16 -539
  50. package/src/movethewheels/pages/ProductDetailsPage.tsx +68 -3
  51. package/src/movethewheels/pages/ReportsPage.tsx +23 -0
  52. package/src/movethewheels/pages/VehicleDetailsPage.tsx +86 -27
  53. package/src/movethewheels/types/index.ts +2 -0
  54. package/src/operations/wspace/movethewheels/fragments/core.graphql +23 -53
  55. package/src/operations/wspace/movethewheels/fragments/core.withdrawn.graphql +59 -0
  56. package/src/operations/wspace/movethewheels/mutations/entities.graphql +5 -5
  57. package/src/operations/wspace/movethewheels/mutations/marketplace-reports.graphql +18 -78
  58. package/src/operations/wspace/movethewheels/mutations/marketplace-reports.withdrawn.graphql +93 -0
  59. package/src/operations/wspace/movethewheels/mutations/orders.graphql +7 -7
  60. package/src/operations/wspace/movethewheels/queries/dashboard.graphql +3 -3
  61. package/src/operations/wspace/movethewheels/queries/entities.graphql +3 -3
  62. package/src/operations/wspace/movethewheels/queries/logistics.graphql +3 -3
  63. package/src/operations/wspace/movethewheels/queries/marketplace-reports.withdrawn.graphql +58 -0
  64. package/src/operations/wspace/movethewheels/queries/orders.graphql +3 -3
  65. package/dist/generated/global-operations.d.ts +0 -1
  66. package/dist/generated/global-types.d.ts +0 -23526
  67. package/dist/node_modules/lucide-react/dist/esm/icons/chevron-down.js +0 -8
  68. package/dist/node_modules/lucide-react/dist/esm/icons/chevron-up.js +0 -8
  69. package/src/generated/global-operations.ts +0 -2
  70. package/src/generated/global-types.ts +0 -27259
  71. package/src/operations/wspace/movethewheels/queries/marketplace-reports.graphql +0 -40
@@ -2,8 +2,8 @@ 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 productId\n warehouseId\n onHand\n available\n allocated\n damaged\n reorderPoint\n createdAt\n updatedAt\n }\n }\n", s = "\n query ListProducts($filter: ProductFilterInput, $pagination: PaginationInput) {\n products(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 GetProduct($id: ID!) {\n product(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 }\n", f = "\n mutation CreateProduct($input: CreateProductInput!) {\n createProduct(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", p = "\n mutation UpdateProduct($id: ID!, $input: UpdateProductInput!) {\n updateProduct(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", m = "\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", h = "\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", g = "\n mutation AdjustInventoryStock($input: AdjustInventoryStockInput!) {\n adjustInventoryStock(input: $input) {\n id\n productId\n warehouseId\n onHand\n available\n allocated\n damaged\n reorderPoint\n createdAt\n updatedAt\n }\n }\n";
6
- function _(e) {
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";
6
+ function v(e) {
7
7
  return {
8
8
  id: e.id,
9
9
  sku: e.sku,
@@ -30,7 +30,7 @@ function _(e) {
30
30
  updatedAt: new Date(e.updatedAt)
31
31
  };
32
32
  }
33
- function v(e) {
33
+ function y(e) {
34
34
  let t = e.totalCapacity ?? 0, n = e.usedCapacity ?? 0;
35
35
  return {
36
36
  id: e.id,
@@ -70,10 +70,10 @@ function v(e) {
70
70
  createdAt: new Date(e.createdAt)
71
71
  };
72
72
  }
73
- function y(e) {
73
+ function b(e) {
74
74
  return {
75
75
  id: e.id,
76
- productId: e.productId,
76
+ productId: e.cargoItemId,
77
77
  warehouseId: e.warehouseId,
78
78
  zoneId: "",
79
79
  quantity: e.onHand,
@@ -93,7 +93,7 @@ function y(e) {
93
93
  updatedAt: new Date(e.updatedAt)
94
94
  };
95
95
  }
96
- function b() {
96
+ function x() {
97
97
  let { apiGatewayUrl: t, authToken: n, workspaceToken: r, workspaceId: a, tenantId: o, currentUser: s } = e();
98
98
  return i(() => ({
99
99
  apiGatewayUrl: t,
@@ -111,19 +111,19 @@ function b() {
111
111
  s?.id
112
112
  ]);
113
113
  }
114
- function x(e = {}) {
114
+ function S(e = {}) {
115
115
  let { filters: l } = e, u = i(() => l, [
116
116
  l?.lowStock,
117
117
  l?.productId,
118
118
  l?.warehouseId
119
- ]), d = b(), [x, S] = a([]), [C, w] = a([]), [T, E] = a([]), [D, O] = a(!1), [k, A] = a(null), j = n(async () => {
119
+ ]), d = x(), [f, S] = a([]), [C, w] = a([]), [T, E] = a([]), [D, O] = a(!1), [k, A] = a(null), j = n(async () => {
120
120
  O(!0), A(null);
121
121
  try {
122
122
  let [e, n, r] = await Promise.all([
123
123
  t(d, o, {
124
124
  filter: {
125
125
  warehouseId: u?.warehouseId,
126
- productId: u?.productId
126
+ cargoItemId: u?.productId
127
127
  },
128
128
  pagination: {
129
129
  limit: 500,
@@ -138,8 +138,8 @@ function x(e = {}) {
138
138
  limit: 500,
139
139
  offset: 0
140
140
  } })
141
- ]), i = e.inventoryItems.map(y);
142
- u?.lowStock && (i = i.filter((e) => e.availableQuantity <= e.reorderLevel)), S(i), w(n.products.map(_)), E(r.warehouses.map(v));
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));
143
143
  } catch (e) {
144
144
  A(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load inventory data"));
145
145
  } finally {
@@ -152,9 +152,9 @@ function x(e = {}) {
152
152
  let M = n(() => {
153
153
  j();
154
154
  }, [j]), N = n(async (e, n, r) => {
155
- let i = x.find((t) => t.id === e);
155
+ let i = f.find((t) => t.id === e);
156
156
  if (!i) throw Error("Inventory item not found");
157
- let a = y((await t(d, g, { input: {
157
+ let a = b((await t(d, _, { input: {
158
158
  id: e,
159
159
  onHand: i.quantity + n,
160
160
  available: i.availableQuantity + n,
@@ -162,23 +162,23 @@ function x(e = {}) {
162
162
  damaged: 0
163
163
  } })).adjustInventoryStock);
164
164
  return S((t) => t.map((t) => t.id === e ? a : t)), a;
165
- }, [d, x]), P = n(async (e, t, n, r) => {
166
- let i = x.find((t) => t.warehouseId === e && t.productId === n);
165
+ }, [d, f]), P = n(async (e, t, n, r) => {
166
+ let i = f.find((t) => t.warehouseId === e && t.productId === n);
167
167
  if (!i) throw Error("Source inventory not found");
168
168
  await N(i.id, -Math.abs(r), "transfer out");
169
- let a = x.find((e) => e.warehouseId === t && e.productId === n);
169
+ let a = f.find((e) => e.warehouseId === t && e.productId === n);
170
170
  a && await N(a.id, Math.abs(r), "transfer in");
171
- }, [x, N]), F = n(async (e) => {
172
- let n = _((await t(d, f, { input: {
171
+ }, [f, N]), F = n(async (e) => {
172
+ let n = v((await t(d, p, { input: {
173
173
  name: e.name,
174
174
  sku: e.sku,
175
175
  category: e.category,
176
176
  brand: e.brand,
177
177
  weight: e.weight
178
- } })).createProduct);
178
+ } })).createCargoItem);
179
179
  return w((e) => [n, ...e]), n;
180
180
  }, [d]), I = n(async (e) => {
181
- let n = v((await t(d, m, { input: {
181
+ let n = y((await t(d, h, { input: {
182
182
  code: e.code,
183
183
  name: e.name,
184
184
  type: e.type,
@@ -187,7 +187,7 @@ function x(e = {}) {
187
187
  } })).createWarehouse);
188
188
  return E((e) => [n, ...e]), n;
189
189
  }, [d]), L = n(async (e, n) => {
190
- let r = _((await t(d, p, {
190
+ let r = v((await t(d, m, {
191
191
  id: e,
192
192
  input: {
193
193
  name: n.name,
@@ -196,10 +196,10 @@ function x(e = {}) {
196
196
  brand: n.brand,
197
197
  weight: n.weight
198
198
  }
199
- })).updateProduct);
199
+ })).updateCargoItem);
200
200
  return w((t) => t.map((t) => t.id === e ? r : t)), r;
201
201
  }, [d]), R = n(async (e, n) => {
202
- let r = v((await t(d, h, {
202
+ let r = y((await t(d, g, {
203
203
  id: e,
204
204
  input: {
205
205
  code: n.code,
@@ -212,10 +212,10 @@ function x(e = {}) {
212
212
  return E((t) => t.map((t) => t.id === e ? r : t)), r;
213
213
  }, [d]);
214
214
  return {
215
- inventory: x,
215
+ inventory: f,
216
216
  products: C,
217
217
  warehouses: T,
218
- totalItems: x.length,
218
+ totalItems: f.length,
219
219
  isLoading: D,
220
220
  error: k,
221
221
  refetch: M,
@@ -227,15 +227,15 @@ function x(e = {}) {
227
227
  updateWarehouse: R
228
228
  };
229
229
  }
230
- function S(e = {}) {
231
- let { limit: i = 500, offset: o = 0 } = e, c = b(), [l, u] = a([]), [d, f] = a(!1), [p, m] = a(!1), [h, g] = a(null), v = n(async () => {
230
+ 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
232
  m(!0), g(null);
233
233
  try {
234
234
  let e = await t(c, s, { pagination: {
235
235
  limit: i,
236
236
  offset: o
237
237
  } });
238
- f(e.products.length === i), u(e.products.map(_));
238
+ f(e.cargoItems.length === i), u(e.cargoItems.map(v));
239
239
  } catch (e) {
240
240
  g(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load products"));
241
241
  } finally {
@@ -247,18 +247,18 @@ function S(e = {}) {
247
247
  o
248
248
  ]);
249
249
  return r(() => {
250
- v();
251
- }, [v]), {
250
+ _();
251
+ }, [_]), {
252
252
  products: l,
253
253
  totalProducts: l.length,
254
254
  hasMore: d,
255
255
  isLoading: p,
256
256
  error: h,
257
- refetch: () => void v()
257
+ refetch: () => void _()
258
258
  };
259
259
  }
260
- function C(e = 500) {
261
- let { products: t, isLoading: n, error: r } = S({
260
+ function w(e = 500) {
261
+ let { products: t, isLoading: n, error: r } = C({
262
262
  limit: e,
263
263
  offset: 0
264
264
  });
@@ -272,8 +272,8 @@ function C(e = 500) {
272
272
  error: r
273
273
  };
274
274
  }
275
- function w(e) {
276
- let i = b(), [o, s] = a(null), [c, u] = a(!1), [d, f] = a(null), p = n(async () => {
275
+ function T(e) {
276
+ let i = x(), [o, s] = a(null), [c, u] = a(!1), [d, f] = a(null), p = n(async () => {
277
277
  if (!e) {
278
278
  s(null);
279
279
  return;
@@ -281,7 +281,7 @@ function w(e) {
281
281
  u(!0), f(null);
282
282
  try {
283
283
  let n = await t(i, l, { id: e });
284
- s(n.product ? _(n.product) : null);
284
+ s(n.cargoItem ? v(n.cargoItem) : null);
285
285
  } catch (e) {
286
286
  f(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load product"));
287
287
  } finally {
@@ -297,15 +297,15 @@ function w(e) {
297
297
  refetch: () => void p()
298
298
  };
299
299
  }
300
- function T(e = {}) {
301
- let { limit: i = 500, offset: o = 0 } = e, s = b(), [l, u] = a([]), [d, f] = a(!1), [p, m] = a(!1), [h, g] = a(null), _ = n(async () => {
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
302
  m(!0), g(null);
303
303
  try {
304
304
  let e = await t(s, c, { pagination: {
305
305
  limit: i,
306
306
  offset: o
307
307
  } });
308
- f(e.warehouses.length === i), u(e.warehouses.map(v));
308
+ f(e.warehouses.length === i), u(e.warehouses.map(y));
309
309
  } catch (e) {
310
310
  g(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load warehouses"));
311
311
  } finally {
@@ -327,8 +327,8 @@ function T(e = {}) {
327
327
  refetch: () => void _()
328
328
  };
329
329
  }
330
- function E(e = 500) {
331
- let { warehouses: t, isLoading: n, error: r } = T({
330
+ function D(e = 500) {
331
+ let { warehouses: t, isLoading: n, error: r } = E({
332
332
  limit: e,
333
333
  offset: 0
334
334
  });
@@ -345,8 +345,8 @@ function E(e = 500) {
345
345
  error: r
346
346
  };
347
347
  }
348
- function D(e) {
349
- let i = b(), [o, s] = a(null), [c, l] = a(!1), [d, f] = a(null), p = n(async () => {
348
+ function O(e) {
349
+ let i = x(), [o, s] = a(null), [c, l] = a(!1), [d, f] = a(null), p = n(async () => {
350
350
  if (!e) {
351
351
  s(null);
352
352
  return;
@@ -354,7 +354,7 @@ function D(e) {
354
354
  l(!0), f(null);
355
355
  try {
356
356
  let n = await t(i, u, { id: e });
357
- s(n.warehouse ? v(n.warehouse) : null);
357
+ s(n.warehouse ? y(n.warehouse) : null);
358
358
  } catch (e) {
359
359
  f(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load warehouse"));
360
360
  } finally {
@@ -370,37 +370,32 @@ function D(e) {
370
370
  refetch: () => void p()
371
371
  };
372
372
  }
373
- function O() {
374
- let e = b(), [n, i] = a({
375
- totalItems: 0,
376
- lowStockItems: 0,
377
- totalValue: 0,
373
+ function k() {
374
+ let e = x(), [n, i] = a({
375
+ totalOnHand: 0,
376
+ totalAvailable: 0,
377
+ totalAllocated: 0,
378
+ totalDamaged: 0,
379
+ lowStockCount: 0,
378
380
  totalProducts: 0,
379
- totalWarehouses: 0,
380
- warehouseUtilization: []
381
- }), [o, s] = a(!1), [l, u] = a(null);
381
+ totalWarehouses: 0
382
+ }), [o, s] = a(!1), [c, l] = a(null);
382
383
  return r(() => {
383
384
  (async () => {
384
- s(!0), u(null);
385
+ s(!0), l(null);
385
386
  try {
386
- let [n, r] = await Promise.all([t(e, d), t(e, c, { pagination: {
387
- limit: 500,
388
- offset: 0
389
- } })]);
387
+ let n = await t(e, d);
390
388
  i({
391
- totalItems: n.inventoryStats.totalOnHand,
392
- lowStockItems: n.inventoryStats.lowStockCount,
393
- totalValue: 0,
394
- totalProducts: 0,
395
- totalWarehouses: r.warehouses.length,
396
- warehouseUtilization: r.warehouses.map((e) => ({
397
- id: e.id,
398
- name: e.name,
399
- utilization: (e.totalCapacity ?? 0) > 0 ? (e.usedCapacity ?? 0) / (e.totalCapacity ?? 1) * 100 : 0
400
- }))
389
+ totalOnHand: n.inventoryStats.totalOnHand,
390
+ totalAvailable: n.inventoryStats.totalAvailable,
391
+ totalAllocated: n.inventoryStats.totalAllocated,
392
+ totalDamaged: n.inventoryStats.totalDamaged,
393
+ lowStockCount: n.inventoryStats.lowStockCount,
394
+ totalProducts: n.cargoItemsCount,
395
+ totalWarehouses: n.warehousesCount
401
396
  });
402
397
  } catch (e) {
403
- u(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load inventory stats"));
398
+ l(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load inventory stats"));
404
399
  } finally {
405
400
  s(!1);
406
401
  }
@@ -408,8 +403,106 @@ function O() {
408
403
  }, [e]), {
409
404
  stats: n,
410
405
  isLoading: o,
411
- error: l
406
+ error: c
407
+ };
408
+ }
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 () => {
412
+ if (!e) {
413
+ s([]);
414
+ return;
415
+ }
416
+ l(!0), d(null);
417
+ try {
418
+ s((await t(i, A, { cargoItemId: e })).inventoryItems.map((e) => ({
419
+ inventoryItemId: e.id,
420
+ warehouseId: e.warehouse?.id ?? "",
421
+ warehouseName: e.warehouse?.name ?? "Unknown warehouse",
422
+ warehouseCode: e.warehouse?.code ?? "",
423
+ onHand: e.onHand,
424
+ available: e.available,
425
+ allocated: e.allocated,
426
+ damaged: e.damaged,
427
+ reorderPoint: e.reorderPoint ?? void 0
428
+ })));
429
+ } catch (e) {
430
+ d(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load stock levels"));
431
+ } finally {
432
+ l(!1);
433
+ }
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])
444
+ };
445
+ }
446
+ var M = [
447
+ "RECEIPT",
448
+ "ISSUE",
449
+ "TRANSFER",
450
+ "ADJUSTMENT",
451
+ "RETURN"
452
+ ];
453
+ function N(e) {
454
+ let t = e.toUpperCase();
455
+ return M.find((e) => e === t) ?? "ADJUSTMENT";
456
+ }
457
+ function P(e) {
458
+ return {
459
+ id: e.id,
460
+ transactionNumber: e.transactionNumber,
461
+ type: N(e.type),
462
+ quantity: e.quantity,
463
+ productId: e.cargoItemId,
464
+ warehouseId: e.warehouseId,
465
+ notes: e.notes ?? void 0,
466
+ referenceType: e.referenceType ?? void 0,
467
+ referenceId: e.referenceId ?? void 0,
468
+ createdAt: new Date(e.createdAt)
469
+ };
470
+ }
471
+ function F(e = {}) {
472
+ 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
+ p(!0), h(null);
474
+ try {
475
+ u((await t(c, f, {
476
+ filter: o || s ? {
477
+ cargoItemId: o,
478
+ warehouseId: s
479
+ } : void 0,
480
+ pagination: {
481
+ limit: i,
482
+ offset: 0
483
+ }
484
+ })).inventoryTransactions.map(P));
485
+ } catch (e) {
486
+ h(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load inventory transactions"));
487
+ } finally {
488
+ p(!1);
489
+ }
490
+ }, [
491
+ c,
492
+ i,
493
+ o,
494
+ s
495
+ ]);
496
+ return r(() => {
497
+ g();
498
+ }, [g]), {
499
+ transactions: l,
500
+ isLoading: d,
501
+ error: m,
502
+ refetch: n(() => {
503
+ g();
504
+ }, [g])
412
505
  };
413
506
  }
414
507
  //#endregion
415
- export { x as useInventory, O as useInventoryStats, w as useProduct, C as useProductStats, S as useProducts, D as useWarehouse, E as useWarehouseStats, T as useWarehouses };
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 };
@@ -216,7 +216,7 @@ function b(o = {}) {
216
216
  pricing: n.pricing,
217
217
  specialInstructions: n.specialInstructions,
218
218
  trackingNumber: n.trackingNumber,
219
- scheduledDelivery: n.scheduledDelivery?.toISOString(),
219
+ scheduledDelivery: n.scheduledDelivery === null ? null : n.scheduledDelivery?.toISOString(),
220
220
  vehicleId: n.vehicleId,
221
221
  driverId: n.driverId
222
222
  }
@@ -352,4 +352,4 @@ function S() {
352
352
  };
353
353
  }
354
354
  //#endregion
355
- export { x as useOrder, S as useOrderStats, b as useOrders };
355
+ export { h as mapOrderPriority, m as mapOrderStatus, x as useOrder, S as useOrderStats, b as useOrders };
@@ -1,85 +1,75 @@
1
1
  import { useMoveTheWheels as e } from "../providers/MoveTheWheelsProvider.js";
2
- import { executeGraphQL as t } from "../utils/graphqlClient.js";
3
- import { useCallback as n, useEffect as r, useMemo as i, useState as a } from "react";
2
+ import { useCallback as t, useEffect as n, useState as r } from "react";
4
3
  //#region src/movethewheels/hooks/useReports.ts
5
- var o = "\n id\n name\n description\n type\n status\n schedule\n lastGenerated\n createdAt\n updatedAt\n", s = `
6
- query MovethewheelsReports($filter: MovethewheelsReportFilterInput, $pagination: PaginationInput) {
7
- movethewheelsReports(filter: $filter, pagination: $pagination) {
8
- ${o}
9
- }
10
- }
11
- `, c = `
12
- mutation CreateMovethewheelsReport($input: CreateMovethewheelsReportInput!) {
13
- createMovethewheelsReport(input: $input) {
14
- ${o}
15
- }
16
- }
17
- `, l = `
18
- mutation GenerateMovethewheelsReport($input: GenerateMovethewheelsReportInput!) {
19
- generateMovethewheelsReport(input: $input) {
20
- generatedAt
21
- result
22
- report {
23
- ${o}
24
- }
25
- }
26
- }
27
- `;
28
- function u(o = {}) {
29
- let { limit: u = 100, offset: d = 0 } = o, { apiGatewayUrl: f, authToken: p, workspaceToken: m, workspaceId: h, tenantId: g, currentUser: _ } = e(), [v, y] = a([]), [b, x] = a(!1), [S, C] = a(!1), [w, T] = a(null), E = i(() => ({
30
- apiGatewayUrl: f,
31
- authToken: p,
32
- workspaceToken: m,
33
- workspaceId: h,
34
- tenantId: g,
35
- actorId: _?.id
36
- }), [
37
- f,
38
- p,
39
- m,
40
- h,
41
- g,
42
- _?.id
43
- ]), D = n(async () => {
44
- C(!0), T(null);
4
+ function i() {
5
+ return typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID() : `${Date.now()}-${Math.random().toString(36).slice(2)}`;
6
+ }
7
+ function a(e) {
8
+ return `movethewheels:reports:${e ?? "default"}`;
9
+ }
10
+ function o(e) {
11
+ if (typeof window > "u") return [];
12
+ try {
13
+ let t = window.localStorage.getItem(a(e));
14
+ if (!t) return [];
15
+ let n = JSON.parse(t);
16
+ return Array.isArray(n) ? n : [];
17
+ } catch {
18
+ return [];
19
+ }
20
+ }
21
+ function s(e, t) {
22
+ if (!(typeof window > "u")) try {
23
+ window.localStorage.setItem(a(e), JSON.stringify(t));
24
+ } catch {}
25
+ }
26
+ function c(a = {}) {
27
+ let { limit: c = 100, offset: l = 0 } = a, { workspaceId: u } = e(), [d, f] = r([]), [p, m] = r(!1), [h, g] = r(!1), [_, v] = r(null), y = t(() => {
28
+ g(!0), v(null);
45
29
  try {
46
- let e = await t(E, s, { pagination: {
47
- limit: u,
48
- offset: d
49
- } });
50
- x(e.movethewheelsReports.length === u), y(e.movethewheelsReports);
30
+ let e = o(u).slice(l, l + c);
31
+ m(e.length === c), f(e);
51
32
  } catch (e) {
52
- T(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load reports"));
33
+ v(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load reports"));
53
34
  } finally {
54
- C(!1);
35
+ g(!1);
55
36
  }
56
37
  }, [
57
- E,
58
38
  u,
59
- d
39
+ c,
40
+ l
60
41
  ]);
61
- return r(() => {
62
- D();
63
- }, [D]), {
64
- reports: v,
65
- hasMore: b,
66
- isLoading: S,
67
- error: w,
68
- refetch: n(() => {
69
- D();
70
- }, [D]),
71
- createReport: n(async (e) => {
72
- let n = (await t(E, c, { input: e })).createMovethewheelsReport;
73
- return y((e) => [n, ...e]), n;
74
- }, [E]),
75
- generateReport: n(async (e, n) => {
76
- let r = (await t(E, l, { input: {
77
- reportId: e,
78
- parameters: n
79
- } })).generateMovethewheelsReport;
80
- return y((t) => t.map((t) => t.id === e ? r.report : t)), r;
81
- }, [E])
42
+ return n(() => {
43
+ y();
44
+ }, [y]), {
45
+ reports: d,
46
+ hasMore: p,
47
+ isLoading: h,
48
+ error: _,
49
+ refetch: t(() => {
50
+ y();
51
+ }, [y]),
52
+ createReport: t(async (e) => {
53
+ let t = (/* @__PURE__ */ new Date()).toISOString(), n = {
54
+ id: i(),
55
+ name: e.name,
56
+ description: e.description ?? null,
57
+ type: e.type,
58
+ status: e.status ?? "ready",
59
+ schedule: e.schedule ?? null,
60
+ lastGenerated: null,
61
+ createdAt: t,
62
+ updatedAt: t
63
+ };
64
+ return f((e) => {
65
+ let t = [n, ...e];
66
+ return s(u, t), t;
67
+ }), n;
68
+ }, [u]),
69
+ generateReport: t(async (e, t) => {
70
+ throw Error("Report generation is not available: the movethewheelsReports surface was withdrawn from the service.");
71
+ }, [])
82
72
  };
83
73
  }
84
74
  //#endregion
85
- export { u as useReports };
75
+ export { c as useReports };