@burdenoff/microfe-movethewheels 2026.1107.3 → 2026.1107.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.
- package/dist/components/ScenarioPlanningPanel.js +411 -0
- package/dist/generated/tracking-quality-operations.d.ts +1 -1
- package/dist/generated/wspace-types.d.ts +1028 -42
- package/dist/hooks/useScenarioPlanning.js +89 -0
- package/dist/movethewheels/components/ScenarioPlanningPanel.d.ts +4 -0
- package/dist/movethewheels/hooks/useCarrierIntegrations.d.ts +2 -0
- package/dist/movethewheels/hooks/useScenarioPlanning.d.ts +94 -0
- package/dist/movethewheels/utils/carrierIntegrations.d.ts +38 -4
- package/dist/node_modules/lucide-react/dist/esm/icons/git-compare.js +26 -0
- package/dist/pages/AnalyticsPage.js +80 -78
- package/dist/pages/IntegrationsPage.js +324 -129
- package/dist/utils/carrierIntegrations.js +62 -23
- package/package.json +1 -1
- package/src/generated/tracking-quality-operations.ts +1 -0
- package/src/generated/wspace-types.ts +1148 -42
- package/src/movethewheels/components/ScenarioPlanningPanel.tsx +539 -0
- package/src/movethewheels/hooks/useCarrierIntegrations.ts +2 -0
- package/src/movethewheels/hooks/useScenarioPlanning.ts +273 -0
- package/src/movethewheels/pages/AnalyticsPage.tsx +5 -0
- package/src/movethewheels/pages/IntegrationsPage.tsx +266 -44
- package/src/movethewheels/utils/carrierIntegrations.ts +76 -8
|
@@ -14,22 +14,22 @@ import { Trash2 as f } from "../node_modules/lucide-react/dist/esm/icons/trash-2
|
|
|
14
14
|
import { useMoveTheWheels as p } from "../providers/MoveTheWheelsProvider.js";
|
|
15
15
|
import { formatDateTime as m } from "../utils/formatters.js";
|
|
16
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
|
|
18
|
-
import { MetricCard as
|
|
19
|
-
import { FormError as
|
|
20
|
-
import { Notice as
|
|
21
|
-
import { INTEGRATION_STATUSES as ce, ROADMAP_PROVIDERS as
|
|
22
|
-
import { useCarrierIntegrationActions as
|
|
23
|
-
import { useEffect as
|
|
24
|
-
import { jsx as R, jsxs as z } from "react/jsx-runtime";
|
|
25
|
-
import { CTAOverflowMenu as
|
|
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";
|
|
26
26
|
//#region src/movethewheels/pages/IntegrationsPage.tsx
|
|
27
27
|
var K = 20, q = "ALL";
|
|
28
28
|
function J(e, t) {
|
|
29
29
|
return e instanceof Error && e.message ? e.message : t;
|
|
30
30
|
}
|
|
31
31
|
function Y({ label: e, value: n, multiline: r }) {
|
|
32
|
-
let [a, o] =
|
|
32
|
+
let [a, o] = I(!1), s = async () => {
|
|
33
33
|
try {
|
|
34
34
|
await navigator.clipboard.writeText(n), o(!0), window.setTimeout(() => o(!1), 2e3);
|
|
35
35
|
} catch {
|
|
@@ -63,7 +63,7 @@ function Y({ label: e, value: n, multiline: r }) {
|
|
|
63
63
|
})]
|
|
64
64
|
});
|
|
65
65
|
}
|
|
66
|
-
function
|
|
66
|
+
function Ee({ secret: e, integrationName: t, onClose: n }) {
|
|
67
67
|
return /* @__PURE__ */ R(B, {
|
|
68
68
|
open: e !== null,
|
|
69
69
|
onOpenChange: (e) => !e && n(),
|
|
@@ -80,39 +80,45 @@ function ve({ secret: e, integrationName: t, onClose: n }) {
|
|
|
80
80
|
] })
|
|
81
81
|
});
|
|
82
82
|
}
|
|
83
|
-
function
|
|
84
|
-
let r =
|
|
85
|
-
a(""), s(
|
|
86
|
-
},
|
|
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) => {
|
|
87
87
|
e.preventDefault();
|
|
88
|
-
let
|
|
89
|
-
if (
|
|
90
|
-
|
|
88
|
+
let i = M(o) ?? (C ? N(d) ?? me(p) : _e(c));
|
|
89
|
+
if (i) {
|
|
90
|
+
_(i);
|
|
91
91
|
return;
|
|
92
92
|
}
|
|
93
|
-
|
|
93
|
+
S(!0), _(null);
|
|
94
94
|
try {
|
|
95
|
-
|
|
95
|
+
let e = p.trim();
|
|
96
|
+
n(await r.create(C ? {
|
|
97
|
+
provider: "SAMSARA",
|
|
98
|
+
name: o,
|
|
99
|
+
apiSecret: d.trim(),
|
|
100
|
+
...e ? { config: { shipmentExternalIdKey: e } } : {}
|
|
101
|
+
} : {
|
|
96
102
|
provider: "GENERIC_WEBHOOK",
|
|
97
|
-
name:
|
|
98
|
-
apiSecret:
|
|
99
|
-
}),
|
|
103
|
+
name: o,
|
|
104
|
+
apiSecret: c
|
|
105
|
+
}), C ? null : c), w(), t(!1);
|
|
100
106
|
} catch (e) {
|
|
101
|
-
|
|
107
|
+
_(J(e, "Could not create the integration."));
|
|
102
108
|
} finally {
|
|
103
|
-
|
|
109
|
+
S(!1);
|
|
104
110
|
}
|
|
105
111
|
};
|
|
106
112
|
return /* @__PURE__ */ R(B, {
|
|
107
113
|
open: e,
|
|
108
114
|
onOpenChange: (e) => {
|
|
109
|
-
e ||
|
|
115
|
+
e || w(), t(e);
|
|
110
116
|
},
|
|
111
117
|
children: /* @__PURE__ */ R(V, { children: /* @__PURE__ */ z("form", {
|
|
112
|
-
onSubmit: (e) => void
|
|
118
|
+
onSubmit: (e) => void ie(e),
|
|
113
119
|
className: "space-y-4",
|
|
114
120
|
children: [
|
|
115
|
-
/* @__PURE__ */ z(W, { children: [/* @__PURE__ */ R(G, { children: "Connect a tracking feed" }), /* @__PURE__ */ R(H, { children: "A signed webhook
|
|
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." })] }),
|
|
116
122
|
/* @__PURE__ */ z("div", {
|
|
117
123
|
className: "space-y-1.5",
|
|
118
124
|
children: [/* @__PURE__ */ R(b, {
|
|
@@ -120,21 +126,85 @@ function ye({ open: e, onOpenChange: t, onCreated: n }) {
|
|
|
120
126
|
children: "Name"
|
|
121
127
|
}), /* @__PURE__ */ R(y, {
|
|
122
128
|
id: "integration-name",
|
|
123
|
-
value:
|
|
129
|
+
value: o,
|
|
124
130
|
maxLength: 120,
|
|
125
|
-
placeholder: "e.g. Fleet GPS feed",
|
|
126
|
-
onChange: (e) =>
|
|
131
|
+
placeholder: C ? "e.g. Samsara fleet" : "e.g. Fleet GPS feed",
|
|
132
|
+
onChange: (e) => s(e.target.value),
|
|
127
133
|
autoFocus: !0
|
|
128
134
|
})]
|
|
129
135
|
}),
|
|
130
136
|
/* @__PURE__ */ z("div", {
|
|
131
137
|
className: "space-y-1.5",
|
|
132
|
-
children: [/* @__PURE__ */ R(b, {
|
|
133
|
-
|
|
134
|
-
children: "
|
|
138
|
+
children: [/* @__PURE__ */ R(b, {
|
|
139
|
+
htmlFor: "integration-type",
|
|
140
|
+
children: "Type"
|
|
141
|
+
}), /* @__PURE__ */ z(ee, {
|
|
142
|
+
value: i,
|
|
143
|
+
onValueChange: (e) => {
|
|
144
|
+
a(e), _(null);
|
|
145
|
+
},
|
|
146
|
+
children: [/* @__PURE__ */ R(ne, {
|
|
147
|
+
id: "integration-type",
|
|
148
|
+
"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
|
+
})] })]
|
|
135
157
|
})]
|
|
136
158
|
}),
|
|
137
|
-
/* @__PURE__ */ z("div", {
|
|
159
|
+
C ? /* @__PURE__ */ z(L, { children: [/* @__PURE__ */ z("div", {
|
|
160
|
+
className: "space-y-1.5",
|
|
161
|
+
children: [
|
|
162
|
+
/* @__PURE__ */ R(b, {
|
|
163
|
+
htmlFor: "samsara-secret",
|
|
164
|
+
children: "Samsara webhook secret key"
|
|
165
|
+
}),
|
|
166
|
+
/* @__PURE__ */ R(y, {
|
|
167
|
+
id: "samsara-secret",
|
|
168
|
+
type: "password",
|
|
169
|
+
autoComplete: "off",
|
|
170
|
+
spellCheck: !1,
|
|
171
|
+
value: d,
|
|
172
|
+
placeholder: "Paste from Samsara → Settings → Webhooks",
|
|
173
|
+
onChange: (e) => f(e.target.value)
|
|
174
|
+
}),
|
|
175
|
+
/* @__PURE__ */ R("p", {
|
|
176
|
+
className: "text-xs text-text-secondary",
|
|
177
|
+
children: "Create the webhook in Samsara first; its page shows this key. MoveTheWheels stores it encrypted and never shows it again."
|
|
178
|
+
})
|
|
179
|
+
]
|
|
180
|
+
}), /* @__PURE__ */ z("div", {
|
|
181
|
+
className: "space-y-1.5",
|
|
182
|
+
children: [
|
|
183
|
+
/* @__PURE__ */ R(b, {
|
|
184
|
+
htmlFor: "samsara-shipment-key",
|
|
185
|
+
children: "Shipment external ID key (optional)"
|
|
186
|
+
}),
|
|
187
|
+
/* @__PURE__ */ R(y, {
|
|
188
|
+
id: "samsara-shipment-key",
|
|
189
|
+
value: p,
|
|
190
|
+
maxLength: 64,
|
|
191
|
+
placeholder: E,
|
|
192
|
+
onChange: (e) => m(e.target.value)
|
|
193
|
+
}),
|
|
194
|
+
/* @__PURE__ */ z("p", {
|
|
195
|
+
className: "text-xs text-text-secondary",
|
|
196
|
+
children: [
|
|
197
|
+
"The external ID on a Samsara route or stop that holds the MoveTheWheels tracking number. Leave blank to use",
|
|
198
|
+
" ",
|
|
199
|
+
/* @__PURE__ */ R("code", {
|
|
200
|
+
className: "font-mono",
|
|
201
|
+
children: E
|
|
202
|
+
}),
|
|
203
|
+
"."
|
|
204
|
+
]
|
|
205
|
+
})
|
|
206
|
+
]
|
|
207
|
+
})] }) : /* @__PURE__ */ z("div", {
|
|
138
208
|
className: "space-y-1.5",
|
|
139
209
|
children: [
|
|
140
210
|
/* @__PURE__ */ z("div", {
|
|
@@ -143,7 +213,7 @@ function ye({ open: e, onOpenChange: t, onCreated: n }) {
|
|
|
143
213
|
type: "button",
|
|
144
214
|
size: "sm",
|
|
145
215
|
variant: "ghost",
|
|
146
|
-
onClick: () =>
|
|
216
|
+
onClick: () => l(A()),
|
|
147
217
|
children: [/* @__PURE__ */ R(u, {
|
|
148
218
|
size: 14,
|
|
149
219
|
className: "mr-1"
|
|
@@ -152,7 +222,7 @@ function ye({ open: e, onOpenChange: t, onCreated: n }) {
|
|
|
152
222
|
}),
|
|
153
223
|
/* @__PURE__ */ R("code", {
|
|
154
224
|
className: "block break-all rounded-lg bg-bg-sunken px-3 py-2 font-mono text-xs",
|
|
155
|
-
children:
|
|
225
|
+
children: c
|
|
156
226
|
}),
|
|
157
227
|
/* @__PURE__ */ R("p", {
|
|
158
228
|
className: "text-xs text-text-secondary",
|
|
@@ -160,7 +230,7 @@ function ye({ open: e, onOpenChange: t, onCreated: n }) {
|
|
|
160
230
|
})
|
|
161
231
|
]
|
|
162
232
|
}),
|
|
163
|
-
/* @__PURE__ */ R(
|
|
233
|
+
/* @__PURE__ */ R(T, { message: h }),
|
|
164
234
|
/* @__PURE__ */ z(U, { children: [/* @__PURE__ */ R(g, {
|
|
165
235
|
type: "button",
|
|
166
236
|
variant: "outline",
|
|
@@ -168,15 +238,116 @@ function ye({ open: e, onOpenChange: t, onCreated: n }) {
|
|
|
168
238
|
children: "Cancel"
|
|
169
239
|
}), /* @__PURE__ */ R(g, {
|
|
170
240
|
type: "submit",
|
|
171
|
-
disabled:
|
|
172
|
-
children:
|
|
241
|
+
disabled: v,
|
|
242
|
+
children: v ? "Connecting…" : "Connect"
|
|
173
243
|
})] })
|
|
174
244
|
]
|
|
175
245
|
}) })
|
|
176
246
|
});
|
|
177
247
|
}
|
|
178
|
-
function
|
|
179
|
-
let
|
|
248
|
+
function Oe({ integration: e, onClose: t, onReplace: n }) {
|
|
249
|
+
let [r, i] = I(""), [a, o] = I(null), [s, c] = I(!1), l = () => {
|
|
250
|
+
i(""), o(null), t();
|
|
251
|
+
}, u = async (t) => {
|
|
252
|
+
if (t.preventDefault(), !e) return;
|
|
253
|
+
let i = N(r);
|
|
254
|
+
if (i) {
|
|
255
|
+
o(i);
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
c(!0), o(null);
|
|
259
|
+
try {
|
|
260
|
+
await n(e, r.trim()), l();
|
|
261
|
+
} catch (e) {
|
|
262
|
+
o(J(e, "Could not replace the secret."));
|
|
263
|
+
} finally {
|
|
264
|
+
c(!1);
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
return /* @__PURE__ */ R(B, {
|
|
268
|
+
open: e !== null,
|
|
269
|
+
onOpenChange: (e) => !e && l(),
|
|
270
|
+
children: /* @__PURE__ */ R(V, { children: /* @__PURE__ */ z("form", {
|
|
271
|
+
onSubmit: (e) => void u(e),
|
|
272
|
+
className: "space-y-4",
|
|
273
|
+
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", {
|
|
276
|
+
className: "space-y-1.5",
|
|
277
|
+
children: [/* @__PURE__ */ R(b, {
|
|
278
|
+
htmlFor: "samsara-new-secret",
|
|
279
|
+
children: "New Samsara webhook secret key"
|
|
280
|
+
}), /* @__PURE__ */ R(y, {
|
|
281
|
+
id: "samsara-new-secret",
|
|
282
|
+
type: "password",
|
|
283
|
+
autoComplete: "off",
|
|
284
|
+
spellCheck: !1,
|
|
285
|
+
value: r,
|
|
286
|
+
onChange: (e) => i(e.target.value),
|
|
287
|
+
autoFocus: !0
|
|
288
|
+
})]
|
|
289
|
+
}),
|
|
290
|
+
/* @__PURE__ */ R(T, { message: a }),
|
|
291
|
+
/* @__PURE__ */ z(U, { children: [/* @__PURE__ */ R(g, {
|
|
292
|
+
type: "button",
|
|
293
|
+
variant: "outline",
|
|
294
|
+
onClick: l,
|
|
295
|
+
children: "Cancel"
|
|
296
|
+
}), /* @__PURE__ */ R(g, {
|
|
297
|
+
type: "submit",
|
|
298
|
+
disabled: s,
|
|
299
|
+
children: s ? "Saving…" : "Replace secret"
|
|
300
|
+
})] })
|
|
301
|
+
]
|
|
302
|
+
}) })
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
function X({ url: e }) {
|
|
306
|
+
return /* @__PURE__ */ z("div", {
|
|
307
|
+
className: "space-y-3",
|
|
308
|
+
children: [
|
|
309
|
+
/* @__PURE__ */ R("p", {
|
|
310
|
+
className: "text-sm font-medium",
|
|
311
|
+
children: "How to connect Samsara"
|
|
312
|
+
}),
|
|
313
|
+
/* @__PURE__ */ R(Y, {
|
|
314
|
+
label: "Webhook URL",
|
|
315
|
+
value: e
|
|
316
|
+
}),
|
|
317
|
+
/* @__PURE__ */ z("ol", {
|
|
318
|
+
className: "list-decimal space-y-1 pl-5 text-xs text-text-secondary",
|
|
319
|
+
children: [
|
|
320
|
+
/* @__PURE__ */ z("li", { children: [
|
|
321
|
+
"In Samsara, open Settings → Developer → Webhooks, add a webhook with the URL above and subscribe it to",
|
|
322
|
+
" ",
|
|
323
|
+
ue.map((e, t) => /* @__PURE__ */ z("span", { children: [t > 0 ? ", " : "", /* @__PURE__ */ R("code", {
|
|
324
|
+
className: "font-mono",
|
|
325
|
+
children: e.type
|
|
326
|
+
})] }, e.type)),
|
|
327
|
+
"."
|
|
328
|
+
] }),
|
|
329
|
+
/* @__PURE__ */ R("li", { children: "Route stop and geofence arrivals become Arrived events; departures become Departed events." }),
|
|
330
|
+
/* @__PURE__ */ z("li", { children: [
|
|
331
|
+
"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
|
+
" ",
|
|
333
|
+
/* @__PURE__ */ R("code", {
|
|
334
|
+
className: "font-mono",
|
|
335
|
+
children: E
|
|
336
|
+
}),
|
|
337
|
+
"). 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
|
+
] }),
|
|
339
|
+
/* @__PURE__ */ z("li", { children: [
|
|
340
|
+
"Samsara signs every delivery (",
|
|
341
|
+
de.join(" and "),
|
|
342
|
+
"); deliveries with a wrong signature or more than five minutes old are refused."
|
|
343
|
+
] })
|
|
344
|
+
]
|
|
345
|
+
})
|
|
346
|
+
]
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
function Z({ integrationId: e, refreshKey: t }) {
|
|
350
|
+
let { events: n, isLoading: r, error: i } = F(e, t);
|
|
180
351
|
return /* @__PURE__ */ z("div", {
|
|
181
352
|
className: "space-y-2",
|
|
182
353
|
children: [
|
|
@@ -184,7 +355,7 @@ function X({ integrationId: e, refreshKey: t }) {
|
|
|
184
355
|
className: "text-sm font-medium",
|
|
185
356
|
children: "Recent deliveries"
|
|
186
357
|
}),
|
|
187
|
-
/* @__PURE__ */ R(
|
|
358
|
+
/* @__PURE__ */ R(T, { message: i?.message }),
|
|
188
359
|
r && n.length === 0 ? /* @__PURE__ */ R(S, { className: "h-12 w-full" }) : n.length === 0 ? /* @__PURE__ */ R("p", {
|
|
189
360
|
className: "text-sm text-text-secondary",
|
|
190
361
|
children: "No deliveries yet. Send a signed test update with the example below."
|
|
@@ -197,7 +368,7 @@ function X({ integrationId: e, refreshKey: t }) {
|
|
|
197
368
|
children: [
|
|
198
369
|
/* @__PURE__ */ z("p", {
|
|
199
370
|
className: "text-sm font-medium",
|
|
200
|
-
children: [e.eventType ?
|
|
371
|
+
children: [e.eventType ? j(e.eventType) : "Delivery", e.externalEventId ? /* @__PURE__ */ R("span", {
|
|
201
372
|
className: "ml-2 font-mono text-xs text-text-tertiary",
|
|
202
373
|
children: e.externalEventId
|
|
203
374
|
}) : null]
|
|
@@ -212,15 +383,15 @@ function X({ integrationId: e, refreshKey: t }) {
|
|
|
212
383
|
}) : null
|
|
213
384
|
]
|
|
214
385
|
}), /* @__PURE__ */ R(h, {
|
|
215
|
-
variant:
|
|
216
|
-
children:
|
|
386
|
+
variant: pe(e.status),
|
|
387
|
+
children: j(e.status)
|
|
217
388
|
})]
|
|
218
389
|
}, e.id))
|
|
219
390
|
})
|
|
220
391
|
]
|
|
221
392
|
});
|
|
222
393
|
}
|
|
223
|
-
function
|
|
394
|
+
function Q({ url: e }) {
|
|
224
395
|
return /* @__PURE__ */ z("div", {
|
|
225
396
|
className: "space-y-3",
|
|
226
397
|
children: [
|
|
@@ -244,7 +415,7 @@ function be({ url: e }) {
|
|
|
244
415
|
"Sign the exact raw body with HMAC-SHA256 using the signing secret and send the hex digest in the ",
|
|
245
416
|
/* @__PURE__ */ R("code", {
|
|
246
417
|
className: "font-mono",
|
|
247
|
-
children:
|
|
418
|
+
children: D
|
|
248
419
|
}),
|
|
249
420
|
" header (a",
|
|
250
421
|
" ",
|
|
@@ -268,7 +439,7 @@ function be({ url: e }) {
|
|
|
268
439
|
}),
|
|
269
440
|
". Event types:",
|
|
270
441
|
" ",
|
|
271
|
-
|
|
442
|
+
fe.join(", "),
|
|
272
443
|
"."
|
|
273
444
|
] }),
|
|
274
445
|
/* @__PURE__ */ z("li", { children: [
|
|
@@ -283,18 +454,18 @@ function be({ url: e }) {
|
|
|
283
454
|
}),
|
|
284
455
|
/* @__PURE__ */ R(Y, {
|
|
285
456
|
label: "Example body",
|
|
286
|
-
value:
|
|
457
|
+
value: k(),
|
|
287
458
|
multiline: !0
|
|
288
459
|
}),
|
|
289
460
|
/* @__PURE__ */ R(Y, {
|
|
290
461
|
label: "Example request",
|
|
291
|
-
value:
|
|
462
|
+
value: O(e),
|
|
292
463
|
multiline: !0
|
|
293
464
|
})
|
|
294
465
|
]
|
|
295
466
|
});
|
|
296
467
|
}
|
|
297
|
-
function
|
|
468
|
+
function ke({ integration: e, url: t, expanded: i, refreshKey: c, busy: l, onToggle: u, onSetStatus: d, onRotate: p, onDelete: y }) {
|
|
298
469
|
let b = e.status === "ACTIVE";
|
|
299
470
|
return /* @__PURE__ */ R(_, { children: /* @__PURE__ */ z(v, {
|
|
300
471
|
className: "p-5",
|
|
@@ -309,13 +480,17 @@ function xe({ integration: e, url: t, expanded: i, refreshKey: c, busy: l, onTog
|
|
|
309
480
|
className: "text-base font-semibold",
|
|
310
481
|
children: e.name
|
|
311
482
|
}), /* @__PURE__ */ R(h, {
|
|
312
|
-
variant:
|
|
313
|
-
children:
|
|
483
|
+
variant: he(e.status),
|
|
484
|
+
children: j(e.status)
|
|
314
485
|
})]
|
|
315
486
|
}),
|
|
316
487
|
/* @__PURE__ */ z("p", {
|
|
317
488
|
className: "text-xs text-text-secondary",
|
|
318
|
-
children: [
|
|
489
|
+
children: [
|
|
490
|
+
ge(e.provider),
|
|
491
|
+
" · ",
|
|
492
|
+
P(e.status)
|
|
493
|
+
]
|
|
319
494
|
}),
|
|
320
495
|
/* @__PURE__ */ z("p", {
|
|
321
496
|
className: "text-xs text-text-secondary",
|
|
@@ -352,7 +527,7 @@ function xe({ integration: e, url: t, expanded: i, refreshKey: c, busy: l, onTog
|
|
|
352
527
|
children: [/* @__PURE__ */ R(a, {
|
|
353
528
|
size: 14,
|
|
354
529
|
className: "mr-1"
|
|
355
|
-
}), "Rotate secret"]
|
|
530
|
+
}), e.provider === "SAMSARA" ? "Replace secret" : "Rotate secret"]
|
|
356
531
|
}),
|
|
357
532
|
/* @__PURE__ */ R(g, {
|
|
358
533
|
size: "sm",
|
|
@@ -374,108 +549,112 @@ function xe({ integration: e, url: t, expanded: i, refreshKey: c, busy: l, onTog
|
|
|
374
549
|
})]
|
|
375
550
|
}), i ? /* @__PURE__ */ z("div", {
|
|
376
551
|
className: "mt-4 grid gap-6 border-t border-border-subtle pt-4 lg:grid-cols-2",
|
|
377
|
-
children: [/* @__PURE__ */ R(
|
|
552
|
+
children: [e.provider === "SAMSARA" ? /* @__PURE__ */ R(X, { url: t }) : /* @__PURE__ */ R(Q, { url: t }), /* @__PURE__ */ R(Z, {
|
|
378
553
|
integrationId: e.id,
|
|
379
554
|
refreshKey: c
|
|
380
555
|
})]
|
|
381
556
|
}) : null]
|
|
382
557
|
}) });
|
|
383
558
|
}
|
|
384
|
-
function
|
|
559
|
+
function Ae() {
|
|
385
560
|
let { tenantId: e, workspaceId: t } = p();
|
|
386
|
-
return /* @__PURE__ */ R(
|
|
561
|
+
return /* @__PURE__ */ R(je, {}, `${e ?? ""}:${t ?? ""}`);
|
|
387
562
|
}
|
|
388
|
-
function
|
|
389
|
-
let { apiGatewayUrl: t } = p(), n =
|
|
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, {
|
|
390
565
|
name: e,
|
|
391
566
|
secret: t
|
|
392
|
-
}]),
|
|
393
|
-
if (!
|
|
394
|
-
|
|
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));
|
|
395
570
|
try {
|
|
396
571
|
await t();
|
|
397
572
|
} finally {
|
|
398
|
-
|
|
573
|
+
N.current.delete(e), P(new Set(N.current));
|
|
399
574
|
}
|
|
400
575
|
}
|
|
401
|
-
}, { integrations:
|
|
576
|
+
}, { integrations: L, total: B, isLoading: V, error: H, refetch: U } = xe({
|
|
402
577
|
status: s === q ? void 0 : s,
|
|
403
578
|
limit: K,
|
|
404
579
|
offset: y * K
|
|
405
|
-
}), { all:
|
|
406
|
-
|
|
407
|
-
!
|
|
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);
|
|
408
583
|
}, [
|
|
409
|
-
|
|
584
|
+
V,
|
|
410
585
|
y,
|
|
411
|
-
|
|
586
|
+
X
|
|
412
587
|
]);
|
|
413
|
-
let
|
|
414
|
-
ue((e) => e + 1),
|
|
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();
|
|
415
590
|
}, $ = (e) => {
|
|
416
|
-
o(null), i(e),
|
|
417
|
-
},
|
|
591
|
+
o(null), i(e), je();
|
|
592
|
+
}, Me = async (e, t) => {
|
|
418
593
|
try {
|
|
419
594
|
await n.update(e.id, { status: t }), $(t === "ACTIVE" ? `Resumed ${e.name}.` : `Paused ${e.name}.`);
|
|
420
595
|
} catch (e) {
|
|
421
596
|
o(J(e, "Could not change the integration status."));
|
|
422
597
|
}
|
|
423
|
-
},
|
|
598
|
+
}, Ne = async (e) => {
|
|
424
599
|
if (!window.confirm(`Rotate the signing secret for ${e.name}? Deliveries signed with the old secret are refused as soon as it changes.`)) return;
|
|
425
|
-
let t =
|
|
600
|
+
let t = A();
|
|
426
601
|
try {
|
|
427
|
-
await n.update(e.id, { apiSecret: t }),
|
|
602
|
+
await n.update(e.id, { apiSecret: t }), ge(e.name, t), $(`Rotated the signing secret for ${e.name}.`);
|
|
428
603
|
} catch (e) {
|
|
429
604
|
o(J(e, "Could not rotate the signing secret."));
|
|
430
605
|
}
|
|
431
|
-
},
|
|
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}.`);
|
|
609
|
+
});
|
|
610
|
+
}, Fe = async (e) => {
|
|
432
611
|
if (window.confirm(`Delete ${e.name}? Its webhook URL stops working; tracking events it already created stay on their shipments.`)) try {
|
|
433
|
-
await n.remove(e.id),
|
|
612
|
+
await n.remove(e.id), de === e.id && D(null), $(`Deleted ${e.name}.`);
|
|
434
613
|
} catch (e) {
|
|
435
614
|
o(J(e, "Could not delete the integration."));
|
|
436
615
|
}
|
|
437
616
|
};
|
|
438
|
-
return /* @__PURE__ */ z(
|
|
617
|
+
return /* @__PURE__ */ z(C, {
|
|
439
618
|
title: "Integrations",
|
|
440
619
|
subtitle: "Carrier, ELD and GPS tracking feeds",
|
|
441
620
|
icon: /* @__PURE__ */ R(c, { size: 24 }),
|
|
442
|
-
headerActions: /* @__PURE__ */ R(
|
|
621
|
+
headerActions: /* @__PURE__ */ R(we, {
|
|
443
622
|
primary: {
|
|
444
623
|
label: "Connect feed",
|
|
445
624
|
icon: /* @__PURE__ */ R(l, { size: 16 }),
|
|
446
|
-
onSelect: () =>
|
|
625
|
+
onSelect: () => O(!0)
|
|
447
626
|
},
|
|
448
627
|
actions: [{
|
|
449
628
|
label: "Refresh",
|
|
450
629
|
icon: /* @__PURE__ */ R(u, { size: 16 }),
|
|
451
|
-
onSelect:
|
|
630
|
+
onSelect: je
|
|
452
631
|
}]
|
|
453
632
|
}),
|
|
454
633
|
children: [
|
|
455
|
-
/* @__PURE__ */ R(
|
|
634
|
+
/* @__PURE__ */ R(Te, {
|
|
456
635
|
icon: /* @__PURE__ */ R(c, { size: 18 }),
|
|
457
636
|
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."
|
|
458
637
|
}),
|
|
459
|
-
/* @__PURE__ */ R(
|
|
460
|
-
/* @__PURE__ */ R(
|
|
461
|
-
/* @__PURE__ */ z(
|
|
638
|
+
/* @__PURE__ */ R(ae, { message: r }),
|
|
639
|
+
/* @__PURE__ */ R(T, { message: a }),
|
|
640
|
+
/* @__PURE__ */ z(ie, {
|
|
462
641
|
columns: 3,
|
|
463
642
|
children: [
|
|
464
|
-
/* @__PURE__ */ R(
|
|
643
|
+
/* @__PURE__ */ R(w, {
|
|
465
644
|
label: "Feeds",
|
|
466
|
-
value:
|
|
645
|
+
value: W,
|
|
467
646
|
icon: /* @__PURE__ */ R(c, { size: 20 }),
|
|
468
647
|
accent: "brand"
|
|
469
648
|
}),
|
|
470
|
-
/* @__PURE__ */ R(
|
|
649
|
+
/* @__PURE__ */ R(w, {
|
|
471
650
|
label: "Active",
|
|
472
|
-
value:
|
|
651
|
+
value: G,
|
|
473
652
|
icon: /* @__PURE__ */ R(d, { size: 20 }),
|
|
474
653
|
accent: "success"
|
|
475
654
|
}),
|
|
476
|
-
/* @__PURE__ */ R(
|
|
655
|
+
/* @__PURE__ */ R(w, {
|
|
477
656
|
label: "Last accepted update (shown)",
|
|
478
|
-
value:
|
|
657
|
+
value: Q ? m(Q) : "—",
|
|
479
658
|
icon: /* @__PURE__ */ R(e, { size: 20 }),
|
|
480
659
|
accent: "blue"
|
|
481
660
|
})
|
|
@@ -495,17 +674,17 @@ function Ce() {
|
|
|
495
674
|
}), /* @__PURE__ */ z(te, { children: [/* @__PURE__ */ R(x, {
|
|
496
675
|
value: q,
|
|
497
676
|
children: "All statuses"
|
|
498
|
-
}),
|
|
677
|
+
}), se.map((e) => /* @__PURE__ */ R(x, {
|
|
499
678
|
value: e,
|
|
500
|
-
children:
|
|
679
|
+
children: j(e)
|
|
501
680
|
}, e))] })]
|
|
502
681
|
})
|
|
503
682
|
}),
|
|
504
|
-
/* @__PURE__ */ R(
|
|
505
|
-
|
|
683
|
+
/* @__PURE__ */ R(T, { message: H?.message }),
|
|
684
|
+
V && L.length === 0 ? /* @__PURE__ */ z("div", {
|
|
506
685
|
className: "grid gap-4",
|
|
507
686
|
children: [/* @__PURE__ */ R(S, { className: "h-28 w-full" }), /* @__PURE__ */ R(S, { className: "h-28 w-full" })]
|
|
508
|
-
}) :
|
|
687
|
+
}) : L.length === 0 && !H ? /* @__PURE__ */ R(_, { children: /* @__PURE__ */ z(v, {
|
|
509
688
|
className: "flex flex-col items-center gap-3 p-10 text-center",
|
|
510
689
|
children: [
|
|
511
690
|
/* @__PURE__ */ R(c, {
|
|
@@ -521,7 +700,7 @@ function Ce() {
|
|
|
521
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."
|
|
522
701
|
}),
|
|
523
702
|
s === q ? /* @__PURE__ */ z(g, {
|
|
524
|
-
onClick: () =>
|
|
703
|
+
onClick: () => O(!0),
|
|
525
704
|
children: [/* @__PURE__ */ R(l, {
|
|
526
705
|
size: 16,
|
|
527
706
|
className: "mr-1.5"
|
|
@@ -530,19 +709,19 @@ function Ce() {
|
|
|
530
709
|
]
|
|
531
710
|
}) }) : /* @__PURE__ */ R("div", {
|
|
532
711
|
className: "grid gap-4",
|
|
533
|
-
children:
|
|
712
|
+
children: L.map((e) => /* @__PURE__ */ R(ke, {
|
|
534
713
|
integration: e,
|
|
535
|
-
url:
|
|
536
|
-
expanded:
|
|
537
|
-
refreshKey:
|
|
538
|
-
busy:
|
|
714
|
+
url: Ae(e),
|
|
715
|
+
expanded: de === e.id,
|
|
716
|
+
refreshKey: E,
|
|
717
|
+
busy: _e.has(e.id),
|
|
539
718
|
onToggle: () => D((t) => t === e.id ? null : e.id),
|
|
540
|
-
onSetStatus: (t) => void
|
|
541
|
-
onRotate: () => void
|
|
542
|
-
onDelete: () => void
|
|
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))
|
|
543
722
|
}, e.id))
|
|
544
723
|
}),
|
|
545
|
-
|
|
724
|
+
B > K ? /* @__PURE__ */ z("div", {
|
|
546
725
|
className: "flex items-center justify-between text-sm",
|
|
547
726
|
children: [/* @__PURE__ */ z("span", {
|
|
548
727
|
className: "text-text-secondary",
|
|
@@ -550,9 +729,9 @@ function Ce() {
|
|
|
550
729
|
"Page ",
|
|
551
730
|
y + 1,
|
|
552
731
|
" of ",
|
|
553
|
-
|
|
732
|
+
X,
|
|
554
733
|
" · ",
|
|
555
|
-
|
|
734
|
+
B,
|
|
556
735
|
" feeds"
|
|
557
736
|
]
|
|
558
737
|
}), /* @__PURE__ */ z("div", {
|
|
@@ -566,7 +745,7 @@ function Ce() {
|
|
|
566
745
|
}), /* @__PURE__ */ R(g, {
|
|
567
746
|
variant: "outline",
|
|
568
747
|
size: "sm",
|
|
569
|
-
disabled: y + 1 >=
|
|
748
|
+
disabled: y + 1 >= X,
|
|
570
749
|
onClick: () => b((e) => e + 1),
|
|
571
750
|
children: "Next"
|
|
572
751
|
})]
|
|
@@ -577,40 +756,56 @@ function Ce() {
|
|
|
577
756
|
children: [
|
|
578
757
|
/* @__PURE__ */ R("p", {
|
|
579
758
|
className: "text-sm font-medium",
|
|
580
|
-
children: "Carrier networks"
|
|
759
|
+
children: "Carrier and ELD networks"
|
|
581
760
|
}),
|
|
582
761
|
/* @__PURE__ */ z("p", {
|
|
583
762
|
className: "text-sm text-text-secondary",
|
|
584
763
|
children: [
|
|
585
|
-
"Direct connections to
|
|
586
|
-
|
|
764
|
+
"Samsara connects directly: choose it when you connect a feed. Direct connections to",
|
|
765
|
+
" ",
|
|
766
|
+
[...le.map((e) => e.label), ...ce].join(", "),
|
|
587
767
|
" ",
|
|
588
768
|
"are not available yet. Until they are, any carrier or telematics system that can send HTTPS webhooks connects through a signed feed above."
|
|
589
769
|
]
|
|
590
770
|
}),
|
|
591
|
-
/* @__PURE__ */
|
|
771
|
+
/* @__PURE__ */ z("div", {
|
|
592
772
|
className: "flex flex-wrap gap-2",
|
|
593
|
-
children:
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
773
|
+
children: [
|
|
774
|
+
/* @__PURE__ */ R(h, {
|
|
775
|
+
variant: "default",
|
|
776
|
+
children: "Samsara · available"
|
|
777
|
+
}),
|
|
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, {
|
|
783
|
+
variant: "outline",
|
|
784
|
+
children: [e.label, " · not available yet"]
|
|
785
|
+
}, e.id))
|
|
786
|
+
]
|
|
597
787
|
})
|
|
598
788
|
]
|
|
599
789
|
}) }),
|
|
600
|
-
/* @__PURE__ */ R(
|
|
601
|
-
open:
|
|
602
|
-
onOpenChange:
|
|
790
|
+
/* @__PURE__ */ R(De, {
|
|
791
|
+
open: fe,
|
|
792
|
+
onOpenChange: O,
|
|
603
793
|
onCreated: (e, t) => {
|
|
604
|
-
D(e.id),
|
|
794
|
+
D(e.id), t && ge(e.name, t), $(`Connected ${e.name}.`);
|
|
605
795
|
}
|
|
606
796
|
}),
|
|
607
|
-
/* @__PURE__ */ R(
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
797
|
+
/* @__PURE__ */ R(Oe, {
|
|
798
|
+
integration: pe,
|
|
799
|
+
onClose: () => k(null),
|
|
800
|
+
onReplace: Pe
|
|
801
|
+
}),
|
|
802
|
+
/* @__PURE__ */ R(Ee, {
|
|
803
|
+
secret: he?.secret ?? null,
|
|
804
|
+
integrationName: he?.name ?? "",
|
|
805
|
+
onClose: () => M((e) => e.slice(1))
|
|
611
806
|
})
|
|
612
807
|
]
|
|
613
808
|
});
|
|
614
809
|
}
|
|
615
810
|
//#endregion
|
|
616
|
-
export {
|
|
811
|
+
export { Ae as default };
|