@bahmni/reports-app 0.0.1-dev.438 → 0.0.1-dev.440
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/{DocumentsTable-CBaZduLC-BcyxF2oD.js → DocumentsTable-CirHKvw9-B17dhopQ.js} +14 -14
- package/dist/{FormsTable-BYeW3DRV-CGqSvvSG.js → FormsTable-CqUGhZ65-37vUnsEl.js} +89 -89
- package/dist/{LNWAZHJI-DyBrB8Jh.js → LNWAZHJI-Dgr1eokx.js} +7 -7
- package/dist/{MWZ6AO7Z-CnfRmymN.js → MWZ6AO7Z-CmWg6Vdd.js} +7 -7
- package/dist/{Observations-Brw1YHvF-DqIzuBZd.js → Observations-BhAU90jX-BQEet5Rt.js} +57 -57
- package/dist/ReportsPage-DCLNH4F3.js +666 -0
- package/dist/{YPM2AS64-aFRyAdNu.js → YPM2AS64-D43fwMxU.js} +138 -138
- package/dist/components/PrivilegeGuard/PrivilegeGuard.d.ts +0 -8
- package/dist/components/PrivilegeGuard/PrivilegeGuard.d.ts.map +1 -1
- package/dist/components/ReportList/ReportList.d.ts +4 -0
- package/dist/components/ReportList/ReportList.d.ts.map +1 -0
- package/dist/components/ReportList/ReportsTable.d.ts +13 -0
- package/dist/components/ReportList/ReportsTable.d.ts.map +1 -0
- package/dist/components/ReportList/TableFilters.d.ts +19 -0
- package/dist/components/ReportList/TableFilters.d.ts.map +1 -0
- package/dist/components/ReportList/appConfigSchema.json.d.ts +28 -0
- package/dist/components/ReportList/constants.d.ts +10 -0
- package/dist/components/ReportList/constants.d.ts.map +1 -0
- package/dist/components/ReportList/models.d.ts +43 -0
- package/dist/components/ReportList/models.d.ts.map +1 -0
- package/dist/components/ReportList/schema.json.d.ts +44 -0
- package/dist/components/ReportList/utils.d.ts +32 -0
- package/dist/components/ReportList/utils.d.ts.map +1 -0
- package/dist/constants/app.d.ts +2 -0
- package/dist/constants/app.d.ts.map +1 -1
- package/dist/hooks/useReportTableState.d.ts +19 -0
- package/dist/hooks/useReportTableState.d.ts.map +1 -0
- package/dist/hooks/useReportsAppConfig.d.ts +3 -0
- package/dist/hooks/useReportsAppConfig.d.ts.map +1 -0
- package/dist/hooks/useReportsConfig.d.ts +3 -0
- package/dist/hooks/useReportsConfig.d.ts.map +1 -0
- package/dist/hooks/useRunReport.d.ts +7 -0
- package/dist/hooks/useRunReport.d.ts.map +1 -0
- package/dist/{index-DCwfYxKs.js → index-CSBzaxP9.js} +39769 -37869
- package/dist/index.css +1 -1
- package/dist/index.js +1 -1
- package/dist/locales/locale_en.json +40 -1
- package/dist/locales/locale_es.json +40 -1
- package/dist/pages/ReportsPage.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/ReportsPage-B7UpjdUg.js +0 -109
|
@@ -0,0 +1,666 @@
|
|
|
1
|
+
import { jsx as a, jsxs as m, Fragment as H } from "react/jsx-runtime";
|
|
2
|
+
import { C as W, p as se, r as oe, t as ie, x as le, y as de, A as Re, M as ce, O as Y, u as b, z as X, S as N, T as F, U as M, V as _e, _ as Te, a0 as pe, a1 as x, k as ue, a2 as me, a3 as Ee, a4 as q, a5 as Se, a6 as U, a7 as fe, a8 as Oe, a9 as Pe, aa as ge, ab as k, ac as Ae, ad as $, ae as he, af as De } from "./index-CSBzaxP9.js";
|
|
3
|
+
import Le, { useCallback as K, useState as A, useEffect as V, useMemo as y } from "react";
|
|
4
|
+
import { useQuery as J } from "@tanstack/react-query";
|
|
5
|
+
import { useLocation as Ce, useNavigate as be } from "react-router-dom";
|
|
6
|
+
const ye = "http://json-schema.org/draft-07/schema#", Ne = "Reports App Configuration", Fe = "object", ve = { 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)" } }, additionalProperties: !0 } }, Ie = !0, Be = {
|
|
7
|
+
$schema: ye,
|
|
8
|
+
title: Ne,
|
|
9
|
+
type: Fe,
|
|
10
|
+
properties: ve,
|
|
11
|
+
additionalProperties: Ie
|
|
12
|
+
}, Me = {
|
|
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
|
+
}, we = [
|
|
20
|
+
"TODAY",
|
|
21
|
+
"THIS_MONTH",
|
|
22
|
+
"LAST_7_DAYS"
|
|
23
|
+
], He = {
|
|
24
|
+
TODAY: "REPORTS_PRESET_TODAY",
|
|
25
|
+
THIS_MONTH: "REPORTS_PRESET_THIS_MONTH",
|
|
26
|
+
LAST_7_DAYS: "REPORTS_PRESET_LAST_7_DAYS"
|
|
27
|
+
}, Q = {
|
|
28
|
+
reportsConfig: ["reportsConfig"],
|
|
29
|
+
reportsAppConfig: ["reportsAppConfig"]
|
|
30
|
+
}, Ye = () => J({
|
|
31
|
+
queryKey: Q.reportsAppConfig,
|
|
32
|
+
queryFn: async () => {
|
|
33
|
+
try {
|
|
34
|
+
return await W(
|
|
35
|
+
se,
|
|
36
|
+
Be
|
|
37
|
+
);
|
|
38
|
+
} catch {
|
|
39
|
+
return {};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}), xe = "http://json-schema.org/draft-07/schema#", qe = "Reports Configuration", Ue = "object", ke = { 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 } } }, $e = {
|
|
43
|
+
$schema: xe,
|
|
44
|
+
title: qe,
|
|
45
|
+
type: Ue,
|
|
46
|
+
additionalProperties: ke
|
|
47
|
+
}, je = () => J({
|
|
48
|
+
queryKey: Q.reportsConfig,
|
|
49
|
+
queryFn: () => W(oe, $e),
|
|
50
|
+
retry: !1
|
|
51
|
+
}), j = Symbol.for("constructDateFrom");
|
|
52
|
+
function Z(e, t) {
|
|
53
|
+
return typeof e == "function" ? e(t) : e && typeof e == "object" && j in e ? e[j](t) : e instanceof Date ? new e.constructor(t) : new Date(t);
|
|
54
|
+
}
|
|
55
|
+
function ee(e, t) {
|
|
56
|
+
return Z(e, e);
|
|
57
|
+
}
|
|
58
|
+
function Ge(e, t, s) {
|
|
59
|
+
const d = ee(e);
|
|
60
|
+
return isNaN(t) ? Z(e, NaN) : (d.setDate(d.getDate() + t), d);
|
|
61
|
+
}
|
|
62
|
+
function ze(e, t) {
|
|
63
|
+
const s = ee(e);
|
|
64
|
+
return s.setDate(1), s.setHours(0, 0, 0, 0), s;
|
|
65
|
+
}
|
|
66
|
+
function We(e, t, s) {
|
|
67
|
+
return Ge(e, -6);
|
|
68
|
+
}
|
|
69
|
+
const Xe = (e, t) => t ? de(e, t) : !0, Ke = (e, t) => e.filter(
|
|
70
|
+
(s) => Xe(t, s.requiredPrivilege)
|
|
71
|
+
), C = (e) => e.config?.dateRangeRequired !== !1, Ve = (e) => ({
|
|
72
|
+
dateRangeReports: e.filter(C),
|
|
73
|
+
noDateRangeReports: e.filter((t) => !C(t))
|
|
74
|
+
}), Je = (e) => !e || e.length === 0 ? ie : e.map(
|
|
75
|
+
(s) => s.toUpperCase()
|
|
76
|
+
).filter((s) => s in le), Qe = (e) => {
|
|
77
|
+
const t = /* @__PURE__ */ new Date();
|
|
78
|
+
switch (e) {
|
|
79
|
+
case "THIS_MONTH":
|
|
80
|
+
return [ze(t), t];
|
|
81
|
+
case "LAST_7_DAYS":
|
|
82
|
+
return [We(t), t];
|
|
83
|
+
default:
|
|
84
|
+
return [new Date(t), new Date(t)];
|
|
85
|
+
}
|
|
86
|
+
}, te = (e) => (t) => t ? e(Me[t]) : "", Ze = (e, t) => {
|
|
87
|
+
const { report: s, requiresDateRange: d, format: n, startDate: _, endDate: R } = e;
|
|
88
|
+
return n ? d && (!_ || !R) ? !_ && !R ? {
|
|
89
|
+
field: "startDate",
|
|
90
|
+
message: t("REPORTS_MISSING_BOTH_DATES_ERROR")
|
|
91
|
+
} : _ ? {
|
|
92
|
+
field: "endDate",
|
|
93
|
+
message: t("REPORTS_MISSING_END_DATE_ERROR")
|
|
94
|
+
} : {
|
|
95
|
+
field: "startDate",
|
|
96
|
+
message: t("REPORTS_MISSING_START_DATE_ERROR")
|
|
97
|
+
} : _ && R && _ > R ? {
|
|
98
|
+
field: "endDate",
|
|
99
|
+
message: t("REPORTS_DATE_ORDER_ERROR")
|
|
100
|
+
} : s.type === "concatenated" && n === "CSV" ? {
|
|
101
|
+
message: t("REPORTS_CSV_NOT_SUPPORTED_ERROR")
|
|
102
|
+
} : null : {
|
|
103
|
+
field: "format",
|
|
104
|
+
message: t("REPORTS_SELECT_FORMAT_ERROR", {
|
|
105
|
+
reportName: s.name
|
|
106
|
+
})
|
|
107
|
+
};
|
|
108
|
+
}, et = (e) => Object.entries(e).map(([t, s]) => ({
|
|
109
|
+
id: t,
|
|
110
|
+
...s
|
|
111
|
+
})), tt = () => ({ runReport: K(
|
|
112
|
+
(t, s, d, n, _) => {
|
|
113
|
+
try {
|
|
114
|
+
const R = Re(
|
|
115
|
+
t.name,
|
|
116
|
+
s,
|
|
117
|
+
d,
|
|
118
|
+
n,
|
|
119
|
+
t.config?.paperSize ?? _
|
|
120
|
+
), u = window.open(R, "_blank");
|
|
121
|
+
return u ? (u.opener = null, ce({
|
|
122
|
+
eventType: Y.RUN_REPORT.eventType,
|
|
123
|
+
messageParams: { reportName: t.name },
|
|
124
|
+
module: Y.RUN_REPORT.module
|
|
125
|
+
}), !0) : !1;
|
|
126
|
+
} catch (R) {
|
|
127
|
+
return console.error("Error running report:", R), !1;
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
[]
|
|
131
|
+
) }), at = (e, t, s) => {
|
|
132
|
+
const { t: d } = b(), { addNotification: n } = X(), { runReport: _ } = tt(), [R, u] = A({}), [f, p] = A({}), [P, i] = A(null);
|
|
133
|
+
V(() => {
|
|
134
|
+
u({}), p({});
|
|
135
|
+
}, [t.version]);
|
|
136
|
+
const r = (o) => R[o] ?? {
|
|
137
|
+
startDate: t.startDate,
|
|
138
|
+
endDate: t.endDate,
|
|
139
|
+
format: t.format
|
|
140
|
+
};
|
|
141
|
+
return {
|
|
142
|
+
rowFilters: r,
|
|
143
|
+
errors: (o) => f[o],
|
|
144
|
+
isRunning: (o) => P === o,
|
|
145
|
+
updateRow: (o, l) => u((c) => ({
|
|
146
|
+
...c,
|
|
147
|
+
[o]: { ...r(o), ...l }
|
|
148
|
+
})),
|
|
149
|
+
clearRowFieldError: (o, l) => p((c) => {
|
|
150
|
+
if (!c[o]?.[l]) return c;
|
|
151
|
+
const D = { ...c[o], [l]: void 0 };
|
|
152
|
+
return { ...c, [o]: D };
|
|
153
|
+
}),
|
|
154
|
+
handleRunReport: (o) => {
|
|
155
|
+
const l = r(o.id), c = Ze(
|
|
156
|
+
{
|
|
157
|
+
report: o,
|
|
158
|
+
requiresDateRange: C(o),
|
|
159
|
+
format: l.format,
|
|
160
|
+
startDate: l.startDate,
|
|
161
|
+
endDate: l.endDate
|
|
162
|
+
},
|
|
163
|
+
(T, g) => d(T, { defaultValue: T, ...g })
|
|
164
|
+
);
|
|
165
|
+
if (c) {
|
|
166
|
+
if (n({
|
|
167
|
+
title: d("REPORTS_VALIDATION_ERROR_TITLE"),
|
|
168
|
+
message: c.message,
|
|
169
|
+
type: "error"
|
|
170
|
+
}), c.field === "format")
|
|
171
|
+
p((T) => ({
|
|
172
|
+
...T,
|
|
173
|
+
[o.id]: { format: c.message }
|
|
174
|
+
}));
|
|
175
|
+
else if (c.field === "startDate" || c.field === "endDate") {
|
|
176
|
+
const T = !l.startDate && !l.endDate;
|
|
177
|
+
p((g) => ({
|
|
178
|
+
...g,
|
|
179
|
+
[o.id]: {
|
|
180
|
+
startDate: c.field === "startDate" || T ? c.message : void 0,
|
|
181
|
+
endDate: c.field === "endDate" || T ? c.message : void 0
|
|
182
|
+
}
|
|
183
|
+
}));
|
|
184
|
+
}
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
if (p((T) => {
|
|
188
|
+
if (!(o.id in T)) return T;
|
|
189
|
+
const g = { ...T };
|
|
190
|
+
return delete g[o.id], g;
|
|
191
|
+
}), i(o.id), !_(
|
|
192
|
+
o,
|
|
193
|
+
l.format,
|
|
194
|
+
l.startDate,
|
|
195
|
+
l.endDate,
|
|
196
|
+
s
|
|
197
|
+
)) {
|
|
198
|
+
i(null), n({
|
|
199
|
+
title: d("REPORTS_ERROR_TITLE"),
|
|
200
|
+
message: d("REPORTS_POPUP_BLOCKED_ERROR"),
|
|
201
|
+
type: "error"
|
|
202
|
+
});
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
setTimeout(() => {
|
|
206
|
+
i((T) => T === o.id ? null : T);
|
|
207
|
+
}, 300);
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
}, rt = "ReportsTable-module_tableContainer__-0YY7", nt = "ReportsTable-module_table__4ySYm", st = "ReportsTable-module_actionsColumn__Haj2L", ot = "ReportsTable-module_nameColumn__BXFAo", it = "ReportsTable-module_dateColumn__zPT-K", lt = "ReportsTable-module_formatColumn__J0nQX", dt = "ReportsTable-module_nameColumnWide__9NELB", Rt = "ReportsTable-module_emptyState__nMhOo", E = {
|
|
211
|
+
tableContainer: rt,
|
|
212
|
+
table: nt,
|
|
213
|
+
actionsColumn: st,
|
|
214
|
+
nameColumn: ot,
|
|
215
|
+
dateColumn: it,
|
|
216
|
+
formatColumn: lt,
|
|
217
|
+
nameColumnWide: dt,
|
|
218
|
+
emptyState: Rt
|
|
219
|
+
}, w = Le.memo(
|
|
220
|
+
({ reports: e, appliedFilters: t, availableFormats: s, defaultPaperSize: d }) => {
|
|
221
|
+
const { t: n } = b(), {
|
|
222
|
+
rowFilters: _,
|
|
223
|
+
errors: R,
|
|
224
|
+
isRunning: u,
|
|
225
|
+
updateRow: f,
|
|
226
|
+
clearRowFieldError: p,
|
|
227
|
+
handleRunReport: P
|
|
228
|
+
} = at(e, t, d);
|
|
229
|
+
if (e.length === 0)
|
|
230
|
+
return /* @__PURE__ */ a("div", { className: E.emptyState, "data-testid": "reports-table-empty", children: n("REPORTS_NO_REPORTS_IN_SECTION") });
|
|
231
|
+
const i = e.some(C);
|
|
232
|
+
return /* @__PURE__ */ a("div", { className: E.tableContainer, children: /* @__PURE__ */ m("table", { className: E.table, "data-testid": "reports-table", children: [
|
|
233
|
+
/* @__PURE__ */ a("thead", { children: /* @__PURE__ */ m("tr", { children: [
|
|
234
|
+
/* @__PURE__ */ a(
|
|
235
|
+
"th",
|
|
236
|
+
{
|
|
237
|
+
className: i ? E.nameColumn : E.nameColumnWide,
|
|
238
|
+
children: n("REPORTS_NAME_HEADER")
|
|
239
|
+
}
|
|
240
|
+
),
|
|
241
|
+
i && /* @__PURE__ */ m(H, { children: [
|
|
242
|
+
/* @__PURE__ */ a("th", { className: E.dateColumn, children: n("REPORTS_START_DATE_LABEL") }),
|
|
243
|
+
/* @__PURE__ */ a("th", { className: E.dateColumn, children: n("REPORTS_END_DATE_LABEL") })
|
|
244
|
+
] }),
|
|
245
|
+
/* @__PURE__ */ a("th", { className: E.formatColumn, children: n("REPORTS_FORMAT_LABEL") }),
|
|
246
|
+
/* @__PURE__ */ a("th", { className: E.actionsColumn, children: n("REPORTS_ACTIONS_HEADER") })
|
|
247
|
+
] }) }),
|
|
248
|
+
/* @__PURE__ */ a("tbody", { children: e.map((r) => {
|
|
249
|
+
const O = _(r.id), S = R(r.id), h = C(r), o = u(r.id);
|
|
250
|
+
return /* @__PURE__ */ m("tr", { children: [
|
|
251
|
+
/* @__PURE__ */ a(
|
|
252
|
+
"td",
|
|
253
|
+
{
|
|
254
|
+
className: i ? E.nameColumn : E.nameColumnWide,
|
|
255
|
+
children: r.name
|
|
256
|
+
}
|
|
257
|
+
),
|
|
258
|
+
i && /* @__PURE__ */ m(H, { children: [
|
|
259
|
+
/* @__PURE__ */ a("td", { children: h && /* @__PURE__ */ a(
|
|
260
|
+
N,
|
|
261
|
+
{
|
|
262
|
+
datePickerType: "single",
|
|
263
|
+
dateFormat: "d/m/Y",
|
|
264
|
+
value: O.startDate ?? void 0,
|
|
265
|
+
onChange: (l) => {
|
|
266
|
+
f(r.id, {
|
|
267
|
+
startDate: l[0] ?? null
|
|
268
|
+
}), p(r.id, "startDate");
|
|
269
|
+
},
|
|
270
|
+
children: /* @__PURE__ */ a(
|
|
271
|
+
F,
|
|
272
|
+
{
|
|
273
|
+
id: `row-start-date-${r.id}`,
|
|
274
|
+
labelText: n("REPORTS_START_DATE_LABEL"),
|
|
275
|
+
hideLabel: !0,
|
|
276
|
+
placeholder: n("REPORTS_DATE_PLACEHOLDER"),
|
|
277
|
+
invalid: !!S?.startDate,
|
|
278
|
+
invalidText: S?.startDate
|
|
279
|
+
}
|
|
280
|
+
)
|
|
281
|
+
}
|
|
282
|
+
) }),
|
|
283
|
+
/* @__PURE__ */ a("td", { children: h && /* @__PURE__ */ a(
|
|
284
|
+
N,
|
|
285
|
+
{
|
|
286
|
+
datePickerType: "single",
|
|
287
|
+
dateFormat: "d/m/Y",
|
|
288
|
+
minDate: O.startDate ?? void 0,
|
|
289
|
+
onChange: (l) => {
|
|
290
|
+
f(r.id, {
|
|
291
|
+
endDate: l[0] ?? null
|
|
292
|
+
}), p(r.id, "endDate");
|
|
293
|
+
},
|
|
294
|
+
value: O.endDate ?? void 0,
|
|
295
|
+
children: /* @__PURE__ */ a(
|
|
296
|
+
F,
|
|
297
|
+
{
|
|
298
|
+
id: `row-end-date-${r.id}`,
|
|
299
|
+
labelText: n("REPORTS_END_DATE_LABEL"),
|
|
300
|
+
hideLabel: !0,
|
|
301
|
+
placeholder: n("REPORTS_DATE_PLACEHOLDER"),
|
|
302
|
+
invalid: !!S?.endDate,
|
|
303
|
+
invalidText: S?.endDate
|
|
304
|
+
}
|
|
305
|
+
)
|
|
306
|
+
}
|
|
307
|
+
) })
|
|
308
|
+
] }),
|
|
309
|
+
/* @__PURE__ */ a("td", { children: /* @__PURE__ */ a(
|
|
310
|
+
M,
|
|
311
|
+
{
|
|
312
|
+
id: `row-format-${r.id}`,
|
|
313
|
+
titleText: n("REPORTS_FORMAT_LABEL"),
|
|
314
|
+
hideLabel: !0,
|
|
315
|
+
label: n("REPORTS_CHOOSE_FORMAT"),
|
|
316
|
+
items: s,
|
|
317
|
+
itemToString: te(n),
|
|
318
|
+
selectedItem: O.format,
|
|
319
|
+
invalid: !!S?.format,
|
|
320
|
+
invalidText: S?.format,
|
|
321
|
+
onChange: ({ selectedItem: l }) => {
|
|
322
|
+
f(r.id, { format: l }), p(r.id, "format");
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
) }),
|
|
326
|
+
/* @__PURE__ */ a("td", { className: E.actionsColumn, children: o ? /* @__PURE__ */ a(
|
|
327
|
+
_e,
|
|
328
|
+
{
|
|
329
|
+
description: n("REPORTS_RUNNING_LOADING_LABEL")
|
|
330
|
+
}
|
|
331
|
+
) : /* @__PURE__ */ a(
|
|
332
|
+
Te,
|
|
333
|
+
{
|
|
334
|
+
flipped: !0,
|
|
335
|
+
"aria-label": n("REPORTS_ACTIONS_HEADER"),
|
|
336
|
+
children: /* @__PURE__ */ a(
|
|
337
|
+
pe,
|
|
338
|
+
{
|
|
339
|
+
itemText: n("REPORTS_RUN_BUTTON_LABEL"),
|
|
340
|
+
onClick: () => P(r)
|
|
341
|
+
}
|
|
342
|
+
)
|
|
343
|
+
}
|
|
344
|
+
) })
|
|
345
|
+
] }, r.id);
|
|
346
|
+
}) })
|
|
347
|
+
] }) });
|
|
348
|
+
}
|
|
349
|
+
);
|
|
350
|
+
w.displayName = "ReportsTable";
|
|
351
|
+
const ct = "ReportList-module_reportList__tPpsJ", _t = "ReportList-module_fullWidth__p10hj", Tt = "ReportList-module_emptyState__0xMZ9", I = {
|
|
352
|
+
reportList: ct,
|
|
353
|
+
fullWidth: _t,
|
|
354
|
+
emptyState: Tt
|
|
355
|
+
}, pt = "TableFilters-module_filtersContainer__k61FE", ut = "TableFilters-module_filtersTitle__fAhZr", mt = "TableFilters-module_filtersRow__nM3k-", Et = "TableFilters-module_divider__r8vOx", St = "TableFilters-module_buttonsRow__otqUJ", L = {
|
|
356
|
+
filtersContainer: pt,
|
|
357
|
+
filtersTitle: ut,
|
|
358
|
+
filtersRow: mt,
|
|
359
|
+
divider: Et,
|
|
360
|
+
buttonsRow: St
|
|
361
|
+
}, ft = ({
|
|
362
|
+
startDate: e,
|
|
363
|
+
endDate: t,
|
|
364
|
+
format: s,
|
|
365
|
+
selectedPreset: d,
|
|
366
|
+
availableFormats: n,
|
|
367
|
+
onStartDateChange: _,
|
|
368
|
+
onEndDateChange: R,
|
|
369
|
+
onFormatChange: u,
|
|
370
|
+
onPresetChange: f,
|
|
371
|
+
onReset: p,
|
|
372
|
+
onApply: P
|
|
373
|
+
}) => {
|
|
374
|
+
const { t: i } = b();
|
|
375
|
+
return /* @__PURE__ */ m("section", { className: L.filtersContainer, "data-testid": "reports-filters", children: [
|
|
376
|
+
/* @__PURE__ */ a("h2", { className: L.filtersTitle, children: i("REPORTS_FILTERS_LABEL") }),
|
|
377
|
+
/* @__PURE__ */ m("div", { className: L.filtersRow, children: [
|
|
378
|
+
/* @__PURE__ */ a(
|
|
379
|
+
M,
|
|
380
|
+
{
|
|
381
|
+
id: "date-range-preset",
|
|
382
|
+
titleText: i("REPORTS_SELECT_DATE_RANGE"),
|
|
383
|
+
label: "",
|
|
384
|
+
items: we,
|
|
385
|
+
itemToString: (r) => r ? i(He[r]) : "",
|
|
386
|
+
selectedItem: d,
|
|
387
|
+
onChange: ({ selectedItem: r }) => {
|
|
388
|
+
if (f(r ?? null), !r) return;
|
|
389
|
+
const [O, S] = Qe(r);
|
|
390
|
+
_(O), R(S);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
),
|
|
394
|
+
/* @__PURE__ */ a(
|
|
395
|
+
N,
|
|
396
|
+
{
|
|
397
|
+
datePickerType: "single",
|
|
398
|
+
dateFormat: "d/m/Y",
|
|
399
|
+
value: e ?? void 0,
|
|
400
|
+
onChange: (r) => _(r[0] ?? null),
|
|
401
|
+
children: /* @__PURE__ */ a(
|
|
402
|
+
F,
|
|
403
|
+
{
|
|
404
|
+
id: "filter-start-date",
|
|
405
|
+
labelText: i("REPORTS_START_DATE_LABEL"),
|
|
406
|
+
placeholder: i("REPORTS_DATE_PLACEHOLDER")
|
|
407
|
+
}
|
|
408
|
+
)
|
|
409
|
+
}
|
|
410
|
+
),
|
|
411
|
+
/* @__PURE__ */ a(
|
|
412
|
+
N,
|
|
413
|
+
{
|
|
414
|
+
datePickerType: "single",
|
|
415
|
+
dateFormat: "d/m/Y",
|
|
416
|
+
minDate: e ?? void 0,
|
|
417
|
+
value: t ?? void 0,
|
|
418
|
+
onChange: (r) => R(r[0] ?? null),
|
|
419
|
+
children: /* @__PURE__ */ a(
|
|
420
|
+
F,
|
|
421
|
+
{
|
|
422
|
+
id: "filter-end-date",
|
|
423
|
+
labelText: i("REPORTS_END_DATE_LABEL"),
|
|
424
|
+
placeholder: i("REPORTS_DATE_PLACEHOLDER")
|
|
425
|
+
}
|
|
426
|
+
)
|
|
427
|
+
}
|
|
428
|
+
),
|
|
429
|
+
/* @__PURE__ */ a("span", { className: L.divider, "aria-hidden": "true" }),
|
|
430
|
+
/* @__PURE__ */ a(
|
|
431
|
+
M,
|
|
432
|
+
{
|
|
433
|
+
id: "filter-format",
|
|
434
|
+
titleText: i("REPORTS_FORMAT_LABEL"),
|
|
435
|
+
label: i("REPORTS_CHOOSE_FORMAT"),
|
|
436
|
+
items: n,
|
|
437
|
+
itemToString: te(i),
|
|
438
|
+
selectedItem: s,
|
|
439
|
+
onChange: ({ selectedItem: r }) => u(r)
|
|
440
|
+
}
|
|
441
|
+
)
|
|
442
|
+
] }),
|
|
443
|
+
/* @__PURE__ */ m("div", { className: L.buttonsRow, children: [
|
|
444
|
+
/* @__PURE__ */ a(x, { kind: "tertiary", onClick: p, children: i("REPORTS_RESET_BUTTON") }),
|
|
445
|
+
/* @__PURE__ */ a(x, { kind: "primary", onClick: P, children: i("REPORTS_APPLY_BUTTON") })
|
|
446
|
+
] })
|
|
447
|
+
] });
|
|
448
|
+
}, G = {
|
|
449
|
+
startDate: null,
|
|
450
|
+
endDate: null,
|
|
451
|
+
format: null,
|
|
452
|
+
version: 0
|
|
453
|
+
}, Ot = () => {
|
|
454
|
+
const { t: e } = b(), { userPrivileges: t, isLoading: s } = ue(), { addNotification: d } = X(), {
|
|
455
|
+
data: n,
|
|
456
|
+
isLoading: _,
|
|
457
|
+
error: R
|
|
458
|
+
} = je(), { data: u } = Ye();
|
|
459
|
+
V(() => {
|
|
460
|
+
R && d({
|
|
461
|
+
title: e("REPORTS_ERROR_TITLE"),
|
|
462
|
+
message: e("REPORTS_CONFIG_LOAD_ERROR"),
|
|
463
|
+
type: "error"
|
|
464
|
+
});
|
|
465
|
+
}, [R, d, e]);
|
|
466
|
+
const [f, p] = A(null), [P, i] = A(null), [r, O] = A(null), [S, h] = A(null), [o, l] = A(G), c = y(() => n ? Ke(
|
|
467
|
+
et(n),
|
|
468
|
+
t
|
|
469
|
+
) : [], [n, t]), D = y(
|
|
470
|
+
() => Je(u?.config?.supportedFormats),
|
|
471
|
+
[u]
|
|
472
|
+
), T = u?.config?.paperSize, { dateRangeReports: g, noDateRangeReports: ae } = y(
|
|
473
|
+
() => Ve(c),
|
|
474
|
+
[c]
|
|
475
|
+
), re = () => {
|
|
476
|
+
l((v) => ({
|
|
477
|
+
startDate: f,
|
|
478
|
+
endDate: P,
|
|
479
|
+
format: r,
|
|
480
|
+
version: v.version + 1
|
|
481
|
+
}));
|
|
482
|
+
}, ne = () => {
|
|
483
|
+
p(null), i(null), O(null), h(null), l((v) => ({ ...G, version: v.version + 1 }));
|
|
484
|
+
};
|
|
485
|
+
return _ || s ? /* @__PURE__ */ a(
|
|
486
|
+
me,
|
|
487
|
+
{
|
|
488
|
+
id: "reports-config-loading",
|
|
489
|
+
testId: "reports-config-loading",
|
|
490
|
+
className: I.fullWidth,
|
|
491
|
+
type: "multi"
|
|
492
|
+
}
|
|
493
|
+
) : R ? null : !n || c.length === 0 ? /* @__PURE__ */ a(
|
|
494
|
+
"p",
|
|
495
|
+
{
|
|
496
|
+
id: "reports-empty-state",
|
|
497
|
+
"data-testid": "reports-empty-state",
|
|
498
|
+
className: I.emptyState,
|
|
499
|
+
children: e("REPORTS_EMPTY_STATE_MESSAGE")
|
|
500
|
+
}
|
|
501
|
+
) : /* @__PURE__ */ m(
|
|
502
|
+
"div",
|
|
503
|
+
{
|
|
504
|
+
id: "report-list",
|
|
505
|
+
"data-testid": "report-list",
|
|
506
|
+
className: I.reportList,
|
|
507
|
+
children: [
|
|
508
|
+
/* @__PURE__ */ a(
|
|
509
|
+
ft,
|
|
510
|
+
{
|
|
511
|
+
startDate: f,
|
|
512
|
+
endDate: P,
|
|
513
|
+
format: r,
|
|
514
|
+
selectedPreset: S,
|
|
515
|
+
availableFormats: D,
|
|
516
|
+
onStartDateChange: p,
|
|
517
|
+
onEndDateChange: i,
|
|
518
|
+
onFormatChange: O,
|
|
519
|
+
onPresetChange: h,
|
|
520
|
+
onReset: ne,
|
|
521
|
+
onApply: re
|
|
522
|
+
}
|
|
523
|
+
),
|
|
524
|
+
/* @__PURE__ */ m(Ee, { align: "start", children: [
|
|
525
|
+
/* @__PURE__ */ a(
|
|
526
|
+
q,
|
|
527
|
+
{
|
|
528
|
+
title: e("REPORTS_DATE_RANGE_SECTION_TITLE"),
|
|
529
|
+
testId: "reports-date-range-section",
|
|
530
|
+
open: !0,
|
|
531
|
+
children: /* @__PURE__ */ a(
|
|
532
|
+
w,
|
|
533
|
+
{
|
|
534
|
+
reports: g,
|
|
535
|
+
appliedFilters: o,
|
|
536
|
+
availableFormats: D,
|
|
537
|
+
defaultPaperSize: T
|
|
538
|
+
}
|
|
539
|
+
)
|
|
540
|
+
}
|
|
541
|
+
),
|
|
542
|
+
/* @__PURE__ */ a(
|
|
543
|
+
q,
|
|
544
|
+
{
|
|
545
|
+
title: e("REPORTS_NO_DATE_RANGE_SECTION_TITLE"),
|
|
546
|
+
testId: "reports-no-date-range-section",
|
|
547
|
+
open: !0,
|
|
548
|
+
children: /* @__PURE__ */ a(
|
|
549
|
+
w,
|
|
550
|
+
{
|
|
551
|
+
reports: ae,
|
|
552
|
+
appliedFilters: o,
|
|
553
|
+
availableFormats: D,
|
|
554
|
+
defaultPaperSize: T
|
|
555
|
+
}
|
|
556
|
+
)
|
|
557
|
+
}
|
|
558
|
+
)
|
|
559
|
+
] })
|
|
560
|
+
]
|
|
561
|
+
}
|
|
562
|
+
);
|
|
563
|
+
}, Pt = "ReportsPage-module_page__ewRXe", gt = "ReportsPage-module_panel__HFBCt", B = {
|
|
564
|
+
page: Pt,
|
|
565
|
+
panel: gt
|
|
566
|
+
}, z = 1, At = 0, yt = () => {
|
|
567
|
+
const { t: e } = b(), t = Ce(), s = be(), d = y(
|
|
568
|
+
() => [
|
|
569
|
+
{ id: "home", label: e("REPORTS_HOME_LABEL"), href: Se },
|
|
570
|
+
{ id: "reports", label: e("REPORTS_LABEL"), isCurrentPage: !0 }
|
|
571
|
+
],
|
|
572
|
+
[e]
|
|
573
|
+
), n = t.pathname === U ? z : At, _ = K(
|
|
574
|
+
({ selectedIndex: R }) => {
|
|
575
|
+
s(
|
|
576
|
+
R === z ? U : fe
|
|
577
|
+
);
|
|
578
|
+
},
|
|
579
|
+
[s]
|
|
580
|
+
);
|
|
581
|
+
return /* @__PURE__ */ a(
|
|
582
|
+
Oe,
|
|
583
|
+
{
|
|
584
|
+
header: /* @__PURE__ */ a(
|
|
585
|
+
"div",
|
|
586
|
+
{
|
|
587
|
+
id: "reports-page-header",
|
|
588
|
+
"data-testid": "reports-page-header-test-id",
|
|
589
|
+
"aria-label": "Reports Page Header",
|
|
590
|
+
children: /* @__PURE__ */ a(
|
|
591
|
+
he,
|
|
592
|
+
{
|
|
593
|
+
breadcrumbItems: d,
|
|
594
|
+
userMenu: /* @__PURE__ */ a(De, {})
|
|
595
|
+
}
|
|
596
|
+
)
|
|
597
|
+
}
|
|
598
|
+
),
|
|
599
|
+
main: /* @__PURE__ */ a(
|
|
600
|
+
"div",
|
|
601
|
+
{
|
|
602
|
+
id: "reports-page",
|
|
603
|
+
"data-testid": "reports-page-test-id",
|
|
604
|
+
"aria-label": "Reports Page",
|
|
605
|
+
className: B.page,
|
|
606
|
+
children: /* @__PURE__ */ m(Pe, { selectedIndex: n, onChange: _, children: [
|
|
607
|
+
/* @__PURE__ */ m(
|
|
608
|
+
ge,
|
|
609
|
+
{
|
|
610
|
+
id: "reports-tab-list",
|
|
611
|
+
"data-testid": "reports-tab-list-test-id",
|
|
612
|
+
"aria-label": e("REPORTS_TAB_LIST_ARIA_LABEL"),
|
|
613
|
+
children: [
|
|
614
|
+
/* @__PURE__ */ a(
|
|
615
|
+
k,
|
|
616
|
+
{
|
|
617
|
+
id: "reports-tab",
|
|
618
|
+
"data-testid": "reports-tab-test-id",
|
|
619
|
+
"aria-label": e("REPORTS_TAB_LABEL"),
|
|
620
|
+
children: e("REPORTS_TAB_LABEL")
|
|
621
|
+
}
|
|
622
|
+
),
|
|
623
|
+
/* @__PURE__ */ a(
|
|
624
|
+
k,
|
|
625
|
+
{
|
|
626
|
+
id: "my-reports-tab",
|
|
627
|
+
"data-testid": "my-reports-tab-test-id",
|
|
628
|
+
"aria-label": e("REPORTS_MY_REPORTS_TAB_LABEL"),
|
|
629
|
+
children: e("REPORTS_MY_REPORTS_TAB_LABEL")
|
|
630
|
+
}
|
|
631
|
+
)
|
|
632
|
+
]
|
|
633
|
+
}
|
|
634
|
+
),
|
|
635
|
+
/* @__PURE__ */ m(Ae, { children: [
|
|
636
|
+
/* @__PURE__ */ a(
|
|
637
|
+
$,
|
|
638
|
+
{
|
|
639
|
+
id: "reports-tab-panel",
|
|
640
|
+
"data-testid": "reports-tab-panel-test-id",
|
|
641
|
+
"aria-label": e("REPORTS_TAB_LABEL"),
|
|
642
|
+
className: B.panel,
|
|
643
|
+
children: /* @__PURE__ */ a(Ot, {})
|
|
644
|
+
}
|
|
645
|
+
),
|
|
646
|
+
/* @__PURE__ */ a(
|
|
647
|
+
$,
|
|
648
|
+
{
|
|
649
|
+
id: "my-reports-tab-panel",
|
|
650
|
+
"data-testid": "my-reports-tab-panel-test-id",
|
|
651
|
+
"aria-label": e("REPORTS_MY_REPORTS_TAB_LABEL"),
|
|
652
|
+
className: B.panel,
|
|
653
|
+
children: /* @__PURE__ */ a("p", { children: e("REPORTS_MY_REPORTS_TAB_PLACEHOLDER") })
|
|
654
|
+
}
|
|
655
|
+
)
|
|
656
|
+
] })
|
|
657
|
+
] })
|
|
658
|
+
}
|
|
659
|
+
)
|
|
660
|
+
}
|
|
661
|
+
);
|
|
662
|
+
};
|
|
663
|
+
export {
|
|
664
|
+
yt as ReportsPage,
|
|
665
|
+
yt as default
|
|
666
|
+
};
|