@burdenoff/microfe-movethewheels 2026.1108.3 → 2026.1108.5

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.
@@ -2,282 +2,424 @@ import { Activity as e } from "../node_modules/lucide-react/dist/esm/icons/activ
2
2
  import { Check as t } from "../node_modules/lucide-react/dist/esm/icons/check.js";
3
3
  import { ChevronDown as n } from "../node_modules/lucide-react/dist/esm/icons/chevron-down.js";
4
4
  import { ChevronUp as r } from "../node_modules/lucide-react/dist/esm/icons/chevron-up.js";
5
- import { Copy as i } from "../node_modules/lucide-react/dist/esm/icons/copy.js";
6
- import { KeyRound as a } from "../node_modules/lucide-react/dist/esm/icons/key-round.js";
7
- import { Pause as o } from "../node_modules/lucide-react/dist/esm/icons/pause.js";
8
- import { Play as s } from "../node_modules/lucide-react/dist/esm/icons/play.js";
9
- import { Plug as c } from "../node_modules/lucide-react/dist/esm/icons/plug.js";
10
- import { Plus as l } from "../node_modules/lucide-react/dist/esm/icons/plus.js";
11
- import { RefreshCw as u } from "../node_modules/lucide-react/dist/esm/icons/refresh-cw.js";
12
- import { ShieldCheck as d } from "../node_modules/lucide-react/dist/esm/icons/shield-check.js";
13
- import { Trash2 as f } from "../node_modules/lucide-react/dist/esm/icons/trash-2.js";
14
- import { useMoveTheWheels as p } from "../providers/MoveTheWheelsProvider.js";
15
- import { formatDateTime as m } from "../utils/formatters.js";
16
- import { Badge as h, Button as g, Card as _, CardContent as v, Input as y, Label as b, Select as ee, SelectContent as te, SelectItem as x, SelectTrigger as ne, SelectValue as re, Skeleton as S } from "../components/ui.js";
17
- import { PageLayout as C } from "../components/PageLayout.js";
18
- import { MetricCard as w, MetricGrid as ie } from "../components/MetricCard.js";
19
- import { FormError as T } from "../components/FormError.js";
20
- import { Notice as ae, useNotice as oe } from "../components/Notice.js";
21
- import { DEFAULT_SAMSARA_SHIPMENT_KEY as E, INTEGRATION_STATUSES as se, PLANNED_ELD_PROVIDERS as ce, ROADMAP_PROVIDERS as le, SAMSARA_EVENT_TYPES as ue, SAMSARA_SIGNATURE_HEADERS as de, SIGNATURE_HEADER as D, TRACKING_EVENT_TYPES as fe, curlExample as O, eventStatusTone as pe, examplePayload as k, externalIdKeyError as me, generateSigningSecret as A, humanize as j, integrationNameError as M, integrationStatusTone as he, providerLabel as ge, samsaraSecretError as N, signingSecretError as _e, statusExplanation as P, webhookUrl as ve } from "../utils/carrierIntegrations.js";
22
- import { useCarrierIntegrationActions as ye, useCarrierIntegrationCounts as be, useCarrierIntegrationEvents as F, useCarrierIntegrations as xe } from "../hooks/useCarrierIntegrations.js";
23
- import { useEffect as Se, useRef as Ce, useState as I } from "react";
24
- import { Fragment as L, jsx as R, jsxs as z } from "react/jsx-runtime";
25
- import { CTAOverflowMenu as we, PagePurpose as Te, ResponsiveDialog as B, ResponsiveDialogContent as V, ResponsiveDialogDescription as H, ResponsiveDialogFooter as U, ResponsiveDialogHeader as W, ResponsiveDialogTitle as G } from "@burdenoff/fe-libs/ui";
5
+ import { CloudDownload as i } from "../node_modules/lucide-react/dist/esm/icons/cloud-download.js";
6
+ import { Copy as a } from "../node_modules/lucide-react/dist/esm/icons/copy.js";
7
+ import { KeyRound as o } from "../node_modules/lucide-react/dist/esm/icons/key-round.js";
8
+ import { Pause as s } from "../node_modules/lucide-react/dist/esm/icons/pause.js";
9
+ import { Play as c } from "../node_modules/lucide-react/dist/esm/icons/play.js";
10
+ import { Plug as l } from "../node_modules/lucide-react/dist/esm/icons/plug.js";
11
+ import { Plus as u } from "../node_modules/lucide-react/dist/esm/icons/plus.js";
12
+ import { RefreshCw as d } from "../node_modules/lucide-react/dist/esm/icons/refresh-cw.js";
13
+ import { ShieldCheck as f } from "../node_modules/lucide-react/dist/esm/icons/shield-check.js";
14
+ import { Trash2 as p } from "../node_modules/lucide-react/dist/esm/icons/trash-2.js";
15
+ import { useMoveTheWheels as m } from "../providers/MoveTheWheelsProvider.js";
16
+ import { formatDateTime as h } from "../utils/formatters.js";
17
+ import { Badge as g, Button as _, Card as v, CardContent as y, Checkbox as b, Input as x, Label as S, Select as C, SelectContent as ee, SelectItem as w, SelectTrigger as te, SelectValue as ne, Skeleton as T, Textarea as re } from "../components/ui.js";
18
+ import { PageLayout as ie } from "../components/PageLayout.js";
19
+ import { MetricCard as E, MetricGrid as ae } from "../components/MetricCard.js";
20
+ import { FormError as D } from "../components/FormError.js";
21
+ import { Notice as oe, useNotice as se } from "../components/Notice.js";
22
+ import { DEFAULT_GEOTAB_SERVER as O, DEFAULT_SAMSARA_SHIPMENT_KEY as k, GEOTAB_RULE_EVENT_TYPES as A, INTEGRATION_STATUSES as ce, MOTIVE_ACTIONS as j, MOTIVE_SIGNATURE_HEADER as le, ROADMAP_PROVIDERS as M, SAMSARA_EVENT_TYPES as ue, SAMSARA_SIGNATURE_HEADERS as N, SIGNATURE_HEADER as P, TRACKING_EVENT_TYPES as F, buildGeotabConfig as I, curlExample as L, eventStatusTone as R, examplePayload as z, externalIdKeyError as B, generateSigningSecret as V, geotabPasswordError as H, humanize as U, integrationNameError as W, integrationStatusTone as de, isPolledProvider as fe, pollResultMessage as pe, pollStatusSummary as me, pollStatusTone as he, providerLabel as ge, samsaraSecretError as _e, signingSecretError as G, statusExplanation as ve, webhookUrl as ye } from "../utils/carrierIntegrations.js";
23
+ import { useCarrierIntegrationActions as be, useCarrierIntegrationCounts as xe, useCarrierIntegrationEvents as Se, useCarrierIntegrations as Ce } from "../hooks/useCarrierIntegrations.js";
24
+ import { useEffect as we, useRef as Te, useState as K } from "react";
25
+ import { Fragment as Ee, jsx as q, jsxs as J } from "react/jsx-runtime";
26
+ import { CTAOverflowMenu as De, PagePurpose as Oe, ResponsiveDialog as Y, ResponsiveDialogContent as X, ResponsiveDialogDescription as ke, ResponsiveDialogFooter as Ae, ResponsiveDialogHeader as je, ResponsiveDialogTitle as Me } from "@burdenoff/fe-libs/ui";
26
27
  //#region src/movethewheels/pages/IntegrationsPage.tsx
27
- var K = 20, q = "ALL";
28
- function J(e, t) {
28
+ var Ne = 20, Z = "ALL";
29
+ function Q(e, t) {
29
30
  return e instanceof Error && e.message ? e.message : t;
30
31
  }
31
- function Y({ label: e, value: n, multiline: r }) {
32
- let [a, o] = I(!1), s = async () => {
32
+ function $({ label: e, value: n, multiline: r }) {
33
+ let [i, o] = K(!1), s = async () => {
33
34
  try {
34
35
  await navigator.clipboard.writeText(n), o(!0), window.setTimeout(() => o(!1), 2e3);
35
36
  } catch {
36
37
  o(!1);
37
38
  }
38
39
  };
39
- return /* @__PURE__ */ z("div", {
40
+ return /* @__PURE__ */ J("div", {
40
41
  className: "space-y-1",
41
- children: [/* @__PURE__ */ z("div", {
42
+ children: [/* @__PURE__ */ J("div", {
42
43
  className: "flex items-center justify-between gap-2",
43
- children: [/* @__PURE__ */ R("span", {
44
+ children: [/* @__PURE__ */ q("span", {
44
45
  className: "text-xs font-medium text-text-secondary",
45
46
  children: e
46
- }), /* @__PURE__ */ z(g, {
47
+ }), /* @__PURE__ */ J(_, {
47
48
  type: "button",
48
49
  size: "sm",
49
50
  variant: "ghost",
50
51
  onClick: () => void s(),
51
52
  "aria-label": `Copy ${e.toLowerCase()}`,
52
- children: [R(a ? t : i, {
53
+ children: [q(i ? t : a, {
53
54
  size: 14,
54
55
  className: "mr-1"
55
- }), a ? "Copied" : "Copy"]
56
+ }), i ? "Copied" : "Copy"]
56
57
  })]
57
- }), r ? /* @__PURE__ */ R("pre", {
58
+ }), r ? /* @__PURE__ */ q("pre", {
58
59
  className: "max-h-64 overflow-auto whitespace-pre-wrap break-all rounded-lg bg-bg-sunken px-3 py-2 font-mono text-xs text-text-primary",
59
60
  children: n
60
- }) : /* @__PURE__ */ R("code", {
61
+ }) : /* @__PURE__ */ q("code", {
61
62
  className: "block break-all rounded-lg bg-bg-sunken px-3 py-2 font-mono text-xs text-text-primary",
62
63
  children: n
63
64
  })]
64
65
  });
65
66
  }
66
- function Ee({ secret: e, integrationName: t, onClose: n }) {
67
- return /* @__PURE__ */ R(B, {
67
+ function Pe({ secret: e, integrationName: t, onClose: n }) {
68
+ return /* @__PURE__ */ q(Y, {
68
69
  open: e !== null,
69
70
  onOpenChange: (e) => !e && n(),
70
- children: /* @__PURE__ */ z(V, { children: [
71
- /* @__PURE__ */ z(W, { children: [/* @__PURE__ */ z(G, { children: ["Signing secret for ", t] }), /* @__PURE__ */ R(H, { children: "Copy it into the sending system now. MoveTheWheels stores it to verify deliveries but will not show it again; rotate it if it is lost." })] }),
72
- e ? /* @__PURE__ */ R(Y, {
71
+ children: /* @__PURE__ */ J(X, { children: [
72
+ /* @__PURE__ */ J(je, { children: [/* @__PURE__ */ J(Me, { children: ["Signing secret for ", t] }), /* @__PURE__ */ q(ke, { children: "Copy it into the sending system now. MoveTheWheels stores it to verify deliveries but will not show it again; rotate it if it is lost." })] }),
73
+ e ? /* @__PURE__ */ q($, {
73
74
  label: "Signing secret",
74
75
  value: e
75
76
  }, e) : null,
76
- /* @__PURE__ */ R(U, { children: /* @__PURE__ */ R(g, {
77
+ /* @__PURE__ */ q(Ae, { children: /* @__PURE__ */ q(_, {
77
78
  onClick: n,
78
79
  children: "I have saved it"
79
80
  }) })
80
81
  ] })
81
82
  });
82
83
  }
83
- function De({ open: e, onOpenChange: t, onCreated: n }) {
84
- let r = ye(), [i, a] = I("GENERIC_WEBHOOK"), [o, s] = I(""), [c, l] = I(() => A()), [d, f] = I(""), [p, m] = I(""), [h, _] = I(null), [v, S] = I(!1), C = i === "SAMSARA", w = () => {
85
- a("GENERIC_WEBHOOK"), s(""), l(A()), f(""), m(""), _(null);
86
- }, ie = async (e) => {
84
+ function Fe({ open: e, onOpenChange: t, onCreated: n }) {
85
+ let r = be(), [i, a] = K("GENERIC_WEBHOOK"), [o, s] = K(""), [c, l] = K(() => V()), [u, f] = K(""), [p, m] = K(""), [h, g] = K(""), [v, y] = K(""), [T, ie] = K(""), [E, ae] = K(""), [oe, se] = K(""), [ce, j] = K(!0), [le, M] = K(null), [ue, N] = K(!1), P = i === "SAMSARA", F = i === "GEOTAB", L = i === "MOTIVE", R = () => {
86
+ a("GENERIC_WEBHOOK"), s(""), l(V()), f(""), m(""), g(""), y(""), ie(""), ae(""), se(""), j(!0), M(null);
87
+ }, z = () => {
88
+ let e = I({
89
+ server: h,
90
+ database: v,
91
+ userName: T,
92
+ ruleMappings: oe,
93
+ locationUpdates: ce
94
+ });
95
+ if (!e.ok) return {
96
+ error: e.error,
97
+ input: null
98
+ };
99
+ let t = H(E);
100
+ return t ? {
101
+ error: t,
102
+ input: null
103
+ } : {
104
+ error: null,
105
+ input: {
106
+ provider: "GEOTAB",
107
+ name: o,
108
+ apiSecret: E,
109
+ config: e.config
110
+ }
111
+ };
112
+ }, U = async (e) => {
87
113
  e.preventDefault();
88
- let i = M(o) ?? (C ? N(d) ?? me(p) : _e(c));
89
- if (i) {
90
- _(i);
114
+ let i = F ? z() : null, a = W(o) ?? (F ? i?.error ?? null : P ? _e(u) ?? B(p) : G(c));
115
+ if (a) {
116
+ M(a);
91
117
  return;
92
118
  }
93
- S(!0), _(null);
119
+ N(!0), M(null);
94
120
  try {
95
121
  let e = p.trim();
96
- n(await r.create(C ? {
122
+ n(await r.create(i?.input ? i.input : P ? {
97
123
  provider: "SAMSARA",
98
124
  name: o,
99
- apiSecret: d.trim(),
125
+ apiSecret: u.trim(),
100
126
  ...e ? { config: { shipmentExternalIdKey: e } } : {}
101
127
  } : {
102
- provider: "GENERIC_WEBHOOK",
128
+ provider: L ? "MOTIVE" : "GENERIC_WEBHOOK",
103
129
  name: o,
104
130
  apiSecret: c
105
- }), C ? null : c), w(), t(!1);
131
+ }), P || F ? null : c), R(), t(!1);
106
132
  } catch (e) {
107
- _(J(e, "Could not create the integration."));
133
+ M(Q(e, "Could not create the integration."));
108
134
  } finally {
109
- S(!1);
135
+ N(!1);
110
136
  }
111
137
  };
112
- return /* @__PURE__ */ R(B, {
138
+ return /* @__PURE__ */ q(Y, {
113
139
  open: e,
114
140
  onOpenChange: (e) => {
115
- e || w(), t(e);
141
+ e || R(), t(e);
116
142
  },
117
- children: /* @__PURE__ */ R(V, { children: /* @__PURE__ */ z("form", {
118
- onSubmit: (e) => void ie(e),
143
+ children: /* @__PURE__ */ q(X, { children: /* @__PURE__ */ J("form", {
144
+ onSubmit: (e) => void U(e),
119
145
  className: "space-y-4",
120
146
  children: [
121
- /* @__PURE__ */ z(W, { children: [/* @__PURE__ */ R(G, { children: "Connect a tracking feed" }), /* @__PURE__ */ R(H, { children: "A signed webhook from a carrier, ELD or GPS provider. Updates it sends become tracking events on the matching shipments." })] }),
122
- /* @__PURE__ */ z("div", {
147
+ /* @__PURE__ */ J(je, { children: [/* @__PURE__ */ q(Me, { children: "Connect a tracking feed" }), /* @__PURE__ */ q(ke, { children: F ? "MoveTheWheels signs in to MyGeotab and reads new GPS positions and exception events every 5 minutes. They become tracking events on the matching shipments." : "A signed webhook from a carrier, ELD or GPS provider. Updates it sends become tracking events on the matching shipments." })] }),
148
+ /* @__PURE__ */ J("div", {
123
149
  className: "space-y-1.5",
124
- children: [/* @__PURE__ */ R(b, {
150
+ children: [/* @__PURE__ */ q(S, {
125
151
  htmlFor: "integration-name",
126
152
  children: "Name"
127
- }), /* @__PURE__ */ R(y, {
153
+ }), /* @__PURE__ */ q(x, {
128
154
  id: "integration-name",
129
155
  value: o,
130
156
  maxLength: 120,
131
- placeholder: C ? "e.g. Samsara fleet" : "e.g. Fleet GPS feed",
157
+ placeholder: P ? "e.g. Samsara fleet" : F ? "e.g. Geotab fleet" : L ? "e.g. Motive fleet" : "e.g. Fleet GPS feed",
132
158
  onChange: (e) => s(e.target.value),
133
159
  autoFocus: !0
134
160
  })]
135
161
  }),
136
- /* @__PURE__ */ z("div", {
162
+ /* @__PURE__ */ J("div", {
137
163
  className: "space-y-1.5",
138
- children: [/* @__PURE__ */ R(b, {
164
+ children: [/* @__PURE__ */ q(S, {
139
165
  htmlFor: "integration-type",
140
166
  children: "Type"
141
- }), /* @__PURE__ */ z(ee, {
167
+ }), /* @__PURE__ */ J(C, {
142
168
  value: i,
143
169
  onValueChange: (e) => {
144
- a(e), _(null);
170
+ a(e), M(null);
145
171
  },
146
- children: [/* @__PURE__ */ R(ne, {
172
+ children: [/* @__PURE__ */ q(te, {
147
173
  id: "integration-type",
148
174
  "aria-label": "Type",
149
- children: /* @__PURE__ */ R(re, {})
150
- }), /* @__PURE__ */ z(te, { children: [/* @__PURE__ */ R(x, {
151
- value: "GENERIC_WEBHOOK",
152
- children: "Signed webhook (any system that can send HTTPS POSTs)"
153
- }), /* @__PURE__ */ R(x, {
154
- value: "SAMSARA",
155
- children: "Samsara (ELD and telematics)"
156
- })] })]
175
+ children: /* @__PURE__ */ q(ne, {})
176
+ }), /* @__PURE__ */ J(ee, { children: [
177
+ /* @__PURE__ */ q(w, {
178
+ value: "GENERIC_WEBHOOK",
179
+ children: "Signed webhook (any system that can send HTTPS POSTs)"
180
+ }),
181
+ /* @__PURE__ */ q(w, {
182
+ value: "SAMSARA",
183
+ children: "Samsara (ELD and telematics)"
184
+ }),
185
+ /* @__PURE__ */ q(w, {
186
+ value: "MOTIVE",
187
+ children: "Motive, formerly KeepTruckin (ELD and telematics)"
188
+ }),
189
+ /* @__PURE__ */ q(w, {
190
+ value: "GEOTAB",
191
+ children: "Geotab / MyGeotab (telematics, polled)"
192
+ })
193
+ ] })]
157
194
  })]
158
195
  }),
159
- C ? /* @__PURE__ */ z(L, { children: [/* @__PURE__ */ z("div", {
196
+ F ? /* @__PURE__ */ J(Ee, { children: [
197
+ /* @__PURE__ */ J("div", {
198
+ className: "grid gap-4 sm:grid-cols-2",
199
+ children: [
200
+ /* @__PURE__ */ J("div", {
201
+ className: "space-y-1.5",
202
+ children: [/* @__PURE__ */ q(S, {
203
+ htmlFor: "geotab-database",
204
+ children: "MyGeotab database"
205
+ }), /* @__PURE__ */ q(x, {
206
+ id: "geotab-database",
207
+ value: v,
208
+ maxLength: 255,
209
+ autoComplete: "off",
210
+ spellCheck: !1,
211
+ placeholder: "e.g. acme_logistics",
212
+ onChange: (e) => y(e.target.value)
213
+ })]
214
+ }),
215
+ /* @__PURE__ */ J("div", {
216
+ className: "space-y-1.5",
217
+ children: [/* @__PURE__ */ q(S, {
218
+ htmlFor: "geotab-server",
219
+ children: "Server (optional)"
220
+ }), /* @__PURE__ */ q(x, {
221
+ id: "geotab-server",
222
+ value: h,
223
+ maxLength: 255,
224
+ autoComplete: "off",
225
+ spellCheck: !1,
226
+ placeholder: O,
227
+ onChange: (e) => g(e.target.value)
228
+ })]
229
+ }),
230
+ /* @__PURE__ */ J("div", {
231
+ className: "space-y-1.5",
232
+ children: [/* @__PURE__ */ q(S, {
233
+ htmlFor: "geotab-user",
234
+ children: "User name"
235
+ }), /* @__PURE__ */ q(x, {
236
+ id: "geotab-user",
237
+ value: T,
238
+ maxLength: 255,
239
+ autoComplete: "off",
240
+ spellCheck: !1,
241
+ placeholder: "e.g. mtw-api@acme.com",
242
+ onChange: (e) => ie(e.target.value)
243
+ })]
244
+ }),
245
+ /* @__PURE__ */ J("div", {
246
+ className: "space-y-1.5",
247
+ children: [/* @__PURE__ */ q(S, {
248
+ htmlFor: "geotab-password",
249
+ children: "Password"
250
+ }), /* @__PURE__ */ q(x, {
251
+ id: "geotab-password",
252
+ type: "password",
253
+ autoComplete: "new-password",
254
+ spellCheck: !1,
255
+ value: E,
256
+ onChange: (e) => ae(e.target.value)
257
+ })]
258
+ })
259
+ ]
260
+ }),
261
+ /* @__PURE__ */ q("p", {
262
+ className: "text-xs text-text-secondary",
263
+ children: "Use a dedicated MyGeotab user with read access to devices, GPS logs and exceptions. MoveTheWheels stores the password encrypted and never shows it again."
264
+ }),
265
+ /* @__PURE__ */ J("div", {
266
+ className: "flex items-center gap-3",
267
+ children: [/* @__PURE__ */ q(b, {
268
+ id: "geotab-locations",
269
+ checked: ce,
270
+ onCheckedChange: (e) => j(e === !0)
271
+ }), /* @__PURE__ */ q(S, {
272
+ htmlFor: "geotab-locations",
273
+ children: "Add each vehicle's latest GPS position as an In transit event"
274
+ })]
275
+ }),
276
+ /* @__PURE__ */ J("div", {
277
+ className: "space-y-1.5",
278
+ children: [
279
+ /* @__PURE__ */ q(S, {
280
+ htmlFor: "geotab-rules",
281
+ children: "Exception rules to track (optional)"
282
+ }),
283
+ /* @__PURE__ */ q(re, {
284
+ id: "geotab-rules",
285
+ value: oe,
286
+ rows: 3,
287
+ spellCheck: !1,
288
+ placeholder: "RuleArriveCustomerId = ARRIVED\nRuleLeaveDepotId = DEPARTED",
289
+ onChange: (e) => se(e.target.value)
290
+ }),
291
+ /* @__PURE__ */ J("p", {
292
+ className: "text-xs text-text-secondary",
293
+ children: [
294
+ "One per line: a MyGeotab rule id (for example a zone arrival rule) and the event it becomes: ",
295
+ A.join(", "),
296
+ ". Other rules are ignored."
297
+ ]
298
+ })
299
+ ]
300
+ })
301
+ ] }) : P ? /* @__PURE__ */ J(Ee, { children: [/* @__PURE__ */ J("div", {
160
302
  className: "space-y-1.5",
161
303
  children: [
162
- /* @__PURE__ */ R(b, {
304
+ /* @__PURE__ */ q(S, {
163
305
  htmlFor: "samsara-secret",
164
306
  children: "Samsara webhook secret key"
165
307
  }),
166
- /* @__PURE__ */ R(y, {
308
+ /* @__PURE__ */ q(x, {
167
309
  id: "samsara-secret",
168
310
  type: "password",
169
311
  autoComplete: "off",
170
312
  spellCheck: !1,
171
- value: d,
313
+ value: u,
172
314
  placeholder: "Paste from Samsara → Settings → Webhooks",
173
315
  onChange: (e) => f(e.target.value)
174
316
  }),
175
- /* @__PURE__ */ R("p", {
317
+ /* @__PURE__ */ q("p", {
176
318
  className: "text-xs text-text-secondary",
177
319
  children: "Create the webhook in Samsara first; its page shows this key. MoveTheWheels stores it encrypted and never shows it again."
178
320
  })
179
321
  ]
180
- }), /* @__PURE__ */ z("div", {
322
+ }), /* @__PURE__ */ J("div", {
181
323
  className: "space-y-1.5",
182
324
  children: [
183
- /* @__PURE__ */ R(b, {
325
+ /* @__PURE__ */ q(S, {
184
326
  htmlFor: "samsara-shipment-key",
185
327
  children: "Shipment external ID key (optional)"
186
328
  }),
187
- /* @__PURE__ */ R(y, {
329
+ /* @__PURE__ */ q(x, {
188
330
  id: "samsara-shipment-key",
189
331
  value: p,
190
332
  maxLength: 64,
191
- placeholder: E,
333
+ placeholder: k,
192
334
  onChange: (e) => m(e.target.value)
193
335
  }),
194
- /* @__PURE__ */ z("p", {
336
+ /* @__PURE__ */ J("p", {
195
337
  className: "text-xs text-text-secondary",
196
338
  children: [
197
339
  "The external ID on a Samsara route or stop that holds the MoveTheWheels tracking number. Leave blank to use",
198
340
  " ",
199
- /* @__PURE__ */ R("code", {
341
+ /* @__PURE__ */ q("code", {
200
342
  className: "font-mono",
201
- children: E
343
+ children: k
202
344
  }),
203
345
  "."
204
346
  ]
205
347
  })
206
348
  ]
207
- })] }) : /* @__PURE__ */ z("div", {
349
+ })] }) : /* @__PURE__ */ J("div", {
208
350
  className: "space-y-1.5",
209
351
  children: [
210
- /* @__PURE__ */ z("div", {
352
+ /* @__PURE__ */ J("div", {
211
353
  className: "flex items-center justify-between",
212
- children: [/* @__PURE__ */ R(b, { children: "Signing secret" }), /* @__PURE__ */ z(g, {
354
+ children: [/* @__PURE__ */ q(S, { children: "Signing secret" }), /* @__PURE__ */ J(_, {
213
355
  type: "button",
214
356
  size: "sm",
215
357
  variant: "ghost",
216
- onClick: () => l(A()),
217
- children: [/* @__PURE__ */ R(u, {
358
+ onClick: () => l(V()),
359
+ children: [/* @__PURE__ */ q(d, {
218
360
  size: 14,
219
361
  className: "mr-1"
220
362
  }), "Generate another"]
221
363
  })]
222
364
  }),
223
- /* @__PURE__ */ R("code", {
365
+ /* @__PURE__ */ q("code", {
224
366
  className: "block break-all rounded-lg bg-bg-sunken px-3 py-2 font-mono text-xs",
225
367
  children: c
226
368
  }),
227
- /* @__PURE__ */ R("p", {
369
+ /* @__PURE__ */ q("p", {
228
370
  className: "text-xs text-text-secondary",
229
- children: "Generated in your browser. You can copy it on the next step."
371
+ children: L ? "Generated in your browser. You can copy it on the next step and enter it as the secret on the Motive webhook." : "Generated in your browser. You can copy it on the next step."
230
372
  })
231
373
  ]
232
374
  }),
233
- /* @__PURE__ */ R(T, { message: h }),
234
- /* @__PURE__ */ z(U, { children: [/* @__PURE__ */ R(g, {
375
+ /* @__PURE__ */ q(D, { message: le }),
376
+ /* @__PURE__ */ J(Ae, { children: [/* @__PURE__ */ q(_, {
235
377
  type: "button",
236
378
  variant: "outline",
237
379
  onClick: () => t(!1),
238
380
  children: "Cancel"
239
- }), /* @__PURE__ */ R(g, {
381
+ }), /* @__PURE__ */ q(_, {
240
382
  type: "submit",
241
- disabled: v,
242
- children: v ? "Connecting…" : "Connect"
383
+ disabled: ue,
384
+ children: ue ? "Connecting…" : "Connect"
243
385
  })] })
244
386
  ]
245
387
  }) })
246
388
  });
247
389
  }
248
- function Oe({ integration: e, onClose: t, onReplace: n }) {
249
- let [r, i] = I(""), [a, o] = I(null), [s, c] = I(!1), l = () => {
390
+ function Ie({ integration: e, onClose: t, onReplace: n }) {
391
+ let [r, i] = K(""), [a, o] = K(null), [s, c] = K(!1), l = e?.provider === "GEOTAB", u = () => {
250
392
  i(""), o(null), t();
251
- }, u = async (t) => {
393
+ }, d = async (t) => {
252
394
  if (t.preventDefault(), !e) return;
253
- let i = N(r);
395
+ let i = l ? H(r) : _e(r);
254
396
  if (i) {
255
397
  o(i);
256
398
  return;
257
399
  }
258
400
  c(!0), o(null);
259
401
  try {
260
- await n(e, r.trim()), l();
402
+ await n(e, l ? r : r.trim()), u();
261
403
  } catch (e) {
262
- o(J(e, "Could not replace the secret."));
404
+ o(Q(e, "Could not replace the secret."));
263
405
  } finally {
264
406
  c(!1);
265
407
  }
266
408
  };
267
- return /* @__PURE__ */ R(B, {
409
+ return /* @__PURE__ */ q(Y, {
268
410
  open: e !== null,
269
- onOpenChange: (e) => !e && l(),
270
- children: /* @__PURE__ */ R(V, { children: /* @__PURE__ */ z("form", {
271
- onSubmit: (e) => void u(e),
411
+ onOpenChange: (e) => !e && u(),
412
+ children: /* @__PURE__ */ q(X, { children: /* @__PURE__ */ J("form", {
413
+ onSubmit: (e) => void d(e),
272
414
  className: "space-y-4",
273
415
  children: [
274
- /* @__PURE__ */ z(W, { children: [/* @__PURE__ */ z(G, { children: ["Replace the Samsara secret for ", e?.name] }), /* @__PURE__ */ R(H, { children: "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." })] }),
275
- /* @__PURE__ */ z("div", {
416
+ /* @__PURE__ */ J(je, { children: [/* @__PURE__ */ q(Me, { children: l ? `Update the MyGeotab password for ${e?.name ?? ""}` : `Replace the Samsara secret for ${e?.name ?? ""}` }), /* @__PURE__ */ q(ke, { children: l ? "Enter the current password of the MyGeotab user this feed signs in as. The next poll signs in with it." : "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." })] }),
417
+ /* @__PURE__ */ J("div", {
276
418
  className: "space-y-1.5",
277
- children: [/* @__PURE__ */ R(b, {
419
+ children: [/* @__PURE__ */ q(S, {
278
420
  htmlFor: "samsara-new-secret",
279
- children: "New Samsara webhook secret key"
280
- }), /* @__PURE__ */ R(y, {
421
+ children: l ? "New MyGeotab password" : "New Samsara webhook secret key"
422
+ }), /* @__PURE__ */ q(x, {
281
423
  id: "samsara-new-secret",
282
424
  type: "password",
283
425
  autoComplete: "off",
@@ -287,58 +429,58 @@ function Oe({ integration: e, onClose: t, onReplace: n }) {
287
429
  autoFocus: !0
288
430
  })]
289
431
  }),
290
- /* @__PURE__ */ R(T, { message: a }),
291
- /* @__PURE__ */ z(U, { children: [/* @__PURE__ */ R(g, {
432
+ /* @__PURE__ */ q(D, { message: a }),
433
+ /* @__PURE__ */ J(Ae, { children: [/* @__PURE__ */ q(_, {
292
434
  type: "button",
293
435
  variant: "outline",
294
- onClick: l,
436
+ onClick: u,
295
437
  children: "Cancel"
296
- }), /* @__PURE__ */ R(g, {
438
+ }), /* @__PURE__ */ q(_, {
297
439
  type: "submit",
298
440
  disabled: s,
299
- children: s ? "Saving…" : "Replace secret"
441
+ children: s ? "Saving…" : l ? "Update password" : "Replace secret"
300
442
  })] })
301
443
  ]
302
444
  }) })
303
445
  });
304
446
  }
305
- function X({ url: e }) {
306
- return /* @__PURE__ */ z("div", {
447
+ function Le({ url: e }) {
448
+ return /* @__PURE__ */ J("div", {
307
449
  className: "space-y-3",
308
450
  children: [
309
- /* @__PURE__ */ R("p", {
451
+ /* @__PURE__ */ q("p", {
310
452
  className: "text-sm font-medium",
311
453
  children: "How to connect Samsara"
312
454
  }),
313
- /* @__PURE__ */ R(Y, {
455
+ /* @__PURE__ */ q($, {
314
456
  label: "Webhook URL",
315
457
  value: e
316
458
  }),
317
- /* @__PURE__ */ z("ol", {
459
+ /* @__PURE__ */ J("ol", {
318
460
  className: "list-decimal space-y-1 pl-5 text-xs text-text-secondary",
319
461
  children: [
320
- /* @__PURE__ */ z("li", { children: [
462
+ /* @__PURE__ */ J("li", { children: [
321
463
  "In Samsara, open Settings → Developer → Webhooks, add a webhook with the URL above and subscribe it to",
322
464
  " ",
323
- ue.map((e, t) => /* @__PURE__ */ z("span", { children: [t > 0 ? ", " : "", /* @__PURE__ */ R("code", {
465
+ ue.map((e, t) => /* @__PURE__ */ J("span", { children: [t > 0 ? ", " : "", /* @__PURE__ */ q("code", {
324
466
  className: "font-mono",
325
467
  children: e.type
326
468
  })] }, e.type)),
327
469
  "."
328
470
  ] }),
329
- /* @__PURE__ */ R("li", { children: "Route stop and geofence arrivals become Arrived events; departures become Departed events." }),
330
- /* @__PURE__ */ z("li", { children: [
471
+ /* @__PURE__ */ q("li", { children: "Route stop and geofence arrivals become Arrived events; departures become Departed events." }),
472
+ /* @__PURE__ */ J("li", { children: [
331
473
  "To match a shipment, put its MoveTheWheels tracking number in the route or stop external ID under the key chosen when this feed was connected (default",
332
474
  " ",
333
- /* @__PURE__ */ R("code", {
475
+ /* @__PURE__ */ q("code", {
334
476
  className: "font-mono",
335
- children: E
477
+ children: k
336
478
  }),
337
479
  "). Without one, the Samsara vehicle name or licence plate is matched to a MoveTheWheels vehicle, and the event goes to that vehicle's single in-progress route."
338
480
  ] }),
339
- /* @__PURE__ */ z("li", { children: [
481
+ /* @__PURE__ */ J("li", { children: [
340
482
  "Samsara signs every delivery (",
341
- de.join(" and "),
483
+ N.join(" and "),
342
484
  "); deliveries with a wrong signature or more than five minutes old are refused."
343
485
  ] })
344
486
  ]
@@ -346,105 +488,203 @@ function X({ url: e }) {
346
488
  ]
347
489
  });
348
490
  }
349
- function Z({ integrationId: e, refreshKey: t }) {
350
- let { events: n, isLoading: r, error: i } = F(e, t);
351
- return /* @__PURE__ */ z("div", {
491
+ function Re({ url: e }) {
492
+ return /* @__PURE__ */ J("div", {
493
+ className: "space-y-3",
494
+ children: [
495
+ /* @__PURE__ */ q("p", {
496
+ className: "text-sm font-medium",
497
+ children: "How to connect Motive"
498
+ }),
499
+ /* @__PURE__ */ q($, {
500
+ label: "Webhook URL",
501
+ value: e
502
+ }),
503
+ /* @__PURE__ */ J("ol", {
504
+ className: "list-decimal space-y-1 pl-5 text-xs text-text-secondary",
505
+ children: [
506
+ /* @__PURE__ */ q("li", { children: "In the Motive dashboard, open Admin → Developer → Webhooks and add a webhook with the URL above, the JSON format and the signing secret shown when this feed was connected (rotate the secret here to get a new one)." }),
507
+ /* @__PURE__ */ J("li", { children: [
508
+ "Subscribe it to",
509
+ " ",
510
+ j.map((e, t) => /* @__PURE__ */ J("span", { children: [
511
+ t > 0 ? " and " : "",
512
+ /* @__PURE__ */ q("code", {
513
+ className: "font-mono",
514
+ children: e.action
515
+ }),
516
+ " (",
517
+ e.becomes.toLowerCase(),
518
+ ")"
519
+ ] }, e.action)),
520
+ ", then enable it. Motive sends an activation test that this feed answers automatically."
521
+ ] }),
522
+ /* @__PURE__ */ q("li", { children: "Motive deliveries carry no shipment reference, so the Motive vehicle number (or VIN) is matched to a MoveTheWheels vehicle by its vehicle number or licence plate, and the event goes to that vehicle's single in-progress route. Ambiguous matches are refused, never guessed." }),
523
+ /* @__PURE__ */ J("li", { children: [
524
+ "Motive signs every delivery with an HMAC-SHA1 of the body in",
525
+ " ",
526
+ /* @__PURE__ */ q("code", {
527
+ className: "font-mono",
528
+ children: le
529
+ }),
530
+ "; deliveries with a wrong signature are refused, and a repeated Motive event is recorded once."
531
+ ] })
532
+ ]
533
+ })
534
+ ]
535
+ });
536
+ }
537
+ function ze({ integration: e }) {
538
+ return /* @__PURE__ */ J("div", {
539
+ className: "space-y-3",
540
+ children: [
541
+ /* @__PURE__ */ q("p", {
542
+ className: "text-sm font-medium",
543
+ children: "How the Geotab feed works"
544
+ }),
545
+ /* @__PURE__ */ J("ol", {
546
+ className: "list-decimal space-y-1 pl-5 text-xs text-text-secondary",
547
+ children: [
548
+ /* @__PURE__ */ J("li", { children: [
549
+ "Every ",
550
+ 5,
551
+ " minutes MoveTheWheels signs in to MyGeotab and reads the GPS log and exception events added since the last poll. Nothing is set up in Geotab."
552
+ ] }),
553
+ /* @__PURE__ */ q("li", { children: "Each Geotab vehicle is matched to a MoveTheWheels vehicle by its name, licence plate or VIN; the event goes to that vehicle's single in-progress route. Records for vehicles that are not on a route are skipped." }),
554
+ /* @__PURE__ */ q("li", { children: "The newest GPS position of each vehicle becomes an In transit event with its location, when position updates are on. Mapped exception rules (typically zone arrivals and departures) become the events they are mapped to." }),
555
+ /* @__PURE__ */ q("li", { children: "Repeated sign-in failures slow the polling down so the MyGeotab user is not locked out; update the password, then use Poll now." })
556
+ ]
557
+ }),
558
+ /* @__PURE__ */ q(Be, { integration: e })
559
+ ]
560
+ });
561
+ }
562
+ function Be({ integration: e }) {
563
+ let t = e.pollStatus;
564
+ return /* @__PURE__ */ J("div", {
565
+ className: "space-y-1 rounded-lg bg-bg-sunken px-3 py-2",
566
+ "data-testid": "poll-status",
567
+ children: [
568
+ /* @__PURE__ */ J("div", {
569
+ className: "flex items-center gap-2",
570
+ children: [/* @__PURE__ */ q("span", {
571
+ className: "text-xs font-medium",
572
+ children: "Latest poll"
573
+ }), t?.lastPollStatus ? /* @__PURE__ */ q(g, {
574
+ variant: he(t.lastPollStatus),
575
+ children: U(t.lastPollStatus)
576
+ }) : null]
577
+ }),
578
+ /* @__PURE__ */ q("p", {
579
+ className: "text-xs text-text-secondary",
580
+ children: me(t, h)
581
+ }),
582
+ t?.lastPollError ? /* @__PURE__ */ q("p", {
583
+ className: "break-words text-xs text-status-error-text",
584
+ children: t.lastPollError
585
+ }) : null
586
+ ]
587
+ });
588
+ }
589
+ function Ve({ integrationId: e, refreshKey: t, polled: n = !1 }) {
590
+ let { events: r, isLoading: i, error: a } = Se(e, t);
591
+ return /* @__PURE__ */ J("div", {
352
592
  className: "space-y-2",
353
593
  children: [
354
- /* @__PURE__ */ R("p", {
594
+ /* @__PURE__ */ q("p", {
355
595
  className: "text-sm font-medium",
356
- children: "Recent deliveries"
596
+ children: n ? "Recent polls" : "Recent deliveries"
357
597
  }),
358
- /* @__PURE__ */ R(T, { message: i?.message }),
359
- r && n.length === 0 ? /* @__PURE__ */ R(S, { className: "h-12 w-full" }) : n.length === 0 ? /* @__PURE__ */ R("p", {
598
+ /* @__PURE__ */ q(D, { message: a?.message }),
599
+ i && r.length === 0 ? /* @__PURE__ */ q(T, { className: "h-12 w-full" }) : r.length === 0 ? /* @__PURE__ */ q("p", {
360
600
  className: "text-sm text-text-secondary",
361
- children: "No deliveries yet. Send a signed test update with the example below."
362
- }) : /* @__PURE__ */ R("ul", {
601
+ children: n ? "No polls with updates yet. Polls that find nothing to add are not listed." : "No deliveries yet. Send a signed test update with the example below."
602
+ }) : /* @__PURE__ */ q("ul", {
363
603
  className: "space-y-2",
364
- children: n.map((e) => /* @__PURE__ */ z("li", {
604
+ children: r.map((e) => /* @__PURE__ */ J("li", {
365
605
  className: "flex flex-wrap items-start justify-between gap-3 rounded-lg bg-bg-sunken px-3 py-2",
366
- children: [/* @__PURE__ */ z("div", {
606
+ children: [/* @__PURE__ */ J("div", {
367
607
  className: "min-w-0",
368
608
  children: [
369
- /* @__PURE__ */ z("p", {
609
+ /* @__PURE__ */ J("p", {
370
610
  className: "text-sm font-medium",
371
- children: [e.eventType ? j(e.eventType) : "Delivery", e.externalEventId ? /* @__PURE__ */ R("span", {
611
+ children: [e.eventType ? U(e.eventType) : n ? "Poll" : "Delivery", e.externalEventId ? /* @__PURE__ */ q("span", {
372
612
  className: "ml-2 font-mono text-xs text-text-tertiary",
373
613
  children: e.externalEventId
374
614
  }) : null]
375
615
  }),
376
- /* @__PURE__ */ R("p", {
616
+ /* @__PURE__ */ q("p", {
377
617
  className: "text-xs text-text-secondary",
378
- children: m(e.receivedAt)
618
+ children: h(e.receivedAt)
379
619
  }),
380
- e.errorMessage ? /* @__PURE__ */ R("p", {
620
+ e.errorMessage ? /* @__PURE__ */ q("p", {
381
621
  className: "mt-1 break-words text-xs text-status-error-text",
382
622
  children: e.errorMessage
383
623
  }) : null
384
624
  ]
385
- }), /* @__PURE__ */ R(h, {
386
- variant: pe(e.status),
387
- children: j(e.status)
625
+ }), /* @__PURE__ */ q(g, {
626
+ variant: R(e.status),
627
+ children: U(e.status)
388
628
  })]
389
629
  }, e.id))
390
630
  })
391
631
  ]
392
632
  });
393
633
  }
394
- function Q({ url: e }) {
395
- return /* @__PURE__ */ z("div", {
634
+ function He({ url: e }) {
635
+ return /* @__PURE__ */ J("div", {
396
636
  className: "space-y-3",
397
637
  children: [
398
- /* @__PURE__ */ R("p", {
638
+ /* @__PURE__ */ q("p", {
399
639
  className: "text-sm font-medium",
400
640
  children: "How to send updates"
401
641
  }),
402
- /* @__PURE__ */ R(Y, {
642
+ /* @__PURE__ */ q($, {
403
643
  label: "Webhook URL",
404
644
  value: e
405
645
  }),
406
- /* @__PURE__ */ z("ul", {
646
+ /* @__PURE__ */ J("ul", {
407
647
  className: "list-disc space-y-1 pl-5 text-xs text-text-secondary",
408
648
  children: [
409
- /* @__PURE__ */ z("li", { children: [
649
+ /* @__PURE__ */ J("li", { children: [
410
650
  "POST JSON: one update object, or an array of up to ",
411
651
  5,
412
652
  "."
413
653
  ] }),
414
- /* @__PURE__ */ z("li", { children: [
654
+ /* @__PURE__ */ J("li", { children: [
415
655
  "Sign the exact raw body with HMAC-SHA256 using the signing secret and send the hex digest in the ",
416
- /* @__PURE__ */ R("code", {
656
+ /* @__PURE__ */ q("code", {
417
657
  className: "font-mono",
418
- children: D
658
+ children: P
419
659
  }),
420
660
  " header (a",
421
661
  " ",
422
- /* @__PURE__ */ R("code", {
662
+ /* @__PURE__ */ q("code", {
423
663
  className: "font-mono",
424
664
  children: "sha256="
425
665
  }),
426
666
  " prefix is accepted)."
427
667
  ] }),
428
- /* @__PURE__ */ z("li", { children: [
668
+ /* @__PURE__ */ J("li", { children: [
429
669
  "Identify the shipment with ",
430
- /* @__PURE__ */ R("code", {
670
+ /* @__PURE__ */ q("code", {
431
671
  className: "font-mono",
432
672
  children: "trackingNumber"
433
673
  }),
434
674
  " or its",
435
675
  " ",
436
- /* @__PURE__ */ R("code", {
676
+ /* @__PURE__ */ q("code", {
437
677
  className: "font-mono",
438
678
  children: "shipmentId"
439
679
  }),
440
680
  ". Event types:",
441
681
  " ",
442
- fe.join(", "),
682
+ F.join(", "),
443
683
  "."
444
684
  ] }),
445
- /* @__PURE__ */ z("li", { children: [
685
+ /* @__PURE__ */ J("li", { children: [
446
686
  "Send a stable ",
447
- /* @__PURE__ */ R("code", {
687
+ /* @__PURE__ */ q("code", {
448
688
  className: "font-mono",
449
689
  children: "externalEventId"
450
690
  }),
@@ -452,334 +692,364 @@ function Q({ url: e }) {
452
692
  ] })
453
693
  ]
454
694
  }),
455
- /* @__PURE__ */ R(Y, {
695
+ /* @__PURE__ */ q($, {
456
696
  label: "Example body",
457
- value: k(),
697
+ value: z(),
458
698
  multiline: !0
459
699
  }),
460
- /* @__PURE__ */ R(Y, {
700
+ /* @__PURE__ */ q($, {
461
701
  label: "Example request",
462
- value: O(e),
702
+ value: L(e),
463
703
  multiline: !0
464
704
  })
465
705
  ]
466
706
  });
467
707
  }
468
- function ke({ integration: e, url: t, expanded: i, refreshKey: c, busy: l, onToggle: u, onSetStatus: d, onRotate: p, onDelete: y }) {
469
- let b = e.status === "ACTIVE";
470
- return /* @__PURE__ */ R(_, { children: /* @__PURE__ */ z(v, {
708
+ function Ue({ integration: e, url: t, expanded: a, refreshKey: l, busy: u, onToggle: d, onSetStatus: f, onRotate: m, onPoll: b, onDelete: x }) {
709
+ let S = e.status === "ACTIVE", C = fe(e.provider);
710
+ return /* @__PURE__ */ q(v, { children: /* @__PURE__ */ J(y, {
471
711
  className: "p-5",
472
- children: [/* @__PURE__ */ z("div", {
712
+ children: [/* @__PURE__ */ J("div", {
473
713
  className: "flex flex-wrap items-start justify-between gap-3",
474
- children: [/* @__PURE__ */ z("div", {
714
+ children: [/* @__PURE__ */ J("div", {
475
715
  className: "min-w-0 space-y-1",
476
716
  children: [
477
- /* @__PURE__ */ z("div", {
717
+ /* @__PURE__ */ J("div", {
478
718
  className: "flex flex-wrap items-center gap-2",
479
- children: [/* @__PURE__ */ R("p", {
719
+ children: [/* @__PURE__ */ q("p", {
480
720
  className: "text-base font-semibold",
481
721
  children: e.name
482
- }), /* @__PURE__ */ R(h, {
483
- variant: he(e.status),
484
- children: j(e.status)
722
+ }), /* @__PURE__ */ q(g, {
723
+ variant: de(e.status),
724
+ children: U(e.status)
485
725
  })]
486
726
  }),
487
- /* @__PURE__ */ z("p", {
727
+ /* @__PURE__ */ J("p", {
488
728
  className: "text-xs text-text-secondary",
489
729
  children: [
490
730
  ge(e.provider),
491
- " · ",
492
- P(e.status)
731
+ " ·",
732
+ " ",
733
+ ve(e.status, e.provider)
493
734
  ]
494
735
  }),
495
- /* @__PURE__ */ z("p", {
736
+ C ? /* @__PURE__ */ q("p", {
737
+ className: "text-xs text-text-secondary",
738
+ children: me(e.pollStatus, h)
739
+ }) : null,
740
+ /* @__PURE__ */ J("p", {
496
741
  className: "text-xs text-text-secondary",
497
742
  children: [
498
743
  "Last accepted update:",
499
744
  " ",
500
- e.lastSyncAt ? m(e.lastSyncAt) : "none yet",
501
- e.lastErrorAt ? ` · Last error ${m(e.lastErrorAt)}` : ""
745
+ e.lastSyncAt ? h(e.lastSyncAt) : "none yet",
746
+ e.lastErrorAt ? ` · Last error ${h(e.lastErrorAt)}` : ""
502
747
  ]
503
748
  }),
504
- e.lastErrorMessage ? /* @__PURE__ */ R("p", {
749
+ e.lastErrorMessage ? /* @__PURE__ */ q("p", {
505
750
  className: "break-words text-xs text-status-error-text",
506
751
  children: e.lastErrorMessage
507
752
  }) : null
508
753
  ]
509
- }), /* @__PURE__ */ z("div", {
754
+ }), /* @__PURE__ */ J("div", {
510
755
  className: "flex flex-wrap items-center gap-2",
511
756
  children: [
512
- /* @__PURE__ */ z(g, {
757
+ /* @__PURE__ */ J(_, {
513
758
  size: "sm",
514
759
  variant: "outline",
515
- disabled: l,
516
- onClick: () => d(b ? "PAUSED" : "ACTIVE"),
517
- children: [R(b ? o : s, {
760
+ disabled: u,
761
+ onClick: () => f(S ? "PAUSED" : "ACTIVE"),
762
+ children: [q(S ? s : c, {
518
763
  size: 14,
519
764
  className: "mr-1"
520
- }), b ? "Pause" : "Resume"]
765
+ }), S ? "Pause" : "Resume"]
521
766
  }),
522
- /* @__PURE__ */ z(g, {
767
+ C ? /* @__PURE__ */ J(_, {
523
768
  size: "sm",
524
769
  variant: "outline",
525
- disabled: l,
526
- onClick: p,
527
- children: [/* @__PURE__ */ R(a, {
770
+ disabled: u || !S,
771
+ onClick: b,
772
+ children: [/* @__PURE__ */ q(i, {
528
773
  size: 14,
529
774
  className: "mr-1"
530
- }), e.provider === "SAMSARA" ? "Replace secret" : "Rotate secret"]
775
+ }), "Poll now"]
776
+ }) : null,
777
+ /* @__PURE__ */ J(_, {
778
+ size: "sm",
779
+ variant: "outline",
780
+ disabled: u,
781
+ onClick: m,
782
+ children: [/* @__PURE__ */ q(o, {
783
+ size: 14,
784
+ className: "mr-1"
785
+ }), e.provider === "SAMSARA" ? "Replace secret" : C ? "Update password" : "Rotate secret"]
531
786
  }),
532
- /* @__PURE__ */ R(g, {
787
+ /* @__PURE__ */ q(_, {
533
788
  size: "sm",
534
789
  variant: "ghost",
535
- disabled: l,
536
- onClick: y,
790
+ disabled: u,
791
+ onClick: x,
537
792
  "aria-label": `Delete ${e.name}`,
538
- children: /* @__PURE__ */ R(f, { size: 14 })
793
+ children: /* @__PURE__ */ q(p, { size: 14 })
539
794
  }),
540
- /* @__PURE__ */ R(g, {
795
+ /* @__PURE__ */ q(_, {
541
796
  size: "sm",
542
797
  variant: "ghost",
543
- onClick: u,
544
- "aria-expanded": i,
545
- "aria-label": i ? "Hide details" : "Show details",
546
- children: R(i ? r : n, { size: 16 })
798
+ onClick: d,
799
+ "aria-expanded": a,
800
+ "aria-label": a ? "Hide details" : "Show details",
801
+ children: q(a ? r : n, { size: 16 })
547
802
  })
548
803
  ]
549
804
  })]
550
- }), i ? /* @__PURE__ */ z("div", {
805
+ }), a ? /* @__PURE__ */ J("div", {
551
806
  className: "mt-4 grid gap-6 border-t border-border-subtle pt-4 lg:grid-cols-2",
552
- children: [e.provider === "SAMSARA" ? /* @__PURE__ */ R(X, { url: t }) : /* @__PURE__ */ R(Q, { url: t }), /* @__PURE__ */ R(Z, {
807
+ children: [C ? /* @__PURE__ */ q(ze, { integration: e }) : e.provider === "SAMSARA" ? /* @__PURE__ */ q(Le, { url: t }) : e.provider === "MOTIVE" ? /* @__PURE__ */ q(Re, { url: t }) : /* @__PURE__ */ q(He, { url: t }), /* @__PURE__ */ q(Ve, {
553
808
  integrationId: e.id,
554
- refreshKey: c
809
+ refreshKey: l,
810
+ polled: C
555
811
  })]
556
812
  }) : null]
557
813
  }) });
558
814
  }
559
- function Ae() {
560
- let { tenantId: e, workspaceId: t } = p();
561
- return /* @__PURE__ */ R(je, {}, `${e ?? ""}:${t ?? ""}`);
815
+ function We() {
816
+ let { tenantId: e, workspaceId: t } = m();
817
+ return /* @__PURE__ */ q(Ge, {}, `${e ?? ""}:${t ?? ""}`);
562
818
  }
563
- function je() {
564
- let { apiGatewayUrl: t } = p(), n = ye(), { message: r, notify: i } = oe(), [a, o] = I(null), [s, f] = I(q), [y, b] = I(0), [E, ue] = I(0), [de, D] = I(null), [fe, O] = I(!1), [pe, k] = I(null), [me, M] = I([]), he = me[0] ?? null, ge = (e, t) => M((n) => [...n, {
819
+ function Ge() {
820
+ let { apiGatewayUrl: t } = m(), n = be(), { message: r, notify: i } = se(), [a, o] = K(null), [s, c] = K(Z), [p, b] = K(0), [x, S] = K(0), [re, O] = K(null), [k, A] = K(!1), [j, le] = K(null), [ue, N] = K([]), P = ue[0] ?? null, F = (e, t) => N((n) => [...n, {
565
821
  name: e,
566
822
  secret: t
567
- }]), N = Ce(/* @__PURE__ */ new Set()), [_e, P] = I(() => /* @__PURE__ */ new Set()), F = async (e, t) => {
568
- if (!N.current.has(e)) {
569
- N.current.add(e), P(new Set(N.current));
823
+ }]), I = Te(/* @__PURE__ */ new Set()), [L, R] = K(() => /* @__PURE__ */ new Set()), z = async (e, t) => {
824
+ if (!I.current.has(e)) {
825
+ I.current.add(e), R(new Set(I.current));
570
826
  try {
571
827
  await t();
572
828
  } finally {
573
- N.current.delete(e), P(new Set(N.current));
829
+ I.current.delete(e), R(new Set(I.current));
574
830
  }
575
831
  }
576
- }, { integrations: L, total: B, isLoading: V, error: H, refetch: U } = xe({
577
- status: s === q ? void 0 : s,
578
- limit: K,
579
- offset: y * K
580
- }), { all: W, active: G, refetch: Y } = be(), X = Math.max(1, Math.ceil(B / K));
581
- Se(() => {
582
- !V && y > 0 && y >= X && b(X - 1);
832
+ }, { integrations: B, total: H, isLoading: W, error: de, refetch: me } = Ce({
833
+ status: s === Z ? void 0 : s,
834
+ limit: Ne,
835
+ offset: p * Ne
836
+ }), { all: he, active: ge, refetch: _e } = xe(), G = Math.max(1, Math.ceil(H / Ne));
837
+ we(() => {
838
+ !W && p > 0 && p >= G && b(G - 1);
583
839
  }, [
584
- V,
585
- y,
586
- X
840
+ W,
841
+ p,
842
+ G
587
843
  ]);
588
- let Z = L.map((e) => e.lastSyncAt).filter((e) => !!e).sort(), Q = Z.length > 0 ? Z[Z.length - 1] : void 0, Ae = (e) => ve(t, e.workspaceId, e.id, window.location.origin), je = () => {
589
- ue((e) => e + 1), U(), Y();
590
- }, $ = (e) => {
591
- o(null), i(e), je();
592
- }, Me = async (e, t) => {
844
+ let ve = B.map((e) => e.lastSyncAt).filter((e) => !!e).sort(), Se = ve.length > 0 ? ve[ve.length - 1] : void 0, Ee = (e) => ye(t, e.workspaceId, e.id, window.location.origin), Y = () => {
845
+ S((e) => e + 1), me(), _e();
846
+ }, X = (e) => {
847
+ o(null), i(e), Y();
848
+ }, ke = async (e, t) => {
593
849
  try {
594
- await n.update(e.id, { status: t }), $(t === "ACTIVE" ? `Resumed ${e.name}.` : `Paused ${e.name}.`);
850
+ await n.update(e.id, { status: t }), X(t === "ACTIVE" ? `Resumed ${e.name}.` : `Paused ${e.name}.`);
595
851
  } catch (e) {
596
- o(J(e, "Could not change the integration status."));
852
+ o(Q(e, "Could not change the integration status."));
597
853
  }
598
- }, Ne = async (e) => {
854
+ }, Ae = async (e) => {
599
855
  if (!window.confirm(`Rotate the signing secret for ${e.name}? Deliveries signed with the old secret are refused as soon as it changes.`)) return;
600
- let t = A();
856
+ let t = V();
601
857
  try {
602
- await n.update(e.id, { apiSecret: t }), ge(e.name, t), $(`Rotated the signing secret for ${e.name}.`);
858
+ await n.update(e.id, { apiSecret: t }), F(e.name, t), X(`Rotated the signing secret for ${e.name}.`);
603
859
  } catch (e) {
604
- o(J(e, "Could not rotate the signing secret."));
860
+ o(Q(e, "Could not rotate the signing secret."));
605
861
  }
606
- }, Pe = async (e, t) => {
607
- await F(e.id, async () => {
608
- await n.update(e.id, { apiSecret: t }), $(`Replaced the Samsara secret for ${e.name}.`);
862
+ }, je = async (e, t) => {
863
+ await z(e.id, async () => {
864
+ await n.update(e.id, { apiSecret: t }), X(e.provider === "GEOTAB" ? `Updated the MyGeotab password for ${e.name}.` : `Replaced the Samsara secret for ${e.name}.`);
609
865
  });
610
- }, Fe = async (e) => {
866
+ }, Me = async (e) => {
867
+ try {
868
+ let t = await n.pollNow(e.id);
869
+ if (t.status === "FAILED") {
870
+ o(pe(e.name, t)), Y();
871
+ return;
872
+ }
873
+ X(pe(e.name, t));
874
+ } catch (t) {
875
+ o(Q(t, `Could not poll ${e.name}.`));
876
+ }
877
+ }, $ = async (e) => {
611
878
  if (window.confirm(`Delete ${e.name}? Its webhook URL stops working; tracking events it already created stay on their shipments.`)) try {
612
- await n.remove(e.id), de === e.id && D(null), $(`Deleted ${e.name}.`);
879
+ await n.remove(e.id), re === e.id && O(null), X(`Deleted ${e.name}.`);
613
880
  } catch (e) {
614
- o(J(e, "Could not delete the integration."));
881
+ o(Q(e, "Could not delete the integration."));
615
882
  }
616
883
  };
617
- return /* @__PURE__ */ z(C, {
884
+ return /* @__PURE__ */ J(ie, {
618
885
  title: "Integrations",
619
886
  subtitle: "Carrier, ELD and GPS tracking feeds",
620
- icon: /* @__PURE__ */ R(c, { size: 24 }),
621
- headerActions: /* @__PURE__ */ R(we, {
887
+ icon: /* @__PURE__ */ q(l, { size: 24 }),
888
+ headerActions: /* @__PURE__ */ q(De, {
622
889
  primary: {
623
890
  label: "Connect feed",
624
- icon: /* @__PURE__ */ R(l, { size: 16 }),
625
- onSelect: () => O(!0)
891
+ icon: /* @__PURE__ */ q(u, { size: 16 }),
892
+ onSelect: () => A(!0)
626
893
  },
627
894
  actions: [{
628
895
  label: "Refresh",
629
- icon: /* @__PURE__ */ R(u, { size: 16 }),
630
- onSelect: je
896
+ icon: /* @__PURE__ */ q(d, { size: 16 }),
897
+ onSelect: Y
631
898
  }]
632
899
  }),
633
900
  children: [
634
- /* @__PURE__ */ R(Te, {
635
- icon: /* @__PURE__ */ R(c, { size: 18 }),
901
+ /* @__PURE__ */ q(Oe, {
902
+ icon: /* @__PURE__ */ q(l, { size: 18 }),
636
903
  children: "Connect the systems that already know where your freight is. Each feed gets its own signed webhook; every update it sends becomes a tracking event on the matching shipment, so status and ETA stay current without manual entry."
637
904
  }),
638
- /* @__PURE__ */ R(ae, { message: r }),
639
- /* @__PURE__ */ R(T, { message: a }),
640
- /* @__PURE__ */ z(ie, {
905
+ /* @__PURE__ */ q(oe, { message: r }),
906
+ /* @__PURE__ */ q(D, { message: a }),
907
+ /* @__PURE__ */ J(ae, {
641
908
  columns: 3,
642
909
  children: [
643
- /* @__PURE__ */ R(w, {
910
+ /* @__PURE__ */ q(E, {
644
911
  label: "Feeds",
645
- value: W,
646
- icon: /* @__PURE__ */ R(c, { size: 20 }),
912
+ value: he,
913
+ icon: /* @__PURE__ */ q(l, { size: 20 }),
647
914
  accent: "brand"
648
915
  }),
649
- /* @__PURE__ */ R(w, {
916
+ /* @__PURE__ */ q(E, {
650
917
  label: "Active",
651
- value: G,
652
- icon: /* @__PURE__ */ R(d, { size: 20 }),
918
+ value: ge,
919
+ icon: /* @__PURE__ */ q(f, { size: 20 }),
653
920
  accent: "success"
654
921
  }),
655
- /* @__PURE__ */ R(w, {
922
+ /* @__PURE__ */ q(E, {
656
923
  label: "Last accepted update (shown)",
657
- value: Q ? m(Q) : "—",
658
- icon: /* @__PURE__ */ R(e, { size: 20 }),
924
+ value: Se ? h(Se) : "—",
925
+ icon: /* @__PURE__ */ q(e, { size: 20 }),
659
926
  accent: "blue"
660
927
  })
661
928
  ]
662
929
  }),
663
- /* @__PURE__ */ R("div", {
930
+ /* @__PURE__ */ q("div", {
664
931
  className: "flex flex-col gap-3 sm:flex-row sm:items-center",
665
- children: /* @__PURE__ */ z(ee, {
932
+ children: /* @__PURE__ */ J(C, {
666
933
  value: s,
667
934
  onValueChange: (e) => {
668
- f(e), b(0);
935
+ c(e), b(0);
669
936
  },
670
- children: [/* @__PURE__ */ R(ne, {
937
+ children: [/* @__PURE__ */ q(te, {
671
938
  "aria-label": "Status",
672
939
  className: "sm:w-56",
673
- children: /* @__PURE__ */ R(re, {})
674
- }), /* @__PURE__ */ z(te, { children: [/* @__PURE__ */ R(x, {
675
- value: q,
940
+ children: /* @__PURE__ */ q(ne, {})
941
+ }), /* @__PURE__ */ J(ee, { children: [/* @__PURE__ */ q(w, {
942
+ value: Z,
676
943
  children: "All statuses"
677
- }), se.map((e) => /* @__PURE__ */ R(x, {
944
+ }), ce.map((e) => /* @__PURE__ */ q(w, {
678
945
  value: e,
679
- children: j(e)
946
+ children: U(e)
680
947
  }, e))] })]
681
948
  })
682
949
  }),
683
- /* @__PURE__ */ R(T, { message: H?.message }),
684
- V && L.length === 0 ? /* @__PURE__ */ z("div", {
950
+ /* @__PURE__ */ q(D, { message: de?.message }),
951
+ W && B.length === 0 ? /* @__PURE__ */ J("div", {
685
952
  className: "grid gap-4",
686
- children: [/* @__PURE__ */ R(S, { className: "h-28 w-full" }), /* @__PURE__ */ R(S, { className: "h-28 w-full" })]
687
- }) : L.length === 0 && !H ? /* @__PURE__ */ R(_, { children: /* @__PURE__ */ z(v, {
953
+ children: [/* @__PURE__ */ q(T, { className: "h-28 w-full" }), /* @__PURE__ */ q(T, { className: "h-28 w-full" })]
954
+ }) : B.length === 0 && !de ? /* @__PURE__ */ q(v, { children: /* @__PURE__ */ J(y, {
688
955
  className: "flex flex-col items-center gap-3 p-10 text-center",
689
956
  children: [
690
- /* @__PURE__ */ R(c, {
957
+ /* @__PURE__ */ q(l, {
691
958
  size: 32,
692
959
  className: "text-text-tertiary"
693
960
  }),
694
- /* @__PURE__ */ R("p", {
961
+ /* @__PURE__ */ q("p", {
695
962
  className: "font-medium",
696
- children: s === q ? "No tracking feeds connected" : "No feeds with this status"
963
+ children: s === Z ? "No tracking feeds connected" : "No feeds with this status"
697
964
  }),
698
- /* @__PURE__ */ R("p", {
965
+ /* @__PURE__ */ q("p", {
699
966
  className: "max-w-md text-sm text-text-secondary",
700
- children: s === q ? "Connect a carrier portal, ELD or GPS tracker so shipment updates arrive on their own." : "Choose another status to see the rest of your feeds."
967
+ children: s === Z ? "Connect a carrier portal, ELD or GPS tracker so shipment updates arrive on their own." : "Choose another status to see the rest of your feeds."
701
968
  }),
702
- s === q ? /* @__PURE__ */ z(g, {
703
- onClick: () => O(!0),
704
- children: [/* @__PURE__ */ R(l, {
969
+ s === Z ? /* @__PURE__ */ J(_, {
970
+ onClick: () => A(!0),
971
+ children: [/* @__PURE__ */ q(u, {
705
972
  size: 16,
706
973
  className: "mr-1.5"
707
974
  }), "Connect feed"]
708
975
  }) : null
709
976
  ]
710
- }) }) : /* @__PURE__ */ R("div", {
977
+ }) }) : /* @__PURE__ */ q("div", {
711
978
  className: "grid gap-4",
712
- children: L.map((e) => /* @__PURE__ */ R(ke, {
979
+ children: B.map((e) => /* @__PURE__ */ q(Ue, {
713
980
  integration: e,
714
- url: Ae(e),
715
- expanded: de === e.id,
716
- refreshKey: E,
717
- busy: _e.has(e.id),
718
- onToggle: () => D((t) => t === e.id ? null : e.id),
719
- onSetStatus: (t) => void F(e.id, () => Me(e, t)),
720
- onRotate: () => e.provider === "SAMSARA" ? k(e) : void F(e.id, () => Ne(e)),
721
- onDelete: () => void F(e.id, () => Fe(e))
981
+ url: Ee(e),
982
+ expanded: re === e.id,
983
+ refreshKey: x,
984
+ busy: L.has(e.id),
985
+ onToggle: () => O((t) => t === e.id ? null : e.id),
986
+ onSetStatus: (t) => void z(e.id, () => ke(e, t)),
987
+ onRotate: () => e.provider === "SAMSARA" || fe(e.provider) ? le(e) : void z(e.id, () => Ae(e)),
988
+ onPoll: () => void z(e.id, () => Me(e)),
989
+ onDelete: () => void z(e.id, () => $(e))
722
990
  }, e.id))
723
991
  }),
724
- B > K ? /* @__PURE__ */ z("div", {
992
+ H > Ne ? /* @__PURE__ */ J("div", {
725
993
  className: "flex items-center justify-between text-sm",
726
- children: [/* @__PURE__ */ z("span", {
994
+ children: [/* @__PURE__ */ J("span", {
727
995
  className: "text-text-secondary",
728
996
  children: [
729
997
  "Page ",
730
- y + 1,
998
+ p + 1,
731
999
  " of ",
732
- X,
1000
+ G,
733
1001
  " · ",
734
- B,
1002
+ H,
735
1003
  " feeds"
736
1004
  ]
737
- }), /* @__PURE__ */ z("div", {
1005
+ }), /* @__PURE__ */ J("div", {
738
1006
  className: "flex gap-2",
739
- children: [/* @__PURE__ */ R(g, {
1007
+ children: [/* @__PURE__ */ q(_, {
740
1008
  variant: "outline",
741
1009
  size: "sm",
742
- disabled: y === 0,
1010
+ disabled: p === 0,
743
1011
  onClick: () => b((e) => e - 1),
744
1012
  children: "Previous"
745
- }), /* @__PURE__ */ R(g, {
1013
+ }), /* @__PURE__ */ q(_, {
746
1014
  variant: "outline",
747
1015
  size: "sm",
748
- disabled: y + 1 >= X,
1016
+ disabled: p + 1 >= G,
749
1017
  onClick: () => b((e) => e + 1),
750
1018
  children: "Next"
751
1019
  })]
752
1020
  })]
753
1021
  }) : null,
754
- /* @__PURE__ */ R(_, { children: /* @__PURE__ */ z(v, {
1022
+ /* @__PURE__ */ q(v, { children: /* @__PURE__ */ J(y, {
755
1023
  className: "space-y-2 p-5",
756
1024
  children: [
757
- /* @__PURE__ */ R("p", {
1025
+ /* @__PURE__ */ q("p", {
758
1026
  className: "text-sm font-medium",
759
1027
  children: "Carrier and ELD networks"
760
1028
  }),
761
- /* @__PURE__ */ z("p", {
1029
+ /* @__PURE__ */ J("p", {
762
1030
  className: "text-sm text-text-secondary",
763
1031
  children: [
764
- "Samsara connects directly: choose it when you connect a feed. Direct connections to",
765
- " ",
766
- [...le.map((e) => e.label), ...ce].join(", "),
767
- " ",
768
- "are not available yet. Until they are, any carrier or telematics system that can send HTTPS webhooks connects through a signed feed above."
1032
+ "Samsara, Motive and Geotab connect directly: choose them when you connect a feed. Direct connections to ",
1033
+ M.map((e) => e.label).join(", "),
1034
+ " are not available yet. Until they are, any carrier or telematics system that can send HTTPS webhooks connects through a signed feed above."
769
1035
  ]
770
1036
  }),
771
- /* @__PURE__ */ z("div", {
1037
+ /* @__PURE__ */ J("div", {
772
1038
  className: "flex flex-wrap gap-2",
773
1039
  children: [
774
- /* @__PURE__ */ R(h, {
1040
+ /* @__PURE__ */ q(g, {
775
1041
  variant: "default",
776
1042
  children: "Samsara · available"
777
1043
  }),
778
- ce.map((e) => /* @__PURE__ */ z(h, {
779
- variant: "outline",
780
- children: [e, " · not available yet"]
781
- }, e)),
782
- le.map((e) => /* @__PURE__ */ z(h, {
1044
+ /* @__PURE__ */ q(g, {
1045
+ variant: "default",
1046
+ children: "Motive · available"
1047
+ }),
1048
+ /* @__PURE__ */ q(g, {
1049
+ variant: "default",
1050
+ children: "Geotab · available"
1051
+ }),
1052
+ M.map((e) => /* @__PURE__ */ J(g, {
783
1053
  variant: "outline",
784
1054
  children: [e.label, " · not available yet"]
785
1055
  }, e.id))
@@ -787,25 +1057,25 @@ function je() {
787
1057
  })
788
1058
  ]
789
1059
  }) }),
790
- /* @__PURE__ */ R(De, {
791
- open: fe,
792
- onOpenChange: O,
1060
+ /* @__PURE__ */ q(Fe, {
1061
+ open: k,
1062
+ onOpenChange: A,
793
1063
  onCreated: (e, t) => {
794
- D(e.id), t && ge(e.name, t), $(`Connected ${e.name}.`);
1064
+ O(e.id), t && F(e.name, t), X(`Connected ${e.name}.`);
795
1065
  }
796
1066
  }),
797
- /* @__PURE__ */ R(Oe, {
798
- integration: pe,
799
- onClose: () => k(null),
800
- onReplace: Pe
1067
+ /* @__PURE__ */ q(Ie, {
1068
+ integration: j,
1069
+ onClose: () => le(null),
1070
+ onReplace: je
801
1071
  }),
802
- /* @__PURE__ */ R(Ee, {
803
- secret: he?.secret ?? null,
804
- integrationName: he?.name ?? "",
805
- onClose: () => M((e) => e.slice(1))
1072
+ /* @__PURE__ */ q(Pe, {
1073
+ secret: P?.secret ?? null,
1074
+ integrationName: P?.name ?? "",
1075
+ onClose: () => N((e) => e.slice(1))
806
1076
  })
807
1077
  ]
808
1078
  });
809
1079
  }
810
1080
  //#endregion
811
- export { Ae as default };
1081
+ export { We as default };