@kenyaemr/esm-admin-app 5.4.3 → 5.4.4-pre.100

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 (296) hide show
  1. package/.turbo/turbo-build.log +5 -12
  2. package/dist/1074.js +1 -0
  3. package/dist/1074.js.map +1 -0
  4. package/dist/12.js +17 -0
  5. package/dist/12.js.map +1 -0
  6. package/dist/1201.js +1 -0
  7. package/dist/1201.js.map +1 -0
  8. package/dist/1242.js +1 -0
  9. package/dist/1242.js.map +1 -0
  10. package/dist/1311.js +1 -0
  11. package/dist/1311.js.map +1 -0
  12. package/dist/1462.js +1 -0
  13. package/dist/1462.js.map +1 -0
  14. package/dist/1469.js +1 -0
  15. package/dist/1469.js.map +1 -0
  16. package/dist/1506.js +13 -0
  17. package/dist/1506.js.map +1 -0
  18. package/dist/1718.js +1 -0
  19. package/dist/1718.js.map +1 -0
  20. package/dist/1722.js +1 -0
  21. package/dist/1722.js.map +1 -0
  22. package/dist/1772.js +1 -0
  23. package/dist/1772.js.map +1 -0
  24. package/dist/1889.js +1 -0
  25. package/dist/1889.js.map +1 -0
  26. package/dist/1972.js +1 -0
  27. package/dist/1972.js.map +1 -0
  28. package/dist/1990.js +1 -0
  29. package/dist/1990.js.map +1 -0
  30. package/dist/2016.js +1 -0
  31. package/dist/2016.js.map +1 -0
  32. package/dist/2080.js +1 -0
  33. package/dist/2080.js.map +1 -0
  34. package/dist/2096.js +1 -0
  35. package/dist/2096.js.map +1 -0
  36. package/dist/2153.js +1 -0
  37. package/dist/2153.js.map +1 -0
  38. package/dist/216.js +1 -0
  39. package/dist/216.js.map +1 -0
  40. package/dist/2270.js +1 -0
  41. package/dist/2270.js.map +1 -0
  42. package/dist/2294.js +1 -0
  43. package/dist/2294.js.map +1 -0
  44. package/dist/2345.js +1 -0
  45. package/dist/2345.js.map +1 -0
  46. package/dist/2402.js +1 -0
  47. package/dist/2402.js.map +1 -0
  48. package/dist/2500.js +1 -0
  49. package/dist/2500.js.map +1 -0
  50. package/dist/251.js +1 -0
  51. package/dist/251.js.map +1 -0
  52. package/dist/257.js +1 -0
  53. package/dist/257.js.map +1 -0
  54. package/dist/2586.js +1 -0
  55. package/dist/2586.js.map +1 -0
  56. package/dist/2625.js +1 -0
  57. package/dist/2625.js.map +1 -0
  58. package/dist/2652.js +1 -0
  59. package/dist/2652.js.map +1 -0
  60. package/dist/2685.js +1 -0
  61. package/dist/2685.js.map +1 -0
  62. package/dist/2948.js +1 -0
  63. package/dist/2948.js.map +1 -0
  64. package/dist/3089.js +1 -0
  65. package/dist/3089.js.map +1 -0
  66. package/dist/3190.js +1 -0
  67. package/dist/3190.js.map +1 -0
  68. package/dist/3224.js +1 -0
  69. package/dist/3224.js.map +1 -0
  70. package/dist/3366.js +1 -0
  71. package/dist/3366.js.map +1 -0
  72. package/dist/349.js +1 -0
  73. package/dist/349.js.map +1 -0
  74. package/dist/3548.js +1 -0
  75. package/dist/3548.js.map +1 -0
  76. package/dist/3571.js +1 -0
  77. package/dist/3571.js.map +1 -0
  78. package/dist/3691.js +1 -0
  79. package/dist/3691.js.map +1 -0
  80. package/dist/3775.js +1 -0
  81. package/dist/3775.js.map +1 -0
  82. package/dist/3816.js +1 -0
  83. package/dist/3816.js.map +1 -0
  84. package/dist/3852.js +1 -0
  85. package/dist/3852.js.map +1 -0
  86. package/dist/3906.js +1 -0
  87. package/dist/3906.js.map +1 -0
  88. package/dist/3963.js +1 -0
  89. package/dist/3963.js.map +1 -0
  90. package/dist/405.js +1 -0
  91. package/dist/405.js.map +1 -0
  92. package/dist/4296.js +1 -0
  93. package/dist/4296.js.map +1 -0
  94. package/dist/4337.js +1 -0
  95. package/dist/4337.js.map +1 -0
  96. package/dist/4735.js +1 -0
  97. package/dist/4735.js.map +1 -0
  98. package/dist/4744.js +1 -0
  99. package/dist/4744.js.map +1 -0
  100. package/dist/4813.js +2 -0
  101. package/dist/4813.js.map +1 -0
  102. package/dist/4858.js +1 -0
  103. package/dist/4858.js.map +1 -0
  104. package/dist/487.js +1 -0
  105. package/dist/487.js.map +1 -0
  106. package/dist/4970.js +1 -0
  107. package/dist/4970.js.map +1 -0
  108. package/dist/5202.js +1 -0
  109. package/dist/5202.js.map +1 -0
  110. package/dist/5294.js +1 -0
  111. package/dist/5294.js.map +1 -0
  112. package/dist/545.js +1 -0
  113. package/dist/545.js.map +1 -0
  114. package/dist/552.js +1 -0
  115. package/dist/552.js.map +1 -0
  116. package/dist/5592.js +1 -0
  117. package/dist/5592.js.map +1 -0
  118. package/dist/5669.js +1 -0
  119. package/dist/5669.js.map +1 -0
  120. package/dist/5884.js +1 -0
  121. package/dist/5884.js.map +1 -0
  122. package/dist/5940.js +1 -0
  123. package/dist/5940.js.map +1 -0
  124. package/dist/6092.js +1 -0
  125. package/dist/6092.js.map +1 -0
  126. package/dist/6155.js +1 -0
  127. package/dist/6155.js.map +1 -0
  128. package/dist/6178.js +1 -0
  129. package/dist/6178.js.map +1 -0
  130. package/dist/6399.js +1 -0
  131. package/dist/6399.js.map +1 -0
  132. package/dist/6456.js +1 -0
  133. package/dist/6466.js +3 -0
  134. package/dist/6466.js.map +1 -0
  135. package/dist/6492.js +1 -0
  136. package/dist/6492.js.map +1 -0
  137. package/dist/6676.js +1 -0
  138. package/dist/6676.js.map +1 -0
  139. package/dist/6800.js +1 -0
  140. package/dist/6800.js.map +1 -0
  141. package/dist/6976.js +1 -0
  142. package/dist/6976.js.map +1 -0
  143. package/dist/7005.js +1 -0
  144. package/dist/7005.js.map +1 -0
  145. package/dist/7201.js +1 -0
  146. package/dist/7201.js.map +1 -0
  147. package/dist/7210.js +1 -0
  148. package/dist/7210.js.map +1 -0
  149. package/dist/7234.js +1 -0
  150. package/dist/7234.js.map +1 -0
  151. package/dist/7261.js +1 -0
  152. package/dist/7261.js.map +1 -0
  153. package/dist/7326.js +1 -0
  154. package/dist/7463.js +1 -0
  155. package/dist/7463.js.map +1 -0
  156. package/dist/7528.js +1 -0
  157. package/dist/7528.js.map +1 -0
  158. package/dist/7584.js +1 -0
  159. package/dist/7584.js.map +1 -0
  160. package/dist/7607.js +1 -0
  161. package/dist/7717.js +1 -0
  162. package/dist/7717.js.map +1 -0
  163. package/dist/7737.js +1 -0
  164. package/dist/7737.js.map +1 -0
  165. package/dist/7739.js +1 -0
  166. package/dist/7739.js.map +1 -0
  167. package/dist/7765.js +1 -0
  168. package/dist/7765.js.map +1 -0
  169. package/dist/7820.js +1 -0
  170. package/dist/7820.js.map +1 -0
  171. package/dist/7844.js +1 -0
  172. package/dist/7844.js.map +1 -0
  173. package/dist/7866.js +1 -0
  174. package/dist/7866.js.map +1 -0
  175. package/dist/7916.js +1 -0
  176. package/dist/7916.js.map +1 -0
  177. package/dist/7971.js +1 -0
  178. package/dist/7971.js.map +1 -0
  179. package/dist/8159.js +7 -0
  180. package/dist/8159.js.map +1 -0
  181. package/dist/8244.js +1 -0
  182. package/dist/8244.js.map +1 -0
  183. package/dist/8262.js +1 -0
  184. package/dist/8262.js.map +1 -0
  185. package/dist/834.js +1 -0
  186. package/dist/834.js.map +1 -0
  187. package/dist/8376.js +1 -0
  188. package/dist/8376.js.map +1 -0
  189. package/dist/845.js +1 -0
  190. package/dist/845.js.map +1 -0
  191. package/dist/8546.js +1 -0
  192. package/dist/8546.js.map +1 -0
  193. package/dist/8570.js +1 -0
  194. package/dist/8570.js.map +1 -0
  195. package/dist/87.js +1 -0
  196. package/dist/87.js.map +1 -0
  197. package/dist/8727.js +1 -0
  198. package/dist/8828.js +1 -0
  199. package/dist/8828.js.map +1 -0
  200. package/dist/8860.js +1 -0
  201. package/dist/8860.js.map +1 -0
  202. package/dist/9036.js +1 -0
  203. package/dist/9036.js.map +1 -0
  204. package/dist/9124.js +1 -0
  205. package/dist/9124.js.map +1 -0
  206. package/dist/9182.js +1 -0
  207. package/dist/921.js +1 -0
  208. package/dist/921.js.map +1 -0
  209. package/dist/9404.js +1 -0
  210. package/dist/9404.js.map +1 -0
  211. package/dist/9406.js +1 -0
  212. package/dist/9406.js.map +1 -0
  213. package/dist/9446.js +1 -0
  214. package/dist/9446.js.map +1 -0
  215. package/dist/9449.js +1 -0
  216. package/dist/9449.js.map +1 -0
  217. package/dist/9566.js +5 -0
  218. package/dist/9566.js.map +1 -0
  219. package/dist/9641.js +1 -0
  220. package/dist/9641.js.map +1 -0
  221. package/dist/9711.js +1 -0
  222. package/dist/9711.js.map +1 -0
  223. package/dist/9801.js +1 -0
  224. package/dist/9801.js.map +1 -0
  225. package/dist/9835.js +11 -0
  226. package/dist/9835.js.map +1 -0
  227. package/dist/kenyaemr-esm-admin-app.js +5 -5
  228. package/dist/kenyaemr-esm-admin-app.js.buildmanifest.json +2704 -155
  229. package/dist/kenyaemr-esm-admin-app.js.map +1 -1
  230. package/dist/main.js +5 -31
  231. package/dist/main.js.map +1 -1
  232. package/dist/routes.json +1 -1
  233. package/package.json +6 -7
  234. package/rspack.config.js +1 -1
  235. package/src/components/facility-setup/facility-info.component.tsx +163 -94
  236. package/src/components/facility-setup/facility-info.scss +98 -55
  237. package/src/components/facility-setup/header/header.component.tsx +4 -10
  238. package/src/components/facility-setup/header/header.scss +3 -9
  239. package/src/components/facility-setup/shared/custom-info.component.tsx +9 -0
  240. package/src/components/facility-setup/shared/custom-section-card.component.tsx +10 -0
  241. package/src/components/facility-setup/shared/custom-status-tag.component.tsx +22 -0
  242. package/src/components/locations/forms/add-location/add-location.workspace.tsx +96 -95
  243. package/src/components/locations/forms/search-location/search-location.workspace.tsx +90 -85
  244. package/src/components/locations/tables/locations-table.component.tsx +117 -121
  245. package/src/components/users/manage-users/manage-user-role-scope/user-role-scope-workspace/user-role-scope.workspace.tsx +15 -15
  246. package/src/components/users/manage-users/user-list/user-list.component.tsx +22 -9
  247. package/src/components/users/manage-users/user-management.workspace.tsx +538 -531
  248. package/src/index.ts +51 -28
  249. package/src/root.component.tsx +11 -13
  250. package/src/routes.json +40 -40
  251. package/src/types/index.ts +29 -1
  252. package/src/user-management.resources.ts +5 -11
  253. package/translations/am.json +26 -8
  254. package/translations/en.json +26 -8
  255. package/translations/sw.json +26 -8
  256. package/tsconfig.json +1 -1
  257. package/dist/127.js +0 -1
  258. package/dist/267.js +0 -1
  259. package/dist/267.js.map +0 -1
  260. package/dist/281.js +0 -15
  261. package/dist/281.js.map +0 -1
  262. package/dist/329.js +0 -1
  263. package/dist/329.js.map +0 -1
  264. package/dist/40.js +0 -1
  265. package/dist/466.js +0 -1
  266. package/dist/466.js.map +0 -1
  267. package/dist/472.js +0 -1
  268. package/dist/472.js.map +0 -1
  269. package/dist/478.js +0 -1
  270. package/dist/478.js.map +0 -1
  271. package/dist/585.js +0 -1
  272. package/dist/585.js.map +0 -1
  273. package/dist/630.js +0 -1
  274. package/dist/630.js.map +0 -1
  275. package/dist/675.js +0 -1
  276. package/dist/675.js.map +0 -1
  277. package/dist/689.js +0 -1
  278. package/dist/689.js.map +0 -1
  279. package/dist/706.js +0 -27
  280. package/dist/706.js.map +0 -1
  281. package/dist/729.js +0 -17
  282. package/dist/729.js.map +0 -1
  283. package/dist/774.js +0 -1
  284. package/dist/774.js.map +0 -1
  285. package/dist/847.js +0 -1
  286. package/dist/847.js.map +0 -1
  287. package/dist/85.js +0 -1
  288. package/dist/85.js.map +0 -1
  289. package/dist/882.js +0 -1
  290. package/dist/91.js +0 -1
  291. package/dist/91.js.map +0 -1
  292. package/dist/916.js +0 -1
  293. package/dist/998.js +0 -1
  294. package/dist/998.js.map +0 -1
  295. package/jest.config.js +0 -8
  296. package/src/components/facility-setup/card.component.tsx +0 -16
@@ -1,4 +1,4 @@
1
- import React, { useMemo, useState, useEffect } from 'react';
1
+ import React, { useMemo, useState } from 'react';
2
2
  import { useTranslation } from 'react-i18next';
3
3
  import {
4
4
  Button,
@@ -18,7 +18,7 @@ import {
18
18
  Tag,
19
19
  } from '@carbon/react';
20
20
  import { Add } from '@carbon/react/icons';
21
- import { WorkspaceContainer, isDesktop as desktopLayout, launchWorkspace, useLayoutType } from '@openmrs/esm-framework';
21
+ import { launchWorkspace2, useLayoutType } from '@openmrs/esm-framework';
22
22
  import styles from './locations-table.scss';
23
23
  import { CardHeader } from '@openmrs/esm-patient-common-lib';
24
24
  import { useFacilitiesTagged } from './locations-table.resource';
@@ -28,23 +28,26 @@ const LocationsTable: React.FC = () => {
28
28
  const { t } = useTranslation();
29
29
  const layout = useLayoutType();
30
30
  const isTablet = layout === 'tablet';
31
- const isDesktop = desktopLayout(layout);
32
31
  const [pageSize, setPageSize] = useState(10);
33
32
  const [searchTerm, setSearchTerm] = useState('');
34
33
  const [currentPage, setCurrentPage] = useState(1);
35
34
 
36
- const { locationTagList, isLoading: tagsLoading, error: tagsError } = useLocationTags();
35
+ const { locationTagList, isLoading: tagsLoading } = useLocationTags();
37
36
  const { facilityList, isLoading: taggedLoading } = useFacilitiesTagged({ results: locationTagList });
38
37
 
39
38
  const handleAddLocationWorkspace = () => {
40
- launchWorkspace('add-location-workspace', {
41
- workspaceTitle: t('addLocation', 'Add Location'),
39
+ launchWorkspace2('add-location-workspace', {
40
+ workspaceProps: {
41
+ workspaceTitle: t('addLocation', 'Add Location'),
42
+ },
42
43
  });
43
44
  };
44
45
 
45
46
  const handleSearchLocationWorkspace = () => {
46
- launchWorkspace('search-location-workspace', {
47
- workspaceTitle: t('tagLocation', 'Tag Location'),
47
+ launchWorkspace2('search-location-workspace', {
48
+ workspaceProps: {
49
+ workspaceTitle: t('tagLocation', 'Tag Location'),
50
+ },
48
51
  });
49
52
  };
50
53
 
@@ -117,126 +120,119 @@ const LocationsTable: React.FC = () => {
117
120
 
118
121
  if (tagsLoading || (taggedLoading && !facilityList.length)) {
119
122
  return (
120
- <>
121
- <div className={styles.widgetCard}>
122
- <DataTableSkeleton role="progressbar" compact={isDesktop} zebra />
123
- </div>
124
- </>
123
+ <div className={styles.widgetCard}>
124
+ <DataTableSkeleton role="progressbar" zebra />
125
+ </div>
125
126
  );
126
127
  }
127
128
 
128
129
  return (
129
- <>
130
- <div className={styles.widgetCard}>
131
- <CardHeader title={t('locations', 'Locations')}>
132
- <span className={styles.backgroundDataFetchingIndicator}>
133
- <span>{tagsLoading ? <InlineLoading /> : null}</span>
134
- </span>
135
- <div className={styles.headerActions}>
136
- <>
137
- <div className={styles.filterContainer}>
138
- <Search
139
- onChange={(e) => {
140
- setSearchTerm(e.target.value);
141
- setCurrentPage(1);
142
- }}
143
- placeholder={t('search', 'Search location')}
144
- value={searchTerm}
145
- labelText={t('search', 'Search location')}
146
- />
147
- </div>
148
- <Button
149
- kind="ghost"
150
- renderIcon={(props) => <Add size={16} {...props} />}
151
- onClick={handleAddLocationWorkspace}>
152
- {t('addLocation', 'Add Location')}
153
- </Button>
154
- <Button
155
- kind="ghost"
156
- renderIcon={(props) => <Add size={16} {...props} />}
157
- onClick={handleSearchLocationWorkspace}>
158
- {t('tagLocation', 'Tag Location')}
159
- </Button>
160
- </>
130
+ <div className={styles.widgetCard}>
131
+ <CardHeader title={t('locations', 'Locations')}>
132
+ <span className={styles.backgroundDataFetchingIndicator}>
133
+ <span>{tagsLoading ? <InlineLoading /> : null}</span>
134
+ </span>
135
+ <div className={styles.headerActions}>
136
+ <div className={styles.filterContainer}>
137
+ <Search
138
+ onChange={(e) => {
139
+ setSearchTerm(e.target.value);
140
+ setCurrentPage(1);
141
+ }}
142
+ placeholder={t('search', 'Search location')}
143
+ value={searchTerm}
144
+ labelText={t('search', 'Search location')}
145
+ />
161
146
  </div>
162
- </CardHeader>
163
-
164
- <DataTable rows={paginatedRows} headers={tableHeaders} isSortable size={isTablet ? 'lg' : 'sm'} useZebraStyles>
165
- {({ rows, headers, getTableProps }) => {
166
- return (
167
- <TableContainer>
168
- <Table {...getTableProps()}>
169
- <TableHead>
170
- <TableRow>
171
- {headers.map((header) => (
172
- <TableHeader key={header.key}>{header.header}</TableHeader>
147
+ <Button
148
+ kind="ghost"
149
+ renderIcon={(props) => <Add size={16} {...props} />}
150
+ onClick={handleAddLocationWorkspace}>
151
+ {t('addLocation', 'Add Location')}
152
+ </Button>
153
+ <Button
154
+ kind="ghost"
155
+ renderIcon={(props) => <Add size={16} {...props} />}
156
+ onClick={handleSearchLocationWorkspace}>
157
+ {t('tagLocation', 'Tag Location')}
158
+ </Button>
159
+ </div>
160
+ </CardHeader>
161
+
162
+ <DataTable rows={paginatedRows} headers={tableHeaders} isSortable size={isTablet ? 'lg' : 'sm'} useZebraStyles>
163
+ {({ rows, headers, getTableProps }) => {
164
+ return (
165
+ <TableContainer>
166
+ <Table {...getTableProps()}>
167
+ <TableHead>
168
+ <TableRow>
169
+ {headers.map((header) => (
170
+ <TableHeader key={header.key}>{header.header}</TableHeader>
171
+ ))}
172
+ </TableRow>
173
+ </TableHead>
174
+ <TableBody>
175
+ {rows.map((row) => (
176
+ <TableRow key={row.id}>
177
+ {row.cells.map((cell) => (
178
+ <TableCell key={cell.id}>
179
+ {cell.id.includes('tags') && cell.value !== 'No tags' ? (
180
+ <div style={{ display: 'flex', flexWrap: 'wrap', gap: '4px' }}>
181
+ {cell.value.split(', ').map((tag, index) => (
182
+ <Tag key={index} type="blue" size="sm">
183
+ {tag}
184
+ </Tag>
185
+ ))}
186
+ </div>
187
+ ) : (
188
+ cell.value
189
+ )}
190
+ </TableCell>
173
191
  ))}
174
192
  </TableRow>
175
- </TableHead>
176
- <TableBody>
177
- {rows.map((row) => (
178
- <TableRow key={row.id}>
179
- {row.cells.map((cell) => (
180
- <TableCell key={cell.id}>
181
- {cell.id.includes('tags') && cell.value !== 'No tags' ? (
182
- <div style={{ display: 'flex', flexWrap: 'wrap', gap: '4px' }}>
183
- {cell.value.split(', ').map((tag, index) => (
184
- <Tag key={index} type="blue" size="sm">
185
- {tag}
186
- </Tag>
187
- ))}
188
- </div>
189
- ) : (
190
- cell.value
191
- )}
192
- </TableCell>
193
- ))}
194
- </TableRow>
195
- ))}
196
- </TableBody>
197
- </Table>
198
- {rows.length === 0 ? (
199
- <div className={styles.tileContainer}>
200
- <Tile className={styles.tile}>
201
- <div className={styles.tileContent}>
202
- <p className={styles.content}>
203
- {searchTerm
204
- ? t('noSearchResults', `No results found for "${searchTerm}"`)
205
- : t('noData', 'No data to display')}
206
- </p>
207
- <p className={styles.helper}>
208
- {searchTerm
209
- ? t('tryDifferentSearch', 'Try a different search term')
210
- : t('checkFilters', 'Check the filters above')}
211
- </p>
212
- </div>
213
- </Tile>
214
- </div>
215
- ) : null}
216
- <Pagination
217
- backwardText="Previous page"
218
- forwardText="Next page"
219
- page={currentPage}
220
- pageSize={pageSize}
221
- pageSizes={[10, 20, 30, 40, 50]}
222
- totalItems={filteredRows.length}
223
- onChange={({ pageSize: newPageSize, page }) => {
224
- if (newPageSize !== pageSize) {
225
- setPageSize(newPageSize);
226
- setCurrentPage(1);
227
- }
228
- if (page !== currentPage) {
229
- setCurrentPage(page);
230
- }
231
- }}
232
- />
233
- </TableContainer>
234
- );
235
- }}
236
- </DataTable>
237
- </div>
238
- <WorkspaceContainer contextKey="locations" />
239
- </>
193
+ ))}
194
+ </TableBody>
195
+ </Table>
196
+ {rows.length === 0 ? (
197
+ <div className={styles.tileContainer}>
198
+ <Tile className={styles.tile}>
199
+ <div className={styles.tileContent}>
200
+ <p className={styles.content}>
201
+ {searchTerm
202
+ ? t('noSearchResults', `No results found for "${searchTerm}"`)
203
+ : t('noData', 'No data to display')}
204
+ </p>
205
+ <p className={styles.helper}>
206
+ {searchTerm
207
+ ? t('tryDifferentSearch', 'Try a different search term')
208
+ : t('checkFilters', 'Check the filters above')}
209
+ </p>
210
+ </div>
211
+ </Tile>
212
+ </div>
213
+ ) : null}
214
+ <Pagination
215
+ backwardText="Previous page"
216
+ forwardText="Next page"
217
+ page={currentPage}
218
+ pageSize={pageSize}
219
+ pageSizes={[10, 20, 30, 40, 50]}
220
+ totalItems={filteredRows.length}
221
+ onChange={({ pageSize: newPageSize, page }) => {
222
+ if (newPageSize !== pageSize) {
223
+ setPageSize(newPageSize);
224
+ setCurrentPage(1);
225
+ }
226
+ if (page !== currentPage) {
227
+ setCurrentPage(page);
228
+ }
229
+ }}
230
+ />
231
+ </TableContainer>
232
+ );
233
+ }}
234
+ </DataTable>
235
+ </div>
240
236
  );
241
237
  };
242
238
 
@@ -6,6 +6,8 @@ import {
6
6
  restBaseUrl,
7
7
  showSnackbar,
8
8
  useLayoutType,
9
+ Workspace2,
10
+ Workspace2DefinitionProps,
9
11
  } from '@openmrs/esm-framework';
10
12
  import { FormProvider, useFieldArray, useForm } from 'react-hook-form';
11
13
  import styles from '../../../manage-users/user-management.workspace.scss';
@@ -29,24 +31,22 @@ import { useSystemUserRoleConfigSetting } from '../../../../hook/useSystemRoleSe
29
31
  import UserRoleScopeFormFields from './user-role-scope-fields.component';
30
32
  import StockUserRoleScopesList from '../user-role-scope-list/user-role-scope-list.component';
31
33
 
32
- type UserRoleScopeWorkspaceProps = DefaultWorkspaceProps & {
34
+ type UserRoleScopeWorkspaceProps = {
33
35
  user?: User;
34
36
  };
35
37
 
36
- const UserRoleScopeWorkspace: React.FC<UserRoleScopeWorkspaceProps> = ({
38
+ const UserRoleScopeWorkspace: React.FC<Workspace2DefinitionProps<UserRoleScopeWorkspaceProps, {}, {}>> = ({
37
39
  closeWorkspace,
38
- promptBeforeClosing,
39
- closeWorkspaceWithSavedChanges,
40
- user = {} as User,
40
+ workspaceProps: { user = {} as User },
41
41
  }) => {
42
42
  const { t } = useTranslation();
43
43
  const isTablet = useLayoutType() === 'tablet';
44
44
  const { userRoleScopeFormSchema } = UserRoleScopeFormSchema();
45
45
  const { stockOperations, loadingStock } = useStockOperationTypes();
46
- const { stockLocations } = useStockTagLocations();
46
+ const { stockLocations, isLoading: loadinglocation } = useStockTagLocations();
47
47
  const { rolesConfig, error } = useSystemUserRoleConfigSetting();
48
48
  const { items, loadingRoleScope } = useUserRoleScopes();
49
-
49
+ const [hasUnsavedChanges, setHasUnsavedChanges] = useState(false);
50
50
  const [userRoleScopeInitialValues, setUserRoleScopeInitialValues] = useState<UserRoleScope | null>(null);
51
51
  const handleEditUserRoleScope = useCallback((userRoleScope: UserRoleScope) => {
52
52
  setUserRoleScopeInitialValues(userRoleScope);
@@ -93,9 +93,9 @@ const UserRoleScopeWorkspace: React.FC<UserRoleScopeWorkspaceProps> = ({
93
93
  const { errors, isSubmitting, isDirty } = roleScopeformMethods.formState;
94
94
  useEffect(() => {
95
95
  if (isDirty) {
96
- promptBeforeClosing(() => isDirty);
96
+ setHasUnsavedChanges(true);
97
97
  }
98
- }, [isDirty, promptBeforeClosing]);
98
+ }, [isDirty, setHasUnsavedChanges]);
99
99
 
100
100
  useEffect(() => {
101
101
  if (userRoleScopeInitialValues && !loadingStock) {
@@ -154,7 +154,7 @@ const UserRoleScopeWorkspace: React.FC<UserRoleScopeWorkspaceProps> = ({
154
154
  const response = await createOrUpdateUserRoleScope(userRoleScopeUrl, roleScope, user?.uuid ?? '');
155
155
  if (response.ok) {
156
156
  showNotification('userRoleScopeSaved', 'User role scope saved successfully', 'success');
157
- closeWorkspaceWithSavedChanges();
157
+ closeWorkspace({ discardUnsavedChanges: true });
158
158
  }
159
159
  }),
160
160
  );
@@ -184,9 +184,9 @@ const UserRoleScopeWorkspace: React.FC<UserRoleScopeWorkspaceProps> = ({
184
184
 
185
185
  useEffect(() => {
186
186
  if (isDirty) {
187
- promptBeforeClosing(() => isDirty);
187
+ setHasUnsavedChanges(true);
188
188
  }
189
- }, [isDirty, promptBeforeClosing]);
189
+ }, [isDirty, setHasUnsavedChanges]);
190
190
 
191
191
  function extractInventoryRoleNames(rolesConfig) {
192
192
  return rolesConfig.find((category) => category.category === ROLE_CATEGORIES.CORE_INVENTORY)?.roles || [];
@@ -225,7 +225,7 @@ const UserRoleScopeWorkspace: React.FC<UserRoleScopeWorkspaceProps> = ({
225
225
  );
226
226
 
227
227
  return (
228
- <>
228
+ <Workspace2 title={t('userRoleScopeWorkspace', 'User Role Scope Workspace')} hasUnsavedChanges={hasUnsavedChanges}>
229
229
  <div>
230
230
  <StockUserRoleScopesList onEditUserRoleScope={handleEditUserRoleScope} user={user} />
231
231
  </div>
@@ -266,7 +266,7 @@ const UserRoleScopeWorkspace: React.FC<UserRoleScopeWorkspaceProps> = ({
266
266
  hasInventoryRole={hasInventoryRole}
267
267
  stockOperations={stockOperations}
268
268
  stockLocations={stockLocations}
269
- loadingStock={loadingStock}
269
+ loadingStock={loadingStock || loadinglocation}
270
270
  roleScopeformMethods={roleScopeformMethods}
271
271
  userRoleScopeInitialValues={userRoleScopeInitialValues}
272
272
  />
@@ -309,7 +309,7 @@ const UserRoleScopeWorkspace: React.FC<UserRoleScopeWorkspaceProps> = ({
309
309
  </form>
310
310
  </FormProvider>
311
311
  )}
312
- </>
312
+ </Workspace2>
313
313
  );
314
314
  };
315
315
 
@@ -29,6 +29,7 @@ import {
29
29
  isDesktop,
30
30
  usePagination,
31
31
  showModal,
32
+ launchWorkspace2,
32
33
  } from '@openmrs/esm-framework';
33
34
  import { CardHeader, usePaginationInfo } from '@openmrs/esm-patient-common-lib';
34
35
  import capitalize from 'lodash-es/capitalize';
@@ -261,10 +262,15 @@ const UserList: React.FC = () => {
261
262
  onClick={() => {
262
263
  const selectedUser = users.find((u) => u.uuid === user.uuid);
263
264
  if (selectedUser) {
264
- launchWorkspace('manage-user-workspace', {
265
- workspaceTitle: t('editUser', 'Edit User'),
266
- initialUserValue: user,
267
- });
265
+ launchWorkspace2(
266
+ 'manage-user-workspace',
267
+ {
268
+ workspaceTitle: t('editUser', 'Edit User'),
269
+ initialUserValue: user,
270
+ },
271
+ {},
272
+ {},
273
+ );
268
274
  } else {
269
275
  console.error('User not found:', user.uuid);
270
276
  }
@@ -280,10 +286,15 @@ const UserList: React.FC = () => {
280
286
  hasDivider
281
287
  disabled={!userHasInventoryRole}
282
288
  onClick={() => {
283
- launchWorkspace('user-role-scope-workspace', {
284
- workspaceTitle: t('manageUserRoleScope', 'Manage user role scope'),
285
- user: user,
286
- });
289
+ launchWorkspace2(
290
+ 'user-role-scope-workspace',
291
+ {
292
+ workspaceTitle: t('manageUserRoleScope', 'Manage user role scope'),
293
+ user: user,
294
+ },
295
+ {},
296
+ {},
297
+ );
287
298
  }}
288
299
  itemText={t('manageUserRoleScope', 'Manage user role scope')}
289
300
  />
@@ -317,7 +328,9 @@ const UserList: React.FC = () => {
317
328
  size={isDesktop(layout) ? 'lg' : 'sm'}
318
329
  />
319
330
  <Button
320
- onClick={() => launchWorkspace('manage-user-workspace', { workspaceTitle: t('addUser', 'Add user') })}
331
+ onClick={() =>
332
+ launchWorkspace2('manage-user-workspace', { workspaceTitle: t('addUser', 'Add user') }, {}, {})
333
+ }
321
334
  className={styles.userManagementModeButton}
322
335
  renderIcon={UserFollow}
323
336
  size={isDesktop(layout) ? 'lg' : 'sm'}