@burdenoff/microfe-movethewheels 2026.930.1 → 2026.930.2
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/hooks/useRefetchOnLeaveEdit.js +10 -0
- package/dist/movethewheels/hooks/useRefetchOnLeaveEdit.d.ts +7 -0
- package/dist/pages/DriverDetailsPage.js +238 -235
- package/dist/pages/ProductDetailsPage.js +22 -19
- package/dist/pages/RouteDetailsPage.js +274 -271
- package/dist/pages/VehicleDetailsPage.js +28 -25
- package/package.json +1 -1
- package/src/movethewheels/hooks/useRefetchOnLeaveEdit.ts +18 -0
- package/src/movethewheels/pages/DriverDetailsPage.tsx +2 -0
- package/src/movethewheels/pages/ProductDetailsPage.tsx +2 -0
- package/src/movethewheels/pages/RouteDetailsPage.tsx +2 -0
- package/src/movethewheels/pages/VehicleDetailsPage.tsx +2 -0
|
@@ -19,15 +19,16 @@ import { FormError as L } from "../components/FormError.js";
|
|
|
19
19
|
import { Notice as R, useNotice as z } from "../components/Notice.js";
|
|
20
20
|
import { formatDate as B, getInitials as V } from "../utils/formatters.js";
|
|
21
21
|
import { DocumentsCard as H } from "../components/DocumentsCard.js";
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
22
|
+
import { useRefetchOnLeaveEdit as U } from "../hooks/useRefetchOnLeaveEdit.js";
|
|
23
|
+
import { useRecordVehicleService as W } from "../hooks/useFleetIntelligence.js";
|
|
24
|
+
import { VehicleServiceCard as ee } from "../components/VehicleServiceCard.js";
|
|
24
25
|
import { useEffect as G, useState as K } from "react";
|
|
25
|
-
import { useLocation as
|
|
26
|
+
import { useLocation as te, useParams as ne } from "react-router";
|
|
26
27
|
import { jsx as q, jsxs as J } from "react/jsx-runtime";
|
|
27
|
-
import { useI18n as
|
|
28
|
-
import { EmphasisPanel as Y, NextSteps as
|
|
28
|
+
import { useI18n as re } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
|
|
29
|
+
import { EmphasisPanel as Y, NextSteps as ie, PagePurpose as X, ResponsiveDialog as Z, ResponsiveDialogContent as Q, ResponsiveDialogDescription as $, ResponsiveDialogFooter as ae, ResponsiveDialogHeader as oe, ResponsiveDialogTitle as se } from "@burdenoff/fe-libs/ui";
|
|
29
30
|
//#region src/movethewheels/pages/VehicleDetailsPage.tsx
|
|
30
|
-
var
|
|
31
|
+
var ce = [
|
|
31
32
|
{
|
|
32
33
|
value: "TRUCK",
|
|
33
34
|
label: "Truck"
|
|
@@ -60,10 +61,10 @@ var se = [
|
|
|
60
61
|
value: "DRONE",
|
|
61
62
|
label: "Drone"
|
|
62
63
|
}
|
|
63
|
-
],
|
|
64
|
+
], le = Object.entries(P).map(([e, t]) => ({
|
|
64
65
|
value: e,
|
|
65
66
|
label: t
|
|
66
|
-
})),
|
|
67
|
+
})), ue = [
|
|
67
68
|
{
|
|
68
69
|
value: "DIESEL",
|
|
69
70
|
label: "Diesel"
|
|
@@ -84,7 +85,7 @@ var se = [
|
|
|
84
85
|
value: "HYBRID",
|
|
85
86
|
label: "Hybrid"
|
|
86
87
|
}
|
|
87
|
-
],
|
|
88
|
+
], de = [
|
|
88
89
|
{
|
|
89
90
|
value: "owned",
|
|
90
91
|
label: "Owned"
|
|
@@ -98,7 +99,7 @@ var se = [
|
|
|
98
99
|
label: "Rented"
|
|
99
100
|
}
|
|
100
101
|
];
|
|
101
|
-
function
|
|
102
|
+
function fe({ editId: t }) {
|
|
102
103
|
let { basePath: n, navigate: r } = d(), { createVehicle: i, updateVehicle: o, deleteVehicle: l } = p(), { vehicle: h } = m(t), g = !!t, [_, T] = K({
|
|
103
104
|
vehicleNumber: "",
|
|
104
105
|
type: "VAN",
|
|
@@ -240,7 +241,7 @@ function de({ editId: t }) {
|
|
|
240
241
|
children: [/* @__PURE__ */ q(k, {
|
|
241
242
|
id: "type",
|
|
242
243
|
children: /* @__PURE__ */ q(A, {})
|
|
243
|
-
}), /* @__PURE__ */ q(D, { children:
|
|
244
|
+
}), /* @__PURE__ */ q(D, { children: ce.map((e) => /* @__PURE__ */ q(O, {
|
|
244
245
|
value: e.value,
|
|
245
246
|
children: e.label
|
|
246
247
|
}, e.value)) })]
|
|
@@ -314,7 +315,7 @@ function de({ editId: t }) {
|
|
|
314
315
|
children: [/* @__PURE__ */ q(k, {
|
|
315
316
|
id: "ownershipType",
|
|
316
317
|
children: /* @__PURE__ */ q(A, { placeholder: "Select ownership" })
|
|
317
|
-
}), /* @__PURE__ */ q(D, { children:
|
|
318
|
+
}), /* @__PURE__ */ q(D, { children: de.map((e) => /* @__PURE__ */ q(O, {
|
|
318
319
|
value: e.value,
|
|
319
320
|
children: e.label
|
|
320
321
|
}, e.value)) })]
|
|
@@ -352,7 +353,7 @@ function de({ editId: t }) {
|
|
|
352
353
|
children: [/* @__PURE__ */ q(k, {
|
|
353
354
|
id: "vehicleStatus",
|
|
354
355
|
children: /* @__PURE__ */ q(A, {})
|
|
355
|
-
}), /* @__PURE__ */ q(D, { children:
|
|
356
|
+
}), /* @__PURE__ */ q(D, { children: le.map((e) => /* @__PURE__ */ q(O, {
|
|
356
357
|
value: e.value,
|
|
357
358
|
children: e.label
|
|
358
359
|
}, e.value)) })]
|
|
@@ -370,7 +371,7 @@ function de({ editId: t }) {
|
|
|
370
371
|
}), /* @__PURE__ */ J(E, {
|
|
371
372
|
value: _.fuelType || void 0,
|
|
372
373
|
onValueChange: (e) => {
|
|
373
|
-
let t =
|
|
374
|
+
let t = ue.find((t) => t.value === e)?.value;
|
|
374
375
|
T((e) => ({
|
|
375
376
|
...e,
|
|
376
377
|
fuelType: t ?? ""
|
|
@@ -379,7 +380,7 @@ function de({ editId: t }) {
|
|
|
379
380
|
children: [/* @__PURE__ */ q(k, {
|
|
380
381
|
id: "fuelType",
|
|
381
382
|
children: /* @__PURE__ */ q(A, { placeholder: "Select fuel type" })
|
|
382
|
-
}), /* @__PURE__ */ q(D, { children:
|
|
383
|
+
}), /* @__PURE__ */ q(D, { children: ue.map((e) => /* @__PURE__ */ q(O, {
|
|
383
384
|
value: e.value,
|
|
384
385
|
children: e.label
|
|
385
386
|
}, e.value)) })]
|
|
@@ -484,7 +485,7 @@ function de({ editId: t }) {
|
|
|
484
485
|
open: I,
|
|
485
486
|
onOpenChange: R,
|
|
486
487
|
children: /* @__PURE__ */ J(Q, { children: [
|
|
487
|
-
/* @__PURE__ */ J(
|
|
488
|
+
/* @__PURE__ */ J(oe, { children: [/* @__PURE__ */ q(se, { children: "Delete this vehicle?" }), /* @__PURE__ */ J($, { children: [
|
|
488
489
|
"This removes ",
|
|
489
490
|
_.vehicleNumber || "this vehicle",
|
|
490
491
|
" from the active fleet. It cannot be undone from here."
|
|
@@ -493,7 +494,7 @@ function de({ editId: t }) {
|
|
|
493
494
|
className: "px-1",
|
|
494
495
|
children: /* @__PURE__ */ q(L, { message: V })
|
|
495
496
|
}),
|
|
496
|
-
/* @__PURE__ */ J(
|
|
497
|
+
/* @__PURE__ */ J(ae, { children: [/* @__PURE__ */ q(v, {
|
|
497
498
|
variant: "outline",
|
|
498
499
|
onClick: () => R(!1),
|
|
499
500
|
disabled: z,
|
|
@@ -520,12 +521,14 @@ function de({ editId: t }) {
|
|
|
520
521
|
]
|
|
521
522
|
});
|
|
522
523
|
}
|
|
523
|
-
function
|
|
524
|
-
let { vehicleId: a } =
|
|
524
|
+
function pe() {
|
|
525
|
+
let { vehicleId: a } = ne(), { basePath: s, navigate: f } = d(), { vehicle: p, isLoading: C, error: w, refetch: E } = m(a), D = W(), { message: O, notify: k } = z(), { t: A } = re(), P = (e, t) => {
|
|
525
526
|
let n = A(e);
|
|
526
527
|
return n === e ? t : n;
|
|
527
|
-
}, L =
|
|
528
|
-
|
|
528
|
+
}, L = te().pathname.endsWith("/edit");
|
|
529
|
+
U(L, E);
|
|
530
|
+
let { drivers: G, isLoading: K, error: Z } = h(L ? void 0 : a), Q = () => f?.(u(s, "fleet/vehicles")), $ = (e) => f?.(u(s, e));
|
|
531
|
+
return a ? L ? /* @__PURE__ */ q(fe, { editId: a }) : C ? /* @__PURE__ */ q(M, { message: "Loading vehicle details..." }) : w || !p ? /* @__PURE__ */ q(j, {
|
|
529
532
|
title: "Vehicle not found",
|
|
530
533
|
onRetry: E
|
|
531
534
|
}) : /* @__PURE__ */ J(N, {
|
|
@@ -555,7 +558,7 @@ function fe() {
|
|
|
555
558
|
icon: /* @__PURE__ */ q(c, { size: 18 }),
|
|
556
559
|
children: "The full record for this vehicle — specs, capacity, fuel and mileage, who is driving it and where it is right now. Use it to confirm a vehicle is fuelled, crewed and the right size before dispatching it on a delivery."
|
|
557
560
|
}),
|
|
558
|
-
/* @__PURE__ */ q(
|
|
561
|
+
/* @__PURE__ */ q(ie, {
|
|
559
562
|
storageKey: "movethewheels-vehicle-details",
|
|
560
563
|
steps: [{
|
|
561
564
|
id: "assign",
|
|
@@ -773,7 +776,7 @@ function fe() {
|
|
|
773
776
|
})]
|
|
774
777
|
}, e.id))
|
|
775
778
|
})] }),
|
|
776
|
-
/* @__PURE__ */ q(
|
|
779
|
+
/* @__PURE__ */ q(ee, {
|
|
777
780
|
vehicle: p,
|
|
778
781
|
t: P,
|
|
779
782
|
onRecord: async (e) => {
|
|
@@ -794,7 +797,7 @@ function fe() {
|
|
|
794
797
|
})]
|
|
795
798
|
})
|
|
796
799
|
]
|
|
797
|
-
}) : /* @__PURE__ */ q(
|
|
800
|
+
}) : /* @__PURE__ */ q(fe, {});
|
|
798
801
|
}
|
|
799
802
|
//#endregion
|
|
800
|
-
export {
|
|
803
|
+
export { pe as default };
|
package/package.json
CHANGED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Detail pages render their `/edit` form from the same route component, so the
|
|
5
|
+
* component (and its record hook) stays mounted across edit → detail. Without a
|
|
6
|
+
* refetch the detail view keeps showing the pre-edit record. Call `refetch`
|
|
7
|
+
* exactly when the edit route is left, never on the initial mount.
|
|
8
|
+
*/
|
|
9
|
+
export function useRefetchOnLeaveEdit(isEditRoute: boolean, refetch: () => void): void {
|
|
10
|
+
const wasEditing = useRef(isEditRoute);
|
|
11
|
+
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
if (wasEditing.current && !isEditRoute) {
|
|
14
|
+
refetch();
|
|
15
|
+
}
|
|
16
|
+
wasEditing.current = isEditRoute;
|
|
17
|
+
}, [isEditRoute, refetch]);
|
|
18
|
+
}
|
|
@@ -57,6 +57,7 @@ import {
|
|
|
57
57
|
type UpdateDriverInput,
|
|
58
58
|
} from '../hooks/useFleet';
|
|
59
59
|
import { useDebouncedValue } from '../hooks/useDebouncedValue';
|
|
60
|
+
import { useRefetchOnLeaveEdit } from '../hooks/useRefetchOnLeaveEdit';
|
|
60
61
|
import { useMoveTheWheels } from '../providers/MoveTheWheelsProvider';
|
|
61
62
|
import { formatCurrency, formatDate } from '../utils/formatters';
|
|
62
63
|
import { joinPath } from '../utils/navigation';
|
|
@@ -631,6 +632,7 @@ export default function DriverDetailsPage() {
|
|
|
631
632
|
const isEditRoute = useLocation().pathname.endsWith('/edit');
|
|
632
633
|
const { basePath, navigate } = useMoveTheWheels();
|
|
633
634
|
const { driver, isLoading, error, refetch } = useDriver(driverId);
|
|
635
|
+
useRefetchOnLeaveEdit(isEditRoute, refetch);
|
|
634
636
|
const { vehicle: assignedVehicle } = useVehicle(driver?.assignedVehicle);
|
|
635
637
|
|
|
636
638
|
const goBack = () => navigate?.(joinPath(basePath, 'fleet/drivers'));
|
|
@@ -42,6 +42,7 @@ import {
|
|
|
42
42
|
ResponsiveDialogDescription,
|
|
43
43
|
} from '@burdenoff/fe-libs/ui';
|
|
44
44
|
import { useProduct, useInventory, useProductStockLevels } from '../hooks/useInventory';
|
|
45
|
+
import { useRefetchOnLeaveEdit } from '../hooks/useRefetchOnLeaveEdit';
|
|
45
46
|
import { useMoveTheWheels } from '../providers/MoveTheWheelsProvider';
|
|
46
47
|
import { formatCurrency } from '../utils/formatters';
|
|
47
48
|
import { joinPath } from '../utils/navigation';
|
|
@@ -326,6 +327,7 @@ export default function ProductDetailsPage() {
|
|
|
326
327
|
const { product, isLoading, error, refetch } = useProduct(productId);
|
|
327
328
|
const { deleteProduct } = useInventory();
|
|
328
329
|
const isEditRoute = useLocation().pathname.endsWith('/edit');
|
|
330
|
+
useRefetchOnLeaveEdit(isEditRoute, refetch);
|
|
329
331
|
const [deleteOpen, setDeleteOpen] = useState(false);
|
|
330
332
|
const [deleting, setDeleting] = useState(false);
|
|
331
333
|
const [deleteError, setDeleteError] = useState<string | null>(null);
|
|
@@ -53,6 +53,7 @@ import { EntityCombobox } from '../components/EntityCombobox';
|
|
|
53
53
|
import { useRoute, useRoutes } from '../hooks/useRoutes';
|
|
54
54
|
import { useVehicles, useVehicle, useDrivers, useDriver } from '../hooks/useFleet';
|
|
55
55
|
import { useAssignmentSuggestions } from '../hooks/useFleetIntelligence';
|
|
56
|
+
import { useRefetchOnLeaveEdit } from '../hooks/useRefetchOnLeaveEdit';
|
|
56
57
|
import { AssignmentSuggestions } from '../components/AssignmentSuggestions';
|
|
57
58
|
import { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';
|
|
58
59
|
import { useMoveTheWheels } from '../providers/MoveTheWheelsProvider';
|
|
@@ -436,6 +437,7 @@ export default function RouteDetailsPage() {
|
|
|
436
437
|
const isEditRoute = useLocation().pathname.endsWith('/edit');
|
|
437
438
|
const { basePath, navigate } = useMoveTheWheels();
|
|
438
439
|
const { route, isLoading, error, refetch } = useRoute(routeId);
|
|
440
|
+
useRefetchOnLeaveEdit(isEditRoute, refetch);
|
|
439
441
|
const { optimizeRoute, updateRoute, deleteRoute } = useRoutes();
|
|
440
442
|
const suggestions = useAssignmentSuggestions(routeId);
|
|
441
443
|
const { t: translate } = useI18n();
|
|
@@ -50,6 +50,7 @@ import { useVehicle, useVehicleDrivers, useFleet, toApiVehicleStatus } from '../
|
|
|
50
50
|
import type { VehicleFuelType, VehicleStatus } from '../types';
|
|
51
51
|
import { VEHICLE_STATUS_LABELS } from '../constants';
|
|
52
52
|
import { useRecordVehicleService } from '../hooks/useFleetIntelligence';
|
|
53
|
+
import { useRefetchOnLeaveEdit } from '../hooks/useRefetchOnLeaveEdit';
|
|
53
54
|
import { VehicleServiceCard } from '../components/VehicleServiceCard';
|
|
54
55
|
import { useMoveTheWheels } from '../providers/MoveTheWheelsProvider';
|
|
55
56
|
import { formatDate, getInitials } from '../utils/formatters';
|
|
@@ -494,6 +495,7 @@ export default function VehicleDetailsPage() {
|
|
|
494
495
|
return value === key ? fallback : value;
|
|
495
496
|
};
|
|
496
497
|
const isEditRoute = useLocation().pathname.endsWith('/edit');
|
|
498
|
+
useRefetchOnLeaveEdit(isEditRoute, refetch);
|
|
497
499
|
// Who is behind the wheel — resolved through DriverFilterInput.vehicleId, the
|
|
498
500
|
// same link `assignDriverVehicle` writes.
|
|
499
501
|
const {
|