@burdenoff/microfe-movethewheels 2026.1108.1 → 2026.1108.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.
- package/dist/components/DocumentsCard.js +183 -55
- package/dist/components/ForecastModelsPanel.js +132 -0
- package/dist/components/UpcomingDemandPanel.js +70 -65
- package/dist/generated/wspace-operations.d.ts +25 -0
- package/dist/generated/wspace-types.d.ts +3301 -144
- package/dist/hooks/useDemandForecast.js +1 -1
- package/dist/hooks/useDocumentExtractions.js +100 -0
- package/dist/hooks/useForecastModelChoices.js +57 -0
- package/dist/movethewheels/components/ForecastModelsPanel.d.ts +4 -0
- package/dist/movethewheels/hooks/useDemandForecast.d.ts +9 -0
- package/dist/movethewheels/hooks/useDocumentExtractions.d.ts +49 -0
- package/dist/movethewheels/hooks/useEntityDocuments.d.ts +5 -5
- package/dist/movethewheels/hooks/useForecastModelChoices.d.ts +34 -0
- package/dist/node_modules/lucide-react/dist/esm/icons/file-search.js +24 -0
- package/dist/node_modules/lucide-react/dist/esm/icons/sigma.js +8 -0
- package/dist/pages/AnalyticsPage.js +83 -81
- package/dist/pages/MultiModalShipmentPage.js +125 -121
- package/dist/pages/RouteDetailsPage.js +212 -207
- package/package.json +1 -1
- package/src/generated/wspace-operations.ts +13 -4
- package/src/generated/wspace-types.ts +3623 -144
- package/src/movethewheels/components/DocumentsCard.tsx +174 -29
- package/src/movethewheels/components/ForecastModelsPanel.tsx +188 -0
- package/src/movethewheels/components/UpcomingDemandPanel.tsx +9 -2
- package/src/movethewheels/hooks/useDemandForecast.ts +13 -0
- package/src/movethewheels/hooks/useDocumentExtractions.ts +246 -0
- package/src/movethewheels/hooks/useEntityDocuments.ts +5 -5
- package/src/movethewheels/hooks/useForecastModelChoices.ts +138 -0
- package/src/movethewheels/pages/AnalyticsPage.tsx +7 -2
- package/src/movethewheels/pages/MultiModalShipmentPage.tsx +2 -0
- package/src/movethewheels/pages/RouteDetailsPage.tsx +2 -0
- package/src/operations/wspace/movethewheels/queries/forecast.graphql +22 -1
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
1
|
+
import { Check as e } from "../node_modules/lucide-react/dist/esm/icons/check.js";
|
|
2
|
+
import { Download as t } from "../node_modules/lucide-react/dist/esm/icons/download.js";
|
|
3
|
+
import { ExternalLink as n } from "../node_modules/lucide-react/dist/esm/icons/external-link.js";
|
|
4
|
+
import { FileSearch as r } from "../node_modules/lucide-react/dist/esm/icons/file-search.js";
|
|
5
|
+
import { FileText as i } from "../node_modules/lucide-react/dist/esm/icons/file-text.js";
|
|
6
|
+
import { Upload as a } from "../node_modules/lucide-react/dist/esm/icons/upload.js";
|
|
7
|
+
import { useMoveTheWheels as o } from "../providers/MoveTheWheelsProvider.js";
|
|
8
|
+
import { formatDate as s } from "../utils/formatters.js";
|
|
9
|
+
import { useEntityDocuments as c } from "../hooks/useEntityDocuments.js";
|
|
10
|
+
import { Badge as l, Button as u, Card as d, CardContent as f, CardHeader as p, CardTitle as m, Input as h, Select as g, SelectContent as _, SelectItem as v, SelectTrigger as y, SelectValue as b } from "./ui.js";
|
|
11
|
+
import { DOCUMENT_TYPE_OPTIONS as x, useDocumentExtractions as S } from "../hooks/useDocumentExtractions.js";
|
|
12
|
+
import { useState as C } from "react";
|
|
13
|
+
import { jsx as w, jsxs as T } from "react/jsx-runtime";
|
|
10
14
|
//#region src/movethewheels/components/DocumentsCard.tsx
|
|
11
|
-
function
|
|
15
|
+
function E(e) {
|
|
12
16
|
if (!Number.isFinite(e) || e <= 0) return "—";
|
|
13
17
|
let t = [
|
|
14
18
|
"B",
|
|
@@ -19,72 +23,196 @@ function m(e) {
|
|
|
19
23
|
for (; n >= 1024 && r < t.length - 1;) n /= 1024, r += 1;
|
|
20
24
|
return `${n.toFixed(n >= 10 || r === 0 ? 0 : 1)} ${t[r]}`;
|
|
21
25
|
}
|
|
22
|
-
function
|
|
23
|
-
|
|
24
|
-
|
|
26
|
+
function D(e) {
|
|
27
|
+
return e === "APPLIED" ? "Applied" : e === "PARTIALLY_APPLIED" ? "Partially applied" : "Proposed";
|
|
28
|
+
}
|
|
29
|
+
function O({ fileId: t }) {
|
|
30
|
+
let { extractions: n, isLoading: i, error: a, extracting: o, extractError: c, extract: d, apply: f } = S(t), [p, m] = C("BILL_OF_LADING"), [E, O] = C({}), [k, A] = C(null), j = n[0] ?? null, M = async (e, t) => {
|
|
31
|
+
A(null);
|
|
32
|
+
let n = E[t]?.trim(), r = n ? [{
|
|
33
|
+
key: t,
|
|
34
|
+
value: n
|
|
35
|
+
}] : null;
|
|
36
|
+
await f(e.id, [t], r) || A(`Accepting "${t}" failed — refresh and try again`);
|
|
37
|
+
};
|
|
38
|
+
return /* @__PURE__ */ T("div", {
|
|
39
|
+
className: "mt-2 space-y-2 border-t border-border-seam pt-2",
|
|
40
|
+
children: [
|
|
41
|
+
/* @__PURE__ */ T("div", {
|
|
42
|
+
className: "flex items-center gap-2",
|
|
43
|
+
children: [/* @__PURE__ */ T(g, {
|
|
44
|
+
value: p,
|
|
45
|
+
onValueChange: (e) => m(e),
|
|
46
|
+
children: [/* @__PURE__ */ w(y, {
|
|
47
|
+
className: "w-40",
|
|
48
|
+
"aria-label": "Document type",
|
|
49
|
+
children: /* @__PURE__ */ w(b, {})
|
|
50
|
+
}), /* @__PURE__ */ w(_, { children: x.map((e) => /* @__PURE__ */ w(v, {
|
|
51
|
+
value: e.value,
|
|
52
|
+
children: e.label
|
|
53
|
+
}, e.value)) })]
|
|
54
|
+
}), /* @__PURE__ */ T(u, {
|
|
55
|
+
variant: "outline",
|
|
56
|
+
size: "sm",
|
|
57
|
+
disabled: o,
|
|
58
|
+
onClick: () => void d(t, p),
|
|
59
|
+
children: [
|
|
60
|
+
/* @__PURE__ */ w(r, { size: 14 }),
|
|
61
|
+
" ",
|
|
62
|
+
o ? "Reading…" : "Extract fields"
|
|
63
|
+
]
|
|
64
|
+
})]
|
|
65
|
+
}),
|
|
66
|
+
(c ?? k) && /* @__PURE__ */ w("p", {
|
|
67
|
+
className: "text-sm text-text-danger",
|
|
68
|
+
children: c ?? k
|
|
69
|
+
}),
|
|
70
|
+
i ? /* @__PURE__ */ w("p", {
|
|
71
|
+
className: "text-sm text-text-secondary",
|
|
72
|
+
children: "Loading extraction…"
|
|
73
|
+
}) : j ? /* @__PURE__ */ T("div", {
|
|
74
|
+
className: "space-y-2",
|
|
75
|
+
children: [
|
|
76
|
+
/* @__PURE__ */ T("div", {
|
|
77
|
+
className: "flex items-center gap-2 text-sm",
|
|
78
|
+
children: [/* @__PURE__ */ w(l, {
|
|
79
|
+
variant: j.status === "APPLIED" ? "default" : "secondary",
|
|
80
|
+
children: D(j.status)
|
|
81
|
+
}), /* @__PURE__ */ T("span", {
|
|
82
|
+
className: "text-text-secondary",
|
|
83
|
+
children: [
|
|
84
|
+
x.find((e) => e.value === j.docType)?.label,
|
|
85
|
+
" ·",
|
|
86
|
+
" ",
|
|
87
|
+
s(j.createdAt, "relative"),
|
|
88
|
+
" · ",
|
|
89
|
+
j.model,
|
|
90
|
+
j.costMicroUsd ? ` · ${(Number(j.costMicroUsd) / 1e6).toFixed(4)} USD` : ""
|
|
91
|
+
]
|
|
92
|
+
})]
|
|
93
|
+
}),
|
|
94
|
+
a && /* @__PURE__ */ w("p", {
|
|
95
|
+
className: "text-sm text-text-danger",
|
|
96
|
+
children: a
|
|
97
|
+
}),
|
|
98
|
+
/* @__PURE__ */ w("ul", {
|
|
99
|
+
className: "space-y-1",
|
|
100
|
+
children: j.fields.map((t) => {
|
|
101
|
+
let n = j.acceptedFields.includes(t.key), r = E[t.key];
|
|
102
|
+
return /* @__PURE__ */ T("li", {
|
|
103
|
+
className: "flex items-center gap-2 text-sm",
|
|
104
|
+
children: [
|
|
105
|
+
/* @__PURE__ */ w("span", {
|
|
106
|
+
className: "w-40 shrink-0 truncate text-text-secondary",
|
|
107
|
+
title: t.label,
|
|
108
|
+
children: t.label
|
|
109
|
+
}),
|
|
110
|
+
/* @__PURE__ */ w(h, {
|
|
111
|
+
className: "h-7 flex-1",
|
|
112
|
+
defaultValue: r ?? t.value ?? "",
|
|
113
|
+
placeholder: "Not shown on document",
|
|
114
|
+
disabled: n,
|
|
115
|
+
onChange: (e) => O((n) => ({
|
|
116
|
+
...n,
|
|
117
|
+
[t.key]: e.target.value
|
|
118
|
+
}))
|
|
119
|
+
}),
|
|
120
|
+
/* @__PURE__ */ T("span", {
|
|
121
|
+
className: "w-12 shrink-0 text-right text-text-secondary",
|
|
122
|
+
children: [Math.round(t.confidence * 100), "%"]
|
|
123
|
+
}),
|
|
124
|
+
n ? /* @__PURE__ */ T(l, {
|
|
125
|
+
variant: "outline",
|
|
126
|
+
className: "flex items-center gap-1",
|
|
127
|
+
children: [/* @__PURE__ */ w(e, { size: 12 }), " Accepted"]
|
|
128
|
+
}) : /* @__PURE__ */ T(u, {
|
|
129
|
+
variant: "ghost",
|
|
130
|
+
size: "sm",
|
|
131
|
+
onClick: () => void M(j, t.key),
|
|
132
|
+
children: [/* @__PURE__ */ w(e, { size: 14 }), " Accept"]
|
|
133
|
+
})
|
|
134
|
+
]
|
|
135
|
+
}, t.key);
|
|
136
|
+
})
|
|
137
|
+
}, j.id),
|
|
138
|
+
/* @__PURE__ */ w("p", {
|
|
139
|
+
className: "text-xs text-text-secondary",
|
|
140
|
+
children: "Accepting writes only what that field maps to — a delivery time closes the shipment, invoice lines reconcile on Finance. Editing a value first corrects it on acceptance."
|
|
141
|
+
})
|
|
142
|
+
]
|
|
143
|
+
}) : null
|
|
144
|
+
]
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
function k({ entityType: e, entityId: r }) {
|
|
148
|
+
let { navigate: l } = o(), { documents: h, hasMore: g, isLoading: _, loadMore: v } = c(e, r), y = () => l("/files/browse");
|
|
149
|
+
return /* @__PURE__ */ T(d, { children: [/* @__PURE__ */ T(p, {
|
|
25
150
|
className: "flex flex-row items-center justify-between",
|
|
26
|
-
children: [/* @__PURE__ */
|
|
151
|
+
children: [/* @__PURE__ */ T(m, {
|
|
27
152
|
className: "flex items-center gap-2",
|
|
28
|
-
children: [/* @__PURE__ */
|
|
29
|
-
}), /* @__PURE__ */
|
|
153
|
+
children: [/* @__PURE__ */ w(i, { size: 18 }), " Documents"]
|
|
154
|
+
}), /* @__PURE__ */ T(u, {
|
|
30
155
|
variant: "outline",
|
|
31
156
|
size: "sm",
|
|
32
|
-
onClick:
|
|
33
|
-
children: [/* @__PURE__ */
|
|
157
|
+
onClick: y,
|
|
158
|
+
children: [/* @__PURE__ */ w(a, { size: 14 }), " Add / Manage"]
|
|
34
159
|
})]
|
|
35
|
-
}), /* @__PURE__ */ f
|
|
160
|
+
}), /* @__PURE__ */ w(f, { children: _ ? /* @__PURE__ */ w("p", {
|
|
36
161
|
className: "text-text-secondary text-center py-4",
|
|
37
162
|
children: "Loading documents…"
|
|
38
|
-
}) :
|
|
163
|
+
}) : h.length > 0 ? /* @__PURE__ */ T("div", {
|
|
39
164
|
className: "space-y-3",
|
|
40
|
-
children: [
|
|
41
|
-
className: "
|
|
42
|
-
children: [/* @__PURE__ */
|
|
43
|
-
className: "
|
|
44
|
-
children: [/* @__PURE__ */
|
|
45
|
-
className: "
|
|
46
|
-
children:
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
165
|
+
children: [h.map((e) => /* @__PURE__ */ T("div", {
|
|
166
|
+
className: "p-3 border rounded-lg",
|
|
167
|
+
children: [/* @__PURE__ */ T("div", {
|
|
168
|
+
className: "flex items-center justify-between gap-3",
|
|
169
|
+
children: [/* @__PURE__ */ T("div", {
|
|
170
|
+
className: "min-w-0",
|
|
171
|
+
children: [/* @__PURE__ */ w("p", {
|
|
172
|
+
className: "font-medium truncate",
|
|
173
|
+
children: e.name
|
|
174
|
+
}), /* @__PURE__ */ T("p", {
|
|
175
|
+
className: "text-sm text-text-secondary",
|
|
176
|
+
children: [
|
|
177
|
+
E(e.size),
|
|
178
|
+
" · ",
|
|
179
|
+
s(e.createdAt, "relative")
|
|
180
|
+
]
|
|
181
|
+
})]
|
|
182
|
+
}), e.downloadUrl ? /* @__PURE__ */ T("a", {
|
|
183
|
+
href: e.downloadUrl,
|
|
184
|
+
target: "_blank",
|
|
185
|
+
rel: "noopener noreferrer",
|
|
186
|
+
className: "shrink-0 inline-flex items-center gap-1 text-sm text-primary hover:underline",
|
|
187
|
+
children: [/* @__PURE__ */ w(t, { size: 14 }), " Open"]
|
|
188
|
+
}) : /* @__PURE__ */ T(u, {
|
|
189
|
+
variant: "ghost",
|
|
190
|
+
size: "sm",
|
|
191
|
+
onClick: y,
|
|
192
|
+
children: [/* @__PURE__ */ w(n, { size: 14 }), " View"]
|
|
54
193
|
})]
|
|
55
|
-
}),
|
|
56
|
-
|
|
57
|
-
target: "_blank",
|
|
58
|
-
rel: "noopener noreferrer",
|
|
59
|
-
className: "shrink-0 inline-flex items-center gap-1 text-sm text-primary hover:underline",
|
|
60
|
-
children: [/* @__PURE__ */ f(e, { size: 14 }), " Open"]
|
|
61
|
-
}) : /* @__PURE__ */ p(s, {
|
|
62
|
-
variant: "ghost",
|
|
63
|
-
size: "sm",
|
|
64
|
-
onClick: S,
|
|
65
|
-
children: [/* @__PURE__ */ f(t, { size: 14 }), " View"]
|
|
66
|
-
})]
|
|
67
|
-
}, n.id)), y && /* @__PURE__ */ f(s, {
|
|
194
|
+
}), /* @__PURE__ */ w(O, { fileId: e.id })]
|
|
195
|
+
}, e.id)), g && /* @__PURE__ */ w(u, {
|
|
68
196
|
variant: "outline",
|
|
69
197
|
size: "sm",
|
|
70
|
-
onClick:
|
|
71
|
-
disabled:
|
|
198
|
+
onClick: v,
|
|
199
|
+
disabled: _,
|
|
72
200
|
children: "Load more documents"
|
|
73
201
|
})]
|
|
74
|
-
}) : /* @__PURE__ */
|
|
202
|
+
}) : /* @__PURE__ */ T("div", {
|
|
75
203
|
className: "text-center py-6",
|
|
76
204
|
children: [
|
|
77
|
-
/* @__PURE__ */
|
|
205
|
+
/* @__PURE__ */ w(i, {
|
|
78
206
|
size: 32,
|
|
79
207
|
className: "mx-auto mb-2 text-text-secondary opacity-50"
|
|
80
208
|
}),
|
|
81
|
-
/* @__PURE__ */
|
|
209
|
+
/* @__PURE__ */ w("p", {
|
|
82
210
|
className: "text-text-secondary",
|
|
83
211
|
children: "No documents yet"
|
|
84
212
|
}),
|
|
85
|
-
/* @__PURE__ */
|
|
213
|
+
/* @__PURE__ */ w("button", {
|
|
86
214
|
type: "button",
|
|
87
|
-
onClick:
|
|
215
|
+
onClick: y,
|
|
88
216
|
className: "mt-1 text-sm text-primary hover:underline",
|
|
89
217
|
children: "Add them in Files"
|
|
90
218
|
})
|
|
@@ -92,4 +220,4 @@ function h({ entityType: h, entityId: g }) {
|
|
|
92
220
|
}) })] });
|
|
93
221
|
}
|
|
94
222
|
//#endregion
|
|
95
|
-
export {
|
|
223
|
+
export { k as DocumentsCard };
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { Sigma as e } from "../node_modules/lucide-react/dist/esm/icons/sigma.js";
|
|
2
|
+
import { Badge as t, Card as n, CardContent as r, CardDescription as i, CardHeader as a, CardTitle as o, Skeleton as s, Table as c, TableBody as l, TableCell as u, TableHead as d, TableHeader as f, TableRow as p, Tabs as m, TabsContent as h, TabsList as g, TabsTrigger as _ } from "./ui.js";
|
|
3
|
+
import { useForecastModelChoices as v } from "../hooks/useForecastModelChoices.js";
|
|
4
|
+
import { useState as y } from "react";
|
|
5
|
+
import { jsx as b, jsxs as x } from "react/jsx-runtime";
|
|
6
|
+
//#region src/movethewheels/components/ForecastModelsPanel.tsx
|
|
7
|
+
var S = (e, t) => {
|
|
8
|
+
switch (e) {
|
|
9
|
+
case "HOLT_LINEAR": return "Holt (trend)";
|
|
10
|
+
case "HOLT_WINTERS": return t ? `Holt-Winters (${t}-week cycle)` : "Holt-Winters (seasonal)";
|
|
11
|
+
case "HEURISTIC_MOVING_AVG":
|
|
12
|
+
case "HEURISTIC_GROWTH_RATE": return "Moving average";
|
|
13
|
+
default: return String(e);
|
|
14
|
+
}
|
|
15
|
+
}, C = (e) => e === null ? "—" : `${Math.round(e * 1e3) / 10}%`, w = (e, t) => e.candidates.find((e) => e.model === t);
|
|
16
|
+
function T() {
|
|
17
|
+
let { laneChoices: t, customerChoices: c, isLoading: l, error: u, refetch: d } = v(5), [f, p] = y("LANE");
|
|
18
|
+
return /* @__PURE__ */ x(n, {
|
|
19
|
+
"data-testid": "forecast-models-panel",
|
|
20
|
+
children: [/* @__PURE__ */ x(a, { children: [/* @__PURE__ */ x(o, {
|
|
21
|
+
className: "flex items-center gap-2",
|
|
22
|
+
children: [/* @__PURE__ */ b(e, {
|
|
23
|
+
size: 18,
|
|
24
|
+
"aria-hidden": "true"
|
|
25
|
+
}), "Forecast models"]
|
|
26
|
+
}), /* @__PURE__ */ b(i, { children: "Lanes and customers with 26 closed weeks of history are back-tested on their last 8 closed weeks. The model with the lowest error (MAPE) produces the forecast: the moving-average heuristic, Holt (trend) or Holt-Winters (seasonal). Shorter histories use the moving average." })] }), /* @__PURE__ */ b(r, { children: u && !l ? /* @__PURE__ */ x("div", {
|
|
27
|
+
className: "space-y-2 text-sm",
|
|
28
|
+
children: [
|
|
29
|
+
/* @__PURE__ */ b("p", {
|
|
30
|
+
className: "text-status-error-text font-medium",
|
|
31
|
+
children: "Couldn't load forecast models"
|
|
32
|
+
}),
|
|
33
|
+
/* @__PURE__ */ b("p", {
|
|
34
|
+
className: "text-text-secondary",
|
|
35
|
+
children: u.message
|
|
36
|
+
}),
|
|
37
|
+
/* @__PURE__ */ b("button", {
|
|
38
|
+
type: "button",
|
|
39
|
+
onClick: d,
|
|
40
|
+
className: "font-medium text-primary hover:underline",
|
|
41
|
+
children: "Retry"
|
|
42
|
+
})
|
|
43
|
+
]
|
|
44
|
+
}) : l ? /* @__PURE__ */ x("div", {
|
|
45
|
+
className: "space-y-3",
|
|
46
|
+
children: [/* @__PURE__ */ b(s, { className: "h-10 w-full" }), /* @__PURE__ */ b(s, { className: "h-10 w-full" })]
|
|
47
|
+
}) : /* @__PURE__ */ x(m, {
|
|
48
|
+
value: f,
|
|
49
|
+
onValueChange: (e) => p(e),
|
|
50
|
+
children: [
|
|
51
|
+
/* @__PURE__ */ x(g, { children: [/* @__PURE__ */ b(_, {
|
|
52
|
+
value: "LANE",
|
|
53
|
+
children: "Lanes"
|
|
54
|
+
}), /* @__PURE__ */ b(_, {
|
|
55
|
+
value: "CUSTOMER",
|
|
56
|
+
children: "Customers"
|
|
57
|
+
})] }),
|
|
58
|
+
/* @__PURE__ */ b(h, {
|
|
59
|
+
value: "LANE",
|
|
60
|
+
children: /* @__PURE__ */ b(E, {
|
|
61
|
+
choices: t,
|
|
62
|
+
nameHeader: "Lane"
|
|
63
|
+
})
|
|
64
|
+
}),
|
|
65
|
+
/* @__PURE__ */ b(h, {
|
|
66
|
+
value: "CUSTOMER",
|
|
67
|
+
children: /* @__PURE__ */ b(E, {
|
|
68
|
+
choices: c,
|
|
69
|
+
nameHeader: "Customer"
|
|
70
|
+
})
|
|
71
|
+
})
|
|
72
|
+
]
|
|
73
|
+
}) })]
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
function E({ choices: e, nameHeader: n }) {
|
|
77
|
+
return e.length === 0 ? /* @__PURE__ */ b("p", {
|
|
78
|
+
className: "py-4 text-sm text-text-secondary",
|
|
79
|
+
children: "No forecasts yet. Model choices appear after the first forecast recalculation."
|
|
80
|
+
}) : /* @__PURE__ */ b("div", {
|
|
81
|
+
className: "overflow-x-auto",
|
|
82
|
+
children: /* @__PURE__ */ x(c, { children: [/* @__PURE__ */ b(f, { children: /* @__PURE__ */ x(p, { children: [
|
|
83
|
+
/* @__PURE__ */ b(d, { children: n }),
|
|
84
|
+
/* @__PURE__ */ b(d, {
|
|
85
|
+
className: "text-right",
|
|
86
|
+
children: "History"
|
|
87
|
+
}),
|
|
88
|
+
/* @__PURE__ */ b(d, { children: "Model" }),
|
|
89
|
+
/* @__PURE__ */ b(d, {
|
|
90
|
+
className: "text-right",
|
|
91
|
+
children: "Model error"
|
|
92
|
+
}),
|
|
93
|
+
/* @__PURE__ */ b(d, {
|
|
94
|
+
className: "text-right",
|
|
95
|
+
children: "Moving-average error"
|
|
96
|
+
})
|
|
97
|
+
] }) }), /* @__PURE__ */ b(l, { children: e.map((e) => {
|
|
98
|
+
let n = e.candidates.find((e) => e.selected), r = w(e, "HEURISTIC_MOVING_AVG");
|
|
99
|
+
return /* @__PURE__ */ x(p, { children: [
|
|
100
|
+
/* @__PURE__ */ x(u, {
|
|
101
|
+
className: "max-w-[16rem]",
|
|
102
|
+
children: [/* @__PURE__ */ b("p", {
|
|
103
|
+
className: "truncate font-medium",
|
|
104
|
+
title: e.scopeLabel,
|
|
105
|
+
children: e.scopeLabel
|
|
106
|
+
}), /* @__PURE__ */ b("p", {
|
|
107
|
+
className: "text-xs text-text-secondary whitespace-normal",
|
|
108
|
+
children: e.reason
|
|
109
|
+
})]
|
|
110
|
+
}),
|
|
111
|
+
/* @__PURE__ */ x(u, {
|
|
112
|
+
className: "text-right whitespace-nowrap",
|
|
113
|
+
children: [e.historyWeeks, " wk"]
|
|
114
|
+
}),
|
|
115
|
+
/* @__PURE__ */ b(u, { children: /* @__PURE__ */ b(t, {
|
|
116
|
+
variant: e.selectedModel === "HEURISTIC_MOVING_AVG" ? "outline" : "default",
|
|
117
|
+
children: S(e.selectedModel, n?.seasonLengthWeeks)
|
|
118
|
+
}) }),
|
|
119
|
+
/* @__PURE__ */ b(u, {
|
|
120
|
+
className: "text-right",
|
|
121
|
+
children: C(n?.mape ?? null)
|
|
122
|
+
}),
|
|
123
|
+
/* @__PURE__ */ b(u, {
|
|
124
|
+
className: "text-right",
|
|
125
|
+
children: C(r?.mape ?? null)
|
|
126
|
+
})
|
|
127
|
+
] }, `${e.scopeType}-${e.scopeKey}`);
|
|
128
|
+
}) })] })
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
//#endregion
|
|
132
|
+
export { T as ForecastModelsPanel, S as forecastModelLabel };
|
|
@@ -4,136 +4,141 @@ import { TrendingDown as n } from "../node_modules/lucide-react/dist/esm/icons/t
|
|
|
4
4
|
import { TrendingUp as r } from "../node_modules/lucide-react/dist/esm/icons/trending-up.js";
|
|
5
5
|
import { formatCurrency as i } from "../utils/formatters.js";
|
|
6
6
|
import { Card as a, CardContent as o, CardHeader as s, CardTitle as c, Skeleton as l } from "./ui.js";
|
|
7
|
-
import {
|
|
7
|
+
import { forecastModelLabel as u } from "./ForecastModelsPanel.js";
|
|
8
|
+
import { jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
8
9
|
//#region src/movethewheels/components/UpcomingDemandPanel.tsx
|
|
9
|
-
var
|
|
10
|
+
var p = (e) => {
|
|
10
11
|
let t = new Date(e);
|
|
11
12
|
return Number.isNaN(t.getTime()) ? e : t.toLocaleDateString(void 0, {
|
|
12
13
|
month: "short",
|
|
13
14
|
day: "numeric"
|
|
14
15
|
});
|
|
15
|
-
},
|
|
16
|
+
}, m = (e, t) => e.filter((e) => e.periodStart === t && e.confidence > 0), h = (e, t) => [...m(e, t)].sort((e, t) => t.predictedVolume - e.predictedVolume || t.predictedRevenue - e.predictedRevenue).slice(0, 3), g = (e, t) => [...m(e, t)].sort((e, t) => t.predictedRevenue - e.predictedRevenue).slice(0, 3), _ = (e, t) => m(e, t).reduce((e, t) => e + t.predictedVolume, 0), v = (e, t = /* @__PURE__ */ new Date()) => {
|
|
16
17
|
let n = [...new Set(e.map((e) => e.periodStart))].sort((e, t) => new Date(e).getTime() - new Date(t).getTime());
|
|
17
18
|
return n.find((e) => new Date(e).getTime() > t.getTime()) ?? n.at(-1) ?? null;
|
|
18
|
-
},
|
|
19
|
-
function
|
|
20
|
-
if (
|
|
19
|
+
}, y = (e, t) => e === 0 && t > 0 ? "<1 job" : e === 1 ? "1 job" : `${e} jobs`, b = (e) => e <= 0 ? "Not enough history" : `${Math.round(e * 100)}% confidence`;
|
|
20
|
+
function x({ laneForecast: n, customerForecast: r, laneVariance: i, customerVariance: y, isLoading: x, error: w, onRetry: T }) {
|
|
21
|
+
if (w && !x) return /* @__PURE__ */ d(a, {
|
|
21
22
|
className: "border-status-error-border",
|
|
22
|
-
children: /* @__PURE__ */
|
|
23
|
+
children: /* @__PURE__ */ f(o, {
|
|
23
24
|
className: "p-6 text-center space-y-3",
|
|
24
25
|
children: [
|
|
25
|
-
/* @__PURE__ */
|
|
26
|
+
/* @__PURE__ */ d("p", {
|
|
26
27
|
className: "text-status-error-text font-medium",
|
|
27
28
|
children: "Couldn't load demand forecast"
|
|
28
29
|
}),
|
|
29
|
-
/* @__PURE__ */
|
|
30
|
+
/* @__PURE__ */ d("p", {
|
|
30
31
|
className: "text-sm text-text-secondary",
|
|
31
|
-
children:
|
|
32
|
+
children: w.message
|
|
32
33
|
}),
|
|
33
|
-
/* @__PURE__ */
|
|
34
|
+
/* @__PURE__ */ d("button", {
|
|
34
35
|
type: "button",
|
|
35
|
-
onClick:
|
|
36
|
+
onClick: T,
|
|
36
37
|
className: "text-sm font-medium text-primary hover:underline",
|
|
37
38
|
children: "Retry"
|
|
38
39
|
})
|
|
39
40
|
]
|
|
40
41
|
})
|
|
41
42
|
});
|
|
42
|
-
if (
|
|
43
|
+
if (x) return /* @__PURE__ */ f(a, { children: [/* @__PURE__ */ d(s, { children: /* @__PURE__ */ d(c, { children: "Upcoming demand" }) }), /* @__PURE__ */ f(o, {
|
|
43
44
|
className: "space-y-4",
|
|
44
45
|
children: [
|
|
45
|
-
/* @__PURE__ */
|
|
46
|
-
/* @__PURE__ */
|
|
47
|
-
/* @__PURE__ */
|
|
46
|
+
/* @__PURE__ */ d(l, { className: "h-16 w-full" }),
|
|
47
|
+
/* @__PURE__ */ d(l, { className: "h-16 w-full" }),
|
|
48
|
+
/* @__PURE__ */ d(l, { className: "h-16 w-full" })
|
|
48
49
|
]
|
|
49
50
|
})] });
|
|
50
|
-
let
|
|
51
|
-
if (!
|
|
51
|
+
let E = v([...n, ...r]), D = E !== null && (m(n, E).length > 0 || m(r, E).length > 0);
|
|
52
|
+
if (!E || !D) return /* @__PURE__ */ f(a, { children: [/* @__PURE__ */ d(s, { children: /* @__PURE__ */ f(c, {
|
|
52
53
|
className: "flex items-center gap-2",
|
|
53
|
-
children: [/* @__PURE__ */
|
|
54
|
+
children: [/* @__PURE__ */ d(e, {
|
|
54
55
|
size: 18,
|
|
55
56
|
"aria-hidden": "true"
|
|
56
57
|
}), "Upcoming demand"]
|
|
57
|
-
}) }), /* @__PURE__ */
|
|
58
|
+
}) }), /* @__PURE__ */ d(o, { children: /* @__PURE__ */ f("div", {
|
|
58
59
|
className: "flex items-start gap-2 rounded-lg border border-border/60 bg-muted/40 p-4 text-sm text-text-secondary",
|
|
59
|
-
children: [/* @__PURE__ */
|
|
60
|
+
children: [/* @__PURE__ */ d(t, {
|
|
60
61
|
size: 16,
|
|
61
62
|
"aria-hidden": "true",
|
|
62
63
|
className: "mt-0.5 shrink-0"
|
|
63
|
-
}), /* @__PURE__ */
|
|
64
|
+
}), /* @__PURE__ */ d("p", { children: "Not enough history to forecast next week yet. Once a lane or customer has at least 4 weeks of delivery jobs, this panel will surface its demand." })]
|
|
64
65
|
}) })] });
|
|
65
|
-
let
|
|
66
|
-
return /* @__PURE__ */
|
|
66
|
+
let O = h(n, E), k = g(n, E), A = h(r, E), j = m(n, E).length > 0, M = _(j ? n : r, E), N = j ? "Predicted jobs (all lanes)" : "Predicted jobs (all customers)", P = j ? O[0] : A[0], F = [...i, ...y].sort((e, t) => Math.abs(t.volumeVariance) - Math.abs(e.volumeVariance)).slice(0, 3);
|
|
67
|
+
return /* @__PURE__ */ f(a, { children: [/* @__PURE__ */ d(s, { children: /* @__PURE__ */ f(c, {
|
|
67
68
|
className: "flex items-center gap-2",
|
|
68
69
|
children: [
|
|
69
|
-
/* @__PURE__ */
|
|
70
|
+
/* @__PURE__ */ d(e, {
|
|
70
71
|
size: 18,
|
|
71
72
|
"aria-hidden": "true"
|
|
72
73
|
}),
|
|
73
74
|
"Upcoming demand — week of ",
|
|
74
|
-
|
|
75
|
+
p(E)
|
|
75
76
|
]
|
|
76
|
-
}) }), /* @__PURE__ */
|
|
77
|
+
}) }), /* @__PURE__ */ f(o, {
|
|
77
78
|
className: "space-y-4",
|
|
78
|
-
children: [/* @__PURE__ */
|
|
79
|
+
children: [/* @__PURE__ */ f("div", {
|
|
79
80
|
className: "flex items-baseline justify-between rounded-lg border border-border/60 bg-muted/40 px-4 py-3",
|
|
80
|
-
children: [/* @__PURE__ */
|
|
81
|
+
children: [/* @__PURE__ */ f("div", { children: [/* @__PURE__ */ d("p", {
|
|
81
82
|
className: "text-xs uppercase tracking-wide text-text-secondary",
|
|
82
|
-
children:
|
|
83
|
-
}), /* @__PURE__ */
|
|
83
|
+
children: N
|
|
84
|
+
}), /* @__PURE__ */ d("p", {
|
|
84
85
|
className: "text-2xl font-bold",
|
|
85
|
-
children:
|
|
86
|
-
})] }), /* @__PURE__ */
|
|
87
|
-
className: "text-xs text-text-secondary",
|
|
88
|
-
children:
|
|
86
|
+
children: M
|
|
87
|
+
})] }), /* @__PURE__ */ f("p", {
|
|
88
|
+
className: "text-xs text-text-secondary text-right",
|
|
89
|
+
children: [P ? b(P.confidence) : "", P ? /* @__PURE__ */ d("span", {
|
|
90
|
+
className: "block",
|
|
91
|
+
"data-testid": "upcoming-demand-model",
|
|
92
|
+
children: u(P.model)
|
|
93
|
+
}) : null]
|
|
89
94
|
})]
|
|
90
|
-
}), /* @__PURE__ */
|
|
95
|
+
}), /* @__PURE__ */ f("div", {
|
|
91
96
|
className: "grid grid-cols-1 md:grid-cols-2 gap-4",
|
|
92
97
|
children: [
|
|
93
|
-
/* @__PURE__ */
|
|
98
|
+
/* @__PURE__ */ d(S, {
|
|
94
99
|
title: "Top lanes (volume)",
|
|
95
|
-
rows:
|
|
100
|
+
rows: O
|
|
96
101
|
}),
|
|
97
|
-
/* @__PURE__ */
|
|
102
|
+
/* @__PURE__ */ d(S, {
|
|
98
103
|
title: "Top lanes (revenue)",
|
|
99
|
-
rows:
|
|
104
|
+
rows: k
|
|
100
105
|
}),
|
|
101
|
-
/* @__PURE__ */
|
|
106
|
+
/* @__PURE__ */ d(S, {
|
|
102
107
|
title: "Top customers (volume)",
|
|
103
|
-
rows:
|
|
108
|
+
rows: A
|
|
104
109
|
}),
|
|
105
|
-
/* @__PURE__ */
|
|
110
|
+
/* @__PURE__ */ d(C, { rows: F })
|
|
106
111
|
]
|
|
107
112
|
})]
|
|
108
113
|
})] });
|
|
109
114
|
}
|
|
110
|
-
function
|
|
111
|
-
return t.length === 0 ? /* @__PURE__ */
|
|
115
|
+
function S({ title: e, rows: t }) {
|
|
116
|
+
return t.length === 0 ? /* @__PURE__ */ f("div", {
|
|
112
117
|
className: "rounded-lg border border-border/60 p-4",
|
|
113
|
-
children: [/* @__PURE__ */
|
|
118
|
+
children: [/* @__PURE__ */ d("p", {
|
|
114
119
|
className: "text-sm font-medium mb-2",
|
|
115
120
|
children: e
|
|
116
|
-
}), /* @__PURE__ */
|
|
121
|
+
}), /* @__PURE__ */ d("p", {
|
|
117
122
|
className: "text-xs text-text-secondary",
|
|
118
123
|
children: "No forecasts yet for this week."
|
|
119
124
|
})]
|
|
120
|
-
}) : /* @__PURE__ */
|
|
125
|
+
}) : /* @__PURE__ */ f("div", {
|
|
121
126
|
className: "rounded-lg border border-border/60 p-4",
|
|
122
|
-
children: [/* @__PURE__ */
|
|
127
|
+
children: [/* @__PURE__ */ d("p", {
|
|
123
128
|
className: "text-sm font-medium mb-3",
|
|
124
129
|
children: e
|
|
125
|
-
}), /* @__PURE__ */
|
|
130
|
+
}), /* @__PURE__ */ d("ul", {
|
|
126
131
|
className: "space-y-2",
|
|
127
|
-
children: t.map((e) => /* @__PURE__ */
|
|
132
|
+
children: t.map((e) => /* @__PURE__ */ f("li", {
|
|
128
133
|
className: "flex items-center justify-between text-sm",
|
|
129
|
-
children: [/* @__PURE__ */
|
|
134
|
+
children: [/* @__PURE__ */ d("span", {
|
|
130
135
|
className: "truncate font-medium",
|
|
131
136
|
title: e.scopeLabel,
|
|
132
137
|
children: e.scopeLabel
|
|
133
|
-
}), /* @__PURE__ */
|
|
138
|
+
}), /* @__PURE__ */ f("span", {
|
|
134
139
|
className: "ml-2 shrink-0 text-text-secondary",
|
|
135
140
|
children: [
|
|
136
|
-
|
|
141
|
+
y(e.predictedVolume, e.predictedRevenue),
|
|
137
142
|
" ·",
|
|
138
143
|
" ",
|
|
139
144
|
i(e.predictedRevenue)
|
|
@@ -143,33 +148,33 @@ function x({ title: e, rows: t }) {
|
|
|
143
148
|
})]
|
|
144
149
|
});
|
|
145
150
|
}
|
|
146
|
-
function
|
|
147
|
-
return /* @__PURE__ */
|
|
151
|
+
function C({ rows: e }) {
|
|
152
|
+
return /* @__PURE__ */ f("div", {
|
|
148
153
|
className: "rounded-lg border border-border/60 p-4",
|
|
149
|
-
children: [/* @__PURE__ */
|
|
154
|
+
children: [/* @__PURE__ */ d("p", {
|
|
150
155
|
className: "text-sm font-medium mb-3",
|
|
151
156
|
children: "Recent forecast variance"
|
|
152
|
-
}), e.length === 0 ? /* @__PURE__ */
|
|
157
|
+
}), e.length === 0 ? /* @__PURE__ */ d("p", {
|
|
153
158
|
className: "text-xs text-text-secondary",
|
|
154
159
|
children: "No closed periods to compare yet."
|
|
155
|
-
}) : /* @__PURE__ */
|
|
160
|
+
}) : /* @__PURE__ */ d("ul", {
|
|
156
161
|
className: "space-y-2",
|
|
157
162
|
children: e.map((e) => {
|
|
158
163
|
let t = e.volumeVariance > 0, i = t ? r : n, a = t ? "text-status-success-text" : "text-status-error-text";
|
|
159
|
-
return /* @__PURE__ */
|
|
164
|
+
return /* @__PURE__ */ f("li", {
|
|
160
165
|
className: "flex items-center justify-between text-sm",
|
|
161
|
-
children: [/* @__PURE__ */
|
|
166
|
+
children: [/* @__PURE__ */ f("span", {
|
|
162
167
|
className: "flex items-center gap-2 truncate",
|
|
163
|
-
children: [/* @__PURE__ */
|
|
168
|
+
children: [/* @__PURE__ */ d(i, {
|
|
164
169
|
size: 14,
|
|
165
170
|
className: a,
|
|
166
171
|
"aria-hidden": "true"
|
|
167
|
-
}), /* @__PURE__ */
|
|
172
|
+
}), /* @__PURE__ */ d("span", {
|
|
168
173
|
className: "truncate font-medium",
|
|
169
174
|
title: e.scopeLabel,
|
|
170
175
|
children: e.scopeLabel
|
|
171
176
|
})]
|
|
172
|
-
}), /* @__PURE__ */
|
|
177
|
+
}), /* @__PURE__ */ f("span", {
|
|
173
178
|
className: `ml-2 shrink-0 ${a}`,
|
|
174
179
|
children: [t ? "+" : "", Math.abs(e.volumeVariance) === 1 ? `${e.volumeVariance} job` : `${e.volumeVariance} jobs`]
|
|
175
180
|
})]
|
|
@@ -179,4 +184,4 @@ function S({ rows: e }) {
|
|
|
179
184
|
});
|
|
180
185
|
}
|
|
181
186
|
//#endregion
|
|
182
|
-
export {
|
|
187
|
+
export { x as UpcomingDemandPanel };
|