@kenyaemr/esm-bed-management-app 1.0.1-pre.7 → 8.0.3-pre.131

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 (176) hide show
  1. package/.turbo/turbo-build.log +36 -0
  2. package/README.md +6 -38
  3. package/dist/130.js +2 -0
  4. package/dist/{800.js.LICENSE.txt → 130.js.LICENSE.txt} +2 -0
  5. package/dist/130.js.map +1 -0
  6. package/dist/148.js +1 -0
  7. package/dist/148.js.map +1 -0
  8. package/dist/169.js +1 -0
  9. package/dist/169.js.map +1 -0
  10. package/dist/271.js +1 -0
  11. package/dist/319.js +1 -0
  12. package/dist/325.js +1 -0
  13. package/dist/325.js.map +1 -0
  14. package/dist/339.js +1 -0
  15. package/dist/339.js.map +1 -0
  16. package/dist/455.js +1 -1
  17. package/dist/455.js.LICENSE.txt +6 -0
  18. package/dist/455.js.map +1 -1
  19. package/dist/460.js +1 -0
  20. package/dist/501.js +1 -0
  21. package/dist/501.js.map +1 -0
  22. package/dist/542.js +1 -0
  23. package/dist/542.js.map +1 -0
  24. package/dist/574.js +1 -1
  25. package/dist/591.js +2 -0
  26. package/dist/{26.js.LICENSE.txt → 591.js.LICENSE.txt} +3 -3
  27. package/dist/591.js.map +1 -0
  28. package/dist/644.js +1 -0
  29. package/dist/757.js +1 -0
  30. package/dist/766.js +2 -0
  31. package/dist/{330.js.LICENSE.txt → 766.js.LICENSE.txt} +0 -9
  32. package/dist/766.js.map +1 -0
  33. package/dist/{294.js → 784.js} +2 -2
  34. package/dist/{294.js.map → 784.js.map} +1 -1
  35. package/dist/788.js +1 -0
  36. package/dist/807.js +1 -0
  37. package/dist/833.js +1 -0
  38. package/dist/main.js +1 -1
  39. package/dist/main.js.map +1 -1
  40. package/dist/openmrs-esm-bed-management-app.js +1 -0
  41. package/dist/{esm-kenyaemr-bed-management-app.js.buildmanifest.json → openmrs-esm-bed-management-app.js.buildmanifest.json} +202 -155
  42. package/dist/openmrs-esm-bed-management-app.js.map +1 -0
  43. package/dist/routes.json +1 -1
  44. package/jest.config.js +3 -0
  45. package/package-lock.json +5893 -0
  46. package/package.json +25 -82
  47. package/src/__mocks__/react-i18next.js +18 -14
  48. package/src/admin-card-link.component.tsx +7 -10
  49. package/src/bed-administration/bed-administration-form.component.tsx +65 -99
  50. package/src/bed-administration/bed-administration-table.component.tsx +68 -127
  51. package/src/bed-administration/bed-administration-table.scss +12 -16
  52. package/src/bed-administration/bed-administration.resource.ts +16 -18
  53. package/src/bed-administration/edit-bed-form.component.tsx +20 -31
  54. package/src/bed-administration/new-bed-form.component.tsx +28 -44
  55. package/src/{bed-admission/bed-tag → bed-tag}/bed-tag-administration-table.component.tsx +35 -60
  56. package/src/{bed-admission/bed-tag → bed-tag}/bed-tags-admin-form.component.tsx +30 -34
  57. package/src/{bed-admission/bed-tag → bed-tag}/edit-tag-form.component.tsx +17 -25
  58. package/src/{bed-admission/bed-tag → bed-tag}/new-tag-form.component.tsx +20 -27
  59. package/src/{bed-admission/bed-type → bed-type}/bed-type-admin-form.component.tsx +37 -44
  60. package/src/{bed-admission/bed-type → bed-type}/bed-type-administration-table.component.tsx +36 -60
  61. package/src/{bed-admission/bed-type → bed-type}/edit-bed-type.component.tsx +17 -25
  62. package/src/{bed-admission/bed-type → bed-type}/new-bed-type-form.component.tsx +21 -28
  63. package/src/card-header/card-header.component.tsx +20 -0
  64. package/src/card-header/card-header.scss +45 -0
  65. package/src/config-schema.ts +9 -17
  66. package/src/declarations.d.ts +5 -5
  67. package/src/empty-state/empty-state.component.tsx +6 -21
  68. package/src/empty-state/empty-state.scss +10 -10
  69. package/src/header/header.component.tsx +14 -23
  70. package/src/header/header.scss +11 -11
  71. package/src/header/illustration.component.tsx +3 -3
  72. package/src/home.component.tsx +4 -4
  73. package/src/index.ts +21 -48
  74. package/src/left-panel/left-panel.component.tsx +7 -17
  75. package/src/left-panel/left-panel.scss +8 -7
  76. package/src/left-panel-link.component.tsx +14 -24
  77. package/src/root.component.tsx +12 -12
  78. package/src/root.scss +2 -2
  79. package/src/routes.json +12 -12
  80. package/src/setup-tests.ts +1 -1
  81. package/src/summary/summary.component.tsx +16 -30
  82. package/src/summary/summary.resource.ts +116 -95
  83. package/src/summary/summary.scss +31 -29
  84. package/src/types.ts +50 -40
  85. package/src/ward-card/ward-card.component.tsx +5 -12
  86. package/src/ward-card/ward-card.scss +2 -2
  87. package/src/ward-with-beds/ward-with-beds.component.tsx +28 -47
  88. package/src/ward-with-beds/ward-with-beds.scss +5 -5
  89. package/translations/am.json +51 -0
  90. package/translations/ar.json +51 -0
  91. package/translations/en.json +48 -4
  92. package/translations/es.json +51 -0
  93. package/translations/fr.json +51 -0
  94. package/translations/he.json +51 -0
  95. package/translations/km.json +51 -0
  96. package/translations/zh.json +51 -0
  97. package/translations/zh_CN.json +51 -0
  98. package/tsconfig.json +3 -21
  99. package/webpack.config.js +1 -1
  100. package/.editorconfig +0 -12
  101. package/.eslintignore +0 -2
  102. package/.eslintrc +0 -37
  103. package/.husky/pre-commit +0 -4
  104. package/.idea/inspectionProfiles/Project_Default.xml +0 -6
  105. package/.idea/modules.xml +0 -8
  106. package/.idea/vcs.xml +0 -6
  107. package/.prettierignore +0 -14
  108. package/.turbo.json +0 -18
  109. package/.yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs +0 -541
  110. package/.yarn/plugins/@yarnpkg/plugin-version.cjs +0 -550
  111. package/.yarn/versions/cb9a89ac.yml +0 -0
  112. package/LICENSE +0 -373
  113. package/dist/187.js +0 -1
  114. package/dist/187.js.map +0 -1
  115. package/dist/207.js +0 -1
  116. package/dist/207.js.map +0 -1
  117. package/dist/26.js +0 -2
  118. package/dist/26.js.map +0 -1
  119. package/dist/283.js +0 -1
  120. package/dist/283.js.map +0 -1
  121. package/dist/330.js +0 -2
  122. package/dist/330.js.map +0 -1
  123. package/dist/352.js +0 -1
  124. package/dist/352.js.map +0 -1
  125. package/dist/404.js +0 -1
  126. package/dist/404.js.map +0 -1
  127. package/dist/558.js +0 -2
  128. package/dist/558.js.LICENSE.txt +0 -14
  129. package/dist/558.js.map +0 -1
  130. package/dist/629.js +0 -1
  131. package/dist/629.js.map +0 -1
  132. package/dist/707.js +0 -1
  133. package/dist/707.js.map +0 -1
  134. package/dist/800.js +0 -2
  135. package/dist/800.js.map +0 -1
  136. package/dist/850.js +0 -1
  137. package/dist/850.js.map +0 -1
  138. package/dist/884.js +0 -1
  139. package/dist/884.js.map +0 -1
  140. package/dist/933.js +0 -1
  141. package/dist/933.js.map +0 -1
  142. package/dist/esm-kenyaemr-bed-management-app.js +0 -1
  143. package/dist/esm-kenyaemr-bed-management-app.js.map +0 -1
  144. package/i18next-parser.config.js +0 -89
  145. package/src/assets/landing-page.png +0 -0
  146. package/src/assets/logo.svg +0 -1
  147. package/src/bed-admission/active-patients/active-patients-table.component.tsx +0 -299
  148. package/src/bed-admission/active-patients/active-visits.resource.ts +0 -171
  149. package/src/bed-admission/active-patients/admission-action-button-styles.scss +0 -0
  150. package/src/bed-admission/active-patients/admission-action-button.component.tsx +0 -26
  151. package/src/bed-admission/active-patients/index.tsx +0 -15
  152. package/src/bed-admission/active-patients/patient-queues.resource.ts +0 -136
  153. package/src/bed-admission/active-patients/styles.scss +0 -284
  154. package/src/bed-admission/active-patients/view-action-menu.component.tsx +0 -33
  155. package/src/bed-admission/admitted-patients/active-admissions.resource.ts +0 -121
  156. package/src/bed-admission/admitted-patients/admitted-patients-table.component.tsx +0 -280
  157. package/src/bed-admission/admitted-patients/admitted-patients.component.tsx +0 -22
  158. package/src/bed-admission/admitted-patients/location-combo-box.component.tsx +0 -55
  159. package/src/bed-admission/admitted-patients/styles.scss +0 -284
  160. package/src/bed-admission/bed-admission-tabs-styles.scss +0 -30
  161. package/src/bed-admission/bed-admission-tabs.component.tsx +0 -69
  162. package/src/bed-admission/bed-admission.component.tsx +0 -15
  163. package/src/bed-admission/bed-admission.resource.ts +0 -35
  164. package/src/bed-admission/bed-layout/bed-layout-list.component.tsx +0 -101
  165. package/src/bed-admission/bed-layout/bed-layout.component.tsx +0 -64
  166. package/src/bed-admission/bed-layout/bed-layout.scss +0 -118
  167. package/src/bed-admission/bed-layout/min-bed-layout.component.tsx +0 -26
  168. package/src/bed-admission/createDashboardLink.tsx +0 -47
  169. package/src/bed-admission/discharged-patients/discharged-patients.componet.tsx +0 -19
  170. package/src/bed-admission/helpers/functions.ts +0 -102
  171. package/src/bed-admission/types.ts +0 -133
  172. package/src/workspace/allocate-bed-workspace.component.tsx +0 -141
  173. package/src/workspace/allocate-bed.scss +0 -117
  174. package/src/workspace/overlay.component.tsx +0 -55
  175. package/src/workspace/overlay.scss +0 -96
  176. /package/dist/{294.js.LICENSE.txt → 784.js.LICENSE.txt} +0 -0
@@ -1,5 +1,5 @@
1
- import React, { useMemo, useState } from "react";
2
- import { useTranslation } from "react-i18next";
1
+ import React, { useMemo, useState } from 'react';
2
+ import { useTranslation } from 'react-i18next';
3
3
  import {
4
4
  Button,
5
5
  DataTable,
@@ -14,49 +14,44 @@ import {
14
14
  TableHeader,
15
15
  TableRow,
16
16
  Tile,
17
- } from "@carbon/react";
18
- import { Add, Edit } from "@carbon/react/icons";
19
- import {
20
- isDesktop as desktopLayout,
21
- useLayoutType,
22
- } from "@openmrs/esm-framework";
23
- import { CardHeader, ErrorState } from "@openmrs/esm-patient-common-lib";
24
- import type { BedTagData } from "../../types";
25
- import { useBedTag } from "../../summary/summary.resource";
26
- import Header from "../../header/header.component";
27
- import styles from "../../bed-administration/bed-administration-table.scss";
28
- import BedTagForm from "./new-tag-form.component";
29
- import EditBedTagForm from "./edit-tag-form.component";
17
+ } from '@carbon/react';
18
+ import { Add, Edit } from '@carbon/react/icons';
19
+ import { ErrorState, isDesktop as desktopLayout, useLayoutType } from '@openmrs/esm-framework';
20
+ import type { BedTagData } from '../types';
21
+ import { useBedTag } from '../summary/summary.resource';
22
+ import Header from '../header/header.component';
23
+ import styles from '../bed-administration/bed-administration-table.scss';
24
+ import { CardHeader } from '../card-header/card-header.component';
25
+ import BedTagForm from './new-tag-form.component';
26
+ import EditBedTagForm from './edit-tag-form.component';
30
27
 
31
28
  const BedTagAdministrationTable: React.FC = () => {
32
29
  const { t } = useTranslation();
33
- const headerTitle = t("bedTag", "Bed Tag");
30
+ const headerTitle = t('bedTag', 'Bed Tag');
34
31
  const layout = useLayoutType();
35
- const isTablet = layout === "tablet";
36
- const responsiveSize = isTablet ? "lg" : "sm";
32
+ const isTablet = layout === 'tablet';
33
+ const responsiveSize = isTablet ? 'lg' : 'sm';
37
34
  const isDesktop = desktopLayout(layout);
38
35
  const [isBedDataLoading] = useState(false);
39
36
  const [showBedTagsModal, setAddBedTagsModal] = useState(false);
40
37
  const [showEditBedModal, setShowEditBedModal] = useState(false);
41
38
  const [editData, setEditData] = useState<BedTagData>();
42
39
  const [currentPage, setCurrentPage] = useState(1);
43
- const [pageSize] = useState(10);
44
40
  const { bedTypeData, isError, loading, validate, mutate } = useBedTag();
45
- const [currentPageSize, setPageSize] = useState(10);
46
- const pageSizes = [10, 20, 30, 40, 50];
41
+ const [pageSize, setPageSize] = useState(10);
47
42
 
48
43
  const tableHeaders = [
49
44
  {
50
- header: t("ids", "Id"),
51
- key: "ids",
45
+ header: t('ids', 'Id'),
46
+ key: 'ids',
52
47
  },
53
48
  {
54
- header: t("name", "Name"),
55
- key: "name",
49
+ header: t('name', 'Name'),
50
+ key: 'name',
56
51
  },
57
52
  {
58
- header: t("actions", "Actions"),
59
- key: "actions",
53
+ header: t('actions', 'Actions'),
54
+ key: 'actions',
60
55
  },
61
56
  ];
62
57
 
@@ -76,8 +71,8 @@ const BedTagAdministrationTable: React.FC = () => {
76
71
  setShowEditBedModal(true);
77
72
  setAddBedTagsModal(false);
78
73
  }}
79
- kind={"ghost"}
80
- iconDescription={t("editBedTag", "Edit Bed Tag")}
74
+ kind={'ghost'}
75
+ iconDescription={t('editBedTag', 'Edit Bed Tag')}
81
76
  hasIconOnly
82
77
  size={responsiveSize}
83
78
  tooltipAlignment="start"
@@ -115,11 +110,7 @@ const BedTagAdministrationTable: React.FC = () => {
115
110
 
116
111
  <div className={styles.widgetCard}>
117
112
  {showBedTagsModal ? (
118
- <BedTagForm
119
- onModalChange={setAddBedTagsModal}
120
- showModal={showBedTagsModal}
121
- mutate={mutate}
122
- />
113
+ <BedTagForm onModalChange={setAddBedTagsModal} showModal={showBedTagsModal} mutate={mutate} />
123
114
  ) : null}
124
115
  {showEditBedModal ? (
125
116
  <EditBedTagForm
@@ -137,28 +128,19 @@ const BedTagAdministrationTable: React.FC = () => {
137
128
  <Button
138
129
  kind="ghost"
139
130
  renderIcon={(props) => <Add size={16} {...props} />}
140
- onClick={() => setAddBedTagsModal(true)}
141
- >
142
- {t("addBedTag", "Add Bed Tag")}
131
+ onClick={() => setAddBedTagsModal(true)}>
132
+ {t('addBedTag', 'Add Bed Tag')}
143
133
  </Button>
144
134
  ) : null}
145
135
  </CardHeader>
146
- <DataTable
147
- rows={tableRows}
148
- headers={tableHeaders}
149
- isSortable
150
- size={isTablet ? "lg" : "sm"}
151
- useZebraStyles
152
- >
136
+ <DataTable rows={tableRows} headers={tableHeaders} isSortable size={isTablet ? 'lg' : 'sm'} useZebraStyles>
153
137
  {({ rows, headers, getTableProps }) => (
154
138
  <TableContainer>
155
139
  <Table {...getTableProps()}>
156
140
  <TableHead>
157
141
  <TableRow>
158
142
  {headers.map((header) => (
159
- <TableHeader>
160
- {header.header?.content ?? header.header}
161
- </TableHeader>
143
+ <TableHeader>{header.header?.content ?? header.header}</TableHeader>
162
144
  ))}
163
145
  </TableRow>
164
146
  </TableHead>
@@ -166,9 +148,7 @@ const BedTagAdministrationTable: React.FC = () => {
166
148
  {rows.map((row) => (
167
149
  <TableRow key={row.id}>
168
150
  {row.cells.map((cell) => (
169
- <TableCell key={cell.id}>
170
- {cell.value?.content ?? cell.value}
171
- </TableCell>
151
+ <TableCell key={cell.id}>{cell.value?.content ?? cell.value}</TableCell>
172
152
  ))}
173
153
  </TableRow>
174
154
  ))}
@@ -178,21 +158,16 @@ const BedTagAdministrationTable: React.FC = () => {
178
158
  <div className={styles.tileContainer}>
179
159
  <Tile className={styles.tile}>
180
160
  <div className={styles.tileContent}>
181
- <p className={styles.content}>
182
- {t("No data", "No data to display")}
183
- </p>
184
- <p className={styles.helper}>
185
- {t("checkFilters", "Check the filters above")}
186
- </p>
161
+ <p className={styles.content}>{t('No data', 'No data to display')}</p>
162
+ <p className={styles.helper}>{t('checkFilters', 'Check the filters above')}</p>
187
163
  </div>
188
- <p className={styles.separator}>{t("or", "or")}</p>
164
+ <p className={styles.separator}>{t('or', 'or')}</p>
189
165
  <Button
190
166
  kind="ghost"
191
167
  size="sm"
192
168
  renderIcon={(props) => <Add size={16} {...props} />}
193
- onClick={() => setAddBedTagsModal(true)}
194
- >
195
- {t("bedTag", "Add Bed Tag")}
169
+ onClick={() => setAddBedTagsModal(true)}>
170
+ {t('bedTag', 'Add Bed Tag')}
196
171
  </Button>
197
172
  </Tile>
198
173
  </div>
@@ -1,7 +1,7 @@
1
- import React, { useState } from "react";
2
- import { z } from "zod";
3
- import { useForm, Controller } from "react-hook-form";
4
- import { zodResolver } from "@hookform/resolvers/zod";
1
+ import React, { useState } from 'react';
2
+ import { z } from 'zod';
3
+ import { useForm, Controller } from 'react-hook-form';
4
+ import { zodResolver } from '@hookform/resolvers/zod';
5
5
  import {
6
6
  Button,
7
7
  ComposedModal,
@@ -13,10 +13,10 @@ import {
13
13
  Stack,
14
14
  TextInput,
15
15
  InlineNotification,
16
- } from "@carbon/react";
17
- import { useTranslation } from "react-i18next";
18
- import { Location } from "@openmrs/esm-framework";
19
- import type { BedTagData } from "../../types";
16
+ } from '@carbon/react';
17
+ import { useTranslation } from 'react-i18next';
18
+ import { getCoreTranslation, type Location } from '@openmrs/esm-framework';
19
+ import type { BedTagData } from '../types';
20
20
 
21
21
  const BedTagAdministrationSchema = z.object({
22
22
  name: z.string().max(255),
@@ -47,17 +47,17 @@ const BedTagsAdministrationForm: React.FC<BedTagAdministrationFormProps> = ({
47
47
  const { t } = useTranslation();
48
48
 
49
49
  const [showErrorNotification, setShowErrorNotification] = useState(false);
50
- const [formStateError, setFormStateError] = useState("");
50
+ const [formStateError, setFormStateError] = useState('');
51
51
 
52
52
  const {
53
53
  handleSubmit,
54
54
  control,
55
55
  formState: { isDirty },
56
56
  } = useForm<BedTagData>({
57
- mode: "all",
57
+ mode: 'all',
58
58
  resolver: zodResolver(BedTagAdministrationSchema),
59
59
  defaultValues: {
60
- name: initialData.name || "",
60
+ name: initialData.name || '',
61
61
  },
62
62
  });
63
63
 
@@ -75,16 +75,12 @@ const BedTagsAdministrationForm: React.FC<BedTagAdministrationFormProps> = ({
75
75
  };
76
76
 
77
77
  return (
78
- <ComposedModal
79
- open={showModal}
80
- onClose={() => onModalChange(false)}
81
- preventCloseOnClickOutside
82
- >
78
+ <ComposedModal open={showModal} onClose={() => onModalChange(false)} preventCloseOnClickOutside>
83
79
  <ModalHeader title={headerTitle} />
84
- <Form onSubmit={handleSubmit(onSubmit, onError)}>
85
- <ModalBody hasScrollingContent>
80
+ <ModalBody hasScrollingContent>
81
+ <Form>
86
82
  <Stack gap={3}>
87
- <FormGroup legendText={""}>
83
+ <FormGroup legendText={''}>
88
84
  <Controller
89
85
  name="name"
90
86
  control={control}
@@ -92,8 +88,8 @@ const BedTagsAdministrationForm: React.FC<BedTagAdministrationFormProps> = ({
92
88
  <>
93
89
  <TextInput
94
90
  id="bedTag"
95
- labelText={t("bedTag", "Bed Tag Name")}
96
- placeholder={t("bedTagPlaceholder", "")}
91
+ labelText={t('bedTag', 'Bed Tag Name')}
92
+ placeholder={t('bedTagPlaceholder', '')}
97
93
  invalidText={fieldState.error?.message}
98
94
  {...field}
99
95
  />
@@ -105,25 +101,25 @@ const BedTagsAdministrationForm: React.FC<BedTagAdministrationFormProps> = ({
105
101
  {showErrorNotification && (
106
102
  <InlineNotification
107
103
  lowContrast
108
- title={t("error", "Error")}
109
- style={{ minWidth: "100%", margin: "0rem", padding: "0rem" }}
104
+ title={t('error', 'Error')}
105
+ style={{ minWidth: '100%', margin: '0', padding: '0' }}
110
106
  role="alert"
111
107
  kind="error"
112
- subtitle={t("pleaseFillField", formStateError) + "."}
108
+ subtitle={t('pleaseFillField', formStateError) + '.'}
113
109
  onClose={() => setShowErrorNotification(false)}
114
110
  />
115
111
  )}
116
112
  </Stack>
117
- </ModalBody>
118
- <ModalFooter>
119
- <Button onClick={() => onModalChange(false)} kind="secondary">
120
- {t("cancel", "Cancel")}
121
- </Button>
122
- <Button disabled={!isDirty} type="submit">
123
- <span>{t("save", "Save")}</span>
124
- </Button>
125
- </ModalFooter>
126
- </Form>
113
+ </Form>
114
+ </ModalBody>
115
+ <ModalFooter>
116
+ <Button onClick={() => onModalChange(false)} kind="secondary">
117
+ {getCoreTranslation('cancel', 'Cancel')}
118
+ </Button>
119
+ <Button disabled={!isDirty} onClick={handleSubmit(onSubmit, onError)}>
120
+ <span>{t('save', 'Save')}</span>
121
+ </Button>
122
+ </ModalFooter>
127
123
  </ComposedModal>
128
124
  );
129
125
  };
@@ -1,11 +1,11 @@
1
- import React, { useCallback } from "react";
2
- import { useTranslation } from "react-i18next";
3
- import { showToast, showNotification, useConfig } from "@openmrs/esm-framework";
1
+ import React, { useCallback } from 'react';
2
+ import { useTranslation } from 'react-i18next';
3
+ import { showToast, showNotification, useConfig } from '@openmrs/esm-framework';
4
4
 
5
- import { editBedTag, useBedTag } from "../../summary/summary.resource";
6
- import { BedTagDataAdministration } from "../../bed-administration/bed-administration-types";
7
- import BedTagsAdministrationForm from "./bed-tags-admin-form.component";
8
- import { BedTagData, Mutator } from "../../types";
5
+ import { editBedTag, useBedTag } from '../summary/summary.resource';
6
+ import { type BedTagDataAdministration } from '../bed-administration/bed-administration-types';
7
+ import BedTagsAdministrationForm from './bed-tags-admin-form.component';
8
+ import { type BedTagData, type Mutator } from '../types';
9
9
 
10
10
  interface EditBedTagFormProps {
11
11
  showModal: boolean;
@@ -14,15 +14,10 @@ interface EditBedTagFormProps {
14
14
  mutate: Mutator;
15
15
  }
16
16
 
17
- const EditBedTagForm: React.FC<EditBedTagFormProps> = ({
18
- showModal,
19
- onModalChange,
20
- editData,
21
- mutate,
22
- }) => {
17
+ const EditBedTagForm: React.FC<EditBedTagFormProps> = ({ showModal, onModalChange, editData, mutate }) => {
23
18
  const { t } = useTranslation();
24
19
 
25
- const headerTitle = t("editBed", "Edit Tag");
20
+ const headerTitle = t('editBed', 'Edit Tag');
26
21
  const { bedTypeData } = useBedTag();
27
22
  const availableBedTypes = bedTypeData ? bedTypeData : [];
28
23
 
@@ -30,19 +25,16 @@ const EditBedTagForm: React.FC<EditBedTagFormProps> = ({
30
25
  (formData: BedTagDataAdministration) => {
31
26
  const bedUuid = editData.uuid;
32
27
  const { name } = formData;
33
- const bedPayload = {
28
+ const bedTagPayload = {
34
29
  name,
35
30
  };
36
- editBedTag({ bedPayload, bedTagId: bedUuid })
31
+ editBedTag({ bedTagPayload, bedTagId: bedUuid })
37
32
  .then(() => {
38
33
  showToast({
39
- title: t("formSaved", "Bed Tag"),
40
- kind: "success",
34
+ title: t('formSaved', 'Bed Tag'),
35
+ kind: 'success',
41
36
  critical: true,
42
- description:
43
- bedPayload.name +
44
- " " +
45
- t("saveSuccessMessage", "was saved successfully."),
37
+ description: bedTagPayload.name + ' ' + t('saveSuccessMessage', 'was saved successfully.'),
46
38
  });
47
39
 
48
40
  mutate();
@@ -50,8 +42,8 @@ const EditBedTagForm: React.FC<EditBedTagFormProps> = ({
50
42
  })
51
43
  .catch((error) => {
52
44
  showNotification({
53
- title: t("errorCreatingForm", "Error creating bed"),
54
- kind: "error",
45
+ title: t('errorCreatingForm', 'Error creating bed'),
46
+ kind: 'error',
55
47
  critical: true,
56
48
  description: error?.message,
57
49
  });
@@ -59,7 +51,7 @@ const EditBedTagForm: React.FC<EditBedTagFormProps> = ({
59
51
  });
60
52
  onModalChange(false);
61
53
  },
62
- [onModalChange, mutate, editData, t]
54
+ [onModalChange, mutate, editData, t],
63
55
  );
64
56
 
65
57
  return (
@@ -1,49 +1,42 @@
1
- import React, { useCallback } from "react";
2
- import { useTranslation } from "react-i18next";
3
- import { showToast, showNotification, useConfig } from "@openmrs/esm-framework";
4
- import { useBedType } from "../../bed-administration/bed-administration.resource";
5
- import BedTagsAdministrationForm from "./bed-tags-admin-form.component";
6
- import { saveBedTag, useLocationsByTag } from "../../summary/summary.resource";
7
- import { BedTagData, Mutator } from "../../types";
1
+ import React, { useCallback } from 'react';
2
+ import { useTranslation } from 'react-i18next';
3
+ import { showToast, showNotification, useConfig } from '@openmrs/esm-framework';
4
+ import { useBedType } from '../bed-administration/bed-administration.resource';
5
+ import BedTagsAdministrationForm from './bed-tags-admin-form.component';
6
+ import { saveBedTag, useLocationsWithAdmissionTag } from '../summary/summary.resource';
7
+ import { type BedTagData, type Mutator } from '../types';
8
8
 
9
9
  interface BedTagFormProps {
10
10
  showModal: boolean;
11
11
  onModalChange: (showModal: boolean) => void;
12
- mutate: Mutator;
12
+ mutate: () => any;
13
13
  }
14
14
 
15
- const NewTagForm: React.FC<BedTagFormProps> = ({
16
- showModal,
17
- onModalChange,
18
- mutate,
19
- }) => {
15
+ const NewTagForm: React.FC<BedTagFormProps> = ({ showModal, onModalChange, mutate }) => {
20
16
  const { t } = useTranslation();
21
- const { admissionLocationTagUuid } = useConfig();
22
- const { data: admissionLocations } = useLocationsByTag(
23
- admissionLocationTagUuid
24
- );
25
- const headerTitle = t("addBedTag", "Create Bed Tag");
17
+ const { data: admissionLocations } = useLocationsWithAdmissionTag();
18
+ const headerTitle = t('addBedTag', 'Create Bed Tag');
26
19
  const { bedTypes } = useBedType();
27
20
  const availableBedTypes = bedTypes ? bedTypes : [];
28
21
 
29
22
  const initialData: BedTagData = {
30
- uuid: "",
31
- name: "",
23
+ uuid: '',
24
+ name: '',
32
25
  };
33
26
 
34
27
  const handleCreateQuestion = useCallback(
35
28
  (formData: BedTagData) => {
36
29
  const { name } = formData;
37
30
 
38
- const bedObject = {
31
+ const bedTagPayload = {
39
32
  name,
40
33
  };
41
34
 
42
- saveBedTag({ bedPayload: bedObject })
35
+ saveBedTag({ bedTagPayload })
43
36
  .then(() => {
44
37
  showToast({
45
- title: t("formCreated", "Add Bed Tag"),
46
- kind: "success",
38
+ title: t('formCreated', 'Add Bed Tag'),
39
+ kind: 'success',
47
40
  critical: true,
48
41
  description: `Tag ${name} was created successfully.`,
49
42
  });
@@ -53,8 +46,8 @@ const NewTagForm: React.FC<BedTagFormProps> = ({
53
46
  })
54
47
  .catch((error) => {
55
48
  showNotification({
56
- title: t("errorCreatingForm", "Error creating bed"),
57
- kind: "error",
49
+ title: t('errorCreatingForm', 'Error creating bed'),
50
+ kind: 'error',
58
51
  critical: true,
59
52
  description: error?.message,
60
53
  });
@@ -62,7 +55,7 @@ const NewTagForm: React.FC<BedTagFormProps> = ({
62
55
  });
63
56
  onModalChange(false);
64
57
  },
65
- [onModalChange, mutate, t]
58
+ [onModalChange, mutate, t],
66
59
  );
67
60
 
68
61
  return (
@@ -1,7 +1,7 @@
1
- import React, { useState } from "react";
2
- import { z } from "zod";
3
- import { useForm, Controller } from "react-hook-form";
4
- import { zodResolver } from "@hookform/resolvers/zod";
1
+ import React, { useState } from 'react';
2
+ import { z } from 'zod';
3
+ import { useForm, Controller } from 'react-hook-form';
4
+ import { zodResolver } from '@hookform/resolvers/zod';
5
5
  import {
6
6
  Button,
7
7
  ComposedModal,
@@ -14,10 +14,10 @@ import {
14
14
  TextArea,
15
15
  TextInput,
16
16
  InlineNotification,
17
- } from "@carbon/react";
18
- import { useTranslation } from "react-i18next";
19
- import { Location } from "@openmrs/esm-framework";
20
- import type { BedType, BedTypeData } from "../../types";
17
+ } from '@carbon/react';
18
+ import { useTranslation } from 'react-i18next';
19
+ import { getCoreTranslation, type Location } from '@openmrs/esm-framework';
20
+ import type { BedType, BedTypeData } from '../types';
21
21
 
22
22
  const BedTypeAdministrationSchema = z.object({
23
23
  name: z.string().max(255),
@@ -49,19 +49,19 @@ const BedTypeAdministrationForm: React.FC<BedAdministrationFormProps> = ({
49
49
  const { t } = useTranslation();
50
50
 
51
51
  const [showErrorNotification, setShowErrorNotification] = useState(false);
52
- const [formStateError, setFormStateError] = useState("");
52
+ const [formStateError, setFormStateError] = useState('');
53
53
 
54
54
  const {
55
55
  handleSubmit,
56
56
  control,
57
57
  formState: { isDirty },
58
58
  } = useForm<BedTypeData>({
59
- mode: "all",
59
+ mode: 'all',
60
60
  resolver: zodResolver(BedTypeAdministrationSchema),
61
61
  defaultValues: {
62
- name: initialData.name || "",
63
- displayName: initialData.displayName || "",
64
- description: initialData.description || "",
62
+ name: initialData.name || '',
63
+ displayName: initialData.displayName || '',
64
+ description: initialData.description || '',
65
65
  },
66
66
  });
67
67
 
@@ -79,16 +79,12 @@ const BedTypeAdministrationForm: React.FC<BedAdministrationFormProps> = ({
79
79
  };
80
80
 
81
81
  return (
82
- <ComposedModal
83
- open={showModal}
84
- onClose={() => onModalChange(false)}
85
- preventCloseOnClickOutside
86
- >
82
+ <ComposedModal open={showModal} onClose={() => onModalChange(false)} preventCloseOnClickOutside>
87
83
  <ModalHeader title={headerTitle} />
88
- <Form onSubmit={handleSubmit(onSubmit, onError)}>
89
- <ModalBody hasScrollingContent>
84
+ <ModalBody hasScrollingContent>
85
+ <Form>
90
86
  <Stack gap={3}>
91
- <FormGroup legendText={""}>
87
+ <FormGroup legendText={''}>
92
88
  <Controller
93
89
  name="name"
94
90
  control={control}
@@ -96,8 +92,8 @@ const BedTypeAdministrationForm: React.FC<BedAdministrationFormProps> = ({
96
92
  <>
97
93
  <TextInput
98
94
  id="bedName"
99
- labelText={t("bedName", "Bed Name")}
100
- placeholder={t("bedTypePlaceholder", "")}
95
+ labelText={t('bedName', 'Bed Name')}
96
+ placeholder={t('bedTypePlaceholder', '')}
101
97
  invalidText={fieldState.error?.message}
102
98
  {...field}
103
99
  />
@@ -105,7 +101,7 @@ const BedTypeAdministrationForm: React.FC<BedAdministrationFormProps> = ({
105
101
  )}
106
102
  />
107
103
  </FormGroup>
108
- <FormGroup legendText={""}>
104
+ <FormGroup legendText={''}>
109
105
  <Controller
110
106
  name="displayName"
111
107
  control={control}
@@ -113,8 +109,8 @@ const BedTypeAdministrationForm: React.FC<BedAdministrationFormProps> = ({
113
109
  <>
114
110
  <TextInput
115
111
  id="displayName"
116
- labelText={t("displayName", "Display Name")}
117
- placeholder={t("displayNamePlaceholder", "")}
112
+ labelText={t('displayName', 'Display Name')}
113
+ placeholder={t('displayNamePlaceholder', '')}
118
114
  invalidText={fieldState.error?.message}
119
115
  {...field}
120
116
  />
@@ -132,12 +128,9 @@ const BedTypeAdministrationForm: React.FC<BedAdministrationFormProps> = ({
132
128
  rows={2}
133
129
  id="description"
134
130
  invalidText={fieldState?.error?.message}
135
- labelText={t("description", "Description")}
131
+ labelText={t('description', 'Description')}
136
132
  {...field}
137
- placeholder={t(
138
- "description",
139
- "Enter the bed description"
140
- )}
133
+ placeholder={t('description', 'Enter the bed description')}
141
134
  />
142
135
  </>
143
136
  )}
@@ -147,25 +140,25 @@ const BedTypeAdministrationForm: React.FC<BedAdministrationFormProps> = ({
147
140
  {showErrorNotification && (
148
141
  <InlineNotification
149
142
  lowContrast
150
- title={t("error", "Error")}
151
- style={{ minWidth: "100%", margin: "0rem", padding: "0rem" }}
143
+ title={t('error', 'Error')}
144
+ style={{ minWidth: '100%', margin: '0', padding: '0' }}
152
145
  role="alert"
153
146
  kind="error"
154
- subtitle={t("pleaseFillField", formStateError) + "."}
147
+ subtitle={t('pleaseFillField', formStateError) + '.'}
155
148
  onClose={() => setShowErrorNotification(false)}
156
149
  />
157
150
  )}
158
151
  </Stack>
159
- </ModalBody>
160
- <ModalFooter>
161
- <Button onClick={() => onModalChange(false)} kind="secondary">
162
- {t("cancel", "Cancel")}
163
- </Button>
164
- <Button disabled={!isDirty} type="submit">
165
- <span>{t("save", "Save")}</span>
166
- </Button>
167
- </ModalFooter>
168
- </Form>
152
+ </Form>
153
+ </ModalBody>
154
+ <ModalFooter>
155
+ <Button onClick={() => onModalChange(false)} kind="secondary">
156
+ {getCoreTranslation('cancel', 'Cancel')}
157
+ </Button>
158
+ <Button disabled={!isDirty} onClick={handleSubmit(onSubmit, onError)}>
159
+ <span>{t('save', 'Save')}</span>
160
+ </Button>
161
+ </ModalFooter>
169
162
  </ComposedModal>
170
163
  );
171
164
  };