@burdenoff/microfe-movethewheels 2026.925.1 → 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 +31 -31
- package/dist/constants/index.js +19 -5
- package/dist/hooks/useCustomers.js +0 -3
- package/dist/hooks/useFleet.js +197 -175
- package/dist/hooks/useInventory.js +144 -145
- package/dist/hooks/useRoutes.js +5 -14
- package/dist/movethewheels/components/StatusBadge.d.ts +3 -1
- package/dist/movethewheels/constants/index.d.ts +2 -0
- package/dist/movethewheels/hooks/useFleet.d.ts +53 -1
- package/dist/movethewheels/hooks/useInventory.d.ts +10 -0
- package/dist/movethewheels/types/index.d.ts +29 -108
- package/dist/node_modules/lucide-react/dist/esm/icons/sticky-note.js +11 -0
- package/dist/node_modules/lucide-react/dist/esm/icons/user-x.js +30 -0
- package/dist/pages/CustomerDetailsPage.js +666 -344
- package/dist/pages/CustomersPage.js +71 -80
- package/dist/pages/DriverDetailsPage.js +702 -421
- package/dist/pages/DriversPage.js +106 -117
- package/dist/pages/FleetPage.js +5 -13
- package/dist/pages/InventoryPage.js +4 -4
- package/dist/pages/OrderDetailsPage.js +279 -274
- package/dist/pages/RouteDetailsPage.js +300 -263
- package/dist/pages/RoutesPage.js +130 -67
- package/dist/pages/VehicleDetailsPage.js +562 -287
- 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 +16 -2
- package/src/movethewheels/constants/index.ts +21 -0
- package/src/movethewheels/hooks/useCustomers.ts +0 -3
- package/src/movethewheels/hooks/useFleet.ts +236 -62
- 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/DriverDetailsPage.tsx +516 -156
- package/src/movethewheels/pages/DriversPage.tsx +28 -11
- package/src/movethewheels/pages/FleetPage.tsx +9 -11
- package/src/movethewheels/pages/InventoryPage.tsx +14 -5
- package/src/movethewheels/pages/OrderDetailsPage.tsx +12 -7
- package/src/movethewheels/pages/RouteDetailsPage.tsx +89 -41
- package/src/movethewheels/pages/RoutesPage.tsx +66 -2
- package/src/movethewheels/pages/VehicleDetailsPage.tsx +282 -20
- 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 +30 -108
package/dist/hooks/useFleet.js
CHANGED
|
@@ -2,40 +2,57 @@ 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 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 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 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 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 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";
|
|
26
28
|
case "ON_BREAK": return "on_break";
|
|
29
|
+
case "INACTIVE": return "inactive";
|
|
27
30
|
default: return "offline";
|
|
28
31
|
}
|
|
29
32
|
}
|
|
30
|
-
function
|
|
33
|
+
function C(e) {
|
|
31
34
|
switch (e) {
|
|
32
35
|
case "available": return "AVAILABLE";
|
|
33
36
|
case "busy": return "ON_DELIVERY";
|
|
34
37
|
case "on_break": return "ON_BREAK";
|
|
38
|
+
case "inactive": return "INACTIVE";
|
|
35
39
|
default: return "OFF_DUTY";
|
|
36
40
|
}
|
|
37
41
|
}
|
|
38
|
-
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) {
|
|
39
56
|
return {
|
|
40
57
|
id: e.id,
|
|
41
58
|
vehicleNumber: e.vehicleNumber,
|
|
@@ -44,30 +61,27 @@ function C(e) {
|
|
|
44
61
|
model: e.model ?? "",
|
|
45
62
|
licensePlate: e.licensePlate ?? "",
|
|
46
63
|
ownershipType: e.ownershipType ?? void 0,
|
|
47
|
-
year: e.year ??
|
|
64
|
+
year: e.year ?? void 0,
|
|
48
65
|
capacity: {
|
|
49
66
|
weight: 0,
|
|
50
67
|
volume: 0,
|
|
51
68
|
...e.capacity ?? {}
|
|
52
69
|
},
|
|
53
|
-
status:
|
|
70
|
+
status: b(e.status),
|
|
54
71
|
driverId: void 0,
|
|
55
|
-
currentLocation: e.currentLocation
|
|
56
|
-
latitude: Number(e.currentLocation.latitude ?? 0),
|
|
57
|
-
longitude: Number(e.currentLocation.longitude ?? 0),
|
|
58
|
-
address: e.currentLocation.address ?? void 0,
|
|
59
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
60
|
-
} : void 0,
|
|
72
|
+
currentLocation: w(e.currentLocation),
|
|
61
73
|
lastMaintenance: e.lastServiceDate ? new Date(e.lastServiceDate) : void 0,
|
|
62
74
|
nextMaintenance: e.nextServiceDueDate ? new Date(e.nextServiceDueDate) : void 0,
|
|
63
75
|
nextMaintenanceMileage: e.nextServiceDueMileage ?? void 0,
|
|
76
|
+
fuelType: e.fuelType ?? void 0,
|
|
77
|
+
fuelEfficiencyLPer100Km: e.fuelEfficiencyLPer100Km ?? void 0,
|
|
64
78
|
fuelLevel: e.fuelLevel ?? void 0,
|
|
65
79
|
mileage: e.mileage ?? void 0,
|
|
66
80
|
documents: [],
|
|
67
81
|
createdAt: new Date(e.createdAt)
|
|
68
82
|
};
|
|
69
83
|
}
|
|
70
|
-
function
|
|
84
|
+
function E(e) {
|
|
71
85
|
return {
|
|
72
86
|
id: e.id,
|
|
73
87
|
userId: e.userId ?? e.id,
|
|
@@ -80,61 +94,22 @@ function w(e) {
|
|
|
80
94
|
licenseExpiry: e.licenseExpiry ? new Date(e.licenseExpiry) : /* @__PURE__ */ new Date(),
|
|
81
95
|
vehicleIds: e.vehicleId ? [e.vehicleId] : [],
|
|
82
96
|
assignedVehicle: e.vehicleId ?? void 0,
|
|
83
|
-
status:
|
|
84
|
-
currentLocation: e.currentLocation
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
specializations: [],
|
|
95
|
-
workingHours: {
|
|
96
|
-
startTime: "09:00",
|
|
97
|
-
endTime: "18:00",
|
|
98
|
-
workingDays: [
|
|
99
|
-
"Mon",
|
|
100
|
-
"Tue",
|
|
101
|
-
"Wed",
|
|
102
|
-
"Thu",
|
|
103
|
-
"Fri"
|
|
104
|
-
],
|
|
105
|
-
maxHoursPerDay: 8,
|
|
106
|
-
maxHoursPerWeek: 40,
|
|
107
|
-
currentHoursToday: 0,
|
|
108
|
-
currentHoursThisWeek: 0
|
|
109
|
-
},
|
|
110
|
-
ratings: {
|
|
111
|
-
overall: e.rating ?? 0,
|
|
112
|
-
punctuality: e.rating ?? 0,
|
|
113
|
-
communication: e.rating ?? 0,
|
|
114
|
-
carefulHandling: e.rating ?? 0,
|
|
115
|
-
professionalism: e.rating ?? 0,
|
|
116
|
-
onTimeDelivery: e.rating ?? 0,
|
|
117
|
-
totalRatings: 0
|
|
118
|
-
},
|
|
97
|
+
status: S(e.status),
|
|
98
|
+
currentLocation: w(e.currentLocation),
|
|
99
|
+
rating: e.rating ?? 0,
|
|
100
|
+
notes: e.notes ?? void 0,
|
|
101
|
+
hireDate: e.hireDate ? new Date(e.hireDate) : void 0,
|
|
102
|
+
baseSalary: e.baseSalary ?? void 0,
|
|
103
|
+
bonusYtd: e.bonusYtd ?? void 0,
|
|
104
|
+
payCurrency: e.payCurrency ?? void 0,
|
|
105
|
+
onLeaveUntil: e.onLeaveUntil ? new Date(e.onLeaveUntil) : void 0,
|
|
106
|
+
terminatedAt: e.terminatedAt ? new Date(e.terminatedAt) : void 0,
|
|
107
|
+
terminationReason: e.terminationReason ?? void 0,
|
|
119
108
|
documents: [],
|
|
120
|
-
earnings: {
|
|
121
|
-
totalEarnings: 0,
|
|
122
|
-
weeklyEarnings: 0,
|
|
123
|
-
monthlyEarnings: 0,
|
|
124
|
-
pendingPayments: 0,
|
|
125
|
-
completedDeliveries: 0,
|
|
126
|
-
bonuses: 0
|
|
127
|
-
},
|
|
128
|
-
compliance: {
|
|
129
|
-
hoursOfService: !0,
|
|
130
|
-
documentation: !0,
|
|
131
|
-
vehicleInspection: !0,
|
|
132
|
-
lastUpdate: /* @__PURE__ */ new Date()
|
|
133
|
-
},
|
|
134
109
|
createdAt: new Date(e.createdAt)
|
|
135
110
|
};
|
|
136
111
|
}
|
|
137
|
-
function
|
|
112
|
+
function D() {
|
|
138
113
|
let { apiGatewayUrl: t, authToken: n, workspaceToken: r, workspaceId: a, tenantId: o, currentUser: s } = e();
|
|
139
114
|
return i(() => ({
|
|
140
115
|
apiGatewayUrl: t,
|
|
@@ -152,178 +127,225 @@ function T() {
|
|
|
152
127
|
s?.id
|
|
153
128
|
]);
|
|
154
129
|
}
|
|
155
|
-
function
|
|
156
|
-
let { filters: c, limit: l = 20 } = e,
|
|
130
|
+
function O(e = {}) {
|
|
131
|
+
let { filters: c, limit: l = 20 } = e, d = i(() => c, [
|
|
157
132
|
c?.driverId,
|
|
158
133
|
c?.search,
|
|
159
134
|
c?.status,
|
|
160
135
|
c?.vehicleId,
|
|
161
136
|
c?.vehicleType
|
|
162
|
-
]),
|
|
163
|
-
|
|
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);
|
|
164
139
|
try {
|
|
165
|
-
let [e, n] = await Promise.all([t(
|
|
140
|
+
let [e, n] = await Promise.all([t(f, o, {
|
|
166
141
|
filter: {
|
|
167
|
-
search:
|
|
168
|
-
type:
|
|
169
|
-
status:
|
|
170
|
-
driverId:
|
|
142
|
+
search: d?.search,
|
|
143
|
+
type: d?.vehicleType?.toUpperCase(),
|
|
144
|
+
status: d?.status ? x(d.status) : void 0,
|
|
145
|
+
driverId: d?.driverId
|
|
171
146
|
},
|
|
172
147
|
pagination: {
|
|
173
148
|
limit: l,
|
|
174
149
|
offset: 0
|
|
175
150
|
}
|
|
176
|
-
}), t(
|
|
151
|
+
}), t(f, s, {
|
|
177
152
|
filter: {
|
|
178
|
-
search:
|
|
179
|
-
vehicleId:
|
|
153
|
+
search: d?.search,
|
|
154
|
+
vehicleId: d?.vehicleId
|
|
180
155
|
},
|
|
181
156
|
pagination: {
|
|
182
157
|
limit: l,
|
|
183
158
|
offset: 0
|
|
184
159
|
}
|
|
185
160
|
})]);
|
|
186
|
-
|
|
161
|
+
v(e.vehicles.map(T)), b(n.drivers.map(E));
|
|
187
162
|
} catch (e) {
|
|
188
|
-
|
|
163
|
+
O(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load fleet data"));
|
|
189
164
|
} finally {
|
|
190
|
-
|
|
165
|
+
C(!1);
|
|
191
166
|
}
|
|
192
167
|
}, [
|
|
193
|
-
u,
|
|
194
168
|
d,
|
|
169
|
+
f,
|
|
195
170
|
l
|
|
196
171
|
]);
|
|
197
172
|
r(() => {
|
|
198
|
-
|
|
199
|
-
}, [
|
|
200
|
-
let
|
|
201
|
-
|
|
202
|
-
}, [
|
|
203
|
-
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: {
|
|
204
179
|
vehicleNumber: e.vehicleNumber,
|
|
205
180
|
type: e.type,
|
|
206
181
|
make: e.make,
|
|
207
182
|
model: e.model,
|
|
208
|
-
licensePlate: e.licensePlate
|
|
183
|
+
licensePlate: e.licensePlate,
|
|
184
|
+
ownershipType: e.ownershipType,
|
|
185
|
+
year: e.year,
|
|
186
|
+
status: e.status,
|
|
187
|
+
fuelType: e.fuelType,
|
|
188
|
+
fuelEfficiencyLPer100Km: e.fuelEfficiencyLPer100Km,
|
|
189
|
+
capacity: e.capacity
|
|
209
190
|
} })).createVehicle);
|
|
210
|
-
return
|
|
211
|
-
}, [
|
|
212
|
-
let n =
|
|
191
|
+
return v((e) => [n, ...e]), n;
|
|
192
|
+
}, [f]), M = n(async (e) => {
|
|
193
|
+
let n = E((await t(f, h, { input: {
|
|
213
194
|
employeeId: e.employeeId,
|
|
214
195
|
firstName: e.firstName,
|
|
215
196
|
lastName: e.lastName,
|
|
216
197
|
email: e.email,
|
|
217
198
|
phone: e.phone,
|
|
218
|
-
licenseNumber: e.licenseNumber
|
|
199
|
+
licenseNumber: e.licenseNumber,
|
|
200
|
+
licenseClass: e.licenseClass,
|
|
201
|
+
licenseExpiry: e.licenseExpiry,
|
|
202
|
+
status: e.status,
|
|
203
|
+
vehicleId: e.vehicleId,
|
|
204
|
+
rating: e.rating,
|
|
205
|
+
notes: e.notes,
|
|
206
|
+
hireDate: e.hireDate,
|
|
207
|
+
baseSalary: e.baseSalary,
|
|
208
|
+
bonusYtd: e.bonusYtd,
|
|
209
|
+
payCurrency: e.payCurrency
|
|
219
210
|
} })).createDriver);
|
|
220
|
-
return
|
|
221
|
-
}, [
|
|
222
|
-
let r =
|
|
211
|
+
return b((e) => [n, ...e]), n;
|
|
212
|
+
}, [f]), N = n(async (e, n) => {
|
|
213
|
+
let r = T((await t(f, g, {
|
|
223
214
|
id: e,
|
|
224
215
|
input: {
|
|
225
216
|
vehicleNumber: n.vehicleNumber,
|
|
226
217
|
type: n.type,
|
|
227
218
|
make: n.make,
|
|
228
219
|
model: n.model,
|
|
229
|
-
licensePlate: n.licensePlate
|
|
220
|
+
licensePlate: n.licensePlate,
|
|
221
|
+
ownershipType: n.ownershipType,
|
|
222
|
+
year: n.year,
|
|
223
|
+
status: n.status,
|
|
224
|
+
fuelType: n.fuelType,
|
|
225
|
+
fuelEfficiencyLPer100Km: n.fuelEfficiencyLPer100Km,
|
|
226
|
+
capacity: n.capacity
|
|
230
227
|
}
|
|
231
228
|
})).updateVehicle);
|
|
232
|
-
return
|
|
233
|
-
}, [
|
|
234
|
-
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, _, {
|
|
235
232
|
id: e,
|
|
236
233
|
input: {
|
|
237
234
|
firstName: n.firstName,
|
|
238
235
|
lastName: n.lastName,
|
|
239
236
|
email: n.email,
|
|
240
237
|
phone: n.phone,
|
|
241
|
-
licenseNumber: n.licenseNumber
|
|
238
|
+
licenseNumber: n.licenseNumber,
|
|
239
|
+
licenseClass: n.licenseClass,
|
|
240
|
+
licenseExpiry: n.licenseExpiry,
|
|
241
|
+
status: n.status,
|
|
242
|
+
vehicleId: n.vehicleId,
|
|
243
|
+
rating: n.rating,
|
|
244
|
+
notes: n.notes,
|
|
245
|
+
hireDate: n.hireDate,
|
|
246
|
+
baseSalary: n.baseSalary,
|
|
247
|
+
bonusYtd: n.bonusYtd,
|
|
248
|
+
payCurrency: n.payCurrency,
|
|
249
|
+
onLeaveUntil: n.onLeaveUntil,
|
|
250
|
+
terminatedAt: n.terminatedAt,
|
|
251
|
+
terminationReason: n.terminationReason
|
|
242
252
|
}
|
|
243
253
|
})).updateDriver);
|
|
244
|
-
return
|
|
245
|
-
}, [
|
|
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]);
|
|
246
258
|
return {
|
|
247
|
-
vehicles:
|
|
248
|
-
drivers:
|
|
249
|
-
totalVehicles:
|
|
250
|
-
totalDrivers:
|
|
251
|
-
isLoading:
|
|
252
|
-
error:
|
|
253
|
-
refetch:
|
|
254
|
-
createVehicle:
|
|
255
|
-
createDriver:
|
|
256
|
-
updateVehicle:
|
|
257
|
-
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
|
|
258
271
|
};
|
|
259
272
|
}
|
|
260
|
-
function
|
|
261
|
-
let { limit: i = 20, offset: s = 0, search: c, status: l, vehicleType:
|
|
262
|
-
|
|
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);
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
E(!0), k(null);
|
|
263
280
|
try {
|
|
264
|
-
let e = await t(
|
|
281
|
+
let e = await t(g, o, {
|
|
265
282
|
filter: {
|
|
266
283
|
search: c || void 0,
|
|
267
|
-
status: l ?
|
|
268
|
-
type:
|
|
269
|
-
driverId:
|
|
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
|
|
270
288
|
},
|
|
271
289
|
pagination: {
|
|
272
|
-
limit: i,
|
|
273
|
-
offset: s
|
|
290
|
+
limit: h && h.length > 0 ? h.length : i,
|
|
291
|
+
offset: h ? 0 : s
|
|
274
292
|
}
|
|
275
293
|
});
|
|
276
|
-
|
|
294
|
+
C(s + e.vehicles.length < e.vehiclesCount), b(e.vehiclesCount), v(e.vehicles.map(T));
|
|
277
295
|
} catch (e) {
|
|
278
|
-
|
|
296
|
+
k(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load vehicles"));
|
|
279
297
|
} finally {
|
|
280
|
-
|
|
298
|
+
E(!1);
|
|
281
299
|
}
|
|
282
300
|
}, [
|
|
283
|
-
|
|
301
|
+
g,
|
|
284
302
|
i,
|
|
285
303
|
s,
|
|
286
304
|
c,
|
|
287
305
|
l,
|
|
288
|
-
|
|
289
|
-
|
|
306
|
+
p,
|
|
307
|
+
m,
|
|
308
|
+
h ? [...h].sort().join(",") : ""
|
|
290
309
|
]);
|
|
291
310
|
return r(() => {
|
|
292
|
-
|
|
293
|
-
}, [
|
|
294
|
-
vehicles:
|
|
295
|
-
totalVehicles:
|
|
296
|
-
hasMore:
|
|
297
|
-
isLoading:
|
|
298
|
-
error:
|
|
311
|
+
A();
|
|
312
|
+
}, [A]), {
|
|
313
|
+
vehicles: _,
|
|
314
|
+
totalVehicles: y,
|
|
315
|
+
hasMore: S,
|
|
316
|
+
isLoading: w,
|
|
317
|
+
error: O,
|
|
299
318
|
refetch: n(() => {
|
|
300
|
-
|
|
301
|
-
}, [
|
|
319
|
+
A();
|
|
320
|
+
}, [A]),
|
|
302
321
|
updateVehicleStatus: n(async (e, n) => {
|
|
303
|
-
let r =
|
|
322
|
+
let r = T((await t(g, d, {
|
|
304
323
|
id: e,
|
|
305
|
-
status:
|
|
324
|
+
status: x(n)
|
|
306
325
|
})).updateVehicleStatus);
|
|
307
|
-
return
|
|
308
|
-
}, [
|
|
326
|
+
return v((t) => t.map((t) => t.id === e ? r : t)), r;
|
|
327
|
+
}, [g]),
|
|
309
328
|
assignDriver: n(async (e, n) => {
|
|
310
|
-
await t(
|
|
329
|
+
await t(g, f, {
|
|
311
330
|
id: n,
|
|
312
331
|
vehicleId: e
|
|
313
332
|
});
|
|
314
|
-
let r =
|
|
333
|
+
let r = _.find((t) => t.id === e);
|
|
315
334
|
if (!r) throw Error("Vehicle not found");
|
|
316
335
|
let i = {
|
|
317
336
|
...r,
|
|
318
337
|
driverId: n,
|
|
319
338
|
status: "assigned"
|
|
320
339
|
};
|
|
321
|
-
return
|
|
322
|
-
}, [
|
|
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])
|
|
323
345
|
};
|
|
324
346
|
}
|
|
325
|
-
function
|
|
326
|
-
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 () => {
|
|
327
349
|
if (!e) {
|
|
328
350
|
s(null);
|
|
329
351
|
return;
|
|
@@ -331,7 +353,7 @@ function O(e) {
|
|
|
331
353
|
u(!0), f(null);
|
|
332
354
|
try {
|
|
333
355
|
let n = await t(i, c, { id: e });
|
|
334
|
-
s(n.vehicle ?
|
|
356
|
+
s(n.vehicle ? T(n.vehicle) : null);
|
|
335
357
|
} catch (e) {
|
|
336
358
|
f(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load vehicle"));
|
|
337
359
|
} finally {
|
|
@@ -349,27 +371,27 @@ function O(e) {
|
|
|
349
371
|
}, [p])
|
|
350
372
|
};
|
|
351
373
|
}
|
|
352
|
-
function
|
|
353
|
-
let { limit: i = 20, offset: o = 0, status: c, search: l, licenseClass: u, vehicleId:
|
|
354
|
-
|
|
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);
|
|
355
377
|
try {
|
|
356
378
|
let e = await t(m, s, {
|
|
357
379
|
filter: {
|
|
358
|
-
status: c ?
|
|
380
|
+
status: c ? C(c) : void 0,
|
|
359
381
|
search: l || void 0,
|
|
360
382
|
licenseClass: u || void 0,
|
|
361
|
-
vehicleId:
|
|
383
|
+
vehicleId: d || void 0
|
|
362
384
|
},
|
|
363
385
|
pagination: {
|
|
364
386
|
limit: i,
|
|
365
387
|
offset: o
|
|
366
388
|
}
|
|
367
389
|
});
|
|
368
|
-
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));
|
|
369
391
|
} catch (e) {
|
|
370
|
-
|
|
392
|
+
T(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load drivers"));
|
|
371
393
|
} finally {
|
|
372
|
-
|
|
394
|
+
S(!1);
|
|
373
395
|
}
|
|
374
396
|
}, [
|
|
375
397
|
m,
|
|
@@ -378,7 +400,7 @@ function k(e = {}) {
|
|
|
378
400
|
c,
|
|
379
401
|
l,
|
|
380
402
|
u,
|
|
381
|
-
|
|
403
|
+
d
|
|
382
404
|
]);
|
|
383
405
|
return r(() => {
|
|
384
406
|
O();
|
|
@@ -387,19 +409,19 @@ function k(e = {}) {
|
|
|
387
409
|
totalDrivers: _,
|
|
388
410
|
hasMore: y,
|
|
389
411
|
isLoading: x,
|
|
390
|
-
error:
|
|
412
|
+
error: w,
|
|
391
413
|
refetch: n(() => {
|
|
392
414
|
O();
|
|
393
415
|
}, [O]),
|
|
394
416
|
updateDriverStatus: n(async (e, n) => {
|
|
395
|
-
let r =
|
|
417
|
+
let r = E((await t(m, p, {
|
|
396
418
|
id: e,
|
|
397
|
-
status:
|
|
419
|
+
status: C(n)
|
|
398
420
|
})).updateDriverStatus);
|
|
399
421
|
return g((t) => t.map((t) => t.id === e ? r : t)), r;
|
|
400
422
|
}, [m]),
|
|
401
423
|
assignVehicle: n(async (e, n) => {
|
|
402
|
-
let r =
|
|
424
|
+
let r = E((await t(m, f, {
|
|
403
425
|
id: e,
|
|
404
426
|
vehicleId: n
|
|
405
427
|
})).assignDriverVehicle);
|
|
@@ -407,8 +429,8 @@ function k(e = {}) {
|
|
|
407
429
|
}, [m])
|
|
408
430
|
};
|
|
409
431
|
}
|
|
410
|
-
function
|
|
411
|
-
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 () => {
|
|
412
434
|
if (!e) {
|
|
413
435
|
s(null);
|
|
414
436
|
return;
|
|
@@ -416,7 +438,7 @@ function A(e) {
|
|
|
416
438
|
u(!0), f(null);
|
|
417
439
|
try {
|
|
418
440
|
let n = await t(i, l, { id: e });
|
|
419
|
-
s(n.driver ?
|
|
441
|
+
s(n.driver ? E(n.driver) : null);
|
|
420
442
|
} catch (e) {
|
|
421
443
|
f(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load driver"));
|
|
422
444
|
} finally {
|
|
@@ -434,15 +456,15 @@ function A(e) {
|
|
|
434
456
|
}, [p])
|
|
435
457
|
};
|
|
436
458
|
}
|
|
437
|
-
function
|
|
438
|
-
let e =
|
|
459
|
+
function N() {
|
|
460
|
+
let e = D(), [i, o] = a({
|
|
439
461
|
onBreak: 0,
|
|
440
462
|
offDuty: 0,
|
|
441
463
|
inactive: 0
|
|
442
464
|
}), [s, c] = a(!1), [l, u] = a(null), d = n(async () => {
|
|
443
465
|
c(!0), u(null);
|
|
444
466
|
try {
|
|
445
|
-
let n = await t(e,
|
|
467
|
+
let n = await t(e, v);
|
|
446
468
|
o({
|
|
447
469
|
onBreak: n.onBreak,
|
|
448
470
|
offDuty: n.offDuty,
|
|
@@ -465,8 +487,8 @@ function j() {
|
|
|
465
487
|
}, [d])
|
|
466
488
|
};
|
|
467
489
|
}
|
|
468
|
-
function
|
|
469
|
-
let i =
|
|
490
|
+
function P(e) {
|
|
491
|
+
let i = D(), [o, c] = a([]), [l, u] = a(!1), [d, f] = a(null), p = n(async () => {
|
|
470
492
|
if (!e) {
|
|
471
493
|
c([]);
|
|
472
494
|
return;
|
|
@@ -479,7 +501,7 @@ function M(e) {
|
|
|
479
501
|
limit: 25,
|
|
480
502
|
offset: 0
|
|
481
503
|
}
|
|
482
|
-
})).drivers.map(
|
|
504
|
+
})).drivers.map(E));
|
|
483
505
|
} catch (e) {
|
|
484
506
|
f(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load assigned driver"));
|
|
485
507
|
} finally {
|
|
@@ -497,8 +519,8 @@ function M(e) {
|
|
|
497
519
|
}, [p])
|
|
498
520
|
};
|
|
499
521
|
}
|
|
500
|
-
function
|
|
501
|
-
let e =
|
|
522
|
+
function F() {
|
|
523
|
+
let e = D(), [i, o] = a({
|
|
502
524
|
totalVehicles: 0,
|
|
503
525
|
totalDrivers: 0,
|
|
504
526
|
vehiclesByStatus: {
|
|
@@ -519,7 +541,7 @@ function N() {
|
|
|
519
541
|
}), [s, c] = a(!1), [l, u] = a(null), d = n(async () => {
|
|
520
542
|
c(!0), u(null);
|
|
521
543
|
try {
|
|
522
|
-
let n = await t(e,
|
|
544
|
+
let n = await t(e, y);
|
|
523
545
|
o({
|
|
524
546
|
totalVehicles: n.fleetStats.totalVehicles,
|
|
525
547
|
totalDrivers: n.fleetStats.totalDrivers,
|
|
@@ -557,4 +579,4 @@ function N() {
|
|
|
557
579
|
};
|
|
558
580
|
}
|
|
559
581
|
//#endregion
|
|
560
|
-
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 };
|