@kenyaemr/esm-bed-management-app 8.1.1-pre.129 → 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.
- 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
|
@@ -1,88 +1,88 @@
|
|
|
1
1
|
import React, { useCallback } from 'react';
|
|
2
2
|
import { useTranslation } from 'react-i18next';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
import type { BedFormData } from '../types';
|
|
6
|
-
import { useBedType, editBed } from './bed-administration.resource';
|
|
7
|
-
import BedAdministrationForm from './bed-administration-form.component';
|
|
3
|
+
import { showSnackbar } from '@openmrs/esm-framework';
|
|
8
4
|
import { type BedAdministrationData } from './bed-administration-types';
|
|
5
|
+
import { type BedFormData } from '../types';
|
|
6
|
+
import { editBed, useBedType } from './bed-administration.resource';
|
|
9
7
|
import { useLocationsWithAdmissionTag } from '../summary/summary.resource';
|
|
8
|
+
import BedAdministrationForm from './bed-administration-form.component';
|
|
10
9
|
|
|
11
10
|
interface EditBedFormProps {
|
|
12
|
-
showModal: boolean;
|
|
13
|
-
onModalChange: (showModal: boolean) => void;
|
|
14
11
|
editData: BedFormData;
|
|
15
|
-
mutate: () =>
|
|
12
|
+
mutate: () => void;
|
|
13
|
+
onModalChange: (showModal: boolean) => void;
|
|
14
|
+
showModal: boolean;
|
|
16
15
|
}
|
|
17
16
|
|
|
18
17
|
const EditBedForm: React.FC<EditBedFormProps> = ({ showModal, onModalChange, editData, mutate }) => {
|
|
19
18
|
const { t } = useTranslation();
|
|
20
|
-
const {
|
|
21
|
-
|
|
22
|
-
const headerTitle = t('editBed', 'Edit bed');
|
|
23
|
-
const occupancyStatuses = ['Available', 'Occupied'];
|
|
19
|
+
const { admissionLocations } = useLocationsWithAdmissionTag();
|
|
24
20
|
const { bedTypes } = useBedType();
|
|
25
21
|
const availableBedTypes = bedTypes ? bedTypes : [];
|
|
26
|
-
const
|
|
22
|
+
const headerTitle = t('editBed', 'Edit bed');
|
|
23
|
+
const occupancyStatuses = ['Available', 'Occupied'];
|
|
24
|
+
|
|
25
|
+
const handleCreateBed = useCallback(
|
|
27
26
|
(formData: BedAdministrationData) => {
|
|
28
27
|
const bedUuid = editData.uuid;
|
|
28
|
+
|
|
29
29
|
const {
|
|
30
|
+
bedColumn = editData.column.toString(),
|
|
30
31
|
bedId = editData.bedNumber,
|
|
31
|
-
description = editData.description,
|
|
32
|
-
occupancyStatus = editData.status,
|
|
33
32
|
bedRow = editData.row.toString(),
|
|
34
|
-
bedColumn = editData.column.toString(),
|
|
35
|
-
location: { uuid: bedLocation = editData.location.uuid },
|
|
36
33
|
bedType = editData.bedType.name,
|
|
34
|
+
description = editData.description,
|
|
35
|
+
location: { uuid: bedLocation = editData.location.uuid },
|
|
36
|
+
occupancyStatus = editData.status,
|
|
37
37
|
} = formData;
|
|
38
|
+
|
|
38
39
|
const bedPayload = {
|
|
39
40
|
bedNumber: bedId,
|
|
40
41
|
bedType,
|
|
41
|
-
description,
|
|
42
|
-
status: occupancyStatus.toUpperCase(),
|
|
43
|
-
row: parseInt(bedRow),
|
|
44
42
|
column: parseInt(bedColumn),
|
|
43
|
+
description,
|
|
45
44
|
locationUuid: bedLocation,
|
|
45
|
+
row: parseInt(bedRow),
|
|
46
|
+
status: occupancyStatus.toUpperCase(),
|
|
46
47
|
};
|
|
48
|
+
|
|
47
49
|
editBed({ bedPayload, bedId: bedUuid })
|
|
48
50
|
.then(() => {
|
|
49
|
-
|
|
50
|
-
title: t('formSaved', 'Bed saved'),
|
|
51
|
+
showSnackbar({
|
|
51
52
|
kind: 'success',
|
|
52
|
-
|
|
53
|
-
|
|
53
|
+
title: t('bedUpdated', 'Bed updated'),
|
|
54
|
+
subtitle: t('bedUpdatedSuccessfully', `${bedPayload.bedNumber} updated successfully`, {
|
|
55
|
+
bedNumber: bedPayload.bedNumber,
|
|
56
|
+
}),
|
|
54
57
|
});
|
|
55
58
|
|
|
56
59
|
mutate();
|
|
57
|
-
onModalChange(false);
|
|
58
60
|
})
|
|
59
61
|
.catch((error) => {
|
|
60
|
-
|
|
61
|
-
title: t('errorCreatingForm', 'Error creating bed'),
|
|
62
|
+
showSnackbar({
|
|
62
63
|
kind: 'error',
|
|
63
|
-
|
|
64
|
-
|
|
64
|
+
title: t('errorCreatingForm', 'Error creating bed'),
|
|
65
|
+
subtitle: error?.message,
|
|
65
66
|
});
|
|
67
|
+
})
|
|
68
|
+
.finally(() => {
|
|
66
69
|
onModalChange(false);
|
|
67
70
|
});
|
|
68
|
-
onModalChange(false);
|
|
69
71
|
},
|
|
70
|
-
[
|
|
72
|
+
[editData, mutate, onModalChange, t],
|
|
71
73
|
);
|
|
72
74
|
|
|
73
75
|
return (
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
/>
|
|
85
|
-
</>
|
|
76
|
+
<BedAdministrationForm
|
|
77
|
+
allLocations={admissionLocations}
|
|
78
|
+
availableBedTypes={availableBedTypes}
|
|
79
|
+
handleCreateBed={handleCreateBed}
|
|
80
|
+
headerTitle={headerTitle}
|
|
81
|
+
initialData={editData}
|
|
82
|
+
occupancyStatuses={occupancyStatuses}
|
|
83
|
+
onModalChange={onModalChange}
|
|
84
|
+
showModal={showModal}
|
|
85
|
+
/>
|
|
86
86
|
);
|
|
87
87
|
};
|
|
88
88
|
|
|
@@ -1,43 +1,43 @@
|
|
|
1
1
|
import React, { useCallback } from 'react';
|
|
2
2
|
import { useTranslation } from 'react-i18next';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
import type { BedFormData } from '../types';
|
|
6
|
-
import { useBedType, saveBed } from './bed-administration.resource';
|
|
7
|
-
import BedAdministrationForm from './bed-administration-form.component';
|
|
8
|
-
import { useLocationsWithAdmissionTag } from '../summary/summary.resource';
|
|
3
|
+
import { showSnackbar } from '@openmrs/esm-framework';
|
|
4
|
+
import { type BedFormData } from '../types';
|
|
9
5
|
import { type BedAdministrationData } from './bed-administration-types';
|
|
6
|
+
import { saveBed, useBedType } from './bed-administration.resource';
|
|
7
|
+
import { useLocationsWithAdmissionTag } from '../summary/summary.resource';
|
|
8
|
+
import BedAdministrationForm from './bed-administration-form.component';
|
|
10
9
|
|
|
11
10
|
interface NewBedFormProps {
|
|
12
|
-
|
|
11
|
+
mutate: () => void;
|
|
13
12
|
onModalChange: (showModal: boolean) => void;
|
|
14
|
-
|
|
13
|
+
showModal: boolean;
|
|
15
14
|
}
|
|
16
15
|
|
|
17
16
|
const NewBedForm: React.FC<NewBedFormProps> = ({ showModal, onModalChange, mutate }) => {
|
|
18
17
|
const { t } = useTranslation();
|
|
19
|
-
const {
|
|
18
|
+
const { admissionLocations } = useLocationsWithAdmissionTag();
|
|
19
|
+
const { bedTypes } = useBedType();
|
|
20
|
+
|
|
20
21
|
const headerTitle = t('createNewBed', 'Create a new bed');
|
|
21
22
|
const occupancyStatuses = ['Available', 'Occupied'];
|
|
22
|
-
const { bedTypes } = useBedType();
|
|
23
23
|
const availableBedTypes = bedTypes ? bedTypes : [];
|
|
24
24
|
|
|
25
25
|
const initialData: BedFormData = {
|
|
26
|
-
id: 0,
|
|
27
|
-
uuid: '',
|
|
28
26
|
bedNumber: '',
|
|
29
|
-
|
|
30
|
-
description: '',
|
|
31
|
-
row: 0,
|
|
27
|
+
bedType: null,
|
|
32
28
|
column: 0,
|
|
29
|
+
description: '',
|
|
30
|
+
id: 0,
|
|
33
31
|
location: {
|
|
34
32
|
display: '',
|
|
35
33
|
uuid: '',
|
|
36
34
|
},
|
|
37
|
-
|
|
35
|
+
row: 0,
|
|
36
|
+
status: null,
|
|
37
|
+
uuid: '',
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
-
const
|
|
40
|
+
const handleCreateBed = useCallback(
|
|
41
41
|
(formData: BedAdministrationData) => {
|
|
42
42
|
const { bedId, description, occupancyStatus, bedRow, bedColumn, location, bedType } = formData;
|
|
43
43
|
|
|
@@ -53,43 +53,39 @@ const NewBedForm: React.FC<NewBedFormProps> = ({ showModal, onModalChange, mutat
|
|
|
53
53
|
|
|
54
54
|
saveBed({ bedPayload: bedObject })
|
|
55
55
|
.then(() => {
|
|
56
|
-
|
|
57
|
-
title: t('
|
|
56
|
+
showSnackbar({
|
|
57
|
+
title: t('newBedCreated', 'New bed created'),
|
|
58
58
|
kind: 'success',
|
|
59
|
-
|
|
60
|
-
description: `Bed ${bedId} was created successfully.`,
|
|
59
|
+
subtitle: `Bed ${bedId} created successfully`,
|
|
61
60
|
});
|
|
62
61
|
|
|
63
62
|
mutate();
|
|
64
|
-
onModalChange(false);
|
|
65
63
|
})
|
|
66
64
|
.catch((error) => {
|
|
67
|
-
|
|
65
|
+
showSnackbar({
|
|
68
66
|
title: t('errorCreatingForm', 'Error creating bed'),
|
|
69
67
|
kind: 'error',
|
|
70
|
-
|
|
71
|
-
description: error?.message,
|
|
68
|
+
subtitle: error?.message,
|
|
72
69
|
});
|
|
70
|
+
})
|
|
71
|
+
.finally(() => {
|
|
73
72
|
onModalChange(false);
|
|
74
73
|
});
|
|
75
|
-
onModalChange(false);
|
|
76
74
|
},
|
|
77
75
|
[onModalChange, mutate, t],
|
|
78
76
|
);
|
|
79
77
|
|
|
80
78
|
return (
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
/>
|
|
92
|
-
</>
|
|
79
|
+
<BedAdministrationForm
|
|
80
|
+
onModalChange={onModalChange}
|
|
81
|
+
allLocations={admissionLocations}
|
|
82
|
+
availableBedTypes={availableBedTypes}
|
|
83
|
+
showModal={showModal}
|
|
84
|
+
handleCreateBed={handleCreateBed}
|
|
85
|
+
headerTitle={headerTitle}
|
|
86
|
+
occupancyStatuses={occupancyStatuses}
|
|
87
|
+
initialData={initialData}
|
|
88
|
+
/>
|
|
93
89
|
);
|
|
94
90
|
};
|
|
95
91
|
|
|
@@ -18,31 +18,32 @@ import {
|
|
|
18
18
|
import { Add, Edit } from '@carbon/react/icons';
|
|
19
19
|
import { ErrorState, isDesktop as desktopLayout, useLayoutType } from '@openmrs/esm-framework';
|
|
20
20
|
import type { BedTagData } from '../types';
|
|
21
|
-
import {
|
|
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';
|
|
21
|
+
import { useBedTags } from '../summary/summary.resource';
|
|
25
22
|
import BedTagForm from './new-tag-form.component';
|
|
23
|
+
import CardHeader from '../card-header/card-header.component';
|
|
26
24
|
import EditBedTagForm from './edit-tag-form.component';
|
|
25
|
+
import Header from '../header/header.component';
|
|
26
|
+
import styles from '../bed-administration/bed-administration-table.scss';
|
|
27
27
|
|
|
28
28
|
const BedTagAdministrationTable: React.FC = () => {
|
|
29
29
|
const { t } = useTranslation();
|
|
30
|
-
const headerTitle = t('
|
|
30
|
+
const headerTitle = t('bedTags', 'Bed tags');
|
|
31
31
|
const layout = useLayoutType();
|
|
32
32
|
const isTablet = layout === 'tablet';
|
|
33
33
|
const responsiveSize = isTablet ? 'lg' : 'sm';
|
|
34
34
|
const isDesktop = desktopLayout(layout);
|
|
35
|
+
const { bedTags, errorLoadingBedTags, isLoadingBedTags, isValidatingBedTags, mutateBedTags } = useBedTags();
|
|
36
|
+
|
|
35
37
|
const [isBedDataLoading] = useState(false);
|
|
36
38
|
const [showBedTagsModal, setAddBedTagsModal] = useState(false);
|
|
37
39
|
const [showEditBedModal, setShowEditBedModal] = useState(false);
|
|
38
40
|
const [editData, setEditData] = useState<BedTagData>();
|
|
39
41
|
const [currentPage, setCurrentPage] = useState(1);
|
|
40
|
-
const { bedTypeData, isError, loading, validate, mutate } = useBedTag();
|
|
41
42
|
const [pageSize, setPageSize] = useState(10);
|
|
42
43
|
|
|
43
44
|
const tableHeaders = [
|
|
44
45
|
{
|
|
45
|
-
header: t('ids', '
|
|
46
|
+
header: t('ids', 'ID'),
|
|
46
47
|
key: 'ids',
|
|
47
48
|
},
|
|
48
49
|
{
|
|
@@ -56,9 +57,8 @@ const BedTagAdministrationTable: React.FC = () => {
|
|
|
56
57
|
];
|
|
57
58
|
|
|
58
59
|
const tableRows = useMemo(() => {
|
|
59
|
-
return
|
|
60
|
+
return bedTags?.map((entry) => ({
|
|
60
61
|
id: entry.uuid,
|
|
61
|
-
ids: entry.id,
|
|
62
62
|
name: entry?.name,
|
|
63
63
|
actions: (
|
|
64
64
|
<>
|
|
@@ -80,12 +80,12 @@ const BedTagAdministrationTable: React.FC = () => {
|
|
|
80
80
|
</>
|
|
81
81
|
),
|
|
82
82
|
}));
|
|
83
|
-
}, [responsiveSize,
|
|
83
|
+
}, [responsiveSize, bedTags, t]);
|
|
84
84
|
|
|
85
|
-
if (isBedDataLoading ||
|
|
85
|
+
if (isBedDataLoading || isLoadingBedTags) {
|
|
86
86
|
return (
|
|
87
87
|
<>
|
|
88
|
-
<Header
|
|
88
|
+
<Header title={t('bedTags', 'Bed tags')} />
|
|
89
89
|
<div className={styles.widgetCard}>
|
|
90
90
|
<DataTableSkeleton role="progressbar" compact={isDesktop} zebra />
|
|
91
91
|
</div>
|
|
@@ -93,12 +93,12 @@ const BedTagAdministrationTable: React.FC = () => {
|
|
|
93
93
|
);
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
if (
|
|
96
|
+
if (errorLoadingBedTags) {
|
|
97
97
|
return (
|
|
98
98
|
<>
|
|
99
|
-
<Header
|
|
99
|
+
<Header title={t('bedTags', 'Bed tags')} />
|
|
100
100
|
<div className={styles.widgetCard}>
|
|
101
|
-
<ErrorState error={
|
|
101
|
+
<ErrorState error={errorLoadingBedTags} headerTitle={headerTitle} />
|
|
102
102
|
</div>
|
|
103
103
|
</>
|
|
104
104
|
);
|
|
@@ -106,30 +106,30 @@ const BedTagAdministrationTable: React.FC = () => {
|
|
|
106
106
|
|
|
107
107
|
return (
|
|
108
108
|
<>
|
|
109
|
-
<Header
|
|
109
|
+
<Header title={t('bedTags', 'Bed tags')} />
|
|
110
110
|
|
|
111
111
|
<div className={styles.widgetCard}>
|
|
112
112
|
{showBedTagsModal ? (
|
|
113
|
-
<BedTagForm onModalChange={setAddBedTagsModal} showModal={showBedTagsModal} mutate={
|
|
113
|
+
<BedTagForm onModalChange={setAddBedTagsModal} showModal={showBedTagsModal} mutate={mutateBedTags} />
|
|
114
114
|
) : null}
|
|
115
115
|
{showEditBedModal ? (
|
|
116
116
|
<EditBedTagForm
|
|
117
117
|
onModalChange={setShowEditBedModal}
|
|
118
118
|
showModal={showEditBedModal}
|
|
119
119
|
editData={editData}
|
|
120
|
-
mutate={
|
|
120
|
+
mutate={mutateBedTags}
|
|
121
121
|
/>
|
|
122
122
|
) : null}
|
|
123
123
|
<CardHeader title={headerTitle}>
|
|
124
124
|
<span className={styles.backgroundDataFetchingIndicator}>
|
|
125
|
-
<span>{
|
|
125
|
+
<span>{isValidatingBedTags ? <InlineLoading /> : null}</span>
|
|
126
126
|
</span>
|
|
127
|
-
{
|
|
127
|
+
{bedTags?.length ? (
|
|
128
128
|
<Button
|
|
129
129
|
kind="ghost"
|
|
130
130
|
renderIcon={(props) => <Add size={16} {...props} />}
|
|
131
131
|
onClick={() => setAddBedTagsModal(true)}>
|
|
132
|
-
{t('addBedTag', 'Add
|
|
132
|
+
{t('addBedTag', 'Add bed tag')}
|
|
133
133
|
</Button>
|
|
134
134
|
) : null}
|
|
135
135
|
</CardHeader>
|
|
@@ -167,7 +167,7 @@ const BedTagAdministrationTable: React.FC = () => {
|
|
|
167
167
|
size="sm"
|
|
168
168
|
renderIcon={(props) => <Add size={16} {...props} />}
|
|
169
169
|
onClick={() => setAddBedTagsModal(true)}>
|
|
170
|
-
{t('
|
|
170
|
+
{t('addBedTag', 'Add bed tag')}
|
|
171
171
|
</Button>
|
|
172
172
|
</Tile>
|
|
173
173
|
</div>
|
|
@@ -176,7 +176,7 @@ const BedTagAdministrationTable: React.FC = () => {
|
|
|
176
176
|
page={currentPage}
|
|
177
177
|
pageSize={pageSize}
|
|
178
178
|
pageSizes={[10, 20, 30, 40, 50]}
|
|
179
|
-
totalItems={
|
|
179
|
+
totalItems={bedTags.length}
|
|
180
180
|
onChange={({ page, pageSize }) => {
|
|
181
181
|
setCurrentPage(page);
|
|
182
182
|
setPageSize(pageSize);
|
|
@@ -7,30 +7,31 @@ 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
|
TextInput,
|
|
15
|
-
InlineNotification,
|
|
16
16
|
} from '@carbon/react';
|
|
17
17
|
import { useTranslation } from 'react-i18next';
|
|
18
18
|
import { getCoreTranslation, type Location } from '@openmrs/esm-framework';
|
|
19
19
|
import type { BedTagData } from '../types';
|
|
20
|
+
import styles from '../modals.scss';
|
|
20
21
|
|
|
21
22
|
const BedTagAdministrationSchema = z.object({
|
|
22
23
|
name: z.string().max(255),
|
|
23
24
|
});
|
|
24
25
|
|
|
25
26
|
interface BedTagAdministrationFormProps {
|
|
26
|
-
showModal: boolean;
|
|
27
|
-
onModalChange: (showModal: boolean) => void;
|
|
28
|
-
availableBedTypes: Array<BedTagData>;
|
|
29
27
|
allLocations: Location[];
|
|
30
|
-
|
|
28
|
+
availableBedTags: Array<BedTagData>;
|
|
29
|
+
handleCreateBedTag?: (formData: BedTagData) => void;
|
|
31
30
|
handleDeleteBedTag?: () => void;
|
|
32
31
|
headerTitle: string;
|
|
33
32
|
initialData: BedTagData;
|
|
33
|
+
onModalChange: (showModal: boolean) => void;
|
|
34
|
+
showModal: boolean;
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
interface ErrorType {
|
|
@@ -38,11 +39,11 @@ interface ErrorType {
|
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
const BedTagsAdministrationForm: React.FC<BedTagAdministrationFormProps> = ({
|
|
41
|
-
|
|
42
|
-
onModalChange,
|
|
43
|
-
handleCreateQuestion,
|
|
42
|
+
handleCreateBedTag,
|
|
44
43
|
headerTitle,
|
|
45
44
|
initialData,
|
|
45
|
+
onModalChange,
|
|
46
|
+
showModal,
|
|
46
47
|
}) => {
|
|
47
48
|
const { t } = useTranslation();
|
|
48
49
|
|
|
@@ -65,7 +66,7 @@ const BedTagsAdministrationForm: React.FC<BedTagAdministrationFormProps> = ({
|
|
|
65
66
|
const result = BedTagAdministrationSchema.safeParse(formData);
|
|
66
67
|
if (result.success) {
|
|
67
68
|
setShowErrorNotification(false);
|
|
68
|
-
|
|
69
|
+
handleCreateBedTag(formData);
|
|
69
70
|
}
|
|
70
71
|
};
|
|
71
72
|
|
|
@@ -76,7 +77,7 @@ const BedTagsAdministrationForm: React.FC<BedTagAdministrationFormProps> = ({
|
|
|
76
77
|
|
|
77
78
|
return (
|
|
78
79
|
<ComposedModal open={showModal} onClose={() => onModalChange(false)} preventCloseOnClickOutside>
|
|
79
|
-
<ModalHeader title={headerTitle} />
|
|
80
|
+
<ModalHeader className={styles.modalHeader} title={headerTitle} />
|
|
80
81
|
<ModalBody hasScrollingContent>
|
|
81
82
|
<Form>
|
|
82
83
|
<Stack gap={3}>
|
|
@@ -88,7 +89,7 @@ const BedTagsAdministrationForm: React.FC<BedTagAdministrationFormProps> = ({
|
|
|
88
89
|
<>
|
|
89
90
|
<TextInput
|
|
90
91
|
id="bedTag"
|
|
91
|
-
labelText={t('
|
|
92
|
+
labelText={t('bedTags', 'Bed tags')}
|
|
92
93
|
placeholder={t('bedTagPlaceholder', '')}
|
|
93
94
|
invalidText={fieldState.error?.message}
|
|
94
95
|
{...field}
|
|
@@ -1,55 +1,53 @@
|
|
|
1
1
|
import React, { useCallback } from 'react';
|
|
2
2
|
import { useTranslation } from 'react-i18next';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
import {
|
|
3
|
+
import { showSnackbar } from '@openmrs/esm-framework';
|
|
4
|
+
import { editBedTag, useBedTags } from '../summary/summary.resource';
|
|
5
|
+
import { type BedTagData, type Mutator } from '../types';
|
|
6
6
|
import { type BedTagDataAdministration } from '../bed-administration/bed-administration-types';
|
|
7
7
|
import BedTagsAdministrationForm from './bed-tags-admin-form.component';
|
|
8
|
-
import { type BedTagData, type Mutator } from '../types';
|
|
9
8
|
|
|
10
9
|
interface EditBedTagFormProps {
|
|
11
|
-
showModal: boolean;
|
|
12
|
-
onModalChange: (showModal: boolean) => void;
|
|
13
10
|
editData: BedTagData;
|
|
14
|
-
mutate: Mutator
|
|
11
|
+
mutate: Mutator<BedTagData>;
|
|
12
|
+
onModalChange: (showModal: boolean) => void;
|
|
13
|
+
showModal: boolean;
|
|
15
14
|
}
|
|
16
15
|
|
|
17
|
-
const EditBedTagForm: React.FC<EditBedTagFormProps> = ({
|
|
16
|
+
const EditBedTagForm: React.FC<EditBedTagFormProps> = ({ editData, mutate, onModalChange, showModal }) => {
|
|
18
17
|
const { t } = useTranslation();
|
|
18
|
+
const { bedTags } = useBedTags();
|
|
19
|
+
const headerTitle = t('editTag', 'Edit Tag');
|
|
19
20
|
|
|
20
|
-
const
|
|
21
|
-
const { bedTypeData } = useBedTag();
|
|
22
|
-
const availableBedTypes = bedTypeData ? bedTypeData : [];
|
|
23
|
-
|
|
24
|
-
const handleCreateQuestion = useCallback(
|
|
21
|
+
const handleUpdateBedTag = useCallback(
|
|
25
22
|
(formData: BedTagDataAdministration) => {
|
|
26
23
|
const bedUuid = editData.uuid;
|
|
27
24
|
const { name } = formData;
|
|
25
|
+
|
|
28
26
|
const bedTagPayload = {
|
|
29
27
|
name,
|
|
30
28
|
};
|
|
29
|
+
|
|
31
30
|
editBedTag({ bedTagPayload, bedTagId: bedUuid })
|
|
32
31
|
.then(() => {
|
|
33
|
-
|
|
34
|
-
title: t('formSaved', 'Bed Tag'),
|
|
32
|
+
showSnackbar({
|
|
35
33
|
kind: 'success',
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
title: t('bedTagUpdated', 'Bed tag updated'),
|
|
35
|
+
subtitle: t('bedTagUpdatedSuccessfully', `${bedTagPayload.name} updated successfully`, {
|
|
36
|
+
bedTag: bedTagPayload.name,
|
|
37
|
+
}),
|
|
38
38
|
});
|
|
39
|
-
|
|
40
39
|
mutate();
|
|
41
|
-
onModalChange(false);
|
|
42
40
|
})
|
|
43
41
|
.catch((error) => {
|
|
44
|
-
|
|
45
|
-
title: t('errorCreatingForm', 'Error creating bed'),
|
|
42
|
+
showSnackbar({
|
|
46
43
|
kind: 'error',
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
title: t('errorCreatingBedTag', 'Error creating bed tag'),
|
|
45
|
+
subtitle: error?.message,
|
|
49
46
|
});
|
|
47
|
+
})
|
|
48
|
+
.finally(() => {
|
|
50
49
|
onModalChange(false);
|
|
51
50
|
});
|
|
52
|
-
onModalChange(false);
|
|
53
51
|
},
|
|
54
52
|
[onModalChange, mutate, editData, t],
|
|
55
53
|
);
|
|
@@ -57,13 +55,13 @@ const EditBedTagForm: React.FC<EditBedTagFormProps> = ({ showModal, onModalChang
|
|
|
57
55
|
return (
|
|
58
56
|
<>
|
|
59
57
|
<BedTagsAdministrationForm
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
handleCreateQuestion={handleCreateQuestion}
|
|
58
|
+
allLocations={[]}
|
|
59
|
+
availableBedTags={bedTags}
|
|
60
|
+
handleCreateBedTag={handleUpdateBedTag}
|
|
64
61
|
headerTitle={headerTitle}
|
|
65
62
|
initialData={editData}
|
|
66
|
-
|
|
63
|
+
onModalChange={onModalChange}
|
|
64
|
+
showModal={showModal}
|
|
67
65
|
/>
|
|
68
66
|
</>
|
|
69
67
|
);
|
|
@@ -1,30 +1,28 @@
|
|
|
1
1
|
import React, { useCallback } from 'react';
|
|
2
2
|
import { useTranslation } from 'react-i18next';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { showSnackbar } from '@openmrs/esm-framework';
|
|
4
|
+
import { saveBedTag, useBedTags, useLocationsWithAdmissionTag } from '../summary/summary.resource';
|
|
5
|
+
import { type BedTagData } from '../types';
|
|
5
6
|
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
7
|
|
|
9
8
|
interface BedTagFormProps {
|
|
10
|
-
|
|
9
|
+
mutate: () => void;
|
|
11
10
|
onModalChange: (showModal: boolean) => void;
|
|
12
|
-
|
|
11
|
+
showModal: boolean;
|
|
13
12
|
}
|
|
14
13
|
|
|
15
14
|
const NewTagForm: React.FC<BedTagFormProps> = ({ showModal, onModalChange, mutate }) => {
|
|
16
15
|
const { t } = useTranslation();
|
|
17
|
-
const {
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const availableBedTypes = bedTypes ? bedTypes : [];
|
|
16
|
+
const { admissionLocations } = useLocationsWithAdmissionTag();
|
|
17
|
+
const { bedTags } = useBedTags();
|
|
18
|
+
const headerTitle = t('createBedTag', 'Create bed tag');
|
|
21
19
|
|
|
22
20
|
const initialData: BedTagData = {
|
|
23
|
-
uuid: '',
|
|
24
21
|
name: '',
|
|
22
|
+
uuid: '',
|
|
25
23
|
};
|
|
26
24
|
|
|
27
|
-
const
|
|
25
|
+
const handleCreateBedTag = useCallback(
|
|
28
26
|
(formData: BedTagData) => {
|
|
29
27
|
const { name } = formData;
|
|
30
28
|
|
|
@@ -34,42 +32,39 @@ const NewTagForm: React.FC<BedTagFormProps> = ({ showModal, onModalChange, mutat
|
|
|
34
32
|
|
|
35
33
|
saveBedTag({ bedTagPayload })
|
|
36
34
|
.then(() => {
|
|
37
|
-
|
|
38
|
-
title: t('formCreated', 'Add Bed Tag'),
|
|
35
|
+
showSnackbar({
|
|
39
36
|
kind: 'success',
|
|
40
|
-
|
|
41
|
-
|
|
37
|
+
title: t('bedTagCreated', 'Bed tag created'),
|
|
38
|
+
subtitle: t('bedTagCreatedSuccessfully', `${name} created successfully`, {
|
|
39
|
+
bedTag: name,
|
|
40
|
+
}),
|
|
42
41
|
});
|
|
43
|
-
|
|
44
42
|
mutate();
|
|
45
|
-
onModalChange(false);
|
|
46
43
|
})
|
|
47
44
|
.catch((error) => {
|
|
48
|
-
|
|
49
|
-
title: t('errorCreatingForm', 'Error creating bed'),
|
|
45
|
+
showSnackbar({
|
|
50
46
|
kind: 'error',
|
|
51
|
-
|
|
52
|
-
|
|
47
|
+
title: t('errorCreatingForm', 'Error creating bed'),
|
|
48
|
+
subtitle: error?.message,
|
|
53
49
|
});
|
|
50
|
+
})
|
|
51
|
+
.finally(() => {
|
|
54
52
|
onModalChange(false);
|
|
55
53
|
});
|
|
56
|
-
onModalChange(false);
|
|
57
54
|
},
|
|
58
55
|
[onModalChange, mutate, t],
|
|
59
56
|
);
|
|
60
57
|
|
|
61
58
|
return (
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
/>
|
|
72
|
-
</>
|
|
59
|
+
<BedTagsAdministrationForm
|
|
60
|
+
allLocations={admissionLocations}
|
|
61
|
+
availableBedTags={bedTags}
|
|
62
|
+
handleCreateBedTag={handleCreateBedTag}
|
|
63
|
+
headerTitle={headerTitle}
|
|
64
|
+
initialData={initialData}
|
|
65
|
+
onModalChange={onModalChange}
|
|
66
|
+
showModal={showModal}
|
|
67
|
+
/>
|
|
73
68
|
);
|
|
74
69
|
};
|
|
75
70
|
|