@kenyaemr/esm-bed-management-app 8.1.1-pre.129 → 8.1.2-pre.154
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/.turbo/turbo-build.log +26 -25
- package/dist/130.js +1 -1
- package/dist/130.js.map +1 -1
- package/dist/148.js +1 -1
- package/dist/148.js.map +1 -1
- package/dist/236.js +1 -0
- package/dist/240.js +1 -0
- package/dist/261.js +1 -0
- package/dist/271.js +1 -1
- package/dist/272.js +1 -0
- package/dist/288.js +1 -0
- package/dist/288.js.map +1 -0
- package/dist/319.js +1 -1
- package/dist/336.js +1 -0
- package/dist/378.js +1 -0
- package/dist/443.js +1 -0
- package/dist/443.js.map +1 -0
- package/dist/460.js +1 -1
- package/dist/539.js +1 -0
- package/dist/542.js +1 -1
- package/dist/542.js.map +1 -1
- package/dist/566.js +1 -0
- package/dist/574.js +1 -1
- package/dist/644.js +1 -1
- package/dist/652.js +1 -0
- package/dist/673.js +1 -0
- package/dist/705.js +1 -0
- package/dist/711.js +1 -0
- package/dist/727.js +1 -0
- package/dist/737.js +1 -0
- package/dist/744.js +1 -0
- package/dist/746.js +2 -0
- package/dist/746.js.map +1 -0
- package/dist/757.js +1 -1
- package/dist/768.js +2 -0
- package/dist/{455.js.LICENSE.txt → 768.js.LICENSE.txt} +0 -6
- package/dist/768.js.map +1 -0
- package/dist/788.js +1 -1
- package/dist/807.js +1 -1
- package/dist/833.js +1 -1
- package/dist/899.js +1 -0
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/openmrs-esm-bed-management-app.js +1 -1
- package/dist/openmrs-esm-bed-management-app.js.buildmanifest.json +414 -83
- package/dist/openmrs-esm-bed-management-app.js.map +1 -1
- package/dist/routes.json +1 -1
- package/package-lock.json +2 -2
- package/package.json +4 -4
- package/src/admin-card-link.component.tsx +3 -2
- package/src/bed-administration/bed-administration-form.component.tsx +53 -54
- package/src/bed-administration/bed-administration-table.component.tsx +27 -23
- package/src/bed-administration/bed-administration-table.scss +1 -1
- package/src/bed-administration/bed-administration-types.ts +7 -5
- package/src/bed-administration/bed-administration.resource.ts +5 -7
- package/src/bed-administration/edit-bed-form.component.tsx +43 -43
- package/src/bed-administration/new-bed-form.component.tsx +34 -38
- package/src/bed-tag/bed-tag-administration-table.component.tsx +23 -23
- package/src/bed-tag/bed-tags-admin-form.component.tsx +12 -11
- package/src/bed-tag/edit-tag-form.component.tsx +27 -29
- package/src/bed-tag/new-tag-form.component.tsx +29 -34
- package/src/bed-type/bed-type-admin-form.component.tsx +32 -35
- package/src/bed-type/bed-type-administration-table.component.tsx +49 -49
- package/src/bed-type/edit-bed-type.component.tsx +24 -23
- package/src/bed-type/new-bed-type-form.component.tsx +32 -37
- package/src/card-header/card-header.component.tsx +3 -1
- package/src/header/header.component.tsx +23 -18
- package/src/header/header.scss +18 -32
- package/src/home.component.tsx +4 -1
- package/src/index.ts +12 -7
- package/src/left-panel/left-panel.component.tsx +10 -8
- package/src/modals.scss +29 -0
- package/src/root.component.tsx +8 -7
- package/src/routes.json +0 -15
- package/src/summary/summary.resource.ts +154 -100
- package/src/types.ts +2 -2
- package/src/ward-with-beds/ward-with-beds.component.tsx +7 -8
- package/translations/am.json +34 -18
- package/translations/ar.json +35 -19
- package/translations/de.json +67 -0
- package/translations/en.json +34 -18
- package/translations/es.json +38 -22
- package/translations/fr.json +34 -18
- package/translations/he.json +34 -18
- package/translations/hi.json +67 -0
- package/translations/hi_IN.json +67 -0
- package/translations/id.json +67 -0
- package/translations/it.json +67 -0
- package/translations/km.json +34 -18
- package/translations/ne.json +67 -0
- package/translations/pt.json +67 -0
- package/translations/pt_BR.json +67 -0
- package/translations/qu.json +67 -0
- package/translations/si.json +67 -0
- package/translations/sw.json +67 -0
- package/translations/sw_KE.json +67 -0
- package/translations/tr.json +67 -0
- package/translations/tr_TR.json +67 -0
- package/translations/uk.json +67 -0
- package/translations/vi.json +67 -0
- package/translations/zh.json +34 -18
- package/translations/zh_CN.json +34 -18
- package/tsconfig.json +0 -1
- package/dist/169.js +0 -1
- package/dist/169.js.map +0 -1
- package/dist/339.js +0 -1
- package/dist/339.js.map +0 -1
- package/dist/455.js +0 -2
- package/dist/455.js.map +0 -1
- package/dist/501.js +0 -1
- package/dist/501.js.map +0 -1
- package/dist/766.js +0 -2
- package/dist/766.js.map +0 -1
- package/src/bed-administration/bed-administration-form.scss +0 -0
- package/src/header/illustration.component.tsx +0 -13
- package/src/setup-tests.ts +0 -1
- /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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
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
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
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
|
-
|
|
144
|
-
style={{ minWidth: '100%', margin: '0', padding: '0' }}
|
|
141
|
+
onClose={() => setShowErrorNotification(false)}
|
|
145
142
|
role="alert"
|
|
146
|
-
|
|
143
|
+
style={{ minWidth: '100%', margin: '0', padding: '0' }}
|
|
147
144
|
subtitle={t('pleaseFillField', formStateError) + '.'}
|
|
148
|
-
|
|
145
|
+
title={t('error', 'Error')}
|
|
149
146
|
/>
|
|
150
147
|
)}
|
|
151
148
|
</Stack>
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import 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 {
|
|
22
|
-
import
|
|
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('
|
|
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
|
|
36
|
-
|
|
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
|
|
42
|
-
const [
|
|
43
|
-
|
|
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
|
|
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
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
<
|
|
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
|
-
|
|
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
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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 (
|
|
91
|
+
if (isLoadingBedTypes) {
|
|
92
92
|
return (
|
|
93
93
|
<>
|
|
94
|
-
<Header
|
|
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 (
|
|
102
|
+
if (errorLoadingBedTypes) {
|
|
103
103
|
return (
|
|
104
104
|
<>
|
|
105
|
-
<Header
|
|
105
|
+
<Header title={t('bedTypes', 'Bed types')} />
|
|
106
106
|
<div className={styles.widgetCard}>
|
|
107
|
-
<ErrorState error={
|
|
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
|
|
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={
|
|
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>{
|
|
131
|
+
<span>{isValidatingBedTypes ? <InlineLoading /> : null}</span>
|
|
132
132
|
</span>
|
|
133
|
-
{
|
|
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('
|
|
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('
|
|
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('
|
|
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={
|
|
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 {
|
|
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> = ({
|
|
16
|
+
const EditBedTypeForm: React.FC<EditBedTypeFormProps> = ({ editData, mutate, onModalChange, showModal }) => {
|
|
18
17
|
const { t } = useTranslation();
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
const
|
|
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
|
-
|
|
34
|
-
title: t('
|
|
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
|
-
|
|
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={
|
|
62
|
+
availableBedTypes={bedTypes}
|
|
62
63
|
showModal={showModal}
|
|
63
|
-
|
|
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 {
|
|
4
|
-
import type { BedTypeData, Mutator } from '../types';
|
|
5
|
-
import {
|
|
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
|
-
|
|
9
|
+
mutate: Mutator<BedType>;
|
|
11
10
|
onModalChange: (showModal: boolean) => void;
|
|
12
|
-
|
|
11
|
+
showModal: boolean;
|
|
13
12
|
}
|
|
14
13
|
|
|
15
|
-
const NewBedTypeForm: React.FC<BedTypeFormProps> = ({
|
|
14
|
+
const NewBedTypeForm: React.FC<BedTypeFormProps> = ({ mutate, onModalChange, showModal }) => {
|
|
16
15
|
const { t } = useTranslation();
|
|
17
|
-
const {
|
|
18
|
-
const headerTitle = t('
|
|
19
|
-
const { bedTypes } =
|
|
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
|
|
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
|
-
|
|
42
|
-
title: t('formCreated', 'Add bed Type'),
|
|
39
|
+
showSnackbar({
|
|
43
40
|
kind: 'success',
|
|
44
|
-
|
|
45
|
-
|
|
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
|
-
|
|
53
|
-
title: t('errorCreatingForm', 'Error creating bed'),
|
|
49
|
+
showSnackbar({
|
|
54
50
|
kind: 'error',
|
|
55
|
-
|
|
56
|
-
|
|
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
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
10
|
-
headerTitle?: string;
|
|
15
|
+
title: string;
|
|
11
16
|
};
|
|
12
17
|
|
|
13
|
-
const Header: React.FC<HeaderProps> = ({
|
|
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
|
-
<
|
|
20
|
-
<
|
|
21
|
-
|
|
22
|
-
<
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
<div className={styles
|
|
30
|
-
<div className={styles
|
|
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}>·</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
|
-
</
|
|
43
|
+
</PageHeader>
|
|
39
44
|
);
|
|
40
45
|
};
|
|
41
46
|
|