@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
package/dist/hooks/useFleet.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { useMoveTheWheels as e } from "../providers/MoveTheWheelsProvider.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { emitVehicleAssigned as t, emitVehicleServiceRecorded as n } from "../events/rybbit.js";
|
|
3
|
+
import { executeGraphQL as r } from "../utils/graphqlClient.js";
|
|
4
|
+
import { useCallback as i, useEffect as a, useMemo as o, useState as s } from "react";
|
|
5
|
+
import { useEventBus as c } from "@burdenoff/fe-libs/shared/events";
|
|
4
6
|
// src/movethewheels/hooks/useFleet.ts
|
|
5
|
-
var
|
|
6
|
-
function
|
|
7
|
+
var l = "\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 drivers {\n id\n }\n }\n vehiclesCount(filter: $filter)\n }\n", u = "\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 vehicles {\n id\n }\n }\n driversCount(filter: $filter)\n }\n", d = "\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 diagnostics\n maintenanceLogs {\n id\n vehicleId\n serviceDate\n serviceType\n description\n mileage\n cost\n currency\n vendor\n notes\n createdAt\n }\n utilizationSummary {\n totalRoutes\n completedRoutes\n activeRoutes\n totalDeliveryJobs\n completedDeliveryJobs\n totalDistanceKm\n utilizationRate\n }\n createdAt\n updatedAt\n drivers {\n id\n }\n }\n }\n", f = "\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 shifts {\n id\n driverId\n shiftDate\n startTime\n endTime\n status\n maxHours\n notes\n }\n complianceRecords {\n id\n driverId\n recordType\n status\n issuedAt\n expiresAt\n referenceNumber\n notes\n }\n createdAt\n vehicles {\n id\n }\n }\n }\n", p = "\n mutation CreateVehicleMaintenanceLog($input: CreateVehicleMaintenanceLogInput!) {\n createVehicleMaintenanceLog(input: $input) {\n id\n vehicleId\n serviceDate\n serviceType\n description\n mileage\n cost\n currency\n vendor\n notes\n createdAt\n }\n }\n", m = "\n mutation DeleteVehicleMaintenanceLog($id: ID!) {\n deleteVehicleMaintenanceLog(id: $id)\n }\n", h = "\n mutation CreateDriverShift($input: CreateDriverShiftInput!) {\n createDriverShift(input: $input) {\n id\n driverId\n shiftDate\n startTime\n endTime\n status\n maxHours\n notes\n }\n }\n", g = "\n mutation DeleteDriverShift($id: ID!) {\n deleteDriverShift(id: $id)\n }\n", _ = "\n mutation CreateDriverComplianceRecord($input: CreateDriverComplianceRecordInput!) {\n createDriverComplianceRecord(input: $input) {\n id\n driverId\n recordType\n status\n issuedAt\n expiresAt\n referenceNumber\n notes\n }\n }\n", v = "\n mutation DeleteDriverComplianceRecord($id: ID!) {\n deleteDriverComplianceRecord(id: $id)\n }\n", y = "\n mutation DeleteDriver($id: ID!) {\n deleteDriver(id: $id)\n }\n", b = "\n mutation DeleteVehicle($id: ID!) {\n deleteVehicle(id: $id)\n }\n", x = "\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 drivers {\n id\n }\n }\n }\n", S = "\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 vehicles {\n id\n }\n }\n }\n", C = "\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 vehicles {\n id\n }\n }\n }\n", w = "\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 drivers {\n id\n }\n }\n }\n", T = "\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 vehicles {\n id\n }\n }\n }\n", E = "\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 drivers {\n id\n }\n }\n }\n", D = "\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 vehicles {\n id\n }\n }\n }\n", O = "\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", k = "\n query GetFleetStats {\n fleetStats {\n totalVehicles\n activeVehicles\n inTransitVehicles\n maintenanceVehicles\n totalDrivers\n availableDrivers\n onDeliveryDrivers\n avgDriverRating\n }\n }\n";
|
|
8
|
+
function A(e) {
|
|
7
9
|
switch (e) {
|
|
8
10
|
case "ACTIVE": return "available";
|
|
9
11
|
case "IN_TRANSIT": return "assigned";
|
|
@@ -12,7 +14,7 @@ function x(e) {
|
|
|
12
14
|
default: return "out_of_service";
|
|
13
15
|
}
|
|
14
16
|
}
|
|
15
|
-
function
|
|
17
|
+
function j(e) {
|
|
16
18
|
switch (e) {
|
|
17
19
|
case "available": return "ACTIVE";
|
|
18
20
|
case "assigned": return "IN_TRANSIT";
|
|
@@ -21,7 +23,7 @@ function S(e) {
|
|
|
21
23
|
default: return "INACTIVE";
|
|
22
24
|
}
|
|
23
25
|
}
|
|
24
|
-
function
|
|
26
|
+
function M(e) {
|
|
25
27
|
switch (e) {
|
|
26
28
|
case "AVAILABLE": return "available";
|
|
27
29
|
case "ON_DELIVERY": return "busy";
|
|
@@ -30,7 +32,7 @@ function C(e) {
|
|
|
30
32
|
default: return "offline";
|
|
31
33
|
}
|
|
32
34
|
}
|
|
33
|
-
function
|
|
35
|
+
function N(e) {
|
|
34
36
|
switch (e) {
|
|
35
37
|
case "available": return "AVAILABLE";
|
|
36
38
|
case "busy": return "ON_DELIVERY";
|
|
@@ -39,7 +41,7 @@ function w(e) {
|
|
|
39
41
|
default: return "OFF_DUTY";
|
|
40
42
|
}
|
|
41
43
|
}
|
|
42
|
-
function
|
|
44
|
+
function P(e) {
|
|
43
45
|
if (!e) return;
|
|
44
46
|
let t = e.lat, n = e.lng;
|
|
45
47
|
if (typeof t != "number" || typeof n != "number") return;
|
|
@@ -52,7 +54,7 @@ function T(e) {
|
|
|
52
54
|
timestamp: r ? new Date(r) : void 0
|
|
53
55
|
};
|
|
54
56
|
}
|
|
55
|
-
function
|
|
57
|
+
function F(e) {
|
|
56
58
|
return {
|
|
57
59
|
id: e.id,
|
|
58
60
|
vehicleNumber: e.vehicleNumber,
|
|
@@ -67,10 +69,10 @@ function E(e) {
|
|
|
67
69
|
volume: typeof e.capacity?.volume == "number" ? e.capacity.volume : void 0,
|
|
68
70
|
pallets: typeof e.capacity?.pallets == "number" ? e.capacity.pallets : void 0
|
|
69
71
|
},
|
|
70
|
-
status:
|
|
72
|
+
status: A(e.status),
|
|
71
73
|
driverIds: (e.drivers ?? []).map((e) => e.id),
|
|
72
74
|
driverId: e.drivers?.[0]?.id,
|
|
73
|
-
currentLocation:
|
|
75
|
+
currentLocation: P(e.currentLocation),
|
|
74
76
|
lastMaintenance: e.lastServiceDate ? new Date(e.lastServiceDate) : void 0,
|
|
75
77
|
nextMaintenance: e.nextServiceDueDate ? new Date(e.nextServiceDueDate) : void 0,
|
|
76
78
|
nextMaintenanceMileage: e.nextServiceDueMileage ?? void 0,
|
|
@@ -78,11 +80,33 @@ function E(e) {
|
|
|
78
80
|
fuelEfficiencyLPer100Km: e.fuelEfficiencyLPer100Km ?? void 0,
|
|
79
81
|
fuelLevel: e.fuelLevel ?? void 0,
|
|
80
82
|
mileage: e.mileage ?? void 0,
|
|
81
|
-
|
|
83
|
+
diagnostics: e.diagnostics ?? void 0,
|
|
84
|
+
maintenanceLogs: e.maintenanceLogs?.map((e) => ({
|
|
85
|
+
id: e.id,
|
|
86
|
+
vehicleId: e.vehicleId,
|
|
87
|
+
serviceDate: new Date(e.serviceDate),
|
|
88
|
+
serviceType: e.serviceType,
|
|
89
|
+
description: e.description,
|
|
90
|
+
mileage: e.mileage ?? void 0,
|
|
91
|
+
cost: e.cost ?? void 0,
|
|
92
|
+
currency: e.currency ?? void 0,
|
|
93
|
+
vendor: e.vendor ?? void 0,
|
|
94
|
+
notes: e.notes ?? void 0,
|
|
95
|
+
createdAt: new Date(e.createdAt)
|
|
96
|
+
})),
|
|
97
|
+
utilizationSummary: e.utilizationSummary ? {
|
|
98
|
+
totalRoutes: e.utilizationSummary.totalRoutes,
|
|
99
|
+
completedRoutes: e.utilizationSummary.completedRoutes,
|
|
100
|
+
activeRoutes: e.utilizationSummary.activeRoutes,
|
|
101
|
+
totalDeliveryJobs: e.utilizationSummary.totalDeliveryJobs,
|
|
102
|
+
completedDeliveryJobs: e.utilizationSummary.completedDeliveryJobs,
|
|
103
|
+
totalDistanceKm: e.utilizationSummary.totalDistanceKm,
|
|
104
|
+
utilizationRate: e.utilizationSummary.utilizationRate ?? void 0
|
|
105
|
+
} : void 0,
|
|
82
106
|
createdAt: new Date(e.createdAt)
|
|
83
107
|
};
|
|
84
108
|
}
|
|
85
|
-
function
|
|
109
|
+
function I(e) {
|
|
86
110
|
return {
|
|
87
111
|
id: e.id,
|
|
88
112
|
userId: e.userId ?? e.id,
|
|
@@ -95,8 +119,8 @@ function D(e) {
|
|
|
95
119
|
licenseExpiry: e.licenseExpiry ? new Date(e.licenseExpiry) : void 0,
|
|
96
120
|
vehicleIds: e.vehicles && e.vehicles.length > 0 ? e.vehicles.map((e) => e.id) : e.vehicleId ? [e.vehicleId] : [],
|
|
97
121
|
assignedVehicle: e.vehicles?.[0]?.id ?? e.vehicleId ?? void 0,
|
|
98
|
-
status:
|
|
99
|
-
currentLocation:
|
|
122
|
+
status: M(e.status),
|
|
123
|
+
currentLocation: P(e.currentLocation),
|
|
100
124
|
rating: e.rating ?? void 0,
|
|
101
125
|
notes: e.notes ?? void 0,
|
|
102
126
|
hireDate: e.hireDate ? new Date(e.hireDate) : void 0,
|
|
@@ -106,84 +130,103 @@ function D(e) {
|
|
|
106
130
|
onLeaveUntil: e.onLeaveUntil ? new Date(e.onLeaveUntil) : void 0,
|
|
107
131
|
terminatedAt: e.terminatedAt ? new Date(e.terminatedAt) : void 0,
|
|
108
132
|
terminationReason: e.terminationReason ?? void 0,
|
|
109
|
-
|
|
133
|
+
shifts: e.shifts?.map((e) => ({
|
|
134
|
+
id: e.id,
|
|
135
|
+
driverId: e.driverId,
|
|
136
|
+
shiftDate: new Date(e.shiftDate),
|
|
137
|
+
startTime: e.startTime,
|
|
138
|
+
endTime: e.endTime,
|
|
139
|
+
status: e.status,
|
|
140
|
+
maxHours: e.maxHours ?? void 0,
|
|
141
|
+
notes: e.notes ?? void 0
|
|
142
|
+
})),
|
|
143
|
+
complianceRecords: e.complianceRecords?.map((e) => ({
|
|
144
|
+
id: e.id,
|
|
145
|
+
driverId: e.driverId,
|
|
146
|
+
recordType: e.recordType,
|
|
147
|
+
status: e.status,
|
|
148
|
+
issuedAt: e.issuedAt ? new Date(e.issuedAt) : void 0,
|
|
149
|
+
expiresAt: e.expiresAt ? new Date(e.expiresAt) : void 0,
|
|
150
|
+
referenceNumber: e.referenceNumber ?? void 0,
|
|
151
|
+
notes: e.notes ?? void 0
|
|
152
|
+
})),
|
|
110
153
|
createdAt: new Date(e.createdAt)
|
|
111
154
|
};
|
|
112
155
|
}
|
|
113
|
-
function
|
|
114
|
-
let { apiGatewayUrl: t, authToken: n, workspaceToken: r, workspaceId:
|
|
115
|
-
return
|
|
156
|
+
function L() {
|
|
157
|
+
let { apiGatewayUrl: t, authToken: n, workspaceToken: r, workspaceId: i, tenantId: a, currentUser: s } = e();
|
|
158
|
+
return o(() => ({
|
|
116
159
|
apiGatewayUrl: t,
|
|
117
160
|
authToken: n,
|
|
118
161
|
workspaceToken: r,
|
|
119
|
-
workspaceId:
|
|
120
|
-
tenantId:
|
|
162
|
+
workspaceId: i,
|
|
163
|
+
tenantId: a,
|
|
121
164
|
actorId: s?.id
|
|
122
165
|
}), [
|
|
123
166
|
t,
|
|
124
167
|
n,
|
|
125
168
|
r,
|
|
169
|
+
i,
|
|
126
170
|
a,
|
|
127
|
-
o,
|
|
128
171
|
s?.id
|
|
129
172
|
]);
|
|
130
173
|
}
|
|
131
|
-
function
|
|
132
|
-
let { filters:
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
]),
|
|
139
|
-
|
|
174
|
+
function R(e = {}) {
|
|
175
|
+
let { filters: t, limit: n = 20 } = e, c = o(() => t, [
|
|
176
|
+
t?.driverId,
|
|
177
|
+
t?.search,
|
|
178
|
+
t?.status,
|
|
179
|
+
t?.vehicleId,
|
|
180
|
+
t?.vehicleType
|
|
181
|
+
]), d = L(), [f, p] = s([]), [m, h] = s([]), [g, _] = s(0), [v, x] = s(0), [S, C] = s(!1), [O, k] = s(null), A = i(async () => {
|
|
182
|
+
C(!0), k(null);
|
|
140
183
|
try {
|
|
141
|
-
let [e,
|
|
184
|
+
let [e, t] = await Promise.all([r(d, l, {
|
|
142
185
|
filter: {
|
|
143
|
-
search:
|
|
144
|
-
type:
|
|
145
|
-
status:
|
|
146
|
-
driverId:
|
|
186
|
+
search: c?.search,
|
|
187
|
+
type: c?.vehicleType?.toUpperCase(),
|
|
188
|
+
status: c?.status ? j(c.status) : void 0,
|
|
189
|
+
driverId: c?.driverId
|
|
147
190
|
},
|
|
148
191
|
pagination: {
|
|
149
|
-
limit:
|
|
192
|
+
limit: n,
|
|
150
193
|
offset: 0
|
|
151
194
|
}
|
|
152
|
-
}),
|
|
195
|
+
}), r(d, u, {
|
|
153
196
|
filter: {
|
|
154
|
-
search:
|
|
155
|
-
vehicleId:
|
|
197
|
+
search: c?.search,
|
|
198
|
+
vehicleId: c?.vehicleId
|
|
156
199
|
},
|
|
157
200
|
pagination: {
|
|
158
|
-
limit:
|
|
201
|
+
limit: n,
|
|
159
202
|
offset: 0
|
|
160
203
|
}
|
|
161
204
|
})]);
|
|
162
|
-
|
|
205
|
+
p(e.vehicles.map(F)), h(t.drivers.map(I)), _(e.vehiclesCount), x(t.driversCount);
|
|
163
206
|
} catch (e) {
|
|
164
|
-
|
|
207
|
+
k(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load fleet data"));
|
|
165
208
|
} finally {
|
|
166
|
-
|
|
209
|
+
C(!1);
|
|
167
210
|
}
|
|
168
211
|
}, [
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
212
|
+
c,
|
|
213
|
+
d,
|
|
214
|
+
n
|
|
172
215
|
]);
|
|
173
|
-
return
|
|
174
|
-
|
|
175
|
-
}, [
|
|
176
|
-
vehicles:
|
|
177
|
-
drivers:
|
|
178
|
-
totalVehicles:
|
|
179
|
-
totalDrivers:
|
|
180
|
-
isLoading:
|
|
181
|
-
error:
|
|
182
|
-
refetch:
|
|
183
|
-
|
|
184
|
-
}, [
|
|
185
|
-
createVehicle:
|
|
186
|
-
let
|
|
216
|
+
return a(() => {
|
|
217
|
+
A();
|
|
218
|
+
}, [A]), {
|
|
219
|
+
vehicles: f,
|
|
220
|
+
drivers: m,
|
|
221
|
+
totalVehicles: g,
|
|
222
|
+
totalDrivers: v,
|
|
223
|
+
isLoading: S,
|
|
224
|
+
error: O,
|
|
225
|
+
refetch: i(() => {
|
|
226
|
+
A();
|
|
227
|
+
}, [A]),
|
|
228
|
+
createVehicle: i(async (e) => {
|
|
229
|
+
let t = F((await r(d, w, { input: {
|
|
187
230
|
vehicleNumber: e.vehicleNumber,
|
|
188
231
|
type: e.type,
|
|
189
232
|
make: e.make,
|
|
@@ -196,10 +239,10 @@ function k(e = {}) {
|
|
|
196
239
|
fuelEfficiencyLPer100Km: e.fuelEfficiencyLPer100Km,
|
|
197
240
|
capacity: e.capacity
|
|
198
241
|
} })).createVehicle);
|
|
199
|
-
return
|
|
200
|
-
}, [
|
|
201
|
-
createDriver:
|
|
202
|
-
let
|
|
242
|
+
return p((e) => [t, ...e]), t;
|
|
243
|
+
}, [d]),
|
|
244
|
+
createDriver: i(async (e) => {
|
|
245
|
+
let t = I((await r(d, T, { input: {
|
|
203
246
|
employeeId: e.employeeId,
|
|
204
247
|
firstName: e.firstName,
|
|
205
248
|
lastName: e.lastName,
|
|
@@ -218,180 +261,180 @@ function k(e = {}) {
|
|
|
218
261
|
bonusYtd: e.bonusYtd,
|
|
219
262
|
payCurrency: e.payCurrency
|
|
220
263
|
} })).createDriver);
|
|
221
|
-
return
|
|
222
|
-
}, [
|
|
223
|
-
updateVehicle:
|
|
224
|
-
let
|
|
264
|
+
return h((e) => [t, ...e]), t;
|
|
265
|
+
}, [d]),
|
|
266
|
+
updateVehicle: i(async (e, t) => {
|
|
267
|
+
let n = F((await r(d, E, {
|
|
225
268
|
id: e,
|
|
226
269
|
input: {
|
|
227
|
-
vehicleNumber:
|
|
228
|
-
type:
|
|
229
|
-
make:
|
|
230
|
-
model:
|
|
231
|
-
licensePlate:
|
|
232
|
-
ownershipType:
|
|
233
|
-
year:
|
|
234
|
-
status:
|
|
235
|
-
fuelType:
|
|
236
|
-
fuelEfficiencyLPer100Km:
|
|
237
|
-
capacity:
|
|
270
|
+
vehicleNumber: t.vehicleNumber,
|
|
271
|
+
type: t.type,
|
|
272
|
+
make: t.make,
|
|
273
|
+
model: t.model,
|
|
274
|
+
licensePlate: t.licensePlate,
|
|
275
|
+
ownershipType: t.ownershipType,
|
|
276
|
+
year: t.year,
|
|
277
|
+
status: t.status,
|
|
278
|
+
fuelType: t.fuelType,
|
|
279
|
+
fuelEfficiencyLPer100Km: t.fuelEfficiencyLPer100Km,
|
|
280
|
+
capacity: t.capacity
|
|
238
281
|
}
|
|
239
282
|
})).updateVehicle);
|
|
240
|
-
return
|
|
241
|
-
}, [
|
|
242
|
-
updateDriver:
|
|
243
|
-
let
|
|
283
|
+
return p((t) => t.map((t) => t.id === e ? n : t)), n;
|
|
284
|
+
}, [d]),
|
|
285
|
+
updateDriver: i(async (e, t) => {
|
|
286
|
+
let n = I((await r(d, D, {
|
|
244
287
|
id: e,
|
|
245
288
|
input: {
|
|
246
|
-
firstName:
|
|
247
|
-
lastName:
|
|
248
|
-
email:
|
|
249
|
-
phone:
|
|
250
|
-
licenseNumber:
|
|
251
|
-
licenseClass:
|
|
252
|
-
licenseExpiry:
|
|
253
|
-
status:
|
|
254
|
-
vehicleId:
|
|
255
|
-
vehicleIds:
|
|
256
|
-
rating:
|
|
257
|
-
notes:
|
|
258
|
-
hireDate:
|
|
259
|
-
baseSalary:
|
|
260
|
-
bonusYtd:
|
|
261
|
-
payCurrency:
|
|
262
|
-
onLeaveUntil:
|
|
263
|
-
terminatedAt:
|
|
264
|
-
terminationReason:
|
|
289
|
+
firstName: t.firstName,
|
|
290
|
+
lastName: t.lastName,
|
|
291
|
+
email: t.email,
|
|
292
|
+
phone: t.phone,
|
|
293
|
+
licenseNumber: t.licenseNumber,
|
|
294
|
+
licenseClass: t.licenseClass,
|
|
295
|
+
licenseExpiry: t.licenseExpiry,
|
|
296
|
+
status: t.status,
|
|
297
|
+
vehicleId: t.vehicleId,
|
|
298
|
+
vehicleIds: t.vehicleIds,
|
|
299
|
+
rating: t.rating,
|
|
300
|
+
notes: t.notes,
|
|
301
|
+
hireDate: t.hireDate,
|
|
302
|
+
baseSalary: t.baseSalary,
|
|
303
|
+
bonusYtd: t.bonusYtd,
|
|
304
|
+
payCurrency: t.payCurrency,
|
|
305
|
+
onLeaveUntil: t.onLeaveUntil,
|
|
306
|
+
terminatedAt: t.terminatedAt,
|
|
307
|
+
terminationReason: t.terminationReason
|
|
265
308
|
}
|
|
266
309
|
})).updateDriver);
|
|
267
|
-
return
|
|
268
|
-
}, [
|
|
269
|
-
deleteVehicle:
|
|
270
|
-
await
|
|
271
|
-
}, [
|
|
272
|
-
deleteDriver:
|
|
273
|
-
await
|
|
274
|
-
}, [
|
|
310
|
+
return h((t) => t.map((t) => t.id === e ? n : t)), n;
|
|
311
|
+
}, [d]),
|
|
312
|
+
deleteVehicle: i(async (e) => {
|
|
313
|
+
await r(d, b, { id: e }), p((t) => t.filter((t) => t.id !== e));
|
|
314
|
+
}, [d]),
|
|
315
|
+
deleteDriver: i(async (e) => {
|
|
316
|
+
await r(d, y, { id: e }), h((t) => t.filter((t) => t.id !== e));
|
|
317
|
+
}, [d])
|
|
275
318
|
};
|
|
276
319
|
}
|
|
277
|
-
function
|
|
278
|
-
let { limit:
|
|
279
|
-
if (
|
|
320
|
+
function z(e = {}) {
|
|
321
|
+
let { limit: n = 20, offset: u = 0, search: f, status: p, vehicleType: m, driverId: h, ids: g } = e, _ = L(), v = c(), [y, C] = s([]), [w, T] = s(0), [E, D] = s(!1), [O, k] = s(!1), [A, M] = s(!1), [N, P] = s(null), I = g ? [...g].sort().join(",") : "", R = g === void 0 ? "none" : "exact", z = o(() => I ? I.split(",") : [], [I]), B = i(async () => {
|
|
322
|
+
if (R === "exact" && z.length === 0) C([]), T(0), D(!1);
|
|
280
323
|
else {
|
|
281
|
-
k(!0),
|
|
324
|
+
k(!0), P(null);
|
|
282
325
|
try {
|
|
283
|
-
let e = await
|
|
326
|
+
let e = await r(_, l, {
|
|
284
327
|
filter: {
|
|
285
|
-
search:
|
|
286
|
-
status:
|
|
287
|
-
type:
|
|
288
|
-
driverId:
|
|
289
|
-
ids:
|
|
328
|
+
search: f || void 0,
|
|
329
|
+
status: p ? j(p) : void 0,
|
|
330
|
+
type: m?.toUpperCase(),
|
|
331
|
+
driverId: h || void 0,
|
|
332
|
+
ids: z.length > 0 ? z : void 0
|
|
290
333
|
},
|
|
291
334
|
pagination: {
|
|
292
|
-
limit:
|
|
293
|
-
offset:
|
|
335
|
+
limit: R === "exact" ? z.length : n,
|
|
336
|
+
offset: R === "exact" ? 0 : u
|
|
294
337
|
}
|
|
295
338
|
});
|
|
296
|
-
|
|
339
|
+
D(R === "none" && u + e.vehicles.length < e.vehiclesCount), T(e.vehiclesCount), C(e.vehicles.map(F));
|
|
297
340
|
} catch (e) {
|
|
298
|
-
|
|
341
|
+
P(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load vehicles"));
|
|
299
342
|
} finally {
|
|
300
343
|
k(!1);
|
|
301
344
|
}
|
|
302
345
|
}
|
|
303
346
|
}, [
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
l,
|
|
347
|
+
_,
|
|
348
|
+
n,
|
|
307
349
|
u,
|
|
350
|
+
f,
|
|
351
|
+
p,
|
|
308
352
|
m,
|
|
309
353
|
h,
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
j(!0), N(null);
|
|
354
|
+
R,
|
|
355
|
+
z
|
|
356
|
+
]), V = i(async () => {
|
|
357
|
+
if (R === "exact" || !E || O || A) return;
|
|
358
|
+
let e = u + y.length;
|
|
359
|
+
M(!0), P(null);
|
|
317
360
|
try {
|
|
318
|
-
let
|
|
361
|
+
let t = await r(_, l, {
|
|
319
362
|
filter: {
|
|
320
|
-
search:
|
|
321
|
-
status:
|
|
322
|
-
type:
|
|
323
|
-
driverId:
|
|
363
|
+
search: f || void 0,
|
|
364
|
+
status: p ? j(p) : void 0,
|
|
365
|
+
type: m?.toUpperCase(),
|
|
366
|
+
driverId: h || void 0
|
|
324
367
|
},
|
|
325
368
|
pagination: {
|
|
326
|
-
limit:
|
|
369
|
+
limit: n,
|
|
327
370
|
offset: e
|
|
328
371
|
}
|
|
329
|
-
}),
|
|
330
|
-
|
|
372
|
+
}), i = t.vehicles.map(F);
|
|
373
|
+
T(t.vehiclesCount), D(e + i.length < t.vehiclesCount), C((e) => {
|
|
331
374
|
let t = new Set(e.map((e) => e.id));
|
|
332
|
-
return [...e, ...
|
|
375
|
+
return [...e, ...i.filter((e) => !t.has(e.id))];
|
|
333
376
|
});
|
|
334
377
|
} catch (e) {
|
|
335
|
-
|
|
378
|
+
P(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load more vehicles"));
|
|
336
379
|
} finally {
|
|
337
|
-
|
|
380
|
+
M(!1);
|
|
338
381
|
}
|
|
339
382
|
}, [
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
383
|
+
h,
|
|
384
|
+
_,
|
|
385
|
+
E,
|
|
386
|
+
R,
|
|
387
|
+
O,
|
|
345
388
|
A,
|
|
346
|
-
|
|
347
|
-
l,
|
|
389
|
+
n,
|
|
348
390
|
u,
|
|
391
|
+
f,
|
|
392
|
+
p,
|
|
349
393
|
m,
|
|
350
|
-
h,
|
|
351
394
|
y.length
|
|
352
395
|
]);
|
|
353
|
-
return
|
|
354
|
-
|
|
355
|
-
}, [
|
|
396
|
+
return a(() => {
|
|
397
|
+
B();
|
|
398
|
+
}, [B]), {
|
|
356
399
|
vehicles: y,
|
|
357
|
-
totalVehicles:
|
|
358
|
-
hasMore:
|
|
359
|
-
isLoading:
|
|
400
|
+
totalVehicles: w,
|
|
401
|
+
hasMore: E,
|
|
402
|
+
isLoading: O,
|
|
360
403
|
isLoadingMore: A,
|
|
361
|
-
error:
|
|
362
|
-
refetch:
|
|
363
|
-
|
|
364
|
-
}, [
|
|
365
|
-
loadMore:
|
|
366
|
-
updateVehicleStatus:
|
|
367
|
-
let
|
|
404
|
+
error: N,
|
|
405
|
+
refetch: i(() => {
|
|
406
|
+
B();
|
|
407
|
+
}, [B]),
|
|
408
|
+
loadMore: V,
|
|
409
|
+
updateVehicleStatus: i(async (e, t) => {
|
|
410
|
+
let n = F((await r(_, x, {
|
|
368
411
|
id: e,
|
|
369
|
-
status:
|
|
412
|
+
status: j(t)
|
|
370
413
|
})).updateVehicleStatus);
|
|
371
|
-
return
|
|
372
|
-
}, [
|
|
373
|
-
assignDriver:
|
|
374
|
-
await
|
|
414
|
+
return C((t) => t.map((t) => t.id === e ? n : t)), n;
|
|
415
|
+
}, [_]),
|
|
416
|
+
assignDriver: i(async (e, n) => {
|
|
417
|
+
await r(_, S, {
|
|
375
418
|
id: n,
|
|
376
419
|
vehicleId: e
|
|
377
420
|
});
|
|
378
|
-
let
|
|
379
|
-
if (!
|
|
380
|
-
let
|
|
381
|
-
return
|
|
382
|
-
}, [v]),
|
|
383
|
-
deleteVehicle:
|
|
384
|
-
await
|
|
385
|
-
}, [
|
|
421
|
+
let i = await r(_, d, { id: e });
|
|
422
|
+
if (!i.vehicle) throw Error("Vehicle not found");
|
|
423
|
+
let a = F(i.vehicle);
|
|
424
|
+
return C((t) => t.map((t) => t.id === e ? a : t)), t(v, e, n, _.workspaceId), a;
|
|
425
|
+
}, [v, _]),
|
|
426
|
+
deleteVehicle: i(async (e) => {
|
|
427
|
+
await r(_, b, { id: e }), C((t) => t.filter((t) => t.id !== e));
|
|
428
|
+
}, [_])
|
|
386
429
|
};
|
|
387
430
|
}
|
|
388
|
-
function
|
|
389
|
-
let
|
|
390
|
-
if (!e)
|
|
431
|
+
function B(e) {
|
|
432
|
+
let t = L(), o = c(), [l, u] = s(null), [f, h] = s(!1), [g, _] = s(null), v = i(async () => {
|
|
433
|
+
if (!e) u(null);
|
|
391
434
|
else {
|
|
392
|
-
|
|
435
|
+
h(!0), _(null);
|
|
393
436
|
try {
|
|
394
|
-
let n = await t
|
|
437
|
+
let n = await r(t, d, { id: e });
|
|
395
438
|
if (n.vehicle && (n.vehicle.id !== e || ![
|
|
396
439
|
"ACTIVE",
|
|
397
440
|
"IN_TRANSIT",
|
|
@@ -399,162 +442,202 @@ function j(e) {
|
|
|
399
442
|
"INACTIVE",
|
|
400
443
|
"DECOMMISSIONED"
|
|
401
444
|
].includes(n.vehicle.status))) throw Error("Vehicle status could not be verified.");
|
|
402
|
-
|
|
445
|
+
u(n.vehicle ? F(n.vehicle) : null);
|
|
403
446
|
} catch (e) {
|
|
404
|
-
|
|
447
|
+
_(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load vehicle"));
|
|
405
448
|
} finally {
|
|
406
|
-
|
|
449
|
+
h(!1);
|
|
407
450
|
}
|
|
408
451
|
}
|
|
409
|
-
}, [
|
|
410
|
-
return
|
|
411
|
-
|
|
412
|
-
}, [
|
|
413
|
-
vehicle:
|
|
414
|
-
isLoading:
|
|
415
|
-
error:
|
|
416
|
-
refetch:
|
|
417
|
-
|
|
418
|
-
}, [
|
|
452
|
+
}, [t, e]);
|
|
453
|
+
return a(() => {
|
|
454
|
+
v();
|
|
455
|
+
}, [v]), {
|
|
456
|
+
vehicle: l,
|
|
457
|
+
isLoading: f,
|
|
458
|
+
error: g,
|
|
459
|
+
refetch: i(() => {
|
|
460
|
+
v();
|
|
461
|
+
}, [v]),
|
|
462
|
+
addMaintenanceLog: i(async (i) => {
|
|
463
|
+
e && (await r(t, p, { input: {
|
|
464
|
+
...i,
|
|
465
|
+
vehicleId: e
|
|
466
|
+
} }), n(o, e, t.workspaceId, i.serviceType), await v());
|
|
467
|
+
}, [
|
|
468
|
+
o,
|
|
469
|
+
t,
|
|
470
|
+
v,
|
|
471
|
+
e
|
|
472
|
+
]),
|
|
473
|
+
removeMaintenanceLog: i(async (e) => {
|
|
474
|
+
await r(t, m, { id: e }), await v();
|
|
475
|
+
}, [t, v])
|
|
419
476
|
};
|
|
420
477
|
}
|
|
421
|
-
function
|
|
422
|
-
let { limit:
|
|
423
|
-
|
|
478
|
+
function V(e = {}) {
|
|
479
|
+
let { limit: t = 20, offset: n = 0, status: o, search: c, licenseClass: l, vehicleId: d } = e, f = L(), [p, m] = s([]), [h, g] = s(0), [_, v] = s(!1), [y, b] = s(!1), [x, w] = s(!1), [T, E] = s(null), D = i(async () => {
|
|
480
|
+
b(!0), E(null);
|
|
424
481
|
try {
|
|
425
|
-
let e = await
|
|
482
|
+
let e = await r(f, u, {
|
|
426
483
|
filter: {
|
|
427
|
-
status:
|
|
428
|
-
search:
|
|
429
|
-
licenseClass:
|
|
484
|
+
status: o ? N(o) : void 0,
|
|
485
|
+
search: c || void 0,
|
|
486
|
+
licenseClass: l || void 0,
|
|
430
487
|
vehicleId: d || void 0
|
|
431
488
|
},
|
|
432
489
|
pagination: {
|
|
433
|
-
limit:
|
|
434
|
-
offset:
|
|
490
|
+
limit: t,
|
|
491
|
+
offset: n
|
|
435
492
|
}
|
|
436
493
|
});
|
|
437
|
-
|
|
494
|
+
v(n + e.drivers.length < e.driversCount), g(e.driversCount), m(e.drivers.map(I));
|
|
438
495
|
} catch (e) {
|
|
439
|
-
|
|
496
|
+
E(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load drivers"));
|
|
440
497
|
} finally {
|
|
441
|
-
|
|
498
|
+
b(!1);
|
|
442
499
|
}
|
|
443
500
|
}, [
|
|
444
501
|
f,
|
|
445
|
-
|
|
502
|
+
t,
|
|
503
|
+
n,
|
|
446
504
|
o,
|
|
447
505
|
c,
|
|
448
506
|
l,
|
|
449
|
-
u,
|
|
450
507
|
d
|
|
451
|
-
]),
|
|
452
|
-
if (!
|
|
453
|
-
let e =
|
|
454
|
-
|
|
508
|
+
]), O = i(async () => {
|
|
509
|
+
if (!_ || y || x) return;
|
|
510
|
+
let e = n + p.length;
|
|
511
|
+
w(!0), E(null);
|
|
455
512
|
try {
|
|
456
|
-
let n = await
|
|
513
|
+
let n = await r(f, u, {
|
|
457
514
|
filter: {
|
|
458
|
-
status:
|
|
459
|
-
search:
|
|
460
|
-
licenseClass:
|
|
515
|
+
status: o ? N(o) : void 0,
|
|
516
|
+
search: c || void 0,
|
|
517
|
+
licenseClass: l || void 0,
|
|
461
518
|
vehicleId: d || void 0
|
|
462
519
|
},
|
|
463
520
|
pagination: {
|
|
464
|
-
limit:
|
|
521
|
+
limit: t,
|
|
465
522
|
offset: e
|
|
466
523
|
}
|
|
467
|
-
}),
|
|
468
|
-
|
|
524
|
+
}), i = n.drivers.map(I);
|
|
525
|
+
g(n.driversCount), v(e + i.length < n.driversCount), m((e) => {
|
|
469
526
|
let t = new Set(e.map((e) => e.id));
|
|
470
|
-
return [...e, ...
|
|
527
|
+
return [...e, ...i.filter((e) => !t.has(e.id))];
|
|
471
528
|
});
|
|
472
529
|
} catch (e) {
|
|
473
|
-
|
|
530
|
+
E(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load more drivers"));
|
|
474
531
|
} finally {
|
|
475
|
-
|
|
532
|
+
w(!1);
|
|
476
533
|
}
|
|
477
534
|
}, [
|
|
478
|
-
|
|
535
|
+
p.length,
|
|
479
536
|
f,
|
|
537
|
+
_,
|
|
480
538
|
y,
|
|
481
539
|
x,
|
|
482
|
-
|
|
483
|
-
i,
|
|
484
|
-
u,
|
|
485
|
-
o,
|
|
540
|
+
t,
|
|
486
541
|
l,
|
|
542
|
+
n,
|
|
487
543
|
c,
|
|
544
|
+
o,
|
|
488
545
|
d
|
|
489
546
|
]);
|
|
490
|
-
return
|
|
491
|
-
|
|
492
|
-
}, [
|
|
493
|
-
drivers:
|
|
494
|
-
totalDrivers:
|
|
495
|
-
hasMore:
|
|
496
|
-
isLoading:
|
|
497
|
-
isLoadingMore:
|
|
498
|
-
error:
|
|
499
|
-
refetch:
|
|
500
|
-
|
|
501
|
-
}, [
|
|
502
|
-
loadMore:
|
|
503
|
-
updateDriverStatus:
|
|
504
|
-
let
|
|
547
|
+
return a(() => {
|
|
548
|
+
D();
|
|
549
|
+
}, [D]), {
|
|
550
|
+
drivers: p,
|
|
551
|
+
totalDrivers: h,
|
|
552
|
+
hasMore: _,
|
|
553
|
+
isLoading: y,
|
|
554
|
+
isLoadingMore: x,
|
|
555
|
+
error: T,
|
|
556
|
+
refetch: i(() => {
|
|
557
|
+
D();
|
|
558
|
+
}, [D]),
|
|
559
|
+
loadMore: O,
|
|
560
|
+
updateDriverStatus: i(async (e, t) => {
|
|
561
|
+
let n = I((await r(f, C, {
|
|
505
562
|
id: e,
|
|
506
|
-
status:
|
|
563
|
+
status: N(t)
|
|
507
564
|
})).updateDriverStatus);
|
|
508
|
-
return
|
|
565
|
+
return m((t) => t.map((t) => t.id === e ? n : t)), n;
|
|
509
566
|
}, [f]),
|
|
510
|
-
assignVehicle:
|
|
511
|
-
let
|
|
567
|
+
assignVehicle: i(async (e, t) => {
|
|
568
|
+
let n = I((await r(f, S, {
|
|
512
569
|
id: e,
|
|
513
|
-
vehicleId:
|
|
570
|
+
vehicleId: t
|
|
514
571
|
})).assignDriverVehicle);
|
|
515
|
-
return
|
|
572
|
+
return m((t) => t.map((t) => t.id === e ? n : t)), n;
|
|
516
573
|
}, [f])
|
|
517
574
|
};
|
|
518
575
|
}
|
|
519
|
-
function
|
|
520
|
-
let
|
|
521
|
-
if (!e)
|
|
576
|
+
function H(e) {
|
|
577
|
+
let t = L(), [n, o] = s(null), [c, l] = s(!1), [u, d] = s(null), p = i(async () => {
|
|
578
|
+
if (!e) o(null);
|
|
522
579
|
else {
|
|
523
|
-
|
|
580
|
+
l(!0), d(null);
|
|
524
581
|
try {
|
|
525
|
-
let n = await t
|
|
526
|
-
|
|
582
|
+
let n = await r(t, f, { id: e });
|
|
583
|
+
o(n.driver ? I(n.driver) : null);
|
|
527
584
|
} catch (e) {
|
|
528
|
-
|
|
585
|
+
d(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load driver"));
|
|
529
586
|
} finally {
|
|
530
|
-
|
|
587
|
+
l(!1);
|
|
531
588
|
}
|
|
532
589
|
}
|
|
533
|
-
}, [e,
|
|
534
|
-
return
|
|
590
|
+
}, [e, t]);
|
|
591
|
+
return a(() => {
|
|
535
592
|
p();
|
|
536
593
|
}, [p]), {
|
|
537
|
-
driver:
|
|
594
|
+
driver: n,
|
|
538
595
|
isLoading: c,
|
|
539
|
-
error:
|
|
540
|
-
refetch:
|
|
596
|
+
error: u,
|
|
597
|
+
refetch: i(() => {
|
|
541
598
|
p();
|
|
542
|
-
}, [p])
|
|
599
|
+
}, [p]),
|
|
600
|
+
addShift: i(async (n) => {
|
|
601
|
+
e && (await r(t, h, { input: {
|
|
602
|
+
...n,
|
|
603
|
+
driverId: e
|
|
604
|
+
} }), await p());
|
|
605
|
+
}, [
|
|
606
|
+
e,
|
|
607
|
+
t,
|
|
608
|
+
p
|
|
609
|
+
]),
|
|
610
|
+
removeShift: i(async (e) => {
|
|
611
|
+
await r(t, g, { id: e }), await p();
|
|
612
|
+
}, [t, p]),
|
|
613
|
+
addComplianceRecord: i(async (n) => {
|
|
614
|
+
e && (await r(t, _, { input: {
|
|
615
|
+
...n,
|
|
616
|
+
driverId: e
|
|
617
|
+
} }), await p());
|
|
618
|
+
}, [
|
|
619
|
+
e,
|
|
620
|
+
t,
|
|
621
|
+
p
|
|
622
|
+
]),
|
|
623
|
+
removeComplianceRecord: i(async (e) => {
|
|
624
|
+
await r(t, v, { id: e }), await p();
|
|
625
|
+
}, [t, p])
|
|
543
626
|
};
|
|
544
627
|
}
|
|
545
|
-
function
|
|
546
|
-
let e =
|
|
628
|
+
function U() {
|
|
629
|
+
let e = L(), [t, n] = s({
|
|
547
630
|
onBreak: 0,
|
|
548
631
|
offDuty: 0,
|
|
549
632
|
inactive: 0
|
|
550
|
-
}), [
|
|
633
|
+
}), [o, c] = s(!1), [l, u] = s(null), d = i(async () => {
|
|
551
634
|
c(!0), u(null);
|
|
552
635
|
try {
|
|
553
|
-
let
|
|
554
|
-
|
|
555
|
-
onBreak:
|
|
556
|
-
offDuty:
|
|
557
|
-
inactive:
|
|
636
|
+
let t = await r(e, O);
|
|
637
|
+
n({
|
|
638
|
+
onBreak: t.onBreak,
|
|
639
|
+
offDuty: t.offDuty,
|
|
640
|
+
inactive: t.inactive
|
|
558
641
|
});
|
|
559
642
|
} catch (e) {
|
|
560
643
|
u(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load driver status counts"));
|
|
@@ -562,51 +645,51 @@ function P() {
|
|
|
562
645
|
c(!1);
|
|
563
646
|
}
|
|
564
647
|
}, [e]);
|
|
565
|
-
return
|
|
648
|
+
return a(() => {
|
|
566
649
|
d();
|
|
567
650
|
}, [d]), {
|
|
568
|
-
counts:
|
|
569
|
-
isLoading:
|
|
651
|
+
counts: t,
|
|
652
|
+
isLoading: o,
|
|
570
653
|
error: l,
|
|
571
|
-
refetch:
|
|
654
|
+
refetch: i(() => {
|
|
572
655
|
d();
|
|
573
656
|
}, [d])
|
|
574
657
|
};
|
|
575
658
|
}
|
|
576
|
-
function
|
|
577
|
-
let
|
|
578
|
-
if (!e)
|
|
659
|
+
function W(e) {
|
|
660
|
+
let t = L(), [n, o] = s([]), [c, l] = s(!1), [d, f] = s(null), p = i(async () => {
|
|
661
|
+
if (!e) o([]);
|
|
579
662
|
else {
|
|
580
|
-
|
|
663
|
+
l(!0), f(null);
|
|
581
664
|
try {
|
|
582
|
-
let n = await t
|
|
665
|
+
let n = await r(t, u, {
|
|
583
666
|
filter: { vehicleId: e },
|
|
584
667
|
pagination: {
|
|
585
668
|
limit: 25,
|
|
586
669
|
offset: 0
|
|
587
670
|
}
|
|
588
671
|
});
|
|
589
|
-
|
|
672
|
+
o(n.drivers.map(I));
|
|
590
673
|
} catch (e) {
|
|
591
674
|
f(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load assigned driver"));
|
|
592
675
|
} finally {
|
|
593
|
-
|
|
676
|
+
l(!1);
|
|
594
677
|
}
|
|
595
678
|
}
|
|
596
|
-
}, [
|
|
597
|
-
return
|
|
679
|
+
}, [t, e]);
|
|
680
|
+
return a(() => {
|
|
598
681
|
p();
|
|
599
682
|
}, [p]), {
|
|
600
|
-
drivers:
|
|
601
|
-
isLoading:
|
|
683
|
+
drivers: n,
|
|
684
|
+
isLoading: c,
|
|
602
685
|
error: d,
|
|
603
|
-
refetch:
|
|
686
|
+
refetch: i(() => {
|
|
604
687
|
p();
|
|
605
688
|
}, [p])
|
|
606
689
|
};
|
|
607
690
|
}
|
|
608
|
-
function
|
|
609
|
-
let e =
|
|
691
|
+
function G() {
|
|
692
|
+
let e = L(), [t, n] = s({
|
|
610
693
|
totalVehicles: 0,
|
|
611
694
|
totalDrivers: 0,
|
|
612
695
|
vehiclesByStatus: {
|
|
@@ -624,28 +707,28 @@ function I() {
|
|
|
624
707
|
avgFuelLevel: 0,
|
|
625
708
|
avgDriverRating: 0,
|
|
626
709
|
utilization: 0
|
|
627
|
-
}), [
|
|
710
|
+
}), [o, c] = s(!1), [l, u] = s(null), d = i(async () => {
|
|
628
711
|
c(!0), u(null);
|
|
629
712
|
try {
|
|
630
|
-
let
|
|
631
|
-
|
|
632
|
-
totalVehicles:
|
|
633
|
-
totalDrivers:
|
|
713
|
+
let t = await r(e, k);
|
|
714
|
+
n({
|
|
715
|
+
totalVehicles: t.fleetStats.totalVehicles,
|
|
716
|
+
totalDrivers: t.fleetStats.totalDrivers,
|
|
634
717
|
vehiclesByStatus: {
|
|
635
|
-
available:
|
|
636
|
-
assigned:
|
|
637
|
-
maintenance:
|
|
638
|
-
out_of_service: Math.max(
|
|
718
|
+
available: t.fleetStats.activeVehicles,
|
|
719
|
+
assigned: t.fleetStats.inTransitVehicles,
|
|
720
|
+
maintenance: t.fleetStats.maintenanceVehicles,
|
|
721
|
+
out_of_service: Math.max(t.fleetStats.totalVehicles - t.fleetStats.activeVehicles - t.fleetStats.inTransitVehicles - t.fleetStats.maintenanceVehicles, 0)
|
|
639
722
|
},
|
|
640
723
|
driversByStatus: {
|
|
641
|
-
available:
|
|
642
|
-
busy:
|
|
643
|
-
offline: Math.max(
|
|
724
|
+
available: t.fleetStats.availableDrivers,
|
|
725
|
+
busy: t.fleetStats.onDeliveryDrivers,
|
|
726
|
+
offline: Math.max(t.fleetStats.totalDrivers - t.fleetStats.availableDrivers - t.fleetStats.onDeliveryDrivers, 0),
|
|
644
727
|
on_break: 0
|
|
645
728
|
},
|
|
646
729
|
avgFuelLevel: 0,
|
|
647
|
-
avgDriverRating:
|
|
648
|
-
utilization:
|
|
730
|
+
avgDriverRating: t.fleetStats.avgDriverRating,
|
|
731
|
+
utilization: t.fleetStats.totalVehicles > 0 ? t.fleetStats.activeVehicles / t.fleetStats.totalVehicles * 100 : 0
|
|
649
732
|
});
|
|
650
733
|
} catch (e) {
|
|
651
734
|
u(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load fleet stats"));
|
|
@@ -653,15 +736,15 @@ function I() {
|
|
|
653
736
|
c(!1);
|
|
654
737
|
}
|
|
655
738
|
}, [e]);
|
|
656
|
-
return
|
|
739
|
+
return a(() => {
|
|
657
740
|
d();
|
|
658
741
|
}, [d]), {
|
|
659
|
-
stats:
|
|
660
|
-
isLoading:
|
|
742
|
+
stats: t,
|
|
743
|
+
isLoading: o,
|
|
661
744
|
error: l,
|
|
662
|
-
refetch:
|
|
745
|
+
refetch: i(() => {
|
|
663
746
|
d();
|
|
664
747
|
}, [d])
|
|
665
748
|
};
|
|
666
749
|
}
|
|
667
|
-
export {
|
|
750
|
+
export { I as mapDriver, F as mapVehicle, N as toApiDriverStatus, j as toApiVehicleStatus, H as useDriver, U as useDriverStatusCounts, V as useDrivers, R as useFleet, G as useFleetStats, B as useVehicle, W as useVehicleDrivers, z as useVehicles };
|