@burdenoff/microfe-movethewheels 2026.1107.1 → 2026.1107.2

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.
@@ -5,343 +5,346 @@ import { LoaderCircle as r } from "../node_modules/lucide-react/dist/esm/icons/l
5
5
  import { Pencil as i } from "../node_modules/lucide-react/dist/esm/icons/pencil.js";
6
6
  import { Play as a } from "../node_modules/lucide-react/dist/esm/icons/play.js";
7
7
  import { Plus as o } from "../node_modules/lucide-react/dist/esm/icons/plus.js";
8
- import { RefreshCw as s } from "../node_modules/lucide-react/dist/esm/icons/refresh-cw.js";
9
- import { Trash2 as c } from "../node_modules/lucide-react/dist/esm/icons/trash-2.js";
10
- import { useMoveTheWheels as l } from "../providers/MoveTheWheelsProvider.js";
11
- import { executeGraphQL as u } from "../utils/graphqlClient.js";
12
- import { formatCurrency as d, formatDate as f, formatDateTime as p, formatDistance as m, formatWeight as h } from "../utils/formatters.js";
13
- import { useModuleSettings as ee } from "../providers/ModuleSettingsProvider.js";
14
- import { Badge as g, Button as _, Card as v, CardContent as y, CardDescription as te, CardHeader as ne, CardTitle as re, Dialog as ie, DialogContent as ae, DialogDescription as oe, DialogFooter as se, DialogHeader as ce, DialogTitle as le, Input as b, Label as x, Select as S, SelectContent as C, SelectItem as w, SelectTrigger as T, SelectValue as E, Skeleton as D, Switch as ue, Table as de, TableBody as fe, TableCell as O, TableHead as k, TableHeader as pe, TableRow as A, Textarea as me } from "../components/ui.js";
15
- import { PageLayout as he } from "../components/PageLayout.js";
16
- import { FormError as j } from "../components/FormError.js";
17
- import { Notice as ge, useNotice as _e } from "../components/Notice.js";
18
- import { CREATE_MTW_REPORT_MUTATION as ve, DELETE_MTW_REPORT_MUTATION as ye, FREQUENCY_OPTIONS as M, GENERATE_MTW_REPORT_MUTATION as be, MTW_REPORTS_QUERY as xe, MTW_REPORT_RUNS_QUERY as Se, MTW_REPORT_RUN_EXPORT_QUERY as Ce, MTW_REPORT_RUN_QUERY as we, REPORT_TYPE_OPTIONS as N, UPDATE_MTW_REPORT_MUTATION as Te, WEEKDAY_LABELS as P, formatCell as F, formatMetric as I, metricLabel as L, newReportInput as R, reportInputError as Ee, reportToInput as De, reportTypeLabel as Oe, scheduleSummary as ke, suggestedPeriodDays as Ae, toServiceInput as je } from "../utils/reports.js";
19
- import { useCallback as Me, useEffect as Ne, useMemo as Pe, useState as z } from "react";
20
- import { Fragment as Fe, jsx as B, jsxs as V } from "react/jsx-runtime";
8
+ import { RefreshCw as ee } from "../node_modules/lucide-react/dist/esm/icons/refresh-cw.js";
9
+ import { Trash2 as te } from "../node_modules/lucide-react/dist/esm/icons/trash-2.js";
10
+ import { useMoveTheWheels as s } from "../providers/MoveTheWheelsProvider.js";
11
+ import { executeGraphQL as c } from "../utils/graphqlClient.js";
12
+ import { formatCurrency as l, formatDate as u, formatDateTime as d, formatDistance as f, formatWeight as p } from "../utils/formatters.js";
13
+ import { useModuleSettings as ne } from "../providers/ModuleSettingsProvider.js";
14
+ import { Badge as re, Button as m, Card as h, CardContent as g, CardDescription as ie, CardHeader as ae, CardTitle as _, Dialog as oe, DialogContent as se, DialogDescription as ce, DialogFooter as le, DialogHeader as ue, DialogTitle as de, Input as v, Label as y, Select as b, SelectContent as x, SelectItem as S, SelectTrigger as C, SelectValue as w, Skeleton as T, Switch as fe, Table as pe, TableBody as me, TableCell as E, TableHead as D, TableHeader as he, TableRow as O, Textarea as k } from "../components/ui.js";
15
+ import { PageLayout as ge } from "../components/PageLayout.js";
16
+ import { FormError as A } from "../components/FormError.js";
17
+ import { Notice as _e, useNotice as ve } from "../components/Notice.js";
18
+ import { CREATE_MTW_REPORT_MUTATION as ye, DELETE_MTW_REPORT_MUTATION as be, FREQUENCY_OPTIONS as j, GENERATE_MTW_REPORT_MUTATION as xe, MTW_REPORTS_QUERY as Se, MTW_REPORT_RUNS_QUERY as Ce, MTW_REPORT_RUN_EXPORT_QUERY as we, MTW_REPORT_RUN_QUERY as Te, REPORT_TYPE_OPTIONS as M, UPDATE_MTW_REPORT_MUTATION as Ee, WEEKDAY_LABELS as N, formatCell as P, formatMetric as F, metricLabel as I, newReportInput as L, reportInputError as R, reportToInput as De, reportTypeLabel as Oe, scheduleSummary as ke, suggestedPeriodDays as z, toServiceInput as Ae } from "../utils/reports.js";
19
+ import { useCallback as je, useEffect as Me, useMemo as Ne, useState as B } from "react";
20
+ import { Fragment as Pe, jsx as V, jsxs as H } from "react/jsx-runtime";
21
+ import { clearGraphqlFetchResponseCache as Fe } from "@burdenoff/fe-libs/shared/graphql";
21
22
  import { EmphasisPanel as Ie, PagePurpose as Le } from "@burdenoff/fe-libs/ui";
22
- import { PermissionProvider as H, usePermissions as Re } from "@burdenoff/fe-libs/shared/providers/shell";
23
+ import { PermissionProvider as U, usePermissions as Re } from "@burdenoff/fe-libs/shared/providers/shell";
23
24
  //#region src/movethewheels/pages/ReportsPage.tsx
24
- var U = {
25
- currency: d,
26
- distance: m,
27
- weight: h
25
+ var W = {
26
+ currency: l,
27
+ distance: f,
28
+ weight: p
28
29
  };
29
30
  function ze(e, t, n) {
30
31
  let r = URL.createObjectURL(new Blob([t], { type: n })), i = document.createElement("a");
31
32
  i.href = r, i.download = e, document.body.appendChild(i), i.click(), i.remove(), URL.revokeObjectURL(r);
32
33
  }
33
- function W(e, t) {
34
+ function G(e, t) {
34
35
  return e instanceof Error && e.message ? e.message : t;
35
36
  }
36
37
  function Be(e) {
37
38
  return e === "COMPLETED" ? "default" : e === "FAILED" ? "destructive" : e === "RUNNING" ? "secondary" : "outline";
38
39
  }
39
40
  function Ve(e) {
40
- return `${p(e.periodStart)} – ${p(e.periodEnd)}`;
41
+ return `${d(e.periodStart)} – ${d(e.periodEnd)}`;
41
42
  }
42
43
  function He() {
43
- let { workspaceId: e } = l();
44
- return /* @__PURE__ */ B(H, {
44
+ let { workspaceId: e } = s();
45
+ return /* @__PURE__ */ V(U, {
45
46
  scopeId: e ?? null,
46
47
  gateway: "workspace",
47
- children: /* @__PURE__ */ B(G, {})
48
+ children: /* @__PURE__ */ V(K, {})
48
49
  });
49
50
  }
50
- function G() {
51
- let { apiGatewayUrl: t, authToken: d, workspaceToken: f, workspaceId: m, tenantId: h, currentUser: b } = l(), { settings: x } = ee(), S = Re(), C = Pe(() => ({
51
+ function K() {
52
+ let { apiGatewayUrl: t, authToken: l, workspaceToken: u, workspaceId: f, tenantId: p, currentUser: v } = s(), { settings: y } = ne(), b = Re(), x = Ne(() => ({
52
53
  apiGatewayUrl: t,
53
- authToken: d,
54
- workspaceToken: f,
55
- workspaceId: m,
56
- tenantId: h,
57
- actorId: b?.id
54
+ authToken: l,
55
+ workspaceToken: u,
56
+ workspaceId: f,
57
+ tenantId: p,
58
+ actorId: v?.id
58
59
  }), [
59
60
  t,
60
- d,
61
+ l,
62
+ u,
61
63
  f,
62
- m,
63
- h,
64
- b?.id
65
- ]), [w, T] = z([]), [E, ue] = z(!0), [me, M] = z(null), [P, F] = z(null), [I, L] = z([]), [R, Ee] = z(null), [De, Ae] = z(!1), [H, U] = z(null), [He, G] = z(null), [K, q] = z(null), [J, Y] = z(null), [Ge, X] = z(0), { message: Ke, notify: qe } = _e(), Je = !!(m && b?.id && S.scopeId === m && !S.isLoading && !S.error), Z = Me((e) => !Je || S.isSuperAdmin || S.hasPermission(`mtw-report:${e}`), [Je, S]), Q = w.find((e) => e.id === P) ?? null;
66
- Ne(() => {
67
- if (!C.workspaceId) return;
64
+ p,
65
+ v?.id
66
+ ]), [S, C] = B([]), [w, fe] = B(!0), [k, j] = B(null), [N, P] = B(null), [F, I] = B([]), [L, R] = B(null), [De, z] = B(!1), [U, W] = B(null), [He, K] = B(null), [Ge, q] = B(null), [J, Y] = B(null), [Ke, qe] = B(0), X = je(() => {
67
+ Fe(), qe((e) => e + 1);
68
+ }, []), { message: Je, notify: Ye } = ve(), Xe = !!(f && v?.id && b.scopeId === f && !b.isLoading && !b.error), Z = je((e) => !Xe || b.isSuperAdmin || b.hasPermission(`mtw-report:${e}`), [Xe, b]), Q = S.find((e) => e.id === N) ?? null;
69
+ Me(() => {
70
+ if (!x.workspaceId) return;
68
71
  let e = !1;
69
- return ue(!0), u(C, xe, { pagination: { limit: 100 } }).then((t) => {
70
- e || (T(t.mtwReports), M(null), F((e) => e && t.mtwReports.some((t) => t.id === e) ? e : t.mtwReports[0]?.id ?? null));
72
+ return fe(!0), c(x, Se, { pagination: { limit: 100 } }).then((t) => {
73
+ e || (C(t.mtwReports), j(null), P((e) => e && t.mtwReports.some((t) => t.id === e) ? e : t.mtwReports[0]?.id ?? null));
71
74
  }).catch((t) => {
72
- e || M(W(t, "Could not load the reports"));
75
+ e || j(G(t, "Could not load the reports"));
73
76
  }).finally(() => {
74
- e || ue(!1);
77
+ e || fe(!1);
75
78
  }), () => {
76
79
  e = !0;
77
80
  };
78
- }, [C, Ge]);
79
- let Ye = Me(async (e) => {
80
- Ae(!0);
81
+ }, [x, Ke]);
82
+ let Ze = je(async (e) => {
83
+ z(!0);
81
84
  try {
82
- Ee((await u(C, we, {
85
+ R((await c(x, Te, {
83
86
  id: e,
84
87
  rows: { limit: 50 }
85
88
  })).mtwReportRun);
86
89
  } catch (e) {
87
- G(W(e, "Could not load the report run"));
90
+ K(G(e, "Could not load the report run"));
88
91
  } finally {
89
- Ae(!1);
92
+ z(!1);
90
93
  }
91
- }, [C]), $ = Q?.latestRun?.id ?? null;
92
- Ne(() => {
93
- if (L([]), Ee(null), !P) return;
94
+ }, [x]), $ = Q?.latestRun?.id ?? null;
95
+ Me(() => {
96
+ if (I([]), R(null), !N) return;
94
97
  let e = !1;
95
- return u(C, Se, {
96
- reportId: P,
98
+ return c(x, Ce, {
99
+ reportId: N,
97
100
  pagination: { limit: 30 }
98
101
  }).then((t) => {
99
- e || L(t.mtwReportRuns);
102
+ e || I(t.mtwReportRuns);
100
103
  }).catch((t) => {
101
- e || G(W(t, "Could not load the run history"));
102
- }), $ && Ye($), () => {
104
+ e || K(G(t, "Could not load the run history"));
105
+ }), $ && Ze($), () => {
103
106
  e = !0;
104
107
  };
105
108
  }, [
106
- C,
107
- P,
109
+ x,
110
+ N,
108
111
  $,
109
- Ye
112
+ Ze
110
113
  ]);
111
- let Xe = async (e) => {
112
- U(`generate:${e.id}`), G(null);
114
+ let Qe = async (e) => {
115
+ W(`generate:${e.id}`), K(null);
113
116
  try {
114
- let t = (await u(C, be, { id: e.id }, "SINGLE_ATTEMPT")).generateMtwReport;
115
- t.status === "COMPLETED" ? qe(`"${e.name}" generated.`) : G(t.error ?? "The report could not be generated."), F(e.id), X((e) => e + 1);
117
+ let t = (await c(x, xe, { id: e.id }, "SINGLE_ATTEMPT")).generateMtwReport;
118
+ t.status === "COMPLETED" ? Ye(`"${e.name}" generated.`) : K(t.error ?? "The report could not be generated."), P(e.id), X();
116
119
  } catch (e) {
117
- G(W(e, "Could not generate the report"));
120
+ K(G(e, "Could not generate the report"));
118
121
  } finally {
119
- U(null);
122
+ W(null);
120
123
  }
121
- }, Ze = async (e, t) => {
122
- U(`download:${e}:${t}`), G(null);
124
+ }, $e = async (e, t) => {
125
+ W(`download:${e}:${t}`), K(null);
123
126
  try {
124
- let n = (await u(C, Ce, {
127
+ let n = (await c(x, we, {
125
128
  runId: e,
126
129
  format: t
127
130
  })).mtwReportRunExport;
128
131
  ze(n.filename, n.content, n.contentType);
129
132
  } catch (e) {
130
- G(W(e, "Could not download the report"));
133
+ K(G(e, "Could not download the report"));
131
134
  } finally {
132
- U(null);
135
+ W(null);
133
136
  }
134
- }, Qe = async (e) => {
135
- U(`delete:${e.id}`), G(null);
137
+ }, et = async (e) => {
138
+ W(`delete:${e.id}`), K(null);
136
139
  try {
137
- await u(C, ye, { id: e.id }, "SINGLE_ATTEMPT"), qe(`"${e.name}" deleted.`), Y(null), P === e.id && F(null), X((e) => e + 1);
140
+ await c(x, be, { id: e.id }, "SINGLE_ATTEMPT"), Ye(`"${e.name}" deleted.`), Y(null), N === e.id && P(null), X();
138
141
  } catch (e) {
139
- G(W(e, "Could not delete the report"));
142
+ K(G(e, "Could not delete the report"));
140
143
  } finally {
141
- U(null);
144
+ W(null);
142
145
  }
143
146
  };
144
- return /* @__PURE__ */ V(he, {
147
+ return /* @__PURE__ */ H(ge, {
145
148
  title: "Reports",
146
149
  subtitle: "Scheduled and on-demand reports over your logistics data",
147
- icon: /* @__PURE__ */ B(n, { size: 24 }),
150
+ icon: /* @__PURE__ */ V(n, { size: 24 }),
148
151
  maxWidth: "full",
149
- headerActions: /* @__PURE__ */ V("div", {
152
+ headerActions: /* @__PURE__ */ H("div", {
150
153
  className: "flex flex-wrap gap-2",
151
- children: [/* @__PURE__ */ V(_, {
154
+ children: [/* @__PURE__ */ H(m, {
152
155
  variant: "outline",
153
- onClick: () => X((e) => e + 1),
154
- children: [/* @__PURE__ */ B(s, {
156
+ onClick: X,
157
+ children: [/* @__PURE__ */ V(ee, {
155
158
  size: 16,
156
159
  className: "mr-2"
157
160
  }), " Refresh"]
158
- }), Z("create") && /* @__PURE__ */ V(_, {
161
+ }), Z("create") && /* @__PURE__ */ H(m, {
159
162
  onClick: () => q("new"),
160
- children: [/* @__PURE__ */ B(o, {
163
+ children: [/* @__PURE__ */ V(o, {
161
164
  size: 16,
162
165
  className: "mr-2"
163
166
  }), " New report"]
164
167
  })]
165
168
  }),
166
169
  children: [
167
- /* @__PURE__ */ B(Le, {
168
- icon: /* @__PURE__ */ B(n, { size: 18 }),
170
+ /* @__PURE__ */ V(Le, {
171
+ icon: /* @__PURE__ */ V(n, { size: 18 }),
169
172
  children: "Save the reports you need and generate them whenever you like, or have them generated every day, week or month. Each generation keeps its figures and rows so you can compare periods and download them as CSV or JSON."
170
173
  }),
171
- me && /* @__PURE__ */ B(j, { message: me }),
172
- /* @__PURE__ */ B(j, { message: He }),
173
- /* @__PURE__ */ B(ge, { message: Ke }),
174
- /* @__PURE__ */ V("div", {
174
+ k && /* @__PURE__ */ V(A, { message: k }),
175
+ /* @__PURE__ */ V(A, { message: He }),
176
+ /* @__PURE__ */ V(_e, { message: Je }),
177
+ /* @__PURE__ */ H("div", {
175
178
  className: "grid grid-cols-1 gap-6 xl:grid-cols-3",
176
- children: [/* @__PURE__ */ V(Ie, {
179
+ children: [/* @__PURE__ */ H(Ie, {
177
180
  className: "space-y-3 xl:col-span-1",
178
- children: [/* @__PURE__ */ B("h2", {
181
+ children: [/* @__PURE__ */ V("h2", {
179
182
  className: "text-base font-semibold text-text-primary",
180
183
  children: "Saved reports"
181
- }), E && w.length === 0 ? /* @__PURE__ */ V("div", {
184
+ }), w && S.length === 0 ? /* @__PURE__ */ H("div", {
182
185
  className: "space-y-3",
183
186
  "aria-busy": "true",
184
- children: [/* @__PURE__ */ B(D, { className: "h-16 w-full" }), /* @__PURE__ */ B(D, { className: "h-16 w-full" })]
185
- }) : w.length === 0 ? /* @__PURE__ */ V("div", {
187
+ children: [/* @__PURE__ */ V(T, { className: "h-16 w-full" }), /* @__PURE__ */ V(T, { className: "h-16 w-full" })]
188
+ }) : S.length === 0 ? /* @__PURE__ */ H("div", {
186
189
  className: "rounded-lg border border-dashed border-border-default p-6 text-center text-sm text-text-secondary",
187
- children: [/* @__PURE__ */ B("p", { children: "No reports yet." }), Z("create") && /* @__PURE__ */ V(_, {
190
+ children: [/* @__PURE__ */ V("p", { children: "No reports yet." }), Z("create") && /* @__PURE__ */ H(m, {
188
191
  className: "mt-4",
189
192
  onClick: () => q("new"),
190
- children: [/* @__PURE__ */ B(o, {
193
+ children: [/* @__PURE__ */ V(o, {
191
194
  size: 16,
192
195
  className: "mr-2"
193
196
  }), " Create your first report"]
194
197
  })]
195
- }) : /* @__PURE__ */ B("ul", {
198
+ }) : /* @__PURE__ */ V("ul", {
196
199
  className: "space-y-2",
197
200
  "aria-label": "Saved reports",
198
- children: w.map((e) => /* @__PURE__ */ B("li", { children: /* @__PURE__ */ V("button", {
201
+ children: S.map((e) => /* @__PURE__ */ V("li", { children: /* @__PURE__ */ H("button", {
199
202
  type: "button",
200
- onClick: () => F(e.id),
201
- "aria-current": e.id === P ? "true" : void 0,
202
- className: `w-full rounded-lg border px-3 py-2 text-left transition-colors ${e.id === P ? "border-border-primary bg-surface-secondary" : "border-border-default hover:bg-surface-secondary"}`,
203
+ onClick: () => P(e.id),
204
+ "aria-current": e.id === N ? "true" : void 0,
205
+ className: `w-full rounded-lg border px-3 py-2 text-left transition-colors ${e.id === N ? "border-border-primary bg-surface-secondary" : "border-border-default hover:bg-surface-secondary"}`,
203
206
  children: [
204
- /* @__PURE__ */ V("span", {
207
+ /* @__PURE__ */ H("span", {
205
208
  className: "flex items-center justify-between gap-2",
206
- children: [/* @__PURE__ */ B("span", {
209
+ children: [/* @__PURE__ */ V("span", {
207
210
  className: "truncate text-sm font-medium text-text-primary",
208
211
  children: e.name
209
- }), /* @__PURE__ */ B(g, {
212
+ }), /* @__PURE__ */ V(re, {
210
213
  variant: "outline",
211
214
  children: Oe(e.type)
212
215
  })]
213
216
  }),
214
- /* @__PURE__ */ B("span", {
217
+ /* @__PURE__ */ V("span", {
215
218
  className: "mt-1 block text-xs text-text-secondary",
216
219
  children: ke(e)
217
220
  }),
218
- /* @__PURE__ */ B("span", {
221
+ /* @__PURE__ */ V("span", {
219
222
  className: "mt-1 block text-xs text-text-tertiary",
220
- children: e.lastGeneratedAt ? `Last generated ${p(e.lastGeneratedAt)}` : "Never generated"
223
+ children: e.lastGeneratedAt ? `Last generated ${d(e.lastGeneratedAt)}` : "Never generated"
221
224
  })
222
225
  ]
223
226
  }) }, e.id))
224
227
  })]
225
- }), /* @__PURE__ */ B("div", {
228
+ }), /* @__PURE__ */ V("div", {
226
229
  className: "space-y-6 xl:col-span-2",
227
- children: Q ? /* @__PURE__ */ V(Fe, { children: [
228
- /* @__PURE__ */ B(v, { children: /* @__PURE__ */ V(ne, {
230
+ children: Q ? /* @__PURE__ */ H(Pe, { children: [
231
+ /* @__PURE__ */ V(h, { children: /* @__PURE__ */ H(ae, {
229
232
  className: "flex flex-row flex-wrap items-start justify-between gap-3",
230
- children: [/* @__PURE__ */ V("div", {
233
+ children: [/* @__PURE__ */ H("div", {
231
234
  className: "min-w-0 space-y-1",
232
235
  children: [
233
- /* @__PURE__ */ B(re, {
236
+ /* @__PURE__ */ V(_, {
234
237
  className: "text-lg",
235
238
  children: Q.name
236
239
  }),
237
- /* @__PURE__ */ B(te, { children: Q.description || N.find((e) => e.value === Q.type)?.description }),
238
- /* @__PURE__ */ V("p", {
240
+ /* @__PURE__ */ V(ie, { children: Q.description || M.find((e) => e.value === Q.type)?.description }),
241
+ /* @__PURE__ */ H("p", {
239
242
  className: "flex flex-wrap items-center gap-2 text-xs text-text-secondary",
240
243
  children: [
241
- /* @__PURE__ */ B(e, { size: 14 }),
242
- /* @__PURE__ */ B("span", { children: ke(Q) }),
243
- /* @__PURE__ */ V("span", { children: [
244
+ /* @__PURE__ */ V(e, { size: 14 }),
245
+ /* @__PURE__ */ V("span", { children: ke(Q) }),
246
+ /* @__PURE__ */ H("span", { children: [
244
247
  "· Covers the last ",
245
248
  Q.periodDays,
246
249
  " day(s)"
247
250
  ] }),
248
- Q.nextRunAt && /* @__PURE__ */ V("span", { children: ["· Next run ", p(Q.nextRunAt)] })
251
+ Q.nextRunAt && /* @__PURE__ */ H("span", { children: ["· Next run ", d(Q.nextRunAt)] })
249
252
  ]
250
253
  })
251
254
  ]
252
- }), /* @__PURE__ */ V("div", {
255
+ }), /* @__PURE__ */ H("div", {
253
256
  className: "flex flex-wrap gap-2",
254
257
  children: [
255
- Z("generate") && /* @__PURE__ */ V(_, {
256
- onClick: () => void Xe(Q),
257
- disabled: H !== null,
258
+ Z("generate") && /* @__PURE__ */ H(m, {
259
+ onClick: () => void Qe(Q),
260
+ disabled: U !== null,
258
261
  "aria-label": `Generate ${Q.name} now`,
259
- children: [H === `generate:${Q.id}` ? /* @__PURE__ */ B(r, {
262
+ children: [U === `generate:${Q.id}` ? /* @__PURE__ */ V(r, {
260
263
  size: 16,
261
264
  className: "mr-2 animate-spin"
262
- }) : /* @__PURE__ */ B(a, {
265
+ }) : /* @__PURE__ */ V(a, {
263
266
  size: 16,
264
267
  className: "mr-2"
265
268
  }), "Generate now"]
266
269
  }),
267
- Z("update") && /* @__PURE__ */ V(_, {
270
+ Z("update") && /* @__PURE__ */ H(m, {
268
271
  variant: "outline",
269
272
  onClick: () => q(Q),
270
- disabled: H !== null,
271
- children: [/* @__PURE__ */ B(i, {
273
+ disabled: U !== null,
274
+ children: [/* @__PURE__ */ V(i, {
272
275
  size: 16,
273
276
  className: "mr-2"
274
277
  }), " Edit"]
275
278
  }),
276
- Z("delete") && /* @__PURE__ */ B(_, {
279
+ Z("delete") && /* @__PURE__ */ V(m, {
277
280
  variant: "outline",
278
281
  onClick: () => Y(Q),
279
- disabled: H !== null,
282
+ disabled: U !== null,
280
283
  "aria-label": `Delete ${Q.name}`,
281
- children: /* @__PURE__ */ B(c, { size: 16 })
284
+ children: /* @__PURE__ */ V(te, { size: 16 })
282
285
  })
283
286
  ]
284
287
  })]
285
288
  }) }),
286
- /* @__PURE__ */ B(Ue, {
287
- run: R,
289
+ /* @__PURE__ */ V(Ue, {
290
+ run: L,
288
291
  isLoading: De,
289
292
  hasRuns: !!Q.latestRun,
290
- busy: H,
291
- onDownload: (e, t) => void Ze(e, t)
293
+ busy: U,
294
+ onDownload: (e, t) => void $e(e, t)
292
295
  }),
293
- /* @__PURE__ */ V(v, { children: [/* @__PURE__ */ V(ne, { children: [/* @__PURE__ */ B(re, {
296
+ /* @__PURE__ */ H(h, { children: [/* @__PURE__ */ H(ae, { children: [/* @__PURE__ */ V(_, {
294
297
  className: "text-base",
295
298
  children: "Run history"
296
- }), /* @__PURE__ */ B(te, { children: "The latest 30 generations are kept. Select one to preview it." })] }), /* @__PURE__ */ B(y, { children: I.length === 0 ? /* @__PURE__ */ B("p", {
299
+ }), /* @__PURE__ */ V(ie, { children: "The latest 30 generations are kept. Select one to preview it." })] }), /* @__PURE__ */ V(g, { children: F.length === 0 ? /* @__PURE__ */ V("p", {
297
300
  className: "text-sm text-text-secondary",
298
301
  children: "No runs yet."
299
- }) : /* @__PURE__ */ B("div", {
302
+ }) : /* @__PURE__ */ V("div", {
300
303
  className: "overflow-x-auto",
301
- children: /* @__PURE__ */ V(de, { children: [/* @__PURE__ */ B(pe, { children: /* @__PURE__ */ V(A, { children: [
302
- /* @__PURE__ */ B(k, { children: "Generated" }),
303
- /* @__PURE__ */ B(k, { children: "Period" }),
304
- /* @__PURE__ */ B(k, { children: "Trigger" }),
305
- /* @__PURE__ */ B(k, { children: "Status" }),
306
- /* @__PURE__ */ B(k, {
304
+ children: /* @__PURE__ */ H(pe, { children: [/* @__PURE__ */ V(he, { children: /* @__PURE__ */ H(O, { children: [
305
+ /* @__PURE__ */ V(D, { children: "Generated" }),
306
+ /* @__PURE__ */ V(D, { children: "Period" }),
307
+ /* @__PURE__ */ V(D, { children: "Trigger" }),
308
+ /* @__PURE__ */ V(D, { children: "Status" }),
309
+ /* @__PURE__ */ V(D, {
307
310
  className: "text-right",
308
311
  children: "Rows"
309
312
  }),
310
- /* @__PURE__ */ B(k, {
313
+ /* @__PURE__ */ V(D, {
311
314
  className: "text-right",
312
315
  children: "Download"
313
316
  })
314
- ] }) }), /* @__PURE__ */ B(fe, { children: I.map((e) => /* @__PURE__ */ V(A, {
315
- className: e.id === R?.id ? "bg-surface-secondary" : void 0,
317
+ ] }) }), /* @__PURE__ */ V(me, { children: F.map((e) => /* @__PURE__ */ H(O, {
318
+ className: e.id === L?.id ? "bg-surface-secondary" : void 0,
316
319
  children: [
317
- /* @__PURE__ */ B(O, { children: /* @__PURE__ */ B("button", {
320
+ /* @__PURE__ */ V(E, { children: /* @__PURE__ */ V("button", {
318
321
  type: "button",
319
322
  className: "text-left font-medium text-text-primary underline-offset-2 hover:underline",
320
- onClick: () => void Ye(e.id),
321
- children: p(e.startedAt)
323
+ onClick: () => void Ze(e.id),
324
+ children: d(e.startedAt)
322
325
  }) }),
323
- /* @__PURE__ */ B(O, {
326
+ /* @__PURE__ */ V(E, {
324
327
  className: "whitespace-nowrap text-xs",
325
328
  children: Ve(e)
326
329
  }),
327
- /* @__PURE__ */ B(O, { children: e.trigger === "SCHEDULED" ? "Scheduled" : "Manual" }),
328
- /* @__PURE__ */ B(O, { children: /* @__PURE__ */ B(g, {
330
+ /* @__PURE__ */ V(E, { children: e.trigger === "SCHEDULED" ? "Scheduled" : "Manual" }),
331
+ /* @__PURE__ */ V(E, { children: /* @__PURE__ */ V(re, {
329
332
  variant: Be(e.status),
330
333
  children: e.status
331
334
  }) }),
332
- /* @__PURE__ */ B(O, {
335
+ /* @__PURE__ */ V(E, {
333
336
  className: "text-right",
334
337
  children: e.rowCount.toLocaleString()
335
338
  }),
336
- /* @__PURE__ */ B(O, {
339
+ /* @__PURE__ */ V(E, {
337
340
  className: "text-right",
338
- children: e.status === "COMPLETED" ? /* @__PURE__ */ B("span", {
341
+ children: e.status === "COMPLETED" ? /* @__PURE__ */ V("span", {
339
342
  className: "inline-flex gap-1",
340
- children: ["CSV", "JSON"].map((t) => /* @__PURE__ */ B(_, {
343
+ children: ["CSV", "JSON"].map((t) => /* @__PURE__ */ V(m, {
341
344
  variant: "ghost",
342
345
  size: "sm",
343
- disabled: H !== null,
344
- onClick: () => void Ze(e.id, t),
346
+ disabled: U !== null,
347
+ onClick: () => void $e(e.id, t),
345
348
  children: t
346
349
  }, t))
347
350
  }) : "—"
@@ -349,36 +352,36 @@ function G() {
349
352
  ]
350
353
  }, e.id)) })] })
351
354
  }) })] })
352
- ] }) : !E && /* @__PURE__ */ B(v, { children: /* @__PURE__ */ B(y, {
355
+ ] }) : !w && /* @__PURE__ */ V(h, { children: /* @__PURE__ */ V(g, {
353
356
  className: "p-6 text-sm text-text-secondary",
354
357
  children: "Select a report to see its latest figures and run history."
355
358
  }) })
356
359
  })]
357
360
  }),
358
- K && /* @__PURE__ */ B(We, {
359
- report: K === "new" ? null : K,
360
- defaultTimezone: x.timezone ?? "UTC",
361
+ Ge && /* @__PURE__ */ V(We, {
362
+ report: Ge === "new" ? null : Ge,
363
+ defaultTimezone: y.timezone ?? "UTC",
361
364
  onClose: () => q(null),
362
365
  onSave: async (e, t) => {
363
- let n = t ? await u(C, Te, {
366
+ let n = t ? await c(x, Ee, {
364
367
  id: t.id,
365
- input: je(e)
366
- }, "SINGLE_ATTEMPT").then((e) => e.updateMtwReport) : await u(C, ve, { input: je(e) }, "SINGLE_ATTEMPT").then((e) => e.createMtwReport);
367
- qe(t ? `"${n.name}" saved.` : `"${n.name}" created.`), q(null), F(n.id), X((e) => e + 1);
368
+ input: Ae(e)
369
+ }, "SINGLE_ATTEMPT").then((e) => e.updateMtwReport) : await c(x, ye, { input: Ae(e) }, "SINGLE_ATTEMPT").then((e) => e.createMtwReport);
370
+ Ye(t ? `"${n.name}" saved.` : `"${n.name}" created.`), q(null), P(n.id), X();
368
371
  }
369
372
  }),
370
- /* @__PURE__ */ B(ie, {
373
+ /* @__PURE__ */ V(oe, {
371
374
  open: J !== null,
372
375
  onOpenChange: (e) => !e && Y(null),
373
- children: /* @__PURE__ */ V(ae, { children: [/* @__PURE__ */ V(ce, { children: [/* @__PURE__ */ B(le, { children: "Delete this report?" }), /* @__PURE__ */ B(oe, { children: J ? `"${J.name}" stops being generated and leaves the list. This cannot be undone.` : "" })] }), /* @__PURE__ */ V(se, { children: [/* @__PURE__ */ B(_, {
376
+ children: /* @__PURE__ */ H(se, { children: [/* @__PURE__ */ H(ue, { children: [/* @__PURE__ */ V(de, { children: "Delete this report?" }), /* @__PURE__ */ V(ce, { children: J ? `"${J.name}" stops being generated and leaves the list. This cannot be undone.` : "" })] }), /* @__PURE__ */ H(le, { children: [/* @__PURE__ */ V(m, {
374
377
  variant: "outline",
375
378
  onClick: () => Y(null),
376
379
  children: "Cancel"
377
- }), /* @__PURE__ */ V(_, {
380
+ }), /* @__PURE__ */ H(m, {
378
381
  variant: "destructive",
379
- disabled: H !== null,
380
- onClick: () => J && void Qe(J),
381
- children: [H?.startsWith("delete:") && /* @__PURE__ */ B(r, {
382
+ disabled: U !== null,
383
+ onClick: () => J && void et(J),
384
+ children: [U?.startsWith("delete:") && /* @__PURE__ */ V(r, {
382
385
  size: 16,
383
386
  className: "mr-2 animate-spin"
384
387
  }), "Delete report"]
@@ -388,67 +391,67 @@ function G() {
388
391
  });
389
392
  }
390
393
  function Ue({ run: e, isLoading: n, hasRuns: i, busy: a, onDownload: o }) {
391
- return n && !e ? /* @__PURE__ */ B(v, { children: /* @__PURE__ */ V(y, {
394
+ return n && !e ? /* @__PURE__ */ V(h, { children: /* @__PURE__ */ H(g, {
392
395
  className: "space-y-3 p-6",
393
396
  "aria-busy": "true",
394
- children: [/* @__PURE__ */ B(D, { className: "h-20 w-full" }), /* @__PURE__ */ B(D, { className: "h-40 w-full" })]
395
- }) }) : e ? /* @__PURE__ */ V(v, {
397
+ children: [/* @__PURE__ */ V(T, { className: "h-20 w-full" }), /* @__PURE__ */ V(T, { className: "h-40 w-full" })]
398
+ }) }) : e ? /* @__PURE__ */ H(h, {
396
399
  "data-testid": "mtw-report-run",
397
- children: [/* @__PURE__ */ V(ne, {
400
+ children: [/* @__PURE__ */ H(ae, {
398
401
  className: "flex flex-row flex-wrap items-start justify-between gap-3",
399
- children: [/* @__PURE__ */ V("div", {
402
+ children: [/* @__PURE__ */ H("div", {
400
403
  className: "space-y-1",
401
- children: [/* @__PURE__ */ V(re, {
404
+ children: [/* @__PURE__ */ H(_, {
402
405
  className: "text-base",
403
406
  children: [
404
407
  e.trigger === "SCHEDULED" ? "Scheduled run" : "Run",
405
408
  " of",
406
409
  " ",
407
- p(e.startedAt)
410
+ d(e.startedAt)
408
411
  ]
409
- }), /* @__PURE__ */ V(te, { children: ["Covers ", Ve(e)] })]
410
- }), /* @__PURE__ */ V("div", {
412
+ }), /* @__PURE__ */ H(ie, { children: ["Covers ", Ve(e)] })]
413
+ }), /* @__PURE__ */ H("div", {
411
414
  className: "flex items-center gap-2",
412
- children: [/* @__PURE__ */ B(g, {
415
+ children: [/* @__PURE__ */ V(re, {
413
416
  variant: Be(e.status),
414
417
  children: e.status
415
- }), e.status === "COMPLETED" && ["CSV", "JSON"].map((n) => /* @__PURE__ */ V(_, {
418
+ }), e.status === "COMPLETED" && ["CSV", "JSON"].map((n) => /* @__PURE__ */ H(m, {
416
419
  variant: "outline",
417
420
  size: "sm",
418
421
  disabled: a !== null,
419
422
  onClick: () => o(e.id, n),
420
- children: [a === `download:${e.id}:${n}` ? /* @__PURE__ */ B(r, {
423
+ children: [a === `download:${e.id}:${n}` ? /* @__PURE__ */ V(r, {
421
424
  size: 14,
422
425
  className: "mr-2 animate-spin"
423
- }) : /* @__PURE__ */ B(t, {
426
+ }) : /* @__PURE__ */ V(t, {
424
427
  size: 14,
425
428
  className: "mr-2"
426
429
  }), n]
427
430
  }, n))]
428
431
  })]
429
- }), /* @__PURE__ */ V(y, {
432
+ }), /* @__PURE__ */ H(g, {
430
433
  className: "space-y-6",
431
434
  children: [
432
- e.status === "FAILED" && /* @__PURE__ */ B(j, { message: e.error ?? "This run failed." }),
433
- e.metrics.length > 0 && /* @__PURE__ */ B("dl", {
435
+ e.status === "FAILED" && /* @__PURE__ */ V(A, { message: e.error ?? "This run failed." }),
436
+ e.metrics.length > 0 && /* @__PURE__ */ V("dl", {
434
437
  className: "grid grid-cols-2 gap-3 md:grid-cols-3 lg:grid-cols-4",
435
- children: e.metrics.map((e) => /* @__PURE__ */ V("div", {
438
+ children: e.metrics.map((e) => /* @__PURE__ */ H("div", {
436
439
  className: "rounded-lg border border-border-default px-3 py-2",
437
- children: [/* @__PURE__ */ B("dt", {
440
+ children: [/* @__PURE__ */ V("dt", {
438
441
  className: "text-xs text-text-secondary",
439
- children: L(e)
440
- }), /* @__PURE__ */ B("dd", {
442
+ children: I(e)
443
+ }), /* @__PURE__ */ V("dd", {
441
444
  className: "text-lg font-semibold text-text-primary",
442
- children: I(e, U)
445
+ children: F(e, W)
443
446
  })]
444
447
  }, e.key))
445
448
  }),
446
- e.status === "COMPLETED" && (e.rowCount === 0 ? /* @__PURE__ */ B("p", {
449
+ e.status === "COMPLETED" && (e.rowCount === 0 ? /* @__PURE__ */ V("p", {
447
450
  className: "text-sm text-text-secondary",
448
451
  children: "The period had no rows for this report."
449
- }) : /* @__PURE__ */ V("div", {
452
+ }) : /* @__PURE__ */ H("div", {
450
453
  className: "space-y-2",
451
- children: [/* @__PURE__ */ V("p", {
454
+ children: [/* @__PURE__ */ H("p", {
452
455
  className: "text-xs text-text-secondary",
453
456
  children: [
454
457
  "Showing ",
@@ -459,252 +462,252 @@ function Ue({ run: e, isLoading: n, hasRuns: i, busy: a, onDownload: o }) {
459
462
  " rows. Download the run for all of them.",
460
463
  e.truncated && " The period had more rows than a run keeps (5,000); the figures above still cover all of them."
461
464
  ]
462
- }), /* @__PURE__ */ B("div", {
465
+ }), /* @__PURE__ */ V("div", {
463
466
  className: "max-h-[28rem] overflow-auto rounded-lg border border-border-default",
464
- children: /* @__PURE__ */ V(de, { children: [/* @__PURE__ */ B(pe, { children: /* @__PURE__ */ B(A, { children: e.columns.map((e) => /* @__PURE__ */ B(k, {
467
+ children: /* @__PURE__ */ H(pe, { children: [/* @__PURE__ */ V(he, { children: /* @__PURE__ */ V(O, { children: e.columns.map((e) => /* @__PURE__ */ V(D, {
465
468
  className: "whitespace-nowrap",
466
469
  children: e.label
467
- }, e.key)) }) }), /* @__PURE__ */ B(fe, { children: e.rows.map((t, n) => /* @__PURE__ */ B(A, { children: e.columns.map((e) => /* @__PURE__ */ B(O, {
470
+ }, e.key)) }) }), /* @__PURE__ */ V(me, { children: e.rows.map((t, n) => /* @__PURE__ */ V(O, { children: e.columns.map((e) => /* @__PURE__ */ V(E, {
468
471
  className: "whitespace-nowrap text-xs",
469
- children: e.kind === "CURRENCY" && typeof t[e.key] == "number" ? d(t[e.key], typeof t.currency == "string" ? t.currency : void 0) : F(t[e.key], e, (e) => f(e))
472
+ children: e.kind === "CURRENCY" && typeof t[e.key] == "number" ? l(t[e.key], typeof t.currency == "string" ? t.currency : void 0) : P(t[e.key], e, (e) => u(e))
470
473
  }, e.key)) }, n)) })] })
471
474
  })]
472
475
  }))
473
476
  ]
474
477
  })]
475
- }) : /* @__PURE__ */ B(v, { children: /* @__PURE__ */ B(y, {
478
+ }) : /* @__PURE__ */ V(h, { children: /* @__PURE__ */ V(g, {
476
479
  className: "p-6 text-sm text-text-secondary",
477
480
  children: i ? "Select a run to preview it." : "This report has not been generated yet. Use \"Generate now\" to produce the first run."
478
481
  }) });
479
482
  }
480
483
  function We({ report: e, defaultTimezone: t, onClose: n, onSave: i }) {
481
- let [a, o] = z(() => e ? De(e) : R(t)), [s, c] = z(String(a.periodDays)), [l, u] = z(!1), [d, f] = z(null), p = {
484
+ let [a, o] = B(() => e ? De(e) : L(t)), [ee, te] = B(String(a.periodDays)), [s, c] = B(!1), [l, u] = B(null), d = {
482
485
  ...a,
483
- periodDays: Number(s)
484
- }, m = Ee(p), h = (e, t) => {
485
- f(null), o((n) => ({
486
+ periodDays: Number(ee)
487
+ }, f = R(d), p = (e, t) => {
488
+ u(null), o((n) => ({
486
489
  ...n,
487
490
  [e]: t
488
491
  }));
489
- }, ee = async (t) => {
490
- if (t.preventDefault(), m) {
491
- f(m);
492
+ }, ne = async (t) => {
493
+ if (t.preventDefault(), f) {
494
+ u(f);
492
495
  return;
493
496
  }
494
- u(!0), f(null);
497
+ c(!0), u(null);
495
498
  try {
496
- await i(p, e);
499
+ await i(d, e);
497
500
  } catch (e) {
498
- f(W(e, "Could not save the report"));
501
+ u(G(e, "Could not save the report"));
499
502
  } finally {
500
- u(!1);
503
+ c(!1);
501
504
  }
502
505
  };
503
- return /* @__PURE__ */ B(ie, {
506
+ return /* @__PURE__ */ V(oe, {
504
507
  open: !0,
505
- onOpenChange: (e) => !e && !l && n(),
506
- children: /* @__PURE__ */ V(ae, {
508
+ onOpenChange: (e) => !e && !s && n(),
509
+ children: /* @__PURE__ */ H(se, {
507
510
  className: "max-h-[90vh] overflow-y-auto sm:max-w-xl",
508
- children: [/* @__PURE__ */ V(ce, { children: [/* @__PURE__ */ B(le, { children: e ? "Edit report" : "New report" }), /* @__PURE__ */ B(oe, { children: "Choose what the report covers and, if you like, when it is generated automatically." })] }), /* @__PURE__ */ V("form", {
511
+ children: [/* @__PURE__ */ H(ue, { children: [/* @__PURE__ */ V(de, { children: e ? "Edit report" : "New report" }), /* @__PURE__ */ V(ce, { children: "Choose what the report covers and, if you like, when it is generated automatically." })] }), /* @__PURE__ */ H("form", {
509
512
  className: "space-y-4",
510
- onSubmit: (e) => void ee(e),
513
+ onSubmit: (e) => void ne(e),
511
514
  "aria-label": "Report",
512
515
  children: [
513
- /* @__PURE__ */ V("div", {
516
+ /* @__PURE__ */ H("div", {
514
517
  className: "space-y-2",
515
- children: [/* @__PURE__ */ B(x, {
518
+ children: [/* @__PURE__ */ V(y, {
516
519
  htmlFor: "mtw-report-name",
517
520
  children: "Name"
518
- }), /* @__PURE__ */ B(b, {
521
+ }), /* @__PURE__ */ V(v, {
519
522
  id: "mtw-report-name",
520
523
  value: a.name,
521
524
  maxLength: 120,
522
- onChange: (e) => h("name", e.target.value),
525
+ onChange: (e) => p("name", e.target.value),
523
526
  placeholder: "Weekly operations review"
524
527
  })]
525
528
  }),
526
- /* @__PURE__ */ V("div", {
529
+ /* @__PURE__ */ H("div", {
527
530
  className: "space-y-2",
528
531
  children: [
529
- /* @__PURE__ */ B(x, {
532
+ /* @__PURE__ */ V(y, {
530
533
  htmlFor: "mtw-report-type",
531
534
  children: "Report type"
532
535
  }),
533
- /* @__PURE__ */ V(S, {
536
+ /* @__PURE__ */ H(b, {
534
537
  value: a.type,
535
538
  onValueChange: (e) => {
536
- let t = N.find((t) => t.value === e);
537
- t && h("type", t.value);
539
+ let t = M.find((t) => t.value === e);
540
+ t && p("type", t.value);
538
541
  },
539
- children: [/* @__PURE__ */ B(T, {
542
+ children: [/* @__PURE__ */ V(C, {
540
543
  id: "mtw-report-type",
541
544
  "aria-label": "Report type",
542
- children: /* @__PURE__ */ B(E, {})
543
- }), /* @__PURE__ */ B(C, { children: N.map((e) => /* @__PURE__ */ B(w, {
545
+ children: /* @__PURE__ */ V(w, {})
546
+ }), /* @__PURE__ */ V(x, { children: M.map((e) => /* @__PURE__ */ V(S, {
544
547
  value: e.value,
545
548
  children: e.label
546
549
  }, e.value)) })]
547
550
  }),
548
- /* @__PURE__ */ B("p", {
551
+ /* @__PURE__ */ V("p", {
549
552
  className: "text-xs text-text-secondary",
550
- children: N.find((e) => e.value === a.type)?.description
553
+ children: M.find((e) => e.value === a.type)?.description
551
554
  })
552
555
  ]
553
556
  }),
554
- /* @__PURE__ */ V("div", {
557
+ /* @__PURE__ */ H("div", {
555
558
  className: "space-y-2",
556
- children: [/* @__PURE__ */ B(x, {
559
+ children: [/* @__PURE__ */ V(y, {
557
560
  htmlFor: "mtw-report-description",
558
561
  children: "Description (optional)"
559
- }), /* @__PURE__ */ B(me, {
562
+ }), /* @__PURE__ */ V(k, {
560
563
  id: "mtw-report-description",
561
564
  value: a.description,
562
565
  maxLength: 1e3,
563
566
  rows: 2,
564
- onChange: (e) => h("description", e.target.value)
567
+ onChange: (e) => p("description", e.target.value)
565
568
  })]
566
569
  }),
567
- /* @__PURE__ */ V("div", {
570
+ /* @__PURE__ */ H("div", {
568
571
  className: "grid grid-cols-1 gap-4 md:grid-cols-2",
569
- children: [/* @__PURE__ */ V("div", {
572
+ children: [/* @__PURE__ */ H("div", {
570
573
  className: "space-y-2",
571
- children: [/* @__PURE__ */ B(x, {
574
+ children: [/* @__PURE__ */ V(y, {
572
575
  htmlFor: "mtw-report-frequency",
573
576
  children: "Generate"
574
- }), /* @__PURE__ */ V(S, {
577
+ }), /* @__PURE__ */ H(b, {
575
578
  value: a.frequency,
576
579
  onValueChange: (t) => {
577
- let n = M.find((e) => e.value === t);
578
- n && (h("frequency", n.value), e || c(String(Ae(n.value))));
580
+ let n = j.find((e) => e.value === t);
581
+ n && (p("frequency", n.value), e || te(String(z(n.value))));
579
582
  },
580
- children: [/* @__PURE__ */ B(T, {
583
+ children: [/* @__PURE__ */ V(C, {
581
584
  id: "mtw-report-frequency",
582
585
  "aria-label": "Generate",
583
- children: /* @__PURE__ */ B(E, {})
584
- }), /* @__PURE__ */ B(C, { children: M.map((e) => /* @__PURE__ */ B(w, {
586
+ children: /* @__PURE__ */ V(w, {})
587
+ }), /* @__PURE__ */ V(x, { children: j.map((e) => /* @__PURE__ */ V(S, {
585
588
  value: e.value,
586
589
  children: e.label
587
590
  }, e.value)) })]
588
591
  })]
589
- }), /* @__PURE__ */ V("div", {
592
+ }), /* @__PURE__ */ H("div", {
590
593
  className: "space-y-2",
591
- children: [/* @__PURE__ */ B(x, {
594
+ children: [/* @__PURE__ */ V(y, {
592
595
  htmlFor: "mtw-report-period",
593
596
  children: "Covers the last (days)"
594
- }), /* @__PURE__ */ B(b, {
597
+ }), /* @__PURE__ */ V(v, {
595
598
  id: "mtw-report-period",
596
599
  type: "number",
597
600
  inputMode: "numeric",
598
601
  min: 1,
599
602
  max: 366,
600
603
  step: 1,
601
- value: s,
604
+ value: ee,
602
605
  onChange: (e) => {
603
- f(null), c(e.target.value);
606
+ u(null), te(e.target.value);
604
607
  }
605
608
  })]
606
609
  })]
607
610
  }),
608
- a.frequency !== "NONE" && /* @__PURE__ */ V("div", {
611
+ a.frequency !== "NONE" && /* @__PURE__ */ H("div", {
609
612
  className: "grid grid-cols-1 gap-4 md:grid-cols-3",
610
613
  children: [
611
- a.frequency === "WEEKLY" && /* @__PURE__ */ V("div", {
614
+ a.frequency === "WEEKLY" && /* @__PURE__ */ H("div", {
612
615
  className: "space-y-2",
613
- children: [/* @__PURE__ */ B(x, {
616
+ children: [/* @__PURE__ */ V(y, {
614
617
  htmlFor: "mtw-report-weekday",
615
618
  children: "Day"
616
- }), /* @__PURE__ */ V(S, {
619
+ }), /* @__PURE__ */ H(b, {
617
620
  value: String(a.runWeekday),
618
- onValueChange: (e) => h("runWeekday", Number(e)),
619
- children: [/* @__PURE__ */ B(T, {
621
+ onValueChange: (e) => p("runWeekday", Number(e)),
622
+ children: [/* @__PURE__ */ V(C, {
620
623
  id: "mtw-report-weekday",
621
624
  "aria-label": "Day",
622
- children: /* @__PURE__ */ B(E, {})
623
- }), /* @__PURE__ */ B(C, { children: P.map((e, t) => /* @__PURE__ */ B(w, {
625
+ children: /* @__PURE__ */ V(w, {})
626
+ }), /* @__PURE__ */ V(x, { children: N.map((e, t) => /* @__PURE__ */ V(S, {
624
627
  value: String(t + 1),
625
628
  children: e
626
629
  }, e)) })]
627
630
  })]
628
631
  }),
629
- a.frequency === "MONTHLY" && /* @__PURE__ */ V("div", {
632
+ a.frequency === "MONTHLY" && /* @__PURE__ */ H("div", {
630
633
  className: "space-y-2",
631
- children: [/* @__PURE__ */ B(x, {
634
+ children: [/* @__PURE__ */ V(y, {
632
635
  htmlFor: "mtw-report-monthday",
633
636
  children: "Day of month"
634
- }), /* @__PURE__ */ V(S, {
637
+ }), /* @__PURE__ */ H(b, {
635
638
  value: String(a.runMonthDay),
636
- onValueChange: (e) => h("runMonthDay", Number(e)),
637
- children: [/* @__PURE__ */ B(T, {
639
+ onValueChange: (e) => p("runMonthDay", Number(e)),
640
+ children: [/* @__PURE__ */ V(C, {
638
641
  id: "mtw-report-monthday",
639
642
  "aria-label": "Day of month",
640
- children: /* @__PURE__ */ B(E, {})
641
- }), /* @__PURE__ */ B(C, {
643
+ children: /* @__PURE__ */ V(w, {})
644
+ }), /* @__PURE__ */ V(x, {
642
645
  className: "max-h-72",
643
- children: Array.from({ length: 28 }, (e, t) => /* @__PURE__ */ B(w, {
646
+ children: Array.from({ length: 28 }, (e, t) => /* @__PURE__ */ V(S, {
644
647
  value: String(t + 1),
645
648
  children: t + 1
646
649
  }, t + 1))
647
650
  })]
648
651
  })]
649
652
  }),
650
- /* @__PURE__ */ V("div", {
653
+ /* @__PURE__ */ H("div", {
651
654
  className: "space-y-2",
652
- children: [/* @__PURE__ */ B(x, {
655
+ children: [/* @__PURE__ */ V(y, {
653
656
  htmlFor: "mtw-report-hour",
654
657
  children: "Time"
655
- }), /* @__PURE__ */ V(S, {
658
+ }), /* @__PURE__ */ H(b, {
656
659
  value: String(a.runHour),
657
- onValueChange: (e) => h("runHour", Number(e)),
658
- children: [/* @__PURE__ */ B(T, {
660
+ onValueChange: (e) => p("runHour", Number(e)),
661
+ children: [/* @__PURE__ */ V(C, {
659
662
  id: "mtw-report-hour",
660
663
  "aria-label": "Time",
661
- children: /* @__PURE__ */ B(E, {})
662
- }), /* @__PURE__ */ B(C, {
664
+ children: /* @__PURE__ */ V(w, {})
665
+ }), /* @__PURE__ */ V(x, {
663
666
  className: "max-h-72",
664
- children: Array.from({ length: 24 }, (e, t) => /* @__PURE__ */ B(w, {
667
+ children: Array.from({ length: 24 }, (e, t) => /* @__PURE__ */ V(S, {
665
668
  value: String(t),
666
669
  children: `${String(t).padStart(2, "0")}:00`
667
670
  }, t))
668
671
  })]
669
672
  })]
670
673
  }),
671
- /* @__PURE__ */ V("div", {
674
+ /* @__PURE__ */ H("div", {
672
675
  className: "space-y-2",
673
- children: [/* @__PURE__ */ B(x, {
676
+ children: [/* @__PURE__ */ V(y, {
674
677
  htmlFor: "mtw-report-timezone",
675
678
  children: "Time zone"
676
- }), /* @__PURE__ */ B(b, {
679
+ }), /* @__PURE__ */ V(v, {
677
680
  id: "mtw-report-timezone",
678
681
  value: a.timezone,
679
- onChange: (e) => h("timezone", e.target.value),
682
+ onChange: (e) => p("timezone", e.target.value),
680
683
  placeholder: "Asia/Kolkata"
681
684
  })]
682
685
  })
683
686
  ]
684
687
  }),
685
- a.frequency !== "NONE" && /* @__PURE__ */ V("div", {
688
+ a.frequency !== "NONE" && /* @__PURE__ */ H("div", {
686
689
  className: "flex items-center justify-between gap-3 rounded-lg border border-border-default px-3 py-2",
687
- children: [/* @__PURE__ */ B(x, {
690
+ children: [/* @__PURE__ */ V(y, {
688
691
  htmlFor: "mtw-report-active",
689
692
  className: "text-sm",
690
693
  children: "Generate automatically"
691
- }), /* @__PURE__ */ B(ue, {
694
+ }), /* @__PURE__ */ V(fe, {
692
695
  id: "mtw-report-active",
693
696
  checked: a.isActive,
694
- onCheckedChange: (e) => h("isActive", e)
697
+ onCheckedChange: (e) => p("isActive", e)
695
698
  })]
696
699
  }),
697
- /* @__PURE__ */ B(j, { message: d }),
698
- /* @__PURE__ */ V(se, { children: [/* @__PURE__ */ B(_, {
700
+ /* @__PURE__ */ V(A, { message: l }),
701
+ /* @__PURE__ */ H(le, { children: [/* @__PURE__ */ V(m, {
699
702
  type: "button",
700
703
  variant: "outline",
701
704
  onClick: n,
702
- disabled: l,
705
+ disabled: s,
703
706
  children: "Cancel"
704
- }), /* @__PURE__ */ V(_, {
707
+ }), /* @__PURE__ */ H(m, {
705
708
  type: "submit",
706
- disabled: l,
707
- children: [l && /* @__PURE__ */ B(r, {
709
+ disabled: s,
710
+ children: [s && /* @__PURE__ */ V(r, {
708
711
  size: 16,
709
712
  className: "mr-2 animate-spin"
710
713
  }), e ? "Save report" : "Create report"]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@burdenoff/microfe-movethewheels",
3
- "version": "2026.1107.1",
3
+ "version": "2026.1107.2",
4
4
  "description": "Burdenoff MoveTheWheels Microfrontend - Logistics & Supply Chain Management Platform",
5
5
  "type": "module",
6
6
  "files": [
@@ -21,6 +21,7 @@ import {
21
21
  } from 'lucide-react';
22
22
  import { EmphasisPanel, PagePurpose } from '@burdenoff/fe-libs/ui';
23
23
  import { PermissionProvider, usePermissions } from '@burdenoff/fe-libs/shared/providers/shell';
24
+ import { clearGraphqlFetchResponseCache } from '@burdenoff/fe-libs/shared/graphql';
24
25
  import { PageLayout } from '../components/PageLayout';
25
26
  import { FormError } from '../components/FormError';
26
27
  import { Notice, useNotice } from '../components/Notice';
@@ -170,6 +171,15 @@ function ReportsWorkbench() {
170
171
  const [editing, setEditing] = useState<MtwReport | 'new' | null>(null);
171
172
  const [deleting, setDeleting] = useState<MtwReport | null>(null);
172
173
  const [reloadKey, setReloadKey] = useState(0);
174
+ // Re-read the reports after a write or an explicit refresh. The shell answers a
175
+ // repeated query from a short-lived response cache while the page is loading,
176
+ // so clear it first; otherwise a report created right after the page opened
177
+ // would be missing from the refreshed list and the selection would fall back
178
+ // to another report.
179
+ const reloadReports = useCallback(() => {
180
+ clearGraphqlFetchResponseCache();
181
+ setReloadKey((key) => key + 1);
182
+ }, []);
173
183
  const { message: notice, notify } = useNotice();
174
184
 
175
185
  const permissionsReady = Boolean(
@@ -276,7 +286,7 @@ function ReportsWorkbench() {
276
286
  if (generated.status === 'COMPLETED') notify(`"${report.name}" generated.`);
277
287
  else setActionError(generated.error ?? 'The report could not be generated.');
278
288
  setSelectedId(report.id);
279
- setReloadKey((key) => key + 1);
289
+ reloadReports();
280
290
  } catch (caught) {
281
291
  setActionError(message(caught, 'Could not generate the report'));
282
292
  } finally {
@@ -315,7 +325,7 @@ function ReportsWorkbench() {
315
325
  notify(`"${report.name}" deleted.`);
316
326
  setDeleting(null);
317
327
  if (selectedId === report.id) setSelectedId(null);
318
- setReloadKey((key) => key + 1);
328
+ reloadReports();
319
329
  } catch (caught) {
320
330
  setActionError(message(caught, 'Could not delete the report'));
321
331
  } finally {
@@ -340,7 +350,7 @@ function ReportsWorkbench() {
340
350
  notify(report ? `"${data.name}" saved.` : `"${data.name}" created.`);
341
351
  setEditing(null);
342
352
  setSelectedId(data.id);
343
- setReloadKey((key) => key + 1);
353
+ reloadReports();
344
354
  };
345
355
 
346
356
  return (
@@ -351,7 +361,7 @@ function ReportsWorkbench() {
351
361
  maxWidth="full"
352
362
  headerActions={
353
363
  <div className="flex flex-wrap gap-2">
354
- <Button variant="outline" onClick={() => setReloadKey((key) => key + 1)}>
364
+ <Button variant="outline" onClick={reloadReports}>
355
365
  <RefreshCw size={16} className="mr-2" /> Refresh
356
366
  </Button>
357
367
  {can('create') && (