@burdenoff/microfe-movethewheels 2026.1108.4 → 2026.1109.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/generated/tracking-quality-operations.d.ts +1 -1
- package/dist/generated/wspace-operations.d.ts +91 -0
- package/dist/generated/wspace-types.d.ts +43263 -9122
- package/dist/hooks/useRoutes.js +91 -52
- package/dist/movethewheels/hooks/useRoutes.d.ts +3 -2
- package/dist/movethewheels/types/index.d.ts +21 -1
- package/dist/movethewheels/utils/carrierIntegrations.d.ts +12 -4
- package/dist/pages/IntegrationsPage.js +371 -323
- package/dist/pages/RouteDetailsPage.js +344 -274
- package/dist/utils/carrierIntegrations.js +52 -45
- package/dist/utils/formatters.js +6 -1
- package/package.json +1 -1
- package/src/generated/tracking-quality-operations.ts +1 -0
- package/src/generated/wspace-operations.ts +13 -12
- package/src/generated/wspace-types.ts +43741 -9123
- package/src/movethewheels/hooks/useRoutes.ts +37 -10
- package/src/movethewheels/pages/IntegrationsPage.tsx +59 -17
- package/src/movethewheels/pages/RouteDetailsPage.tsx +107 -10
- package/src/movethewheels/types/index.ts +27 -1
- package/src/movethewheels/utils/carrierIntegrations.ts +24 -7
- package/src/operations/wspace/movethewheels/fragments/core.graphql +15 -0
- package/src/operations/wspace/movethewheels/mutations/logistics.graphql +2 -2
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
2
2
|
import { useMoveTheWheels } from '../providers/MoveTheWheelsProvider';
|
|
3
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
Route,
|
|
5
|
+
RouteOptimizationStrategy,
|
|
6
|
+
RouteOptimizationSummary,
|
|
7
|
+
RouteStop,
|
|
8
|
+
} from '../types';
|
|
4
9
|
import { executeGraphQL } from '../utils/graphqlClient';
|
|
5
10
|
|
|
6
11
|
interface UseRoutesOptions {
|
|
@@ -32,7 +37,7 @@ interface UseRoutesResult {
|
|
|
32
37
|
}
|
|
33
38
|
) => Promise<Route>;
|
|
34
39
|
deleteRoute: (id: string) => Promise<void>;
|
|
35
|
-
optimizeRoute: (routeId: string) => Promise<Route>;
|
|
40
|
+
optimizeRoute: (routeId: string, strategy?: RouteOptimizationStrategy) => Promise<Route>;
|
|
36
41
|
updateStopStatus: (
|
|
37
42
|
routeId: string,
|
|
38
43
|
stopId: string,
|
|
@@ -53,9 +58,28 @@ interface ApiRoute {
|
|
|
53
58
|
fuelCost?: number | null;
|
|
54
59
|
actualDistance?: number | null;
|
|
55
60
|
actualDuration?: number | null;
|
|
61
|
+
lastOptimization?: RouteOptimizationSummary | null;
|
|
56
62
|
createdAt: string;
|
|
57
63
|
}
|
|
58
64
|
|
|
65
|
+
const LAST_OPTIMIZATION_FIELDS = `
|
|
66
|
+
lastOptimization {
|
|
67
|
+
strategy
|
|
68
|
+
ranAt
|
|
69
|
+
waypointCount
|
|
70
|
+
distanceBeforeKm
|
|
71
|
+
distanceAfterKm
|
|
72
|
+
distanceSavedKm
|
|
73
|
+
durationAfterMinutes
|
|
74
|
+
feasible
|
|
75
|
+
violations {
|
|
76
|
+
code
|
|
77
|
+
message
|
|
78
|
+
sequence
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
`;
|
|
82
|
+
|
|
59
83
|
const LIST_ROUTES_QUERY = `
|
|
60
84
|
query ListRoutes($filter: RouteFilterInput, $pagination: PaginationInput) {
|
|
61
85
|
routes(filter: $filter, pagination: $pagination) {
|
|
@@ -93,6 +117,7 @@ const GET_ROUTE_QUERY = `
|
|
|
93
117
|
actualDistance
|
|
94
118
|
actualDuration
|
|
95
119
|
createdAt
|
|
120
|
+
${LAST_OPTIMIZATION_FIELDS}
|
|
96
121
|
}
|
|
97
122
|
}
|
|
98
123
|
`;
|
|
@@ -144,8 +169,8 @@ const DELETE_ROUTE_MUTATION = `
|
|
|
144
169
|
`;
|
|
145
170
|
|
|
146
171
|
const OPTIMIZE_ROUTE_MUTATION = `
|
|
147
|
-
mutation OptimizeRoute($id: ID
|
|
148
|
-
optimizeRoute(id: $id) {
|
|
172
|
+
mutation OptimizeRoute($id: ID!, $input: OptimizeRouteInput) {
|
|
173
|
+
optimizeRoute(id: $id, input: $input) {
|
|
149
174
|
id
|
|
150
175
|
name
|
|
151
176
|
status
|
|
@@ -159,6 +184,7 @@ const OPTIMIZE_ROUTE_MUTATION = `
|
|
|
159
184
|
actualDistance
|
|
160
185
|
actualDuration
|
|
161
186
|
createdAt
|
|
187
|
+
${LAST_OPTIMIZATION_FIELDS}
|
|
162
188
|
}
|
|
163
189
|
}
|
|
164
190
|
`;
|
|
@@ -247,10 +273,10 @@ export function mapRoute(route: ApiRoute): Route {
|
|
|
247
273
|
estimatedDuration: route.estimatedDuration ?? 0,
|
|
248
274
|
fuelCost: route.fuelCost ?? undefined,
|
|
249
275
|
actualDuration: route.actualDuration ?? undefined,
|
|
250
|
-
//
|
|
251
|
-
//
|
|
252
|
-
|
|
253
|
-
|
|
276
|
+
// `lastOptimization` is the persisted proof that the optimize mutation ran;
|
|
277
|
+
// `estimatedDistance` alone is only a measurement.
|
|
278
|
+
optimized: route.lastOptimization ? true : undefined,
|
|
279
|
+
lastOptimization: route.lastOptimization ?? undefined,
|
|
254
280
|
createdAt: new Date(route.createdAt),
|
|
255
281
|
};
|
|
256
282
|
}
|
|
@@ -440,15 +466,16 @@ export function useRoutes(options: UseRoutesOptions = {}): UseRoutesResult {
|
|
|
440
466
|
);
|
|
441
467
|
|
|
442
468
|
const optimizeRoute = useCallback(
|
|
443
|
-
async (routeId: string): Promise<Route> => {
|
|
469
|
+
async (routeId: string, strategy?: RouteOptimizationStrategy): Promise<Route> => {
|
|
444
470
|
const data = await executeGraphQL<{ optimizeRoute: ApiRoute }>(
|
|
445
471
|
graphQLOptions,
|
|
446
472
|
OPTIMIZE_ROUTE_MUTATION,
|
|
447
473
|
{
|
|
448
474
|
id: routeId,
|
|
475
|
+
input: strategy ? { strategy } : undefined,
|
|
449
476
|
}
|
|
450
477
|
);
|
|
451
|
-
const optimized =
|
|
478
|
+
const optimized = mapRoute(data.optimizeRoute);
|
|
452
479
|
setRoutes((previous) => previous.map((item) => (item.id === routeId ? optimized : item)));
|
|
453
480
|
return optimized;
|
|
454
481
|
},
|
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
* (BOFF-10922) is pulled instead: MyGeotab has no push webhooks, so the
|
|
13
13
|
* service signs in with the credentials entered here and polls its data feeds
|
|
14
14
|
* every few minutes; the card shows the latest poll and offers "Poll now".
|
|
15
|
+
* A Motive feed (BOFF-10921) uses a secret generated here, shown once and
|
|
16
|
+
* entered on the Motive webhook, which signs with HMAC-SHA1.
|
|
15
17
|
* Named carrier
|
|
16
18
|
* networks (project44, FourKites, Descartes) are listed as not yet available:
|
|
17
19
|
* they need vendor agreements before an adapter can ship, and the service
|
|
@@ -78,7 +80,8 @@ import {
|
|
|
78
80
|
GEOTAB_RULE_EVENT_TYPES,
|
|
79
81
|
INTEGRATION_STATUSES,
|
|
80
82
|
MAX_UPDATES_PER_DELIVERY,
|
|
81
|
-
|
|
83
|
+
MOTIVE_ACTIONS,
|
|
84
|
+
MOTIVE_SIGNATURE_HEADER,
|
|
82
85
|
ROADMAP_PROVIDERS,
|
|
83
86
|
SAMSARA_EVENT_TYPES,
|
|
84
87
|
SAMSARA_SIGNATURE_HEADERS,
|
|
@@ -218,6 +221,7 @@ function CreateIntegrationDialog({
|
|
|
218
221
|
const [isSaving, setIsSaving] = useState(false);
|
|
219
222
|
const isSamsara = provider === 'SAMSARA';
|
|
220
223
|
const isGeotab = provider === 'GEOTAB';
|
|
224
|
+
const isMotive = provider === 'MOTIVE';
|
|
221
225
|
|
|
222
226
|
const reset = () => {
|
|
223
227
|
setProvider('GENERIC_WEBHOOK');
|
|
@@ -284,7 +288,7 @@ function CreateIntegrationDialog({
|
|
|
284
288
|
apiSecret: samsaraSecret.trim(),
|
|
285
289
|
...(key ? { config: { shipmentExternalIdKey: key } } : {}),
|
|
286
290
|
}
|
|
287
|
-
: { provider: 'GENERIC_WEBHOOK', name, apiSecret: secret }
|
|
291
|
+
: { provider: isMotive ? 'MOTIVE' : 'GENERIC_WEBHOOK', name, apiSecret: secret }
|
|
288
292
|
);
|
|
289
293
|
onCreated(created, isSamsara || isGeotab ? null : secret);
|
|
290
294
|
reset();
|
|
@@ -325,7 +329,9 @@ function CreateIntegrationDialog({
|
|
|
325
329
|
? 'e.g. Samsara fleet'
|
|
326
330
|
: isGeotab
|
|
327
331
|
? 'e.g. Geotab fleet'
|
|
328
|
-
:
|
|
332
|
+
: isMotive
|
|
333
|
+
? 'e.g. Motive fleet'
|
|
334
|
+
: 'e.g. Fleet GPS feed'
|
|
329
335
|
}
|
|
330
336
|
onChange={(event) => setName(event.target.value)}
|
|
331
337
|
autoFocus
|
|
@@ -348,6 +354,9 @@ function CreateIntegrationDialog({
|
|
|
348
354
|
Signed webhook (any system that can send HTTPS POSTs)
|
|
349
355
|
</SelectItem>
|
|
350
356
|
<SelectItem value="SAMSARA">Samsara (ELD and telematics)</SelectItem>
|
|
357
|
+
<SelectItem value="MOTIVE">
|
|
358
|
+
Motive, formerly KeepTruckin (ELD and telematics)
|
|
359
|
+
</SelectItem>
|
|
351
360
|
<SelectItem value="GEOTAB">Geotab / MyGeotab (telematics, polled)</SelectItem>
|
|
352
361
|
</SelectContent>
|
|
353
362
|
</Select>
|
|
@@ -485,7 +494,9 @@ function CreateIntegrationDialog({
|
|
|
485
494
|
{secret}
|
|
486
495
|
</code>
|
|
487
496
|
<p className="text-xs text-text-secondary">
|
|
488
|
-
|
|
497
|
+
{isMotive
|
|
498
|
+
? 'Generated in your browser. You can copy it on the next step and enter it as the secret on the Motive webhook.'
|
|
499
|
+
: 'Generated in your browser. You can copy it on the next step.'}
|
|
489
500
|
</p>
|
|
490
501
|
</div>
|
|
491
502
|
)}
|
|
@@ -627,6 +638,43 @@ function SamsaraSetupInstructions({ url }: { url: string }) {
|
|
|
627
638
|
);
|
|
628
639
|
}
|
|
629
640
|
|
|
641
|
+
function MotiveSetupInstructions({ url }: { url: string }) {
|
|
642
|
+
return (
|
|
643
|
+
<div className="space-y-3">
|
|
644
|
+
<p className="text-sm font-medium">How to connect Motive</p>
|
|
645
|
+
<CopyField label="Webhook URL" value={url} />
|
|
646
|
+
<ol className="list-decimal space-y-1 pl-5 text-xs text-text-secondary">
|
|
647
|
+
<li>
|
|
648
|
+
In the Motive dashboard, open Admin → Developer → Webhooks and add a webhook with the URL
|
|
649
|
+
above, the JSON format and the signing secret shown when this feed was connected (rotate
|
|
650
|
+
the secret here to get a new one).
|
|
651
|
+
</li>
|
|
652
|
+
<li>
|
|
653
|
+
Subscribe it to{' '}
|
|
654
|
+
{MOTIVE_ACTIONS.map((entry, index) => (
|
|
655
|
+
<span key={entry.action}>
|
|
656
|
+
{index > 0 ? ' and ' : ''}
|
|
657
|
+
<code className="font-mono">{entry.action}</code> ({entry.becomes.toLowerCase()})
|
|
658
|
+
</span>
|
|
659
|
+
))}
|
|
660
|
+
, then enable it. Motive sends an activation test that this feed answers automatically.
|
|
661
|
+
</li>
|
|
662
|
+
<li>
|
|
663
|
+
Motive deliveries carry no shipment reference, so the Motive vehicle number (or VIN) is
|
|
664
|
+
matched to a MoveTheWheels vehicle by its vehicle number or licence plate, and the event
|
|
665
|
+
goes to that vehicle's single in-progress route. Ambiguous matches are refused, never
|
|
666
|
+
guessed.
|
|
667
|
+
</li>
|
|
668
|
+
<li>
|
|
669
|
+
Motive signs every delivery with an HMAC-SHA1 of the body in{' '}
|
|
670
|
+
<code className="font-mono">{MOTIVE_SIGNATURE_HEADER}</code>; deliveries with a wrong
|
|
671
|
+
signature are refused, and a repeated Motive event is recorded once.
|
|
672
|
+
</li>
|
|
673
|
+
</ol>
|
|
674
|
+
</div>
|
|
675
|
+
);
|
|
676
|
+
}
|
|
677
|
+
|
|
630
678
|
function GeotabSetupInstructions({ integration }: { integration: CarrierIntegration }) {
|
|
631
679
|
return (
|
|
632
680
|
<div className="space-y-3">
|
|
@@ -871,6 +919,8 @@ function IntegrationCard({
|
|
|
871
919
|
<GeotabSetupInstructions integration={integration} />
|
|
872
920
|
) : integration.provider === 'SAMSARA' ? (
|
|
873
921
|
<SamsaraSetupInstructions url={url} />
|
|
922
|
+
) : integration.provider === 'MOTIVE' ? (
|
|
923
|
+
<MotiveSetupInstructions url={url} />
|
|
874
924
|
) : (
|
|
875
925
|
<SetupInstructions url={url} />
|
|
876
926
|
)}
|
|
@@ -1180,23 +1230,15 @@ function WorkspaceIntegrationsPage() {
|
|
|
1180
1230
|
<CardContent className="space-y-2 p-5">
|
|
1181
1231
|
<p className="text-sm font-medium">Carrier and ELD networks</p>
|
|
1182
1232
|
<p className="text-sm text-text-secondary">
|
|
1183
|
-
Samsara and Geotab connect directly: choose them when you connect a feed. Direct
|
|
1184
|
-
connections to{' '}
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
...PLANNED_ELD_PROVIDERS,
|
|
1188
|
-
].join(', ')}{' '}
|
|
1189
|
-
are not available yet. Until they are, any carrier or telematics system that can send
|
|
1190
|
-
HTTPS webhooks connects through a signed feed above.
|
|
1233
|
+
Samsara, Motive and Geotab connect directly: choose them when you connect a feed. Direct
|
|
1234
|
+
connections to {ROADMAP_PROVIDERS.map((provider) => provider.label).join(', ')} are not
|
|
1235
|
+
available yet. Until they are, any carrier or telematics system that can send HTTPS
|
|
1236
|
+
webhooks connects through a signed feed above.
|
|
1191
1237
|
</p>
|
|
1192
1238
|
<div className="flex flex-wrap gap-2">
|
|
1193
1239
|
<Badge variant="default">Samsara · available</Badge>
|
|
1240
|
+
<Badge variant="default">Motive · available</Badge>
|
|
1194
1241
|
<Badge variant="default">Geotab · available</Badge>
|
|
1195
|
-
{PLANNED_ELD_PROVIDERS.map((label) => (
|
|
1196
|
-
<Badge key={label} variant="outline">
|
|
1197
|
-
{label} · not available yet
|
|
1198
|
-
</Badge>
|
|
1199
|
-
))}
|
|
1200
1242
|
{ROADMAP_PROVIDERS.map((provider) => (
|
|
1201
1243
|
<Badge key={provider.id} variant="outline">
|
|
1202
1244
|
{provider.label} · not available yet
|
|
@@ -58,12 +58,23 @@ import { useRefetchOnLeaveEdit } from '../hooks/useRefetchOnLeaveEdit';
|
|
|
58
58
|
import { AssignmentSuggestions } from '../components/AssignmentSuggestions';
|
|
59
59
|
import { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';
|
|
60
60
|
import { useMoveTheWheels } from '../providers/MoveTheWheelsProvider';
|
|
61
|
-
import {
|
|
61
|
+
import {
|
|
62
|
+
formatDate,
|
|
63
|
+
formatAddress,
|
|
64
|
+
formatCurrency,
|
|
65
|
+
formatDistance,
|
|
66
|
+
formatDuration,
|
|
67
|
+
} from '../utils/formatters';
|
|
62
68
|
import { joinPath } from '../utils/navigation';
|
|
63
69
|
import { ROUTE_STATUS_COLORS } from '../constants';
|
|
64
70
|
import { FormError } from '../components/FormError';
|
|
65
71
|
import { Notice, useNotice } from '../components/Notice';
|
|
66
|
-
import type {
|
|
72
|
+
import type {
|
|
73
|
+
Route as RouteType,
|
|
74
|
+
RouteOptimizationStrategy,
|
|
75
|
+
RouteOptimizationSummary,
|
|
76
|
+
RouteStop,
|
|
77
|
+
} from '../types';
|
|
67
78
|
|
|
68
79
|
const ROUTE_STATUS_OPTIONS: { value: RouteType['status']; label: string }[] = [
|
|
69
80
|
{ value: 'planned', label: 'Planned' },
|
|
@@ -433,6 +444,65 @@ function NewRouteForm({ editId }: { editId?: string }) {
|
|
|
433
444
|
);
|
|
434
445
|
}
|
|
435
446
|
|
|
447
|
+
function OptimizationSummaryCard({ summary }: { summary: RouteOptimizationSummary }) {
|
|
448
|
+
const ranAt = new Date(summary.ranAt);
|
|
449
|
+
const when = Number.isNaN(ranAt.getTime())
|
|
450
|
+
? summary.ranAt
|
|
451
|
+
: ranAt.toLocaleString(undefined, { dateStyle: 'medium', timeStyle: 'short' });
|
|
452
|
+
return (
|
|
453
|
+
<Card className="mb-6">
|
|
454
|
+
<CardHeader>
|
|
455
|
+
<CardTitle className="flex items-center gap-2">
|
|
456
|
+
<Zap size={16} />
|
|
457
|
+
Last optimization
|
|
458
|
+
<Badge variant={summary.feasible ? 'default' : 'secondary'}>
|
|
459
|
+
{summary.feasible ? 'Feasible' : `${summary.violations.length} warning(s)`}
|
|
460
|
+
</Badge>
|
|
461
|
+
</CardTitle>
|
|
462
|
+
</CardHeader>
|
|
463
|
+
<CardContent className="space-y-2 text-sm">
|
|
464
|
+
<div className="flex flex-wrap gap-x-6 gap-y-1">
|
|
465
|
+
<span>
|
|
466
|
+
Strategy: <strong>{summary.strategy}</strong>
|
|
467
|
+
</span>
|
|
468
|
+
<span>
|
|
469
|
+
Run: <strong>{when}</strong>
|
|
470
|
+
</span>
|
|
471
|
+
{summary.distanceAfterKm != null && (
|
|
472
|
+
<span>
|
|
473
|
+
Distance: <strong>{formatDistance(summary.distanceAfterKm)}</strong>
|
|
474
|
+
</span>
|
|
475
|
+
)}
|
|
476
|
+
{summary.distanceSavedKm != null && summary.distanceSavedKm > 0 && (
|
|
477
|
+
<span>
|
|
478
|
+
Saved: <strong>{formatDistance(summary.distanceSavedKm)}</strong> vs recorded order
|
|
479
|
+
</span>
|
|
480
|
+
)}
|
|
481
|
+
{summary.durationAfterMinutes != null && (
|
|
482
|
+
<span>
|
|
483
|
+
Drive time: <strong>{formatDuration(summary.durationAfterMinutes)}</strong>
|
|
484
|
+
</span>
|
|
485
|
+
)}
|
|
486
|
+
</div>
|
|
487
|
+
{summary.violations.length > 0 && (
|
|
488
|
+
<ul className="list-disc pl-5 space-y-1">
|
|
489
|
+
{summary.violations.map((violation, index) => (
|
|
490
|
+
<li key={`${violation.code}-${index}`}>
|
|
491
|
+
{violation.message}
|
|
492
|
+
{violation.sequence != null && (
|
|
493
|
+
<Badge variant="outline" className="ml-2">
|
|
494
|
+
stop {violation.sequence}
|
|
495
|
+
</Badge>
|
|
496
|
+
)}
|
|
497
|
+
</li>
|
|
498
|
+
))}
|
|
499
|
+
</ul>
|
|
500
|
+
)}
|
|
501
|
+
</CardContent>
|
|
502
|
+
</Card>
|
|
503
|
+
);
|
|
504
|
+
}
|
|
505
|
+
|
|
436
506
|
export default function RouteDetailsPage() {
|
|
437
507
|
const { routeId } = useParams<{ routeId: string }>();
|
|
438
508
|
const isEditRoute = useLocation().pathname.endsWith('/edit');
|
|
@@ -449,6 +519,7 @@ export default function RouteDetailsPage() {
|
|
|
449
519
|
const { message: notice, notify } = useNotice();
|
|
450
520
|
const [optimizeError, setOptimizeError] = useState<string | null>(null);
|
|
451
521
|
const [optimizing, setOptimizing] = useState(false);
|
|
522
|
+
const [optimizeStrategy, setOptimizeStrategy] = useState<RouteOptimizationStrategy>('AUTO');
|
|
452
523
|
const [deleteOpen, setDeleteOpen] = useState(false);
|
|
453
524
|
const [deleting, setDeleting] = useState(false);
|
|
454
525
|
const [deleteError, setDeleteError] = useState<string | null>(null);
|
|
@@ -475,8 +546,15 @@ export default function RouteDetailsPage() {
|
|
|
475
546
|
setOptimizing(true);
|
|
476
547
|
setOptimizeError(null);
|
|
477
548
|
try {
|
|
478
|
-
await optimizeRoute(routeId);
|
|
479
|
-
|
|
549
|
+
const updated = await optimizeRoute(routeId, optimizeStrategy);
|
|
550
|
+
const summary = updated.lastOptimization;
|
|
551
|
+
if (summary && !summary.feasible) {
|
|
552
|
+
notify(
|
|
553
|
+
`Route optimized with ${summary.violations.length} constraint warning(s) — see the optimization panel below.`
|
|
554
|
+
);
|
|
555
|
+
} else {
|
|
556
|
+
notify('Route optimized — stops resequenced for the shortest feasible run.');
|
|
557
|
+
}
|
|
480
558
|
refetch();
|
|
481
559
|
} catch (e) {
|
|
482
560
|
setOptimizeError(e instanceof Error ? e.message : 'Failed to optimize route.');
|
|
@@ -534,10 +612,27 @@ export default function RouteDetailsPage() {
|
|
|
534
612
|
<Button variant="outline" onClick={goBack}>
|
|
535
613
|
<ArrowLeft size={16} /> Back
|
|
536
614
|
</Button>
|
|
537
|
-
{
|
|
538
|
-
|
|
539
|
-
<
|
|
540
|
-
|
|
615
|
+
{(route.status === 'planned' || route.status === 'in_progress') && (
|
|
616
|
+
<>
|
|
617
|
+
<Select
|
|
618
|
+
value={optimizeStrategy}
|
|
619
|
+
onValueChange={(value) => setOptimizeStrategy(value as RouteOptimizationStrategy)}
|
|
620
|
+
>
|
|
621
|
+
<SelectTrigger className="w-44" aria-label="Optimization strategy">
|
|
622
|
+
<SelectValue />
|
|
623
|
+
</SelectTrigger>
|
|
624
|
+
<SelectContent>
|
|
625
|
+
<SelectItem value="AUTO">Auto (windows + 2-opt)</SelectItem>
|
|
626
|
+
<SelectItem value="NEAREST_NEIGHBOUR">Nearest neighbour</SelectItem>
|
|
627
|
+
<SelectItem value="TIME_WINDOW">Time windows</SelectItem>
|
|
628
|
+
<SelectItem value="TWO_OPT">Shortest tour (2-opt)</SelectItem>
|
|
629
|
+
</SelectContent>
|
|
630
|
+
</Select>
|
|
631
|
+
<Button variant="outline" onClick={handleOptimize} disabled={optimizing}>
|
|
632
|
+
<Zap size={16} />{' '}
|
|
633
|
+
{optimizing ? 'Optimizing…' : route.optimized ? 'Re-optimize' : 'Optimize & start'}
|
|
634
|
+
</Button>
|
|
635
|
+
</>
|
|
541
636
|
)}
|
|
542
637
|
<Button onClick={() => navigate?.(joinPath(basePath, `routes/${routeId}/edit`))}>
|
|
543
638
|
<Edit size={16} /> Edit
|
|
@@ -566,11 +661,11 @@ export default function RouteDetailsPage() {
|
|
|
566
661
|
<NextSteps
|
|
567
662
|
storageKey="movethewheels-route-details"
|
|
568
663
|
steps={[
|
|
569
|
-
...(
|
|
664
|
+
...(route.status === 'planned' || route.status === 'in_progress'
|
|
570
665
|
? [
|
|
571
666
|
{
|
|
572
667
|
id: 'optimize',
|
|
573
|
-
label: 'Optimize & start this route',
|
|
668
|
+
label: route.optimized ? 'Re-optimize this route' : 'Optimize & start this route',
|
|
574
669
|
description:
|
|
575
670
|
'Reorder stops to cut distance and driving time, then mark the route In Progress.',
|
|
576
671
|
icon: <Zap size={16} />,
|
|
@@ -606,6 +701,8 @@ export default function RouteDetailsPage() {
|
|
|
606
701
|
</div>
|
|
607
702
|
)}
|
|
608
703
|
|
|
704
|
+
{route.lastOptimization && <OptimizationSummaryCard summary={route.lastOptimization} />}
|
|
705
|
+
|
|
609
706
|
<div className="grid grid-cols-1 lg:grid-cols-3 gap-6">
|
|
610
707
|
<div className="lg:col-span-2 space-y-6">
|
|
611
708
|
<Card>
|
|
@@ -498,6 +498,30 @@ export interface TrafficCondition {
|
|
|
498
498
|
location: string;
|
|
499
499
|
}
|
|
500
500
|
|
|
501
|
+
// Route optimization types (svc RouteOptimizationSummary)
|
|
502
|
+
export type RouteOptimizationStrategy = 'AUTO' | 'NEAREST_NEIGHBOUR' | 'TIME_WINDOW' | 'TWO_OPT';
|
|
503
|
+
|
|
504
|
+
export type RouteOptimizationViolationCode =
|
|
505
|
+
'WINDOW_MISSED' | 'OVER_CAPACITY' | 'OVER_DRIVER_HOURS' | 'NO_COORDINATES';
|
|
506
|
+
|
|
507
|
+
export interface RouteOptimizationViolation {
|
|
508
|
+
code: RouteOptimizationViolationCode;
|
|
509
|
+
message: string;
|
|
510
|
+
sequence?: number | null;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
export interface RouteOptimizationSummary {
|
|
514
|
+
strategy: RouteOptimizationStrategy;
|
|
515
|
+
ranAt: string;
|
|
516
|
+
waypointCount: number;
|
|
517
|
+
distanceBeforeKm?: number | null;
|
|
518
|
+
distanceAfterKm?: number | null;
|
|
519
|
+
distanceSavedKm?: number | null;
|
|
520
|
+
durationAfterMinutes?: number | null;
|
|
521
|
+
feasible: boolean;
|
|
522
|
+
violations: RouteOptimizationViolation[];
|
|
523
|
+
}
|
|
524
|
+
|
|
501
525
|
// Route type
|
|
502
526
|
export interface Route {
|
|
503
527
|
id: string;
|
|
@@ -511,8 +535,10 @@ export interface Route {
|
|
|
511
535
|
/** Estimated fuel cost for the route (svc MtwRoute.fuelCost). */
|
|
512
536
|
fuelCost?: number;
|
|
513
537
|
actualDuration?: number;
|
|
514
|
-
/**
|
|
538
|
+
/** True once the backend reports a persisted optimization summary. */
|
|
515
539
|
optimized?: boolean;
|
|
540
|
+
/** Summary of the most recent optimizeRoute run, when one has run. */
|
|
541
|
+
lastOptimization?: RouteOptimizationSummary;
|
|
516
542
|
createdAt: Date;
|
|
517
543
|
}
|
|
518
544
|
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Carrier and telematics integrations (BOFF-4404, Samsara in BOFF-10703,
|
|
3
|
-
* Geotab in BOFF-10922).
|
|
3
|
+
* Geotab in BOFF-10922, Motive in BOFF-10921).
|
|
4
4
|
*
|
|
5
5
|
* A workspace connects an external carrier, ELD or GPS feed to MoveTheWheels.
|
|
6
6
|
* Webhook feeds push: a generic feed is verified with HMAC-SHA256 over the
|
|
7
7
|
* raw request body using a secret generated here; a Samsara feed is verified
|
|
8
|
-
* with Samsara's own timestamped signature using the secret Samsara issues
|
|
8
|
+
* with Samsara's own timestamped signature using the secret Samsara issues; a
|
|
9
|
+
* Motive feed is verified with Motive's HMAC-SHA1 signature using a secret
|
|
10
|
+
* generated here and entered on the Motive webhook.
|
|
9
11
|
* Geotab has no push webhooks, so a Geotab feed is pulled: the service signs
|
|
10
12
|
* in to MyGeotab with the credentials entered here and polls its data feeds
|
|
11
13
|
* every few minutes. Every accepted update becomes a tracking event on the
|
|
@@ -20,7 +22,7 @@ import { resolveGraphqlUrl } from './graphqlClient';
|
|
|
20
22
|
* Providers this page can connect. The service also ingests SHIPROCKET, which
|
|
21
23
|
* is set up from the Shiprocket carrier flow rather than here.
|
|
22
24
|
*/
|
|
23
|
-
export const SUPPORTED_PROVIDERS = ['GENERIC_WEBHOOK', 'SAMSARA', 'GEOTAB'] as const;
|
|
25
|
+
export const SUPPORTED_PROVIDERS = ['GENERIC_WEBHOOK', 'SAMSARA', 'MOTIVE', 'GEOTAB'] as const;
|
|
24
26
|
export type SupportedProvider = (typeof SUPPORTED_PROVIDERS)[number];
|
|
25
27
|
|
|
26
28
|
/** Providers the service pulls on a schedule instead of receiving webhooks. */
|
|
@@ -37,14 +39,18 @@ export const ROADMAP_PROVIDERS = [
|
|
|
37
39
|
{ id: 'DESCARTES', label: 'Descartes' },
|
|
38
40
|
] as const;
|
|
39
41
|
|
|
40
|
-
/** ELD networks planned after Samsara and Geotab (BOFF-10703 follow-ups); not in the schema yet. */
|
|
41
|
-
export const PLANNED_ELD_PROVIDERS = ['Motive'] as const;
|
|
42
|
-
|
|
43
42
|
export const INTEGRATION_STATUSES = ['ACTIVE', 'PAUSED', 'DISABLED'] as const;
|
|
44
43
|
export type IntegrationStatus = (typeof INTEGRATION_STATUSES)[number];
|
|
45
44
|
|
|
46
45
|
export type IntegrationProvider =
|
|
47
|
-
|
|
46
|
+
| 'GENERIC_WEBHOOK'
|
|
47
|
+
| 'SAMSARA'
|
|
48
|
+
| 'MOTIVE'
|
|
49
|
+
| 'GEOTAB'
|
|
50
|
+
| 'SHIPROCKET'
|
|
51
|
+
| 'PROJECT44'
|
|
52
|
+
| 'FOURKITES'
|
|
53
|
+
| 'DESCARTES';
|
|
48
54
|
|
|
49
55
|
/** How each provider is named on the page. */
|
|
50
56
|
export function providerLabel(provider: IntegrationProvider): string {
|
|
@@ -53,6 +59,8 @@ export function providerLabel(provider: IntegrationProvider): string {
|
|
|
53
59
|
return 'Signed webhook';
|
|
54
60
|
case 'SAMSARA':
|
|
55
61
|
return 'Samsara';
|
|
62
|
+
case 'MOTIVE':
|
|
63
|
+
return 'Motive';
|
|
56
64
|
case 'GEOTAB':
|
|
57
65
|
return 'Geotab';
|
|
58
66
|
case 'SHIPROCKET':
|
|
@@ -74,6 +82,15 @@ export const SAMSARA_EVENT_TYPES = [
|
|
|
74
82
|
{ type: 'GeofenceExit', becomes: 'DEPARTED' },
|
|
75
83
|
] as const;
|
|
76
84
|
|
|
85
|
+
/** Motive webhook actions the service turns into tracking events. */
|
|
86
|
+
export const MOTIVE_ACTIONS = [
|
|
87
|
+
{ action: 'vehicle_geofence_event', becomes: 'Arrived on geofence entry, Departed on exit' },
|
|
88
|
+
{ action: 'vehicle_location_updated', becomes: 'In transit, with the reported position' },
|
|
89
|
+
] as const;
|
|
90
|
+
|
|
91
|
+
/** Header Motive signs each delivery with (hex HMAC-SHA1 of the raw body); the gateway forwards it. */
|
|
92
|
+
export const MOTIVE_SIGNATURE_HEADER = 'X-KT-Webhook-Signature';
|
|
93
|
+
|
|
77
94
|
/** Route or stop external id key the service reads the shipment reference from by default. */
|
|
78
95
|
export const DEFAULT_SAMSARA_SHIPMENT_KEY = 'mtwShipment';
|
|
79
96
|
|
|
@@ -135,6 +135,21 @@ fragment RouteCore on MtwRoute {
|
|
|
135
135
|
actualDistance
|
|
136
136
|
actualDuration
|
|
137
137
|
fuelCost
|
|
138
|
+
lastOptimization {
|
|
139
|
+
strategy
|
|
140
|
+
ranAt
|
|
141
|
+
waypointCount
|
|
142
|
+
distanceBeforeKm
|
|
143
|
+
distanceAfterKm
|
|
144
|
+
distanceSavedKm
|
|
145
|
+
durationAfterMinutes
|
|
146
|
+
feasible
|
|
147
|
+
violations {
|
|
148
|
+
code
|
|
149
|
+
message
|
|
150
|
+
sequence
|
|
151
|
+
}
|
|
152
|
+
}
|
|
138
153
|
createdAt
|
|
139
154
|
updatedAt
|
|
140
155
|
}
|
|
@@ -48,8 +48,8 @@ mutation UpdateRoute($id: ID!, $input: UpdateRouteInput!) {
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
mutation OptimizeRoute($id: ID
|
|
52
|
-
optimizeRoute(id: $id) {
|
|
51
|
+
mutation OptimizeRoute($id: ID!, $input: OptimizeRouteInput) {
|
|
52
|
+
optimizeRoute(id: $id, input: $input) {
|
|
53
53
|
...RouteCore
|
|
54
54
|
}
|
|
55
55
|
}
|