@burdenoff/microfe-movethewheels 2026.1117.1 → 2026.1123.2

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 (70) hide show
  1. package/dist/MoveTheWheelsRoot.js +149 -133
  2. package/dist/MoveTheWheelsRoutes.js +157 -139
  3. package/dist/components/EntityConversationsCard.js +145 -0
  4. package/dist/components/maps/MapCanvas.js +4 -3
  5. package/dist/events/rybbit.js +87 -0
  6. package/dist/generated/tracking-quality-operations.d.ts +342 -0
  7. package/dist/hooks/useEntityComments.js +111 -0
  8. package/dist/hooks/useFleet.js +394 -311
  9. package/dist/hooks/useInventory.js +378 -313
  10. package/dist/hooks/useMultiModalShipments.js +58 -53
  11. package/dist/hooks/useOrders.js +178 -158
  12. package/dist/hooks/useRoutes.js +146 -130
  13. package/dist/index.js +35 -34
  14. package/dist/movethewheels/components/EntityConversationsCard.d.ts +8 -0
  15. package/dist/movethewheels/events/rybbit.d.ts +27 -0
  16. package/dist/movethewheels/hooks/useEntityComments.d.ts +26 -0
  17. package/dist/movethewheels/hooks/useFleet.d.ts +73 -1
  18. package/dist/movethewheels/hooks/useInventory.d.ts +19 -0
  19. package/dist/movethewheels/index.d.ts +1 -0
  20. package/dist/movethewheels/pages/DocumentsLibraryPage.d.ts +1 -0
  21. package/dist/movethewheels/pages/NotificationsCenterPage.d.ts +1 -0
  22. package/dist/movethewheels/types/index.d.ts +95 -2
  23. package/dist/node_modules/lucide-react/dist/esm/icons/check-check.js +10 -0
  24. package/dist/node_modules/lucide-react/dist/esm/icons/layers.js +17 -0
  25. package/dist/node_modules/lucide-react/dist/esm/icons/message-square.js +7 -0
  26. package/dist/node_modules/lucide-react/dist/esm/icons/send.js +10 -0
  27. package/dist/pages/DocumentsLibraryPage.js +235 -0
  28. package/dist/pages/DriverDetailsPage.js +625 -351
  29. package/dist/pages/NotificationsCenterPage.js +310 -0
  30. package/dist/pages/OrderDetailsPage.js +48 -42
  31. package/dist/pages/RouteDetailsPage.js +257 -251
  32. package/dist/pages/TrackingPage.js +202 -196
  33. package/dist/pages/VehicleDetailsPage.js +616 -314
  34. package/dist/pages/WarehouseDetailsPage.js +539 -253
  35. package/dist/stories/ControlTowerWidgets.stories.d.ts +10 -0
  36. package/dist/stories/DataTable.stories.d.ts +15 -0
  37. package/dist/stories/FleetCards.stories.d.ts +9 -0
  38. package/dist/stories/OrderForms.stories.d.ts +8 -0
  39. package/dist/stories/RouteMap.stories.d.ts +7 -0
  40. package/dist/stories/ShipmentTimeline.stories.d.ts +6 -0
  41. package/package.json +1 -1
  42. package/src/generated/tracking-quality-operations.ts +407 -0
  43. package/src/movethewheels/MoveTheWheelsRoot.tsx +16 -0
  44. package/src/movethewheels/MoveTheWheelsRoutes.tsx +17 -2
  45. package/src/movethewheels/components/EntityConversationsCard.tsx +143 -0
  46. package/src/movethewheels/components/maps/MapCanvas.tsx +3 -3
  47. package/src/movethewheels/events/__tests__/rybbit.test.ts +98 -0
  48. package/src/movethewheels/events/rybbit.ts +191 -0
  49. package/src/movethewheels/hooks/useEntityComments.ts +258 -0
  50. package/src/movethewheels/hooks/useFleet.ts +300 -5
  51. package/src/movethewheels/hooks/useInventory.ts +231 -3
  52. package/src/movethewheels/hooks/useMultiModalShipments.ts +8 -1
  53. package/src/movethewheels/hooks/useOrders.ts +19 -3
  54. package/src/movethewheels/hooks/useRoutes.ts +14 -2
  55. package/src/movethewheels/index.ts +1 -0
  56. package/src/movethewheels/pages/DocumentsLibraryPage.tsx +229 -0
  57. package/src/movethewheels/pages/DriverDetailsPage.tsx +250 -1
  58. package/src/movethewheels/pages/NotificationsCenterPage.tsx +331 -0
  59. package/src/movethewheels/pages/OrderDetailsPage.tsx +8 -0
  60. package/src/movethewheels/pages/RouteDetailsPage.tsx +6 -0
  61. package/src/movethewheels/pages/TrackingPage.tsx +8 -0
  62. package/src/movethewheels/pages/VehicleDetailsPage.tsx +255 -1
  63. package/src/movethewheels/pages/WarehouseDetailsPage.tsx +266 -2
  64. package/src/movethewheels/types/index.ts +103 -2
  65. package/src/stories/ControlTowerWidgets.stories.tsx +150 -0
  66. package/src/stories/DataTable.stories.tsx +94 -0
  67. package/src/stories/FleetCards.stories.tsx +77 -0
  68. package/src/stories/OrderForms.stories.tsx +84 -0
  69. package/src/stories/RouteMap.stories.tsx +43 -0
  70. package/src/stories/ShipmentTimeline.stories.tsx +128 -0
@@ -1,32 +1,34 @@
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 { emitWarehouseInboundReceived as t } from "../events/rybbit.js";
3
+ import { executeGraphQL as n } from "../utils/graphqlClient.js";
4
+ import { useCallback as r, useEffect as i, useMemo as a, useState as o } from "react";
5
+ import { useEventBus as s } from "@burdenoff/fe-libs/shared/events";
4
6
  // 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 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 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", b = `
7
+ var c = "\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", l = "\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", u = "\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", d = "\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", f = "\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 zones {\n id\n warehouseId\n code\n name\n zoneType\n temperatureRange\n totalCapacity\n usedCapacity\n status\n }\n staff {\n id\n warehouseId\n userId\n name\n role\n shift\n status\n contactEmail\n contactPhone\n }\n metrics {\n totalLocations\n activeLocations\n zoneCount\n staffCount\n totalSkus\n totalOnHand\n totalAvailable\n lowStockCount\n utilizationPercent\n }\n createdAt\n }\n }\n", p = "\n mutation CreateWarehouseZone($input: CreateWarehouseZoneInput!) {\n createWarehouseZone(input: $input) {\n id\n warehouseId\n code\n name\n zoneType\n temperatureRange\n totalCapacity\n usedCapacity\n status\n }\n }\n", m = "\n mutation DeleteWarehouseZone($id: ID!) {\n deleteWarehouseZone(id: $id)\n }\n", h = "\n mutation CreateWarehouseStaff($input: CreateWarehouseStaffInput!) {\n createWarehouseStaff(input: $input) {\n id\n warehouseId\n userId\n name\n role\n shift\n status\n contactEmail\n contactPhone\n }\n }\n", g = "\n mutation DeleteWarehouseStaff($id: ID!) {\n deleteWarehouseStaff(id: $id)\n }\n", _ = "\n query GetInventoryStats {\n inventoryStats {\n totalOnHand\n totalAvailable\n totalAllocated\n totalDamaged\n lowStockCount\n }\n cargoItemsCount\n warehousesCount\n }\n", v = "\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", y = "\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", b = "\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", x = "\n mutation DeleteCargoItem($id: ID!) {\n deleteCargoItem(id: $id)\n }\n", S = "\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", C = "\n mutation DeleteWarehouse($id: ID!) {\n deleteWarehouse(id: $id)\n }\n", w = "\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", T = "\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", E = `
6
8
  query FindStockLine($filter: InventoryFilterInput, $pagination: PaginationInput) {
7
9
  inventoryItems(filter: $filter, pagination: $pagination) {
8
- ${y}
10
+ ${T}
9
11
  }
10
12
  }
11
- `, x = `
13
+ `, D = `
12
14
  mutation CreateInventoryItem($input: CreateInventoryItemInput!) {
13
15
  createInventoryItem(input: $input) {
14
- ${y}
16
+ ${T}
15
17
  }
16
18
  }
17
- `, S = "\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", C = `
19
+ `, O = "\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", k = `
18
20
  mutation TransferInventoryStock($input: TransferInventoryStockInput!) {
19
21
  transferInventoryStock(input: $input) {
20
22
  source {
21
- ${y}
23
+ ${T}
22
24
  }
23
25
  destination {
24
- ${y}
26
+ ${T}
25
27
  }
26
28
  }
27
29
  }
28
30
  `;
29
- function w(e) {
31
+ function A(e) {
30
32
  if (!e) return;
31
33
  let t = {};
32
34
  for (let n of [
@@ -39,7 +41,7 @@ function w(e) {
39
41
  }
40
42
  return typeof e.unit == "string" && e.unit.trim() && (t.unit = e.unit), Object.keys(t).length > 0 ? t : void 0;
41
43
  }
42
- function T(e) {
44
+ function j(e) {
43
45
  return {
44
46
  id: e.id,
45
47
  sku: e.sku,
@@ -47,7 +49,7 @@ function T(e) {
47
49
  description: e.description ?? void 0,
48
50
  category: e.category ?? void 0,
49
51
  brand: e.brand ?? void 0,
50
- dimensions: w(e.dimensions),
52
+ dimensions: A(e.dimensions),
51
53
  weight: e.weight ?? void 0,
52
54
  value: e.value ?? void 0,
53
55
  barcode: void 0,
@@ -60,10 +62,10 @@ function T(e) {
60
62
  updatedAt: new Date(e.updatedAt)
61
63
  };
62
64
  }
63
- function E(e) {
65
+ function M(e) {
64
66
  return e ? Object.fromEntries(Object.entries(e).flatMap(([e, t]) => typeof t == "string" && t.trim() ? [[e, t]] : [])) : {};
65
67
  }
66
- function D(e) {
68
+ function N(e) {
67
69
  let t = typeof e.totalCapacity == "number" ? e.totalCapacity : void 0, n = typeof e.usedCapacity == "number" ? e.usedCapacity : void 0, r = e.operatingHours ?? {}, i = {};
68
70
  for (let [e, t] of Object.entries(r)) i[e] = t && typeof t == "object" && "open" in t && "close" in t ? {
69
71
  open: String(t.open),
@@ -74,7 +76,7 @@ function D(e) {
74
76
  id: e.id,
75
77
  name: e.name,
76
78
  code: e.code,
77
- address: E(e.address),
79
+ address: M(e.address),
78
80
  type: e.type.toLowerCase(),
79
81
  status: e.status,
80
82
  capacity: {
@@ -87,10 +89,43 @@ function D(e) {
87
89
  phone: typeof a.phone == "string" ? a.phone : void 0
88
90
  } : void 0,
89
91
  utilization: o,
92
+ zones: e.zones?.map((e) => ({
93
+ id: e.id,
94
+ warehouseId: e.warehouseId,
95
+ code: e.code,
96
+ name: e.name,
97
+ zoneType: e.zoneType,
98
+ temperatureRange: e.temperatureRange ?? void 0,
99
+ totalCapacity: e.totalCapacity ?? void 0,
100
+ usedCapacity: e.usedCapacity ?? void 0,
101
+ status: e.status
102
+ })),
103
+ staff: e.staff?.map((e) => ({
104
+ id: e.id,
105
+ warehouseId: e.warehouseId,
106
+ userId: e.userId ?? void 0,
107
+ name: e.name,
108
+ role: e.role,
109
+ shift: e.shift ?? void 0,
110
+ status: e.status,
111
+ contactEmail: e.contactEmail ?? void 0,
112
+ contactPhone: e.contactPhone ?? void 0
113
+ })),
114
+ metrics: e.metrics ? {
115
+ totalLocations: e.metrics.totalLocations,
116
+ activeLocations: e.metrics.activeLocations,
117
+ zoneCount: e.metrics.zoneCount,
118
+ staffCount: e.metrics.staffCount,
119
+ totalSkus: e.metrics.totalSkus,
120
+ totalOnHand: e.metrics.totalOnHand,
121
+ totalAvailable: e.metrics.totalAvailable,
122
+ lowStockCount: e.metrics.lowStockCount,
123
+ utilizationPercent: e.metrics.utilizationPercent ?? void 0
124
+ } : void 0,
90
125
  createdAt: new Date(e.createdAt)
91
126
  };
92
127
  }
93
- function O(e) {
128
+ function P(e) {
94
129
  return {
95
130
  id: e.id,
96
131
  productId: e.cargoItemId,
@@ -108,50 +143,50 @@ function O(e) {
108
143
  updatedAt: new Date(e.updatedAt)
109
144
  };
110
145
  }
111
- function k() {
112
- let { apiGatewayUrl: t, authToken: n, workspaceToken: r, workspaceId: a, tenantId: o, currentUser: s } = e();
113
- return i(() => ({
146
+ function F() {
147
+ let { apiGatewayUrl: t, authToken: n, workspaceToken: r, workspaceId: i, tenantId: o, currentUser: s } = e();
148
+ return a(() => ({
114
149
  apiGatewayUrl: t,
115
150
  authToken: n,
116
151
  workspaceToken: r,
117
- workspaceId: a,
152
+ workspaceId: i,
118
153
  tenantId: o,
119
154
  actorId: s?.id
120
155
  }), [
121
156
  t,
122
157
  n,
123
158
  r,
124
- a,
159
+ i,
125
160
  o,
126
161
  s?.id
127
162
  ]);
128
163
  }
129
- function A(e = {}) {
130
- let { filters: l, search: u, limit: d = 10, offset: f = 0 } = e, y = i(() => l, [
131
- l?.lowStock,
132
- l?.productId,
133
- l?.search,
134
- l?.warehouseId
135
- ]), b = k(), [x, w] = a([]), [E, 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 () => {
136
- B(!0), H(null);
164
+ function I(e = {}) {
165
+ let { filters: d, search: f, limit: p = 10, offset: m = 0 } = e, h = a(() => d, [
166
+ d?.lowStock,
167
+ d?.productId,
168
+ d?.search,
169
+ d?.warehouseId
170
+ ]), g = F(), _ = s(), [v, T] = o([]), [E, D] = o([]), [A, M] = o([]), [I, L] = o([]), [R, z] = o(0), [B, V] = o(!1), [H, U] = o(!1), [W, G] = o(null), K = r(async () => {
171
+ U(!0), G(null);
137
172
  try {
138
173
  let e = {
139
- warehouseId: y?.warehouseId,
140
- cargoItemId: y?.productId,
141
- search: u || y?.search || void 0,
142
- lowStock: y?.lowStock || void 0
143
- }, [n, r, i, a] = await Promise.all([
144
- t(b, o, {
174
+ warehouseId: h?.warehouseId,
175
+ cargoItemId: h?.productId,
176
+ search: f || h?.search || void 0,
177
+ lowStock: h?.lowStock || void 0
178
+ }, [t, r, i, a] = await Promise.all([
179
+ n(g, c, {
145
180
  filter: e,
146
181
  pagination: {
147
- limit: d,
148
- offset: f
182
+ limit: p,
183
+ offset: m
149
184
  }
150
185
  }),
151
- t(b, o, {
186
+ n(g, c, {
152
187
  filter: {
153
- warehouseId: y?.warehouseId,
154
- cargoItemId: y?.productId,
188
+ warehouseId: h?.warehouseId,
189
+ cargoItemId: h?.productId,
155
190
  lowStock: !0
156
191
  },
157
192
  pagination: {
@@ -159,59 +194,63 @@ function A(e = {}) {
159
194
  offset: 0
160
195
  }
161
196
  }),
162
- t(b, s, { pagination: {
197
+ n(g, l, { pagination: {
163
198
  limit: 5,
164
199
  offset: 0
165
200
  } }),
166
- t(b, c, { pagination: {
201
+ n(g, u, { pagination: {
167
202
  limit: 5,
168
203
  offset: 0
169
204
  } })
170
205
  ]);
171
- w(n.inventoryItems.map(O)), A(r.inventoryItems.map(O)), I(n.inventoryItemsCount), R(f + n.inventoryItems.length < n.inventoryItemsCount), M(i.cargoItems.map(T)), P(a.warehouses.map(D));
206
+ T(t.inventoryItems.map(P)), D(r.inventoryItems.map(P)), z(t.inventoryItemsCount), V(m + t.inventoryItems.length < t.inventoryItemsCount), M(i.cargoItems.map(j)), L(a.warehouses.map(N));
172
207
  } catch (e) {
173
- H(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load inventory data"));
208
+ G(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load inventory data"));
174
209
  } finally {
175
- B(!1);
210
+ U(!1);
176
211
  }
177
212
  }, [
178
- y,
179
- b,
180
- d,
181
- f,
182
- u
213
+ h,
214
+ g,
215
+ p,
216
+ m,
217
+ f
183
218
  ]);
184
- r(() => {
185
- U();
186
- }, [U]);
187
- let W = n(() => {
188
- U();
189
- }, [U]), G = n(async (e, n, r) => {
190
- let i = x.find((t) => t.id === e);
191
- if (!i) throw Error("Inventory item not found");
192
- let a = O((await t(b, S, { input: {
219
+ i(() => {
220
+ K();
221
+ }, [K]);
222
+ let q = r(() => {
223
+ K();
224
+ }, [K]), J = r(async (e, r, i) => {
225
+ let a = v.find((t) => t.id === e);
226
+ if (!a) throw Error("Inventory item not found");
227
+ let o = P((await n(g, O, { input: {
193
228
  id: e,
194
- onHand: i.quantity + n,
195
- available: i.availableQuantity + n,
196
- allocated: i.reservedQuantity,
197
- damaged: i.damagedQuantity
229
+ onHand: a.quantity + r,
230
+ available: a.availableQuantity + r,
231
+ allocated: a.reservedQuantity,
232
+ damaged: a.damagedQuantity
198
233
  } })).adjustInventoryStock);
199
- return w((t) => t.map((t) => t.id === e ? a : t)), a;
200
- }, [b, x]), K = n(async (e, n, r, i) => {
234
+ return T((t) => t.map((t) => t.id === e ? o : t)), r > 0 && t(_, o.warehouseId, o.id, g.workspaceId), o;
235
+ }, [
236
+ _,
237
+ g,
238
+ v
239
+ ]), Y = r(async (e, t, r, i) => {
201
240
  if (!Number.isInteger(i) || i <= 0) throw Error("Transfer quantity must be a positive whole number.");
202
- if (e === n) throw Error("Source and destination warehouses must be different.");
203
- let a = x.find((t) => t.warehouseId === e && t.productId === r);
241
+ if (e === t) throw Error("Source and destination warehouses must be different.");
242
+ let a = v.find((t) => t.warehouseId === e && t.productId === r);
204
243
  if (!a) throw Error("Source inventory not found");
205
- let o = x.find((e) => e.warehouseId === n && e.productId === r);
244
+ let o = v.find((e) => e.warehouseId === t && e.productId === r);
206
245
  if (!o) throw Error("Destination inventory not found");
207
- let s = await t(b, C, { input: {
246
+ let s = await n(g, k, { input: {
208
247
  sourceInventoryItemId: a.id,
209
248
  destinationInventoryItemId: o.id,
210
249
  quantity: i
211
- } }), c = O(s.transferInventoryStock.source), l = O(s.transferInventoryStock.destination);
212
- w((e) => e.map((e) => e.id === c.id ? c : e.id === l.id ? l : e));
213
- }, [b, x]), q = n(async (e) => {
214
- let n = T((await t(b, p, { input: {
250
+ } }), c = P(s.transferInventoryStock.source), l = P(s.transferInventoryStock.destination);
251
+ T((e) => e.map((e) => e.id === c.id ? c : e.id === l.id ? l : e));
252
+ }, [g, v]), X = r(async (e) => {
253
+ let t = j((await n(g, y, { input: {
215
254
  name: e.name,
216
255
  sku: e.sku,
217
256
  description: e.description,
@@ -224,9 +263,9 @@ function A(e = {}) {
224
263
  fragile: e.fragile,
225
264
  temperatureControlled: e.temperatureControlled
226
265
  } })).createCargoItem);
227
- return M((e) => [n, ...e]), n;
228
- }, [b]), J = n(async (e) => {
229
- let n = D((await t(b, g, { input: {
266
+ return M((e) => [t, ...e]), t;
267
+ }, [g]), Z = r(async (e) => {
268
+ let t = N((await n(g, S, { input: {
230
269
  code: e.code,
231
270
  name: e.name,
232
271
  type: e.type,
@@ -236,80 +275,80 @@ function A(e = {}) {
236
275
  totalCapacity: e.totalCapacity,
237
276
  usedCapacity: e.usedCapacity
238
277
  } })).createWarehouse);
239
- return P((e) => [n, ...e]), n;
240
- }, [b]);
278
+ return L((e) => [t, ...e]), t;
279
+ }, [g]);
241
280
  return {
242
- inventory: x,
281
+ inventory: v,
243
282
  lowStockItems: E,
244
- products: j,
245
- warehouses: N,
246
- totalItems: F,
247
- hasMore: L,
248
- isLoading: z,
249
- error: V,
250
- refetch: W,
251
- updateStock: G,
252
- transferStock: K,
253
- createProduct: q,
254
- updateProduct: n(async (e, n) => {
255
- let r = T((await t(b, m, {
283
+ products: A,
284
+ warehouses: I,
285
+ totalItems: R,
286
+ hasMore: B,
287
+ isLoading: H,
288
+ error: W,
289
+ refetch: q,
290
+ updateStock: J,
291
+ transferStock: Y,
292
+ createProduct: X,
293
+ updateProduct: r(async (e, t) => {
294
+ let r = j((await n(g, b, {
256
295
  id: e,
257
296
  input: {
258
- name: n.name,
259
- sku: n.sku,
260
- description: n.description,
261
- category: n.category,
262
- brand: n.brand,
263
- dimensions: n.dimensions,
264
- weight: n.weight,
265
- value: n.value,
266
- hazardous: n.hazardous,
267
- fragile: n.fragile,
268
- temperatureControlled: n.temperatureControlled
297
+ name: t.name,
298
+ sku: t.sku,
299
+ description: t.description,
300
+ category: t.category,
301
+ brand: t.brand,
302
+ dimensions: t.dimensions,
303
+ weight: t.weight,
304
+ value: t.value,
305
+ hazardous: t.hazardous,
306
+ fragile: t.fragile,
307
+ temperatureControlled: t.temperatureControlled
269
308
  }
270
309
  })).updateCargoItem);
271
310
  return M((t) => t.map((t) => t.id === e ? r : t)), r;
272
- }, [b]),
273
- deleteProduct: n(async (e) => {
274
- await t(b, h, { id: e }), M((t) => t.filter((t) => t.id !== e));
275
- }, [b]),
276
- createWarehouse: J,
277
- updateWarehouse: n(async (e, n) => {
278
- let r = D((await t(b, v, {
311
+ }, [g]),
312
+ deleteProduct: r(async (e) => {
313
+ await n(g, x, { id: e }), M((t) => t.filter((t) => t.id !== e));
314
+ }, [g]),
315
+ createWarehouse: Z,
316
+ updateWarehouse: r(async (e, t) => {
317
+ let r = N((await n(g, w, {
279
318
  id: e,
280
319
  input: {
281
- code: n.code,
282
- name: n.name,
283
- type: n.type,
284
- address: n.address,
285
- status: n.status,
286
- contactInfo: n.contactInfo,
287
- totalCapacity: n.totalCapacity,
288
- usedCapacity: n.usedCapacity
320
+ code: t.code,
321
+ name: t.name,
322
+ type: t.type,
323
+ address: t.address,
324
+ status: t.status,
325
+ contactInfo: t.contactInfo,
326
+ totalCapacity: t.totalCapacity,
327
+ usedCapacity: t.usedCapacity
289
328
  }
290
329
  })).updateWarehouse);
291
- return P((t) => t.map((t) => t.id === e ? r : t)), r;
292
- }, [b]),
293
- deleteWarehouse: n(async (e) => {
294
- await t(b, _, { id: e }), P((t) => t.filter((t) => t.id !== e));
295
- }, [b])
330
+ return L((t) => t.map((t) => t.id === e ? r : t)), r;
331
+ }, [g]),
332
+ deleteWarehouse: r(async (e) => {
333
+ await n(g, C, { id: e }), L((t) => t.filter((t) => t.id !== e));
334
+ }, [g])
296
335
  };
297
336
  }
298
- function j(e = {}) {
299
- let { limit: i = 20, offset: o = 0, search: c, category: l } = e, u = k(), [d, f] = a([]), [p, m] = a(0), [h, g] = a(!1), [_, v] = a(!1), [y, b] = a(!1), [x, S] = a(null), C = n(async () => {
337
+ function L(e = {}) {
338
+ let { limit: t = 20, offset: a = 0, search: s, category: c } = e, u = F(), [d, f] = o([]), [p, m] = o(0), [h, g] = o(!1), [_, v] = o(!1), [y, b] = o(!1), [x, S] = o(null), C = r(async () => {
300
339
  v(!0), S(null);
301
340
  try {
302
- let e = await t(u, s, {
341
+ let e = await n(u, l, {
303
342
  filter: {
304
- search: c || void 0,
305
- category: l || void 0
343
+ search: s || void 0,
344
+ category: c || void 0
306
345
  },
307
346
  pagination: {
308
- limit: i,
309
- offset: o
347
+ limit: t,
348
+ offset: a
310
349
  }
311
350
  });
312
- g(o + e.cargoItems.length < e.cargoItemsCount), m(e.cargoItemsCount), f(e.cargoItems.map(T));
351
+ g(a + e.cargoItems.length < e.cargoItemsCount), m(e.cargoItemsCount), f(e.cargoItems.map(j));
313
352
  } catch (e) {
314
353
  S(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load products"));
315
354
  } finally {
@@ -317,28 +356,28 @@ function j(e = {}) {
317
356
  }
318
357
  }, [
319
358
  u,
320
- i,
321
- o,
322
- c,
323
- l
324
- ]), w = n(async () => {
359
+ t,
360
+ a,
361
+ s,
362
+ c
363
+ ]), w = r(async () => {
325
364
  if (!h || _ || y) return;
326
- let e = o + d.length;
365
+ let e = a + d.length;
327
366
  b(!0), S(null);
328
367
  try {
329
- let n = await t(u, s, {
368
+ let r = await n(u, l, {
330
369
  filter: {
331
- search: c || void 0,
332
- category: l || void 0
370
+ search: s || void 0,
371
+ category: c || void 0
333
372
  },
334
373
  pagination: {
335
- limit: i,
374
+ limit: t,
336
375
  offset: e
337
376
  }
338
- }), r = n.cargoItems.map(T);
339
- m(n.cargoItemsCount), g(e + r.length < n.cargoItemsCount), f((e) => {
377
+ }), i = r.cargoItems.map(j);
378
+ m(r.cargoItemsCount), g(e + i.length < r.cargoItemsCount), f((e) => {
340
379
  let t = new Set(e.map((e) => e.id));
341
- return [...e, ...r.filter((e) => !t.has(e.id))];
380
+ return [...e, ...i.filter((e) => !t.has(e.id))];
342
381
  });
343
382
  } catch (e) {
344
383
  S(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load more products"));
@@ -346,17 +385,17 @@ function j(e = {}) {
346
385
  b(!1);
347
386
  }
348
387
  }, [
349
- l,
388
+ c,
350
389
  u,
351
390
  h,
352
391
  _,
353
392
  y,
354
- i,
355
- o,
393
+ t,
394
+ a,
356
395
  d.length,
357
- c
396
+ s
358
397
  ]);
359
- return r(() => {
398
+ return i(() => {
360
399
  C();
361
400
  }, [C]), {
362
401
  products: d,
@@ -369,19 +408,19 @@ function j(e = {}) {
369
408
  loadMore: w
370
409
  };
371
410
  }
372
- var M = "\n query CargoItemStats {\n cargoItemStats {\n total\n specialHandling\n temperatureControlled\n }\n }\n";
373
- function N() {
374
- let e = k(), [n, i] = a({
411
+ var R = "\n query CargoItemStats {\n cargoItemStats {\n total\n specialHandling\n temperatureControlled\n }\n }\n";
412
+ function z() {
413
+ let e = F(), [t, r] = o({
375
414
  total: 0,
376
415
  specialHandling: 0,
377
416
  temperatureControlled: 0
378
- }), [o, s] = a(!1), [c, l] = a(null);
379
- return r(() => {
417
+ }), [a, s] = o(!1), [c, l] = o(null);
418
+ return i(() => {
380
419
  (async () => {
381
420
  s(!0), l(null);
382
421
  try {
383
- let n = await t(e, M);
384
- i(n.cargoItemStats);
422
+ let t = await n(e, R);
423
+ r(t.cargoItemStats);
385
424
  } catch (e) {
386
425
  l(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load product stats"));
387
426
  } finally {
@@ -389,79 +428,79 @@ function N() {
389
428
  }
390
429
  })();
391
430
  }, [e]), {
392
- stats: n,
393
- isLoading: o,
431
+ stats: t,
432
+ isLoading: a,
394
433
  error: c
395
434
  };
396
435
  }
397
- function P(e) {
398
- let i = k(), [o, s] = a(null), [c, u] = a(!1), [d, f] = a(null), p = n(async () => {
436
+ function B(e) {
437
+ let t = F(), [a, s] = o(null), [c, l] = o(!1), [u, f] = o(null), p = r(async () => {
399
438
  if (!e) s(null);
400
439
  else {
401
- u(!0), f(null);
440
+ l(!0), f(null);
402
441
  try {
403
- let n = await t(i, l, { id: e });
404
- s(n.cargoItem ? T(n.cargoItem) : null);
442
+ let r = await n(t, d, { id: e });
443
+ s(r.cargoItem ? j(r.cargoItem) : null);
405
444
  } catch (e) {
406
445
  f(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load product"));
407
446
  } finally {
408
- u(!1);
447
+ l(!1);
409
448
  }
410
449
  }
411
- }, [i, e]);
412
- return r(() => {
450
+ }, [t, e]);
451
+ return i(() => {
413
452
  p();
414
453
  }, [p]), {
415
- product: o,
454
+ product: a,
416
455
  isLoading: c,
417
- error: d,
456
+ error: u,
418
457
  refetch: () => void p()
419
458
  };
420
459
  }
421
- function F(e = {}) {
422
- let { limit: i = 20, offset: o = 0, search: s, status: l } = e, u = k(), [d, f] = a([]), [p, m] = a(0), [h, g] = a(!1), [_, v] = a(!1), [y, b] = a(!1), [x, S] = a(null), C = n(async () => {
460
+ function V(e = {}) {
461
+ let { limit: t = 20, offset: a = 0, search: s, status: c } = e, l = F(), [d, f] = o([]), [p, m] = o(0), [h, g] = o(!1), [_, v] = o(!1), [y, b] = o(!1), [x, S] = o(null), C = r(async () => {
423
462
  v(!0), S(null);
424
463
  try {
425
- let e = await t(u, c, {
464
+ let e = await n(l, u, {
426
465
  filter: {
427
466
  search: s || void 0,
428
- status: l || void 0
467
+ status: c || void 0
429
468
  },
430
469
  pagination: {
431
- limit: i,
432
- offset: o
470
+ limit: t,
471
+ offset: a
433
472
  }
434
473
  });
435
- m(e.warehousesCount), g(o + e.warehouses.length < e.warehousesCount), f(e.warehouses.map(D));
474
+ m(e.warehousesCount), g(a + e.warehouses.length < e.warehousesCount), f(e.warehouses.map(N));
436
475
  } catch (e) {
437
476
  S(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load warehouses"));
438
477
  } finally {
439
478
  v(!1);
440
479
  }
441
480
  }, [
442
- u,
443
- i,
444
- o,
481
+ l,
482
+ t,
483
+ a,
445
484
  s,
446
- l
447
- ]), w = n(async () => {
485
+ c
486
+ ]), w = r(async () => {
448
487
  if (!h || _ || y) return;
449
- let e = o + d.length;
488
+ let e = a + d.length;
450
489
  b(!0), S(null);
451
490
  try {
452
- let n = await t(u, c, {
491
+ let r = await n(l, u, {
453
492
  filter: {
454
493
  search: s || void 0,
455
- status: l || void 0
494
+ status: c || void 0
456
495
  },
457
496
  pagination: {
458
- limit: i,
497
+ limit: t,
459
498
  offset: e
460
499
  }
461
- }), r = n.warehouses.map(D);
462
- m(n.warehousesCount), g(e + r.length < n.warehousesCount), f((e) => {
500
+ }), i = r.warehouses.map(N);
501
+ m(r.warehousesCount), g(e + i.length < r.warehousesCount), f((e) => {
463
502
  let t = new Set(e.map((e) => e.id));
464
- return [...e, ...r.filter((e) => !t.has(e.id))];
503
+ return [...e, ...i.filter((e) => !t.has(e.id))];
465
504
  });
466
505
  } catch (e) {
467
506
  S(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load more warehouses"));
@@ -469,17 +508,17 @@ function F(e = {}) {
469
508
  b(!1);
470
509
  }
471
510
  }, [
472
- u,
511
+ l,
473
512
  h,
474
513
  _,
475
514
  y,
476
- i,
477
- o,
515
+ t,
516
+ a,
478
517
  s,
479
- l,
518
+ c,
480
519
  d.length
481
520
  ]);
482
- return r(() => {
521
+ return i(() => {
483
522
  C();
484
523
  }, [C]), {
485
524
  warehouses: d,
@@ -492,19 +531,19 @@ function F(e = {}) {
492
531
  loadMore: w
493
532
  };
494
533
  }
495
- var I = "\n query WarehouseStats {\n warehouseStats {\n total\n active\n avgUtilization\n }\n }\n";
496
- function L() {
497
- let e = k(), [n, i] = a({
534
+ var H = "\n query WarehouseStats {\n warehouseStats {\n total\n active\n avgUtilization\n }\n }\n";
535
+ function U() {
536
+ let e = F(), [t, r] = o({
498
537
  total: 0,
499
538
  active: 0,
500
539
  avgUtilization: 0
501
- }), [o, s] = a(!1), [c, l] = a(null);
502
- return r(() => {
540
+ }), [a, s] = o(!1), [c, l] = o(null);
541
+ return i(() => {
503
542
  (async () => {
504
543
  s(!0), l(null);
505
544
  try {
506
- let n = await t(e, I);
507
- i(n.warehouseStats);
545
+ let t = await n(e, H);
546
+ r(t.warehouseStats);
508
547
  } catch (e) {
509
548
  l(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load warehouse stats"));
510
549
  } finally {
@@ -512,38 +551,64 @@ function L() {
512
551
  }
513
552
  })();
514
553
  }, [e]), {
515
- stats: n,
516
- isLoading: o,
554
+ stats: t,
555
+ isLoading: a,
517
556
  error: c
518
557
  };
519
558
  }
520
- function R(e) {
521
- let i = k(), [o, s] = a(null), [c, l] = a(!1), [d, f] = a(null), p = n(async () => {
559
+ function W(e) {
560
+ let t = F(), [a, s] = o(null), [c, l] = o(!1), [u, d] = o(null), _ = r(async () => {
522
561
  if (!e) s(null);
523
562
  else {
524
- l(!0), f(null);
563
+ l(!0), d(null);
525
564
  try {
526
- let n = await t(i, u, { id: e });
527
- s(n.warehouse ? D(n.warehouse) : null);
565
+ let r = await n(t, f, { id: e });
566
+ s(r.warehouse ? N(r.warehouse) : null);
528
567
  } catch (e) {
529
- f(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load warehouse"));
568
+ d(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load warehouse"));
530
569
  } finally {
531
570
  l(!1);
532
571
  }
533
572
  }
534
- }, [i, e]);
535
- return r(() => {
536
- p();
537
- }, [p]), {
538
- warehouse: o,
573
+ }, [t, e]);
574
+ return i(() => {
575
+ _();
576
+ }, [_]), {
577
+ warehouse: a,
539
578
  isLoading: c,
540
- error: d,
541
- refetch: () => void p(),
542
- reload: p
579
+ error: u,
580
+ refetch: () => void _(),
581
+ reload: _,
582
+ addZone: r(async (r) => {
583
+ e && (await n(t, p, { input: {
584
+ ...r,
585
+ warehouseId: e
586
+ } }), await _());
587
+ }, [
588
+ t,
589
+ _,
590
+ e
591
+ ]),
592
+ removeZone: r(async (e) => {
593
+ await n(t, m, { id: e }), await _();
594
+ }, [t, _]),
595
+ addStaff: r(async (r) => {
596
+ e && (await n(t, h, { input: {
597
+ ...r,
598
+ warehouseId: e
599
+ } }), await _());
600
+ }, [
601
+ t,
602
+ _,
603
+ e
604
+ ]),
605
+ removeStaff: r(async (e) => {
606
+ await n(t, g, { id: e }), await _();
607
+ }, [t, _])
543
608
  };
544
609
  }
545
- function z() {
546
- let e = k(), [i, o] = a({
610
+ function G() {
611
+ let e = F(), [t, a] = o({
547
612
  totalOnHand: 0,
548
613
  totalAvailable: 0,
549
614
  totalAllocated: 0,
@@ -551,18 +616,18 @@ function z() {
551
616
  lowStockCount: 0,
552
617
  totalProducts: 0,
553
618
  totalWarehouses: 0
554
- }), [s, c] = a(!1), [l, u] = a(null), f = n(async () => {
619
+ }), [s, c] = o(!1), [l, u] = o(null), d = r(async () => {
555
620
  c(!0), u(null);
556
621
  try {
557
- let n = await t(e, d);
558
- o({
559
- totalOnHand: n.inventoryStats.totalOnHand,
560
- totalAvailable: n.inventoryStats.totalAvailable,
561
- totalAllocated: n.inventoryStats.totalAllocated,
562
- totalDamaged: n.inventoryStats.totalDamaged,
563
- lowStockCount: n.inventoryStats.lowStockCount,
564
- totalProducts: n.cargoItemsCount,
565
- totalWarehouses: n.warehousesCount
622
+ let t = await n(e, _);
623
+ a({
624
+ totalOnHand: t.inventoryStats.totalOnHand,
625
+ totalAvailable: t.inventoryStats.totalAvailable,
626
+ totalAllocated: t.inventoryStats.totalAllocated,
627
+ totalDamaged: t.inventoryStats.totalDamaged,
628
+ lowStockCount: t.inventoryStats.lowStockCount,
629
+ totalProducts: t.cargoItemsCount,
630
+ totalWarehouses: t.warehousesCount
566
631
  });
567
632
  } catch (e) {
568
633
  u(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load inventory stats"));
@@ -570,32 +635,32 @@ function z() {
570
635
  c(!1);
571
636
  }
572
637
  }, [e]);
573
- return r(() => {
574
- f();
575
- }, [f]), {
576
- stats: i,
638
+ return i(() => {
639
+ d();
640
+ }, [d]), {
641
+ stats: t,
577
642
  isLoading: s,
578
643
  error: l,
579
- refetch: n(() => {
580
- f();
581
- }, [f])
644
+ refetch: r(() => {
645
+ d();
646
+ }, [d])
582
647
  };
583
648
  }
584
- var B = "\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";
585
- function V(e, i = {}) {
586
- let { limit: o = 20, offset: s = 0 } = i, c = k(), [l, u] = a([]), [d, f] = a(0), [p, m] = a(0), [h, g] = a(!1), [_, v] = a(null), y = n(async () => {
649
+ var K = "\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";
650
+ function q(e, t = {}) {
651
+ let { limit: a = 20, offset: s = 0 } = t, c = F(), [l, u] = o([]), [d, f] = o(0), [p, m] = o(0), [h, g] = o(!1), [_, v] = o(null), y = r(async () => {
587
652
  if (!e) u([]), f(0), m(0);
588
653
  else {
589
654
  g(!0), v(null);
590
655
  try {
591
- let n = await t(c, B, {
656
+ let t = await n(c, K, {
592
657
  cargoItemId: e,
593
658
  pagination: {
594
- limit: o,
659
+ limit: a,
595
660
  offset: s
596
661
  }
597
662
  });
598
- u((n.inventoryItems ?? []).map((e) => ({
663
+ u((t.inventoryItems ?? []).map((e) => ({
599
664
  inventoryItemId: e.id,
600
665
  warehouseId: e.warehouse?.id ?? "",
601
666
  warehouseName: e.warehouse?.name ?? "Unknown warehouse",
@@ -605,7 +670,7 @@ function V(e, i = {}) {
605
670
  allocated: e.allocated,
606
671
  damaged: e.damaged,
607
672
  reorderPoint: e.reorderPoint ?? void 0
608
- }))), f(n.inventoryItemsCount ?? 0), m(n.inventoryStats?.totalAvailable ?? 0);
673
+ }))), f(t.inventoryItemsCount ?? 0), m(t.inventoryStats?.totalAvailable ?? 0);
609
674
  } catch (e) {
610
675
  v(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load stock levels"));
611
676
  } finally {
@@ -614,14 +679,14 @@ function V(e, i = {}) {
614
679
  }
615
680
  }, [
616
681
  c,
617
- o,
682
+ a,
618
683
  s,
619
684
  e
620
685
  ]);
621
- r(() => {
686
+ i(() => {
622
687
  y();
623
688
  }, [y]);
624
- let b = n(() => {
689
+ let b = r(() => {
625
690
  y();
626
691
  }, [y]);
627
692
  return {
@@ -634,22 +699,22 @@ function V(e, i = {}) {
634
699
  refetch: b
635
700
  };
636
701
  }
637
- var H = [
702
+ var J = [
638
703
  "RECEIPT",
639
704
  "ISSUE",
640
705
  "TRANSFER",
641
706
  "ADJUSTMENT",
642
707
  "RETURN"
643
708
  ];
644
- function U(e) {
709
+ function Y(e) {
645
710
  let t = e.toUpperCase();
646
- return H.find((e) => e === t) ?? "ADJUSTMENT";
711
+ return J.find((e) => e === t) ?? "ADJUSTMENT";
647
712
  }
648
- function W(e) {
713
+ function X(e) {
649
714
  return {
650
715
  id: e.id,
651
716
  transactionNumber: e.transactionNumber,
652
- type: U(e.type),
717
+ type: Y(e.type),
653
718
  quantity: e.quantity,
654
719
  productId: e.cargoItemId,
655
720
  warehouseId: e.warehouseId,
@@ -659,114 +724,114 @@ function W(e) {
659
724
  createdAt: new Date(e.createdAt)
660
725
  };
661
726
  }
662
- function G(e = {}) {
663
- let { limit: i = 10, productId: o, warehouseId: s } = e, c = k(), [l, u] = a([]), [d, p] = a(!1), [m, h] = a(null), g = n(async () => {
664
- p(!0), h(null);
727
+ function Z(e = {}) {
728
+ let { limit: t = 10, productId: a, warehouseId: s } = e, c = F(), [l, u] = o([]), [d, f] = o(!1), [p, m] = o(null), h = r(async () => {
729
+ f(!0), m(null);
665
730
  try {
666
- let e = await t(c, f, {
667
- filter: o || s ? {
668
- cargoItemId: o,
731
+ let e = await n(c, v, {
732
+ filter: a || s ? {
733
+ cargoItemId: a,
669
734
  warehouseId: s
670
735
  } : void 0,
671
736
  pagination: {
672
- limit: i,
737
+ limit: t,
673
738
  offset: 0
674
739
  }
675
740
  });
676
- u(e.inventoryTransactions.map(W));
741
+ u(e.inventoryTransactions.map(X));
677
742
  } catch (e) {
678
- h(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load inventory transactions"));
743
+ m(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load inventory transactions"));
679
744
  } finally {
680
- p(!1);
745
+ f(!1);
681
746
  }
682
747
  }, [
683
748
  c,
684
- i,
685
- o,
749
+ t,
750
+ a,
686
751
  s
687
752
  ]);
688
- return r(() => {
689
- g();
690
- }, [g]), {
753
+ return i(() => {
754
+ h();
755
+ }, [h]), {
691
756
  transactions: l,
692
757
  isLoading: d,
693
- error: m,
694
- refetch: n(() => {
695
- g();
696
- }, [g])
758
+ error: p,
759
+ refetch: r(() => {
760
+ h();
761
+ }, [h])
697
762
  };
698
763
  }
699
- function K(e, t) {
764
+ function Q(e, t) {
700
765
  if (!Number.isInteger(e) || e <= 0) throw Error(`${t} must be a positive whole number.`);
701
766
  }
702
- function q() {
703
- let e = k(), r = n(async (n) => {
704
- let r = (await t(e, b, {
705
- filter: n,
767
+ function $() {
768
+ let e = F(), t = r(async (t) => {
769
+ let r = (await n(e, E, {
770
+ filter: t,
706
771
  pagination: { limit: 1 }
707
772
  })).inventoryItems[0];
708
- return r ? O(r) : null;
709
- }, [e]), i = n(async (n, r) => {
710
- let i = n.quantity + r, a = n.availableQuantity + r;
711
- if (a < 0) throw Error(`Only ${n.availableQuantity.toLocaleString()} unit(s) are available to remove.`);
773
+ return r ? P(r) : null;
774
+ }, [e]), i = r(async (t, r) => {
775
+ let i = t.quantity + r, a = t.availableQuantity + r;
776
+ if (a < 0) throw Error(`Only ${t.availableQuantity.toLocaleString()} unit(s) are available to remove.`);
712
777
  if (i < 0) throw Error("On-hand stock cannot go below zero.");
713
- return O((await t(e, S, { input: {
714
- id: n.id,
778
+ return P((await n(e, O, { input: {
779
+ id: t.id,
715
780
  onHand: i,
716
781
  available: a,
717
- allocated: n.reservedQuantity,
718
- damaged: n.damagedQuantity
782
+ allocated: t.reservedQuantity,
783
+ damaged: t.damagedQuantity
719
784
  } })).adjustInventoryStock);
720
- }, [e]), a = n(async (e, t) => {
721
- if (!Number.isInteger(t) || t === 0) throw Error("Enter a whole-number change other than zero.");
722
- let n = await r({ inventoryItemId: e });
723
- if (!n) throw Error("This stock line no longer exists.");
724
- return i(n, t);
725
- }, [i, r]);
785
+ }, [e]), a = r(async (e, n) => {
786
+ if (!Number.isInteger(n) || n === 0) throw Error("Enter a whole-number change other than zero.");
787
+ let r = await t({ inventoryItemId: e });
788
+ if (!r) throw Error("This stock line no longer exists.");
789
+ return i(r, n);
790
+ }, [i, t]);
726
791
  return {
727
- receiveStock: n(async (n) => {
728
- K(n.quantity, "Quantity received");
729
- let a = await r({
730
- cargoItemId: n.productId,
731
- warehouseId: n.warehouseId
792
+ receiveStock: r(async (r) => {
793
+ Q(r.quantity, "Quantity received");
794
+ let a = await t({
795
+ cargoItemId: r.productId,
796
+ warehouseId: r.warehouseId
732
797
  });
733
- return a ? i(a, n.quantity) : O((await t(e, x, { input: {
734
- cargoItemId: n.productId,
735
- warehouseId: n.warehouseId,
736
- onHand: n.quantity,
737
- available: n.quantity,
738
- ...n.reorderPoint !== null && n.reorderPoint !== void 0 ? { reorderPoint: n.reorderPoint } : {}
798
+ return a ? i(a, r.quantity) : P((await n(e, D, { input: {
799
+ cargoItemId: r.productId,
800
+ warehouseId: r.warehouseId,
801
+ onHand: r.quantity,
802
+ available: r.quantity,
803
+ ...r.reorderPoint !== null && r.reorderPoint !== void 0 ? { reorderPoint: r.reorderPoint } : {}
739
804
  } })).createInventoryItem);
740
805
  }, [
741
806
  i,
742
- r,
807
+ t,
743
808
  e
744
809
  ]),
745
810
  adjustStock: a,
746
- transferStock: n(async (n) => {
747
- K(n.quantity, "Transfer quantity");
748
- let i = await r({ inventoryItemId: n.sourceInventoryId });
811
+ transferStock: r(async (r) => {
812
+ Q(r.quantity, "Transfer quantity");
813
+ let i = await t({ inventoryItemId: r.sourceInventoryId });
749
814
  if (!i) throw Error("The source stock line no longer exists.");
750
- if (i.warehouseId === n.destinationWarehouseId) throw Error("Source and destination warehouses must be different.");
751
- if (n.quantity > i.availableQuantity) throw Error(`Only ${i.availableQuantity.toLocaleString()} unit(s) are available to transfer.`);
752
- let a = await r({
815
+ if (i.warehouseId === r.destinationWarehouseId) throw Error("Source and destination warehouses must be different.");
816
+ if (r.quantity > i.availableQuantity) throw Error(`Only ${i.availableQuantity.toLocaleString()} unit(s) are available to transfer.`);
817
+ let a = await t({
753
818
  cargoItemId: i.productId,
754
- warehouseId: n.destinationWarehouseId
819
+ warehouseId: r.destinationWarehouseId
755
820
  });
756
- a ||= O((await t(e, x, { input: {
821
+ a ||= P((await n(e, D, { input: {
757
822
  cargoItemId: i.productId,
758
- warehouseId: n.destinationWarehouseId
823
+ warehouseId: r.destinationWarehouseId
759
824
  } })).createInventoryItem);
760
- let o = await t(e, C, { input: {
825
+ let o = await n(e, k, { input: {
761
826
  sourceInventoryItemId: i.id,
762
827
  destinationInventoryItemId: a.id,
763
- quantity: n.quantity
828
+ quantity: r.quantity
764
829
  } });
765
830
  return {
766
- source: O(o.transferInventoryStock.source),
767
- destination: O(o.transferInventoryStock.destination)
831
+ source: P(o.transferInventoryStock.source),
832
+ destination: P(o.transferInventoryStock.destination)
768
833
  };
769
- }, [r, e])
834
+ }, [t, e])
770
835
  };
771
836
  }
772
- export { A as useInventory, z as useInventoryStats, G as useInventoryTransactions, P as useProduct, N as useProductStats, V as useProductStockLevels, j as useProducts, q as useStockActions, R as useWarehouse, L as useWarehouseStats, F as useWarehouses };
837
+ export { I as useInventory, G as useInventoryStats, Z as useInventoryTransactions, B as useProduct, z as useProductStats, q as useProductStockLevels, L as useProducts, $ as useStockActions, W as useWarehouse, U as useWarehouseStats, V as useWarehouses };