@bahmni/reports-app 0.0.1-dev.455 → 0.0.1-dev.457

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.
Files changed (33) hide show
  1. package/dist/{DocumentsTable-DZ1zyEeJ-DABASslp.js → DocumentsTable-BY19cMyH-C_hDo9LW.js} +61 -61
  2. package/dist/{FormsTable-C1Yy7yQt-CNwCapgX.js → FormsTable-D04JNgYd-DHkJQESF.js} +57 -57
  3. package/dist/{LNWAZHJI-pbosfkqW.js → LNWAZHJI-Dp9-DjTn.js} +10 -10
  4. package/dist/{MWZ6AO7Z-a_vR_MdQ.js → MWZ6AO7Z-DCN3dl79.js} +7 -7
  5. package/dist/{Observations-D079FoDG-BGwIPW_z.js → Observations-B0V1ebXI-M-Exclxs.js} +21 -21
  6. package/dist/ReportsPage-DHGuOQY_.js +887 -0
  7. package/dist/{YPM2AS64-Cp3d5iX-.js → YPM2AS64-Dx-EiwQF.js} +1 -1
  8. package/dist/components/ReportList/ReportList.d.ts.map +1 -1
  9. package/dist/components/ReportList/ReportsTable.d.ts +1 -0
  10. package/dist/components/ReportList/ReportsTable.d.ts.map +1 -1
  11. package/dist/components/ReportList/TableFilters.d.ts.map +1 -1
  12. package/dist/components/ReportList/appConfigSchema.json.d.ts +4 -0
  13. package/dist/components/ReportList/constants.d.ts +2 -1
  14. package/dist/components/ReportList/constants.d.ts.map +1 -1
  15. package/dist/components/ReportList/models.d.ts +3 -0
  16. package/dist/components/ReportList/models.d.ts.map +1 -1
  17. package/dist/components/ReportList/utils.d.ts +4 -0
  18. package/dist/components/ReportList/utils.d.ts.map +1 -1
  19. package/dist/hooks/useQueueReport.d.ts +7 -0
  20. package/dist/hooks/useQueueReport.d.ts.map +1 -0
  21. package/dist/hooks/useReportTableState.d.ts +10 -2
  22. package/dist/hooks/useReportTableState.d.ts.map +1 -1
  23. package/dist/hooks/useRunReport.d.ts +1 -1
  24. package/dist/hooks/useRunReport.d.ts.map +1 -1
  25. package/dist/{index-j-6IAmqw.js → index-D-SD6TFa.js} +29047 -28995
  26. package/dist/index.css +1 -1
  27. package/dist/index.js +2 -2
  28. package/dist/locales/locale_en.json +16 -0
  29. package/dist/locales/locale_es.json +16 -0
  30. package/dist/utils/reportAuditEvent.d.ts +8 -0
  31. package/dist/utils/reportAuditEvent.d.ts.map +1 -0
  32. package/package.json +1 -1
  33. package/dist/ReportsPage-CcVV2dV0.js +0 -666
@@ -0,0 +1,887 @@
1
+ import { jsx as r, jsxs as S, Fragment as K } from "react/jsx-runtime";
2
+ import { F as de, G as me, L as Se, O as fe, Q as Oe, V as ge, a0 as Pe, a1 as Ae, a2 as he, a3 as Re, a4 as Le, u as w, z as ce, a5 as De, a6 as q, a7 as Q, a8 as j, a9 as Ce, aa as be, ab as Ne, ac as J, ad as Z, Z as ye, ae as Ie, af as Me, ag as ee, ah as Fe, ai as te, aj as Be, ak as Ue, al as ve, am as He, an as ae, ao as Ye, ap as ne, aq as we, ar as xe } from "./index-D-SD6TFa.js";
3
+ import qe, { useCallback as V, useState as A, useEffect as _e, useMemo as x } from "react";
4
+ import { useQuery as ue } from "@tanstack/react-query";
5
+ import { useLocation as Qe, useNavigate as Ge } from "react-router-dom";
6
+ const $e = "http://json-schema.org/draft-07/schema#", Xe = "Reports App Configuration", je = "object", ke = { config: { type: "object", properties: { supportedFormats: { type: "array", items: { type: "string" }, description: "List of supported report formats" }, paperSize: { type: "string", description: "Default paper size for generated reports (e.g., A4)" }, enableReportQueue: { type: "boolean", description: "Whether reports can be queued (run asynchronously) in addition to running immediately" } }, additionalProperties: !0 } }, ze = !0, Ve = {
7
+ $schema: $e,
8
+ title: Xe,
9
+ type: je,
10
+ properties: ke,
11
+ additionalProperties: ze
12
+ }, We = {
13
+ PDF: "REPORTS_FORMAT_PDF",
14
+ CSV: "REPORTS_FORMAT_CSV",
15
+ HTML: "REPORTS_FORMAT_HTML",
16
+ EXCEL: "REPORTS_FORMAT_EXCEL",
17
+ "CUSTOM EXCEL": "REPORTS_FORMAT_CUSTOM_EXCEL",
18
+ ODS: "REPORTS_FORMAT_ODS"
19
+ }, Ke = [
20
+ "TODAY",
21
+ "THIS_MONTH",
22
+ "PREVIOUS_MONTH",
23
+ "THIS_QUARTER",
24
+ "THIS_YEAR",
25
+ "LAST_7_DAYS",
26
+ "LAST_30_DAYS"
27
+ ], Je = {
28
+ TODAY: "REPORTS_PRESET_TODAY",
29
+ THIS_MONTH: "REPORTS_PRESET_THIS_MONTH",
30
+ PREVIOUS_MONTH: "REPORTS_PRESET_PREVIOUS_MONTH",
31
+ THIS_QUARTER: "REPORTS_PRESET_THIS_QUARTER",
32
+ THIS_YEAR: "REPORTS_PRESET_THIS_YEAR",
33
+ LAST_7_DAYS: "REPORTS_PRESET_LAST_7_DAYS",
34
+ LAST_30_DAYS: "REPORTS_PRESET_LAST_30_DAYS"
35
+ }, Te = {
36
+ reportsConfig: ["reportsConfig"],
37
+ reportsAppConfig: ["reportsAppConfig"]
38
+ }, Ze = [".xls", ".xlsx"], et = () => ue({
39
+ queryKey: Te.reportsAppConfig,
40
+ queryFn: async () => {
41
+ try {
42
+ return await de(
43
+ me,
44
+ Ve
45
+ );
46
+ } catch {
47
+ return {};
48
+ }
49
+ }
50
+ }), tt = "http://json-schema.org/draft-07/schema#", at = "Reports Configuration", nt = "object", rt = { type: "object", required: ["name", "type"], properties: { name: { type: "string", description: "Display name of the report" }, type: { type: "string", description: "Report generator type" }, requiredPrivilege: { type: "string", description: "Privilege required to view/run this report" }, config: { type: "object", properties: { dateRangeRequired: { type: "boolean", description: "Whether this report requires a date range (defaults to true)" }, paperSize: { type: "string", description: "Paper size for PDF generation (e.g., A4)" }, macroTemplatePath: { type: "string", description: "Path to macro template for custom Excel reports" } }, additionalProperties: !0 } } }, st = {
51
+ $schema: tt,
52
+ title: at,
53
+ type: nt,
54
+ additionalProperties: rt
55
+ }, ot = () => ue({
56
+ queryKey: Te.reportsConfig,
57
+ queryFn: () => de(Se, st),
58
+ retry: !1
59
+ }), re = Symbol.for("constructDateFrom");
60
+ function G(e, t) {
61
+ return typeof e == "function" ? e(t) : e && typeof e == "object" && re in e ? e[re](t) : e instanceof Date ? new e.constructor(t) : new Date(t);
62
+ }
63
+ function U(e, t) {
64
+ return G(e, e);
65
+ }
66
+ function it(e, t, a) {
67
+ const l = U(e);
68
+ return isNaN(t) ? G(e, NaN) : (t && l.setDate(l.getDate() + t), l);
69
+ }
70
+ function lt(e, t, a) {
71
+ const l = U(e);
72
+ if (isNaN(t)) return G(e, NaN);
73
+ const o = l.getDate(), s = G(e, l.getTime());
74
+ s.setMonth(l.getMonth() + t + 1, 0);
75
+ const _ = s.getDate();
76
+ return o >= _ ? s : (l.setFullYear(
77
+ s.getFullYear(),
78
+ s.getMonth(),
79
+ o
80
+ ), l);
81
+ }
82
+ function dt(e, t) {
83
+ const a = U(e), l = a.getMonth();
84
+ return a.setFullYear(a.getFullYear(), l + 1, 0), a.setHours(23, 59, 59, 999), a;
85
+ }
86
+ function Rt(e, t) {
87
+ const a = U(e), l = a.getMonth(), o = l - l % 3;
88
+ return a.setMonth(o, 1), a.setHours(0, 0, 0, 0), a;
89
+ }
90
+ function se(e, t) {
91
+ const a = U(e);
92
+ return a.setDate(1), a.setHours(0, 0, 0, 0), a;
93
+ }
94
+ function ct(e, t) {
95
+ const a = U(e);
96
+ return a.setFullYear(a.getFullYear(), 0, 1), a.setHours(0, 0, 0, 0), a;
97
+ }
98
+ function oe(e, t, a) {
99
+ return it(e, -t);
100
+ }
101
+ function _t(e, t, a) {
102
+ return lt(e, -1);
103
+ }
104
+ const ut = (e, t) => t ? ge(e, t) : !0, Tt = (e, t) => e.filter(
105
+ (a) => ut(t, a.requiredPrivilege)
106
+ ), Y = (e) => e.config?.dateRangeRequired !== !1, Et = (e) => ({
107
+ dateRangeReports: e.filter(Y),
108
+ noDateRangeReports: e.filter((t) => !Y(t))
109
+ }), pt = (e) => !e || e.length === 0 ? fe : e.map(
110
+ (a) => a.toUpperCase()
111
+ ).filter((a) => a in Oe), mt = (e) => {
112
+ const t = /* @__PURE__ */ new Date();
113
+ switch (e) {
114
+ case "THIS_MONTH":
115
+ return [se(t), t];
116
+ case "PREVIOUS_MONTH": {
117
+ const a = _t(t);
118
+ return [se(a), dt(a)];
119
+ }
120
+ case "THIS_QUARTER":
121
+ return [Rt(t), t];
122
+ case "THIS_YEAR":
123
+ return [ct(t), t];
124
+ case "LAST_7_DAYS":
125
+ return [oe(t, 7), t];
126
+ case "LAST_30_DAYS":
127
+ return [oe(t, 30), t];
128
+ default:
129
+ return [new Date(t), new Date(t)];
130
+ }
131
+ }, Ee = (e) => (t) => t ? e(We[t]) : "", k = (e, t) => t ?? e.config?.macroTemplatePath ?? null, St = (e, t) => {
132
+ const {
133
+ report: a,
134
+ requiresDateRange: l,
135
+ format: o,
136
+ startDate: s,
137
+ endDate: _,
138
+ templateLocation: E
139
+ } = e;
140
+ return o ? o === "CUSTOM EXCEL" && !k(a, E) ? {
141
+ field: "format",
142
+ message: t("REPORTS_MISSING_TEMPLATE_ERROR", {
143
+ reportName: a.name
144
+ })
145
+ } : l && (!s || !_) ? !s && !_ ? {
146
+ field: "startDate",
147
+ message: t("REPORTS_MISSING_BOTH_DATES_ERROR")
148
+ } : s ? {
149
+ field: "endDate",
150
+ message: t("REPORTS_MISSING_END_DATE_ERROR")
151
+ } : {
152
+ field: "startDate",
153
+ message: t("REPORTS_MISSING_START_DATE_ERROR")
154
+ } : s && _ && s > _ ? {
155
+ field: "endDate",
156
+ message: t("REPORTS_DATE_ORDER_ERROR")
157
+ } : a.type === "concatenated" && o === "CSV" ? {
158
+ message: t("REPORTS_CSV_NOT_SUPPORTED_ERROR")
159
+ } : null : {
160
+ field: "format",
161
+ message: t("REPORTS_SELECT_FORMAT_ERROR", {
162
+ reportName: a.name
163
+ })
164
+ };
165
+ }, ft = (e) => Object.entries(e).map(([t, a]) => ({
166
+ id: t,
167
+ ...a
168
+ })), pe = (e, t) => {
169
+ Pe({
170
+ eventType: e.eventType,
171
+ messageParams: { reportName: t },
172
+ module: e.module
173
+ });
174
+ }, Ot = () => {
175
+ const { user: e } = Ae();
176
+ return { queueReport: V(
177
+ async (a, l, o, s, _, E) => {
178
+ if (!e?.username)
179
+ return console.error("Error queueing report: no current user"), !1;
180
+ try {
181
+ return await he({
182
+ reportName: a.name,
183
+ reportFormat: l,
184
+ userName: e.username,
185
+ startDate: o,
186
+ endDate: s,
187
+ paperSize: a.config?.paperSize ?? _,
188
+ macroTemplateLocation: E
189
+ }), pe(
190
+ Re.RUN_REPORT,
191
+ a.name
192
+ ), !0;
193
+ } catch (p) {
194
+ return console.error("Error queueing report:", p), !1;
195
+ }
196
+ },
197
+ [e?.username]
198
+ ) };
199
+ }, gt = () => ({ runReport: V(
200
+ (t, a, l, o, s, _) => {
201
+ try {
202
+ const E = Le(
203
+ t.name,
204
+ a,
205
+ l,
206
+ o,
207
+ t.config?.paperSize ?? s,
208
+ void 0,
209
+ _
210
+ ), p = window.open(E, "_blank");
211
+ return p ? (p.opener = null, pe(
212
+ Re.RUN_REPORT,
213
+ t.name
214
+ ), !0) : !1;
215
+ } catch (E) {
216
+ return console.error("Error running report:", E), !1;
217
+ }
218
+ },
219
+ []
220
+ ) }), Pt = (e, t, a, l) => {
221
+ const { t: o } = w(), { addNotification: s } = ce(), { runReport: _ } = gt(), { queueReport: E } = Ot(), [p, h] = A({}), [D, c] = A({}), [u, P] = A(null), [b, N] = A(null), [L, R] = A(
222
+ null
223
+ );
224
+ _e(() => {
225
+ h({}), c({});
226
+ }, [t.version]);
227
+ const m = (n) => p[n] ?? {
228
+ startDate: t.startDate,
229
+ endDate: t.endDate,
230
+ format: t.format
231
+ }, f = (n, i) => h((d) => ({
232
+ ...d,
233
+ [n]: { ...m(n), ...i }
234
+ })), C = (n, i) => c((d) => {
235
+ if (!d[n]?.[i]) return d;
236
+ const T = { ...d[n], [i]: void 0 };
237
+ return { ...d, [n]: T };
238
+ }), y = (n, i, d) => {
239
+ if (d.field === "format")
240
+ c((T) => ({
241
+ ...T,
242
+ [n]: { format: d.message }
243
+ }));
244
+ else if (d.field === "startDate" || d.field === "endDate") {
245
+ const T = !i.startDate && !i.endDate;
246
+ c((B) => ({
247
+ ...B,
248
+ [n]: {
249
+ startDate: d.field === "startDate" || T ? d.message : void 0,
250
+ endDate: d.field === "endDate" || T ? d.message : void 0
251
+ }
252
+ }));
253
+ }
254
+ }, v = (n) => {
255
+ const i = m(n.id), d = St(
256
+ {
257
+ report: n,
258
+ requiresDateRange: Y(n),
259
+ format: i.format,
260
+ startDate: i.startDate,
261
+ endDate: i.endDate,
262
+ templateLocation: i.templateLocation
263
+ },
264
+ (T, B) => o(T, { defaultValue: T, ...B })
265
+ );
266
+ return { filters: i, validationErr: d };
267
+ }, I = (n, i) => {
268
+ if (i.format === "CUSTOM EXCEL") {
269
+ const d = a.find((T) => T !== "CUSTOM EXCEL") ?? null;
270
+ f(n, {
271
+ format: d,
272
+ templateLocation: null
273
+ });
274
+ }
275
+ }, M = (n) => {
276
+ const { filters: i, validationErr: d } = v(n);
277
+ return d ? (s({
278
+ title: o("REPORTS_VALIDATION_ERROR_TITLE"),
279
+ message: d.message,
280
+ type: "error"
281
+ }), y(n.id, i, d), null) : (c((T) => {
282
+ if (!(n.id in T)) return T;
283
+ const B = { ...T };
284
+ return delete B[n.id], B;
285
+ }), i);
286
+ };
287
+ return {
288
+ rowFilters: m,
289
+ errors: (n) => D[n],
290
+ isRunning: (n) => u === n,
291
+ isQueuing: (n) => b === n,
292
+ isUploadingTemplate: (n) => L === n,
293
+ updateRow: f,
294
+ clearRowFieldError: C,
295
+ handleRunReport: (n) => {
296
+ const i = M(n);
297
+ if (!i) return;
298
+ if (P(n.id), !_(
299
+ n,
300
+ i.format,
301
+ i.startDate,
302
+ i.endDate,
303
+ l,
304
+ k(n, i.templateLocation)
305
+ )) {
306
+ P(null), s({
307
+ title: o("REPORTS_ERROR_TITLE"),
308
+ message: o("REPORTS_POPUP_BLOCKED_ERROR"),
309
+ type: "error"
310
+ });
311
+ return;
312
+ }
313
+ I(n.id, i), setTimeout(() => {
314
+ P((T) => T === n.id ? null : T);
315
+ }, 300);
316
+ },
317
+ handleQueueReport: async (n) => {
318
+ const i = M(n);
319
+ if (!i) return;
320
+ N(n.id);
321
+ const d = await E(
322
+ n,
323
+ i.format,
324
+ i.startDate,
325
+ i.endDate,
326
+ l,
327
+ k(n, i.templateLocation)
328
+ );
329
+ if (N((T) => T === n.id ? null : T), !d) {
330
+ s({
331
+ title: o("REPORTS_ERROR_TITLE"),
332
+ message: o("REPORTS_QUEUE_ERROR_MESSAGE"),
333
+ type: "error"
334
+ });
335
+ return;
336
+ }
337
+ s({
338
+ title: o("REPORTS_QUEUE_SUCCESS_TITLE"),
339
+ message: o("REPORTS_QUEUE_SUCCESS_MESSAGE", { reportName: n.name }),
340
+ type: "success"
341
+ }), I(n.id, i);
342
+ },
343
+ handleTemplateUpload: async (n, i) => {
344
+ R(n.id);
345
+ try {
346
+ const d = await De(i);
347
+ f(n.id, { templateLocation: d }), C(n.id, "format");
348
+ } catch (d) {
349
+ console.error("Error uploading template:", d), s({
350
+ title: o("REPORTS_ERROR_TITLE"),
351
+ message: o("REPORTS_UPLOAD_ERROR"),
352
+ type: "error"
353
+ });
354
+ } finally {
355
+ R(
356
+ (d) => d === n.id ? null : d
357
+ );
358
+ }
359
+ }
360
+ };
361
+ }, At = "ReportsTable-module_tableContainer__-0YY7", ht = "ReportsTable-module_table__4ySYm", Lt = "ReportsTable-module_actionsColumn__Haj2L", Dt = "ReportsTable-module_nameColumn__BXFAo", Ct = "ReportsTable-module_dateColumn__zPT-K", bt = "ReportsTable-module_formatColumn__J0nQX", Nt = "ReportsTable-module_nameColumnWide__9NELB", yt = "ReportsTable-module_preconfiguredTemplateLabel__caPze", It = "ReportsTable-module_emptyState__nMhOo", O = {
362
+ tableContainer: At,
363
+ table: ht,
364
+ actionsColumn: Lt,
365
+ nameColumn: Dt,
366
+ dateColumn: Ct,
367
+ formatColumn: bt,
368
+ nameColumnWide: Nt,
369
+ preconfiguredTemplateLabel: yt,
370
+ emptyState: It
371
+ }, z = qe.memo(
372
+ ({
373
+ reports: e,
374
+ appliedFilters: t,
375
+ availableFormats: a,
376
+ defaultPaperSize: l,
377
+ enableReportQueue: o
378
+ }) => {
379
+ const { t: s } = w(), {
380
+ rowFilters: _,
381
+ errors: E,
382
+ isRunning: p,
383
+ isQueuing: h,
384
+ isUploadingTemplate: D,
385
+ updateRow: c,
386
+ clearRowFieldError: u,
387
+ handleRunReport: P,
388
+ handleQueueReport: b,
389
+ handleTemplateUpload: N
390
+ } = Pt(
391
+ e,
392
+ t,
393
+ a,
394
+ l
395
+ );
396
+ if (e.length === 0)
397
+ return /* @__PURE__ */ r("div", { className: O.emptyState, "data-testid": "reports-table-empty", children: s("REPORTS_NO_REPORTS_IN_SECTION") });
398
+ const L = e.some(Y);
399
+ return /* @__PURE__ */ r("div", { className: O.tableContainer, children: /* @__PURE__ */ S(
400
+ "table",
401
+ {
402
+ className: O.table,
403
+ "data-testid": "reports-table",
404
+ "aria-label": s("REPORTS_TABLE_ARIA_LABEL"),
405
+ children: [
406
+ /* @__PURE__ */ r("thead", { children: /* @__PURE__ */ S("tr", { children: [
407
+ /* @__PURE__ */ r(
408
+ "th",
409
+ {
410
+ className: L ? O.nameColumn : O.nameColumnWide,
411
+ children: s("REPORTS_NAME_HEADER")
412
+ }
413
+ ),
414
+ L && /* @__PURE__ */ S(K, { children: [
415
+ /* @__PURE__ */ r("th", { className: O.dateColumn, children: s("REPORTS_START_DATE_LABEL") }),
416
+ /* @__PURE__ */ r("th", { className: O.dateColumn, children: s("REPORTS_END_DATE_LABEL") })
417
+ ] }),
418
+ /* @__PURE__ */ r("th", { className: O.formatColumn, children: s("REPORTS_FORMAT_LABEL") }),
419
+ /* @__PURE__ */ r("th", { className: O.actionsColumn, children: s("REPORTS_ACTIONS_HEADER") })
420
+ ] }) }),
421
+ /* @__PURE__ */ r("tbody", { children: e.map((R) => {
422
+ const m = _(R.id), f = E(R.id), C = Y(R), y = p(R.id), v = h(R.id), I = m.format === "CUSTOM EXCEL", M = !!R.config?.macroTemplatePath;
423
+ let F = "edit";
424
+ return D(R.id) ? F = "uploading" : m.templateLocation && (F = "complete"), /* @__PURE__ */ S("tr", { children: [
425
+ /* @__PURE__ */ r(
426
+ "td",
427
+ {
428
+ className: L ? O.nameColumn : O.nameColumnWide,
429
+ children: R.name
430
+ }
431
+ ),
432
+ L && /* @__PURE__ */ S(K, { children: [
433
+ /* @__PURE__ */ r("td", { children: C && /* @__PURE__ */ r(
434
+ q,
435
+ {
436
+ datePickerType: "single",
437
+ dateFormat: "d/m/Y",
438
+ value: m.startDate ?? void 0,
439
+ onChange: (g) => {
440
+ c(R.id, {
441
+ startDate: g[0] ?? null
442
+ }), u(R.id, "startDate");
443
+ },
444
+ children: /* @__PURE__ */ r(
445
+ Q,
446
+ {
447
+ id: `row-start-date-${R.id}`,
448
+ labelText: s("REPORTS_START_DATE_LABEL"),
449
+ hideLabel: !0,
450
+ placeholder: s("REPORTS_DATE_PLACEHOLDER"),
451
+ invalid: !!f?.startDate,
452
+ invalidText: f?.startDate
453
+ }
454
+ )
455
+ }
456
+ ) }),
457
+ /* @__PURE__ */ r("td", { children: C && /* @__PURE__ */ r(
458
+ q,
459
+ {
460
+ datePickerType: "single",
461
+ dateFormat: "d/m/Y",
462
+ minDate: m.startDate ?? void 0,
463
+ onChange: (g) => {
464
+ c(R.id, {
465
+ endDate: g[0] ?? null
466
+ }), u(R.id, "endDate");
467
+ },
468
+ value: m.endDate ?? void 0,
469
+ children: /* @__PURE__ */ r(
470
+ Q,
471
+ {
472
+ id: `row-end-date-${R.id}`,
473
+ labelText: s("REPORTS_END_DATE_LABEL"),
474
+ hideLabel: !0,
475
+ placeholder: s("REPORTS_DATE_PLACEHOLDER"),
476
+ invalid: !!f?.endDate,
477
+ invalidText: f?.endDate
478
+ }
479
+ )
480
+ }
481
+ ) })
482
+ ] }),
483
+ /* @__PURE__ */ S("td", { children: [
484
+ /* @__PURE__ */ r(
485
+ j,
486
+ {
487
+ id: `row-format-${R.id}`,
488
+ titleText: s("REPORTS_FORMAT_LABEL"),
489
+ hideLabel: !0,
490
+ label: s("REPORTS_CHOOSE_FORMAT"),
491
+ items: a,
492
+ itemToString: Ee(s),
493
+ selectedItem: m.format,
494
+ invalid: !!f?.format,
495
+ invalidText: f?.format,
496
+ onChange: ({ selectedItem: g }) => {
497
+ c(R.id, { format: g }), u(R.id, "format");
498
+ }
499
+ }
500
+ ),
501
+ I && (M ? /* @__PURE__ */ r(
502
+ "p",
503
+ {
504
+ className: O.preconfiguredTemplateLabel,
505
+ "data-testid": `preconfigured-template-${R.id}`,
506
+ children: s("REPORTS_PRECONFIGURED_TEMPLATE_LABEL")
507
+ }
508
+ ) : /* @__PURE__ */ r(
509
+ Ce,
510
+ {
511
+ testId: `template-uploader-${R.id}`,
512
+ accept: Ze,
513
+ buttonLabel: s(
514
+ "REPORTS_UPLOAD_TEMPLATE_BUTTON_LABEL"
515
+ ),
516
+ labelTitle: s("REPORTS_UPLOAD_TEMPLATE_LABEL"),
517
+ filenameStatus: F,
518
+ onChange: (g, W) => {
519
+ const n = W?.addedFiles?.[0]?.file ?? g?.target?.files?.[0];
520
+ n && N(R, n);
521
+ }
522
+ },
523
+ `${R.id}-${m.templateLocation ?? "empty"}`
524
+ ))
525
+ ] }),
526
+ /* @__PURE__ */ r("td", { className: O.actionsColumn, children: y || v ? /* @__PURE__ */ r(
527
+ be,
528
+ {
529
+ description: s(
530
+ y ? "REPORTS_RUNNING_LOADING_LABEL" : "REPORTS_QUEUEING_LOADING_LABEL"
531
+ )
532
+ }
533
+ ) : /* @__PURE__ */ S(
534
+ Ne,
535
+ {
536
+ flipped: !0,
537
+ "aria-label": s("REPORTS_ACTIONS_HEADER"),
538
+ children: [
539
+ /* @__PURE__ */ r(
540
+ J,
541
+ {
542
+ itemText: s(
543
+ o ? "REPORTS_RUN_NOW_BUTTON_LABEL" : "REPORTS_RUN_BUTTON_LABEL"
544
+ ),
545
+ onClick: () => P(R)
546
+ }
547
+ ),
548
+ o && /* @__PURE__ */ r(
549
+ J,
550
+ {
551
+ itemText: s("REPORTS_QUEUE_BUTTON_LABEL"),
552
+ onClick: () => b(R)
553
+ }
554
+ )
555
+ ]
556
+ }
557
+ ) })
558
+ ] }, R.id);
559
+ }) })
560
+ ]
561
+ }
562
+ ) });
563
+ }
564
+ );
565
+ z.displayName = "ReportsTable";
566
+ const Mt = "ReportList-module_reportList__tPpsJ", Ft = "ReportList-module_fullWidth__p10hj", Bt = "ReportList-module_emptyState__0xMZ9", $ = {
567
+ reportList: Mt,
568
+ fullWidth: Ft,
569
+ emptyState: Bt
570
+ }, Ut = "TableFilters-module_filtersContainer__k61FE", vt = "TableFilters-module_filtersTitle__fAhZr", Ht = "TableFilters-module_filtersRow__nM3k-", Yt = "TableFilters-module_divider__r8vOx", wt = "TableFilters-module_buttonsRow__otqUJ", H = {
571
+ filtersContainer: Ut,
572
+ filtersTitle: vt,
573
+ filtersRow: Ht,
574
+ divider: Yt,
575
+ buttonsRow: wt
576
+ }, xt = ({
577
+ startDate: e,
578
+ endDate: t,
579
+ format: a,
580
+ selectedPreset: l,
581
+ availableFormats: o,
582
+ onStartDateChange: s,
583
+ onEndDateChange: _,
584
+ onFormatChange: E,
585
+ onPresetChange: p,
586
+ onReset: h,
587
+ onApply: D
588
+ }) => {
589
+ const { t: c } = w();
590
+ return /* @__PURE__ */ S("section", { className: H.filtersContainer, "data-testid": "reports-filters", children: [
591
+ /* @__PURE__ */ r("h2", { className: H.filtersTitle, children: c("REPORTS_FILTERS_LABEL") }),
592
+ /* @__PURE__ */ S("div", { className: H.filtersRow, children: [
593
+ /* @__PURE__ */ r(
594
+ j,
595
+ {
596
+ id: "date-range-preset",
597
+ titleText: c("REPORTS_SELECT_DATE_RANGE"),
598
+ label: "",
599
+ items: Ke,
600
+ itemToString: (u) => u ? c(Je[u]) : "",
601
+ selectedItem: l,
602
+ onChange: ({ selectedItem: u }) => {
603
+ if (p(u ?? null), !u) return;
604
+ const [P, b] = mt(u);
605
+ s(P), _(b);
606
+ }
607
+ }
608
+ ),
609
+ /* @__PURE__ */ r(
610
+ q,
611
+ {
612
+ datePickerType: "single",
613
+ dateFormat: "d/m/Y",
614
+ value: e ?? void 0,
615
+ onChange: (u) => {
616
+ p(null), s(u[0] ?? null);
617
+ },
618
+ children: /* @__PURE__ */ r(
619
+ Q,
620
+ {
621
+ id: "filter-start-date",
622
+ labelText: c("REPORTS_START_DATE_LABEL"),
623
+ placeholder: c("REPORTS_DATE_PLACEHOLDER")
624
+ }
625
+ )
626
+ }
627
+ ),
628
+ /* @__PURE__ */ r(
629
+ q,
630
+ {
631
+ datePickerType: "single",
632
+ dateFormat: "d/m/Y",
633
+ minDate: e ?? void 0,
634
+ value: t ?? void 0,
635
+ onChange: (u) => {
636
+ p(null), _(u[0] ?? null);
637
+ },
638
+ children: /* @__PURE__ */ r(
639
+ Q,
640
+ {
641
+ id: "filter-end-date",
642
+ labelText: c("REPORTS_END_DATE_LABEL"),
643
+ placeholder: c("REPORTS_DATE_PLACEHOLDER")
644
+ }
645
+ )
646
+ }
647
+ ),
648
+ /* @__PURE__ */ r("span", { className: H.divider, "aria-hidden": "true" }),
649
+ /* @__PURE__ */ r(
650
+ j,
651
+ {
652
+ id: "filter-format",
653
+ titleText: c("REPORTS_FORMAT_LABEL"),
654
+ label: c("REPORTS_CHOOSE_FORMAT"),
655
+ items: o,
656
+ itemToString: Ee(c),
657
+ selectedItem: a,
658
+ onChange: ({ selectedItem: u }) => E(u)
659
+ }
660
+ )
661
+ ] }),
662
+ /* @__PURE__ */ S("div", { className: H.buttonsRow, children: [
663
+ /* @__PURE__ */ r(Z, { kind: "tertiary", onClick: h, children: c("REPORTS_RESET_BUTTON") }),
664
+ /* @__PURE__ */ r(Z, { kind: "primary", onClick: D, children: c("REPORTS_APPLY_BUTTON") })
665
+ ] })
666
+ ] });
667
+ }, ie = {
668
+ startDate: null,
669
+ endDate: null,
670
+ format: null,
671
+ version: 0
672
+ }, qt = () => {
673
+ const { t: e } = w(), { userPrivileges: t, isLoading: a } = ye(), { addNotification: l } = ce(), {
674
+ data: o,
675
+ isLoading: s,
676
+ error: _
677
+ } = ot(), { data: E } = et();
678
+ _e(() => {
679
+ _ && l({
680
+ title: e("REPORTS_ERROR_TITLE"),
681
+ message: e("REPORTS_CONFIG_LOAD_ERROR"),
682
+ type: "error"
683
+ });
684
+ }, [_, l, e]);
685
+ const [p, h] = A(null), [D, c] = A(null), [u, P] = A(null), [b, N] = A(null), [L, R] = A(ie), m = x(() => o ? Tt(
686
+ ft(o),
687
+ t
688
+ ) : [], [o, t]), f = x(
689
+ () => pt(E?.config?.supportedFormats),
690
+ [E]
691
+ ), C = E?.config?.paperSize, y = E?.config?.enableReportQueue ?? !1, { dateRangeReports: v, noDateRangeReports: I } = x(
692
+ () => Et(m),
693
+ [m]
694
+ ), M = () => {
695
+ R((g) => ({
696
+ startDate: p,
697
+ endDate: D,
698
+ format: u,
699
+ version: g.version + 1
700
+ }));
701
+ }, F = () => {
702
+ h(null), c(null), P(null), N(null), R((g) => ({ ...ie, version: g.version + 1 }));
703
+ };
704
+ return s || a ? /* @__PURE__ */ r(
705
+ Ie,
706
+ {
707
+ id: "reports-config-loading",
708
+ testId: "reports-config-loading",
709
+ className: $.fullWidth,
710
+ type: "multi"
711
+ }
712
+ ) : _ ? null : !o || m.length === 0 ? /* @__PURE__ */ r(
713
+ "p",
714
+ {
715
+ id: "reports-empty-state",
716
+ "data-testid": "reports-empty-state",
717
+ className: $.emptyState,
718
+ children: e("REPORTS_EMPTY_STATE_MESSAGE")
719
+ }
720
+ ) : /* @__PURE__ */ S(
721
+ "div",
722
+ {
723
+ id: "report-list",
724
+ "data-testid": "report-list",
725
+ className: $.reportList,
726
+ children: [
727
+ /* @__PURE__ */ r(
728
+ xt,
729
+ {
730
+ startDate: p,
731
+ endDate: D,
732
+ format: u,
733
+ selectedPreset: b,
734
+ availableFormats: f,
735
+ onStartDateChange: h,
736
+ onEndDateChange: c,
737
+ onFormatChange: P,
738
+ onPresetChange: N,
739
+ onReset: F,
740
+ onApply: M
741
+ }
742
+ ),
743
+ /* @__PURE__ */ S(Me, { align: "start", children: [
744
+ /* @__PURE__ */ r(
745
+ ee,
746
+ {
747
+ title: e("REPORTS_DATE_RANGE_SECTION_TITLE"),
748
+ testId: "reports-date-range-section",
749
+ open: !0,
750
+ children: /* @__PURE__ */ r(
751
+ z,
752
+ {
753
+ reports: v,
754
+ appliedFilters: L,
755
+ availableFormats: f,
756
+ defaultPaperSize: C,
757
+ enableReportQueue: y
758
+ }
759
+ )
760
+ }
761
+ ),
762
+ /* @__PURE__ */ r(
763
+ ee,
764
+ {
765
+ title: e("REPORTS_NO_DATE_RANGE_SECTION_TITLE"),
766
+ testId: "reports-no-date-range-section",
767
+ open: !0,
768
+ children: /* @__PURE__ */ r(
769
+ z,
770
+ {
771
+ reports: I,
772
+ appliedFilters: L,
773
+ availableFormats: f,
774
+ defaultPaperSize: C,
775
+ enableReportQueue: y
776
+ }
777
+ )
778
+ }
779
+ )
780
+ ] })
781
+ ]
782
+ }
783
+ );
784
+ }, Qt = "ReportsPage-module_page__ewRXe", Gt = "ReportsPage-module_panel__HFBCt", X = {
785
+ page: Qt,
786
+ panel: Gt
787
+ }, le = 1, $t = 0, Wt = () => {
788
+ const { t: e } = w(), t = Qe(), a = Ge(), l = x(
789
+ () => [
790
+ { id: "home", label: e("REPORTS_HOME_LABEL"), href: Fe },
791
+ { id: "reports", label: e("REPORTS_LABEL"), isCurrentPage: !0 }
792
+ ],
793
+ [e]
794
+ ), o = t.pathname === te ? le : $t, s = V(
795
+ ({ selectedIndex: _ }) => {
796
+ a(
797
+ _ === le ? te : Be
798
+ );
799
+ },
800
+ [a]
801
+ );
802
+ return /* @__PURE__ */ r(
803
+ Ue,
804
+ {
805
+ header: /* @__PURE__ */ r(
806
+ "div",
807
+ {
808
+ id: "reports-page-header",
809
+ "data-testid": "reports-page-header-test-id",
810
+ "aria-label": "Reports Page Header",
811
+ children: /* @__PURE__ */ r(
812
+ we,
813
+ {
814
+ breadcrumbItems: l,
815
+ userMenu: /* @__PURE__ */ r(xe, {})
816
+ }
817
+ )
818
+ }
819
+ ),
820
+ main: /* @__PURE__ */ r(
821
+ "div",
822
+ {
823
+ id: "reports-page",
824
+ "data-testid": "reports-page-test-id",
825
+ "aria-label": "Reports Page",
826
+ className: X.page,
827
+ children: /* @__PURE__ */ S(ve, { selectedIndex: o, onChange: s, children: [
828
+ /* @__PURE__ */ S(
829
+ He,
830
+ {
831
+ id: "reports-tab-list",
832
+ "data-testid": "reports-tab-list-test-id",
833
+ "aria-label": e("REPORTS_TAB_LIST_ARIA_LABEL"),
834
+ children: [
835
+ /* @__PURE__ */ r(
836
+ ae,
837
+ {
838
+ id: "reports-tab",
839
+ "data-testid": "reports-tab-test-id",
840
+ "aria-label": e("REPORTS_TAB_LABEL"),
841
+ children: e("REPORTS_TAB_LABEL")
842
+ }
843
+ ),
844
+ /* @__PURE__ */ r(
845
+ ae,
846
+ {
847
+ id: "my-reports-tab",
848
+ "data-testid": "my-reports-tab-test-id",
849
+ "aria-label": e("REPORTS_MY_REPORTS_TAB_LABEL"),
850
+ children: e("REPORTS_MY_REPORTS_TAB_LABEL")
851
+ }
852
+ )
853
+ ]
854
+ }
855
+ ),
856
+ /* @__PURE__ */ S(Ye, { children: [
857
+ /* @__PURE__ */ r(
858
+ ne,
859
+ {
860
+ id: "reports-tab-panel",
861
+ "data-testid": "reports-tab-panel-test-id",
862
+ "aria-label": e("REPORTS_TAB_LABEL"),
863
+ className: X.panel,
864
+ children: /* @__PURE__ */ r(qt, {})
865
+ }
866
+ ),
867
+ /* @__PURE__ */ r(
868
+ ne,
869
+ {
870
+ id: "my-reports-tab-panel",
871
+ "data-testid": "my-reports-tab-panel-test-id",
872
+ "aria-label": e("REPORTS_MY_REPORTS_TAB_LABEL"),
873
+ className: X.panel,
874
+ children: /* @__PURE__ */ r("p", { children: e("REPORTS_MY_REPORTS_TAB_PLACEHOLDER") })
875
+ }
876
+ )
877
+ ] })
878
+ ] })
879
+ }
880
+ )
881
+ }
882
+ );
883
+ };
884
+ export {
885
+ Wt as ReportsPage,
886
+ Wt as default
887
+ };