@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
@@ -1,43 +1,43 @@
1
1
  import React, { useCallback } from 'react';
2
2
  import { useTranslation } from 'react-i18next';
3
- import { showToast, showNotification } from '@openmrs/esm-framework';
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
- showModal: boolean;
11
+ mutate: () => void;
13
12
  onModalChange: (showModal: boolean) => void;
14
- mutate: () => any;
13
+ showModal: boolean;
15
14
  }
16
15
 
17
16
  const NewBedForm: React.FC<NewBedFormProps> = ({ showModal, onModalChange, mutate }) => {
18
17
  const { t } = useTranslation();
19
- const { data: admissionLocations } = useLocationsWithAdmissionTag();
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
- status: null,
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
- bedType: null,
35
+ row: 0,
36
+ status: null,
37
+ uuid: '',
38
38
  };
39
39
 
40
- const handleCreateQuestion = useCallback(
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
- showToast({
57
- title: t('formCreated', 'New bed created'),
56
+ showSnackbar({
57
+ title: t('newBedCreated', 'New bed created'),
58
58
  kind: 'success',
59
- critical: true,
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
- showNotification({
65
+ showSnackbar({
68
66
  title: t('errorCreatingForm', 'Error creating bed'),
69
67
  kind: 'error',
70
- critical: true,
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
- <BedAdministrationForm
83
- onModalChange={onModalChange}
84
- allLocations={admissionLocations}
85
- availableBedTypes={availableBedTypes}
86
- showModal={showModal}
87
- handleCreateQuestion={handleCreateQuestion}
88
- headerTitle={headerTitle}
89
- occupancyStatuses={occupancyStatuses}
90
- initialData={initialData}
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 { 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';
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('bedTag', 'Bed Tag');
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', 'Id'),
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 bedTypeData?.map((entry) => ({
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, bedTypeData, t]);
83
+ }, [responsiveSize, bedTags, t]);
84
84
 
85
- if (isBedDataLoading || loading) {
85
+ if (isBedDataLoading || isLoadingBedTags) {
86
86
  return (
87
87
  <>
88
- <Header route="Bed Tag" />
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 (isError) {
96
+ if (errorLoadingBedTags) {
97
97
  return (
98
98
  <>
99
- <Header route="Bed Tag" />
99
+ <Header title={t('bedTags', 'Bed tags')} />
100
100
  <div className={styles.widgetCard}>
101
- <ErrorState error={isError} headerTitle={headerTitle} />
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 route="Bed Tag" />
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={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={mutate}
120
+ mutate={mutateBedTags}
121
121
  />
122
122
  ) : null}
123
123
  <CardHeader title={headerTitle}>
124
124
  <span className={styles.backgroundDataFetchingIndicator}>
125
- <span>{validate ? <InlineLoading /> : null}</span>
125
+ <span>{isValidatingBedTags ? <InlineLoading /> : null}</span>
126
126
  </span>
127
- {bedTypeData?.length ? (
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 Bed Tag')}
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('bedTag', 'Add Bed Tag')}
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={bedTypeData.length}
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
- handleCreateQuestion?: (formData: BedTagData) => void;
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
- showModal,
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
- handleCreateQuestion(formData);
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('bedTag', 'Bed Tag Name')}
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 { showToast, showNotification, useConfig } from '@openmrs/esm-framework';
4
-
5
- import { editBedTag, useBedTag } from '../summary/summary.resource';
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> = ({ showModal, onModalChange, editData, mutate }) => {
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 headerTitle = t('editBed', 'Edit Tag');
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
- showToast({
34
- title: t('formSaved', 'Bed Tag'),
32
+ showSnackbar({
35
33
  kind: 'success',
36
- critical: true,
37
- description: bedTagPayload.name + ' ' + t('saveSuccessMessage', 'was saved successfully.'),
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
- showNotification({
45
- title: t('errorCreatingForm', 'Error creating bed'),
42
+ showSnackbar({
46
43
  kind: 'error',
47
- critical: true,
48
- description: error?.message,
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
- onModalChange={onModalChange}
61
- availableBedTypes={availableBedTypes}
62
- showModal={showModal}
63
- handleCreateQuestion={handleCreateQuestion}
58
+ allLocations={[]}
59
+ availableBedTags={bedTags}
60
+ handleCreateBedTag={handleUpdateBedTag}
64
61
  headerTitle={headerTitle}
65
62
  initialData={editData}
66
- allLocations={[]}
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 { showToast, showNotification, useConfig } from '@openmrs/esm-framework';
4
- import { useBedType } from '../bed-administration/bed-administration.resource';
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
- showModal: boolean;
9
+ mutate: () => void;
11
10
  onModalChange: (showModal: boolean) => void;
12
- mutate: () => any;
11
+ showModal: boolean;
13
12
  }
14
13
 
15
14
  const NewTagForm: React.FC<BedTagFormProps> = ({ showModal, onModalChange, mutate }) => {
16
15
  const { t } = useTranslation();
17
- const { data: admissionLocations } = useLocationsWithAdmissionTag();
18
- const headerTitle = t('addBedTag', 'Create Bed Tag');
19
- const { bedTypes } = useBedType();
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 handleCreateQuestion = useCallback(
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
- showToast({
38
- title: t('formCreated', 'Add Bed Tag'),
35
+ showSnackbar({
39
36
  kind: 'success',
40
- critical: true,
41
- description: `Tag ${name} was created successfully.`,
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
- showNotification({
49
- title: t('errorCreatingForm', 'Error creating bed'),
45
+ showSnackbar({
50
46
  kind: 'error',
51
- critical: true,
52
- description: error?.message,
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
- <BedTagsAdministrationForm
64
- onModalChange={onModalChange}
65
- allLocations={admissionLocations}
66
- availableBedTypes={availableBedTypes}
67
- showModal={showModal}
68
- handleCreateQuestion={handleCreateQuestion}
69
- headerTitle={headerTitle}
70
- initialData={initialData}
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