@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.
@@ -0,0 +1,111 @@
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/useShipmentDecision.ts
5
+ var o = "\n id\n kind\n shipmentId\n shipmentNumber\n status\n method\n options {\n id\n rank\n action\n execution\n confidence\n score\n reasons\n rationale\n aiRationale\n carrierId\n newEstimatedDelivery\n followUpMutation\n followUpArgs\n deliveredCount\n onTimeCount\n laneDeliveredCount\n laneOnTimeCount\n medianLaneCost\n currency\n }\n chosenOptionId\n outcome\n decisionReason\n currentCarrierId\n promisedDelivery\n riskScore\n predictedSlipMinutes\n breached\n laneKnown\n historyCount\n aiStatus\n aiSummary\n aiModel\n expiresAt\n decidedAt\n createdAt\n", s = `
6
+ query LatestShipmentDecision($shipmentId: ID!, $kind: MtwShipmentDecisionKind!) {
7
+ mtwLatestShipmentDecision(shipmentId: $shipmentId, kind: $kind) {
8
+ ${o}
9
+ }
10
+ }
11
+ `, c = `
12
+ mutation RecommendCarrier($shipmentId: ID!) {
13
+ mtwRecommendCarrier(shipmentId: $shipmentId) {
14
+ ${o}
15
+ }
16
+ }
17
+ `, l = `
18
+ mutation ResolveException($shipmentId: ID!) {
19
+ mtwResolveException(shipmentId: $shipmentId) {
20
+ ${o}
21
+ }
22
+ }
23
+ `, u = `
24
+ mutation AcceptShipmentDecision($decisionId: ID!, $optionId: ID!) {
25
+ mtwAcceptShipmentDecision(decisionId: $decisionId, optionId: $optionId) {
26
+ ${o}
27
+ }
28
+ }
29
+ `, d = `
30
+ mutation RejectShipmentDecision($decisionId: ID!) {
31
+ mtwRejectShipmentDecision(decisionId: $decisionId) {
32
+ ${o}
33
+ }
34
+ }
35
+ `;
36
+ function f(o, f) {
37
+ let { apiGatewayUrl: p, authToken: m, workspaceToken: h, workspaceId: g, tenantId: _, currentUser: v } = e(), y = i(() => ({
38
+ apiGatewayUrl: p,
39
+ authToken: m,
40
+ workspaceToken: h,
41
+ workspaceId: g,
42
+ tenantId: _,
43
+ actorId: v?.id
44
+ }), [
45
+ p,
46
+ m,
47
+ h,
48
+ g,
49
+ _,
50
+ v?.id
51
+ ]), [b, x] = a(null), [S, C] = a(!1), [w, T] = a(null), [E, D] = a(null), O = n(async (e) => {
52
+ if (o) {
53
+ C(!0), T(null);
54
+ try {
55
+ let n = await t({
56
+ ...y,
57
+ signal: e
58
+ }, s, {
59
+ shipmentId: o,
60
+ kind: f
61
+ });
62
+ if (e?.aborted) return;
63
+ x(n.mtwLatestShipmentDecision);
64
+ } catch (t) {
65
+ if (e?.aborted) return;
66
+ T(t instanceof Error ? t : /* @__PURE__ */ Error("Failed to load the decision"));
67
+ } finally {
68
+ e?.aborted || C(!1);
69
+ }
70
+ }
71
+ }, [
72
+ y,
73
+ o,
74
+ f
75
+ ]);
76
+ r(() => {
77
+ let e = new AbortController();
78
+ return x(null), O(e.signal), () => e.abort();
79
+ }, [O]);
80
+ let k = n(async (e, t, n) => {
81
+ D(e);
82
+ try {
83
+ let e = n(await t());
84
+ return x(e), e;
85
+ } catch (e) {
86
+ throw O(), e;
87
+ } finally {
88
+ D(null);
89
+ }
90
+ }, [O]);
91
+ return {
92
+ decision: b,
93
+ isLoading: S,
94
+ error: w,
95
+ pendingAction: E,
96
+ refetch: () => void O(),
97
+ propose: n(() => o ? f === "CARRIER_RECOMMENDATION" ? k("propose", () => t(y, c, { shipmentId: o }, "SINGLE_ATTEMPT"), (e) => e.mtwRecommendCarrier) : k("propose", () => t(y, l, { shipmentId: o }, "SINGLE_ATTEMPT"), (e) => e.mtwResolveException) : Promise.reject(/* @__PURE__ */ Error("No shipment selected")), [
98
+ y,
99
+ f,
100
+ k,
101
+ o
102
+ ]),
103
+ accept: n((e, n) => k("accept", () => t(y, u, {
104
+ decisionId: e,
105
+ optionId: n
106
+ }, "SINGLE_ATTEMPT"), (e) => e.mtwAcceptShipmentDecision), [y, k]),
107
+ reject: n((e) => k("reject", () => t(y, d, { decisionId: e }, "SINGLE_ATTEMPT"), (e) => e.mtwRejectShipmentDecision), [y, k])
108
+ };
109
+ }
110
+ //#endregion
111
+ export { f as useShipmentDecision };
@@ -0,0 +1,20 @@
1
+ /**
2
+ * CarrierRecommendationDialog (BOFF-10908)
3
+ *
4
+ * Carrier recommendation cards for one PLANNED shipment, opened from the
5
+ * dispatch planner when the shipment should go with a carrier rather than the
6
+ * own fleet (no free vehicle, or the dispatcher prefers a carrier). Accepting
7
+ * a card assigns that carrier to the shipment; rejecting changes nothing.
8
+ */
9
+ type Translate = (key: string, fallback: string) => string;
10
+ interface CarrierRecommendationDialogProps {
11
+ shipment: {
12
+ id: string;
13
+ number: string | null;
14
+ } | null;
15
+ onOpenChange: (open: boolean) => void;
16
+ onApplied?: () => void;
17
+ t: Translate;
18
+ }
19
+ export declare function CarrierRecommendationDialog({ shipment, onOpenChange, onApplied, t, }: CarrierRecommendationDialogProps): import('react').JSX.Element;
20
+ export {};
@@ -2,6 +2,8 @@ import { DispatchAssignment } from '../hooks/useDispatchPlan';
2
2
  export type DispatchChoice = 'accept' | 'reject' | null;
3
3
  type Translate = (key: string, fallback: string) => string;
4
4
  export declare function reasonLabel(reason: string, t: Translate): string;
5
+ /** Text colour for a 0..1 confidence; shared by every decision card. */
6
+ export declare function confidenceTone(confidence: number): string;
5
7
  interface DispatchDecisionCardProps {
6
8
  assignment: DispatchAssignment;
7
9
  /** True while the plan can still be decided. */
@@ -10,7 +12,9 @@ interface DispatchDecisionCardProps {
10
12
  disabled: boolean;
11
13
  onChoose: (choice: DispatchChoice) => void;
12
14
  onOpenRoute: (routeId: string) => void;
15
+ /** When set, an open card also offers a carrier recommendation for its shipment. */
16
+ onRecommendCarrier?: (shipmentId: string, shipmentNumber: string | null) => void;
13
17
  t: Translate;
14
18
  }
15
- export declare function DispatchDecisionCard({ assignment, open, choice, disabled, onChoose, onOpenRoute, t, }: DispatchDecisionCardProps): import('react').JSX.Element;
19
+ export declare function DispatchDecisionCard({ assignment, open, choice, disabled, onChoose, onOpenRoute, onRecommendCarrier, t, }: DispatchDecisionCardProps): import('react').JSX.Element;
16
20
  export {};
@@ -0,0 +1,14 @@
1
+ import { ReactNode } from 'react';
2
+ import { ShipmentDecision, ShipmentDecisionKind, ShipmentDecisionOption } from '../hooks/useShipmentDecision';
3
+ type Translate = (key: string, fallback: string) => string;
4
+ interface ShipmentDecisionPanelProps {
5
+ shipmentId: string | undefined;
6
+ kind: ShipmentDecisionKind;
7
+ t: Translate;
8
+ /** Called after an accepted option changed the shipment. */
9
+ onApplied?: (decision: ShipmentDecision) => void;
10
+ /** The manual step for an accepted FOLLOW_UP option, rendered under its card. */
11
+ renderFollowUp?: (option: ShipmentDecisionOption) => ReactNode;
12
+ }
13
+ export declare function ShipmentDecisionPanel({ shipmentId, kind, t, onApplied, renderFollowUp, }: ShipmentDecisionPanelProps): import('react').JSX.Element;
14
+ export {};
@@ -71,7 +71,7 @@ export declare function useDispatchPlan(): {
71
71
  plan: DispatchPlan | null;
72
72
  isLoading: boolean;
73
73
  error: Error | null;
74
- pendingAction: "reject" | "propose" | "apply" | null;
74
+ pendingAction: "propose" | "apply" | "reject" | null;
75
75
  refetch: () => undefined;
76
76
  propose: (options?: PlanDispatchOptions) => Promise<DispatchPlan>;
77
77
  apply: (planId: string, accept: string[]) => Promise<DispatchPlan>;
@@ -0,0 +1,67 @@
1
+ import { DecisionRationaleStatus } from './useDispatchPlan';
2
+ export type ShipmentDecisionKind = 'CARRIER_RECOMMENDATION' | 'EXCEPTION_REMEDIATION';
3
+ export type ShipmentDecisionStatus = 'PROPOSED' | 'ACCEPTED' | 'REJECTED' | 'STALE' | 'EXPIRED';
4
+ export type ShipmentDecisionAction = 'USE_CARRIER' | 'REASSIGN_VEHICLE' | 'REPROMISE_DELIVERY' | 'REQUEST_TRACKING_UPDATE' | 'SWITCH_CARRIER' | 'ACCEPT_SLIP';
5
+ export type ShipmentDecisionExecution = 'APPLY' | 'FOLLOW_UP' | 'RECORD';
6
+ export type ShipmentDecisionOutcome = 'APPLIED' | 'RECORDED' | 'FOLLOW_UP';
7
+ export interface ShipmentDecisionOption {
8
+ id: string;
9
+ rank: number;
10
+ action: ShipmentDecisionAction;
11
+ execution: ShipmentDecisionExecution;
12
+ confidence: number;
13
+ score: number | null;
14
+ reasons: string[];
15
+ rationale: string;
16
+ aiRationale: string | null;
17
+ carrierId: string | null;
18
+ newEstimatedDelivery: string | null;
19
+ followUpMutation: string | null;
20
+ followUpArgs: Record<string, string> | null;
21
+ deliveredCount: number | null;
22
+ onTimeCount: number | null;
23
+ laneDeliveredCount: number | null;
24
+ laneOnTimeCount: number | null;
25
+ medianLaneCost: number | null;
26
+ currency: string | null;
27
+ }
28
+ export interface ShipmentDecision {
29
+ id: string;
30
+ kind: ShipmentDecisionKind;
31
+ shipmentId: string;
32
+ shipmentNumber: string | null;
33
+ status: ShipmentDecisionStatus;
34
+ method: string;
35
+ options: ShipmentDecisionOption[];
36
+ chosenOptionId: string | null;
37
+ outcome: ShipmentDecisionOutcome | null;
38
+ decisionReason: string | null;
39
+ currentCarrierId: string | null;
40
+ promisedDelivery: string | null;
41
+ riskScore: number | null;
42
+ predictedSlipMinutes: number | null;
43
+ breached: boolean | null;
44
+ laneKnown: boolean | null;
45
+ historyCount: number | null;
46
+ aiStatus: DecisionRationaleStatus;
47
+ aiSummary: string | null;
48
+ aiModel: string | null;
49
+ expiresAt: string;
50
+ decidedAt: string | null;
51
+ createdAt: string;
52
+ }
53
+ type PendingAction = 'propose' | 'accept' | 'reject';
54
+ /**
55
+ * @param shipmentId the shipment, or undefined while nothing is selected (no request is made)
56
+ */
57
+ export declare function useShipmentDecision(shipmentId: string | undefined, kind: ShipmentDecisionKind): {
58
+ decision: ShipmentDecision | null;
59
+ isLoading: boolean;
60
+ error: Error | null;
61
+ pendingAction: PendingAction | null;
62
+ refetch: () => undefined;
63
+ propose: () => Promise<ShipmentDecision>;
64
+ accept: (decisionId: string, optionId: string) => Promise<ShipmentDecision>;
65
+ reject: (decisionId: string) => Promise<ShipmentDecision>;
66
+ };
67
+ export {};