@burdenoff/microfe-movethewheels 2026.1107.5 → 2026.1107.7

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,10 +2,11 @@ import { formatDateTime as e } from "../utils/formatters.js";
2
2
  import { formatSlip as t, riskSignalLabel as n } from "../utils/trackingAlerts.js";
3
3
  import { Badge as r, Button as i, Dialog as a, DialogContent as o, DialogDescription as s, DialogHeader as c, DialogTitle as l, Skeleton as u, Textarea as d } from "./ui.js";
4
4
  import { useShipmentRisk as f } from "../hooks/useShipmentRisk.js";
5
- import { useEffect as p, useState as m } from "react";
6
- import { jsx as h, jsxs as g } from "react/jsx-runtime";
5
+ import { ShipmentDecisionPanel as p } from "./ShipmentDecisionPanel.js";
6
+ import { useEffect as m, useState as h } from "react";
7
+ import { jsx as g, jsxs as _ } from "react/jsx-runtime";
7
8
  //#region src/movethewheels/components/ShipmentRiskDialog.tsx
8
- var _ = {
9
+ var v = {
9
10
  NONE: {
10
11
  key: "movethewheels.risk.level.none",
11
12
  fallback: "No risk"
@@ -22,7 +23,7 @@ var _ = {
22
23
  key: "movethewheels.risk.level.high",
23
24
  fallback: "High"
24
25
  }
25
- }, v = {
26
+ }, y = {
26
27
  NONE: {
27
28
  key: "movethewheels.risk.action.none",
28
29
  fallback: "No action needed"
@@ -44,178 +45,222 @@ var _ = {
44
45
  fallback: "Reassign the vehicle on this order"
45
46
  }
46
47
  };
47
- function y(e, n) {
48
+ function b(e, n) {
48
49
  return e.ratio === null ? e.minutes !== null && e.minutes > 0 ? t(e.minutes) : null : `${Math.round(e.ratio * 100)}% ${n("movethewheels.risk.lateRate", "late recently")}`;
49
50
  }
50
- function b({ shipmentId: b, shipmentNumber: x, open: S, onOpenChange: C, t: w, onOpenOrder: T, onChanged: E }) {
51
- let { forecast: D, shipment: O, isLoading: k, error: A, refetch: j, repromise: M, recordTrackingUpdate: N } = f(S ? b : void 0), [P, F] = m(null), [I, L] = m(null), [R, z] = m(!1), [B, V] = m("");
52
- p(() => {
53
- F(null), L(null), V("");
54
- }, [b, S]);
55
- let H = async (e, t) => {
56
- z(!0), F(null), L(null);
51
+ function x({ shipmentId: x, shipmentNumber: S, open: C, onOpenChange: w, t: T, onOpenOrder: E, onChanged: D }) {
52
+ let { forecast: O, shipment: k, isLoading: A, error: j, refetch: M, repromise: N, recordTrackingUpdate: P } = f(C ? x : void 0), [F, I] = h(null), [L, R] = h(null), [z, B] = h(!1), [V, H] = h(""), [U, W] = h("");
53
+ m(() => {
54
+ I(null), R(null), H(""), W("");
55
+ }, [x, C]);
56
+ let G = async (e, t) => {
57
+ B(!0), I(null), R(null);
57
58
  try {
58
- await e(), L(t), E();
59
+ await e(), R(t), D();
59
60
  } catch (e) {
60
- F(e instanceof Error ? e.message : w("movethewheels.risk.actionFailed", "The action failed"));
61
+ I(e instanceof Error ? e.message : T("movethewheels.risk.actionFailed", "The action failed"));
61
62
  } finally {
62
- z(!1);
63
+ B(!1);
63
64
  }
64
- }, U = D?.predictedDeliveryLatest ?? D?.predictedDeliveryEarliest, W = O?.deliveryJobId ?? null;
65
- return /* @__PURE__ */ h(a, {
66
- open: S,
67
- onOpenChange: C,
68
- children: /* @__PURE__ */ g(o, {
69
- className: "max-w-lg",
65
+ }, K = O?.predictedDeliveryLatest ?? O?.predictedDeliveryEarliest, q = k?.deliveryJobId ?? null;
66
+ return /* @__PURE__ */ g(a, {
67
+ open: C,
68
+ onOpenChange: w,
69
+ children: /* @__PURE__ */ _(o, {
70
+ className: "max-h-[90vh] max-w-lg overflow-y-auto",
70
71
  children: [
71
- /* @__PURE__ */ g(c, { children: [/* @__PURE__ */ g(l, { children: [w("movethewheels.risk.title", "Delivery risk"), x ? ` · ${x}` : ""] }), /* @__PURE__ */ h(s, { children: w("movethewheels.risk.description", "Forecast from this shipment’s legs, route, tracking, vehicle and carrier history.") })] }),
72
- k && !D && /* @__PURE__ */ g("div", {
72
+ /* @__PURE__ */ _(c, { children: [/* @__PURE__ */ _(l, { children: [T("movethewheels.risk.title", "Delivery risk"), S ? ` · ${S}` : ""] }), /* @__PURE__ */ g(s, { children: T("movethewheels.risk.description", "Forecast from this shipment’s legs, route, tracking, vehicle and carrier history.") })] }),
73
+ A && !O && /* @__PURE__ */ _("div", {
73
74
  className: "space-y-2",
74
75
  "aria-busy": "true",
75
- children: [/* @__PURE__ */ h(u, { className: "h-6 w-1/2" }), /* @__PURE__ */ h(u, { className: "h-16 w-full" })]
76
+ children: [/* @__PURE__ */ g(u, { className: "h-6 w-1/2" }), /* @__PURE__ */ g(u, { className: "h-16 w-full" })]
76
77
  }),
77
- A && !k && /* @__PURE__ */ g("div", {
78
+ j && !A && /* @__PURE__ */ _("div", {
78
79
  role: "alert",
79
80
  className: "space-y-2 text-sm",
80
- children: [/* @__PURE__ */ h("p", {
81
+ children: [/* @__PURE__ */ g("p", {
81
82
  className: "text-status-error-text",
82
- children: A.message
83
- }), /* @__PURE__ */ h(i, {
83
+ children: j.message
84
+ }), /* @__PURE__ */ g(i, {
84
85
  size: "sm",
85
86
  variant: "outline",
86
- onClick: j,
87
- children: w("movethewheels.risk.retry", "Retry")
87
+ onClick: M,
88
+ children: T("movethewheels.risk.retry", "Retry")
88
89
  })]
89
90
  }),
90
- D && /* @__PURE__ */ g("div", {
91
+ O && /* @__PURE__ */ _("div", {
91
92
  className: "space-y-4 text-sm",
92
93
  "data-testid": "shipment-risk-panel",
93
94
  children: [
94
- /* @__PURE__ */ g("div", {
95
+ /* @__PURE__ */ _("div", {
95
96
  className: "flex flex-wrap items-center gap-2",
96
97
  children: [
97
- /* @__PURE__ */ h(r, {
98
- variant: D.riskLevel === "HIGH" ? "destructive" : "secondary",
99
- children: w(_[D.riskLevel].key, _[D.riskLevel].fallback)
98
+ /* @__PURE__ */ g(r, {
99
+ variant: O.riskLevel === "HIGH" ? "destructive" : "secondary",
100
+ children: T(v[O.riskLevel].key, v[O.riskLevel].fallback)
100
101
  }),
101
- /* @__PURE__ */ g("span", {
102
+ /* @__PURE__ */ _("span", {
102
103
  className: "text-text-secondary",
103
104
  children: [
104
- w("movethewheels.risk.score", "Risk score"),
105
+ T("movethewheels.risk.score", "Risk score"),
105
106
  ":",
106
107
  " ",
107
- /* @__PURE__ */ g("span", {
108
+ /* @__PURE__ */ _("span", {
108
109
  className: "font-medium text-text-primary",
109
- children: [D.riskScore, "/100"]
110
+ children: [O.riskScore, "/100"]
110
111
  })
111
112
  ]
112
113
  }),
113
- D.breached && /* @__PURE__ */ h(r, {
114
+ O.breached && /* @__PURE__ */ g(r, {
114
115
  variant: "destructive",
115
- children: w("movethewheels.risk.breached", "Promise missed")
116
+ children: T("movethewheels.risk.breached", "Promise missed")
116
117
  })
117
118
  ]
118
119
  }),
119
- /* @__PURE__ */ g("dl", {
120
+ /* @__PURE__ */ _("dl", {
120
121
  className: "grid grid-cols-1 gap-2 sm:grid-cols-2",
121
- children: [/* @__PURE__ */ g("div", { children: [/* @__PURE__ */ h("dt", {
122
+ children: [/* @__PURE__ */ _("div", { children: [/* @__PURE__ */ g("dt", {
122
123
  className: "text-xs text-text-secondary",
123
- children: w("movethewheels.alerts.promised", "Promised")
124
- }), /* @__PURE__ */ h("dd", { children: D.promisedDelivery ? e(D.promisedDelivery) : w("movethewheels.risk.noPromise", "No promised time") })] }), /* @__PURE__ */ g("div", { children: [/* @__PURE__ */ h("dt", {
124
+ children: T("movethewheels.alerts.promised", "Promised")
125
+ }), /* @__PURE__ */ g("dd", { children: O.promisedDelivery ? e(O.promisedDelivery) : T("movethewheels.risk.noPromise", "No promised time") })] }), /* @__PURE__ */ _("div", { children: [/* @__PURE__ */ g("dt", {
125
126
  className: "text-xs text-text-secondary",
126
- children: w("movethewheels.risk.window", "Predicted window")
127
- }), /* @__PURE__ */ g("dd", { children: [D.predictedDeliveryEarliest ? `${e(D.predictedDeliveryEarliest)}${D.predictedDeliveryLatest && D.predictedDeliveryLatest !== D.predictedDeliveryEarliest ? ` – ${e(D.predictedDeliveryLatest)}` : ""}` : w("movethewheels.risk.noPrediction", "Not enough data to predict"), D.predictedSlipMinutes > 0 && /* @__PURE__ */ g("span", {
127
+ children: T("movethewheels.risk.window", "Predicted window")
128
+ }), /* @__PURE__ */ _("dd", { children: [O.predictedDeliveryEarliest ? `${e(O.predictedDeliveryEarliest)}${O.predictedDeliveryLatest && O.predictedDeliveryLatest !== O.predictedDeliveryEarliest ? ` – ${e(O.predictedDeliveryLatest)}` : ""}` : T("movethewheels.risk.noPrediction", "Not enough data to predict"), O.predictedSlipMinutes > 0 && /* @__PURE__ */ _("span", {
128
129
  className: "ml-1 text-status-error-text",
129
130
  children: [
130
131
  "(+",
131
- t(D.predictedSlipMinutes),
132
+ t(O.predictedSlipMinutes),
132
133
  ")"
133
134
  ]
134
135
  })] })] })]
135
136
  }),
136
- /* @__PURE__ */ g("div", { children: [/* @__PURE__ */ h("p", {
137
+ /* @__PURE__ */ _("div", { children: [/* @__PURE__ */ g("p", {
137
138
  className: "mb-1 text-xs text-text-secondary",
138
- children: w("movethewheels.alerts.signals", "Risk signals")
139
- }), D.signals.length > 0 ? /* @__PURE__ */ h("ul", {
139
+ children: T("movethewheels.alerts.signals", "Risk signals")
140
+ }), O.signals.length > 0 ? /* @__PURE__ */ g("ul", {
140
141
  className: "space-y-1",
141
- children: D.signals.map((e) => {
142
- let t = y(e, w);
143
- return /* @__PURE__ */ g("li", {
142
+ children: O.signals.map((e) => {
143
+ let t = b(e, T);
144
+ return /* @__PURE__ */ _("li", {
144
145
  className: "flex items-center justify-between rounded border border-border-primary px-2 py-1",
145
- children: [/* @__PURE__ */ g("span", { children: [n(e.code, w), t && /* @__PURE__ */ g("span", {
146
+ children: [/* @__PURE__ */ _("span", { children: [n(e.code, T), t && /* @__PURE__ */ _("span", {
146
147
  className: "ml-1 text-text-secondary",
147
148
  children: ["· ", t]
148
- })] }), /* @__PURE__ */ g("span", {
149
+ })] }), /* @__PURE__ */ _("span", {
149
150
  className: "text-xs text-text-secondary",
150
151
  children: ["+", e.weight]
151
152
  })]
152
153
  }, e.code);
153
154
  })
154
- }) : /* @__PURE__ */ h("p", {
155
+ }) : /* @__PURE__ */ g("p", {
155
156
  className: "text-text-secondary",
156
- children: w("movethewheels.risk.noSignals", "No risk signals right now")
157
+ children: T("movethewheels.risk.noSignals", "No risk signals right now")
157
158
  })] }),
158
- /* @__PURE__ */ g("div", {
159
+ /* @__PURE__ */ _("div", {
159
160
  className: "rounded-lg bg-status-info-bg-subtle p-3",
160
161
  children: [
161
- /* @__PURE__ */ h("p", {
162
+ /* @__PURE__ */ g("p", {
162
163
  className: "text-xs text-text-secondary",
163
- children: w("movethewheels.risk.recommended", "Recommended action")
164
+ children: T("movethewheels.risk.recommended", "Recommended action")
164
165
  }),
165
- /* @__PURE__ */ h("p", {
166
+ /* @__PURE__ */ g("p", {
166
167
  className: "font-medium",
167
- children: w(v[D.recommendedAction].key, v[D.recommendedAction].fallback)
168
+ children: T(y[O.recommendedAction].key, y[O.recommendedAction].fallback)
168
169
  }),
169
- D.recommendedAction === "REPROMISE_DELIVERY" && U && /* @__PURE__ */ g(i, {
170
+ O.recommendedAction === "REPROMISE_DELIVERY" && K && /* @__PURE__ */ _(i, {
170
171
  size: "sm",
171
172
  className: "mt-2",
172
- disabled: R,
173
- onClick: () => void H(() => M(U), w("movethewheels.risk.repromised", "Delivery re-promised")),
173
+ disabled: z,
174
+ onClick: () => void G(() => N(K), T("movethewheels.risk.repromised", "Delivery re-promised")),
174
175
  children: [
175
- w("movethewheels.risk.repromiseTo", "Re-promise to"),
176
+ T("movethewheels.risk.repromiseTo", "Re-promise to"),
176
177
  " ",
177
- e(U)
178
+ e(K)
178
179
  ]
179
180
  }),
180
- D.recommendedAction === "REQUEST_TRACKING_UPDATE" && /* @__PURE__ */ g("div", {
181
+ O.recommendedAction === "REQUEST_TRACKING_UPDATE" && /* @__PURE__ */ _("div", {
181
182
  className: "mt-2 space-y-2",
182
- children: [/* @__PURE__ */ h(d, {
183
- value: B,
184
- onChange: (e) => V(e.target.value),
183
+ children: [/* @__PURE__ */ g(d, {
184
+ value: V,
185
+ onChange: (e) => H(e.target.value),
185
186
  maxLength: 500,
186
- "aria-label": w("movethewheels.risk.updateDetails", "Tracking update"),
187
- placeholder: w("movethewheels.risk.updatePlaceholder", "What did the driver or carrier report?")
188
- }), /* @__PURE__ */ h(i, {
187
+ "aria-label": T("movethewheels.risk.updateDetails", "Tracking update"),
188
+ placeholder: T("movethewheels.risk.updatePlaceholder", "What did the driver or carrier report?")
189
+ }), /* @__PURE__ */ g(i, {
189
190
  size: "sm",
190
- disabled: R || B.trim().length === 0,
191
- onClick: () => void H(() => N(B.trim()), w("movethewheels.risk.updateRecorded", "Tracking update recorded")),
192
- children: w("movethewheels.risk.recordUpdate", "Record tracking update")
191
+ disabled: z || V.trim().length === 0,
192
+ onClick: () => void G(() => P(V.trim()), T("movethewheels.risk.updateRecorded", "Tracking update recorded")),
193
+ children: T("movethewheels.risk.recordUpdate", "Record tracking update")
193
194
  })]
194
195
  }),
195
- D.recommendedAction === "REASSIGN_VEHICLE" && W && /* @__PURE__ */ h(i, {
196
+ O.recommendedAction === "REASSIGN_VEHICLE" && q && /* @__PURE__ */ g(i, {
196
197
  size: "sm",
197
198
  className: "mt-2",
198
- onClick: () => T(W),
199
- children: w("movethewheels.risk.openOrder", "Open order to reassign")
199
+ onClick: () => E(q),
200
+ children: T("movethewheels.risk.openOrder", "Open order to reassign")
200
201
  }),
201
- I && /* @__PURE__ */ h("p", {
202
+ L && /* @__PURE__ */ g("p", {
202
203
  role: "status",
203
204
  className: "mt-2 text-xs text-status-success-text",
204
- children: I
205
+ children: L
205
206
  }),
206
- P && /* @__PURE__ */ h("p", {
207
+ F && /* @__PURE__ */ g("p", {
207
208
  role: "alert",
208
209
  className: "mt-2 text-xs text-status-error-text",
209
- children: P
210
+ children: F
210
211
  })
211
212
  ]
212
213
  }),
213
- /* @__PURE__ */ g("p", {
214
+ /* @__PURE__ */ _("p", {
214
215
  className: "text-xs text-text-secondary",
215
216
  children: [
216
- w("movethewheels.risk.evaluated", "Evaluated"),
217
+ T("movethewheels.risk.evaluated", "Evaluated"),
217
218
  " ",
218
- e(D.evaluatedAt)
219
+ e(O.evaluatedAt)
220
+ ]
221
+ }),
222
+ (O.atRisk || O.breached) && /* @__PURE__ */ _("div", {
223
+ className: "space-y-2 border-t border-border-primary pt-4",
224
+ children: [
225
+ /* @__PURE__ */ g("p", {
226
+ className: "text-sm font-semibold text-text-primary",
227
+ children: T("movethewheels.exceptionDecision.title", "Remediation options")
228
+ }),
229
+ /* @__PURE__ */ g("p", {
230
+ className: "text-xs text-text-secondary",
231
+ children: T("movethewheels.exceptionDecision.description", "Ranked ways to handle this exception, from the forecast above. Nothing changes until you accept one; the manual action above stays available.")
232
+ }),
233
+ /* @__PURE__ */ g(p, {
234
+ shipmentId: x,
235
+ kind: "EXCEPTION_REMEDIATION",
236
+ onApplied: () => {
237
+ M(), D();
238
+ },
239
+ renderFollowUp: (e) => {
240
+ let t = e.followUpArgs?.id ?? q;
241
+ return e.action === "REASSIGN_VEHICLE" && t ? /* @__PURE__ */ g(i, {
242
+ size: "sm",
243
+ variant: "outline",
244
+ onClick: () => E(t),
245
+ children: T("movethewheels.risk.openOrder", "Open order to reassign")
246
+ }) : e.action === "REQUEST_TRACKING_UPDATE" ? /* @__PURE__ */ _("div", {
247
+ className: "space-y-2",
248
+ children: [/* @__PURE__ */ g(d, {
249
+ value: U,
250
+ onChange: (e) => W(e.target.value),
251
+ maxLength: 500,
252
+ "aria-label": T("movethewheels.risk.updateDetails", "Tracking update"),
253
+ placeholder: T("movethewheels.risk.updatePlaceholder", "What did the driver or carrier report?")
254
+ }), /* @__PURE__ */ g(i, {
255
+ size: "sm",
256
+ disabled: z || U.trim().length === 0,
257
+ onClick: () => void G(() => P(U.trim()), T("movethewheels.risk.updateRecorded", "Tracking update recorded")),
258
+ children: T("movethewheels.risk.recordUpdate", "Record tracking update")
259
+ })]
260
+ }) : null;
261
+ },
262
+ t: T
263
+ })
219
264
  ]
220
265
  })
221
266
  ]
@@ -225,4 +270,4 @@ function b({ shipmentId: b, shipmentNumber: x, open: S, onOpenChange: C, t: w, o
225
270
  });
226
271
  }
227
272
  //#endregion
228
- export { b as ShipmentRiskDialog };
273
+ export { x as ShipmentRiskDialog };