@burdenoff/microfe-movethewheels 2026.929.3 → 2026.930.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 (72) hide show
  1. package/dist/components/CustomerPicker.js +52 -48
  2. package/dist/components/EntityCombobox.js +25 -23
  3. package/dist/components/OrderItemRow.js +123 -78
  4. package/dist/generated/wspace-types.d.ts +1547 -64
  5. package/dist/hooks/useCustomers.js +55 -26
  6. package/dist/hooks/useFleet.js +236 -157
  7. package/dist/hooks/useInventory.js +214 -153
  8. package/dist/hooks/useMultiModalShipments.js +30 -26
  9. package/dist/hooks/useRoutes.js +64 -24
  10. package/dist/hooks/useTracking.js +14 -16
  11. package/dist/movethewheels/components/CustomerPicker.d.ts +5 -1
  12. package/dist/movethewheels/components/EntityCombobox.d.ts +6 -3
  13. package/dist/movethewheels/components/OrderItemRow.d.ts +7 -1
  14. package/dist/movethewheels/hooks/useCustomers.d.ts +3 -0
  15. package/dist/movethewheels/hooks/useFleet.d.ts +15 -2
  16. package/dist/movethewheels/hooks/useInventory.d.ts +15 -12
  17. package/dist/movethewheels/hooks/useMultiModalShipments.d.ts +1 -0
  18. package/dist/movethewheels/hooks/useRoutes.d.ts +7 -1
  19. package/dist/movethewheels/types/index.d.ts +33 -23
  20. package/dist/movethewheels/utils/formatters.d.ts +1 -1
  21. package/dist/movethewheels/utils/orderValidation.d.ts +11 -0
  22. package/dist/pages/CreateOrderPage.js +349 -297
  23. package/dist/pages/CustomerDetailsPage.js +6 -6
  24. package/dist/pages/CustomersPage.js +2 -2
  25. package/dist/pages/DashboardPage.js +1 -1
  26. package/dist/pages/DriverDetailsPage.js +340 -332
  27. package/dist/pages/DriversPage.js +7 -5
  28. package/dist/pages/FleetPage.js +1 -1
  29. package/dist/pages/InventoryPage.js +11 -12
  30. package/dist/pages/LiveTrackingPage.js +4 -4
  31. package/dist/pages/MultiModalShipmentPage.js +139 -125
  32. package/dist/pages/OrderDetailsPage.js +132 -140
  33. package/dist/pages/ProductDetailsPage.js +408 -249
  34. package/dist/pages/ProductsPage.js +5 -5
  35. package/dist/pages/RouteDetailsPage.js +208 -210
  36. package/dist/pages/RoutesPage.js +2 -2
  37. package/dist/pages/TrackingPage.js +16 -9
  38. package/dist/pages/WarehouseDetailsPage.js +166 -163
  39. package/dist/pages/WarehousesPage.js +29 -21
  40. package/dist/utils/orderValidation.js +18 -0
  41. package/package.json +1 -1
  42. package/src/generated/wspace-types.ts +1762 -64
  43. package/src/movethewheels/components/CustomerPicker.tsx +12 -0
  44. package/src/movethewheels/components/EntityCombobox.tsx +30 -11
  45. package/src/movethewheels/components/OrderItemRow.tsx +44 -0
  46. package/src/movethewheels/hooks/useCustomers.ts +45 -9
  47. package/src/movethewheels/hooks/useFleet.ts +214 -36
  48. package/src/movethewheels/hooks/useInventory.ts +185 -49
  49. package/src/movethewheels/hooks/useMultiModalShipments.ts +9 -7
  50. package/src/movethewheels/hooks/useRoutes.ts +87 -16
  51. package/src/movethewheels/hooks/useTracking.ts +23 -15
  52. package/src/movethewheels/pages/CreateOrderPage.tsx +66 -2
  53. package/src/movethewheels/pages/CustomerDetailsPage.tsx +14 -8
  54. package/src/movethewheels/pages/CustomersPage.tsx +5 -2
  55. package/src/movethewheels/pages/DashboardPage.tsx +3 -1
  56. package/src/movethewheels/pages/DriverDetailsPage.tsx +25 -4
  57. package/src/movethewheels/pages/DriversPage.tsx +8 -2
  58. package/src/movethewheels/pages/FleetPage.tsx +1 -1
  59. package/src/movethewheels/pages/InventoryPage.tsx +20 -16
  60. package/src/movethewheels/pages/LiveTrackingPage.tsx +6 -4
  61. package/src/movethewheels/pages/MultiModalShipmentPage.tsx +15 -1
  62. package/src/movethewheels/pages/OrderDetailsPage.tsx +25 -25
  63. package/src/movethewheels/pages/ProductDetailsPage.tsx +228 -49
  64. package/src/movethewheels/pages/ProductsPage.tsx +13 -5
  65. package/src/movethewheels/pages/RouteDetailsPage.tsx +24 -12
  66. package/src/movethewheels/pages/RoutesPage.tsx +4 -2
  67. package/src/movethewheels/pages/TrackingPage.tsx +32 -12
  68. package/src/movethewheels/pages/WarehouseDetailsPage.tsx +42 -29
  69. package/src/movethewheels/pages/WarehousesPage.tsx +23 -15
  70. package/src/movethewheels/types/index.ts +36 -24
  71. package/src/movethewheels/utils/formatters.ts +1 -1
  72. package/src/movethewheels/utils/orderValidation.ts +53 -0
@@ -2,24 +2,31 @@ 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 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 status\n contactInfo\n operatingHours\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 status\n contactInfo\n operatingHours\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 status\n contactInfo\n operatingHours\n totalCapacity\n usedCapacity\n createdAt\n }\n }\n", g = "\n mutation DeleteWarehouse($id: ID!) {\n deleteWarehouse(id: $id)\n }\n", _ = "\n mutation UpdateWarehouse($id: ID!, $input: UpdateWarehouseInput!) {\n updateWarehouse(id: $id, input: $input) {\n id\n name\n code\n type\n address\n status\n contactInfo\n operatingHours\n totalCapacity\n usedCapacity\n createdAt\n }\n }\n", v = "\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 y(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 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 status\n contactInfo\n operatingHours\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 status\n contactInfo\n operatingHours\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 DeleteCargoItem($id: ID!) {\n deleteCargoItem(id: $id)\n }\n", g = "\n mutation CreateWarehouse($input: CreateWarehouseInput!) {\n createWarehouse(input: $input) {\n id\n name\n code\n type\n address\n status\n contactInfo\n operatingHours\n totalCapacity\n usedCapacity\n createdAt\n }\n }\n", _ = "\n mutation DeleteWarehouse($id: ID!) {\n deleteWarehouse(id: $id)\n }\n", v = "\n mutation UpdateWarehouse($id: ID!, $input: UpdateWarehouseInput!) {\n updateWarehouse(id: $id, input: $input) {\n id\n name\n code\n type\n address\n status\n contactInfo\n operatingHours\n totalCapacity\n usedCapacity\n createdAt\n }\n }\n", y = "\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", b = "\n mutation TransferInventoryStock($input: TransferInventoryStockInput!) {\n transferInventoryStock(input: $input) {\n source {\n id\n cargoItemId\n warehouseId\n onHand\n available\n allocated\n damaged\n reorderPoint\n createdAt\n updatedAt\n }\n destination {\n id\n cargoItemId\n warehouseId\n onHand\n available\n allocated\n damaged\n reorderPoint\n createdAt\n updatedAt\n }\n }\n }\n";
6
+ function x(e) {
7
+ if (!e) return;
8
+ let t = {};
9
+ for (let n of [
10
+ "length",
11
+ "width",
12
+ "height"
13
+ ]) {
14
+ let r = e[n];
15
+ typeof r == "number" && Number.isFinite(r) && (t[n] = r);
16
+ }
17
+ return typeof e.unit == "string" && e.unit.trim() && (t.unit = e.unit), Object.keys(t).length > 0 ? t : void 0;
18
+ }
19
+ function S(e) {
7
20
  return {
8
21
  id: e.id,
9
22
  sku: e.sku,
10
23
  name: e.name,
11
- description: e.description ?? "",
12
- category: e.category ?? "general",
24
+ description: e.description ?? void 0,
25
+ category: e.category ?? void 0,
13
26
  brand: e.brand ?? void 0,
14
- dimensions: {
15
- length: 0,
16
- width: 0,
17
- height: 0,
18
- unit: "cm",
19
- ...e.dimensions ?? {}
20
- },
21
- weight: e.weight ?? 0,
22
- value: e.value ?? 0,
27
+ dimensions: x(e.dimensions),
28
+ weight: e.weight ?? void 0,
29
+ value: e.value ?? void 0,
23
30
  barcode: void 0,
24
31
  images: [],
25
32
  attributes: [],
@@ -30,41 +37,37 @@ function y(e) {
30
37
  updatedAt: new Date(e.updatedAt)
31
38
  };
32
39
  }
33
- function b(e) {
34
- let t = e.totalCapacity ?? 0, n = e.usedCapacity ?? 0, r = e.operatingHours ?? {}, i = {};
40
+ function C(e) {
41
+ return e ? Object.fromEntries(Object.entries(e).flatMap(([e, t]) => typeof t == "string" && t.trim() ? [[e, t]] : [])) : {};
42
+ }
43
+ function w(e) {
44
+ let t = typeof e.totalCapacity == "number" ? e.totalCapacity : void 0, n = typeof e.usedCapacity == "number" ? e.usedCapacity : void 0, r = e.operatingHours ?? {}, i = {};
35
45
  for (let [e, t] of Object.entries(r)) t && typeof t == "object" && "open" in t && "close" in t ? i[e] = {
36
46
  open: String(t.open),
37
47
  close: String(t.close)
38
48
  } : i[e] = null;
39
- let a = e.contactInfo ?? void 0;
49
+ let a = e.contactInfo ?? void 0, o = t !== void 0 && t > 0 && n !== void 0 ? n / t * 100 : void 0;
40
50
  return {
41
51
  id: e.id,
42
52
  name: e.name,
43
53
  code: e.code,
44
- address: {
45
- street: "",
46
- city: "",
47
- state: "",
48
- postalCode: "",
49
- country: "",
50
- ...e.address ?? {}
51
- },
52
- type: e.type?.toLowerCase() ?? "distribution",
53
- status: e.status ?? "ACTIVE",
54
+ address: C(e.address),
55
+ type: e.type.toLowerCase(),
56
+ status: e.status,
54
57
  capacity: {
55
58
  totalSpace: t,
56
59
  usedSpace: n
57
60
  },
58
61
  operatingHours: i,
59
62
  contactInfo: a ? {
60
- email: a.email ?? void 0,
61
- phone: a.phone ?? void 0
63
+ email: typeof a.email == "string" ? a.email : void 0,
64
+ phone: typeof a.phone == "string" ? a.phone : void 0
62
65
  } : void 0,
63
- utilization: t > 0 ? n / t * 100 : 0,
66
+ utilization: o,
64
67
  createdAt: new Date(e.createdAt)
65
68
  };
66
69
  }
67
- function x(e) {
70
+ function T(e) {
68
71
  return {
69
72
  id: e.id,
70
73
  productId: e.cargoItemId,
@@ -82,7 +85,7 @@ function x(e) {
82
85
  updatedAt: new Date(e.updatedAt)
83
86
  };
84
87
  }
85
- function S() {
88
+ function E() {
86
89
  let { apiGatewayUrl: t, authToken: n, workspaceToken: r, workspaceId: a, tenantId: o, currentUser: s } = e();
87
90
  return i(() => ({
88
91
  apiGatewayUrl: t,
@@ -100,32 +103,32 @@ function S() {
100
103
  s?.id
101
104
  ]);
102
105
  }
103
- function C(e = {}) {
104
- let { filters: l, search: u, limit: d = 10, offset: f = 0 } = e, C = i(() => l, [
106
+ function D(e = {}) {
107
+ let { filters: l, search: u, limit: d = 10, offset: f = 0 } = e, x = i(() => l, [
105
108
  l?.lowStock,
106
109
  l?.productId,
107
110
  l?.search,
108
111
  l?.warehouseId
109
- ]), w = S(), [T, E] = a([]), [D, O] = a([]), [k, A] = a([]), [j, M] = a([]), [N, P] = a(0), [F, I] = a(!1), [L, R] = a(!1), [z, B] = a(null), V = n(async () => {
110
- R(!0), B(null);
112
+ ]), C = E(), [D, O] = a([]), [k, A] = a([]), [j, M] = a([]), [N, P] = a([]), [F, I] = a(0), [L, R] = a(!1), [z, B] = a(!1), [V, H] = a(null), U = n(async () => {
113
+ B(!0), H(null);
111
114
  try {
112
115
  let e = {
113
- warehouseId: C?.warehouseId,
114
- cargoItemId: C?.productId,
115
- search: u || C?.search || void 0,
116
- lowStock: C?.lowStock || void 0
116
+ warehouseId: x?.warehouseId,
117
+ cargoItemId: x?.productId,
118
+ search: u || x?.search || void 0,
119
+ lowStock: x?.lowStock || void 0
117
120
  }, [n, r, i, a] = await Promise.all([
118
- t(w, o, {
121
+ t(C, o, {
119
122
  filter: e,
120
123
  pagination: {
121
124
  limit: d,
122
125
  offset: f
123
126
  }
124
127
  }),
125
- t(w, o, {
128
+ t(C, o, {
126
129
  filter: {
127
- warehouseId: C?.warehouseId,
128
- cargoItemId: C?.productId,
130
+ warehouseId: x?.warehouseId,
131
+ cargoItemId: x?.productId,
129
132
  lowStock: !0
130
133
  },
131
134
  pagination: {
@@ -133,101 +136,123 @@ function C(e = {}) {
133
136
  offset: 0
134
137
  }
135
138
  }),
136
- t(w, s, { pagination: {
139
+ t(C, s, { pagination: {
137
140
  limit: 5,
138
141
  offset: 0
139
142
  } }),
140
- t(w, c, { pagination: {
143
+ t(C, c, { pagination: {
141
144
  limit: 5,
142
145
  offset: 0
143
146
  } })
144
147
  ]);
145
- E(n.inventoryItems.map(x)), O(r.inventoryItems.map(x)), P(n.inventoryItemsCount), I(f + n.inventoryItems.length < n.inventoryItemsCount), A(i.cargoItems.map(y)), M(a.warehouses.map(b));
148
+ O(n.inventoryItems.map(T)), A(r.inventoryItems.map(T)), I(n.inventoryItemsCount), R(f + n.inventoryItems.length < n.inventoryItemsCount), M(i.cargoItems.map(S)), P(a.warehouses.map(w));
146
149
  } catch (e) {
147
- B(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load inventory data"));
150
+ H(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load inventory data"));
148
151
  } finally {
149
- R(!1);
152
+ B(!1);
150
153
  }
151
154
  }, [
155
+ x,
152
156
  C,
153
- w,
154
157
  d,
155
158
  f,
156
159
  u
157
160
  ]);
158
161
  r(() => {
159
- V();
160
- }, [V]);
161
- let H = n(() => {
162
- V();
163
- }, [V]), U = n(async (e, n, r) => {
164
- let i = T.find((t) => t.id === e);
162
+ U();
163
+ }, [U]);
164
+ let W = n(() => {
165
+ U();
166
+ }, [U]), G = n(async (e, n, r) => {
167
+ let i = D.find((t) => t.id === e);
165
168
  if (!i) throw Error("Inventory item not found");
166
- let a = x((await t(w, v, { input: {
169
+ let a = T((await t(C, y, { input: {
167
170
  id: e,
168
171
  onHand: i.quantity + n,
169
172
  available: i.availableQuantity + n,
170
173
  allocated: i.reservedQuantity,
171
174
  damaged: i.damagedQuantity
172
175
  } })).adjustInventoryStock);
173
- return E((t) => t.map((t) => t.id === e ? a : t)), a;
174
- }, [w, T]);
176
+ return O((t) => t.map((t) => t.id === e ? a : t)), a;
177
+ }, [C, D]), K = n(async (e, n, r, i) => {
178
+ if (!Number.isInteger(i) || i <= 0) throw Error("Transfer quantity must be a positive whole number.");
179
+ if (e === n) throw Error("Source and destination warehouses must be different.");
180
+ let a = D.find((t) => t.warehouseId === e && t.productId === r);
181
+ if (!a) throw Error("Source inventory not found");
182
+ let o = D.find((e) => e.warehouseId === n && e.productId === r);
183
+ if (!o) throw Error("Destination inventory not found");
184
+ let s = await t(C, b, { input: {
185
+ sourceInventoryItemId: a.id,
186
+ destinationInventoryItemId: o.id,
187
+ quantity: i
188
+ } }), c = T(s.transferInventoryStock.source), l = T(s.transferInventoryStock.destination);
189
+ O((e) => e.map((e) => e.id === c.id ? c : e.id === l.id ? l : e));
190
+ }, [C, D]), q = n(async (e) => {
191
+ let n = S((await t(C, p, { input: {
192
+ name: e.name,
193
+ sku: e.sku,
194
+ description: e.description,
195
+ category: e.category,
196
+ brand: e.brand,
197
+ dimensions: e.dimensions,
198
+ weight: e.weight,
199
+ value: e.value,
200
+ hazardous: e.hazardous,
201
+ fragile: e.fragile,
202
+ temperatureControlled: e.temperatureControlled
203
+ } })).createCargoItem);
204
+ return M((e) => [n, ...e]), n;
205
+ }, [C]), J = n(async (e) => {
206
+ let n = w((await t(C, g, { input: {
207
+ code: e.code,
208
+ name: e.name,
209
+ type: e.type,
210
+ address: e.address,
211
+ status: e.status,
212
+ contactInfo: e.contactInfo,
213
+ totalCapacity: e.totalCapacity,
214
+ usedCapacity: e.usedCapacity
215
+ } })).createWarehouse);
216
+ return P((e) => [n, ...e]), n;
217
+ }, [C]);
175
218
  return {
176
- inventory: T,
177
- lowStockItems: D,
178
- products: k,
179
- warehouses: j,
180
- totalItems: N,
181
- hasMore: F,
182
- isLoading: L,
183
- error: z,
184
- refetch: H,
185
- updateStock: U,
186
- transferStock: n(async (e, t, n, r) => {
187
- let i = T.find((t) => t.warehouseId === e && t.productId === n);
188
- if (!i) throw Error("Source inventory not found");
189
- await U(i.id, -Math.abs(r), "transfer out");
190
- let a = T.find((e) => e.warehouseId === t && e.productId === n);
191
- a && await U(a.id, Math.abs(r), "transfer in");
192
- }, [T, U]),
193
- createProduct: n(async (e) => {
194
- let n = y((await t(w, p, { input: {
195
- name: e.name,
196
- sku: e.sku,
197
- category: e.category,
198
- brand: e.brand,
199
- weight: e.weight
200
- } })).createCargoItem);
201
- return A((e) => [n, ...e]), n;
202
- }, [w]),
203
- createWarehouse: n(async (e) => {
204
- let n = b((await t(w, h, { input: {
205
- code: e.code,
206
- name: e.name,
207
- type: e.type,
208
- address: e.address,
209
- status: e.status,
210
- contactInfo: e.contactInfo,
211
- totalCapacity: e.totalCapacity,
212
- usedCapacity: e.usedCapacity
213
- } })).createWarehouse);
214
- return M((e) => [n, ...e]), n;
215
- }, [w]),
219
+ inventory: D,
220
+ lowStockItems: k,
221
+ products: j,
222
+ warehouses: N,
223
+ totalItems: F,
224
+ hasMore: L,
225
+ isLoading: z,
226
+ error: V,
227
+ refetch: W,
228
+ updateStock: G,
229
+ transferStock: K,
230
+ createProduct: q,
216
231
  updateProduct: n(async (e, n) => {
217
- let r = y((await t(w, m, {
232
+ let r = S((await t(C, m, {
218
233
  id: e,
219
234
  input: {
220
235
  name: n.name,
221
236
  sku: n.sku,
237
+ description: n.description,
222
238
  category: n.category,
223
239
  brand: n.brand,
224
- weight: n.weight
240
+ dimensions: n.dimensions,
241
+ weight: n.weight,
242
+ value: n.value,
243
+ hazardous: n.hazardous,
244
+ fragile: n.fragile,
245
+ temperatureControlled: n.temperatureControlled
225
246
  }
226
247
  })).updateCargoItem);
227
- return A((t) => t.map((t) => t.id === e ? r : t)), r;
228
- }, [w]),
248
+ return M((t) => t.map((t) => t.id === e ? r : t)), r;
249
+ }, [C]),
250
+ deleteProduct: n(async (e) => {
251
+ await t(C, h, { id: e }), M((t) => t.filter((t) => t.id !== e));
252
+ }, [C]),
253
+ createWarehouse: J,
229
254
  updateWarehouse: n(async (e, n) => {
230
- let r = b((await t(w, _, {
255
+ let r = w((await t(C, v, {
231
256
  id: e,
232
257
  input: {
233
258
  code: n.code,
@@ -240,16 +265,16 @@ function C(e = {}) {
240
265
  usedCapacity: n.usedCapacity
241
266
  }
242
267
  })).updateWarehouse);
243
- return M((t) => t.map((t) => t.id === e ? r : t)), r;
244
- }, [w]),
268
+ return P((t) => t.map((t) => t.id === e ? r : t)), r;
269
+ }, [C]),
245
270
  deleteWarehouse: n(async (e) => {
246
- await t(w, g, { id: e }), M((t) => t.filter((t) => t.id !== e));
247
- }, [w])
271
+ await t(C, _, { id: e }), P((t) => t.filter((t) => t.id !== e));
272
+ }, [C])
248
273
  };
249
274
  }
250
- function w(e = {}) {
251
- let { limit: i = 20, offset: o = 0, search: c, category: l } = e, u = S(), [d, f] = a([]), [p, m] = a(0), [h, g] = a(!1), [_, v] = a(!1), [b, x] = a(null), C = n(async () => {
252
- v(!0), x(null);
275
+ function O(e = {}) {
276
+ let { limit: i = 20, offset: o = 0, search: c, category: l } = e, u = E(), [d, f] = a([]), [p, m] = a(0), [h, g] = a(!1), [_, v] = a(!1), [y, b] = a(!1), [x, C] = a(null), w = n(async () => {
277
+ v(!0), C(null);
253
278
  try {
254
279
  let e = await t(u, s, {
255
280
  filter: {
@@ -261,9 +286,9 @@ function w(e = {}) {
261
286
  offset: o
262
287
  }
263
288
  });
264
- g(o + e.cargoItems.length < e.cargoItemsCount), m(e.cargoItemsCount), f(e.cargoItems.map(y));
289
+ g(o + e.cargoItems.length < e.cargoItemsCount), m(e.cargoItemsCount), f(e.cargoItems.map(S));
265
290
  } catch (e) {
266
- x(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load products"));
291
+ C(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load products"));
267
292
  } finally {
268
293
  v(!1);
269
294
  }
@@ -273,21 +298,57 @@ function w(e = {}) {
273
298
  o,
274
299
  c,
275
300
  l
301
+ ]), T = n(async () => {
302
+ if (!h || _ || y) return;
303
+ let e = o + d.length;
304
+ b(!0), C(null);
305
+ try {
306
+ let n = await t(u, s, {
307
+ filter: {
308
+ search: c || void 0,
309
+ category: l || void 0
310
+ },
311
+ pagination: {
312
+ limit: i,
313
+ offset: e
314
+ }
315
+ }), r = n.cargoItems.map(S);
316
+ m(n.cargoItemsCount), g(e + r.length < n.cargoItemsCount), f((e) => {
317
+ let t = new Set(e.map((e) => e.id));
318
+ return [...e, ...r.filter((e) => !t.has(e.id))];
319
+ });
320
+ } catch (e) {
321
+ C(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load more products"));
322
+ } finally {
323
+ b(!1);
324
+ }
325
+ }, [
326
+ l,
327
+ u,
328
+ h,
329
+ _,
330
+ y,
331
+ i,
332
+ o,
333
+ d.length,
334
+ c
276
335
  ]);
277
336
  return r(() => {
278
- C();
279
- }, [C]), {
337
+ w();
338
+ }, [w]), {
280
339
  products: d,
281
340
  totalProducts: p,
282
341
  hasMore: h,
283
342
  isLoading: _,
284
- error: b,
285
- refetch: () => void C()
343
+ isLoadingMore: y,
344
+ error: x,
345
+ refetch: () => void w(),
346
+ loadMore: T
286
347
  };
287
348
  }
288
- var T = "\n query CargoItemStats {\n cargoItemStats {\n total\n specialHandling\n temperatureControlled\n }\n }\n";
289
- function E() {
290
- let e = S(), [n, i] = a({
349
+ var k = "\n query CargoItemStats {\n cargoItemStats {\n total\n specialHandling\n temperatureControlled\n }\n }\n";
350
+ function A() {
351
+ let e = E(), [n, i] = a({
291
352
  total: 0,
292
353
  specialHandling: 0,
293
354
  temperatureControlled: 0
@@ -296,7 +357,7 @@ function E() {
296
357
  (async () => {
297
358
  s(!0), l(null);
298
359
  try {
299
- i((await t(e, T)).cargoItemStats);
360
+ i((await t(e, k)).cargoItemStats);
300
361
  } catch (e) {
301
362
  l(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load product stats"));
302
363
  } finally {
@@ -309,8 +370,8 @@ function E() {
309
370
  error: c
310
371
  };
311
372
  }
312
- function D(e) {
313
- let i = S(), [o, s] = a(null), [c, u] = a(!1), [d, f] = a(null), p = n(async () => {
373
+ function j(e) {
374
+ let i = E(), [o, s] = a(null), [c, u] = a(!1), [d, f] = a(null), p = n(async () => {
314
375
  if (!e) {
315
376
  s(null);
316
377
  return;
@@ -318,7 +379,7 @@ function D(e) {
318
379
  u(!0), f(null);
319
380
  try {
320
381
  let n = await t(i, l, { id: e });
321
- s(n.cargoItem ? y(n.cargoItem) : null);
382
+ s(n.cargoItem ? S(n.cargoItem) : null);
322
383
  } catch (e) {
323
384
  f(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load product"));
324
385
  } finally {
@@ -334,9 +395,9 @@ function D(e) {
334
395
  refetch: () => void p()
335
396
  };
336
397
  }
337
- function O(e = {}) {
338
- let { limit: i = 20, offset: o = 0, search: s, status: l } = e, u = S(), [d, f] = a([]), [p, m] = a(0), [h, g] = a(!1), [_, v] = a(!1), [y, x] = a(null), C = n(async () => {
339
- v(!0), x(null);
398
+ function M(e = {}) {
399
+ let { limit: i = 20, offset: o = 0, search: s, status: l } = e, u = E(), [d, f] = a([]), [p, m] = a(0), [h, g] = a(!1), [_, v] = a(!1), [y, b] = a(null), x = n(async () => {
400
+ v(!0), b(null);
340
401
  try {
341
402
  let e = await t(u, c, {
342
403
  filter: {
@@ -348,9 +409,9 @@ function O(e = {}) {
348
409
  offset: o
349
410
  }
350
411
  });
351
- m(e.warehousesCount), g(o + e.warehouses.length < e.warehousesCount), f(e.warehouses.map(b));
412
+ m(e.warehousesCount), g(o + e.warehouses.length < e.warehousesCount), f(e.warehouses.map(w));
352
413
  } catch (e) {
353
- x(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load warehouses"));
414
+ b(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load warehouses"));
354
415
  } finally {
355
416
  v(!1);
356
417
  }
@@ -362,19 +423,19 @@ function O(e = {}) {
362
423
  l
363
424
  ]);
364
425
  return r(() => {
365
- C();
366
- }, [C]), {
426
+ x();
427
+ }, [x]), {
367
428
  warehouses: d,
368
429
  totalWarehouses: p,
369
430
  hasMore: h,
370
431
  isLoading: _,
371
432
  error: y,
372
- refetch: () => void C()
433
+ refetch: () => void x()
373
434
  };
374
435
  }
375
- var k = "\n query WarehouseStats {\n warehouseStats {\n total\n active\n avgUtilization\n }\n }\n";
376
- function A() {
377
- let e = S(), [n, i] = a({
436
+ var N = "\n query WarehouseStats {\n warehouseStats {\n total\n active\n avgUtilization\n }\n }\n";
437
+ function P() {
438
+ let e = E(), [n, i] = a({
378
439
  total: 0,
379
440
  active: 0,
380
441
  avgUtilization: 0
@@ -383,7 +444,7 @@ function A() {
383
444
  (async () => {
384
445
  s(!0), l(null);
385
446
  try {
386
- i((await t(e, k)).warehouseStats);
447
+ i((await t(e, N)).warehouseStats);
387
448
  } catch (e) {
388
449
  l(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load warehouse stats"));
389
450
  } finally {
@@ -396,8 +457,8 @@ function A() {
396
457
  error: c
397
458
  };
398
459
  }
399
- function j(e) {
400
- let i = S(), [o, s] = a(null), [c, l] = a(!1), [d, f] = a(null), p = n(async () => {
460
+ function F(e) {
461
+ let i = E(), [o, s] = a(null), [c, l] = a(!1), [d, f] = a(null), p = n(async () => {
401
462
  if (!e) {
402
463
  s(null);
403
464
  return;
@@ -405,7 +466,7 @@ function j(e) {
405
466
  l(!0), f(null);
406
467
  try {
407
468
  let n = await t(i, u, { id: e });
408
- s(n.warehouse ? b(n.warehouse) : null);
469
+ s(n.warehouse ? w(n.warehouse) : null);
409
470
  } catch (e) {
410
471
  f(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load warehouse"));
411
472
  } finally {
@@ -422,8 +483,8 @@ function j(e) {
422
483
  reload: p
423
484
  };
424
485
  }
425
- function M() {
426
- let e = S(), [n, i] = a({
486
+ function I() {
487
+ let e = E(), [n, i] = a({
427
488
  totalOnHand: 0,
428
489
  totalAvailable: 0,
429
490
  totalAllocated: 0,
@@ -458,16 +519,16 @@ function M() {
458
519
  error: c
459
520
  };
460
521
  }
461
- var N = "\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 P(e, i = {}) {
463
- let { limit: o = 20, offset: s = 0 } = i, c = S(), [l, u] = a([]), [d, f] = a(0), [p, m] = a(0), [h, g] = a(!1), [_, v] = a(null), y = n(async () => {
522
+ var L = "\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";
523
+ function R(e, i = {}) {
524
+ let { limit: o = 20, offset: s = 0 } = i, c = E(), [l, u] = a([]), [d, f] = a(0), [p, m] = a(0), [h, g] = a(!1), [_, v] = a(null), y = n(async () => {
464
525
  if (!e) {
465
526
  u([]), f(0), m(0);
466
527
  return;
467
528
  }
468
529
  g(!0), v(null);
469
530
  try {
470
- let n = await t(c, N, {
531
+ let n = await t(c, L, {
471
532
  cargoItemId: e,
472
533
  pagination: {
473
534
  limit: o,
@@ -512,22 +573,22 @@ function P(e, i = {}) {
512
573
  refetch: b
513
574
  };
514
575
  }
515
- var F = [
576
+ var z = [
516
577
  "RECEIPT",
517
578
  "ISSUE",
518
579
  "TRANSFER",
519
580
  "ADJUSTMENT",
520
581
  "RETURN"
521
582
  ];
522
- function I(e) {
583
+ function B(e) {
523
584
  let t = e.toUpperCase();
524
- return F.find((e) => e === t) ?? "ADJUSTMENT";
585
+ return z.find((e) => e === t) ?? "ADJUSTMENT";
525
586
  }
526
- function L(e) {
587
+ function V(e) {
527
588
  return {
528
589
  id: e.id,
529
590
  transactionNumber: e.transactionNumber,
530
- type: I(e.type),
591
+ type: B(e.type),
531
592
  quantity: e.quantity,
532
593
  productId: e.cargoItemId,
533
594
  warehouseId: e.warehouseId,
@@ -537,8 +598,8 @@ function L(e) {
537
598
  createdAt: new Date(e.createdAt)
538
599
  };
539
600
  }
540
- function R(e = {}) {
541
- let { limit: i = 10, productId: o, warehouseId: s } = e, c = S(), [l, u] = a([]), [d, p] = a(!1), [m, h] = a(null), g = n(async () => {
601
+ function H(e = {}) {
602
+ let { limit: i = 10, productId: o, warehouseId: s } = e, c = E(), [l, u] = a([]), [d, p] = a(!1), [m, h] = a(null), g = n(async () => {
542
603
  p(!0), h(null);
543
604
  try {
544
605
  u((await t(c, f, {
@@ -550,7 +611,7 @@ function R(e = {}) {
550
611
  limit: i,
551
612
  offset: 0
552
613
  }
553
- })).inventoryTransactions.map(L));
614
+ })).inventoryTransactions.map(V));
554
615
  } catch (e) {
555
616
  h(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load inventory transactions"));
556
617
  } finally {
@@ -574,4 +635,4 @@ function R(e = {}) {
574
635
  };
575
636
  }
576
637
  //#endregion
577
- export { C as useInventory, M as useInventoryStats, R as useInventoryTransactions, D as useProduct, E as useProductStats, P as useProductStockLevels, w as useProducts, j as useWarehouse, A as useWarehouseStats, O as useWarehouses };
638
+ export { D as useInventory, I as useInventoryStats, H as useInventoryTransactions, j as useProduct, A as useProductStats, R as useProductStockLevels, O as useProducts, F as useWarehouse, P as useWarehouseStats, M as useWarehouses };