@burdenoff/microfe-movethewheels 2026.930.3 → 2026.930.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/StockActionDialogs.js +385 -0
- package/dist/hooks/useInventory.js +259 -124
- package/dist/index.js +34 -34
- package/dist/movethewheels/components/StockActionDialogs.d.ts +24 -0
- package/dist/movethewheels/hooks/index.d.ts +1 -1
- package/dist/movethewheels/hooks/useInventory.d.ts +30 -0
- package/dist/node_modules/lucide-react/dist/esm/icons/package-plus.js +33 -0
- package/dist/node_modules/lucide-react/dist/esm/icons/sliders-horizontal.js +69 -0
- package/dist/pages/InventoryPage.js +284 -201
- package/dist/pages/RouteDetailsPage.js +4 -4
- package/package.json +1 -1
- package/src/movethewheels/components/StockActionDialogs.tsx +512 -0
- package/src/movethewheels/hooks/index.ts +3 -0
- package/src/movethewheels/hooks/useInventory.ts +296 -55
- package/src/movethewheels/pages/InventoryPage.tsx +114 -3
- package/src/movethewheels/pages/RouteDetailsPage.tsx +5 -4
|
@@ -2,8 +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 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
|
|
6
|
-
|
|
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 = `
|
|
6
|
+
query FindStockLine($filter: InventoryFilterInput, $pagination: PaginationInput) {
|
|
7
|
+
inventoryItems(filter: $filter, pagination: $pagination) {
|
|
8
|
+
${y}
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
`, x = `
|
|
12
|
+
mutation CreateInventoryItem($input: CreateInventoryItemInput!) {
|
|
13
|
+
createInventoryItem(input: $input) {
|
|
14
|
+
${y}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
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 = `
|
|
18
|
+
mutation TransferInventoryStock($input: TransferInventoryStockInput!) {
|
|
19
|
+
transferInventoryStock(input: $input) {
|
|
20
|
+
source {
|
|
21
|
+
${y}
|
|
22
|
+
}
|
|
23
|
+
destination {
|
|
24
|
+
${y}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
`;
|
|
29
|
+
function w(e) {
|
|
7
30
|
if (!e) return;
|
|
8
31
|
let t = {};
|
|
9
32
|
for (let n of [
|
|
@@ -16,7 +39,7 @@ function x(e) {
|
|
|
16
39
|
}
|
|
17
40
|
return typeof e.unit == "string" && e.unit.trim() && (t.unit = e.unit), Object.keys(t).length > 0 ? t : void 0;
|
|
18
41
|
}
|
|
19
|
-
function
|
|
42
|
+
function T(e) {
|
|
20
43
|
return {
|
|
21
44
|
id: e.id,
|
|
22
45
|
sku: e.sku,
|
|
@@ -24,7 +47,7 @@ function S(e) {
|
|
|
24
47
|
description: e.description ?? void 0,
|
|
25
48
|
category: e.category ?? void 0,
|
|
26
49
|
brand: e.brand ?? void 0,
|
|
27
|
-
dimensions:
|
|
50
|
+
dimensions: w(e.dimensions),
|
|
28
51
|
weight: e.weight ?? void 0,
|
|
29
52
|
value: e.value ?? void 0,
|
|
30
53
|
barcode: void 0,
|
|
@@ -37,10 +60,10 @@ function S(e) {
|
|
|
37
60
|
updatedAt: new Date(e.updatedAt)
|
|
38
61
|
};
|
|
39
62
|
}
|
|
40
|
-
function
|
|
63
|
+
function E(e) {
|
|
41
64
|
return e ? Object.fromEntries(Object.entries(e).flatMap(([e, t]) => typeof t == "string" && t.trim() ? [[e, t]] : [])) : {};
|
|
42
65
|
}
|
|
43
|
-
function
|
|
66
|
+
function D(e) {
|
|
44
67
|
let t = typeof e.totalCapacity == "number" ? e.totalCapacity : void 0, n = typeof e.usedCapacity == "number" ? e.usedCapacity : void 0, r = e.operatingHours ?? {}, i = {};
|
|
45
68
|
for (let [e, t] of Object.entries(r)) t && typeof t == "object" && "open" in t && "close" in t ? i[e] = {
|
|
46
69
|
open: String(t.open),
|
|
@@ -51,7 +74,7 @@ function w(e) {
|
|
|
51
74
|
id: e.id,
|
|
52
75
|
name: e.name,
|
|
53
76
|
code: e.code,
|
|
54
|
-
address:
|
|
77
|
+
address: E(e.address),
|
|
55
78
|
type: e.type.toLowerCase(),
|
|
56
79
|
status: e.status,
|
|
57
80
|
capacity: {
|
|
@@ -67,7 +90,7 @@ function w(e) {
|
|
|
67
90
|
createdAt: new Date(e.createdAt)
|
|
68
91
|
};
|
|
69
92
|
}
|
|
70
|
-
function
|
|
93
|
+
function O(e) {
|
|
71
94
|
return {
|
|
72
95
|
id: e.id,
|
|
73
96
|
productId: e.cargoItemId,
|
|
@@ -85,7 +108,7 @@ function T(e) {
|
|
|
85
108
|
updatedAt: new Date(e.updatedAt)
|
|
86
109
|
};
|
|
87
110
|
}
|
|
88
|
-
function
|
|
111
|
+
function k() {
|
|
89
112
|
let { apiGatewayUrl: t, authToken: n, workspaceToken: r, workspaceId: a, tenantId: o, currentUser: s } = e();
|
|
90
113
|
return i(() => ({
|
|
91
114
|
apiGatewayUrl: t,
|
|
@@ -103,32 +126,32 @@ function E() {
|
|
|
103
126
|
s?.id
|
|
104
127
|
]);
|
|
105
128
|
}
|
|
106
|
-
function
|
|
107
|
-
let { filters: l, search: u, limit: d = 10, offset: f = 0 } = e,
|
|
129
|
+
function A(e = {}) {
|
|
130
|
+
let { filters: l, search: u, limit: d = 10, offset: f = 0 } = e, y = i(() => l, [
|
|
108
131
|
l?.lowStock,
|
|
109
132
|
l?.productId,
|
|
110
133
|
l?.search,
|
|
111
134
|
l?.warehouseId
|
|
112
|
-
]),
|
|
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 () => {
|
|
113
136
|
B(!0), H(null);
|
|
114
137
|
try {
|
|
115
138
|
let e = {
|
|
116
|
-
warehouseId:
|
|
117
|
-
cargoItemId:
|
|
118
|
-
search: u ||
|
|
119
|
-
lowStock:
|
|
139
|
+
warehouseId: y?.warehouseId,
|
|
140
|
+
cargoItemId: y?.productId,
|
|
141
|
+
search: u || y?.search || void 0,
|
|
142
|
+
lowStock: y?.lowStock || void 0
|
|
120
143
|
}, [n, r, i, a] = await Promise.all([
|
|
121
|
-
t(
|
|
144
|
+
t(b, o, {
|
|
122
145
|
filter: e,
|
|
123
146
|
pagination: {
|
|
124
147
|
limit: d,
|
|
125
148
|
offset: f
|
|
126
149
|
}
|
|
127
150
|
}),
|
|
128
|
-
t(
|
|
151
|
+
t(b, o, {
|
|
129
152
|
filter: {
|
|
130
|
-
warehouseId:
|
|
131
|
-
cargoItemId:
|
|
153
|
+
warehouseId: y?.warehouseId,
|
|
154
|
+
cargoItemId: y?.productId,
|
|
132
155
|
lowStock: !0
|
|
133
156
|
},
|
|
134
157
|
pagination: {
|
|
@@ -136,24 +159,24 @@ function D(e = {}) {
|
|
|
136
159
|
offset: 0
|
|
137
160
|
}
|
|
138
161
|
}),
|
|
139
|
-
t(
|
|
162
|
+
t(b, s, { pagination: {
|
|
140
163
|
limit: 5,
|
|
141
164
|
offset: 0
|
|
142
165
|
} }),
|
|
143
|
-
t(
|
|
166
|
+
t(b, c, { pagination: {
|
|
144
167
|
limit: 5,
|
|
145
168
|
offset: 0
|
|
146
169
|
} })
|
|
147
170
|
]);
|
|
148
|
-
|
|
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));
|
|
149
172
|
} catch (e) {
|
|
150
173
|
H(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load inventory data"));
|
|
151
174
|
} finally {
|
|
152
175
|
B(!1);
|
|
153
176
|
}
|
|
154
177
|
}, [
|
|
155
|
-
|
|
156
|
-
|
|
178
|
+
y,
|
|
179
|
+
b,
|
|
157
180
|
d,
|
|
158
181
|
f,
|
|
159
182
|
u
|
|
@@ -164,31 +187,31 @@ function D(e = {}) {
|
|
|
164
187
|
let W = n(() => {
|
|
165
188
|
U();
|
|
166
189
|
}, [U]), G = n(async (e, n, r) => {
|
|
167
|
-
let i =
|
|
190
|
+
let i = x.find((t) => t.id === e);
|
|
168
191
|
if (!i) throw Error("Inventory item not found");
|
|
169
|
-
let a =
|
|
192
|
+
let a = O((await t(b, S, { input: {
|
|
170
193
|
id: e,
|
|
171
194
|
onHand: i.quantity + n,
|
|
172
195
|
available: i.availableQuantity + n,
|
|
173
196
|
allocated: i.reservedQuantity,
|
|
174
197
|
damaged: i.damagedQuantity
|
|
175
198
|
} })).adjustInventoryStock);
|
|
176
|
-
return
|
|
177
|
-
}, [
|
|
199
|
+
return w((t) => t.map((t) => t.id === e ? a : t)), a;
|
|
200
|
+
}, [b, x]), K = n(async (e, n, r, i) => {
|
|
178
201
|
if (!Number.isInteger(i) || i <= 0) throw Error("Transfer quantity must be a positive whole number.");
|
|
179
202
|
if (e === n) throw Error("Source and destination warehouses must be different.");
|
|
180
|
-
let a =
|
|
203
|
+
let a = x.find((t) => t.warehouseId === e && t.productId === r);
|
|
181
204
|
if (!a) throw Error("Source inventory not found");
|
|
182
|
-
let o =
|
|
205
|
+
let o = x.find((e) => e.warehouseId === n && e.productId === r);
|
|
183
206
|
if (!o) throw Error("Destination inventory not found");
|
|
184
|
-
let s = await t(
|
|
207
|
+
let s = await t(b, C, { input: {
|
|
185
208
|
sourceInventoryItemId: a.id,
|
|
186
209
|
destinationInventoryItemId: o.id,
|
|
187
210
|
quantity: i
|
|
188
|
-
} }), c =
|
|
189
|
-
|
|
190
|
-
}, [
|
|
191
|
-
let n =
|
|
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: {
|
|
192
215
|
name: e.name,
|
|
193
216
|
sku: e.sku,
|
|
194
217
|
description: e.description,
|
|
@@ -202,8 +225,8 @@ function D(e = {}) {
|
|
|
202
225
|
temperatureControlled: e.temperatureControlled
|
|
203
226
|
} })).createCargoItem);
|
|
204
227
|
return M((e) => [n, ...e]), n;
|
|
205
|
-
}, [
|
|
206
|
-
let n =
|
|
228
|
+
}, [b]), J = n(async (e) => {
|
|
229
|
+
let n = D((await t(b, g, { input: {
|
|
207
230
|
code: e.code,
|
|
208
231
|
name: e.name,
|
|
209
232
|
type: e.type,
|
|
@@ -214,10 +237,10 @@ function D(e = {}) {
|
|
|
214
237
|
usedCapacity: e.usedCapacity
|
|
215
238
|
} })).createWarehouse);
|
|
216
239
|
return P((e) => [n, ...e]), n;
|
|
217
|
-
}, [
|
|
240
|
+
}, [b]);
|
|
218
241
|
return {
|
|
219
|
-
inventory:
|
|
220
|
-
lowStockItems:
|
|
242
|
+
inventory: x,
|
|
243
|
+
lowStockItems: E,
|
|
221
244
|
products: j,
|
|
222
245
|
warehouses: N,
|
|
223
246
|
totalItems: F,
|
|
@@ -229,7 +252,7 @@ function D(e = {}) {
|
|
|
229
252
|
transferStock: K,
|
|
230
253
|
createProduct: q,
|
|
231
254
|
updateProduct: n(async (e, n) => {
|
|
232
|
-
let r =
|
|
255
|
+
let r = T((await t(b, m, {
|
|
233
256
|
id: e,
|
|
234
257
|
input: {
|
|
235
258
|
name: n.name,
|
|
@@ -246,13 +269,13 @@ function D(e = {}) {
|
|
|
246
269
|
}
|
|
247
270
|
})).updateCargoItem);
|
|
248
271
|
return M((t) => t.map((t) => t.id === e ? r : t)), r;
|
|
249
|
-
}, [
|
|
272
|
+
}, [b]),
|
|
250
273
|
deleteProduct: n(async (e) => {
|
|
251
|
-
await t(
|
|
252
|
-
}, [
|
|
274
|
+
await t(b, h, { id: e }), M((t) => t.filter((t) => t.id !== e));
|
|
275
|
+
}, [b]),
|
|
253
276
|
createWarehouse: J,
|
|
254
277
|
updateWarehouse: n(async (e, n) => {
|
|
255
|
-
let r =
|
|
278
|
+
let r = D((await t(b, v, {
|
|
256
279
|
id: e,
|
|
257
280
|
input: {
|
|
258
281
|
code: n.code,
|
|
@@ -266,15 +289,15 @@ function D(e = {}) {
|
|
|
266
289
|
}
|
|
267
290
|
})).updateWarehouse);
|
|
268
291
|
return P((t) => t.map((t) => t.id === e ? r : t)), r;
|
|
269
|
-
}, [
|
|
292
|
+
}, [b]),
|
|
270
293
|
deleteWarehouse: n(async (e) => {
|
|
271
|
-
await t(
|
|
272
|
-
}, [
|
|
294
|
+
await t(b, _, { id: e }), P((t) => t.filter((t) => t.id !== e));
|
|
295
|
+
}, [b])
|
|
273
296
|
};
|
|
274
297
|
}
|
|
275
|
-
function
|
|
276
|
-
let { limit: i = 20, offset: o = 0, search: c, category: l } = e, u =
|
|
277
|
-
v(!0),
|
|
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 () => {
|
|
300
|
+
v(!0), S(null);
|
|
278
301
|
try {
|
|
279
302
|
let e = await t(u, s, {
|
|
280
303
|
filter: {
|
|
@@ -286,9 +309,9 @@ function O(e = {}) {
|
|
|
286
309
|
offset: o
|
|
287
310
|
}
|
|
288
311
|
});
|
|
289
|
-
g(o + e.cargoItems.length < e.cargoItemsCount), m(e.cargoItemsCount), f(e.cargoItems.map(
|
|
312
|
+
g(o + e.cargoItems.length < e.cargoItemsCount), m(e.cargoItemsCount), f(e.cargoItems.map(T));
|
|
290
313
|
} catch (e) {
|
|
291
|
-
|
|
314
|
+
S(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load products"));
|
|
292
315
|
} finally {
|
|
293
316
|
v(!1);
|
|
294
317
|
}
|
|
@@ -298,10 +321,10 @@ function O(e = {}) {
|
|
|
298
321
|
o,
|
|
299
322
|
c,
|
|
300
323
|
l
|
|
301
|
-
]),
|
|
324
|
+
]), w = n(async () => {
|
|
302
325
|
if (!h || _ || y) return;
|
|
303
326
|
let e = o + d.length;
|
|
304
|
-
b(!0),
|
|
327
|
+
b(!0), S(null);
|
|
305
328
|
try {
|
|
306
329
|
let n = await t(u, s, {
|
|
307
330
|
filter: {
|
|
@@ -312,13 +335,13 @@ function O(e = {}) {
|
|
|
312
335
|
limit: i,
|
|
313
336
|
offset: e
|
|
314
337
|
}
|
|
315
|
-
}), r = n.cargoItems.map(
|
|
338
|
+
}), r = n.cargoItems.map(T);
|
|
316
339
|
m(n.cargoItemsCount), g(e + r.length < n.cargoItemsCount), f((e) => {
|
|
317
340
|
let t = new Set(e.map((e) => e.id));
|
|
318
341
|
return [...e, ...r.filter((e) => !t.has(e.id))];
|
|
319
342
|
});
|
|
320
343
|
} catch (e) {
|
|
321
|
-
|
|
344
|
+
S(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load more products"));
|
|
322
345
|
} finally {
|
|
323
346
|
b(!1);
|
|
324
347
|
}
|
|
@@ -334,21 +357,21 @@ function O(e = {}) {
|
|
|
334
357
|
c
|
|
335
358
|
]);
|
|
336
359
|
return r(() => {
|
|
337
|
-
|
|
338
|
-
}, [
|
|
360
|
+
C();
|
|
361
|
+
}, [C]), {
|
|
339
362
|
products: d,
|
|
340
363
|
totalProducts: p,
|
|
341
364
|
hasMore: h,
|
|
342
365
|
isLoading: _,
|
|
343
366
|
isLoadingMore: y,
|
|
344
367
|
error: x,
|
|
345
|
-
refetch: () => void
|
|
346
|
-
loadMore:
|
|
368
|
+
refetch: () => void C(),
|
|
369
|
+
loadMore: w
|
|
347
370
|
};
|
|
348
371
|
}
|
|
349
|
-
var
|
|
350
|
-
function
|
|
351
|
-
let e =
|
|
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({
|
|
352
375
|
total: 0,
|
|
353
376
|
specialHandling: 0,
|
|
354
377
|
temperatureControlled: 0
|
|
@@ -357,7 +380,7 @@ function A() {
|
|
|
357
380
|
(async () => {
|
|
358
381
|
s(!0), l(null);
|
|
359
382
|
try {
|
|
360
|
-
i((await t(e,
|
|
383
|
+
i((await t(e, M)).cargoItemStats);
|
|
361
384
|
} catch (e) {
|
|
362
385
|
l(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load product stats"));
|
|
363
386
|
} finally {
|
|
@@ -370,8 +393,8 @@ function A() {
|
|
|
370
393
|
error: c
|
|
371
394
|
};
|
|
372
395
|
}
|
|
373
|
-
function
|
|
374
|
-
let i =
|
|
396
|
+
function P(e) {
|
|
397
|
+
let i = k(), [o, s] = a(null), [c, u] = a(!1), [d, f] = a(null), p = n(async () => {
|
|
375
398
|
if (!e) {
|
|
376
399
|
s(null);
|
|
377
400
|
return;
|
|
@@ -379,7 +402,7 @@ function j(e) {
|
|
|
379
402
|
u(!0), f(null);
|
|
380
403
|
try {
|
|
381
404
|
let n = await t(i, l, { id: e });
|
|
382
|
-
s(n.cargoItem ?
|
|
405
|
+
s(n.cargoItem ? T(n.cargoItem) : null);
|
|
383
406
|
} catch (e) {
|
|
384
407
|
f(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load product"));
|
|
385
408
|
} finally {
|
|
@@ -395,9 +418,9 @@ function j(e) {
|
|
|
395
418
|
refetch: () => void p()
|
|
396
419
|
};
|
|
397
420
|
}
|
|
398
|
-
function
|
|
399
|
-
let { limit: i = 20, offset: o = 0, search: s, status: l } = e, u =
|
|
400
|
-
v(!0),
|
|
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 () => {
|
|
423
|
+
v(!0), S(null);
|
|
401
424
|
try {
|
|
402
425
|
let e = await t(u, c, {
|
|
403
426
|
filter: {
|
|
@@ -409,9 +432,9 @@ function M(e = {}) {
|
|
|
409
432
|
offset: o
|
|
410
433
|
}
|
|
411
434
|
});
|
|
412
|
-
m(e.warehousesCount), g(o + e.warehouses.length < e.warehousesCount), f(e.warehouses.map(
|
|
435
|
+
m(e.warehousesCount), g(o + e.warehouses.length < e.warehousesCount), f(e.warehouses.map(D));
|
|
413
436
|
} catch (e) {
|
|
414
|
-
|
|
437
|
+
S(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load warehouses"));
|
|
415
438
|
} finally {
|
|
416
439
|
v(!1);
|
|
417
440
|
}
|
|
@@ -421,21 +444,57 @@ function M(e = {}) {
|
|
|
421
444
|
o,
|
|
422
445
|
s,
|
|
423
446
|
l
|
|
447
|
+
]), w = n(async () => {
|
|
448
|
+
if (!h || _ || y) return;
|
|
449
|
+
let e = o + d.length;
|
|
450
|
+
b(!0), S(null);
|
|
451
|
+
try {
|
|
452
|
+
let n = await t(u, c, {
|
|
453
|
+
filter: {
|
|
454
|
+
search: s || void 0,
|
|
455
|
+
status: l || void 0
|
|
456
|
+
},
|
|
457
|
+
pagination: {
|
|
458
|
+
limit: i,
|
|
459
|
+
offset: e
|
|
460
|
+
}
|
|
461
|
+
}), r = n.warehouses.map(D);
|
|
462
|
+
m(n.warehousesCount), g(e + r.length < n.warehousesCount), f((e) => {
|
|
463
|
+
let t = new Set(e.map((e) => e.id));
|
|
464
|
+
return [...e, ...r.filter((e) => !t.has(e.id))];
|
|
465
|
+
});
|
|
466
|
+
} catch (e) {
|
|
467
|
+
S(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load more warehouses"));
|
|
468
|
+
} finally {
|
|
469
|
+
b(!1);
|
|
470
|
+
}
|
|
471
|
+
}, [
|
|
472
|
+
u,
|
|
473
|
+
h,
|
|
474
|
+
_,
|
|
475
|
+
y,
|
|
476
|
+
i,
|
|
477
|
+
o,
|
|
478
|
+
s,
|
|
479
|
+
l,
|
|
480
|
+
d.length
|
|
424
481
|
]);
|
|
425
482
|
return r(() => {
|
|
426
|
-
|
|
427
|
-
}, [
|
|
483
|
+
C();
|
|
484
|
+
}, [C]), {
|
|
428
485
|
warehouses: d,
|
|
429
486
|
totalWarehouses: p,
|
|
430
487
|
hasMore: h,
|
|
431
488
|
isLoading: _,
|
|
432
|
-
|
|
433
|
-
|
|
489
|
+
isLoadingMore: y,
|
|
490
|
+
error: x,
|
|
491
|
+
refetch: () => void C(),
|
|
492
|
+
loadMore: w
|
|
434
493
|
};
|
|
435
494
|
}
|
|
436
|
-
var
|
|
437
|
-
function
|
|
438
|
-
let e =
|
|
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({
|
|
439
498
|
total: 0,
|
|
440
499
|
active: 0,
|
|
441
500
|
avgUtilization: 0
|
|
@@ -444,7 +503,7 @@ function P() {
|
|
|
444
503
|
(async () => {
|
|
445
504
|
s(!0), l(null);
|
|
446
505
|
try {
|
|
447
|
-
i((await t(e,
|
|
506
|
+
i((await t(e, I)).warehouseStats);
|
|
448
507
|
} catch (e) {
|
|
449
508
|
l(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load warehouse stats"));
|
|
450
509
|
} finally {
|
|
@@ -457,8 +516,8 @@ function P() {
|
|
|
457
516
|
error: c
|
|
458
517
|
};
|
|
459
518
|
}
|
|
460
|
-
function
|
|
461
|
-
let i =
|
|
519
|
+
function R(e) {
|
|
520
|
+
let i = k(), [o, s] = a(null), [c, l] = a(!1), [d, f] = a(null), p = n(async () => {
|
|
462
521
|
if (!e) {
|
|
463
522
|
s(null);
|
|
464
523
|
return;
|
|
@@ -466,7 +525,7 @@ function F(e) {
|
|
|
466
525
|
l(!0), f(null);
|
|
467
526
|
try {
|
|
468
527
|
let n = await t(i, u, { id: e });
|
|
469
|
-
s(n.warehouse ?
|
|
528
|
+
s(n.warehouse ? D(n.warehouse) : null);
|
|
470
529
|
} catch (e) {
|
|
471
530
|
f(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load warehouse"));
|
|
472
531
|
} finally {
|
|
@@ -483,8 +542,8 @@ function F(e) {
|
|
|
483
542
|
reload: p
|
|
484
543
|
};
|
|
485
544
|
}
|
|
486
|
-
function
|
|
487
|
-
let e =
|
|
545
|
+
function z() {
|
|
546
|
+
let e = k(), [i, o] = a({
|
|
488
547
|
totalOnHand: 0,
|
|
489
548
|
totalAvailable: 0,
|
|
490
549
|
totalAllocated: 0,
|
|
@@ -492,43 +551,46 @@ function I() {
|
|
|
492
551
|
lowStockCount: 0,
|
|
493
552
|
totalProducts: 0,
|
|
494
553
|
totalWarehouses: 0
|
|
495
|
-
}), [
|
|
554
|
+
}), [s, c] = a(!1), [l, u] = a(null), f = n(async () => {
|
|
555
|
+
c(!0), u(null);
|
|
556
|
+
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
|
|
566
|
+
});
|
|
567
|
+
} catch (e) {
|
|
568
|
+
u(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load inventory stats"));
|
|
569
|
+
} finally {
|
|
570
|
+
c(!1);
|
|
571
|
+
}
|
|
572
|
+
}, [e]);
|
|
496
573
|
return r(() => {
|
|
497
|
-
(
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
totalDamaged: n.inventoryStats.totalDamaged,
|
|
506
|
-
lowStockCount: n.inventoryStats.lowStockCount,
|
|
507
|
-
totalProducts: n.cargoItemsCount,
|
|
508
|
-
totalWarehouses: n.warehousesCount
|
|
509
|
-
});
|
|
510
|
-
} catch (e) {
|
|
511
|
-
l(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load inventory stats"));
|
|
512
|
-
} finally {
|
|
513
|
-
s(!1);
|
|
514
|
-
}
|
|
515
|
-
})();
|
|
516
|
-
}, [e]), {
|
|
517
|
-
stats: n,
|
|
518
|
-
isLoading: o,
|
|
519
|
-
error: c
|
|
574
|
+
f();
|
|
575
|
+
}, [f]), {
|
|
576
|
+
stats: i,
|
|
577
|
+
isLoading: s,
|
|
578
|
+
error: l,
|
|
579
|
+
refetch: n(() => {
|
|
580
|
+
f();
|
|
581
|
+
}, [f])
|
|
520
582
|
};
|
|
521
583
|
}
|
|
522
|
-
var
|
|
523
|
-
function
|
|
524
|
-
let { limit: o = 20, offset: s = 0 } = i, c =
|
|
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 () => {
|
|
525
587
|
if (!e) {
|
|
526
588
|
u([]), f(0), m(0);
|
|
527
589
|
return;
|
|
528
590
|
}
|
|
529
591
|
g(!0), v(null);
|
|
530
592
|
try {
|
|
531
|
-
let n = await t(c,
|
|
593
|
+
let n = await t(c, B, {
|
|
532
594
|
cargoItemId: e,
|
|
533
595
|
pagination: {
|
|
534
596
|
limit: o,
|
|
@@ -573,22 +635,22 @@ function R(e, i = {}) {
|
|
|
573
635
|
refetch: b
|
|
574
636
|
};
|
|
575
637
|
}
|
|
576
|
-
var
|
|
638
|
+
var H = [
|
|
577
639
|
"RECEIPT",
|
|
578
640
|
"ISSUE",
|
|
579
641
|
"TRANSFER",
|
|
580
642
|
"ADJUSTMENT",
|
|
581
643
|
"RETURN"
|
|
582
644
|
];
|
|
583
|
-
function
|
|
645
|
+
function U(e) {
|
|
584
646
|
let t = e.toUpperCase();
|
|
585
|
-
return
|
|
647
|
+
return H.find((e) => e === t) ?? "ADJUSTMENT";
|
|
586
648
|
}
|
|
587
|
-
function
|
|
649
|
+
function W(e) {
|
|
588
650
|
return {
|
|
589
651
|
id: e.id,
|
|
590
652
|
transactionNumber: e.transactionNumber,
|
|
591
|
-
type:
|
|
653
|
+
type: U(e.type),
|
|
592
654
|
quantity: e.quantity,
|
|
593
655
|
productId: e.cargoItemId,
|
|
594
656
|
warehouseId: e.warehouseId,
|
|
@@ -598,8 +660,8 @@ function V(e) {
|
|
|
598
660
|
createdAt: new Date(e.createdAt)
|
|
599
661
|
};
|
|
600
662
|
}
|
|
601
|
-
function
|
|
602
|
-
let { limit: i = 10, productId: o, warehouseId: s } = e, c =
|
|
663
|
+
function G(e = {}) {
|
|
664
|
+
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 () => {
|
|
603
665
|
p(!0), h(null);
|
|
604
666
|
try {
|
|
605
667
|
u((await t(c, f, {
|
|
@@ -611,7 +673,7 @@ function H(e = {}) {
|
|
|
611
673
|
limit: i,
|
|
612
674
|
offset: 0
|
|
613
675
|
}
|
|
614
|
-
})).inventoryTransactions.map(
|
|
676
|
+
})).inventoryTransactions.map(W));
|
|
615
677
|
} catch (e) {
|
|
616
678
|
h(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load inventory transactions"));
|
|
617
679
|
} finally {
|
|
@@ -634,5 +696,78 @@ function H(e = {}) {
|
|
|
634
696
|
}, [g])
|
|
635
697
|
};
|
|
636
698
|
}
|
|
699
|
+
function K(e, t) {
|
|
700
|
+
if (!Number.isInteger(e) || e <= 0) throw Error(`${t} must be a positive whole number.`);
|
|
701
|
+
}
|
|
702
|
+
function q() {
|
|
703
|
+
let e = k(), r = n(async (n) => {
|
|
704
|
+
let r = (await t(e, b, {
|
|
705
|
+
filter: n,
|
|
706
|
+
pagination: { limit: 1 }
|
|
707
|
+
})).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.`);
|
|
712
|
+
if (i < 0) throw Error("On-hand stock cannot go below zero.");
|
|
713
|
+
return O((await t(e, S, { input: {
|
|
714
|
+
id: n.id,
|
|
715
|
+
onHand: i,
|
|
716
|
+
available: a,
|
|
717
|
+
allocated: n.reservedQuantity,
|
|
718
|
+
damaged: n.damagedQuantity
|
|
719
|
+
} })).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]);
|
|
726
|
+
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
|
|
732
|
+
});
|
|
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 } : {}
|
|
739
|
+
} })).createInventoryItem);
|
|
740
|
+
}, [
|
|
741
|
+
i,
|
|
742
|
+
r,
|
|
743
|
+
e
|
|
744
|
+
]),
|
|
745
|
+
adjustStock: a,
|
|
746
|
+
transferStock: n(async (n) => {
|
|
747
|
+
K(n.quantity, "Transfer quantity");
|
|
748
|
+
let i = await r({ inventoryItemId: n.sourceInventoryId });
|
|
749
|
+
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({
|
|
753
|
+
cargoItemId: i.productId,
|
|
754
|
+
warehouseId: n.destinationWarehouseId
|
|
755
|
+
});
|
|
756
|
+
a ||= O((await t(e, x, { input: {
|
|
757
|
+
cargoItemId: i.productId,
|
|
758
|
+
warehouseId: n.destinationWarehouseId
|
|
759
|
+
} })).createInventoryItem);
|
|
760
|
+
let o = await t(e, C, { input: {
|
|
761
|
+
sourceInventoryItemId: i.id,
|
|
762
|
+
destinationInventoryItemId: a.id,
|
|
763
|
+
quantity: n.quantity
|
|
764
|
+
} });
|
|
765
|
+
return {
|
|
766
|
+
source: O(o.transferInventoryStock.source),
|
|
767
|
+
destination: O(o.transferInventoryStock.destination)
|
|
768
|
+
};
|
|
769
|
+
}, [r, e])
|
|
770
|
+
};
|
|
771
|
+
}
|
|
637
772
|
//#endregion
|
|
638
|
-
export {
|
|
773
|
+
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 };
|