@kenyaemr/esm-bed-management-app 8.1.1-pre.124 → 8.1.2-pre.152

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 (117) hide show
  1. package/.turbo/turbo-build.log +26 -25
  2. package/dist/130.js +1 -1
  3. package/dist/130.js.map +1 -1
  4. package/dist/148.js +1 -1
  5. package/dist/148.js.map +1 -1
  6. package/dist/236.js +1 -0
  7. package/dist/240.js +1 -0
  8. package/dist/261.js +1 -0
  9. package/dist/271.js +1 -1
  10. package/dist/272.js +1 -0
  11. package/dist/288.js +1 -0
  12. package/dist/288.js.map +1 -0
  13. package/dist/319.js +1 -1
  14. package/dist/336.js +1 -0
  15. package/dist/378.js +1 -0
  16. package/dist/443.js +1 -0
  17. package/dist/443.js.map +1 -0
  18. package/dist/460.js +1 -1
  19. package/dist/539.js +1 -0
  20. package/dist/542.js +1 -1
  21. package/dist/542.js.map +1 -1
  22. package/dist/566.js +1 -0
  23. package/dist/574.js +1 -1
  24. package/dist/644.js +1 -1
  25. package/dist/652.js +1 -0
  26. package/dist/673.js +1 -0
  27. package/dist/705.js +1 -0
  28. package/dist/711.js +1 -0
  29. package/dist/727.js +1 -0
  30. package/dist/737.js +1 -0
  31. package/dist/744.js +1 -0
  32. package/dist/746.js +2 -0
  33. package/dist/746.js.map +1 -0
  34. package/dist/757.js +1 -1
  35. package/dist/768.js +2 -0
  36. package/dist/{455.js.LICENSE.txt → 768.js.LICENSE.txt} +0 -6
  37. package/dist/768.js.map +1 -0
  38. package/dist/788.js +1 -1
  39. package/dist/807.js +1 -1
  40. package/dist/833.js +1 -1
  41. package/dist/899.js +1 -0
  42. package/dist/main.js +1 -1
  43. package/dist/main.js.map +1 -1
  44. package/dist/openmrs-esm-bed-management-app.js +1 -1
  45. package/dist/openmrs-esm-bed-management-app.js.buildmanifest.json +414 -83
  46. package/dist/openmrs-esm-bed-management-app.js.map +1 -1
  47. package/dist/routes.json +1 -1
  48. package/package-lock.json +5893 -0
  49. package/package.json +4 -4
  50. package/src/admin-card-link.component.tsx +3 -2
  51. package/src/bed-administration/bed-administration-form.component.tsx +53 -54
  52. package/src/bed-administration/bed-administration-table.component.tsx +27 -23
  53. package/src/bed-administration/bed-administration-table.scss +1 -1
  54. package/src/bed-administration/bed-administration-types.ts +7 -5
  55. package/src/bed-administration/bed-administration.resource.ts +5 -7
  56. package/src/bed-administration/edit-bed-form.component.tsx +43 -43
  57. package/src/bed-administration/new-bed-form.component.tsx +34 -38
  58. package/src/bed-tag/bed-tag-administration-table.component.tsx +23 -23
  59. package/src/bed-tag/bed-tags-admin-form.component.tsx +12 -11
  60. package/src/bed-tag/edit-tag-form.component.tsx +27 -29
  61. package/src/bed-tag/new-tag-form.component.tsx +29 -34
  62. package/src/bed-type/bed-type-admin-form.component.tsx +32 -35
  63. package/src/bed-type/bed-type-administration-table.component.tsx +49 -49
  64. package/src/bed-type/edit-bed-type.component.tsx +24 -23
  65. package/src/bed-type/new-bed-type-form.component.tsx +32 -37
  66. package/src/card-header/card-header.component.tsx +3 -1
  67. package/src/header/header.component.tsx +23 -18
  68. package/src/header/header.scss +18 -32
  69. package/src/home.component.tsx +4 -1
  70. package/src/index.ts +12 -7
  71. package/src/left-panel/left-panel.component.tsx +10 -8
  72. package/src/modals.scss +29 -0
  73. package/src/root.component.tsx +8 -7
  74. package/src/routes.json +0 -15
  75. package/src/summary/summary.resource.ts +154 -100
  76. package/src/types.ts +2 -2
  77. package/src/ward-with-beds/ward-with-beds.component.tsx +7 -8
  78. package/translations/am.json +34 -18
  79. package/translations/ar.json +35 -19
  80. package/translations/de.json +67 -0
  81. package/translations/en.json +34 -18
  82. package/translations/es.json +38 -22
  83. package/translations/fr.json +34 -18
  84. package/translations/he.json +34 -18
  85. package/translations/hi.json +67 -0
  86. package/translations/hi_IN.json +67 -0
  87. package/translations/id.json +67 -0
  88. package/translations/it.json +67 -0
  89. package/translations/km.json +34 -18
  90. package/translations/ne.json +67 -0
  91. package/translations/pt.json +67 -0
  92. package/translations/pt_BR.json +67 -0
  93. package/translations/qu.json +67 -0
  94. package/translations/si.json +67 -0
  95. package/translations/sw.json +67 -0
  96. package/translations/sw_KE.json +67 -0
  97. package/translations/tr.json +67 -0
  98. package/translations/tr_TR.json +67 -0
  99. package/translations/uk.json +67 -0
  100. package/translations/vi.json +67 -0
  101. package/translations/zh.json +34 -18
  102. package/translations/zh_CN.json +34 -18
  103. package/tsconfig.json +0 -1
  104. package/dist/169.js +0 -1
  105. package/dist/169.js.map +0 -1
  106. package/dist/339.js +0 -1
  107. package/dist/339.js.map +0 -1
  108. package/dist/455.js +0 -2
  109. package/dist/455.js.map +0 -1
  110. package/dist/501.js +0 -1
  111. package/dist/501.js.map +0 -1
  112. package/dist/766.js +0 -2
  113. package/dist/766.js.map +0 -1
  114. package/src/bed-administration/bed-administration-form.scss +0 -0
  115. package/src/header/illustration.component.tsx +0 -13
  116. package/src/setup-tests.ts +0 -1
  117. /package/dist/{766.js.LICENSE.txt → 746.js.LICENSE.txt} +0 -0
@@ -7,17 +7,18 @@ import {
7
7
  ComposedModal,
8
8
  Form,
9
9
  FormGroup,
10
+ InlineNotification,
10
11
  ModalBody,
11
12
  ModalFooter,
12
13
  ModalHeader,
13
14
  Stack,
14
15
  TextArea,
15
16
  TextInput,
16
- InlineNotification,
17
17
  } from '@carbon/react';
18
18
  import { useTranslation } from 'react-i18next';
19
19
  import { getCoreTranslation, type Location } from '@openmrs/esm-framework';
20
20
  import type { BedType, BedTypeData } from '../types';
21
+ import styles from '../modals.scss';
21
22
 
22
23
  const BedTypeAdministrationSchema = z.object({
23
24
  name: z.string().max(255),
@@ -26,13 +27,13 @@ const BedTypeAdministrationSchema = z.object({
26
27
  });
27
28
 
28
29
  interface BedAdministrationFormProps {
29
- showModal: boolean;
30
- onModalChange: (showModal: boolean) => void;
31
- availableBedTypes: Array<BedType>;
32
30
  allLocations: Location[];
33
- handleCreateQuestion?: (formData: BedTypeData) => void;
31
+ availableBedTypes: Array<BedType>;
32
+ handleSubmission?: (formData: BedTypeData) => void;
34
33
  headerTitle: string;
35
34
  initialData: BedTypeData;
35
+ onModalChange: (showModal: boolean) => void;
36
+ showModal: boolean;
36
37
  }
37
38
 
38
39
  interface ErrorType {
@@ -40,11 +41,11 @@ interface ErrorType {
40
41
  }
41
42
 
42
43
  const BedTypeAdministrationForm: React.FC<BedAdministrationFormProps> = ({
43
- showModal,
44
- onModalChange,
45
- handleCreateQuestion,
44
+ handleSubmission,
46
45
  headerTitle,
47
46
  initialData,
47
+ onModalChange,
48
+ showModal,
48
49
  }) => {
49
50
  const { t } = useTranslation();
50
51
 
@@ -69,7 +70,7 @@ const BedTypeAdministrationForm: React.FC<BedAdministrationFormProps> = ({
69
70
  const result = BedTypeAdministrationSchema.safeParse(formData);
70
71
  if (result.success) {
71
72
  setShowErrorNotification(false);
72
- handleCreateQuestion(formData);
73
+ handleSubmission?.(formData);
73
74
  }
74
75
  };
75
76
 
@@ -80,7 +81,7 @@ const BedTypeAdministrationForm: React.FC<BedAdministrationFormProps> = ({
80
81
 
81
82
  return (
82
83
  <ComposedModal open={showModal} onClose={() => onModalChange(false)} preventCloseOnClickOutside>
83
- <ModalHeader title={headerTitle} />
84
+ <ModalHeader className={styles.modalHeader} title={headerTitle} />
84
85
  <ModalBody hasScrollingContent>
85
86
  <Form>
86
87
  <Stack gap={3}>
@@ -92,9 +93,9 @@ const BedTypeAdministrationForm: React.FC<BedAdministrationFormProps> = ({
92
93
  <>
93
94
  <TextInput
94
95
  id="bedName"
95
- labelText={t('bedName', 'Bed Name')}
96
- placeholder={t('bedTypePlaceholder', '')}
97
96
  invalidText={fieldState.error?.message}
97
+ labelText={t('bedName', 'Bed name')}
98
+ placeholder={t('bedTypePlaceholder', '')}
98
99
  {...field}
99
100
  />
100
101
  </>
@@ -106,15 +107,13 @@ const BedTypeAdministrationForm: React.FC<BedAdministrationFormProps> = ({
106
107
  name="displayName"
107
108
  control={control}
108
109
  render={({ field, fieldState }) => (
109
- <>
110
- <TextInput
111
- id="displayName"
112
- labelText={t('displayName', 'Display Name')}
113
- placeholder={t('displayNamePlaceholder', '')}
114
- invalidText={fieldState.error?.message}
115
- {...field}
116
- />
117
- </>
110
+ <TextInput
111
+ id="displayName"
112
+ invalidText={fieldState.error?.message}
113
+ labelText={t('displayName', 'Display name')}
114
+ placeholder={t('displayNamePlaceholder', '')}
115
+ {...field}
116
+ />
118
117
  )}
119
118
  />
120
119
  </FormGroup>
@@ -123,29 +122,27 @@ const BedTypeAdministrationForm: React.FC<BedAdministrationFormProps> = ({
123
122
  name="description"
124
123
  control={control}
125
124
  render={({ field, fieldState }) => (
126
- <>
127
- <TextArea
128
- rows={2}
129
- id="description"
130
- invalidText={fieldState?.error?.message}
131
- labelText={t('description', 'Description')}
132
- {...field}
133
- placeholder={t('description', 'Enter the bed description')}
134
- />
135
- </>
125
+ <TextArea
126
+ rows={2}
127
+ id="description"
128
+ invalidText={fieldState?.error?.message}
129
+ labelText={t('description', 'Description')}
130
+ {...field}
131
+ placeholder={t('enterBedDescription', 'Enter the bed description')}
132
+ />
136
133
  )}
137
134
  />
138
135
  </FormGroup>
139
136
 
140
137
  {showErrorNotification && (
141
138
  <InlineNotification
139
+ kind="error"
142
140
  lowContrast
143
- title={t('error', 'Error')}
144
- style={{ minWidth: '100%', margin: '0', padding: '0' }}
141
+ onClose={() => setShowErrorNotification(false)}
145
142
  role="alert"
146
- kind="error"
143
+ style={{ minWidth: '100%', margin: '0', padding: '0' }}
147
144
  subtitle={t('pleaseFillField', formStateError) + '.'}
148
- onClose={() => setShowErrorNotification(false)}
145
+ title={t('error', 'Error')}
149
146
  />
150
147
  )}
151
148
  </Stack>
@@ -1,9 +1,10 @@
1
- import React, { useEffect, useMemo, useState } from 'react';
1
+ import React, { useMemo, useState } from 'react';
2
2
  import { useTranslation } from 'react-i18next';
3
3
  import {
4
4
  Button,
5
5
  DataTable,
6
6
  DataTableSkeleton,
7
+ IconButton,
7
8
  InlineLoading,
8
9
  Pagination,
9
10
  Table,
@@ -18,36 +19,36 @@ import {
18
19
  import { Add, Edit } from '@carbon/react/icons';
19
20
  import { ErrorState, isDesktop as desktopLayout, useLayoutType } from '@openmrs/esm-framework';
20
21
  import type { BedTypeData } from '../types';
21
- import { useBedType } from '../summary/summary.resource';
22
- import Header from '../header/header.component';
22
+ import { useBedTypes } from '../summary/summary.resource';
23
+ import CardHeader from '../card-header/card-header.component';
23
24
  import BedTypeForm from './new-bed-type-form.component';
24
- import styles from '../bed-administration/bed-administration-table.scss';
25
- import { CardHeader } from '../card-header/card-header.component';
26
25
  import EditBedTypeForm from './edit-bed-type.component';
26
+ import Header from '../header/header.component';
27
+ import styles from '../bed-administration/bed-administration-table.scss';
27
28
 
28
29
  const BedTypeAdministrationTable: React.FC = () => {
29
30
  const { t } = useTranslation();
30
- const headerTitle = t('bedType', 'Bed Type');
31
+ const headerTitle = t('bedTypes', 'Bed types');
31
32
  const layout = useLayoutType();
32
33
  const isTablet = layout === 'tablet';
33
34
  const responsiveSize = isTablet ? 'lg' : 'sm';
34
35
  const isDesktop = desktopLayout(layout);
35
- const [showEditBedModal, setShowEditBedModal] = useState(false);
36
- const [isBedDataLoading, setIsBedDataLoading] = useState(false);
37
- const [showBedTypeModal, setAddBedTypeModal] = useState(false);
36
+ const { bedTypes, errorLoadingBedTypes, isLoadingBedTypes, isValidatingBedTypes, mutateBedTypes } = useBedTypes();
37
+
38
38
  const [currentPage, setCurrentPage] = useState(1);
39
+ const [currentPageSize, setPageSize] = useState(10);
39
40
  const [editData, setEditData] = useState<BedTypeData>();
40
41
  const [pageSize] = useState(10);
41
- const { bedTypeData, isError, loading, validate, mutate } = useBedType();
42
- const [currentPageSize, setPageSize] = useState(10);
43
- const pageSizes = [10, 20, 30, 40, 50];
42
+ const [showBedTypeModal, setAddBedTypeModal] = useState(false);
43
+ const [showEditBedModal, setShowEditBedModal] = useState(false);
44
+
44
45
  const tableHeaders = [
45
46
  {
46
47
  header: t('name', 'Name'),
47
48
  key: 'name',
48
49
  },
49
50
  {
50
- header: t('displayName', 'Display Name'),
51
+ header: t('displayName', 'Display name'),
51
52
  key: 'displayName',
52
53
  },
53
54
  {
@@ -60,38 +61,37 @@ const BedTypeAdministrationTable: React.FC = () => {
60
61
  },
61
62
  ];
62
63
 
63
- const tableRows = useMemo(() => {
64
- return bedTypeData?.map((entry) => ({
65
- id: entry.uuid,
66
- name: entry?.name,
67
- displayName: entry?.displayName,
68
- description: entry?.description,
69
- actions: (
70
- <>
71
- <Button
64
+ const tableRows = useMemo(
65
+ () =>
66
+ bedTypes?.map((entry) => ({
67
+ id: entry.uuid,
68
+ name: entry?.name,
69
+ displayName: entry?.displayName,
70
+ description: entry?.description,
71
+ actions: (
72
+ <IconButton
73
+ align="top-start"
72
74
  enterDelayMs={300}
73
- renderIcon={Edit}
75
+ kind="ghost"
76
+ label={t('editBedType', 'Edit bed type')}
74
77
  onClick={(e) => {
75
78
  e.preventDefault();
76
79
  setEditData(entry);
77
80
  setShowEditBedModal(true);
78
81
  setAddBedTypeModal(false);
79
82
  }}
80
- kind={'ghost'}
81
- iconDescription={t('editBedType', 'Edit Bed Type')}
82
- hasIconOnly
83
- size={responsiveSize}
84
- tooltipAlignment="start"
85
- />
86
- </>
87
- ),
88
- }));
89
- }, [responsiveSize, bedTypeData, t]);
83
+ size={responsiveSize}>
84
+ <Edit />
85
+ </IconButton>
86
+ ),
87
+ })),
88
+ [responsiveSize, bedTypes, t],
89
+ );
90
90
 
91
- if (isBedDataLoading || loading) {
91
+ if (isLoadingBedTypes) {
92
92
  return (
93
93
  <>
94
- <Header route="Bed Type" />
94
+ <Header title={t('bedTypes', 'Bed types')} />
95
95
  <div className={styles.widgetCard}>
96
96
  <DataTableSkeleton role="progressbar" compact={isDesktop} zebra />
97
97
  </div>
@@ -99,12 +99,12 @@ const BedTypeAdministrationTable: React.FC = () => {
99
99
  );
100
100
  }
101
101
 
102
- if (isError) {
102
+ if (errorLoadingBedTypes) {
103
103
  return (
104
104
  <>
105
- <Header route="Bed Type" />
105
+ <Header title={t('bedTypes', 'Bed types')} />
106
106
  <div className={styles.widgetCard}>
107
- <ErrorState error={isError} headerTitle={headerTitle} />
107
+ <ErrorState error={errorLoadingBedTypes} headerTitle={headerTitle} />
108
108
  </div>
109
109
  </>
110
110
  );
@@ -112,30 +112,30 @@ const BedTypeAdministrationTable: React.FC = () => {
112
112
 
113
113
  return (
114
114
  <>
115
- <Header route="Bed Type" />
115
+ <Header title={t('bedTypes', 'Bed types')} />
116
116
 
117
117
  <div className={styles.widgetCard}>
118
118
  {showBedTypeModal ? (
119
- <BedTypeForm onModalChange={setAddBedTypeModal} showModal={showBedTypeModal} mutate={mutate} />
119
+ <BedTypeForm onModalChange={setAddBedTypeModal} showModal={showBedTypeModal} mutate={mutateBedTypes} />
120
120
  ) : null}
121
121
  {showEditBedModal ? (
122
122
  <EditBedTypeForm
123
+ editData={editData}
124
+ mutate={mutateBedTypes}
123
125
  onModalChange={setShowEditBedModal}
124
126
  showModal={showEditBedModal}
125
- editData={editData}
126
- mutate={mutate}
127
127
  />
128
128
  ) : null}
129
129
  <CardHeader title={headerTitle}>
130
130
  <span className={styles.backgroundDataFetchingIndicator}>
131
- <span>{validate ? <InlineLoading /> : null}</span>
131
+ <span>{isValidatingBedTypes ? <InlineLoading /> : null}</span>
132
132
  </span>
133
- {bedTypeData?.length ? (
133
+ {bedTypes?.length ? (
134
134
  <Button
135
135
  kind="ghost"
136
136
  renderIcon={(props) => <Add size={16} {...props} />}
137
137
  onClick={() => setAddBedTypeModal(true)}>
138
- {t('addBedtype', 'Add Bed Type')}
138
+ {t('addBedType', 'Add bed type')}
139
139
  </Button>
140
140
  ) : null}
141
141
  </CardHeader>
@@ -146,7 +146,7 @@ const BedTypeAdministrationTable: React.FC = () => {
146
146
  <TableHead>
147
147
  <TableRow>
148
148
  {headers.map((header) => (
149
- <TableHeader>{header.header?.content ?? header.header}</TableHeader>
149
+ <TableHeader key={header.key}>{header.header?.content ?? header.header}</TableHeader>
150
150
  ))}
151
151
  </TableRow>
152
152
  </TableHead>
@@ -164,7 +164,7 @@ const BedTypeAdministrationTable: React.FC = () => {
164
164
  <div className={styles.tileContainer}>
165
165
  <Tile className={styles.tile}>
166
166
  <div className={styles.tileContent}>
167
- <p className={styles.content}>{t('No data', 'No data to display')}</p>
167
+ <p className={styles.content}>{t('noDataToDisplay', 'No data to display')}</p>
168
168
  <p className={styles.helper}>{t('checkFilters', 'Check the filters above')}</p>
169
169
  </div>
170
170
  <p className={styles.separator}>{t('or', 'or')}</p>
@@ -173,7 +173,7 @@ const BedTypeAdministrationTable: React.FC = () => {
173
173
  size="sm"
174
174
  renderIcon={(props) => <Add size={16} {...props} />}
175
175
  onClick={() => setAddBedTypeModal(true)}>
176
- {t('bedType', 'Add Bed Type')}
176
+ {t('addBedType', 'Add bed type')}
177
177
  </Button>
178
178
  </Tile>
179
179
  </div>
@@ -182,7 +182,7 @@ const BedTypeAdministrationTable: React.FC = () => {
182
182
  page={currentPage}
183
183
  pageSize={pageSize}
184
184
  pageSizes={[10, 20, 30, 40, 50]}
185
- totalItems={bedTypeData.length}
185
+ totalItems={bedTypes.length}
186
186
  onChange={({ page, pageSize }) => {
187
187
  setCurrentPage(page);
188
188
  setPageSize(pageSize);
@@ -1,55 +1,56 @@
1
1
  import React, { useCallback } from 'react';
2
2
  import { useTranslation } from 'react-i18next';
3
- import { showToast, showNotification, useConfig } from '@openmrs/esm-framework';
4
-
5
- import { editBedType, useBedType } from '../summary/summary.resource';
3
+ import { showSnackbar } from '@openmrs/esm-framework';
4
+ import { editBedType, useBedTypes } from '../summary/summary.resource';
6
5
  import { type BedTypeDataAdministration } from '../bed-administration/bed-administration-types';
7
- import { type BedTypeData, type Mutator } from '../types';
6
+ import { type BedType, type BedTypeData, type Mutator } from '../types';
8
7
  import BedTypeAdministrationForm from './bed-type-admin-form.component';
9
8
 
10
9
  interface EditBedTypeFormProps {
11
- showModal: boolean;
12
- onModalChange: (showModal: boolean) => void;
13
10
  editData: BedTypeData;
14
- mutate: Mutator;
11
+ mutate: Mutator<BedType>;
12
+ onModalChange: (showModal: boolean) => void;
13
+ showModal: boolean;
15
14
  }
16
15
 
17
- const EditBedTypeForm: React.FC<EditBedTypeFormProps> = ({ showModal, onModalChange, editData, mutate }) => {
16
+ const EditBedTypeForm: React.FC<EditBedTypeFormProps> = ({ editData, mutate, onModalChange, showModal }) => {
18
17
  const { t } = useTranslation();
19
- const headerTitle = t('editBedType', 'Edit Bed Type');
20
- const { bedTypeData } = useBedType();
21
- const availableBedTypes = bedTypeData ? bedTypeData : [];
22
- const handleCreateQuestion = useCallback(
18
+ const { bedTypes } = useBedTypes();
19
+ const headerTitle = t('editBedType', 'Edit bed type');
20
+
21
+ const handleUpdateBedType = useCallback(
23
22
  (formData: BedTypeDataAdministration) => {
24
23
  const bedUuid = editData.uuid;
25
24
  const { name, displayName, description } = formData;
25
+
26
26
  const bedTypePayload = {
27
27
  name,
28
28
  displayName,
29
29
  description,
30
30
  };
31
+
31
32
  editBedType({ bedTypePayload, bedTypeId: bedUuid })
32
33
  .then(() => {
33
- showToast({
34
- title: t('formSaved', 'Bed Type'),
34
+ showSnackbar({
35
+ title: t('bedTypeUpdated', 'Bed type updated'),
36
+ subtitle: t('bedTypeUpdatedSuccessfully', `${bedTypePayload.name} updated successfully`, {
37
+ bedType: bedTypePayload.name,
38
+ }),
35
39
  kind: 'success',
36
- critical: true,
37
- description: bedTypePayload.name + ' ' + t('saveSuccessMessage', 'was saved successfully.'),
38
40
  });
39
41
 
40
42
  mutate();
41
- onModalChange(false);
42
43
  })
43
44
  .catch((error) => {
44
- showNotification({
45
+ showSnackbar({
45
46
  title: t('errorCreatingForm', 'Error creating bed'),
47
+ subtitle: error?.message,
46
48
  kind: 'error',
47
- critical: true,
48
- description: error?.message,
49
49
  });
50
+ })
51
+ .finally(() => {
50
52
  onModalChange(false);
51
53
  });
52
- onModalChange(false);
53
54
  },
54
55
  [onModalChange, mutate, editData, t],
55
56
  );
@@ -58,9 +59,9 @@ const EditBedTypeForm: React.FC<EditBedTypeFormProps> = ({ showModal, onModalCha
58
59
  <>
59
60
  <BedTypeAdministrationForm
60
61
  onModalChange={onModalChange}
61
- availableBedTypes={availableBedTypes}
62
+ availableBedTypes={bedTypes}
62
63
  showModal={showModal}
63
- handleCreateQuestion={handleCreateQuestion}
64
+ handleSubmission={handleUpdateBedType}
64
65
  headerTitle={headerTitle}
65
66
  initialData={editData}
66
67
  allLocations={[]}
@@ -1,32 +1,30 @@
1
1
  import React, { useCallback } from 'react';
2
2
  import { useTranslation } from 'react-i18next';
3
- import { showToast, showNotification, useConfig } from '@openmrs/esm-framework';
4
- import type { BedTypeData, Mutator } from '../types';
5
- import { useBedType } from '../bed-administration/bed-administration.resource';
6
- import { saveBedType, useLocationsWithAdmissionTag } from '../summary/summary.resource';
3
+ import { showSnackbar } from '@openmrs/esm-framework';
4
+ import type { BedType, BedTypeData, Mutator } from '../types';
5
+ import { saveBedType, useBedTypes, useLocationsWithAdmissionTag } from '../summary/summary.resource';
7
6
  import BedTypeAdministrationForm from './bed-type-admin-form.component';
8
7
 
9
8
  interface BedTypeFormProps {
10
- showModal: boolean;
9
+ mutate: Mutator<BedType>;
11
10
  onModalChange: (showModal: boolean) => void;
12
- mutate: Mutator;
11
+ showModal: boolean;
13
12
  }
14
13
 
15
- const NewBedTypeForm: React.FC<BedTypeFormProps> = ({ showModal, onModalChange, mutate }) => {
14
+ const NewBedTypeForm: React.FC<BedTypeFormProps> = ({ mutate, onModalChange, showModal }) => {
16
15
  const { t } = useTranslation();
17
- const { data: admissionLocations } = useLocationsWithAdmissionTag();
18
- const headerTitle = t('addBedType', 'Create Bed type');
19
- const { bedTypes } = useBedType();
20
- const availableBedTypes = bedTypes ? bedTypes : [];
16
+ const { admissionLocations } = useLocationsWithAdmissionTag();
17
+ const headerTitle = t('createBedType', 'Create bed type');
18
+ const { bedTypes } = useBedTypes();
21
19
 
22
20
  const initialData: BedTypeData = {
23
- uuid: '',
24
- name: '',
25
- displayName: '',
26
21
  description: '',
22
+ displayName: '',
23
+ name: '',
24
+ uuid: '',
27
25
  };
28
26
 
29
- const handleCreateQuestion = useCallback(
27
+ const handleCreateBedType = useCallback(
30
28
  (formData: BedTypeData) => {
31
29
  const { name, displayName, description } = formData;
32
30
 
@@ -38,42 +36,39 @@ const NewBedTypeForm: React.FC<BedTypeFormProps> = ({ showModal, onModalChange,
38
36
 
39
37
  saveBedType({ bedTypePayload })
40
38
  .then(() => {
41
- showToast({
42
- title: t('formCreated', 'Add bed Type'),
39
+ showSnackbar({
43
40
  kind: 'success',
44
- critical: true,
45
- description: `Bed ${name} was created successfully.`,
41
+ title: t('bedTypeCreated', 'Bed type created'),
42
+ subtitle: t('bedTypeCreatedSuccessfully', `${name} created successfully`, {
43
+ bedType: name,
44
+ }),
46
45
  });
47
-
48
46
  mutate();
49
- onModalChange(false);
50
47
  })
51
48
  .catch((error) => {
52
- showNotification({
53
- title: t('errorCreatingForm', 'Error creating bed'),
49
+ showSnackbar({
54
50
  kind: 'error',
55
- critical: true,
56
- description: error?.message,
51
+ title: t('errorCreatingForm', 'Error creating bed'),
52
+ subtitle: error?.message,
57
53
  });
54
+ })
55
+ .finally(() => {
58
56
  onModalChange(false);
59
57
  });
60
- onModalChange(false);
61
58
  },
62
59
  [onModalChange, mutate, t],
63
60
  );
64
61
 
65
62
  return (
66
- <>
67
- <BedTypeAdministrationForm
68
- onModalChange={onModalChange}
69
- allLocations={admissionLocations}
70
- availableBedTypes={availableBedTypes}
71
- showModal={showModal}
72
- handleCreateQuestion={handleCreateQuestion}
73
- headerTitle={headerTitle}
74
- initialData={initialData}
75
- />
76
- </>
63
+ <BedTypeAdministrationForm
64
+ allLocations={admissionLocations}
65
+ availableBedTypes={bedTypes}
66
+ handleSubmission={handleCreateBedType}
67
+ headerTitle={headerTitle}
68
+ initialData={initialData}
69
+ onModalChange={onModalChange}
70
+ showModal={showModal}
71
+ />
77
72
  );
78
73
  };
79
74
 
@@ -8,7 +8,7 @@ interface CardHeaderProps {
8
8
  children: React.ReactNode;
9
9
  }
10
10
 
11
- export function CardHeader({ title, children }: CardHeaderProps) {
11
+ function CardHeader({ title, children }: CardHeaderProps) {
12
12
  const isTablet = useLayoutType() === 'tablet';
13
13
 
14
14
  return (
@@ -18,3 +18,5 @@ export function CardHeader({ title, children }: CardHeaderProps) {
18
18
  </div>
19
19
  );
20
20
  }
21
+
22
+ export default CardHeader;
@@ -1,33 +1,38 @@
1
1
  import React from 'react';
2
- import { ConfigurableLink, formatDate, useSession } from '@openmrs/esm-framework';
3
2
  import { useTranslation } from 'react-i18next';
4
3
  import { Calendar, Location } from '@carbon/react/icons';
5
- import Illustration from './illustration.component';
4
+ import {
5
+ ConfigurableLink,
6
+ formatDate,
7
+ InPatientPictogram,
8
+ PageHeader,
9
+ PageHeaderContent,
10
+ useSession,
11
+ } from '@openmrs/esm-framework';
6
12
  import styles from './header.scss';
7
13
 
8
14
  type HeaderProps = {
9
- route: string;
10
- headerTitle?: string;
15
+ title: string;
11
16
  };
12
17
 
13
- const Header: React.FC<HeaderProps> = ({ route, headerTitle = 'Bed Management' }) => {
18
+ const Header: React.FC<HeaderProps> = ({ title }) => {
14
19
  const { t } = useTranslation();
15
20
  const userSession = useSession();
16
21
  const userLocation = userSession?.sessionLocation?.display;
17
22
 
18
23
  return (
19
- <div className={styles.header}>
20
- <div className={styles['left-justified-items']}>
21
- <ConfigurableLink to={`${window.getOpenmrsSpaBase()}bed-management`}>
22
- <Illustration />
23
- </ConfigurableLink>
24
- <div className={styles['page-labels']}>
25
- <p>{t('headerTitle', headerTitle)}</p>
26
- <p className={styles['page-name']}>{route}</p>
27
- </div>
28
- </div>
29
- <div className={styles['right-justified-items']}>
30
- <div className={styles['date-and-location']}>
24
+ <PageHeader className={styles.header}>
25
+ <PageHeaderContent
26
+ illustration={
27
+ <ConfigurableLink to={`${window.getOpenmrsSpaBase()}bed-management`}>
28
+ <InPatientPictogram className={styles.inPatientPictogram} />
29
+ </ConfigurableLink>
30
+ }
31
+ title={title}
32
+ className={styles.leftJustifiedItems}
33
+ />
34
+ <div className={styles.rightJustifiedItems}>
35
+ <div className={styles.dateAndLocation}>
31
36
  <Location size={16} />
32
37
  <span className={styles.value}>{userLocation}</span>
33
38
  <span className={styles.middot}>&middot;</span>
@@ -35,7 +40,7 @@ const Header: React.FC<HeaderProps> = ({ route, headerTitle = 'Bed Management' }
35
40
  <span className={styles.value}>{formatDate(new Date(), { mode: 'standard' })}</span>
36
41
  </div>
37
42
  </div>
38
- </div>
43
+ </PageHeader>
39
44
  );
40
45
  };
41
46