@burdenoff/microfe-movethewheels 2026.925.2 → 2026.925.3
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/StatusBadge.js +30 -30
- package/dist/constants/index.js +12 -5
- package/dist/hooks/useCustomers.js +0 -3
- package/dist/hooks/useFleet.js +144 -131
- package/dist/hooks/useInventory.js +144 -145
- package/dist/hooks/useRoutes.js +5 -14
- package/dist/movethewheels/constants/index.d.ts +1 -0
- package/dist/movethewheels/hooks/useFleet.d.ts +13 -1
- package/dist/movethewheels/hooks/useInventory.d.ts +10 -0
- package/dist/movethewheels/types/index.d.ts +13 -70
- package/dist/pages/CustomerDetailsPage.js +666 -344
- package/dist/pages/CustomersPage.js +71 -80
- package/dist/pages/FleetPage.js +1 -3
- package/dist/pages/InventoryPage.js +4 -4
- package/dist/pages/RouteDetailsPage.js +273 -248
- package/dist/pages/RoutesPage.js +130 -67
- package/dist/pages/VehicleDetailsPage.js +506 -391
- package/dist/pages/VehiclesPage.js +119 -70
- package/dist/pages/WarehouseDetailsPage.js +410 -370
- package/dist/pages/WarehousesPage.js +131 -82
- package/package.json +1 -1
- package/src/movethewheels/components/StatusBadge.tsx +8 -3
- package/src/movethewheels/constants/index.ts +9 -0
- package/src/movethewheels/hooks/useCustomers.ts +0 -3
- package/src/movethewheels/hooks/useFleet.ts +74 -19
- package/src/movethewheels/hooks/useInventory.ts +76 -32
- package/src/movethewheels/hooks/useRoutes.ts +17 -12
- package/src/movethewheels/pages/CustomerDetailsPage.tsx +376 -109
- package/src/movethewheels/pages/CustomersPage.tsx +6 -15
- package/src/movethewheels/pages/FleetPage.tsx +2 -1
- package/src/movethewheels/pages/InventoryPage.tsx +14 -5
- package/src/movethewheels/pages/RouteDetailsPage.tsx +74 -34
- package/src/movethewheels/pages/RoutesPage.tsx +66 -2
- package/src/movethewheels/pages/VehicleDetailsPage.tsx +151 -11
- package/src/movethewheels/pages/VehiclesPage.tsx +68 -3
- package/src/movethewheels/pages/WarehouseDetailsPage.tsx +213 -135
- package/src/movethewheels/pages/WarehousesPage.tsx +77 -16
- package/src/movethewheels/types/index.ts +14 -70
package/dist/hooks/useFleet.js
CHANGED
|
@@ -2,24 +2,26 @@ 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/useFleet.ts
|
|
5
|
-
var o = "\n query ListVehicles($filter: VehicleFilterInput, $pagination: PaginationInput) {\n vehicles(filter: $filter, pagination: $pagination) {\n id\n vehicleNumber\n type\n make\n model\n licensePlate\n ownershipType\n year\n capacity\n status\n currentLocation\n fuelType\n fuelEfficiencyLPer100Km\n fuelLevel\n mileage\n lastServiceDate\n nextServiceDueDate\n nextServiceDueMileage\n createdAt\n updatedAt\n }\n vehiclesCount(filter: $filter)\n }\n", s = "\n query ListDrivers($filter: DriverFilterInput, $pagination: PaginationInput) {\n drivers(filter: $filter, pagination: $pagination) {\n id\n userId\n firstName\n lastName\n email\n phone\n employeeId\n licenseNumber\n licenseClass\n licenseExpiry\n status\n currentLocation\n rating\n vehicleId\n notes\n hireDate\n baseSalary\n bonusYtd\n payCurrency\n onLeaveUntil\n terminatedAt\n terminationReason\n createdAt\n }\n driversCount(filter: $filter)\n }\n", c = "\n query GetVehicle($id: ID!) {\n vehicle(id: $id) {\n id\n vehicleNumber\n type\n make\n model\n licensePlate\n ownershipType\n year\n capacity\n status\n currentLocation\n fuelType\n fuelEfficiencyLPer100Km\n fuelLevel\n mileage\n lastServiceDate\n nextServiceDueDate\n nextServiceDueMileage\n createdAt\n updatedAt\n }\n }\n", l = "\n query GetDriver($id: ID!) {\n driver(id: $id) {\n id\n userId\n firstName\n lastName\n email\n phone\n employeeId\n licenseNumber\n licenseClass\n licenseExpiry\n status\n currentLocation\n rating\n vehicleId\n notes\n hireDate\n baseSalary\n bonusYtd\n payCurrency\n onLeaveUntil\n terminatedAt\n terminationReason\n createdAt\n }\n }\n", u = "\n mutation UpdateVehicleStatus($id: ID!, $status: VehicleStatus!) {\n updateVehicleStatus(id: $id, status: $status) {\n id\n vehicleNumber\n type\n make\n model\n licensePlate\n ownershipType\n year\n capacity\n status\n currentLocation\n fuelType\n fuelEfficiencyLPer100Km\n fuelLevel\n mileage\n createdAt\n updatedAt\n }\n }\n",
|
|
6
|
-
function
|
|
5
|
+
var o = "\n query ListVehicles($filter: VehicleFilterInput, $pagination: PaginationInput) {\n vehicles(filter: $filter, pagination: $pagination) {\n id\n vehicleNumber\n type\n make\n model\n licensePlate\n ownershipType\n year\n capacity\n status\n currentLocation\n fuelType\n fuelEfficiencyLPer100Km\n fuelLevel\n mileage\n lastServiceDate\n nextServiceDueDate\n nextServiceDueMileage\n createdAt\n updatedAt\n }\n vehiclesCount(filter: $filter)\n }\n", s = "\n query ListDrivers($filter: DriverFilterInput, $pagination: PaginationInput) {\n drivers(filter: $filter, pagination: $pagination) {\n id\n userId\n firstName\n lastName\n email\n phone\n employeeId\n licenseNumber\n licenseClass\n licenseExpiry\n status\n currentLocation\n rating\n vehicleId\n notes\n hireDate\n baseSalary\n bonusYtd\n payCurrency\n onLeaveUntil\n terminatedAt\n terminationReason\n createdAt\n }\n driversCount(filter: $filter)\n }\n", c = "\n query GetVehicle($id: ID!) {\n vehicle(id: $id) {\n id\n vehicleNumber\n type\n make\n model\n licensePlate\n ownershipType\n year\n capacity\n status\n currentLocation\n fuelType\n fuelEfficiencyLPer100Km\n fuelLevel\n mileage\n lastServiceDate\n nextServiceDueDate\n nextServiceDueMileage\n createdAt\n updatedAt\n }\n }\n", l = "\n query GetDriver($id: ID!) {\n driver(id: $id) {\n id\n userId\n firstName\n lastName\n email\n phone\n employeeId\n licenseNumber\n licenseClass\n licenseExpiry\n status\n currentLocation\n rating\n vehicleId\n notes\n hireDate\n baseSalary\n bonusYtd\n payCurrency\n onLeaveUntil\n terminatedAt\n terminationReason\n createdAt\n }\n }\n", u = "\n mutation DeleteVehicle($id: ID!) {\n deleteVehicle(id: $id)\n }\n", d = "\n mutation UpdateVehicleStatus($id: ID!, $status: VehicleStatus!) {\n updateVehicleStatus(id: $id, status: $status) {\n id\n vehicleNumber\n type\n make\n model\n licensePlate\n ownershipType\n year\n capacity\n status\n currentLocation\n fuelType\n fuelEfficiencyLPer100Km\n fuelLevel\n mileage\n createdAt\n updatedAt\n }\n }\n", f = "\n mutation AssignDriverVehicle($id: ID!, $vehicleId: ID) {\n assignDriverVehicle(id: $id, vehicleId: $vehicleId) {\n id\n userId\n firstName\n lastName\n email\n phone\n employeeId\n licenseNumber\n licenseClass\n licenseExpiry\n status\n currentLocation\n rating\n vehicleId\n notes\n hireDate\n baseSalary\n bonusYtd\n payCurrency\n onLeaveUntil\n terminatedAt\n terminationReason\n createdAt\n }\n }\n", p = "\n mutation UpdateDriverStatus($id: ID!, $status: DriverStatus!) {\n updateDriverStatus(id: $id, status: $status) {\n id\n userId\n firstName\n lastName\n email\n phone\n employeeId\n licenseNumber\n licenseClass\n licenseExpiry\n status\n currentLocation\n rating\n vehicleId\n notes\n hireDate\n baseSalary\n bonusYtd\n payCurrency\n onLeaveUntil\n terminatedAt\n terminationReason\n createdAt\n }\n }\n", m = "\n mutation CreateVehicle($input: CreateVehicleInput!) {\n createVehicle(input: $input) {\n id\n vehicleNumber\n type\n make\n model\n licensePlate\n ownershipType\n year\n capacity\n status\n currentLocation\n fuelType\n fuelEfficiencyLPer100Km\n fuelLevel\n mileage\n createdAt\n updatedAt\n }\n }\n", h = "\n mutation CreateDriver($input: CreateDriverInput!) {\n createDriver(input: $input) {\n id\n userId\n firstName\n lastName\n email\n phone\n employeeId\n licenseNumber\n licenseClass\n licenseExpiry\n status\n currentLocation\n rating\n vehicleId\n notes\n hireDate\n baseSalary\n bonusYtd\n payCurrency\n onLeaveUntil\n terminatedAt\n terminationReason\n createdAt\n }\n }\n", g = "\n mutation UpdateVehicle($id: ID!, $input: UpdateVehicleInput!) {\n updateVehicle(id: $id, input: $input) {\n id\n vehicleNumber\n type\n make\n model\n licensePlate\n ownershipType\n year\n capacity\n status\n currentLocation\n fuelType\n fuelEfficiencyLPer100Km\n fuelLevel\n mileage\n createdAt\n updatedAt\n }\n }\n", _ = "\n mutation UpdateDriver($id: ID!, $input: UpdateDriverInput!) {\n updateDriver(id: $id, input: $input) {\n id\n userId\n firstName\n lastName\n email\n phone\n employeeId\n licenseNumber\n licenseClass\n licenseExpiry\n status\n currentLocation\n rating\n vehicleId\n notes\n hireDate\n baseSalary\n bonusYtd\n payCurrency\n onLeaveUntil\n terminatedAt\n terminationReason\n createdAt\n }\n }\n", v = "\n query GetDriverStatusCounts {\n onBreak: driversCount(filter: { status: ON_BREAK })\n offDuty: driversCount(filter: { status: OFF_DUTY })\n inactive: driversCount(filter: { status: INACTIVE })\n }\n", y = "\n query GetFleetStats {\n fleetStats {\n totalVehicles\n activeVehicles\n inTransitVehicles\n maintenanceVehicles\n totalDrivers\n availableDrivers\n onDeliveryDrivers\n avgDriverRating\n }\n }\n";
|
|
6
|
+
function b(e) {
|
|
7
7
|
switch (e) {
|
|
8
8
|
case "ACTIVE": return "available";
|
|
9
9
|
case "IN_TRANSIT": return "assigned";
|
|
10
10
|
case "MAINTENANCE": return "maintenance";
|
|
11
|
+
case "DECOMMISSIONED": return "decommissioned";
|
|
11
12
|
default: return "out_of_service";
|
|
12
13
|
}
|
|
13
14
|
}
|
|
14
|
-
function
|
|
15
|
+
function x(e) {
|
|
15
16
|
switch (e) {
|
|
16
17
|
case "available": return "ACTIVE";
|
|
17
18
|
case "assigned": return "IN_TRANSIT";
|
|
18
19
|
case "maintenance": return "MAINTENANCE";
|
|
20
|
+
case "decommissioned": return "DECOMMISSIONED";
|
|
19
21
|
default: return "INACTIVE";
|
|
20
22
|
}
|
|
21
23
|
}
|
|
22
|
-
function
|
|
24
|
+
function S(e) {
|
|
23
25
|
switch (e) {
|
|
24
26
|
case "AVAILABLE": return "available";
|
|
25
27
|
case "ON_DELIVERY": return "busy";
|
|
@@ -28,7 +30,7 @@ function x(e) {
|
|
|
28
30
|
default: return "offline";
|
|
29
31
|
}
|
|
30
32
|
}
|
|
31
|
-
function
|
|
33
|
+
function C(e) {
|
|
32
34
|
switch (e) {
|
|
33
35
|
case "available": return "AVAILABLE";
|
|
34
36
|
case "busy": return "ON_DELIVERY";
|
|
@@ -37,7 +39,20 @@ function S(e) {
|
|
|
37
39
|
default: return "OFF_DUTY";
|
|
38
40
|
}
|
|
39
41
|
}
|
|
40
|
-
function
|
|
42
|
+
function w(e) {
|
|
43
|
+
if (!e) return;
|
|
44
|
+
let t = e.lat, n = e.lng;
|
|
45
|
+
if (typeof t != "number" || typeof n != "number") return;
|
|
46
|
+
let r = e.recordedAt;
|
|
47
|
+
return {
|
|
48
|
+
latitude: t,
|
|
49
|
+
longitude: n,
|
|
50
|
+
address: e.address ?? void 0,
|
|
51
|
+
accuracy: typeof e.accuracy == "number" ? e.accuracy : void 0,
|
|
52
|
+
timestamp: r ? new Date(r) : void 0
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function T(e) {
|
|
41
56
|
return {
|
|
42
57
|
id: e.id,
|
|
43
58
|
vehicleNumber: e.vehicleNumber,
|
|
@@ -46,20 +61,15 @@ function C(e) {
|
|
|
46
61
|
model: e.model ?? "",
|
|
47
62
|
licensePlate: e.licensePlate ?? "",
|
|
48
63
|
ownershipType: e.ownershipType ?? void 0,
|
|
49
|
-
year: e.year ??
|
|
64
|
+
year: e.year ?? void 0,
|
|
50
65
|
capacity: {
|
|
51
66
|
weight: 0,
|
|
52
67
|
volume: 0,
|
|
53
68
|
...e.capacity ?? {}
|
|
54
69
|
},
|
|
55
|
-
status:
|
|
70
|
+
status: b(e.status),
|
|
56
71
|
driverId: void 0,
|
|
57
|
-
currentLocation: e.currentLocation
|
|
58
|
-
latitude: Number(e.currentLocation.latitude ?? 0),
|
|
59
|
-
longitude: Number(e.currentLocation.longitude ?? 0),
|
|
60
|
-
address: e.currentLocation.address ?? void 0,
|
|
61
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
62
|
-
} : void 0,
|
|
72
|
+
currentLocation: w(e.currentLocation),
|
|
63
73
|
lastMaintenance: e.lastServiceDate ? new Date(e.lastServiceDate) : void 0,
|
|
64
74
|
nextMaintenance: e.nextServiceDueDate ? new Date(e.nextServiceDueDate) : void 0,
|
|
65
75
|
nextMaintenanceMileage: e.nextServiceDueMileage ?? void 0,
|
|
@@ -71,7 +81,7 @@ function C(e) {
|
|
|
71
81
|
createdAt: new Date(e.createdAt)
|
|
72
82
|
};
|
|
73
83
|
}
|
|
74
|
-
function
|
|
84
|
+
function E(e) {
|
|
75
85
|
return {
|
|
76
86
|
id: e.id,
|
|
77
87
|
userId: e.userId ?? e.id,
|
|
@@ -84,13 +94,8 @@ function w(e) {
|
|
|
84
94
|
licenseExpiry: e.licenseExpiry ? new Date(e.licenseExpiry) : /* @__PURE__ */ new Date(),
|
|
85
95
|
vehicleIds: e.vehicleId ? [e.vehicleId] : [],
|
|
86
96
|
assignedVehicle: e.vehicleId ?? void 0,
|
|
87
|
-
status:
|
|
88
|
-
currentLocation: e.currentLocation
|
|
89
|
-
latitude: Number(e.currentLocation.latitude ?? 0),
|
|
90
|
-
longitude: Number(e.currentLocation.longitude ?? 0),
|
|
91
|
-
address: e.currentLocation.address ?? void 0,
|
|
92
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
93
|
-
} : void 0,
|
|
97
|
+
status: S(e.status),
|
|
98
|
+
currentLocation: w(e.currentLocation),
|
|
94
99
|
rating: e.rating ?? 0,
|
|
95
100
|
notes: e.notes ?? void 0,
|
|
96
101
|
hireDate: e.hireDate ? new Date(e.hireDate) : void 0,
|
|
@@ -104,7 +109,7 @@ function w(e) {
|
|
|
104
109
|
createdAt: new Date(e.createdAt)
|
|
105
110
|
};
|
|
106
111
|
}
|
|
107
|
-
function
|
|
112
|
+
function D() {
|
|
108
113
|
let { apiGatewayUrl: t, authToken: n, workspaceToken: r, workspaceId: a, tenantId: o, currentUser: s } = e();
|
|
109
114
|
return i(() => ({
|
|
110
115
|
apiGatewayUrl: t,
|
|
@@ -122,55 +127,55 @@ function T() {
|
|
|
122
127
|
s?.id
|
|
123
128
|
]);
|
|
124
129
|
}
|
|
125
|
-
function
|
|
126
|
-
let { filters: c, limit: l = 20 } = e,
|
|
130
|
+
function O(e = {}) {
|
|
131
|
+
let { filters: c, limit: l = 20 } = e, d = i(() => c, [
|
|
127
132
|
c?.driverId,
|
|
128
133
|
c?.search,
|
|
129
134
|
c?.status,
|
|
130
135
|
c?.vehicleId,
|
|
131
136
|
c?.vehicleType
|
|
132
|
-
]),
|
|
133
|
-
|
|
137
|
+
]), f = D(), [p, v] = a([]), [y, b] = a([]), [S, C] = a(!1), [w, O] = a(null), k = n(async () => {
|
|
138
|
+
C(!0), O(null);
|
|
134
139
|
try {
|
|
135
|
-
let [e, n] = await Promise.all([t(
|
|
140
|
+
let [e, n] = await Promise.all([t(f, o, {
|
|
136
141
|
filter: {
|
|
137
|
-
search:
|
|
138
|
-
type:
|
|
139
|
-
status:
|
|
140
|
-
driverId:
|
|
142
|
+
search: d?.search,
|
|
143
|
+
type: d?.vehicleType?.toUpperCase(),
|
|
144
|
+
status: d?.status ? x(d.status) : void 0,
|
|
145
|
+
driverId: d?.driverId
|
|
141
146
|
},
|
|
142
147
|
pagination: {
|
|
143
148
|
limit: l,
|
|
144
149
|
offset: 0
|
|
145
150
|
}
|
|
146
|
-
}), t(
|
|
151
|
+
}), t(f, s, {
|
|
147
152
|
filter: {
|
|
148
|
-
search:
|
|
149
|
-
vehicleId:
|
|
153
|
+
search: d?.search,
|
|
154
|
+
vehicleId: d?.vehicleId
|
|
150
155
|
},
|
|
151
156
|
pagination: {
|
|
152
157
|
limit: l,
|
|
153
158
|
offset: 0
|
|
154
159
|
}
|
|
155
160
|
})]);
|
|
156
|
-
|
|
161
|
+
v(e.vehicles.map(T)), b(n.drivers.map(E));
|
|
157
162
|
} catch (e) {
|
|
158
|
-
|
|
163
|
+
O(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load fleet data"));
|
|
159
164
|
} finally {
|
|
160
|
-
|
|
165
|
+
C(!1);
|
|
161
166
|
}
|
|
162
167
|
}, [
|
|
163
|
-
u,
|
|
164
168
|
d,
|
|
169
|
+
f,
|
|
165
170
|
l
|
|
166
171
|
]);
|
|
167
172
|
r(() => {
|
|
168
|
-
|
|
169
|
-
}, [
|
|
170
|
-
let
|
|
171
|
-
|
|
172
|
-
}, [
|
|
173
|
-
let n =
|
|
173
|
+
k();
|
|
174
|
+
}, [k]);
|
|
175
|
+
let A = n(() => {
|
|
176
|
+
k();
|
|
177
|
+
}, [k]), j = n(async (e) => {
|
|
178
|
+
let n = T((await t(f, m, { input: {
|
|
174
179
|
vehicleNumber: e.vehicleNumber,
|
|
175
180
|
type: e.type,
|
|
176
181
|
make: e.make,
|
|
@@ -180,11 +185,12 @@ function E(e = {}) {
|
|
|
180
185
|
year: e.year,
|
|
181
186
|
status: e.status,
|
|
182
187
|
fuelType: e.fuelType,
|
|
183
|
-
fuelEfficiencyLPer100Km: e.fuelEfficiencyLPer100Km
|
|
188
|
+
fuelEfficiencyLPer100Km: e.fuelEfficiencyLPer100Km,
|
|
189
|
+
capacity: e.capacity
|
|
184
190
|
} })).createVehicle);
|
|
185
|
-
return
|
|
186
|
-
}, [
|
|
187
|
-
let n =
|
|
191
|
+
return v((e) => [n, ...e]), n;
|
|
192
|
+
}, [f]), M = n(async (e) => {
|
|
193
|
+
let n = E((await t(f, h, { input: {
|
|
188
194
|
employeeId: e.employeeId,
|
|
189
195
|
firstName: e.firstName,
|
|
190
196
|
lastName: e.lastName,
|
|
@@ -202,9 +208,9 @@ function E(e = {}) {
|
|
|
202
208
|
bonusYtd: e.bonusYtd,
|
|
203
209
|
payCurrency: e.payCurrency
|
|
204
210
|
} })).createDriver);
|
|
205
|
-
return
|
|
206
|
-
}, [
|
|
207
|
-
let r =
|
|
211
|
+
return b((e) => [n, ...e]), n;
|
|
212
|
+
}, [f]), N = n(async (e, n) => {
|
|
213
|
+
let r = T((await t(f, g, {
|
|
208
214
|
id: e,
|
|
209
215
|
input: {
|
|
210
216
|
vehicleNumber: n.vehicleNumber,
|
|
@@ -216,12 +222,13 @@ function E(e = {}) {
|
|
|
216
222
|
year: n.year,
|
|
217
223
|
status: n.status,
|
|
218
224
|
fuelType: n.fuelType,
|
|
219
|
-
fuelEfficiencyLPer100Km: n.fuelEfficiencyLPer100Km
|
|
225
|
+
fuelEfficiencyLPer100Km: n.fuelEfficiencyLPer100Km,
|
|
226
|
+
capacity: n.capacity
|
|
220
227
|
}
|
|
221
228
|
})).updateVehicle);
|
|
222
|
-
return
|
|
223
|
-
}, [
|
|
224
|
-
let r =
|
|
229
|
+
return v((t) => t.map((t) => t.id === e ? r : t)), r;
|
|
230
|
+
}, [f]), P = n(async (e, n) => {
|
|
231
|
+
let r = E((await t(f, _, {
|
|
225
232
|
id: e,
|
|
226
233
|
input: {
|
|
227
234
|
firstName: n.firstName,
|
|
@@ -244,95 +251,101 @@ function E(e = {}) {
|
|
|
244
251
|
terminationReason: n.terminationReason
|
|
245
252
|
}
|
|
246
253
|
})).updateDriver);
|
|
247
|
-
return
|
|
248
|
-
}, [
|
|
254
|
+
return b((t) => t.map((t) => t.id === e ? r : t)), r;
|
|
255
|
+
}, [f]), F = n(async (e) => {
|
|
256
|
+
await t(f, u, { id: e }), v((t) => t.filter((t) => t.id !== e));
|
|
257
|
+
}, [f]);
|
|
249
258
|
return {
|
|
250
|
-
vehicles:
|
|
251
|
-
drivers:
|
|
252
|
-
totalVehicles:
|
|
253
|
-
totalDrivers:
|
|
254
|
-
isLoading:
|
|
255
|
-
error:
|
|
256
|
-
refetch:
|
|
257
|
-
createVehicle:
|
|
258
|
-
createDriver:
|
|
259
|
-
updateVehicle:
|
|
260
|
-
updateDriver:
|
|
259
|
+
vehicles: p,
|
|
260
|
+
drivers: y,
|
|
261
|
+
totalVehicles: p.length,
|
|
262
|
+
totalDrivers: y.length,
|
|
263
|
+
isLoading: S,
|
|
264
|
+
error: w,
|
|
265
|
+
refetch: A,
|
|
266
|
+
createVehicle: j,
|
|
267
|
+
createDriver: M,
|
|
268
|
+
updateVehicle: N,
|
|
269
|
+
updateDriver: P,
|
|
270
|
+
deleteVehicle: F
|
|
261
271
|
};
|
|
262
272
|
}
|
|
263
|
-
function
|
|
264
|
-
let { limit: i = 20, offset: s = 0, search: c, status: l, vehicleType:
|
|
265
|
-
if (
|
|
266
|
-
|
|
273
|
+
function k(e = {}) {
|
|
274
|
+
let { limit: i = 20, offset: s = 0, search: c, status: l, vehicleType: p, driverId: m, ids: h } = e, g = D(), [_, v] = a([]), [y, b] = a(0), [S, C] = a(!1), [w, E] = a(!1), [O, k] = a(null), A = n(async () => {
|
|
275
|
+
if (h && h.length === 0) {
|
|
276
|
+
v([]), b(0), C(!1);
|
|
267
277
|
return;
|
|
268
278
|
}
|
|
269
|
-
E(!0),
|
|
279
|
+
E(!0), k(null);
|
|
270
280
|
try {
|
|
271
|
-
let e = await t(
|
|
281
|
+
let e = await t(g, o, {
|
|
272
282
|
filter: {
|
|
273
283
|
search: c || void 0,
|
|
274
|
-
status: l ?
|
|
275
|
-
type:
|
|
276
|
-
driverId:
|
|
277
|
-
ids:
|
|
284
|
+
status: l ? x(l) : void 0,
|
|
285
|
+
type: p?.toUpperCase(),
|
|
286
|
+
driverId: m || void 0,
|
|
287
|
+
ids: h && h.length > 0 ? [...h] : void 0
|
|
278
288
|
},
|
|
279
289
|
pagination: {
|
|
280
|
-
limit:
|
|
281
|
-
offset:
|
|
290
|
+
limit: h && h.length > 0 ? h.length : i,
|
|
291
|
+
offset: h ? 0 : s
|
|
282
292
|
}
|
|
283
293
|
});
|
|
284
|
-
|
|
294
|
+
C(s + e.vehicles.length < e.vehiclesCount), b(e.vehiclesCount), v(e.vehicles.map(T));
|
|
285
295
|
} catch (e) {
|
|
286
|
-
|
|
296
|
+
k(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load vehicles"));
|
|
287
297
|
} finally {
|
|
288
298
|
E(!1);
|
|
289
299
|
}
|
|
290
300
|
}, [
|
|
291
|
-
|
|
301
|
+
g,
|
|
292
302
|
i,
|
|
293
303
|
s,
|
|
294
304
|
c,
|
|
295
305
|
l,
|
|
296
|
-
f,
|
|
297
306
|
p,
|
|
298
|
-
m
|
|
307
|
+
m,
|
|
308
|
+
h ? [...h].sort().join(",") : ""
|
|
299
309
|
]);
|
|
300
310
|
return r(() => {
|
|
301
|
-
|
|
302
|
-
}, [
|
|
303
|
-
vehicles:
|
|
304
|
-
totalVehicles:
|
|
305
|
-
hasMore:
|
|
311
|
+
A();
|
|
312
|
+
}, [A]), {
|
|
313
|
+
vehicles: _,
|
|
314
|
+
totalVehicles: y,
|
|
315
|
+
hasMore: S,
|
|
306
316
|
isLoading: w,
|
|
307
|
-
error:
|
|
317
|
+
error: O,
|
|
308
318
|
refetch: n(() => {
|
|
309
|
-
|
|
310
|
-
}, [
|
|
319
|
+
A();
|
|
320
|
+
}, [A]),
|
|
311
321
|
updateVehicleStatus: n(async (e, n) => {
|
|
312
|
-
let r =
|
|
322
|
+
let r = T((await t(g, d, {
|
|
313
323
|
id: e,
|
|
314
|
-
status:
|
|
324
|
+
status: x(n)
|
|
315
325
|
})).updateVehicleStatus);
|
|
316
|
-
return
|
|
317
|
-
}, [
|
|
326
|
+
return v((t) => t.map((t) => t.id === e ? r : t)), r;
|
|
327
|
+
}, [g]),
|
|
318
328
|
assignDriver: n(async (e, n) => {
|
|
319
|
-
await t(
|
|
329
|
+
await t(g, f, {
|
|
320
330
|
id: n,
|
|
321
331
|
vehicleId: e
|
|
322
332
|
});
|
|
323
|
-
let r =
|
|
333
|
+
let r = _.find((t) => t.id === e);
|
|
324
334
|
if (!r) throw Error("Vehicle not found");
|
|
325
335
|
let i = {
|
|
326
336
|
...r,
|
|
327
337
|
driverId: n,
|
|
328
338
|
status: "assigned"
|
|
329
339
|
};
|
|
330
|
-
return
|
|
331
|
-
}, [
|
|
340
|
+
return v((t) => t.map((t) => t.id === e ? i : t)), i;
|
|
341
|
+
}, [g, _]),
|
|
342
|
+
deleteVehicle: n(async (e) => {
|
|
343
|
+
await t(g, u, { id: e }), v((t) => t.filter((t) => t.id !== e));
|
|
344
|
+
}, [g])
|
|
332
345
|
};
|
|
333
346
|
}
|
|
334
|
-
function
|
|
335
|
-
let i =
|
|
347
|
+
function A(e) {
|
|
348
|
+
let i = D(), [o, s] = a(null), [l, u] = a(!1), [d, f] = a(null), p = n(async () => {
|
|
336
349
|
if (!e) {
|
|
337
350
|
s(null);
|
|
338
351
|
return;
|
|
@@ -340,7 +353,7 @@ function O(e) {
|
|
|
340
353
|
u(!0), f(null);
|
|
341
354
|
try {
|
|
342
355
|
let n = await t(i, c, { id: e });
|
|
343
|
-
s(n.vehicle ?
|
|
356
|
+
s(n.vehicle ? T(n.vehicle) : null);
|
|
344
357
|
} catch (e) {
|
|
345
358
|
f(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load vehicle"));
|
|
346
359
|
} finally {
|
|
@@ -358,27 +371,27 @@ function O(e) {
|
|
|
358
371
|
}, [p])
|
|
359
372
|
};
|
|
360
373
|
}
|
|
361
|
-
function
|
|
362
|
-
let { limit: i = 20, offset: o = 0, status: c, search: l, licenseClass: u, vehicleId:
|
|
363
|
-
|
|
374
|
+
function j(e = {}) {
|
|
375
|
+
let { limit: i = 20, offset: o = 0, status: c, search: l, licenseClass: u, vehicleId: d } = e, m = D(), [h, g] = a([]), [_, v] = a(0), [y, b] = a(!1), [x, S] = a(!1), [w, T] = a(null), O = n(async () => {
|
|
376
|
+
S(!0), T(null);
|
|
364
377
|
try {
|
|
365
378
|
let e = await t(m, s, {
|
|
366
379
|
filter: {
|
|
367
|
-
status: c ?
|
|
380
|
+
status: c ? C(c) : void 0,
|
|
368
381
|
search: l || void 0,
|
|
369
382
|
licenseClass: u || void 0,
|
|
370
|
-
vehicleId:
|
|
383
|
+
vehicleId: d || void 0
|
|
371
384
|
},
|
|
372
385
|
pagination: {
|
|
373
386
|
limit: i,
|
|
374
387
|
offset: o
|
|
375
388
|
}
|
|
376
389
|
});
|
|
377
|
-
b(o + e.drivers.length < e.driversCount), v(e.driversCount), g(e.drivers.map(
|
|
390
|
+
b(o + e.drivers.length < e.driversCount), v(e.driversCount), g(e.drivers.map(E));
|
|
378
391
|
} catch (e) {
|
|
379
|
-
|
|
392
|
+
T(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load drivers"));
|
|
380
393
|
} finally {
|
|
381
|
-
|
|
394
|
+
S(!1);
|
|
382
395
|
}
|
|
383
396
|
}, [
|
|
384
397
|
m,
|
|
@@ -387,7 +400,7 @@ function k(e = {}) {
|
|
|
387
400
|
c,
|
|
388
401
|
l,
|
|
389
402
|
u,
|
|
390
|
-
|
|
403
|
+
d
|
|
391
404
|
]);
|
|
392
405
|
return r(() => {
|
|
393
406
|
O();
|
|
@@ -396,19 +409,19 @@ function k(e = {}) {
|
|
|
396
409
|
totalDrivers: _,
|
|
397
410
|
hasMore: y,
|
|
398
411
|
isLoading: x,
|
|
399
|
-
error:
|
|
412
|
+
error: w,
|
|
400
413
|
refetch: n(() => {
|
|
401
414
|
O();
|
|
402
415
|
}, [O]),
|
|
403
416
|
updateDriverStatus: n(async (e, n) => {
|
|
404
|
-
let r =
|
|
417
|
+
let r = E((await t(m, p, {
|
|
405
418
|
id: e,
|
|
406
|
-
status:
|
|
419
|
+
status: C(n)
|
|
407
420
|
})).updateDriverStatus);
|
|
408
421
|
return g((t) => t.map((t) => t.id === e ? r : t)), r;
|
|
409
422
|
}, [m]),
|
|
410
423
|
assignVehicle: n(async (e, n) => {
|
|
411
|
-
let r =
|
|
424
|
+
let r = E((await t(m, f, {
|
|
412
425
|
id: e,
|
|
413
426
|
vehicleId: n
|
|
414
427
|
})).assignDriverVehicle);
|
|
@@ -416,8 +429,8 @@ function k(e = {}) {
|
|
|
416
429
|
}, [m])
|
|
417
430
|
};
|
|
418
431
|
}
|
|
419
|
-
function
|
|
420
|
-
let i =
|
|
432
|
+
function M(e) {
|
|
433
|
+
let i = D(), [o, s] = a(null), [c, u] = a(!1), [d, f] = a(null), p = n(async () => {
|
|
421
434
|
if (!e) {
|
|
422
435
|
s(null);
|
|
423
436
|
return;
|
|
@@ -425,7 +438,7 @@ function A(e) {
|
|
|
425
438
|
u(!0), f(null);
|
|
426
439
|
try {
|
|
427
440
|
let n = await t(i, l, { id: e });
|
|
428
|
-
s(n.driver ?
|
|
441
|
+
s(n.driver ? E(n.driver) : null);
|
|
429
442
|
} catch (e) {
|
|
430
443
|
f(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load driver"));
|
|
431
444
|
} finally {
|
|
@@ -443,15 +456,15 @@ function A(e) {
|
|
|
443
456
|
}, [p])
|
|
444
457
|
};
|
|
445
458
|
}
|
|
446
|
-
function
|
|
447
|
-
let e =
|
|
459
|
+
function N() {
|
|
460
|
+
let e = D(), [i, o] = a({
|
|
448
461
|
onBreak: 0,
|
|
449
462
|
offDuty: 0,
|
|
450
463
|
inactive: 0
|
|
451
464
|
}), [s, c] = a(!1), [l, u] = a(null), d = n(async () => {
|
|
452
465
|
c(!0), u(null);
|
|
453
466
|
try {
|
|
454
|
-
let n = await t(e,
|
|
467
|
+
let n = await t(e, v);
|
|
455
468
|
o({
|
|
456
469
|
onBreak: n.onBreak,
|
|
457
470
|
offDuty: n.offDuty,
|
|
@@ -474,8 +487,8 @@ function j() {
|
|
|
474
487
|
}, [d])
|
|
475
488
|
};
|
|
476
489
|
}
|
|
477
|
-
function
|
|
478
|
-
let i =
|
|
490
|
+
function P(e) {
|
|
491
|
+
let i = D(), [o, c] = a([]), [l, u] = a(!1), [d, f] = a(null), p = n(async () => {
|
|
479
492
|
if (!e) {
|
|
480
493
|
c([]);
|
|
481
494
|
return;
|
|
@@ -488,7 +501,7 @@ function M(e) {
|
|
|
488
501
|
limit: 25,
|
|
489
502
|
offset: 0
|
|
490
503
|
}
|
|
491
|
-
})).drivers.map(
|
|
504
|
+
})).drivers.map(E));
|
|
492
505
|
} catch (e) {
|
|
493
506
|
f(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load assigned driver"));
|
|
494
507
|
} finally {
|
|
@@ -506,8 +519,8 @@ function M(e) {
|
|
|
506
519
|
}, [p])
|
|
507
520
|
};
|
|
508
521
|
}
|
|
509
|
-
function
|
|
510
|
-
let e =
|
|
522
|
+
function F() {
|
|
523
|
+
let e = D(), [i, o] = a({
|
|
511
524
|
totalVehicles: 0,
|
|
512
525
|
totalDrivers: 0,
|
|
513
526
|
vehiclesByStatus: {
|
|
@@ -528,7 +541,7 @@ function N() {
|
|
|
528
541
|
}), [s, c] = a(!1), [l, u] = a(null), d = n(async () => {
|
|
529
542
|
c(!0), u(null);
|
|
530
543
|
try {
|
|
531
|
-
let n = await t(e,
|
|
544
|
+
let n = await t(e, y);
|
|
532
545
|
o({
|
|
533
546
|
totalVehicles: n.fleetStats.totalVehicles,
|
|
534
547
|
totalDrivers: n.fleetStats.totalDrivers,
|
|
@@ -566,4 +579,4 @@ function N() {
|
|
|
566
579
|
};
|
|
567
580
|
}
|
|
568
581
|
//#endregion
|
|
569
|
-
export {
|
|
582
|
+
export { E as mapDriver, T as mapVehicle, C as toApiDriverStatus, x as toApiVehicleStatus, M as useDriver, N as useDriverStatusCounts, j as useDrivers, O as useFleet, F as useFleetStats, A as useVehicle, P as useVehicleDrivers, k as useVehicles };
|