@bahmni/admin-app 0.0.1-dev.439 → 0.0.1-dev.441

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.
@@ -1,11 +1,11 @@
1
1
  import { jsx as e } from "react/jsx-runtime";
2
- import { y as o, C as a, D as s, E as N } from "./index-DCAEnw_P.js";
2
+ import { A as o, p as a, r as s, t as r } from "./index-C1nJC-ZZ.js";
3
3
  import "react";
4
4
  import "@tanstack/react-query";
5
5
  const i = () => /* @__PURE__ */ e(o, { children: /* @__PURE__ */ e(
6
6
  a,
7
7
  {
8
- extensionPointId: N,
8
+ extensionPointId: r,
9
9
  appName: s,
10
10
  loadingLabelKey: "ADMIN_LOADING_MODULES",
11
11
  errorMessageKey: "ADMIN_ERROR_FETCH_CONFIG",
package/dist/App.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../src/App.tsx"],"names":[],"mappings":"AAoBA,wBAAgB,GAAG,4CA2ClB;AAED,eAAe,GAAG,CAAC"}
1
+ {"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../src/App.tsx"],"names":[],"mappings":"AAqBA,wBAAgB,GAAG,4CA2ClB;AAED,eAAe,GAAG,CAAC"}
@@ -1,10 +1,10 @@
1
1
  import { jsx as d, jsxs as S } from "react/jsx-runtime";
2
- import { N as ee, G as te, V as se, I as K, u as ae, K as ne, Q as re, y as ie, S as oe, X as ue, Z as de, _ as C, a0 as v, a1 as le } from "./index-DCAEnw_P.js";
3
- import { useState as l, useRef as U, useEffect as G, useMemo as ce, useCallback as me } from "react";
2
+ import { _ as ee, a0 as te, a1 as se, a2 as K, u as ae, a3 as ne, a4 as re, A as ie, S as oe, a5 as ue, a6 as de, a7 as U, U as H, a8 as le } from "./index-C1nJC-ZZ.js";
3
+ import { useState as l, useRef as C, useEffect as k, useMemo as ce, useCallback as me } from "react";
4
4
  import { useQuery as _e } from "@tanstack/react-query";
5
- const k = Symbol.for("constructDateFrom");
5
+ const G = Symbol.for("constructDateFrom");
6
6
  function y(e, t) {
7
- return typeof e == "function" ? e(t) : e && typeof e == "object" && k in e ? e[k](t) : e instanceof Date ? new e.constructor(t) : new Date(t);
7
+ return typeof e == "function" ? e(t) : e && typeof e == "object" && G in e ? e[G](t) : e instanceof Date ? new e.constructor(t) : new Date(t);
8
8
  }
9
9
  function w(e, t) {
10
10
  return y(e, e);
@@ -32,15 +32,15 @@ const Le = (e, t) => {
32
32
  }
33
33
  if (!Number.isNaN(r.getTime()))
34
34
  return r.toISOString();
35
- }, q = "NO_EVENTS_FOUND", Y = "NO_MORE_EVENTS_FOUND", Ie = "MATCHING_EVENTS_NOT_FOUND", Te = () => {
35
+ }, q = "NO_EVENTS_FOUND", Y = "NO_MORE_EVENTS_FOUND", Te = "MATCHING_EVENTS_NOT_FOUND", Ie = () => {
36
36
  const [e, t] = l({
37
37
  startDate: ee(),
38
38
  startTime: "00:00",
39
39
  username: "",
40
40
  patientId: ""
41
- }), [r, a] = l(0), [i, u] = l(0), [_, E] = l([]), [R, p] = l(null), [b, f] = l(!1), [F, g] = l(!1), [O, M] = l(1), I = U(1), s = (c) => {
42
- I.current = c, M(c);
43
- }, o = U(0), [n, j] = l(null), B = U(null), { data: N, isLoading: Q, isFetching: L, isError: X } = _e({
41
+ }), [r, a] = l(0), [i, u] = l(0), [_, E] = l([]), [R, p] = l(null), [b, f] = l(!1), [F, g] = l(!1), [O, M] = l(1), T = C(1), s = (c) => {
42
+ T.current = c, M(c);
43
+ }, o = C(0), [n, j] = l(null), B = C(null), { data: N, isLoading: z, isFetching: L, isError: Q } = _e({
44
44
  queryKey: ["auditLogs", n?.requestId],
45
45
  queryFn: () => te(n.params),
46
46
  enabled: !!n,
@@ -48,18 +48,18 @@ const Le = (e, t) => {
48
48
  // (and audit logs must always be fetched fresh). Drop entries as soon as
49
49
  // they become inactive instead of retaining them for the default gcTime.
50
50
  gcTime: 0
51
- }), T = (c, H, m, D, h, $) => {
51
+ }), I = (c, V, m, D, h, $) => {
52
52
  o.current += 1, j({
53
53
  action: c,
54
- params: H,
54
+ params: V,
55
55
  alwaysReplace: m,
56
56
  defaultFirstIndex: D,
57
57
  defaultLastIndex: h,
58
58
  emptyMessageKey: $,
59
59
  requestId: o.current
60
60
  });
61
- }, A = Le(e.startDate, e.startTime), z = () => {
62
- T(
61
+ }, A = Le(e.startDate, e.startTime), X = () => {
62
+ I(
63
63
  "init",
64
64
  { startFrom: A, defaultView: !0 },
65
65
  !0,
@@ -67,13 +67,13 @@ const Le = (e, t) => {
67
67
  0,
68
68
  q
69
69
  );
70
- }, V = () => !!r || !!i, Z = () => {
70
+ }, v = () => !!r || !!i, W = () => {
71
71
  if (!L) {
72
- if (!V()) {
72
+ if (!v()) {
73
73
  x();
74
74
  return;
75
75
  }
76
- T(
76
+ I(
77
77
  "next",
78
78
  {
79
79
  lastAuditLogId: i,
@@ -88,13 +88,13 @@ const Le = (e, t) => {
88
88
  Y
89
89
  );
90
90
  }
91
- }, W = () => {
91
+ }, Z = () => {
92
92
  if (!L) {
93
- if (!V()) {
93
+ if (!v()) {
94
94
  x();
95
95
  return;
96
96
  }
97
- T(
97
+ I(
98
98
  "prev",
99
99
  {
100
100
  lastAuditLogId: r,
@@ -109,7 +109,7 @@ const Le = (e, t) => {
109
109
  );
110
110
  }
111
111
  }, x = () => {
112
- L || T(
112
+ L || I(
113
113
  "runReport",
114
114
  {
115
115
  defaultView: !0,
@@ -120,7 +120,7 @@ const Le = (e, t) => {
120
120
  !0,
121
121
  0,
122
122
  0,
123
- Ie
123
+ Te
124
124
  );
125
125
  }, J = () => {
126
126
  L || (t({
@@ -128,11 +128,11 @@ const Le = (e, t) => {
128
128
  startTime: "",
129
129
  username: "",
130
130
  patientId: ""
131
- }), T("init", { defaultView: !0 }, !0, 0, 0, q));
131
+ }), I("init", { defaultView: !0 }, !0, 0, 0, q));
132
132
  };
133
- return G(() => {
134
- z();
135
- }, []), G(() => {
133
+ return k(() => {
134
+ X();
135
+ }, []), k(() => {
136
136
  if (!n || N === void 0 || B.current === n.requestId) return;
137
137
  B.current = n.requestId;
138
138
  const c = !!n.params.defaultView, m = (c ? N : [...N].reverse()).map(se), D = m.length === K;
@@ -140,10 +140,10 @@ const Le = (e, t) => {
140
140
  if (E(m), p(null), a(m[0].auditLogId), u(m[m.length - 1].auditLogId), c)
141
141
  g(!1), f(D), s(1);
142
142
  else if (n.action === "next")
143
- g(!0), f(D), s(I.current + 1);
143
+ g(!0), f(D), s(T.current + 1);
144
144
  else {
145
145
  f(!0);
146
- const h = Math.max(1, I.current - 1);
146
+ const h = Math.max(1, T.current - 1);
147
147
  g(h > 1), s(h);
148
148
  }
149
149
  else
@@ -152,17 +152,17 @@ const Le = (e, t) => {
152
152
  filters: e,
153
153
  setFilters: t,
154
154
  logs: _,
155
- isLoading: Q || L,
155
+ isLoading: z || L,
156
156
  isFetching: L,
157
- isError: X,
157
+ isError: Q,
158
158
  emptyMessageKey: R,
159
159
  firstIndex: r,
160
160
  lastIndex: i,
161
161
  hasNext: b,
162
162
  hasPrevious: F,
163
163
  currentPageNumber: O,
164
- next: Z,
165
- prev: W,
164
+ next: W,
165
+ prev: Z,
166
166
  runReport: x,
167
167
  reset: J
168
168
  };
@@ -186,7 +186,7 @@ const Le = (e, t) => {
186
186
  prev: F,
187
187
  runReport: g,
188
188
  reset: O
189
- } = Te(), M = ce(
189
+ } = Ie(), M = ce(
190
190
  () => [
191
191
  { key: "auditLogId", header: e("EVENT_ID") },
192
192
  { key: "dateCreated", header: e("CREATED_AT") },
@@ -197,7 +197,7 @@ const Le = (e, t) => {
197
197
  { key: "module", header: e("MODULE") }
198
198
  ],
199
199
  [e]
200
- ), I = me(
200
+ ), T = me(
201
201
  (s, o) => {
202
202
  switch (o) {
203
203
  case "dateCreated":
@@ -256,7 +256,7 @@ const Le = (e, t) => {
256
256
  t.startDate?.getTime() ?? "empty"
257
257
  ),
258
258
  /* @__PURE__ */ d(
259
- C,
259
+ U,
260
260
  {
261
261
  id: "audit-log-start-time",
262
262
  type: "time",
@@ -270,7 +270,7 @@ const Le = (e, t) => {
270
270
  }
271
271
  ),
272
272
  /* @__PURE__ */ d(
273
- C,
273
+ U,
274
274
  {
275
275
  id: "audit-log-username",
276
276
  labelText: e("USERNAME_FILTER_LABEL"),
@@ -284,7 +284,7 @@ const Le = (e, t) => {
284
284
  }
285
285
  ),
286
286
  /* @__PURE__ */ d(
287
- C,
287
+ U,
288
288
  {
289
289
  id: "audit-log-patient-id",
290
290
  labelText: e("PATIENT_ID_FILTER_LABEL"),
@@ -298,7 +298,7 @@ const Le = (e, t) => {
298
298
  }
299
299
  ),
300
300
  /* @__PURE__ */ d(
301
- v,
301
+ H,
302
302
  {
303
303
  kind: "tertiary",
304
304
  onClick: O,
@@ -308,7 +308,7 @@ const Le = (e, t) => {
308
308
  }
309
309
  ),
310
310
  /* @__PURE__ */ d(
311
- v,
311
+ H,
312
312
  {
313
313
  kind: "primary",
314
314
  onClick: g,
@@ -328,7 +328,7 @@ const Le = (e, t) => {
328
328
  title: e("AUDIT_LOG_TABLE_HEADER_LABEL"),
329
329
  dataTestId: "audit-log-table",
330
330
  loading: i,
331
- renderCell: I,
331
+ renderCell: T,
332
332
  emptyStateMessage: E ? e(E) : void 0,
333
333
  errorStateMessage: _ ? e("ADMIN_ERROR_FETCH_CONFIG") : null,
334
334
  pagination: {
@@ -0,0 +1,122 @@
1
+ import { jsx as n, jsxs as d } from "react/jsx-runtime";
2
+ import { u as M, z as N, x as R, y as O, C as h, M as P, O as g, A as V, S as x, T as D, U as f, V as y } from "./index-C1nJC-ZZ.js";
3
+ import { useState as E, useMemo as b } from "react";
4
+ import { useQuery as L, useMutation as v } from "@tanstack/react-query";
5
+ const X = "CsvExport-module_tile__yBrLM", B = "CsvExport-module_title__epZnI", U = "CsvExport-module_form__w-cN-", z = "CsvExport-module_search__G82i7", r = {
6
+ tile: X,
7
+ title: B,
8
+ form: U,
9
+ search: z
10
+ }, G = 300, S = 2, _ = 5e3, H = "custom:(uuid,setMembers:(uuid))", K = () => {
11
+ const { t } = M(), { addNotification: i } = N(), [p, C] = E(""), [s, c] = E(
12
+ null
13
+ ), a = R(p.trim(), G), { data: l = [] } = L({
14
+ queryKey: ["csvExportConceptSearch", a],
15
+ queryFn: () => O(a),
16
+ enabled: a.length >= S && a !== s?.name,
17
+ // Keep prior options visible while the next term loads, but not once the input is too short to search
18
+ placeholderData: (e) => a.length >= S ? e : void 0
19
+ }), T = b(
20
+ () => l.flatMap(
21
+ (e) => e.name?.name ? [{ uuid: e.uuid, name: e.name.name }] : []
22
+ ),
23
+ [l]
24
+ ), o = v({
25
+ mutationFn: async (e) => (await P(e.uuid, H)).setMembers?.length ? g(e.name) : null,
26
+ onSuccess: (e, u) => {
27
+ const m = u.name;
28
+ if (!e || e.size === 0) {
29
+ i({
30
+ type: "error",
31
+ title: t("ADMIN_CSV_EXPORT_NO_DATA_TITLE"),
32
+ message: t("ADMIN_CSV_EXPORT_NO_DATA_MESSAGE"),
33
+ timeout: _
34
+ });
35
+ return;
36
+ }
37
+ h(e, `${m}.zip`), i({
38
+ type: "success",
39
+ title: t("ADMIN_CSV_EXPORT_SUCCESS_TITLE"),
40
+ message: t("ADMIN_CSV_EXPORT_SUCCESS_MESSAGE", { conceptName: m }),
41
+ timeout: _
42
+ });
43
+ },
44
+ onError: (e) => {
45
+ i({
46
+ type: "error",
47
+ title: t("ADMIN_CSV_EXPORT_ERROR_TITLE"),
48
+ message: e.message,
49
+ timeout: _
50
+ });
51
+ }
52
+ }), I = (e) => {
53
+ C(e), s && e !== s.name && c(null);
54
+ }, A = (e) => {
55
+ if (e.preventDefault(), !o.isPending) {
56
+ if (!s) {
57
+ i({
58
+ type: "error",
59
+ title: t("ADMIN_CSV_EXPORT_SELECT_CONCEPT_TITLE"),
60
+ message: t("ADMIN_CSV_EXPORT_SELECT_CONCEPT_MESSAGE"),
61
+ timeout: _
62
+ });
63
+ return;
64
+ }
65
+ o.mutate(s);
66
+ }
67
+ };
68
+ return /* @__PURE__ */ n(V, { breadcrumbLabel: t("BREADCRUMB_CSV_EXPORT"), children: /* @__PURE__ */ d(
69
+ x,
70
+ {
71
+ id: "admin-csv-export-page",
72
+ "data-testid": "admin-csv-export-page-test-id",
73
+ "aria-label": "CSV Export Page",
74
+ className: r.tile,
75
+ children: [
76
+ /* @__PURE__ */ n("h2", { className: r.title, children: t("ADMIN_CSV_EXPORT_TITLE") }),
77
+ /* @__PURE__ */ d("form", { className: r.form, onSubmit: A, noValidate: !0, children: [
78
+ /* @__PURE__ */ n("div", { className: r.search, children: /* @__PURE__ */ n(
79
+ D,
80
+ {
81
+ id: "csv-export-concept-search",
82
+ "data-testid": "csv-export-concept-search-test-id",
83
+ titleText: "",
84
+ placeholder: t("ADMIN_CSV_EXPORT_SEARCH_PLACEHOLDER"),
85
+ "aria-label": t("ADMIN_CSV_EXPORT_SEARCH_ARIA_LABEL"),
86
+ items: T,
87
+ itemToString: (e) => e?.name ?? "",
88
+ selectedItem: s,
89
+ onChange: ({ selectedItem: e }) => c(
90
+ typeof e == "object" ? e ?? null : null
91
+ ),
92
+ onInputChange: I,
93
+ allowCustomValue: !0,
94
+ disabled: o.isPending,
95
+ size: "md"
96
+ }
97
+ ) }),
98
+ /* @__PURE__ */ n(
99
+ f,
100
+ {
101
+ type: "submit",
102
+ kind: "primary",
103
+ size: "md",
104
+ testId: "csv-export-button-test-id",
105
+ disabled: o.isPending,
106
+ children: o.isPending ? /* @__PURE__ */ n(
107
+ y,
108
+ {
109
+ description: t("ADMIN_CSV_EXPORT_IN_PROGRESS"),
110
+ testId: "csv-export-loading-test-id"
111
+ }
112
+ ) : t("ADMIN_CSV_EXPORT_BUTTON")
113
+ }
114
+ )
115
+ ] })
116
+ ]
117
+ }
118
+ ) });
119
+ };
120
+ export {
121
+ K as CsvExport
122
+ };
@@ -1,5 +1,5 @@
1
1
  import { jsx as a, jsxs as e } from "react/jsx-runtime";
2
- import { u as d, y as o } from "./index-DCAEnw_P.js";
2
+ import { u as d, A as o } from "./index-C1nJC-ZZ.js";
3
3
  const t = "CsvUpload-module_page__AxMNv", i = {
4
4
  page: t
5
5
  }, n = () => {
@@ -1,5 +1,5 @@
1
1
  import { jsx as d, jsxs as h, Fragment as x } from "react/jsx-runtime";
2
- import { d as G, u as W, z as Y, R as J, s as X, h as Z, $ as ee, a as te } from "./index-DCAEnw_P.js";
2
+ import { d as G, u as W, z as Y, P as J, s as X, h as Z, $ as ee, a as te } from "./index-C1nJC-ZZ.js";
3
3
  import { useQuery as ae } from "@tanstack/react-query";
4
4
  import { useState as l, useCallback as _, useEffect as I, useMemo as p } from "react";
5
5
  const ne = "DocumentsTable-module_documentsTableBody__6iR3w", oe = "DocumentsTable-module_viewAttachmentsLink__aQ1on", de = "DocumentsTable-module_documentViewerContainer__F5m8D", re = "DocumentsTable-module_attachmentItem__17KA7", se = "DocumentsTable-module_attachmentCounter__WFiI3", me = "DocumentsTable-module_attachmentError__RI4U2", ce = "DocumentsTable-module_documentIframe__ptq5I", le = "DocumentsTable-module_documentImage__KQVgS", r = {
@@ -18,7 +18,7 @@ const ne = "DocumentsTable-module_documentsTableBody__6iR3w", oe = "DocumentsTab
18
18
  uploadedBy: "DOCUMENTS_UPLOADED_BY",
19
19
  attachments: "DOCUMENTS_ATTACHMENTS"
20
20
  };
21
- function v(a) {
21
+ function R(a) {
22
22
  return !a || a.includes(":") ? "#" : `/openmrs/auth?requested_document=/document_images/${a}`;
23
23
  }
24
24
  function ie(a, E) {
@@ -42,9 +42,9 @@ const Te = [
42
42
  U(e), w(!0);
43
43
  }, []), H = _(() => {
44
44
  w(!1), U(null), O(/* @__PURE__ */ new Set());
45
- }, []), R = _((e) => {
45
+ }, []), v = _((e) => {
46
46
  O((t) => new Set(t).add(e));
47
- }, []), { data: i, isLoading: q, isError: y, error: b } = ae({
47
+ }, []), { data: i, isLoading: P, isError: y, error: b } = ae({
48
48
  queryKey: [
49
49
  "documents",
50
50
  g,
@@ -76,7 +76,7 @@ const Te = [
76
76
  if (!s || !o) return;
77
77
  const t = /* @__PURE__ */ new Set(), m = B(o);
78
78
  for (let c = 0; c < m.length; c++) {
79
- const S = v(m[c].url);
79
+ const S = R(m[c].url);
80
80
  try {
81
81
  (await fetch(S, {
82
82
  method: "HEAD",
@@ -89,7 +89,7 @@ const Te = [
89
89
  e.signal.aborted || O(t);
90
90
  })(), () => e.abort();
91
91
  }, [s, o]);
92
- const z = _(
92
+ const q = _(
93
93
  (e, t) => {
94
94
  t !== u ? (V(t), C(1), A(void 0)) : C(e);
95
95
  },
@@ -97,7 +97,7 @@ const Te = [
97
97
  ), N = p(
98
98
  () => a?.fields ?? Te,
99
99
  [a?.fields]
100
- ), j = p(() => [...i?.documents ?? []].sort((e, t) => !e.uploadedOn && !t.uploadedOn ? 0 : e.uploadedOn ? t.uploadedOn ? new Date(t.uploadedOn).getTime() - new Date(e.uploadedOn).getTime() : -1 : 1), [i]), P = p(() => ie(N, n), [N, n]), K = p(
100
+ ), z = p(() => [...i?.documents ?? []].sort((e, t) => !e.uploadedOn && !t.uploadedOn ? 0 : e.uploadedOn ? t.uploadedOn ? new Date(t.uploadedOn).getTime() - new Date(e.uploadedOn).getTime() : -1 : 1), [i]), j = p(() => ie(N, n), [N, n]), K = p(
101
101
  () => N.map((e) => ({
102
102
  key: e,
103
103
  sortable: e !== "attachments"
@@ -141,10 +141,10 @@ const Te = [
141
141
  /* @__PURE__ */ d("div", { "data-testid": "documents-table", children: /* @__PURE__ */ d(
142
142
  ee,
143
143
  {
144
- headers: P,
144
+ headers: j,
145
145
  ariaLabel: n("DOCUMENTS_TABLE_HEADING"),
146
- rows: j,
147
- loading: q,
146
+ rows: z,
147
+ loading: P,
148
148
  errorStateMessage: y ? b?.message : null,
149
149
  sortable: K,
150
150
  emptyStateMessage: n("DOCUMENTS_NO_RECORDS"),
@@ -154,7 +154,7 @@ const Te = [
154
154
  pageSize: u,
155
155
  totalItems: F,
156
156
  page: f,
157
- onPageChange: z
157
+ onPageChange: q
158
158
  }
159
159
  ) }),
160
160
  s && o && /* @__PURE__ */ d(
@@ -169,7 +169,7 @@ const Te = [
169
169
  size: "lg",
170
170
  testId: "document-view-modal",
171
171
  children: /* @__PURE__ */ d("div", { className: r.documentViewerContainer, children: T.map((e, t) => {
172
- const m = v(e.url), c = e.contentType?.toLowerCase().includes("pdf"), S = (e.contentType?.toLowerCase().includes("image") ?? !1) || he.test(e.url ?? ""), D = $.has(t);
172
+ const m = R(e.url), c = e.contentType?.toLowerCase().includes("pdf"), S = (e.contentType?.toLowerCase().includes("image") ?? !1) || he.test(e.url ?? ""), D = $.has(t);
173
173
  return m === "#" || D ? /* @__PURE__ */ h(
174
174
  "div",
175
175
  {
@@ -202,7 +202,7 @@ const Te = [
202
202
  src: m,
203
203
  alt: o.documentIdentifier,
204
204
  className: r.documentImage,
205
- onError: () => R(t)
205
+ onError: () => v(t)
206
206
  }
207
207
  ) : /* @__PURE__ */ d(
208
208
  "iframe",
@@ -210,7 +210,7 @@ const Te = [
210
210
  src: c ? `${m}#toolbar=0` : m,
211
211
  className: r.documentIframe,
212
212
  title: o.documentIdentifier,
213
- onError: () => R(t)
213
+ onError: () => v(t)
214
214
  }
215
215
  )
216
216
  ]