@burdenoff/microfe-movethewheels 2026.1102.2 → 2026.1107.1
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/MoveTheWheelsRoot.js +148 -140
- package/dist/MoveTheWheelsRoutes.js +29 -25
- package/dist/generated/tracking-quality-operations.d.ts +467 -1
- package/dist/generated/wspace-types.d.ts +9779 -330
- package/dist/movethewheels/pages/ReportsPage.d.ts +1 -0
- package/dist/movethewheels/utils/reports.d.ts +132 -0
- package/dist/node_modules/lucide-react/dist/esm/icons/file-chart-column-increasing.js +26 -0
- package/dist/pages/ReportsPage.js +718 -0
- package/dist/utils/reports.js +202 -0
- package/package.json +3 -2
- package/src/generated/tracking-quality-operations.ts +569 -1
- package/src/generated/wspace-types.ts +11263 -380
- package/src/movethewheels/MoveTheWheelsRoot.tsx +8 -0
- package/src/movethewheels/MoveTheWheelsRoutes.tsx +4 -0
- package/src/movethewheels/pages/ReportsPage.tsx +989 -0
- package/src/movethewheels/utils/reports.ts +419 -0
|
@@ -0,0 +1,718 @@
|
|
|
1
|
+
import { CalendarClock as e } from "../node_modules/lucide-react/dist/esm/icons/calendar-clock.js";
|
|
2
|
+
import { Download as t } from "../node_modules/lucide-react/dist/esm/icons/download.js";
|
|
3
|
+
import { FileChartColumnIncreasing as n } from "../node_modules/lucide-react/dist/esm/icons/file-chart-column-increasing.js";
|
|
4
|
+
import { LoaderCircle as r } from "../node_modules/lucide-react/dist/esm/icons/loader-circle.js";
|
|
5
|
+
import { Pencil as i } from "../node_modules/lucide-react/dist/esm/icons/pencil.js";
|
|
6
|
+
import { Play as a } from "../node_modules/lucide-react/dist/esm/icons/play.js";
|
|
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";
|
|
21
|
+
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
|
+
//#region src/movethewheels/pages/ReportsPage.tsx
|
|
24
|
+
var U = {
|
|
25
|
+
currency: d,
|
|
26
|
+
distance: m,
|
|
27
|
+
weight: h
|
|
28
|
+
};
|
|
29
|
+
function ze(e, t, n) {
|
|
30
|
+
let r = URL.createObjectURL(new Blob([t], { type: n })), i = document.createElement("a");
|
|
31
|
+
i.href = r, i.download = e, document.body.appendChild(i), i.click(), i.remove(), URL.revokeObjectURL(r);
|
|
32
|
+
}
|
|
33
|
+
function W(e, t) {
|
|
34
|
+
return e instanceof Error && e.message ? e.message : t;
|
|
35
|
+
}
|
|
36
|
+
function Be(e) {
|
|
37
|
+
return e === "COMPLETED" ? "default" : e === "FAILED" ? "destructive" : e === "RUNNING" ? "secondary" : "outline";
|
|
38
|
+
}
|
|
39
|
+
function Ve(e) {
|
|
40
|
+
return `${p(e.periodStart)} – ${p(e.periodEnd)}`;
|
|
41
|
+
}
|
|
42
|
+
function He() {
|
|
43
|
+
let { workspaceId: e } = l();
|
|
44
|
+
return /* @__PURE__ */ B(H, {
|
|
45
|
+
scopeId: e ?? null,
|
|
46
|
+
gateway: "workspace",
|
|
47
|
+
children: /* @__PURE__ */ B(G, {})
|
|
48
|
+
});
|
|
49
|
+
}
|
|
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(() => ({
|
|
52
|
+
apiGatewayUrl: t,
|
|
53
|
+
authToken: d,
|
|
54
|
+
workspaceToken: f,
|
|
55
|
+
workspaceId: m,
|
|
56
|
+
tenantId: h,
|
|
57
|
+
actorId: b?.id
|
|
58
|
+
}), [
|
|
59
|
+
t,
|
|
60
|
+
d,
|
|
61
|
+
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;
|
|
68
|
+
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));
|
|
71
|
+
}).catch((t) => {
|
|
72
|
+
e || M(W(t, "Could not load the reports"));
|
|
73
|
+
}).finally(() => {
|
|
74
|
+
e || ue(!1);
|
|
75
|
+
}), () => {
|
|
76
|
+
e = !0;
|
|
77
|
+
};
|
|
78
|
+
}, [C, Ge]);
|
|
79
|
+
let Ye = Me(async (e) => {
|
|
80
|
+
Ae(!0);
|
|
81
|
+
try {
|
|
82
|
+
Ee((await u(C, we, {
|
|
83
|
+
id: e,
|
|
84
|
+
rows: { limit: 50 }
|
|
85
|
+
})).mtwReportRun);
|
|
86
|
+
} catch (e) {
|
|
87
|
+
G(W(e, "Could not load the report run"));
|
|
88
|
+
} finally {
|
|
89
|
+
Ae(!1);
|
|
90
|
+
}
|
|
91
|
+
}, [C]), $ = Q?.latestRun?.id ?? null;
|
|
92
|
+
Ne(() => {
|
|
93
|
+
if (L([]), Ee(null), !P) return;
|
|
94
|
+
let e = !1;
|
|
95
|
+
return u(C, Se, {
|
|
96
|
+
reportId: P,
|
|
97
|
+
pagination: { limit: 30 }
|
|
98
|
+
}).then((t) => {
|
|
99
|
+
e || L(t.mtwReportRuns);
|
|
100
|
+
}).catch((t) => {
|
|
101
|
+
e || G(W(t, "Could not load the run history"));
|
|
102
|
+
}), $ && Ye($), () => {
|
|
103
|
+
e = !0;
|
|
104
|
+
};
|
|
105
|
+
}, [
|
|
106
|
+
C,
|
|
107
|
+
P,
|
|
108
|
+
$,
|
|
109
|
+
Ye
|
|
110
|
+
]);
|
|
111
|
+
let Xe = async (e) => {
|
|
112
|
+
U(`generate:${e.id}`), G(null);
|
|
113
|
+
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);
|
|
116
|
+
} catch (e) {
|
|
117
|
+
G(W(e, "Could not generate the report"));
|
|
118
|
+
} finally {
|
|
119
|
+
U(null);
|
|
120
|
+
}
|
|
121
|
+
}, Ze = async (e, t) => {
|
|
122
|
+
U(`download:${e}:${t}`), G(null);
|
|
123
|
+
try {
|
|
124
|
+
let n = (await u(C, Ce, {
|
|
125
|
+
runId: e,
|
|
126
|
+
format: t
|
|
127
|
+
})).mtwReportRunExport;
|
|
128
|
+
ze(n.filename, n.content, n.contentType);
|
|
129
|
+
} catch (e) {
|
|
130
|
+
G(W(e, "Could not download the report"));
|
|
131
|
+
} finally {
|
|
132
|
+
U(null);
|
|
133
|
+
}
|
|
134
|
+
}, Qe = async (e) => {
|
|
135
|
+
U(`delete:${e.id}`), G(null);
|
|
136
|
+
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);
|
|
138
|
+
} catch (e) {
|
|
139
|
+
G(W(e, "Could not delete the report"));
|
|
140
|
+
} finally {
|
|
141
|
+
U(null);
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
return /* @__PURE__ */ V(he, {
|
|
145
|
+
title: "Reports",
|
|
146
|
+
subtitle: "Scheduled and on-demand reports over your logistics data",
|
|
147
|
+
icon: /* @__PURE__ */ B(n, { size: 24 }),
|
|
148
|
+
maxWidth: "full",
|
|
149
|
+
headerActions: /* @__PURE__ */ V("div", {
|
|
150
|
+
className: "flex flex-wrap gap-2",
|
|
151
|
+
children: [/* @__PURE__ */ V(_, {
|
|
152
|
+
variant: "outline",
|
|
153
|
+
onClick: () => X((e) => e + 1),
|
|
154
|
+
children: [/* @__PURE__ */ B(s, {
|
|
155
|
+
size: 16,
|
|
156
|
+
className: "mr-2"
|
|
157
|
+
}), " Refresh"]
|
|
158
|
+
}), Z("create") && /* @__PURE__ */ V(_, {
|
|
159
|
+
onClick: () => q("new"),
|
|
160
|
+
children: [/* @__PURE__ */ B(o, {
|
|
161
|
+
size: 16,
|
|
162
|
+
className: "mr-2"
|
|
163
|
+
}), " New report"]
|
|
164
|
+
})]
|
|
165
|
+
}),
|
|
166
|
+
children: [
|
|
167
|
+
/* @__PURE__ */ B(Le, {
|
|
168
|
+
icon: /* @__PURE__ */ B(n, { size: 18 }),
|
|
169
|
+
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
|
+
}),
|
|
171
|
+
me && /* @__PURE__ */ B(j, { message: me }),
|
|
172
|
+
/* @__PURE__ */ B(j, { message: He }),
|
|
173
|
+
/* @__PURE__ */ B(ge, { message: Ke }),
|
|
174
|
+
/* @__PURE__ */ V("div", {
|
|
175
|
+
className: "grid grid-cols-1 gap-6 xl:grid-cols-3",
|
|
176
|
+
children: [/* @__PURE__ */ V(Ie, {
|
|
177
|
+
className: "space-y-3 xl:col-span-1",
|
|
178
|
+
children: [/* @__PURE__ */ B("h2", {
|
|
179
|
+
className: "text-base font-semibold text-text-primary",
|
|
180
|
+
children: "Saved reports"
|
|
181
|
+
}), E && w.length === 0 ? /* @__PURE__ */ V("div", {
|
|
182
|
+
className: "space-y-3",
|
|
183
|
+
"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", {
|
|
186
|
+
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(_, {
|
|
188
|
+
className: "mt-4",
|
|
189
|
+
onClick: () => q("new"),
|
|
190
|
+
children: [/* @__PURE__ */ B(o, {
|
|
191
|
+
size: 16,
|
|
192
|
+
className: "mr-2"
|
|
193
|
+
}), " Create your first report"]
|
|
194
|
+
})]
|
|
195
|
+
}) : /* @__PURE__ */ B("ul", {
|
|
196
|
+
className: "space-y-2",
|
|
197
|
+
"aria-label": "Saved reports",
|
|
198
|
+
children: w.map((e) => /* @__PURE__ */ B("li", { children: /* @__PURE__ */ V("button", {
|
|
199
|
+
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
|
+
children: [
|
|
204
|
+
/* @__PURE__ */ V("span", {
|
|
205
|
+
className: "flex items-center justify-between gap-2",
|
|
206
|
+
children: [/* @__PURE__ */ B("span", {
|
|
207
|
+
className: "truncate text-sm font-medium text-text-primary",
|
|
208
|
+
children: e.name
|
|
209
|
+
}), /* @__PURE__ */ B(g, {
|
|
210
|
+
variant: "outline",
|
|
211
|
+
children: Oe(e.type)
|
|
212
|
+
})]
|
|
213
|
+
}),
|
|
214
|
+
/* @__PURE__ */ B("span", {
|
|
215
|
+
className: "mt-1 block text-xs text-text-secondary",
|
|
216
|
+
children: ke(e)
|
|
217
|
+
}),
|
|
218
|
+
/* @__PURE__ */ B("span", {
|
|
219
|
+
className: "mt-1 block text-xs text-text-tertiary",
|
|
220
|
+
children: e.lastGeneratedAt ? `Last generated ${p(e.lastGeneratedAt)}` : "Never generated"
|
|
221
|
+
})
|
|
222
|
+
]
|
|
223
|
+
}) }, e.id))
|
|
224
|
+
})]
|
|
225
|
+
}), /* @__PURE__ */ B("div", {
|
|
226
|
+
className: "space-y-6 xl:col-span-2",
|
|
227
|
+
children: Q ? /* @__PURE__ */ V(Fe, { children: [
|
|
228
|
+
/* @__PURE__ */ B(v, { children: /* @__PURE__ */ V(ne, {
|
|
229
|
+
className: "flex flex-row flex-wrap items-start justify-between gap-3",
|
|
230
|
+
children: [/* @__PURE__ */ V("div", {
|
|
231
|
+
className: "min-w-0 space-y-1",
|
|
232
|
+
children: [
|
|
233
|
+
/* @__PURE__ */ B(re, {
|
|
234
|
+
className: "text-lg",
|
|
235
|
+
children: Q.name
|
|
236
|
+
}),
|
|
237
|
+
/* @__PURE__ */ B(te, { children: Q.description || N.find((e) => e.value === Q.type)?.description }),
|
|
238
|
+
/* @__PURE__ */ V("p", {
|
|
239
|
+
className: "flex flex-wrap items-center gap-2 text-xs text-text-secondary",
|
|
240
|
+
children: [
|
|
241
|
+
/* @__PURE__ */ B(e, { size: 14 }),
|
|
242
|
+
/* @__PURE__ */ B("span", { children: ke(Q) }),
|
|
243
|
+
/* @__PURE__ */ V("span", { children: [
|
|
244
|
+
"· Covers the last ",
|
|
245
|
+
Q.periodDays,
|
|
246
|
+
" day(s)"
|
|
247
|
+
] }),
|
|
248
|
+
Q.nextRunAt && /* @__PURE__ */ V("span", { children: ["· Next run ", p(Q.nextRunAt)] })
|
|
249
|
+
]
|
|
250
|
+
})
|
|
251
|
+
]
|
|
252
|
+
}), /* @__PURE__ */ V("div", {
|
|
253
|
+
className: "flex flex-wrap gap-2",
|
|
254
|
+
children: [
|
|
255
|
+
Z("generate") && /* @__PURE__ */ V(_, {
|
|
256
|
+
onClick: () => void Xe(Q),
|
|
257
|
+
disabled: H !== null,
|
|
258
|
+
"aria-label": `Generate ${Q.name} now`,
|
|
259
|
+
children: [H === `generate:${Q.id}` ? /* @__PURE__ */ B(r, {
|
|
260
|
+
size: 16,
|
|
261
|
+
className: "mr-2 animate-spin"
|
|
262
|
+
}) : /* @__PURE__ */ B(a, {
|
|
263
|
+
size: 16,
|
|
264
|
+
className: "mr-2"
|
|
265
|
+
}), "Generate now"]
|
|
266
|
+
}),
|
|
267
|
+
Z("update") && /* @__PURE__ */ V(_, {
|
|
268
|
+
variant: "outline",
|
|
269
|
+
onClick: () => q(Q),
|
|
270
|
+
disabled: H !== null,
|
|
271
|
+
children: [/* @__PURE__ */ B(i, {
|
|
272
|
+
size: 16,
|
|
273
|
+
className: "mr-2"
|
|
274
|
+
}), " Edit"]
|
|
275
|
+
}),
|
|
276
|
+
Z("delete") && /* @__PURE__ */ B(_, {
|
|
277
|
+
variant: "outline",
|
|
278
|
+
onClick: () => Y(Q),
|
|
279
|
+
disabled: H !== null,
|
|
280
|
+
"aria-label": `Delete ${Q.name}`,
|
|
281
|
+
children: /* @__PURE__ */ B(c, { size: 16 })
|
|
282
|
+
})
|
|
283
|
+
]
|
|
284
|
+
})]
|
|
285
|
+
}) }),
|
|
286
|
+
/* @__PURE__ */ B(Ue, {
|
|
287
|
+
run: R,
|
|
288
|
+
isLoading: De,
|
|
289
|
+
hasRuns: !!Q.latestRun,
|
|
290
|
+
busy: H,
|
|
291
|
+
onDownload: (e, t) => void Ze(e, t)
|
|
292
|
+
}),
|
|
293
|
+
/* @__PURE__ */ V(v, { children: [/* @__PURE__ */ V(ne, { children: [/* @__PURE__ */ B(re, {
|
|
294
|
+
className: "text-base",
|
|
295
|
+
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", {
|
|
297
|
+
className: "text-sm text-text-secondary",
|
|
298
|
+
children: "No runs yet."
|
|
299
|
+
}) : /* @__PURE__ */ B("div", {
|
|
300
|
+
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, {
|
|
307
|
+
className: "text-right",
|
|
308
|
+
children: "Rows"
|
|
309
|
+
}),
|
|
310
|
+
/* @__PURE__ */ B(k, {
|
|
311
|
+
className: "text-right",
|
|
312
|
+
children: "Download"
|
|
313
|
+
})
|
|
314
|
+
] }) }), /* @__PURE__ */ B(fe, { children: I.map((e) => /* @__PURE__ */ V(A, {
|
|
315
|
+
className: e.id === R?.id ? "bg-surface-secondary" : void 0,
|
|
316
|
+
children: [
|
|
317
|
+
/* @__PURE__ */ B(O, { children: /* @__PURE__ */ B("button", {
|
|
318
|
+
type: "button",
|
|
319
|
+
className: "text-left font-medium text-text-primary underline-offset-2 hover:underline",
|
|
320
|
+
onClick: () => void Ye(e.id),
|
|
321
|
+
children: p(e.startedAt)
|
|
322
|
+
}) }),
|
|
323
|
+
/* @__PURE__ */ B(O, {
|
|
324
|
+
className: "whitespace-nowrap text-xs",
|
|
325
|
+
children: Ve(e)
|
|
326
|
+
}),
|
|
327
|
+
/* @__PURE__ */ B(O, { children: e.trigger === "SCHEDULED" ? "Scheduled" : "Manual" }),
|
|
328
|
+
/* @__PURE__ */ B(O, { children: /* @__PURE__ */ B(g, {
|
|
329
|
+
variant: Be(e.status),
|
|
330
|
+
children: e.status
|
|
331
|
+
}) }),
|
|
332
|
+
/* @__PURE__ */ B(O, {
|
|
333
|
+
className: "text-right",
|
|
334
|
+
children: e.rowCount.toLocaleString()
|
|
335
|
+
}),
|
|
336
|
+
/* @__PURE__ */ B(O, {
|
|
337
|
+
className: "text-right",
|
|
338
|
+
children: e.status === "COMPLETED" ? /* @__PURE__ */ B("span", {
|
|
339
|
+
className: "inline-flex gap-1",
|
|
340
|
+
children: ["CSV", "JSON"].map((t) => /* @__PURE__ */ B(_, {
|
|
341
|
+
variant: "ghost",
|
|
342
|
+
size: "sm",
|
|
343
|
+
disabled: H !== null,
|
|
344
|
+
onClick: () => void Ze(e.id, t),
|
|
345
|
+
children: t
|
|
346
|
+
}, t))
|
|
347
|
+
}) : "—"
|
|
348
|
+
})
|
|
349
|
+
]
|
|
350
|
+
}, e.id)) })] })
|
|
351
|
+
}) })] })
|
|
352
|
+
] }) : !E && /* @__PURE__ */ B(v, { children: /* @__PURE__ */ B(y, {
|
|
353
|
+
className: "p-6 text-sm text-text-secondary",
|
|
354
|
+
children: "Select a report to see its latest figures and run history."
|
|
355
|
+
}) })
|
|
356
|
+
})]
|
|
357
|
+
}),
|
|
358
|
+
K && /* @__PURE__ */ B(We, {
|
|
359
|
+
report: K === "new" ? null : K,
|
|
360
|
+
defaultTimezone: x.timezone ?? "UTC",
|
|
361
|
+
onClose: () => q(null),
|
|
362
|
+
onSave: async (e, t) => {
|
|
363
|
+
let n = t ? await u(C, Te, {
|
|
364
|
+
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
|
+
}
|
|
369
|
+
}),
|
|
370
|
+
/* @__PURE__ */ B(ie, {
|
|
371
|
+
open: J !== null,
|
|
372
|
+
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(_, {
|
|
374
|
+
variant: "outline",
|
|
375
|
+
onClick: () => Y(null),
|
|
376
|
+
children: "Cancel"
|
|
377
|
+
}), /* @__PURE__ */ V(_, {
|
|
378
|
+
variant: "destructive",
|
|
379
|
+
disabled: H !== null,
|
|
380
|
+
onClick: () => J && void Qe(J),
|
|
381
|
+
children: [H?.startsWith("delete:") && /* @__PURE__ */ B(r, {
|
|
382
|
+
size: 16,
|
|
383
|
+
className: "mr-2 animate-spin"
|
|
384
|
+
}), "Delete report"]
|
|
385
|
+
})] })] })
|
|
386
|
+
})
|
|
387
|
+
]
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
function Ue({ run: e, isLoading: n, hasRuns: i, busy: a, onDownload: o }) {
|
|
391
|
+
return n && !e ? /* @__PURE__ */ B(v, { children: /* @__PURE__ */ V(y, {
|
|
392
|
+
className: "space-y-3 p-6",
|
|
393
|
+
"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, {
|
|
396
|
+
"data-testid": "mtw-report-run",
|
|
397
|
+
children: [/* @__PURE__ */ V(ne, {
|
|
398
|
+
className: "flex flex-row flex-wrap items-start justify-between gap-3",
|
|
399
|
+
children: [/* @__PURE__ */ V("div", {
|
|
400
|
+
className: "space-y-1",
|
|
401
|
+
children: [/* @__PURE__ */ V(re, {
|
|
402
|
+
className: "text-base",
|
|
403
|
+
children: [
|
|
404
|
+
e.trigger === "SCHEDULED" ? "Scheduled run" : "Run",
|
|
405
|
+
" of",
|
|
406
|
+
" ",
|
|
407
|
+
p(e.startedAt)
|
|
408
|
+
]
|
|
409
|
+
}), /* @__PURE__ */ V(te, { children: ["Covers ", Ve(e)] })]
|
|
410
|
+
}), /* @__PURE__ */ V("div", {
|
|
411
|
+
className: "flex items-center gap-2",
|
|
412
|
+
children: [/* @__PURE__ */ B(g, {
|
|
413
|
+
variant: Be(e.status),
|
|
414
|
+
children: e.status
|
|
415
|
+
}), e.status === "COMPLETED" && ["CSV", "JSON"].map((n) => /* @__PURE__ */ V(_, {
|
|
416
|
+
variant: "outline",
|
|
417
|
+
size: "sm",
|
|
418
|
+
disabled: a !== null,
|
|
419
|
+
onClick: () => o(e.id, n),
|
|
420
|
+
children: [a === `download:${e.id}:${n}` ? /* @__PURE__ */ B(r, {
|
|
421
|
+
size: 14,
|
|
422
|
+
className: "mr-2 animate-spin"
|
|
423
|
+
}) : /* @__PURE__ */ B(t, {
|
|
424
|
+
size: 14,
|
|
425
|
+
className: "mr-2"
|
|
426
|
+
}), n]
|
|
427
|
+
}, n))]
|
|
428
|
+
})]
|
|
429
|
+
}), /* @__PURE__ */ V(y, {
|
|
430
|
+
className: "space-y-6",
|
|
431
|
+
children: [
|
|
432
|
+
e.status === "FAILED" && /* @__PURE__ */ B(j, { message: e.error ?? "This run failed." }),
|
|
433
|
+
e.metrics.length > 0 && /* @__PURE__ */ B("dl", {
|
|
434
|
+
className: "grid grid-cols-2 gap-3 md:grid-cols-3 lg:grid-cols-4",
|
|
435
|
+
children: e.metrics.map((e) => /* @__PURE__ */ V("div", {
|
|
436
|
+
className: "rounded-lg border border-border-default px-3 py-2",
|
|
437
|
+
children: [/* @__PURE__ */ B("dt", {
|
|
438
|
+
className: "text-xs text-text-secondary",
|
|
439
|
+
children: L(e)
|
|
440
|
+
}), /* @__PURE__ */ B("dd", {
|
|
441
|
+
className: "text-lg font-semibold text-text-primary",
|
|
442
|
+
children: I(e, U)
|
|
443
|
+
})]
|
|
444
|
+
}, e.key))
|
|
445
|
+
}),
|
|
446
|
+
e.status === "COMPLETED" && (e.rowCount === 0 ? /* @__PURE__ */ B("p", {
|
|
447
|
+
className: "text-sm text-text-secondary",
|
|
448
|
+
children: "The period had no rows for this report."
|
|
449
|
+
}) : /* @__PURE__ */ V("div", {
|
|
450
|
+
className: "space-y-2",
|
|
451
|
+
children: [/* @__PURE__ */ V("p", {
|
|
452
|
+
className: "text-xs text-text-secondary",
|
|
453
|
+
children: [
|
|
454
|
+
"Showing ",
|
|
455
|
+
Math.min(e.rows.length, e.rowCount).toLocaleString(),
|
|
456
|
+
" of",
|
|
457
|
+
" ",
|
|
458
|
+
e.rowCount.toLocaleString(),
|
|
459
|
+
" rows. Download the run for all of them.",
|
|
460
|
+
e.truncated && " The period had more rows than a run keeps (5,000); the figures above still cover all of them."
|
|
461
|
+
]
|
|
462
|
+
}), /* @__PURE__ */ B("div", {
|
|
463
|
+
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, {
|
|
465
|
+
className: "whitespace-nowrap",
|
|
466
|
+
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, {
|
|
468
|
+
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))
|
|
470
|
+
}, e.key)) }, n)) })] })
|
|
471
|
+
})]
|
|
472
|
+
}))
|
|
473
|
+
]
|
|
474
|
+
})]
|
|
475
|
+
}) : /* @__PURE__ */ B(v, { children: /* @__PURE__ */ B(y, {
|
|
476
|
+
className: "p-6 text-sm text-text-secondary",
|
|
477
|
+
children: i ? "Select a run to preview it." : "This report has not been generated yet. Use \"Generate now\" to produce the first run."
|
|
478
|
+
}) });
|
|
479
|
+
}
|
|
480
|
+
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 = {
|
|
482
|
+
...a,
|
|
483
|
+
periodDays: Number(s)
|
|
484
|
+
}, m = Ee(p), h = (e, t) => {
|
|
485
|
+
f(null), o((n) => ({
|
|
486
|
+
...n,
|
|
487
|
+
[e]: t
|
|
488
|
+
}));
|
|
489
|
+
}, ee = async (t) => {
|
|
490
|
+
if (t.preventDefault(), m) {
|
|
491
|
+
f(m);
|
|
492
|
+
return;
|
|
493
|
+
}
|
|
494
|
+
u(!0), f(null);
|
|
495
|
+
try {
|
|
496
|
+
await i(p, e);
|
|
497
|
+
} catch (e) {
|
|
498
|
+
f(W(e, "Could not save the report"));
|
|
499
|
+
} finally {
|
|
500
|
+
u(!1);
|
|
501
|
+
}
|
|
502
|
+
};
|
|
503
|
+
return /* @__PURE__ */ B(ie, {
|
|
504
|
+
open: !0,
|
|
505
|
+
onOpenChange: (e) => !e && !l && n(),
|
|
506
|
+
children: /* @__PURE__ */ V(ae, {
|
|
507
|
+
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", {
|
|
509
|
+
className: "space-y-4",
|
|
510
|
+
onSubmit: (e) => void ee(e),
|
|
511
|
+
"aria-label": "Report",
|
|
512
|
+
children: [
|
|
513
|
+
/* @__PURE__ */ V("div", {
|
|
514
|
+
className: "space-y-2",
|
|
515
|
+
children: [/* @__PURE__ */ B(x, {
|
|
516
|
+
htmlFor: "mtw-report-name",
|
|
517
|
+
children: "Name"
|
|
518
|
+
}), /* @__PURE__ */ B(b, {
|
|
519
|
+
id: "mtw-report-name",
|
|
520
|
+
value: a.name,
|
|
521
|
+
maxLength: 120,
|
|
522
|
+
onChange: (e) => h("name", e.target.value),
|
|
523
|
+
placeholder: "Weekly operations review"
|
|
524
|
+
})]
|
|
525
|
+
}),
|
|
526
|
+
/* @__PURE__ */ V("div", {
|
|
527
|
+
className: "space-y-2",
|
|
528
|
+
children: [
|
|
529
|
+
/* @__PURE__ */ B(x, {
|
|
530
|
+
htmlFor: "mtw-report-type",
|
|
531
|
+
children: "Report type"
|
|
532
|
+
}),
|
|
533
|
+
/* @__PURE__ */ V(S, {
|
|
534
|
+
value: a.type,
|
|
535
|
+
onValueChange: (e) => {
|
|
536
|
+
let t = N.find((t) => t.value === e);
|
|
537
|
+
t && h("type", t.value);
|
|
538
|
+
},
|
|
539
|
+
children: [/* @__PURE__ */ B(T, {
|
|
540
|
+
id: "mtw-report-type",
|
|
541
|
+
"aria-label": "Report type",
|
|
542
|
+
children: /* @__PURE__ */ B(E, {})
|
|
543
|
+
}), /* @__PURE__ */ B(C, { children: N.map((e) => /* @__PURE__ */ B(w, {
|
|
544
|
+
value: e.value,
|
|
545
|
+
children: e.label
|
|
546
|
+
}, e.value)) })]
|
|
547
|
+
}),
|
|
548
|
+
/* @__PURE__ */ B("p", {
|
|
549
|
+
className: "text-xs text-text-secondary",
|
|
550
|
+
children: N.find((e) => e.value === a.type)?.description
|
|
551
|
+
})
|
|
552
|
+
]
|
|
553
|
+
}),
|
|
554
|
+
/* @__PURE__ */ V("div", {
|
|
555
|
+
className: "space-y-2",
|
|
556
|
+
children: [/* @__PURE__ */ B(x, {
|
|
557
|
+
htmlFor: "mtw-report-description",
|
|
558
|
+
children: "Description (optional)"
|
|
559
|
+
}), /* @__PURE__ */ B(me, {
|
|
560
|
+
id: "mtw-report-description",
|
|
561
|
+
value: a.description,
|
|
562
|
+
maxLength: 1e3,
|
|
563
|
+
rows: 2,
|
|
564
|
+
onChange: (e) => h("description", e.target.value)
|
|
565
|
+
})]
|
|
566
|
+
}),
|
|
567
|
+
/* @__PURE__ */ V("div", {
|
|
568
|
+
className: "grid grid-cols-1 gap-4 md:grid-cols-2",
|
|
569
|
+
children: [/* @__PURE__ */ V("div", {
|
|
570
|
+
className: "space-y-2",
|
|
571
|
+
children: [/* @__PURE__ */ B(x, {
|
|
572
|
+
htmlFor: "mtw-report-frequency",
|
|
573
|
+
children: "Generate"
|
|
574
|
+
}), /* @__PURE__ */ V(S, {
|
|
575
|
+
value: a.frequency,
|
|
576
|
+
onValueChange: (t) => {
|
|
577
|
+
let n = M.find((e) => e.value === t);
|
|
578
|
+
n && (h("frequency", n.value), e || c(String(Ae(n.value))));
|
|
579
|
+
},
|
|
580
|
+
children: [/* @__PURE__ */ B(T, {
|
|
581
|
+
id: "mtw-report-frequency",
|
|
582
|
+
"aria-label": "Generate",
|
|
583
|
+
children: /* @__PURE__ */ B(E, {})
|
|
584
|
+
}), /* @__PURE__ */ B(C, { children: M.map((e) => /* @__PURE__ */ B(w, {
|
|
585
|
+
value: e.value,
|
|
586
|
+
children: e.label
|
|
587
|
+
}, e.value)) })]
|
|
588
|
+
})]
|
|
589
|
+
}), /* @__PURE__ */ V("div", {
|
|
590
|
+
className: "space-y-2",
|
|
591
|
+
children: [/* @__PURE__ */ B(x, {
|
|
592
|
+
htmlFor: "mtw-report-period",
|
|
593
|
+
children: "Covers the last (days)"
|
|
594
|
+
}), /* @__PURE__ */ B(b, {
|
|
595
|
+
id: "mtw-report-period",
|
|
596
|
+
type: "number",
|
|
597
|
+
inputMode: "numeric",
|
|
598
|
+
min: 1,
|
|
599
|
+
max: 366,
|
|
600
|
+
step: 1,
|
|
601
|
+
value: s,
|
|
602
|
+
onChange: (e) => {
|
|
603
|
+
f(null), c(e.target.value);
|
|
604
|
+
}
|
|
605
|
+
})]
|
|
606
|
+
})]
|
|
607
|
+
}),
|
|
608
|
+
a.frequency !== "NONE" && /* @__PURE__ */ V("div", {
|
|
609
|
+
className: "grid grid-cols-1 gap-4 md:grid-cols-3",
|
|
610
|
+
children: [
|
|
611
|
+
a.frequency === "WEEKLY" && /* @__PURE__ */ V("div", {
|
|
612
|
+
className: "space-y-2",
|
|
613
|
+
children: [/* @__PURE__ */ B(x, {
|
|
614
|
+
htmlFor: "mtw-report-weekday",
|
|
615
|
+
children: "Day"
|
|
616
|
+
}), /* @__PURE__ */ V(S, {
|
|
617
|
+
value: String(a.runWeekday),
|
|
618
|
+
onValueChange: (e) => h("runWeekday", Number(e)),
|
|
619
|
+
children: [/* @__PURE__ */ B(T, {
|
|
620
|
+
id: "mtw-report-weekday",
|
|
621
|
+
"aria-label": "Day",
|
|
622
|
+
children: /* @__PURE__ */ B(E, {})
|
|
623
|
+
}), /* @__PURE__ */ B(C, { children: P.map((e, t) => /* @__PURE__ */ B(w, {
|
|
624
|
+
value: String(t + 1),
|
|
625
|
+
children: e
|
|
626
|
+
}, e)) })]
|
|
627
|
+
})]
|
|
628
|
+
}),
|
|
629
|
+
a.frequency === "MONTHLY" && /* @__PURE__ */ V("div", {
|
|
630
|
+
className: "space-y-2",
|
|
631
|
+
children: [/* @__PURE__ */ B(x, {
|
|
632
|
+
htmlFor: "mtw-report-monthday",
|
|
633
|
+
children: "Day of month"
|
|
634
|
+
}), /* @__PURE__ */ V(S, {
|
|
635
|
+
value: String(a.runMonthDay),
|
|
636
|
+
onValueChange: (e) => h("runMonthDay", Number(e)),
|
|
637
|
+
children: [/* @__PURE__ */ B(T, {
|
|
638
|
+
id: "mtw-report-monthday",
|
|
639
|
+
"aria-label": "Day of month",
|
|
640
|
+
children: /* @__PURE__ */ B(E, {})
|
|
641
|
+
}), /* @__PURE__ */ B(C, {
|
|
642
|
+
className: "max-h-72",
|
|
643
|
+
children: Array.from({ length: 28 }, (e, t) => /* @__PURE__ */ B(w, {
|
|
644
|
+
value: String(t + 1),
|
|
645
|
+
children: t + 1
|
|
646
|
+
}, t + 1))
|
|
647
|
+
})]
|
|
648
|
+
})]
|
|
649
|
+
}),
|
|
650
|
+
/* @__PURE__ */ V("div", {
|
|
651
|
+
className: "space-y-2",
|
|
652
|
+
children: [/* @__PURE__ */ B(x, {
|
|
653
|
+
htmlFor: "mtw-report-hour",
|
|
654
|
+
children: "Time"
|
|
655
|
+
}), /* @__PURE__ */ V(S, {
|
|
656
|
+
value: String(a.runHour),
|
|
657
|
+
onValueChange: (e) => h("runHour", Number(e)),
|
|
658
|
+
children: [/* @__PURE__ */ B(T, {
|
|
659
|
+
id: "mtw-report-hour",
|
|
660
|
+
"aria-label": "Time",
|
|
661
|
+
children: /* @__PURE__ */ B(E, {})
|
|
662
|
+
}), /* @__PURE__ */ B(C, {
|
|
663
|
+
className: "max-h-72",
|
|
664
|
+
children: Array.from({ length: 24 }, (e, t) => /* @__PURE__ */ B(w, {
|
|
665
|
+
value: String(t),
|
|
666
|
+
children: `${String(t).padStart(2, "0")}:00`
|
|
667
|
+
}, t))
|
|
668
|
+
})]
|
|
669
|
+
})]
|
|
670
|
+
}),
|
|
671
|
+
/* @__PURE__ */ V("div", {
|
|
672
|
+
className: "space-y-2",
|
|
673
|
+
children: [/* @__PURE__ */ B(x, {
|
|
674
|
+
htmlFor: "mtw-report-timezone",
|
|
675
|
+
children: "Time zone"
|
|
676
|
+
}), /* @__PURE__ */ B(b, {
|
|
677
|
+
id: "mtw-report-timezone",
|
|
678
|
+
value: a.timezone,
|
|
679
|
+
onChange: (e) => h("timezone", e.target.value),
|
|
680
|
+
placeholder: "Asia/Kolkata"
|
|
681
|
+
})]
|
|
682
|
+
})
|
|
683
|
+
]
|
|
684
|
+
}),
|
|
685
|
+
a.frequency !== "NONE" && /* @__PURE__ */ V("div", {
|
|
686
|
+
className: "flex items-center justify-between gap-3 rounded-lg border border-border-default px-3 py-2",
|
|
687
|
+
children: [/* @__PURE__ */ B(x, {
|
|
688
|
+
htmlFor: "mtw-report-active",
|
|
689
|
+
className: "text-sm",
|
|
690
|
+
children: "Generate automatically"
|
|
691
|
+
}), /* @__PURE__ */ B(ue, {
|
|
692
|
+
id: "mtw-report-active",
|
|
693
|
+
checked: a.isActive,
|
|
694
|
+
onCheckedChange: (e) => h("isActive", e)
|
|
695
|
+
})]
|
|
696
|
+
}),
|
|
697
|
+
/* @__PURE__ */ B(j, { message: d }),
|
|
698
|
+
/* @__PURE__ */ V(se, { children: [/* @__PURE__ */ B(_, {
|
|
699
|
+
type: "button",
|
|
700
|
+
variant: "outline",
|
|
701
|
+
onClick: n,
|
|
702
|
+
disabled: l,
|
|
703
|
+
children: "Cancel"
|
|
704
|
+
}), /* @__PURE__ */ V(_, {
|
|
705
|
+
type: "submit",
|
|
706
|
+
disabled: l,
|
|
707
|
+
children: [l && /* @__PURE__ */ B(r, {
|
|
708
|
+
size: 16,
|
|
709
|
+
className: "mr-2 animate-spin"
|
|
710
|
+
}), e ? "Save report" : "Create report"]
|
|
711
|
+
})] })
|
|
712
|
+
]
|
|
713
|
+
})]
|
|
714
|
+
})
|
|
715
|
+
});
|
|
716
|
+
}
|
|
717
|
+
//#endregion
|
|
718
|
+
export { He as default };
|