@burdenoff/microfe-movethewheels 2026.1108.3 → 2026.1108.4
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 +328 -1
- package/dist/hooks/useCarrierIntegrations.js +30 -29
- package/dist/movethewheels/hooks/useCarrierIntegrations.d.ts +9 -3
- package/dist/movethewheels/utils/carrierIntegrations.d.ts +90 -9
- package/dist/node_modules/lucide-react/dist/esm/icons/cloud-download.js +18 -0
- package/dist/pages/IntegrationsPage.js +551 -329
- package/dist/utils/carrierIntegrations.js +127 -30
- package/package.json +1 -1
- package/src/generated/tracking-quality-operations.ts +373 -0
- package/src/movethewheels/hooks/useCarrierIntegrations.ts +19 -2
- package/src/movethewheels/pages/IntegrationsPage.tsx +292 -36
- package/src/movethewheels/utils/carrierIntegrations.ts +252 -10
|
@@ -8,7 +8,11 @@
|
|
|
8
8
|
*
|
|
9
9
|
* A generic feed's signing secret is generated in the browser, shown exactly
|
|
10
10
|
* once and never read back from the service. A Samsara feed (BOFF-10703) uses
|
|
11
|
-
* the secret Samsara issues for its webhook, pasted here once.
|
|
11
|
+
* the secret Samsara issues for its webhook, pasted here once. A Geotab feed
|
|
12
|
+
* (BOFF-10922) is pulled instead: MyGeotab has no push webhooks, so the
|
|
13
|
+
* service signs in with the credentials entered here and polls its data feeds
|
|
14
|
+
* every few minutes; the card shows the latest poll and offers "Poll now".
|
|
15
|
+
* Named carrier
|
|
12
16
|
* networks (project44, FourKites, Descartes) are listed as not yet available:
|
|
13
17
|
* they need vendor agreements before an adapter can ship, and the service
|
|
14
18
|
* refuses them.
|
|
@@ -20,6 +24,7 @@ import {
|
|
|
20
24
|
ChevronDown,
|
|
21
25
|
ChevronUp,
|
|
22
26
|
Copy,
|
|
27
|
+
DownloadCloud,
|
|
23
28
|
KeyRound,
|
|
24
29
|
Pause,
|
|
25
30
|
Play,
|
|
@@ -48,6 +53,7 @@ import {
|
|
|
48
53
|
Button,
|
|
49
54
|
Card,
|
|
50
55
|
CardContent,
|
|
56
|
+
Checkbox,
|
|
51
57
|
Input,
|
|
52
58
|
Label,
|
|
53
59
|
Select,
|
|
@@ -56,6 +62,7 @@ import {
|
|
|
56
62
|
SelectTrigger,
|
|
57
63
|
SelectValue,
|
|
58
64
|
Skeleton,
|
|
65
|
+
Textarea,
|
|
59
66
|
} from '../components/ui';
|
|
60
67
|
import { useMoveTheWheels } from '../providers/MoveTheWheelsProvider';
|
|
61
68
|
import {
|
|
@@ -65,7 +72,10 @@ import {
|
|
|
65
72
|
useCarrierIntegrations,
|
|
66
73
|
} from '../hooks/useCarrierIntegrations';
|
|
67
74
|
import {
|
|
75
|
+
DEFAULT_GEOTAB_SERVER,
|
|
68
76
|
DEFAULT_SAMSARA_SHIPMENT_KEY,
|
|
77
|
+
GEOTAB_POLL_INTERVAL_MINUTES,
|
|
78
|
+
GEOTAB_RULE_EVENT_TYPES,
|
|
69
79
|
INTEGRATION_STATUSES,
|
|
70
80
|
MAX_UPDATES_PER_DELIVERY,
|
|
71
81
|
PLANNED_ELD_PROVIDERS,
|
|
@@ -74,14 +84,20 @@ import {
|
|
|
74
84
|
SAMSARA_SIGNATURE_HEADERS,
|
|
75
85
|
SIGNATURE_HEADER,
|
|
76
86
|
TRACKING_EVENT_TYPES,
|
|
87
|
+
buildGeotabConfig,
|
|
77
88
|
curlExample,
|
|
78
89
|
eventStatusTone,
|
|
79
90
|
examplePayload,
|
|
80
91
|
externalIdKeyError,
|
|
81
92
|
generateSigningSecret,
|
|
93
|
+
geotabPasswordError,
|
|
82
94
|
humanize,
|
|
83
95
|
integrationNameError,
|
|
84
96
|
integrationStatusTone,
|
|
97
|
+
isPolledProvider,
|
|
98
|
+
pollResultMessage,
|
|
99
|
+
pollStatusSummary,
|
|
100
|
+
pollStatusTone,
|
|
85
101
|
providerLabel,
|
|
86
102
|
samsaraSecretError,
|
|
87
103
|
signingSecretError,
|
|
@@ -192,9 +208,16 @@ function CreateIntegrationDialog({
|
|
|
192
208
|
const [secret, setSecret] = useState(() => generateSigningSecret());
|
|
193
209
|
const [samsaraSecret, setSamsaraSecret] = useState('');
|
|
194
210
|
const [shipmentKey, setShipmentKey] = useState('');
|
|
211
|
+
const [geotabServer, setGeotabServer] = useState('');
|
|
212
|
+
const [geotabDatabase, setGeotabDatabase] = useState('');
|
|
213
|
+
const [geotabUser, setGeotabUser] = useState('');
|
|
214
|
+
const [geotabPassword, setGeotabPassword] = useState('');
|
|
215
|
+
const [geotabRules, setGeotabRules] = useState('');
|
|
216
|
+
const [geotabLocations, setGeotabLocations] = useState(true);
|
|
195
217
|
const [error, setError] = useState<string | null>(null);
|
|
196
218
|
const [isSaving, setIsSaving] = useState(false);
|
|
197
219
|
const isSamsara = provider === 'SAMSARA';
|
|
220
|
+
const isGeotab = provider === 'GEOTAB';
|
|
198
221
|
|
|
199
222
|
const reset = () => {
|
|
200
223
|
setProvider('GENERIC_WEBHOOK');
|
|
@@ -202,16 +225,47 @@ function CreateIntegrationDialog({
|
|
|
202
225
|
setSecret(generateSigningSecret());
|
|
203
226
|
setSamsaraSecret('');
|
|
204
227
|
setShipmentKey('');
|
|
228
|
+
setGeotabServer('');
|
|
229
|
+
setGeotabDatabase('');
|
|
230
|
+
setGeotabUser('');
|
|
231
|
+
setGeotabPassword('');
|
|
232
|
+
setGeotabRules('');
|
|
233
|
+
setGeotabLocations(true);
|
|
205
234
|
setError(null);
|
|
206
235
|
};
|
|
207
236
|
|
|
237
|
+
const geotabInput = () => {
|
|
238
|
+
const config = buildGeotabConfig({
|
|
239
|
+
server: geotabServer,
|
|
240
|
+
database: geotabDatabase,
|
|
241
|
+
userName: geotabUser,
|
|
242
|
+
ruleMappings: geotabRules,
|
|
243
|
+
locationUpdates: geotabLocations,
|
|
244
|
+
});
|
|
245
|
+
if (!config.ok) return { error: config.error, input: null };
|
|
246
|
+
const passwordProblem = geotabPasswordError(geotabPassword);
|
|
247
|
+
if (passwordProblem) return { error: passwordProblem, input: null };
|
|
248
|
+
return {
|
|
249
|
+
error: null,
|
|
250
|
+
input: {
|
|
251
|
+
provider: 'GEOTAB' as const,
|
|
252
|
+
name,
|
|
253
|
+
apiSecret: geotabPassword,
|
|
254
|
+
config: config.config,
|
|
255
|
+
},
|
|
256
|
+
};
|
|
257
|
+
};
|
|
258
|
+
|
|
208
259
|
const submit = async (event: FormEvent) => {
|
|
209
260
|
event.preventDefault();
|
|
261
|
+
const geotab = isGeotab ? geotabInput() : null;
|
|
210
262
|
const problem =
|
|
211
263
|
integrationNameError(name) ??
|
|
212
|
-
(
|
|
213
|
-
? (
|
|
214
|
-
:
|
|
264
|
+
(isGeotab
|
|
265
|
+
? (geotab?.error ?? null)
|
|
266
|
+
: isSamsara
|
|
267
|
+
? (samsaraSecretError(samsaraSecret) ?? externalIdKeyError(shipmentKey))
|
|
268
|
+
: signingSecretError(secret));
|
|
215
269
|
if (problem) {
|
|
216
270
|
setError(problem);
|
|
217
271
|
return;
|
|
@@ -221,16 +275,18 @@ function CreateIntegrationDialog({
|
|
|
221
275
|
try {
|
|
222
276
|
const key = shipmentKey.trim();
|
|
223
277
|
const created = await actions.create(
|
|
224
|
-
|
|
225
|
-
?
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
278
|
+
geotab?.input
|
|
279
|
+
? geotab.input
|
|
280
|
+
: isSamsara
|
|
281
|
+
? {
|
|
282
|
+
provider: 'SAMSARA',
|
|
283
|
+
name,
|
|
284
|
+
apiSecret: samsaraSecret.trim(),
|
|
285
|
+
...(key ? { config: { shipmentExternalIdKey: key } } : {}),
|
|
286
|
+
}
|
|
287
|
+
: { provider: 'GENERIC_WEBHOOK', name, apiSecret: secret }
|
|
232
288
|
);
|
|
233
|
-
onCreated(created, isSamsara ? null : secret);
|
|
289
|
+
onCreated(created, isSamsara || isGeotab ? null : secret);
|
|
234
290
|
reset();
|
|
235
291
|
onOpenChange(false);
|
|
236
292
|
} catch (createError) {
|
|
@@ -253,8 +309,9 @@ function CreateIntegrationDialog({
|
|
|
253
309
|
<ResponsiveDialogHeader>
|
|
254
310
|
<ResponsiveDialogTitle>Connect a tracking feed</ResponsiveDialogTitle>
|
|
255
311
|
<ResponsiveDialogDescription>
|
|
256
|
-
|
|
257
|
-
|
|
312
|
+
{isGeotab
|
|
313
|
+
? `MoveTheWheels signs in to MyGeotab and reads new GPS positions and exception events every ${GEOTAB_POLL_INTERVAL_MINUTES} minutes. They become tracking events on the matching shipments.`
|
|
314
|
+
: 'A signed webhook from a carrier, ELD or GPS provider. Updates it sends become tracking events on the matching shipments.'}
|
|
258
315
|
</ResponsiveDialogDescription>
|
|
259
316
|
</ResponsiveDialogHeader>
|
|
260
317
|
<div className="space-y-1.5">
|
|
@@ -263,7 +320,13 @@ function CreateIntegrationDialog({
|
|
|
263
320
|
id="integration-name"
|
|
264
321
|
value={name}
|
|
265
322
|
maxLength={120}
|
|
266
|
-
placeholder={
|
|
323
|
+
placeholder={
|
|
324
|
+
isSamsara
|
|
325
|
+
? 'e.g. Samsara fleet'
|
|
326
|
+
: isGeotab
|
|
327
|
+
? 'e.g. Geotab fleet'
|
|
328
|
+
: 'e.g. Fleet GPS feed'
|
|
329
|
+
}
|
|
267
330
|
onChange={(event) => setName(event.target.value)}
|
|
268
331
|
autoFocus
|
|
269
332
|
/>
|
|
@@ -285,10 +348,92 @@ function CreateIntegrationDialog({
|
|
|
285
348
|
Signed webhook (any system that can send HTTPS POSTs)
|
|
286
349
|
</SelectItem>
|
|
287
350
|
<SelectItem value="SAMSARA">Samsara (ELD and telematics)</SelectItem>
|
|
351
|
+
<SelectItem value="GEOTAB">Geotab / MyGeotab (telematics, polled)</SelectItem>
|
|
288
352
|
</SelectContent>
|
|
289
353
|
</Select>
|
|
290
354
|
</div>
|
|
291
|
-
{
|
|
355
|
+
{isGeotab ? (
|
|
356
|
+
<>
|
|
357
|
+
<div className="grid gap-4 sm:grid-cols-2">
|
|
358
|
+
<div className="space-y-1.5">
|
|
359
|
+
<Label htmlFor="geotab-database">MyGeotab database</Label>
|
|
360
|
+
<Input
|
|
361
|
+
id="geotab-database"
|
|
362
|
+
value={geotabDatabase}
|
|
363
|
+
maxLength={255}
|
|
364
|
+
autoComplete="off"
|
|
365
|
+
spellCheck={false}
|
|
366
|
+
placeholder="e.g. acme_logistics"
|
|
367
|
+
onChange={(event) => setGeotabDatabase(event.target.value)}
|
|
368
|
+
/>
|
|
369
|
+
</div>
|
|
370
|
+
<div className="space-y-1.5">
|
|
371
|
+
<Label htmlFor="geotab-server">Server (optional)</Label>
|
|
372
|
+
<Input
|
|
373
|
+
id="geotab-server"
|
|
374
|
+
value={geotabServer}
|
|
375
|
+
maxLength={255}
|
|
376
|
+
autoComplete="off"
|
|
377
|
+
spellCheck={false}
|
|
378
|
+
placeholder={DEFAULT_GEOTAB_SERVER}
|
|
379
|
+
onChange={(event) => setGeotabServer(event.target.value)}
|
|
380
|
+
/>
|
|
381
|
+
</div>
|
|
382
|
+
<div className="space-y-1.5">
|
|
383
|
+
<Label htmlFor="geotab-user">User name</Label>
|
|
384
|
+
<Input
|
|
385
|
+
id="geotab-user"
|
|
386
|
+
value={geotabUser}
|
|
387
|
+
maxLength={255}
|
|
388
|
+
autoComplete="off"
|
|
389
|
+
spellCheck={false}
|
|
390
|
+
placeholder="e.g. mtw-api@acme.com"
|
|
391
|
+
onChange={(event) => setGeotabUser(event.target.value)}
|
|
392
|
+
/>
|
|
393
|
+
</div>
|
|
394
|
+
<div className="space-y-1.5">
|
|
395
|
+
<Label htmlFor="geotab-password">Password</Label>
|
|
396
|
+
<Input
|
|
397
|
+
id="geotab-password"
|
|
398
|
+
type="password"
|
|
399
|
+
autoComplete="new-password"
|
|
400
|
+
spellCheck={false}
|
|
401
|
+
value={geotabPassword}
|
|
402
|
+
onChange={(event) => setGeotabPassword(event.target.value)}
|
|
403
|
+
/>
|
|
404
|
+
</div>
|
|
405
|
+
</div>
|
|
406
|
+
<p className="text-xs text-text-secondary">
|
|
407
|
+
Use a dedicated MyGeotab user with read access to devices, GPS logs and exceptions.
|
|
408
|
+
MoveTheWheels stores the password encrypted and never shows it again.
|
|
409
|
+
</p>
|
|
410
|
+
<div className="flex items-center gap-3">
|
|
411
|
+
<Checkbox
|
|
412
|
+
id="geotab-locations"
|
|
413
|
+
checked={geotabLocations}
|
|
414
|
+
onCheckedChange={(value) => setGeotabLocations(value === true)}
|
|
415
|
+
/>
|
|
416
|
+
<Label htmlFor="geotab-locations">
|
|
417
|
+
Add each vehicle's latest GPS position as an In transit event
|
|
418
|
+
</Label>
|
|
419
|
+
</div>
|
|
420
|
+
<div className="space-y-1.5">
|
|
421
|
+
<Label htmlFor="geotab-rules">Exception rules to track (optional)</Label>
|
|
422
|
+
<Textarea
|
|
423
|
+
id="geotab-rules"
|
|
424
|
+
value={geotabRules}
|
|
425
|
+
rows={3}
|
|
426
|
+
spellCheck={false}
|
|
427
|
+
placeholder={'RuleArriveCustomerId = ARRIVED\nRuleLeaveDepotId = DEPARTED'}
|
|
428
|
+
onChange={(event) => setGeotabRules(event.target.value)}
|
|
429
|
+
/>
|
|
430
|
+
<p className="text-xs text-text-secondary">
|
|
431
|
+
One per line: a MyGeotab rule id (for example a zone arrival rule) and the event
|
|
432
|
+
it becomes: {GEOTAB_RULE_EVENT_TYPES.join(', ')}. Other rules are ignored.
|
|
433
|
+
</p>
|
|
434
|
+
</div>
|
|
435
|
+
</>
|
|
436
|
+
) : isSamsara ? (
|
|
292
437
|
<>
|
|
293
438
|
<div className="space-y-1.5">
|
|
294
439
|
<Label htmlFor="samsara-secret">Samsara webhook secret key</Label>
|
|
@@ -359,7 +504,10 @@ function CreateIntegrationDialog({
|
|
|
359
504
|
);
|
|
360
505
|
}
|
|
361
506
|
|
|
362
|
-
/**
|
|
507
|
+
/**
|
|
508
|
+
* Samsara issues the secret and Geotab's is the MyGeotab password, so
|
|
509
|
+
* replacing either means pasting the new value rather than generating one.
|
|
510
|
+
*/
|
|
363
511
|
function ReplaceSamsaraSecretDialog({
|
|
364
512
|
integration,
|
|
365
513
|
onClose,
|
|
@@ -372,6 +520,7 @@ function ReplaceSamsaraSecretDialog({
|
|
|
372
520
|
const [secret, setSecret] = useState('');
|
|
373
521
|
const [error, setError] = useState<string | null>(null);
|
|
374
522
|
const [isSaving, setIsSaving] = useState(false);
|
|
523
|
+
const isGeotab = integration?.provider === 'GEOTAB';
|
|
375
524
|
const close = () => {
|
|
376
525
|
setSecret('');
|
|
377
526
|
setError(null);
|
|
@@ -380,7 +529,7 @@ function ReplaceSamsaraSecretDialog({
|
|
|
380
529
|
const submit = async (event: FormEvent) => {
|
|
381
530
|
event.preventDefault();
|
|
382
531
|
if (!integration) return;
|
|
383
|
-
const problem = samsaraSecretError(secret);
|
|
532
|
+
const problem = isGeotab ? geotabPasswordError(secret) : samsaraSecretError(secret);
|
|
384
533
|
if (problem) {
|
|
385
534
|
setError(problem);
|
|
386
535
|
return;
|
|
@@ -388,7 +537,8 @@ function ReplaceSamsaraSecretDialog({
|
|
|
388
537
|
setIsSaving(true);
|
|
389
538
|
setError(null);
|
|
390
539
|
try {
|
|
391
|
-
|
|
540
|
+
// A MyGeotab password is kept exactly as typed; a Samsara key is trimmed.
|
|
541
|
+
await onReplace(integration, isGeotab ? secret : secret.trim());
|
|
392
542
|
close();
|
|
393
543
|
} catch (replaceError) {
|
|
394
544
|
setError(errorMessage(replaceError, 'Could not replace the secret.'));
|
|
@@ -402,15 +552,20 @@ function ReplaceSamsaraSecretDialog({
|
|
|
402
552
|
<form onSubmit={(event) => void submit(event)} className="space-y-4">
|
|
403
553
|
<ResponsiveDialogHeader>
|
|
404
554
|
<ResponsiveDialogTitle>
|
|
405
|
-
|
|
555
|
+
{isGeotab
|
|
556
|
+
? `Update the MyGeotab password for ${integration?.name ?? ''}`
|
|
557
|
+
: `Replace the Samsara secret for ${integration?.name ?? ''}`}
|
|
406
558
|
</ResponsiveDialogTitle>
|
|
407
559
|
<ResponsiveDialogDescription>
|
|
408
|
-
|
|
409
|
-
|
|
560
|
+
{isGeotab
|
|
561
|
+
? 'Enter the current password of the MyGeotab user this feed signs in as. The next poll signs in with it.'
|
|
562
|
+
: 'Regenerate the secret on the webhook page in Samsara, then paste the new key here. Deliveries signed with the old key are refused once you save.'}
|
|
410
563
|
</ResponsiveDialogDescription>
|
|
411
564
|
</ResponsiveDialogHeader>
|
|
412
565
|
<div className="space-y-1.5">
|
|
413
|
-
<Label htmlFor="samsara-new-secret">
|
|
566
|
+
<Label htmlFor="samsara-new-secret">
|
|
567
|
+
{isGeotab ? 'New MyGeotab password' : 'New Samsara webhook secret key'}
|
|
568
|
+
</Label>
|
|
414
569
|
<Input
|
|
415
570
|
id="samsara-new-secret"
|
|
416
571
|
type="password"
|
|
@@ -427,7 +582,7 @@ function ReplaceSamsaraSecretDialog({
|
|
|
427
582
|
Cancel
|
|
428
583
|
</Button>
|
|
429
584
|
<Button type="submit" disabled={isSaving}>
|
|
430
|
-
{isSaving ? 'Saving…' : 'Replace secret'}
|
|
585
|
+
{isSaving ? 'Saving…' : isGeotab ? 'Update password' : 'Replace secret'}
|
|
431
586
|
</Button>
|
|
432
587
|
</ResponsiveDialogFooter>
|
|
433
588
|
</form>
|
|
@@ -472,17 +627,76 @@ function SamsaraSetupInstructions({ url }: { url: string }) {
|
|
|
472
627
|
);
|
|
473
628
|
}
|
|
474
629
|
|
|
475
|
-
function
|
|
630
|
+
function GeotabSetupInstructions({ integration }: { integration: CarrierIntegration }) {
|
|
631
|
+
return (
|
|
632
|
+
<div className="space-y-3">
|
|
633
|
+
<p className="text-sm font-medium">How the Geotab feed works</p>
|
|
634
|
+
<ol className="list-decimal space-y-1 pl-5 text-xs text-text-secondary">
|
|
635
|
+
<li>
|
|
636
|
+
Every {GEOTAB_POLL_INTERVAL_MINUTES} minutes MoveTheWheels signs in to MyGeotab and reads
|
|
637
|
+
the GPS log and exception events added since the last poll. Nothing is set up in Geotab.
|
|
638
|
+
</li>
|
|
639
|
+
<li>
|
|
640
|
+
Each Geotab vehicle is matched to a MoveTheWheels vehicle by its name, licence plate or
|
|
641
|
+
VIN; the event goes to that vehicle's single in-progress route. Records for vehicles
|
|
642
|
+
that are not on a route are skipped.
|
|
643
|
+
</li>
|
|
644
|
+
<li>
|
|
645
|
+
The newest GPS position of each vehicle becomes an In transit event with its location,
|
|
646
|
+
when position updates are on. Mapped exception rules (typically zone arrivals and
|
|
647
|
+
departures) become the events they are mapped to.
|
|
648
|
+
</li>
|
|
649
|
+
<li>
|
|
650
|
+
Repeated sign-in failures slow the polling down so the MyGeotab user is not locked out;
|
|
651
|
+
update the password, then use Poll now.
|
|
652
|
+
</li>
|
|
653
|
+
</ol>
|
|
654
|
+
<PollStatusPanel integration={integration} />
|
|
655
|
+
</div>
|
|
656
|
+
);
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
function PollStatusPanel({ integration }: { integration: CarrierIntegration }) {
|
|
660
|
+
const pollStatus = integration.pollStatus;
|
|
661
|
+
return (
|
|
662
|
+
<div className="space-y-1 rounded-lg bg-bg-sunken px-3 py-2" data-testid="poll-status">
|
|
663
|
+
<div className="flex items-center gap-2">
|
|
664
|
+
<span className="text-xs font-medium">Latest poll</span>
|
|
665
|
+
{pollStatus?.lastPollStatus ? (
|
|
666
|
+
<Badge variant={pollStatusTone(pollStatus.lastPollStatus)}>
|
|
667
|
+
{humanize(pollStatus.lastPollStatus)}
|
|
668
|
+
</Badge>
|
|
669
|
+
) : null}
|
|
670
|
+
</div>
|
|
671
|
+
<p className="text-xs text-text-secondary">{pollStatusSummary(pollStatus, formatDateTime)}</p>
|
|
672
|
+
{pollStatus?.lastPollError ? (
|
|
673
|
+
<p className="break-words text-xs text-status-error-text">{pollStatus.lastPollError}</p>
|
|
674
|
+
) : null}
|
|
675
|
+
</div>
|
|
676
|
+
);
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
function DeliveryLog({
|
|
680
|
+
integrationId,
|
|
681
|
+
refreshKey,
|
|
682
|
+
polled = false,
|
|
683
|
+
}: {
|
|
684
|
+
integrationId: string;
|
|
685
|
+
refreshKey: number;
|
|
686
|
+
polled?: boolean;
|
|
687
|
+
}) {
|
|
476
688
|
const { events, isLoading, error } = useCarrierIntegrationEvents(integrationId, refreshKey);
|
|
477
689
|
return (
|
|
478
690
|
<div className="space-y-2">
|
|
479
|
-
<p className="text-sm font-medium">Recent deliveries</p>
|
|
691
|
+
<p className="text-sm font-medium">{polled ? 'Recent polls' : 'Recent deliveries'}</p>
|
|
480
692
|
<FormError message={error?.message} />
|
|
481
693
|
{isLoading && events.length === 0 ? (
|
|
482
694
|
<Skeleton className="h-12 w-full" />
|
|
483
695
|
) : events.length === 0 ? (
|
|
484
696
|
<p className="text-sm text-text-secondary">
|
|
485
|
-
|
|
697
|
+
{polled
|
|
698
|
+
? 'No polls with updates yet. Polls that find nothing to add are not listed.'
|
|
699
|
+
: 'No deliveries yet. Send a signed test update with the example below.'}
|
|
486
700
|
</p>
|
|
487
701
|
) : (
|
|
488
702
|
<ul className="space-y-2">
|
|
@@ -493,7 +707,7 @@ function DeliveryLog({ integrationId, refreshKey }: { integrationId: string; ref
|
|
|
493
707
|
>
|
|
494
708
|
<div className="min-w-0">
|
|
495
709
|
<p className="text-sm font-medium">
|
|
496
|
-
{event.eventType ? humanize(event.eventType) : 'Delivery'}
|
|
710
|
+
{event.eventType ? humanize(event.eventType) : polled ? 'Poll' : 'Delivery'}
|
|
497
711
|
{event.externalEventId ? (
|
|
498
712
|
<span className="ml-2 font-mono text-xs text-text-tertiary">
|
|
499
713
|
{event.externalEventId}
|
|
@@ -553,6 +767,7 @@ function IntegrationCard({
|
|
|
553
767
|
onToggle,
|
|
554
768
|
onSetStatus,
|
|
555
769
|
onRotate,
|
|
770
|
+
onPoll,
|
|
556
771
|
onDelete,
|
|
557
772
|
}: {
|
|
558
773
|
integration: CarrierIntegration;
|
|
@@ -564,9 +779,11 @@ function IntegrationCard({
|
|
|
564
779
|
onToggle: () => void;
|
|
565
780
|
onSetStatus: (status: IntegrationStatus) => void;
|
|
566
781
|
onRotate: () => void;
|
|
782
|
+
onPoll: () => void;
|
|
567
783
|
onDelete: () => void;
|
|
568
784
|
}) {
|
|
569
785
|
const isActive = integration.status === 'ACTIVE';
|
|
786
|
+
const polled = isPolledProvider(integration.provider);
|
|
570
787
|
return (
|
|
571
788
|
<Card>
|
|
572
789
|
<CardContent className="p-5">
|
|
@@ -579,8 +796,14 @@ function IntegrationCard({
|
|
|
579
796
|
</Badge>
|
|
580
797
|
</div>
|
|
581
798
|
<p className="text-xs text-text-secondary">
|
|
582
|
-
{providerLabel(integration.provider)} ·
|
|
799
|
+
{providerLabel(integration.provider)} ·{' '}
|
|
800
|
+
{statusExplanation(integration.status, integration.provider)}
|
|
583
801
|
</p>
|
|
802
|
+
{polled ? (
|
|
803
|
+
<p className="text-xs text-text-secondary">
|
|
804
|
+
{pollStatusSummary(integration.pollStatus, formatDateTime)}
|
|
805
|
+
</p>
|
|
806
|
+
) : null}
|
|
584
807
|
<p className="text-xs text-text-secondary">
|
|
585
808
|
Last accepted update:{' '}
|
|
586
809
|
{integration.lastSyncAt ? formatDateTime(integration.lastSyncAt) : 'none yet'}
|
|
@@ -608,9 +831,19 @@ function IntegrationCard({
|
|
|
608
831
|
)}
|
|
609
832
|
{isActive ? 'Pause' : 'Resume'}
|
|
610
833
|
</Button>
|
|
834
|
+
{polled ? (
|
|
835
|
+
<Button size="sm" variant="outline" disabled={busy || !isActive} onClick={onPoll}>
|
|
836
|
+
<DownloadCloud size={14} className="mr-1" />
|
|
837
|
+
Poll now
|
|
838
|
+
</Button>
|
|
839
|
+
) : null}
|
|
611
840
|
<Button size="sm" variant="outline" disabled={busy} onClick={onRotate}>
|
|
612
841
|
<KeyRound size={14} className="mr-1" />
|
|
613
|
-
{integration.provider === 'SAMSARA'
|
|
842
|
+
{integration.provider === 'SAMSARA'
|
|
843
|
+
? 'Replace secret'
|
|
844
|
+
: polled
|
|
845
|
+
? 'Update password'
|
|
846
|
+
: 'Rotate secret'}
|
|
614
847
|
</Button>
|
|
615
848
|
<Button
|
|
616
849
|
size="sm"
|
|
@@ -634,12 +867,14 @@ function IntegrationCard({
|
|
|
634
867
|
</div>
|
|
635
868
|
{expanded ? (
|
|
636
869
|
<div className="mt-4 grid gap-6 border-t border-border-subtle pt-4 lg:grid-cols-2">
|
|
637
|
-
{
|
|
870
|
+
{polled ? (
|
|
871
|
+
<GeotabSetupInstructions integration={integration} />
|
|
872
|
+
) : integration.provider === 'SAMSARA' ? (
|
|
638
873
|
<SamsaraSetupInstructions url={url} />
|
|
639
874
|
) : (
|
|
640
875
|
<SetupInstructions url={url} />
|
|
641
876
|
)}
|
|
642
|
-
<DeliveryLog integrationId={integration.id} refreshKey={refreshKey} />
|
|
877
|
+
<DeliveryLog integrationId={integration.id} refreshKey={refreshKey} polled={polled} />
|
|
643
878
|
</div>
|
|
644
879
|
) : null}
|
|
645
880
|
</CardContent>
|
|
@@ -759,10 +994,28 @@ function WorkspaceIntegrationsPage() {
|
|
|
759
994
|
const replaceSamsaraSecret = async (integration: CarrierIntegration, secret: string) => {
|
|
760
995
|
await exclusive(integration.id, async () => {
|
|
761
996
|
await actions.update(integration.id, { apiSecret: secret });
|
|
762
|
-
done(
|
|
997
|
+
done(
|
|
998
|
+
integration.provider === 'GEOTAB'
|
|
999
|
+
? `Updated the MyGeotab password for ${integration.name}.`
|
|
1000
|
+
: `Replaced the Samsara secret for ${integration.name}.`
|
|
1001
|
+
);
|
|
763
1002
|
});
|
|
764
1003
|
};
|
|
765
1004
|
|
|
1005
|
+
const pollNow = async (integration: CarrierIntegration) => {
|
|
1006
|
+
try {
|
|
1007
|
+
const result = await actions.pollNow(integration.id);
|
|
1008
|
+
if (result.status === 'FAILED') {
|
|
1009
|
+
setActionError(pollResultMessage(integration.name, result));
|
|
1010
|
+
refresh();
|
|
1011
|
+
return;
|
|
1012
|
+
}
|
|
1013
|
+
done(pollResultMessage(integration.name, result));
|
|
1014
|
+
} catch (pollError) {
|
|
1015
|
+
setActionError(errorMessage(pollError, `Could not poll ${integration.name}.`));
|
|
1016
|
+
}
|
|
1017
|
+
};
|
|
1018
|
+
|
|
766
1019
|
const removeIntegration = async (integration: CarrierIntegration) => {
|
|
767
1020
|
if (
|
|
768
1021
|
!window.confirm(
|
|
@@ -886,10 +1139,11 @@ function WorkspaceIntegrationsPage() {
|
|
|
886
1139
|
void exclusive(integration.id, () => setIntegrationStatus(integration, next))
|
|
887
1140
|
}
|
|
888
1141
|
onRotate={() =>
|
|
889
|
-
integration.provider === 'SAMSARA'
|
|
1142
|
+
integration.provider === 'SAMSARA' || isPolledProvider(integration.provider)
|
|
890
1143
|
? setReplaceTarget(integration)
|
|
891
1144
|
: void exclusive(integration.id, () => rotateSecret(integration))
|
|
892
1145
|
}
|
|
1146
|
+
onPoll={() => void exclusive(integration.id, () => pollNow(integration))}
|
|
893
1147
|
onDelete={() => void exclusive(integration.id, () => removeIntegration(integration))}
|
|
894
1148
|
/>
|
|
895
1149
|
))}
|
|
@@ -926,7 +1180,8 @@ function WorkspaceIntegrationsPage() {
|
|
|
926
1180
|
<CardContent className="space-y-2 p-5">
|
|
927
1181
|
<p className="text-sm font-medium">Carrier and ELD networks</p>
|
|
928
1182
|
<p className="text-sm text-text-secondary">
|
|
929
|
-
Samsara
|
|
1183
|
+
Samsara and Geotab connect directly: choose them when you connect a feed. Direct
|
|
1184
|
+
connections to{' '}
|
|
930
1185
|
{[
|
|
931
1186
|
...ROADMAP_PROVIDERS.map((provider) => provider.label),
|
|
932
1187
|
...PLANNED_ELD_PROVIDERS,
|
|
@@ -936,6 +1191,7 @@ function WorkspaceIntegrationsPage() {
|
|
|
936
1191
|
</p>
|
|
937
1192
|
<div className="flex flex-wrap gap-2">
|
|
938
1193
|
<Badge variant="default">Samsara · available</Badge>
|
|
1194
|
+
<Badge variant="default">Geotab · available</Badge>
|
|
939
1195
|
{PLANNED_ELD_PROVIDERS.map((label) => (
|
|
940
1196
|
<Badge key={label} variant="outline">
|
|
941
1197
|
{label} · not available yet
|