@burdenoff/microfe-movethewheels 2026.1107.1 → 2026.1107.3

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.
@@ -29,8 +29,8 @@ function p() {
29
29
  })
30
30
  });
31
31
  }
32
- var m = i(() => import("./pages/DashboardPage.js")), h = i(() => import("./pages/OrdersListPage.js")), g = i(() => import("./pages/OrderDetailsPage.js")), _ = i(() => import("./pages/CreateOrderPage.js")), v = i(() => import("./pages/TrackingPage.js")), y = i(() => import("./pages/TrackingEventQualityPage.js")), b = i(() => import("./pages/ShipmentStatusAuthorityPage.js")), x = i(() => import("./pages/LiveTrackingPage.js")), S = i(() => import("./pages/FleetPage.js")), C = i(() => import("./pages/VehiclesPage.js")), w = i(() => import("./pages/VehicleDetailsPage.js")), T = i(() => import("./pages/DriversPage.js")), E = i(() => import("./pages/DriverDetailsPage.js")), D = i(() => import("./pages/InventoryPage.js")), O = i(() => import("./pages/ProductsPage.js")), k = i(() => import("./pages/ProductDetailsPage.js")), A = i(() => import("./pages/PalletPreviewPage.js")), j = i(() => import("./pages/WarehousesPage.js")), M = i(() => import("./pages/WarehouseDetailsPage.js")), N = i(() => import("./pages/CustomersPage.js")), P = i(() => import("./pages/CustomerDetailsPage.js")), F = i(() => import("./pages/MarketplacePage.js")), ee = i(() => import("./pages/ImportExportPage.js")), I = i(() => import("./pages/SettingsPage.js")), L = i(() => import("./pages/IntegrationsPage.js")), R = i(() => import("./pages/ReportsPage.js")), z = i(() => import("./pages/RoutesPage.js")), B = i(() => import("./pages/RouteDetailsPage.js")), V = i(() => import("./pages/AnalyticsPage.js")), H = i(() => import("./pages/FinancePage.js")), U = i(() => import("./pages/FreightEstimatePage.js")), W = i(() => import("./pages/FreightInvoicePage.js")), G = i(() => import("./pages/ConsolidationPage.js")), K = i(() => import("./pages/LogisticsProceduresPage.js")), q = i(() => import("./pages/DeliveryCapturePage.js")), J = i(() => import("./pages/MultiModalShipmentPage.js")), Y = i(() => import("./pages/ShippingRatesPage.js")), X = i(() => import("./pages/ContainersPage.js")), Z = i(() => import("./pages/ContainerConditionPage.js")), Q = i(() => import("./pages/FreeTimePage.js")), $ = i(() => import("./pages/PendingPickPage.js")), te = i(() => import("./pages/StockObservationsPage.js")), ne = i(() => import("./pages/StockBindingPage.js")), re = i(() => import("./pages/TripUtilizationPage.js")), ie = i(() => import("./pages/ConsumedFuelPreviewPage.js")), ae = i(() => import("./pages/EmptyReusePage.js"));
33
- function oe() {
32
+ var m = i(() => import("./pages/DashboardPage.js")), h = i(() => import("./pages/OrdersListPage.js")), g = i(() => import("./pages/OrderDetailsPage.js")), _ = i(() => import("./pages/CreateOrderPage.js")), v = i(() => import("./pages/TrackingPage.js")), y = i(() => import("./pages/TrackingEventQualityPage.js")), b = i(() => import("./pages/ShipmentStatusAuthorityPage.js")), x = i(() => import("./pages/LiveTrackingPage.js")), S = i(() => import("./pages/FleetPage.js")), C = i(() => import("./pages/VehiclesPage.js")), w = i(() => import("./pages/VehicleDetailsPage.js")), T = i(() => import("./pages/DriversPage.js")), E = i(() => import("./pages/DriverDetailsPage.js")), D = i(() => import("./pages/InventoryPage.js")), O = i(() => import("./pages/ProductsPage.js")), k = i(() => import("./pages/ProductDetailsPage.js")), A = i(() => import("./pages/PalletPreviewPage.js")), j = i(() => import("./pages/WarehousesPage.js")), M = i(() => import("./pages/WarehouseDetailsPage.js")), N = i(() => import("./pages/CustomersPage.js")), P = i(() => import("./pages/CustomerDetailsPage.js")), F = i(() => import("./pages/MarketplacePage.js")), ee = i(() => import("./pages/ImportExportPage.js")), I = i(() => import("./pages/SettingsPage.js")), L = i(() => import("./pages/IntegrationsPage.js")), R = i(() => import("./pages/ReportsPage.js")), z = i(() => import("./pages/RoutesPage.js")), B = i(() => import("./pages/RouteDetailsPage.js")), V = i(() => import("./pages/AnalyticsPage.js")), H = i(() => import("./pages/FinancePage.js")), U = i(() => import("./pages/FreightEstimatePage.js")), W = i(() => import("./pages/FreightInvoicePage.js")), G = i(() => import("./pages/ConsolidationPage.js")), K = i(() => import("./pages/LogisticsProceduresPage.js")), q = i(() => import("./pages/DeliveryCapturePage.js")), J = i(() => import("./pages/MultiModalShipmentPage.js")), Y = i(() => import("./pages/ShippingRatesPage.js")), X = i(() => import("./pages/ContainersPage.js")), Z = i(() => import("./pages/ContainerConditionPage.js")), Q = i(() => import("./pages/FreeTimePage.js")), $ = i(() => import("./pages/PendingPickPage.js")), te = i(() => import("./pages/StockObservationsPage.js")), ne = i(() => import("./pages/StockBindingPage.js")), re = i(() => import("./pages/TripUtilizationPage.js")), ie = i(() => import("./pages/DispatchPlanPage.js")), ae = i(() => import("./pages/ConsumedFuelPreviewPage.js")), oe = i(() => import("./pages/EmptyReusePage.js"));
33
+ function se() {
34
34
  return t(), /* @__PURE__ */ l(r, {
35
35
  fallback: /* @__PURE__ */ l(p, {}),
36
36
  children: /* @__PURE__ */ u(s, { children: [
@@ -96,7 +96,7 @@ function oe() {
96
96
  }),
97
97
  /* @__PURE__ */ l(o, {
98
98
  path: "containers/empty-reuse",
99
- element: /* @__PURE__ */ l(ae, {})
99
+ element: /* @__PURE__ */ l(oe, {})
100
100
  }),
101
101
  /* @__PURE__ */ l(o, {
102
102
  path: "containers/consolidation",
@@ -235,9 +235,13 @@ function oe() {
235
235
  element: /* @__PURE__ */ l(re, {})
236
236
  }),
237
237
  /* @__PURE__ */ l(o, {
238
- path: "fuel-preview",
238
+ path: "routes/dispatch-plan",
239
239
  element: /* @__PURE__ */ l(ie, {})
240
240
  }),
241
+ /* @__PURE__ */ l(o, {
242
+ path: "fuel-preview",
243
+ element: /* @__PURE__ */ l(ae, {})
244
+ }),
241
245
  /* @__PURE__ */ l(o, {
242
246
  path: "routes/new",
243
247
  element: /* @__PURE__ */ l(B, {})
@@ -281,4 +285,4 @@ function oe() {
281
285
  });
282
286
  }
283
287
  //#endregion
284
- export { oe as MoveTheWheelsRoutes };
288
+ export { se as MoveTheWheelsRoutes };
@@ -0,0 +1,203 @@
1
+ import { Check as e } from "../node_modules/lucide-react/dist/esm/icons/check.js";
2
+ import { Route as t } from "../node_modules/lucide-react/dist/esm/icons/route.js";
3
+ import { Sparkles as n } from "../node_modules/lucide-react/dist/esm/icons/sparkles.js";
4
+ import { Truck as r } from "../node_modules/lucide-react/dist/esm/icons/truck.js";
5
+ import { User as i } from "../node_modules/lucide-react/dist/esm/icons/user.js";
6
+ import { X as a } from "../node_modules/lucide-react/dist/esm/icons/x.js";
7
+ import { formatDateTime as o } from "../utils/formatters.js";
8
+ import { Badge as s, Button as c, Card as l, CardContent as u } from "./ui.js";
9
+ import { jsx as d, jsxs as f } from "react/jsx-runtime";
10
+ //#region src/movethewheels/components/DispatchDecisionCard.tsx
11
+ var p = {
12
+ EARLIEST_DUE: ["movethewheels.dispatch.reason.earliestDue", "Earliest due"],
13
+ MAINTENANCE_OK: ["movethewheels.dispatch.reason.maintenanceOk", "No service due"],
14
+ MAINTENANCE_DUE_SOON: ["movethewheels.dispatch.reason.maintenanceDueSoon", "Service due soon"],
15
+ MAINTENANCE_OVERDUE: ["movethewheels.dispatch.reason.maintenanceOverdue", "Service overdue"],
16
+ FUEL_EFFICIENT: ["movethewheels.dispatch.reason.fuelEfficient", "Most fuel-efficient"],
17
+ CAPACITY_FITS: ["movethewheels.dispatch.reason.capacityFits", "Capacity fits"],
18
+ CAPACITY_UNKNOWN: ["movethewheels.dispatch.reason.capacityUnknown", "Capacity not recorded"],
19
+ DRIVER_AVAILABLE: ["movethewheels.dispatch.reason.driverAvailable", "Driver available"],
20
+ DRIVER_RATED: ["movethewheels.dispatch.reason.driverRated", "Driver rated"],
21
+ LICENSE_EXPIRING: ["movethewheels.dispatch.reason.licenseExpiring", "Licence expiring"],
22
+ LINKED_PAIR: ["movethewheels.dispatch.reason.linkedPair", "Linked vehicle and driver"],
23
+ DISTANCE_MEASURED: ["movethewheels.dispatch.reason.distanceMeasured", "Distance measured"],
24
+ DISTANCE_UNKNOWN: ["movethewheels.dispatch.reason.distanceUnknown", "No coordinates"]
25
+ }, m = new Set([
26
+ "MAINTENANCE_DUE_SOON",
27
+ "MAINTENANCE_OVERDUE",
28
+ "CAPACITY_UNKNOWN",
29
+ "LICENSE_EXPIRING",
30
+ "DISTANCE_UNKNOWN"
31
+ ]);
32
+ function h(e, t) {
33
+ let n = p[e];
34
+ return n ? t(n[0], n[1]) : e;
35
+ }
36
+ function g(e) {
37
+ return e >= .75 ? "text-status-success-text" : e >= .5 ? "text-status-warning-text" : "text-status-error-text";
38
+ }
39
+ function _({ assignment: e, onOpenRoute: n, t: r }) {
40
+ return e.decision === "ACCEPTED" ? /* @__PURE__ */ f("div", {
41
+ className: "flex flex-wrap items-center gap-2",
42
+ children: [/* @__PURE__ */ d(s, {
43
+ variant: "default",
44
+ children: r("movethewheels.dispatch.decision.accepted", "Accepted")
45
+ }), e.routeId && /* @__PURE__ */ f(c, {
46
+ size: "sm",
47
+ variant: "outline",
48
+ onClick: () => n(e.routeId),
49
+ children: [/* @__PURE__ */ d(t, {
50
+ size: 14,
51
+ "aria-hidden": "true"
52
+ }), r("movethewheels.dispatch.openRoute", "Open route")]
53
+ })]
54
+ }) : e.decision === "STALE" ? /* @__PURE__ */ f("div", {
55
+ className: "space-y-1",
56
+ children: [/* @__PURE__ */ d(s, {
57
+ variant: "outline",
58
+ children: r("movethewheels.dispatch.decision.stale", "Not applied")
59
+ }), e.decisionReason && /* @__PURE__ */ d("p", {
60
+ className: "text-xs text-status-warning-text",
61
+ children: e.decisionReason
62
+ })]
63
+ }) : e.decision === "REJECTED" ? /* @__PURE__ */ d(s, {
64
+ variant: "secondary",
65
+ children: r("movethewheels.dispatch.decision.rejected", "Rejected")
66
+ }) : /* @__PURE__ */ d(s, {
67
+ variant: "outline",
68
+ children: r("movethewheels.dispatch.decision.pending", "Not decided")
69
+ });
70
+ }
71
+ function v({ assignment: t, open: p, choice: v, disabled: y, onChoose: b, onOpenRoute: x, t: S }) {
72
+ let C = Math.round(t.confidence * 100), w = t.shipmentNumber ?? t.shipmentId, T = "border-border-default";
73
+ return p && v === "accept" ? T = "border-status-success-border" : p && v === "reject" && (T = "border-status-error-border"), /* @__PURE__ */ d(l, {
74
+ className: T,
75
+ "data-assignment-id": t.id,
76
+ "data-testid": "dispatch-decision-card",
77
+ children: /* @__PURE__ */ f(u, {
78
+ className: "space-y-3 p-4",
79
+ children: [
80
+ /* @__PURE__ */ f("div", {
81
+ className: "flex flex-wrap items-start justify-between gap-3",
82
+ children: [/* @__PURE__ */ f("div", {
83
+ className: "min-w-0 space-y-1",
84
+ children: [/* @__PURE__ */ f("p", {
85
+ className: "text-sm font-semibold break-words text-text-primary",
86
+ children: [
87
+ S("movethewheels.dispatch.shipment", "Shipment"),
88
+ " ",
89
+ w
90
+ ]
91
+ }), t.estimatedDelivery && /* @__PURE__ */ f("p", {
92
+ className: "text-xs text-text-secondary",
93
+ children: [
94
+ S("movethewheels.dispatch.due", "Due"),
95
+ " ",
96
+ o(t.estimatedDelivery)
97
+ ]
98
+ })]
99
+ }), /* @__PURE__ */ f("div", {
100
+ className: "text-right",
101
+ children: [/* @__PURE__ */ f("p", {
102
+ className: `text-lg font-bold tabular-nums ${g(t.confidence)}`,
103
+ children: [C, "%"]
104
+ }), /* @__PURE__ */ d("p", {
105
+ className: "text-xs text-text-secondary",
106
+ children: S("movethewheels.dispatch.confidence", "Planner confidence")
107
+ })]
108
+ })]
109
+ }),
110
+ /* @__PURE__ */ f("div", {
111
+ className: "grid gap-2 text-sm sm:grid-cols-2",
112
+ children: [/* @__PURE__ */ f("p", {
113
+ className: "flex items-center gap-2 break-words",
114
+ children: [/* @__PURE__ */ d(r, {
115
+ size: 16,
116
+ className: "shrink-0 text-text-secondary",
117
+ "aria-hidden": "true"
118
+ }), /* @__PURE__ */ f("span", { children: [t.vehicleNumber ?? t.vehicleId, t.vehicleType && /* @__PURE__ */ f("span", {
119
+ className: "text-text-secondary",
120
+ children: [" · ", t.vehicleType]
121
+ })] })]
122
+ }), /* @__PURE__ */ f("p", {
123
+ className: "flex items-center gap-2 break-words",
124
+ children: [/* @__PURE__ */ d(i, {
125
+ size: 16,
126
+ className: "shrink-0 text-text-secondary",
127
+ "aria-hidden": "true"
128
+ }), /* @__PURE__ */ d("span", { children: t.driverName ?? t.driverId })]
129
+ })]
130
+ }),
131
+ /* @__PURE__ */ d("ul", {
132
+ className: "flex flex-wrap gap-1.5",
133
+ "aria-label": S("movethewheels.dispatch.reasons", "Reasons"),
134
+ children: t.reasons.map((e) => /* @__PURE__ */ d("li", { children: /* @__PURE__ */ d(s, {
135
+ variant: m.has(e) ? "outline" : "secondary",
136
+ children: h(e, S)
137
+ }) }, e))
138
+ }),
139
+ /* @__PURE__ */ d("p", {
140
+ className: "text-sm text-text-secondary",
141
+ children: t.rationale
142
+ }),
143
+ t.aiRationale && /* @__PURE__ */ f("p", {
144
+ className: "flex items-start gap-2 rounded-md bg-surface-secondary p-2 text-sm text-text-primary",
145
+ children: [/* @__PURE__ */ d(n, {
146
+ size: 14,
147
+ className: "mt-0.5 shrink-0",
148
+ "aria-hidden": "true"
149
+ }), /* @__PURE__ */ f("span", { children: [/* @__PURE__ */ f("span", {
150
+ className: "sr-only",
151
+ children: [
152
+ S("movethewheels.dispatch.aiWritten", "AI-written"),
153
+ ":",
154
+ " "
155
+ ]
156
+ }), t.aiRationale] })]
157
+ }),
158
+ t.estimatedDistanceKm !== null && /* @__PURE__ */ f("p", {
159
+ className: "text-xs text-text-secondary",
160
+ children: [
161
+ S("movethewheels.dispatch.distance", "Straight-line distance"),
162
+ " ",
163
+ t.estimatedDistanceKm,
164
+ " km",
165
+ t.estimatedDurationMinutes !== null && ` · ~${Math.round(t.estimatedDurationMinutes)} min`
166
+ ]
167
+ }),
168
+ p ? /* @__PURE__ */ f("div", {
169
+ className: "flex flex-wrap gap-2",
170
+ role: "group",
171
+ "aria-label": S("movethewheels.dispatch.decide", "Decide this assignment"),
172
+ children: [/* @__PURE__ */ f(c, {
173
+ size: "sm",
174
+ variant: v === "accept" ? "default" : "outline",
175
+ "aria-pressed": v === "accept",
176
+ disabled: y,
177
+ onClick: () => b(v === "accept" ? null : "accept"),
178
+ children: [/* @__PURE__ */ d(e, {
179
+ size: 14,
180
+ "aria-hidden": "true"
181
+ }), S("movethewheels.dispatch.accept", "Accept")]
182
+ }), /* @__PURE__ */ f(c, {
183
+ size: "sm",
184
+ variant: v === "reject" ? "destructive" : "outline",
185
+ "aria-pressed": v === "reject",
186
+ disabled: y,
187
+ onClick: () => b(v === "reject" ? null : "reject"),
188
+ children: [/* @__PURE__ */ d(a, {
189
+ size: 14,
190
+ "aria-hidden": "true"
191
+ }), S("movethewheels.dispatch.reject", "Reject")]
192
+ })]
193
+ }) : /* @__PURE__ */ d(_, {
194
+ assignment: t,
195
+ onOpenRoute: x,
196
+ t: S
197
+ })
198
+ ]
199
+ })
200
+ });
201
+ }
202
+ //#endregion
203
+ export { v as DispatchDecisionCard };
@@ -1095,6 +1095,19 @@ export type MtwDashboardMetrics = {
1095
1095
  totalDeliveryJobs: Scalars['Int']['output'];
1096
1096
  totalRevenue: Scalars['Float']['output'];
1097
1097
  };
1098
+ export type MtwDecisionRationaleStatus =
1099
+ /** AI is switched off for this environment; the planner's own rationale is shown. */
1100
+ 'AI_DISABLED'
1101
+ /** A model-written summary and rationale are attached. */
1102
+ | 'AVAILABLE'
1103
+ /** The workspace has spent its MoveTheWheels AI credits; no model call was made. */
1104
+ | 'CREDITS_EXHAUSTED'
1105
+ /** The workspace reached its daily AI cap; no model call was made. */
1106
+ | 'DAILY_CAP_REACHED'
1107
+ /** There was nothing to explain (no assignments). */
1108
+ | 'NOT_NEEDED'
1109
+ /** The model could not produce a rationale this time; the plan is unchanged. */
1110
+ | 'UNAVAILABLE';
1098
1111
  /**
1099
1112
  * MoveTheWheels-owned operational dispatch unit. It is intentionally not a cart/order
1100
1113
  * system; checkout and order of record remain in global-store-svc StoreOrder.
@@ -1216,6 +1229,78 @@ export type MtwDemandForecastVariance = {
1216
1229
  scopeType: DemandForecastScope;
1217
1230
  volumeVariance: Scalars['Int']['output'];
1218
1231
  };
1232
+ /** One proposed shipment -> vehicle + driver pairing. */
1233
+ export type MtwDispatchAssignment = {
1234
+ __typename?: 'MtwDispatchAssignment';
1235
+ /** Model-written rationale, when AI produced one. */
1236
+ aiRationale?: Maybe<Scalars['String']['output']>;
1237
+ /** Planner confidence from 0 to 1, from how much of what the pairing depends on is recorded and favourable. Not a probability of on-time delivery. */
1238
+ confidence: Scalars['Float']['output'];
1239
+ decidedAt?: Maybe<Scalars['DateTime']['output']>;
1240
+ decision: MtwDispatchAssignmentDecision;
1241
+ decisionReason?: Maybe<Scalars['String']['output']>;
1242
+ driverId: Scalars['ID']['output'];
1243
+ driverName?: Maybe<Scalars['String']['output']>;
1244
+ estimatedDelivery?: Maybe<Scalars['DateTime']['output']>;
1245
+ estimatedDistanceKm?: Maybe<Scalars['Float']['output']>;
1246
+ estimatedDurationMinutes?: Maybe<Scalars['Float']['output']>;
1247
+ id: Scalars['ID']['output'];
1248
+ planId: Scalars['ID']['output'];
1249
+ /** The planner's own factual rationale. */
1250
+ rationale: Scalars['String']['output'];
1251
+ /** Reason codes behind the pairing, e.g. MAINTENANCE_OK, CAPACITY_FITS, LINKED_PAIR. */
1252
+ reasons: Array<Scalars['String']['output']>;
1253
+ routeId?: Maybe<Scalars['ID']['output']>;
1254
+ sequence: Scalars['Int']['output'];
1255
+ shipmentId: Scalars['ID']['output'];
1256
+ shipmentNumber?: Maybe<Scalars['String']['output']>;
1257
+ vehicleId: Scalars['ID']['output'];
1258
+ vehicleNumber?: Maybe<Scalars['String']['output']>;
1259
+ vehicleType?: Maybe<Scalars['String']['output']>;
1260
+ waypoints: Scalars['JSON']['output'];
1261
+ };
1262
+ export type MtwDispatchAssignmentDecision =
1263
+ /** Accepted; routeId is the route that was created. */
1264
+ 'ACCEPTED' | 'PENDING' | 'REJECTED'
1265
+ /** Accepted, but the shipment, vehicle or driver changed since the proposal; decisionReason says how. No route was created. */
1266
+ | 'STALE';
1267
+ export type MtwDispatchPlan = {
1268
+ __typename?: 'MtwDispatchPlan';
1269
+ acceptedCount: Scalars['Int']['output'];
1270
+ /** Provider-qualified model that wrote the rationale, when one did. */
1271
+ aiModel?: Maybe<Scalars['String']['output']>;
1272
+ aiStatus: MtwDecisionRationaleStatus;
1273
+ aiSummary?: Maybe<Scalars['String']['output']>;
1274
+ assignments: Array<MtwDispatchAssignment>;
1275
+ createdAt: Scalars['DateTime']['output'];
1276
+ createdBy: Scalars['String']['output'];
1277
+ decidedAt?: Maybe<Scalars['DateTime']['output']>;
1278
+ decidedBy?: Maybe<Scalars['String']['output']>;
1279
+ expiresAt: Scalars['DateTime']['output'];
1280
+ id: Scalars['ID']['output'];
1281
+ /** The deterministic planner that produced the assignments. */
1282
+ method: Scalars['String']['output'];
1283
+ pendingCount: Scalars['Int']['output'];
1284
+ rejectedCount: Scalars['Int']['output'];
1285
+ staleCount: Scalars['Int']['output'];
1286
+ status: MtwDispatchPlanStatus;
1287
+ unassigned: Array<MtwUnassignedShipment>;
1288
+ windowEnd?: Maybe<Scalars['DateTime']['output']>;
1289
+ windowStart?: Maybe<Scalars['DateTime']['output']>;
1290
+ };
1291
+ export type MtwDispatchPlanStatus =
1292
+ /** Every assignment was accepted and has a route. */
1293
+ 'APPLIED'
1294
+ /** A decision is being applied right now. */
1295
+ | 'APPLYING'
1296
+ /** The plan was superseded by a newer one or passed its expiry without a decision. */
1297
+ | 'EXPIRED'
1298
+ /** Some assignments were accepted; the rest were rejected or had gone stale. */
1299
+ | 'PARTIALLY_APPLIED'
1300
+ /** Waiting for a decision. */
1301
+ | 'PROPOSED'
1302
+ /** No assignment was accepted; nothing was written. */
1303
+ | 'REJECTED';
1219
1304
  /** Unit MoveTheWheels shows distances in. */
1220
1305
  export type MtwDistanceUnit =
1221
1306
  /** Kilometres */
@@ -2828,6 +2913,16 @@ export type MtwPickTaskPage = {
2828
2913
  };
2829
2914
  export type MtwPickTaskStatus = 'PENDING_REVIEW';
2830
2915
  export type MtwPickTaskWorkflow = 'PICK_TO_STAGING';
2916
+ export type MtwPlanDispatchInput = {
2917
+ /** Only shipments due at or after this time (shipments with no due date are always considered). */
2918
+ from?: InputMaybe<Scalars['DateTime']['input']>;
2919
+ /** At most this many assignments, 1 to 50. Default 25. */
2920
+ maxAssignments?: InputMaybe<Scalars['Int']['input']>;
2921
+ /** Plan only these shipments (at most 100). */
2922
+ shipmentIds?: InputMaybe<Array<Scalars['ID']['input']>>;
2923
+ /** Only shipments due at or before this time. */
2924
+ to?: InputMaybe<Scalars['DateTime']['input']>;
2925
+ };
2831
2926
  export type MtwProcedureApplicability = {
2832
2927
  __typename?: 'MtwProcedureApplicability';
2833
2928
  enforcement: MtwProcedureRecordingBoundary;
@@ -4166,6 +4261,13 @@ export type MtwTripUtilizationSummary = {
4166
4261
  tripId: Scalars['ID']['output'];
4167
4262
  unknownFactsSegmentCount: Scalars['Int']['output'];
4168
4263
  };
4264
+ export type MtwUnassignedShipment = {
4265
+ __typename?: 'MtwUnassignedShipment';
4266
+ /** NO_ELIGIBLE_PAIR, FLEET_FULLY_ASSIGNED, OVER_CAPACITY, PLAN_LIMIT_REACHED or NOT_PLANNABLE. */
4267
+ reason: Scalars['String']['output'];
4268
+ shipmentId: Scalars['ID']['output'];
4269
+ shipmentNumber?: Maybe<Scalars['String']['output']>;
4270
+ };
4169
4271
  export type MtwUpdateReportInput = {
4170
4272
  description?: InputMaybe<Scalars['String']['input']>;
4171
4273
  frequency?: InputMaybe<MtwReportFrequency>;
@@ -4407,6 +4509,12 @@ export type Mutation = {
4407
4509
  importMtwDrivers: MtwImportResult;
4408
4510
  importMtwVehicles: MtwImportResult;
4409
4511
  importMtwWarehouses: MtwImportResult;
4512
+ /**
4513
+ * Accept the listed assignments of an open plan and reject the rest. One PLANNED
4514
+ * route is created per accepted assignment, through the normal route checks.
4515
+ * An empty list rejects the whole plan.
4516
+ */
4517
+ mtwApplyDispatchPlan: MtwDispatchPlan;
4410
4518
  /** Register, verify or repair the workspace's scheduled-reports job. Idempotent. */
4411
4519
  mtwEnsureReportSchedule?: Maybe<MtwReportSchedule>;
4412
4520
  /**
@@ -4421,6 +4529,14 @@ export type Mutation = {
4421
4529
  * makes no model call; `narrationStatus` says why.
4422
4530
  */
4423
4531
  mtwNarrateShipmentRiskForecast: MtwRiskForecast;
4532
+ /**
4533
+ * Propose vehicle + driver assignments for PLANNED shipments that have no live
4534
+ * route. Proposal only: no route or delivery job is written. A new proposal
4535
+ * expires any older open one.
4536
+ */
4537
+ mtwPlanDispatch: MtwDispatchPlan;
4538
+ /** Reject every assignment of an open plan. Writes no route or delivery job. */
4539
+ mtwRejectDispatchPlan: MtwDispatchPlan;
4424
4540
  /**
4425
4541
  * Re-forecast every in-flight shipment of the workspace and notify for any that
4426
4542
  * started slipping. Fired by wspace-scheduler-svc as this service's own service
@@ -4656,9 +4772,19 @@ export type MutationImportMtwVehiclesArgs = {
4656
4772
  export type MutationImportMtwWarehousesArgs = {
4657
4773
  input: MtwImportInput;
4658
4774
  };
4775
+ export type MutationMtwApplyDispatchPlanArgs = {
4776
+ accept: Array<Scalars['ID']['input']>;
4777
+ planId: Scalars['ID']['input'];
4778
+ };
4659
4779
  export type MutationMtwNarrateShipmentRiskForecastArgs = {
4660
4780
  shipmentId: Scalars['ID']['input'];
4661
4781
  };
4782
+ export type MutationMtwPlanDispatchArgs = {
4783
+ input?: InputMaybe<MtwPlanDispatchInput>;
4784
+ };
4785
+ export type MutationMtwRejectDispatchPlanArgs = {
4786
+ planId: Scalars['ID']['input'];
4787
+ };
4662
4788
  export type MutationMtwRunRiskSweepArgs = {
4663
4789
  input?: InputMaybe<MtwRunRiskSweepInput>;
4664
4790
  };
@@ -5015,6 +5141,8 @@ export type Query = {
5015
5141
  mtwCustomerNotificationSettings: MtwCustomerNotificationSettings;
5016
5142
  /** Customer notifications sent or attempted in this workspace, newest first. */
5017
5143
  mtwCustomerNotifications: MtwCustomerNotificationPage;
5144
+ mtwDispatchPlan?: Maybe<MtwDispatchPlan>;
5145
+ mtwDispatchPlans: Array<MtwDispatchPlan>;
5018
5146
  /** Exact immutable instruction, including a proposal's historical owner; not a current-eligibility claim. */
5019
5147
  mtwEmptyReturnInstruction: MtwEmptyReturnInstruction;
5020
5148
  mtwEmptyReturnInstructionPage: MtwEmptyReturnInstructionPage;
@@ -5040,6 +5168,8 @@ export type Query = {
5040
5168
  * entity create permission.
5041
5169
  */
5042
5170
  mtwImportSpec: Array<MtwImportEntitySpec>;
5171
+ /** The workspace's most recent dispatch plan, whatever its status. */
5172
+ mtwLatestDispatchPlan?: Maybe<MtwDispatchPlan>;
5043
5173
  /** The workspace's MoveTheWheels operational defaults; platform defaults when none were saved. */
5044
5174
  mtwModuleSettings: MtwModuleSettings;
5045
5175
  mtwPalletGeometryPreview: MtwPalletGeometryPreview;
@@ -5315,6 +5445,13 @@ export type QueryMtwCustomerNotificationsArgs = {
5315
5445
  filter?: InputMaybe<MtwCustomerNotificationFilterInput>;
5316
5446
  pagination?: InputMaybe<PaginationInput>;
5317
5447
  };
5448
+ export type QueryMtwDispatchPlanArgs = {
5449
+ id: Scalars['ID']['input'];
5450
+ };
5451
+ export type QueryMtwDispatchPlansArgs = {
5452
+ pagination?: InputMaybe<PaginationInput>;
5453
+ status?: InputMaybe<MtwDispatchPlanStatus>;
5454
+ };
5318
5455
  export type QueryMtwEmptyReturnInstructionArgs = {
5319
5456
  id: Scalars['ID']['input'];
5320
5457
  };
@@ -0,0 +1,88 @@
1
+ import { useMoveTheWheels as e } from "../providers/MoveTheWheelsProvider.js";
2
+ import { executeGraphQL as t } from "../utils/graphqlClient.js";
3
+ import { useCallback as n, useEffect as r, useMemo as i, useState as a } from "react";
4
+ //#region src/movethewheels/hooks/useDispatchPlan.ts
5
+ var o = "\n id\n status\n method\n aiStatus\n aiSummary\n aiModel\n assignments {\n id\n sequence\n shipmentId\n shipmentNumber\n estimatedDelivery\n vehicleId\n vehicleNumber\n vehicleType\n driverId\n driverName\n confidence\n reasons\n rationale\n aiRationale\n estimatedDistanceKm\n estimatedDurationMinutes\n decision\n decisionReason\n routeId\n }\n unassigned {\n shipmentId\n shipmentNumber\n reason\n }\n acceptedCount\n rejectedCount\n staleCount\n pendingCount\n expiresAt\n decidedAt\n createdAt\n", s = `
6
+ query LatestDispatchPlan {
7
+ mtwLatestDispatchPlan {
8
+ ${o}
9
+ }
10
+ }
11
+ `, c = `
12
+ mutation PlanDispatch($input: MtwPlanDispatchInput) {
13
+ mtwPlanDispatch(input: $input) {
14
+ ${o}
15
+ }
16
+ }
17
+ `, l = `
18
+ mutation ApplyDispatchPlan($planId: ID!, $accept: [ID!]!) {
19
+ mtwApplyDispatchPlan(planId: $planId, accept: $accept) {
20
+ ${o}
21
+ }
22
+ }
23
+ `, u = `
24
+ mutation RejectDispatchPlan($planId: ID!) {
25
+ mtwRejectDispatchPlan(planId: $planId) {
26
+ ${o}
27
+ }
28
+ }
29
+ `;
30
+ function d() {
31
+ let { apiGatewayUrl: t, authToken: n, workspaceToken: r, workspaceId: a, tenantId: o, currentUser: s } = e();
32
+ return i(() => ({
33
+ apiGatewayUrl: t,
34
+ authToken: n,
35
+ workspaceToken: r,
36
+ workspaceId: a,
37
+ tenantId: o,
38
+ actorId: s?.id
39
+ }), [
40
+ t,
41
+ n,
42
+ r,
43
+ a,
44
+ o,
45
+ s?.id
46
+ ]);
47
+ }
48
+ function f() {
49
+ let e = d(), [i, o] = a(null), [f, p] = a(!0), [m, h] = a(null), [g, _] = a(null), v = n(async () => {
50
+ p(!0), h(null);
51
+ try {
52
+ o((await t(e, s)).mtwLatestDispatchPlan);
53
+ } catch (e) {
54
+ h(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load the dispatch plan"));
55
+ } finally {
56
+ p(!1);
57
+ }
58
+ }, [e]);
59
+ r(() => {
60
+ v();
61
+ }, [v]);
62
+ let y = n(async (e, t, n) => {
63
+ _(e);
64
+ try {
65
+ let e = n(await t());
66
+ return o(e), e;
67
+ } catch (e) {
68
+ throw v(), e;
69
+ } finally {
70
+ _(null);
71
+ }
72
+ }, [v]);
73
+ return {
74
+ plan: i,
75
+ isLoading: f,
76
+ error: m,
77
+ pendingAction: g,
78
+ refetch: () => void v(),
79
+ propose: n((n = {}) => y("propose", () => t(e, c, { input: n }, "SINGLE_ATTEMPT"), (e) => e.mtwPlanDispatch), [e, y]),
80
+ apply: n((n, r) => y("apply", () => t(e, l, {
81
+ planId: n,
82
+ accept: r
83
+ }, "SINGLE_ATTEMPT"), (e) => e.mtwApplyDispatchPlan), [e, y]),
84
+ reject: n((n) => y("reject", () => t(e, u, { planId: n }, "SINGLE_ATTEMPT"), (e) => e.mtwRejectDispatchPlan), [e, y])
85
+ };
86
+ }
87
+ //#endregion
88
+ export { f as useDispatchPlan };
@@ -0,0 +1,16 @@
1
+ import { DispatchAssignment } from '../hooks/useDispatchPlan';
2
+ export type DispatchChoice = 'accept' | 'reject' | null;
3
+ type Translate = (key: string, fallback: string) => string;
4
+ export declare function reasonLabel(reason: string, t: Translate): string;
5
+ interface DispatchDecisionCardProps {
6
+ assignment: DispatchAssignment;
7
+ /** True while the plan can still be decided. */
8
+ open: boolean;
9
+ choice: DispatchChoice;
10
+ disabled: boolean;
11
+ onChoose: (choice: DispatchChoice) => void;
12
+ onOpenRoute: (routeId: string) => void;
13
+ t: Translate;
14
+ }
15
+ export declare function DispatchDecisionCard({ assignment, open, choice, disabled, onChoose, onOpenRoute, t, }: DispatchDecisionCardProps): import('react').JSX.Element;
16
+ export {};
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Dispatch decision proposals (BOFF-10562).
3
+ *
4
+ * Reads the workspace's latest dispatch plan and drives its three decisions:
5
+ *
6
+ * - `propose` calls `mtwPlanDispatch`, which proposes vehicle + driver pairings
7
+ * for PLANNED shipments and writes no route.
8
+ * - `apply(acceptIds)` calls `mtwApplyDispatchPlan`: one PLANNED route per
9
+ * accepted assignment, every other assignment rejected. Partial accept is the
10
+ * normal case.
11
+ * - `reject` calls `mtwRejectDispatchPlan`, which writes nothing else.
12
+ *
13
+ * The server decides everything (eligibility, staleness, expiry, AI credit
14
+ * gating). This hook only reflects the plan the server returns after each
15
+ * call, so what a person sees is always the stored record.
16
+ */
17
+ export type DispatchPlanStatus = 'PROPOSED' | 'APPLYING' | 'APPLIED' | 'PARTIALLY_APPLIED' | 'REJECTED' | 'EXPIRED';
18
+ export type DispatchAssignmentDecision = 'PENDING' | 'ACCEPTED' | 'REJECTED' | 'STALE';
19
+ export type DecisionRationaleStatus = 'AVAILABLE' | 'NOT_NEEDED' | 'AI_DISABLED' | 'CREDITS_EXHAUSTED' | 'DAILY_CAP_REACHED' | 'UNAVAILABLE';
20
+ export interface DispatchAssignment {
21
+ id: string;
22
+ sequence: number;
23
+ shipmentId: string;
24
+ shipmentNumber: string | null;
25
+ estimatedDelivery: string | null;
26
+ vehicleId: string;
27
+ vehicleNumber: string | null;
28
+ vehicleType: string | null;
29
+ driverId: string;
30
+ driverName: string | null;
31
+ confidence: number;
32
+ reasons: string[];
33
+ rationale: string;
34
+ aiRationale: string | null;
35
+ estimatedDistanceKm: number | null;
36
+ estimatedDurationMinutes: number | null;
37
+ decision: DispatchAssignmentDecision;
38
+ decisionReason: string | null;
39
+ routeId: string | null;
40
+ }
41
+ export interface UnassignedShipment {
42
+ shipmentId: string;
43
+ shipmentNumber: string | null;
44
+ reason: string;
45
+ }
46
+ export interface DispatchPlan {
47
+ id: string;
48
+ status: DispatchPlanStatus;
49
+ method: string;
50
+ aiStatus: DecisionRationaleStatus;
51
+ aiSummary: string | null;
52
+ aiModel: string | null;
53
+ assignments: DispatchAssignment[];
54
+ unassigned: UnassignedShipment[];
55
+ acceptedCount: number;
56
+ rejectedCount: number;
57
+ staleCount: number;
58
+ pendingCount: number;
59
+ expiresAt: string;
60
+ decidedAt: string | null;
61
+ createdAt: string;
62
+ }
63
+ export interface PlanDispatchOptions {
64
+ /** ISO date-time: only shipments due at or after this. */
65
+ from?: string;
66
+ /** ISO date-time: only shipments due at or before this. */
67
+ to?: string;
68
+ maxAssignments?: number;
69
+ }
70
+ export declare function useDispatchPlan(): {
71
+ plan: DispatchPlan | null;
72
+ isLoading: boolean;
73
+ error: Error | null;
74
+ pendingAction: "reject" | "propose" | "apply" | null;
75
+ refetch: () => undefined;
76
+ propose: (options?: PlanDispatchOptions) => Promise<DispatchPlan>;
77
+ apply: (planId: string, accept: string[]) => Promise<DispatchPlan>;
78
+ reject: (planId: string) => Promise<DispatchPlan>;
79
+ };
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Dispatch planner (BOFF-10562)
3
+ *
4
+ * Decision cards for `mtwPlanDispatch` proposals. The planner proposes a
5
+ * vehicle + driver for each PLANNED shipment without a route; nothing is
6
+ * written until the dispatcher accepts. Accepting some cards and applying
7
+ * creates one PLANNED route per accepted card (partial accept); everything not
8
+ * accepted is rejected. Rejecting the plan writes nothing.
9
+ *
10
+ * Graceful degradation: when AI is switched off, the workspace's AI credits are
11
+ * spent or the model fails, the plan is the same and only the AI-written text
12
+ * is missing; manual route creation is always one click away.
13
+ */
14
+ export default function DispatchPlanPage(): import('react').JSX.Element;