@burdenoff/microfe-movethewheels 2026.1114.1 → 2026.1123.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.
- package/dist/MoveTheWheelsRoot.js +149 -133
- package/dist/MoveTheWheelsRoutes.js +157 -139
- package/dist/components/EntityConversationsCard.js +145 -0
- package/dist/components/maps/MapCanvas.js +4 -3
- package/dist/events/rybbit.js +87 -0
- package/dist/generated/tracking-quality-operations.d.ts +342 -0
- package/dist/hooks/useEntityComments.js +111 -0
- package/dist/hooks/useFleet.js +394 -311
- package/dist/hooks/useInventory.js +378 -313
- package/dist/hooks/useMultiModalShipments.js +58 -53
- package/dist/hooks/useOrders.js +178 -158
- package/dist/hooks/useRoutes.js +146 -130
- package/dist/index.js +35 -34
- package/dist/movethewheels/components/EntityConversationsCard.d.ts +8 -0
- package/dist/movethewheels/events/rybbit.d.ts +27 -0
- package/dist/movethewheels/hooks/useEntityComments.d.ts +26 -0
- package/dist/movethewheels/hooks/useFleet.d.ts +73 -1
- package/dist/movethewheels/hooks/useInventory.d.ts +19 -0
- package/dist/movethewheels/index.d.ts +1 -0
- package/dist/movethewheels/pages/DocumentsLibraryPage.d.ts +1 -0
- package/dist/movethewheels/pages/NotificationsCenterPage.d.ts +1 -0
- package/dist/movethewheels/types/index.d.ts +95 -2
- package/dist/node_modules/lucide-react/dist/esm/icons/check-check.js +10 -0
- package/dist/node_modules/lucide-react/dist/esm/icons/layers.js +17 -0
- package/dist/node_modules/lucide-react/dist/esm/icons/message-square.js +7 -0
- package/dist/node_modules/lucide-react/dist/esm/icons/send.js +10 -0
- package/dist/pages/DocumentsLibraryPage.js +235 -0
- package/dist/pages/DriverDetailsPage.js +625 -351
- package/dist/pages/NotificationsCenterPage.js +310 -0
- package/dist/pages/OrderDetailsPage.js +48 -42
- package/dist/pages/RouteDetailsPage.js +257 -251
- package/dist/pages/TrackingPage.js +202 -196
- package/dist/pages/VehicleDetailsPage.js +616 -314
- package/dist/pages/WarehouseDetailsPage.js +539 -253
- package/dist/stories/ControlTowerWidgets.stories.d.ts +10 -0
- package/dist/stories/DataTable.stories.d.ts +15 -0
- package/dist/stories/FleetCards.stories.d.ts +9 -0
- package/dist/stories/OrderForms.stories.d.ts +8 -0
- package/dist/stories/RouteMap.stories.d.ts +7 -0
- package/dist/stories/ShipmentTimeline.stories.d.ts +6 -0
- package/package.json +3 -2
- package/src/generated/tracking-quality-operations.ts +407 -0
- package/src/movethewheels/MoveTheWheelsRoot.tsx +16 -0
- package/src/movethewheels/MoveTheWheelsRoutes.tsx +17 -2
- package/src/movethewheels/components/EntityConversationsCard.tsx +143 -0
- package/src/movethewheels/components/maps/MapCanvas.tsx +3 -3
- package/src/movethewheels/events/__tests__/rybbit.test.ts +98 -0
- package/src/movethewheels/events/rybbit.ts +191 -0
- package/src/movethewheels/hooks/useEntityComments.ts +258 -0
- package/src/movethewheels/hooks/useFleet.ts +300 -5
- package/src/movethewheels/hooks/useInventory.ts +231 -3
- package/src/movethewheels/hooks/useMultiModalShipments.ts +8 -1
- package/src/movethewheels/hooks/useOrders.ts +19 -3
- package/src/movethewheels/hooks/useRoutes.ts +14 -2
- package/src/movethewheels/index.ts +1 -0
- package/src/movethewheels/pages/DocumentsLibraryPage.tsx +229 -0
- package/src/movethewheels/pages/DriverDetailsPage.tsx +250 -1
- package/src/movethewheels/pages/NotificationsCenterPage.tsx +331 -0
- package/src/movethewheels/pages/OrderDetailsPage.tsx +8 -0
- package/src/movethewheels/pages/RouteDetailsPage.tsx +6 -0
- package/src/movethewheels/pages/TrackingPage.tsx +8 -0
- package/src/movethewheels/pages/VehicleDetailsPage.tsx +255 -1
- package/src/movethewheels/pages/WarehouseDetailsPage.tsx +266 -2
- package/src/movethewheels/types/index.ts +103 -2
- package/src/stories/ControlTowerWidgets.stories.tsx +150 -0
- package/src/stories/DataTable.stories.tsx +94 -0
- package/src/stories/FleetCards.stories.tsx +77 -0
- package/src/stories/OrderForms.stories.tsx +84 -0
- package/src/stories/RouteMap.stories.tsx +43 -0
- package/src/stories/ShipmentTimeline.stories.tsx +128 -0
|
@@ -1,32 +1,34 @@
|
|
|
1
1
|
import { useMoveTheWheels as e } from "../providers/MoveTheWheelsProvider.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
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
|
|
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
|
-
${
|
|
10
|
+
${T}
|
|
9
11
|
}
|
|
10
12
|
}
|
|
11
|
-
`,
|
|
13
|
+
`, D = `
|
|
12
14
|
mutation CreateInventoryItem($input: CreateInventoryItemInput!) {
|
|
13
15
|
createInventoryItem(input: $input) {
|
|
14
|
-
${
|
|
16
|
+
${T}
|
|
15
17
|
}
|
|
16
18
|
}
|
|
17
|
-
`,
|
|
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
|
-
${
|
|
23
|
+
${T}
|
|
22
24
|
}
|
|
23
25
|
destination {
|
|
24
|
-
${
|
|
26
|
+
${T}
|
|
25
27
|
}
|
|
26
28
|
}
|
|
27
29
|
}
|
|
28
30
|
`;
|
|
29
|
-
function
|
|
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
|
|
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:
|
|
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
|
|
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
|
|
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:
|
|
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
|
|
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
|
|
112
|
-
let { apiGatewayUrl: t, authToken: n, workspaceToken: r, workspaceId:
|
|
113
|
-
return
|
|
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:
|
|
152
|
+
workspaceId: i,
|
|
118
153
|
tenantId: o,
|
|
119
154
|
actorId: s?.id
|
|
120
155
|
}), [
|
|
121
156
|
t,
|
|
122
157
|
n,
|
|
123
158
|
r,
|
|
124
|
-
|
|
159
|
+
i,
|
|
125
160
|
o,
|
|
126
161
|
s?.id
|
|
127
162
|
]);
|
|
128
163
|
}
|
|
129
|
-
function
|
|
130
|
-
let { filters:
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
]),
|
|
136
|
-
|
|
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:
|
|
140
|
-
cargoItemId:
|
|
141
|
-
search:
|
|
142
|
-
lowStock:
|
|
143
|
-
}, [
|
|
144
|
-
|
|
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:
|
|
148
|
-
offset:
|
|
182
|
+
limit: p,
|
|
183
|
+
offset: m
|
|
149
184
|
}
|
|
150
185
|
}),
|
|
151
|
-
|
|
186
|
+
n(g, c, {
|
|
152
187
|
filter: {
|
|
153
|
-
warehouseId:
|
|
154
|
-
cargoItemId:
|
|
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
|
-
|
|
197
|
+
n(g, l, { pagination: {
|
|
163
198
|
limit: 5,
|
|
164
199
|
offset: 0
|
|
165
200
|
} }),
|
|
166
|
-
|
|
201
|
+
n(g, u, { pagination: {
|
|
167
202
|
limit: 5,
|
|
168
203
|
offset: 0
|
|
169
204
|
} })
|
|
170
205
|
]);
|
|
171
|
-
|
|
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
|
-
|
|
208
|
+
G(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load inventory data"));
|
|
174
209
|
} finally {
|
|
175
|
-
|
|
210
|
+
U(!1);
|
|
176
211
|
}
|
|
177
212
|
}, [
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
213
|
+
h,
|
|
214
|
+
g,
|
|
215
|
+
p,
|
|
216
|
+
m,
|
|
217
|
+
f
|
|
183
218
|
]);
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
}, [
|
|
187
|
-
let
|
|
188
|
-
|
|
189
|
-
}, [
|
|
190
|
-
let
|
|
191
|
-
if (!
|
|
192
|
-
let
|
|
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:
|
|
195
|
-
available:
|
|
196
|
-
allocated:
|
|
197
|
-
damaged:
|
|
229
|
+
onHand: a.quantity + r,
|
|
230
|
+
available: a.availableQuantity + r,
|
|
231
|
+
allocated: a.reservedQuantity,
|
|
232
|
+
damaged: a.damagedQuantity
|
|
198
233
|
} })).adjustInventoryStock);
|
|
199
|
-
return
|
|
200
|
-
}, [
|
|
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 ===
|
|
203
|
-
let a =
|
|
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 =
|
|
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
|
|
246
|
+
let s = await n(g, k, { input: {
|
|
208
247
|
sourceInventoryItemId: a.id,
|
|
209
248
|
destinationInventoryItemId: o.id,
|
|
210
249
|
quantity: i
|
|
211
|
-
} }), c =
|
|
212
|
-
|
|
213
|
-
}, [
|
|
214
|
-
let
|
|
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) => [
|
|
228
|
-
}, [
|
|
229
|
-
let
|
|
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
|
|
240
|
-
}, [
|
|
278
|
+
return L((e) => [t, ...e]), t;
|
|
279
|
+
}, [g]);
|
|
241
280
|
return {
|
|
242
|
-
inventory:
|
|
281
|
+
inventory: v,
|
|
243
282
|
lowStockItems: E,
|
|
244
|
-
products:
|
|
245
|
-
warehouses:
|
|
246
|
-
totalItems:
|
|
247
|
-
hasMore:
|
|
248
|
-
isLoading:
|
|
249
|
-
error:
|
|
250
|
-
refetch:
|
|
251
|
-
updateStock:
|
|
252
|
-
transferStock:
|
|
253
|
-
createProduct:
|
|
254
|
-
updateProduct:
|
|
255
|
-
let r =
|
|
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:
|
|
259
|
-
sku:
|
|
260
|
-
description:
|
|
261
|
-
category:
|
|
262
|
-
brand:
|
|
263
|
-
dimensions:
|
|
264
|
-
weight:
|
|
265
|
-
value:
|
|
266
|
-
hazardous:
|
|
267
|
-
fragile:
|
|
268
|
-
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
|
-
}, [
|
|
273
|
-
deleteProduct:
|
|
274
|
-
await
|
|
275
|
-
}, [
|
|
276
|
-
createWarehouse:
|
|
277
|
-
updateWarehouse:
|
|
278
|
-
let r =
|
|
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:
|
|
282
|
-
name:
|
|
283
|
-
type:
|
|
284
|
-
address:
|
|
285
|
-
status:
|
|
286
|
-
contactInfo:
|
|
287
|
-
totalCapacity:
|
|
288
|
-
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
|
|
292
|
-
}, [
|
|
293
|
-
deleteWarehouse:
|
|
294
|
-
await
|
|
295
|
-
}, [
|
|
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
|
|
299
|
-
let { limit:
|
|
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
|
|
341
|
+
let e = await n(u, l, {
|
|
303
342
|
filter: {
|
|
304
|
-
search:
|
|
305
|
-
category:
|
|
343
|
+
search: s || void 0,
|
|
344
|
+
category: c || void 0
|
|
306
345
|
},
|
|
307
346
|
pagination: {
|
|
308
|
-
limit:
|
|
309
|
-
offset:
|
|
347
|
+
limit: t,
|
|
348
|
+
offset: a
|
|
310
349
|
}
|
|
311
350
|
});
|
|
312
|
-
g(
|
|
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
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
]), w =
|
|
359
|
+
t,
|
|
360
|
+
a,
|
|
361
|
+
s,
|
|
362
|
+
c
|
|
363
|
+
]), w = r(async () => {
|
|
325
364
|
if (!h || _ || y) return;
|
|
326
|
-
let e =
|
|
365
|
+
let e = a + d.length;
|
|
327
366
|
b(!0), S(null);
|
|
328
367
|
try {
|
|
329
|
-
let
|
|
368
|
+
let r = await n(u, l, {
|
|
330
369
|
filter: {
|
|
331
|
-
search:
|
|
332
|
-
category:
|
|
370
|
+
search: s || void 0,
|
|
371
|
+
category: c || void 0
|
|
333
372
|
},
|
|
334
373
|
pagination: {
|
|
335
|
-
limit:
|
|
374
|
+
limit: t,
|
|
336
375
|
offset: e
|
|
337
376
|
}
|
|
338
|
-
}),
|
|
339
|
-
m(
|
|
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, ...
|
|
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
|
-
|
|
388
|
+
c,
|
|
350
389
|
u,
|
|
351
390
|
h,
|
|
352
391
|
_,
|
|
353
392
|
y,
|
|
354
|
-
|
|
355
|
-
|
|
393
|
+
t,
|
|
394
|
+
a,
|
|
356
395
|
d.length,
|
|
357
|
-
|
|
396
|
+
s
|
|
358
397
|
]);
|
|
359
|
-
return
|
|
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
|
|
373
|
-
function
|
|
374
|
-
let e =
|
|
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
|
-
}), [
|
|
379
|
-
return
|
|
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
|
|
384
|
-
|
|
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:
|
|
393
|
-
isLoading:
|
|
431
|
+
stats: t,
|
|
432
|
+
isLoading: a,
|
|
394
433
|
error: c
|
|
395
434
|
};
|
|
396
435
|
}
|
|
397
|
-
function
|
|
398
|
-
let
|
|
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
|
-
|
|
440
|
+
l(!0), f(null);
|
|
402
441
|
try {
|
|
403
|
-
let
|
|
404
|
-
s(
|
|
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
|
-
|
|
447
|
+
l(!1);
|
|
409
448
|
}
|
|
410
449
|
}
|
|
411
|
-
}, [
|
|
412
|
-
return
|
|
450
|
+
}, [t, e]);
|
|
451
|
+
return i(() => {
|
|
413
452
|
p();
|
|
414
453
|
}, [p]), {
|
|
415
|
-
product:
|
|
454
|
+
product: a,
|
|
416
455
|
isLoading: c,
|
|
417
|
-
error:
|
|
456
|
+
error: u,
|
|
418
457
|
refetch: () => void p()
|
|
419
458
|
};
|
|
420
459
|
}
|
|
421
|
-
function
|
|
422
|
-
let { limit:
|
|
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
|
|
464
|
+
let e = await n(l, u, {
|
|
426
465
|
filter: {
|
|
427
466
|
search: s || void 0,
|
|
428
|
-
status:
|
|
467
|
+
status: c || void 0
|
|
429
468
|
},
|
|
430
469
|
pagination: {
|
|
431
|
-
limit:
|
|
432
|
-
offset:
|
|
470
|
+
limit: t,
|
|
471
|
+
offset: a
|
|
433
472
|
}
|
|
434
473
|
});
|
|
435
|
-
m(e.warehousesCount), g(
|
|
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
|
-
|
|
443
|
-
|
|
444
|
-
|
|
481
|
+
l,
|
|
482
|
+
t,
|
|
483
|
+
a,
|
|
445
484
|
s,
|
|
446
|
-
|
|
447
|
-
]), w =
|
|
485
|
+
c
|
|
486
|
+
]), w = r(async () => {
|
|
448
487
|
if (!h || _ || y) return;
|
|
449
|
-
let e =
|
|
488
|
+
let e = a + d.length;
|
|
450
489
|
b(!0), S(null);
|
|
451
490
|
try {
|
|
452
|
-
let
|
|
491
|
+
let r = await n(l, u, {
|
|
453
492
|
filter: {
|
|
454
493
|
search: s || void 0,
|
|
455
|
-
status:
|
|
494
|
+
status: c || void 0
|
|
456
495
|
},
|
|
457
496
|
pagination: {
|
|
458
|
-
limit:
|
|
497
|
+
limit: t,
|
|
459
498
|
offset: e
|
|
460
499
|
}
|
|
461
|
-
}),
|
|
462
|
-
m(
|
|
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, ...
|
|
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
|
-
|
|
511
|
+
l,
|
|
473
512
|
h,
|
|
474
513
|
_,
|
|
475
514
|
y,
|
|
476
|
-
|
|
477
|
-
|
|
515
|
+
t,
|
|
516
|
+
a,
|
|
478
517
|
s,
|
|
479
|
-
|
|
518
|
+
c,
|
|
480
519
|
d.length
|
|
481
520
|
]);
|
|
482
|
-
return
|
|
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
|
|
496
|
-
function
|
|
497
|
-
let e =
|
|
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
|
-
}), [
|
|
502
|
-
return
|
|
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
|
|
507
|
-
|
|
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:
|
|
516
|
-
isLoading:
|
|
554
|
+
stats: t,
|
|
555
|
+
isLoading: a,
|
|
517
556
|
error: c
|
|
518
557
|
};
|
|
519
558
|
}
|
|
520
|
-
function
|
|
521
|
-
let
|
|
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),
|
|
563
|
+
l(!0), d(null);
|
|
525
564
|
try {
|
|
526
|
-
let
|
|
527
|
-
s(
|
|
565
|
+
let r = await n(t, f, { id: e });
|
|
566
|
+
s(r.warehouse ? N(r.warehouse) : null);
|
|
528
567
|
} catch (e) {
|
|
529
|
-
|
|
568
|
+
d(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load warehouse"));
|
|
530
569
|
} finally {
|
|
531
570
|
l(!1);
|
|
532
571
|
}
|
|
533
572
|
}
|
|
534
|
-
}, [
|
|
535
|
-
return
|
|
536
|
-
|
|
537
|
-
}, [
|
|
538
|
-
warehouse:
|
|
573
|
+
}, [t, e]);
|
|
574
|
+
return i(() => {
|
|
575
|
+
_();
|
|
576
|
+
}, [_]), {
|
|
577
|
+
warehouse: a,
|
|
539
578
|
isLoading: c,
|
|
540
|
-
error:
|
|
541
|
-
refetch: () => void
|
|
542
|
-
reload:
|
|
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
|
|
546
|
-
let e =
|
|
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] =
|
|
619
|
+
}), [s, c] = o(!1), [l, u] = o(null), d = r(async () => {
|
|
555
620
|
c(!0), u(null);
|
|
556
621
|
try {
|
|
557
|
-
let
|
|
558
|
-
|
|
559
|
-
totalOnHand:
|
|
560
|
-
totalAvailable:
|
|
561
|
-
totalAllocated:
|
|
562
|
-
totalDamaged:
|
|
563
|
-
lowStockCount:
|
|
564
|
-
totalProducts:
|
|
565
|
-
totalWarehouses:
|
|
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
|
|
574
|
-
|
|
575
|
-
}, [
|
|
576
|
-
stats:
|
|
638
|
+
return i(() => {
|
|
639
|
+
d();
|
|
640
|
+
}, [d]), {
|
|
641
|
+
stats: t,
|
|
577
642
|
isLoading: s,
|
|
578
643
|
error: l,
|
|
579
|
-
refetch:
|
|
580
|
-
|
|
581
|
-
}, [
|
|
644
|
+
refetch: r(() => {
|
|
645
|
+
d();
|
|
646
|
+
}, [d])
|
|
582
647
|
};
|
|
583
648
|
}
|
|
584
|
-
var
|
|
585
|
-
function
|
|
586
|
-
let { limit:
|
|
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
|
|
656
|
+
let t = await n(c, K, {
|
|
592
657
|
cargoItemId: e,
|
|
593
658
|
pagination: {
|
|
594
|
-
limit:
|
|
659
|
+
limit: a,
|
|
595
660
|
offset: s
|
|
596
661
|
}
|
|
597
662
|
});
|
|
598
|
-
u((
|
|
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(
|
|
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
|
-
|
|
682
|
+
a,
|
|
618
683
|
s,
|
|
619
684
|
e
|
|
620
685
|
]);
|
|
621
|
-
|
|
686
|
+
i(() => {
|
|
622
687
|
y();
|
|
623
688
|
}, [y]);
|
|
624
|
-
let b =
|
|
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
|
|
702
|
+
var J = [
|
|
638
703
|
"RECEIPT",
|
|
639
704
|
"ISSUE",
|
|
640
705
|
"TRANSFER",
|
|
641
706
|
"ADJUSTMENT",
|
|
642
707
|
"RETURN"
|
|
643
708
|
];
|
|
644
|
-
function
|
|
709
|
+
function Y(e) {
|
|
645
710
|
let t = e.toUpperCase();
|
|
646
|
-
return
|
|
711
|
+
return J.find((e) => e === t) ?? "ADJUSTMENT";
|
|
647
712
|
}
|
|
648
|
-
function
|
|
713
|
+
function X(e) {
|
|
649
714
|
return {
|
|
650
715
|
id: e.id,
|
|
651
716
|
transactionNumber: e.transactionNumber,
|
|
652
|
-
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
|
|
663
|
-
let { limit:
|
|
664
|
-
|
|
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
|
|
667
|
-
filter:
|
|
668
|
-
cargoItemId:
|
|
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:
|
|
737
|
+
limit: t,
|
|
673
738
|
offset: 0
|
|
674
739
|
}
|
|
675
740
|
});
|
|
676
|
-
u(e.inventoryTransactions.map(
|
|
741
|
+
u(e.inventoryTransactions.map(X));
|
|
677
742
|
} catch (e) {
|
|
678
|
-
|
|
743
|
+
m(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load inventory transactions"));
|
|
679
744
|
} finally {
|
|
680
|
-
|
|
745
|
+
f(!1);
|
|
681
746
|
}
|
|
682
747
|
}, [
|
|
683
748
|
c,
|
|
684
|
-
|
|
685
|
-
|
|
749
|
+
t,
|
|
750
|
+
a,
|
|
686
751
|
s
|
|
687
752
|
]);
|
|
688
|
-
return
|
|
689
|
-
|
|
690
|
-
}, [
|
|
753
|
+
return i(() => {
|
|
754
|
+
h();
|
|
755
|
+
}, [h]), {
|
|
691
756
|
transactions: l,
|
|
692
757
|
isLoading: d,
|
|
693
|
-
error:
|
|
694
|
-
refetch:
|
|
695
|
-
|
|
696
|
-
}, [
|
|
758
|
+
error: p,
|
|
759
|
+
refetch: r(() => {
|
|
760
|
+
h();
|
|
761
|
+
}, [h])
|
|
697
762
|
};
|
|
698
763
|
}
|
|
699
|
-
function
|
|
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
|
|
703
|
-
let e =
|
|
704
|
-
let r = (await
|
|
705
|
-
filter:
|
|
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 ?
|
|
709
|
-
}, [e]), i =
|
|
710
|
-
let i =
|
|
711
|
-
if (a < 0) throw Error(`Only ${
|
|
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
|
|
714
|
-
id:
|
|
778
|
+
return P((await n(e, O, { input: {
|
|
779
|
+
id: t.id,
|
|
715
780
|
onHand: i,
|
|
716
781
|
available: a,
|
|
717
|
-
allocated:
|
|
718
|
-
damaged:
|
|
782
|
+
allocated: t.reservedQuantity,
|
|
783
|
+
damaged: t.damagedQuantity
|
|
719
784
|
} })).adjustInventoryStock);
|
|
720
|
-
}, [e]), a =
|
|
721
|
-
if (!Number.isInteger(
|
|
722
|
-
let
|
|
723
|
-
if (!
|
|
724
|
-
return i(
|
|
725
|
-
}, [i,
|
|
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:
|
|
728
|
-
|
|
729
|
-
let a = await
|
|
730
|
-
cargoItemId:
|
|
731
|
-
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,
|
|
734
|
-
cargoItemId:
|
|
735
|
-
warehouseId:
|
|
736
|
-
onHand:
|
|
737
|
-
available:
|
|
738
|
-
...
|
|
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
|
-
|
|
807
|
+
t,
|
|
743
808
|
e
|
|
744
809
|
]),
|
|
745
810
|
adjustStock: a,
|
|
746
|
-
transferStock:
|
|
747
|
-
|
|
748
|
-
let i = await
|
|
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 ===
|
|
751
|
-
if (
|
|
752
|
-
let a = await
|
|
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:
|
|
819
|
+
warehouseId: r.destinationWarehouseId
|
|
755
820
|
});
|
|
756
|
-
a ||=
|
|
821
|
+
a ||= P((await n(e, D, { input: {
|
|
757
822
|
cargoItemId: i.productId,
|
|
758
|
-
warehouseId:
|
|
823
|
+
warehouseId: r.destinationWarehouseId
|
|
759
824
|
} })).createInventoryItem);
|
|
760
|
-
let o = await
|
|
825
|
+
let o = await n(e, k, { input: {
|
|
761
826
|
sourceInventoryItemId: i.id,
|
|
762
827
|
destinationInventoryItemId: a.id,
|
|
763
|
-
quantity:
|
|
828
|
+
quantity: r.quantity
|
|
764
829
|
} });
|
|
765
830
|
return {
|
|
766
|
-
source:
|
|
767
|
-
destination:
|
|
831
|
+
source: P(o.transferInventoryStock.source),
|
|
832
|
+
destination: P(o.transferInventoryStock.destination)
|
|
768
833
|
};
|
|
769
|
-
}, [
|
|
834
|
+
}, [t, e])
|
|
770
835
|
};
|
|
771
836
|
}
|
|
772
|
-
export {
|
|
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 };
|