@kenyaemr/esm-admin-app 5.4.4-pre.5 → 5.4.4-pre.501

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 (406) hide show
  1. package/.turbo/turbo-build.log +5 -12
  2. package/dist/1102.js +1 -0
  3. package/dist/1102.js.map +1 -0
  4. package/dist/1278.js +1 -0
  5. package/dist/1278.js.map +1 -0
  6. package/dist/1442.js +1 -0
  7. package/dist/1442.js.map +1 -0
  8. package/dist/15.js +1 -0
  9. package/dist/15.js.map +1 -0
  10. package/dist/162.js +1 -0
  11. package/dist/162.js.map +1 -0
  12. package/dist/1620.js +1 -0
  13. package/dist/1620.js.map +1 -0
  14. package/dist/1789.js +1 -0
  15. package/dist/1789.js.map +1 -0
  16. package/dist/1831.js +1 -0
  17. package/dist/1831.js.map +1 -0
  18. package/dist/1844.js +1 -0
  19. package/dist/1844.js.map +1 -0
  20. package/dist/1854.js +1 -0
  21. package/dist/1854.js.map +1 -0
  22. package/dist/1919.js +1 -0
  23. package/dist/1919.js.map +1 -0
  24. package/dist/193.js +1 -0
  25. package/dist/193.js.map +1 -0
  26. package/dist/1946.js +1 -0
  27. package/dist/1946.js.map +1 -0
  28. package/dist/2007.js +1 -0
  29. package/dist/2007.js.map +1 -0
  30. package/dist/2043.js +1 -0
  31. package/dist/2043.js.map +1 -0
  32. package/dist/2127.js +1 -0
  33. package/dist/2127.js.map +1 -0
  34. package/dist/2146.js +1 -0
  35. package/dist/2146.js.map +1 -0
  36. package/dist/2152.js +1 -0
  37. package/dist/2152.js.map +1 -0
  38. package/dist/2202.js +1 -0
  39. package/dist/2202.js.map +1 -0
  40. package/dist/2258.js +1 -0
  41. package/dist/2258.js.map +1 -0
  42. package/dist/2394.js +1 -0
  43. package/dist/2394.js.map +1 -0
  44. package/dist/2468.js +1 -0
  45. package/dist/2468.js.map +1 -0
  46. package/dist/2534.js +1 -0
  47. package/dist/2534.js.map +1 -0
  48. package/dist/2556.js +1 -0
  49. package/dist/2556.js.map +1 -0
  50. package/dist/26.js +1 -0
  51. package/dist/26.js.map +1 -0
  52. package/dist/2638.js +1 -0
  53. package/dist/2638.js.map +1 -0
  54. package/dist/2648.js +1 -0
  55. package/dist/2648.js.map +1 -0
  56. package/dist/2709.js +1 -0
  57. package/dist/2709.js.map +1 -0
  58. package/dist/2823.js +1 -0
  59. package/dist/2823.js.map +1 -0
  60. package/dist/2840.js +1 -0
  61. package/dist/2840.js.map +1 -0
  62. package/dist/2842.js +1 -0
  63. package/dist/2842.js.map +1 -0
  64. package/dist/2916.js +1 -0
  65. package/dist/2916.js.map +1 -0
  66. package/dist/2924.js +1 -0
  67. package/dist/2924.js.map +1 -0
  68. package/dist/3137.js +1 -0
  69. package/dist/3137.js.map +1 -0
  70. package/dist/3248.js +1 -0
  71. package/dist/3248.js.map +1 -0
  72. package/dist/3282.js +1 -0
  73. package/dist/3282.js.map +1 -0
  74. package/dist/3285.js +1 -0
  75. package/dist/3285.js.map +1 -0
  76. package/dist/3302.js +1 -0
  77. package/dist/3302.js.map +1 -0
  78. package/dist/3335.js +1 -0
  79. package/dist/3335.js.map +1 -0
  80. package/dist/3378.js +1 -0
  81. package/dist/3378.js.map +1 -0
  82. package/dist/3504.js +1 -0
  83. package/dist/3504.js.map +1 -0
  84. package/dist/356.js +1 -0
  85. package/dist/356.js.map +1 -0
  86. package/dist/3569.js +1 -0
  87. package/dist/3569.js.map +1 -0
  88. package/dist/3580.js +1 -0
  89. package/dist/3580.js.map +1 -0
  90. package/dist/3690.js +1 -0
  91. package/dist/3690.js.map +1 -0
  92. package/dist/3723.js +1 -0
  93. package/dist/3723.js.map +1 -0
  94. package/dist/3745.js +1 -0
  95. package/dist/3745.js.map +1 -0
  96. package/dist/3796.js +1 -0
  97. package/dist/3796.js.map +1 -0
  98. package/dist/3813.js +1 -0
  99. package/dist/3813.js.map +1 -0
  100. package/dist/393.js +6 -0
  101. package/dist/393.js.map +1 -0
  102. package/dist/3953.js +1 -0
  103. package/dist/3953.js.map +1 -0
  104. package/dist/3989.js +1 -0
  105. package/dist/3989.js.map +1 -0
  106. package/dist/4124.js +1 -0
  107. package/dist/4124.js.map +1 -0
  108. package/dist/4163.js +1 -0
  109. package/dist/4163.js.map +1 -0
  110. package/dist/4178.js +1 -0
  111. package/dist/4178.js.map +1 -0
  112. package/dist/4308.js +1 -0
  113. package/dist/4308.js.map +1 -0
  114. package/dist/4487.js +11 -0
  115. package/dist/4487.js.map +1 -0
  116. package/dist/4588.js +1 -0
  117. package/dist/4588.js.map +1 -0
  118. package/dist/4637.js +1 -0
  119. package/dist/4637.js.map +1 -0
  120. package/dist/466.js +1 -1
  121. package/dist/466.js.map +1 -1
  122. package/dist/4711.js +1 -0
  123. package/dist/4711.js.map +1 -0
  124. package/dist/4759.js +1 -0
  125. package/dist/4759.js.map +1 -0
  126. package/dist/4817.js +1 -0
  127. package/dist/4817.js.map +1 -0
  128. package/dist/4818.js +1 -0
  129. package/dist/4818.js.map +1 -0
  130. package/dist/4902.js +1 -0
  131. package/dist/4902.js.map +1 -0
  132. package/dist/4973.js +1 -0
  133. package/dist/4973.js.map +1 -0
  134. package/dist/500.js +1 -0
  135. package/dist/500.js.map +1 -0
  136. package/dist/5086.js +1 -0
  137. package/dist/5086.js.map +1 -0
  138. package/dist/5117.js +1 -0
  139. package/dist/5117.js.map +1 -0
  140. package/dist/5203.js +1 -0
  141. package/dist/5203.js.map +1 -0
  142. package/dist/5361.js +1 -0
  143. package/dist/5361.js.map +1 -0
  144. package/dist/5362.js +1 -0
  145. package/dist/5362.js.map +1 -0
  146. package/dist/5366.js +1 -0
  147. package/dist/5366.js.map +1 -0
  148. package/dist/5536.js +1 -0
  149. package/dist/5536.js.map +1 -0
  150. package/dist/5567.js +1 -0
  151. package/dist/5567.js.map +1 -0
  152. package/dist/5598.js +1 -0
  153. package/dist/5598.js.map +1 -0
  154. package/dist/5676.js +1 -0
  155. package/dist/5676.js.map +1 -0
  156. package/dist/5693.js +1 -0
  157. package/dist/5693.js.map +1 -0
  158. package/dist/5731.js +5 -0
  159. package/dist/5731.js.map +1 -0
  160. package/dist/5767.js +1 -0
  161. package/dist/5767.js.map +1 -0
  162. package/dist/5809.js +1 -0
  163. package/dist/5809.js.map +1 -0
  164. package/dist/5825.js +1 -0
  165. package/dist/5825.js.map +1 -0
  166. package/dist/5932.js +1 -0
  167. package/dist/5932.js.map +1 -0
  168. package/dist/5941.js +1 -0
  169. package/dist/5941.js.map +1 -0
  170. package/dist/6104.js +1 -0
  171. package/dist/6104.js.map +1 -0
  172. package/dist/6273.js +1 -0
  173. package/dist/6273.js.map +1 -0
  174. package/dist/6337.js +1 -0
  175. package/dist/6337.js.map +1 -0
  176. package/dist/6355.js +1 -0
  177. package/dist/6355.js.map +1 -0
  178. package/dist/6357.js +1 -0
  179. package/dist/6357.js.map +1 -0
  180. package/dist/6427.js +1 -0
  181. package/dist/6427.js.map +1 -0
  182. package/dist/6478.js +7 -0
  183. package/dist/6478.js.map +1 -0
  184. package/dist/6508.js +1 -0
  185. package/dist/6508.js.map +1 -0
  186. package/dist/6567.js +1 -0
  187. package/dist/6567.js.map +1 -0
  188. package/dist/6634.js +1 -0
  189. package/dist/6634.js.map +1 -0
  190. package/dist/6698.js +1 -0
  191. package/dist/6698.js.map +1 -0
  192. package/dist/682.js +1 -0
  193. package/dist/682.js.map +1 -0
  194. package/dist/6848.js +1 -0
  195. package/dist/6848.js.map +1 -0
  196. package/dist/689.js +1 -1
  197. package/dist/689.js.map +1 -1
  198. package/dist/6978.js +1 -0
  199. package/dist/6978.js.map +1 -0
  200. package/dist/7085.js +1 -0
  201. package/dist/7085.js.map +1 -0
  202. package/dist/7187.js +1 -0
  203. package/dist/7187.js.map +1 -0
  204. package/dist/7209.js +1 -0
  205. package/dist/7209.js.map +1 -0
  206. package/dist/740.js +1 -0
  207. package/dist/740.js.map +1 -0
  208. package/dist/7419.js +1 -0
  209. package/dist/7419.js.map +1 -0
  210. package/dist/7478.js +1 -0
  211. package/dist/7478.js.map +1 -0
  212. package/dist/7686.js +1 -0
  213. package/dist/7686.js.map +1 -0
  214. package/dist/770.js +1 -0
  215. package/dist/770.js.map +1 -0
  216. package/dist/7782.js +1 -0
  217. package/dist/7782.js.map +1 -0
  218. package/dist/7783.js +1 -0
  219. package/dist/7783.js.map +1 -0
  220. package/dist/7808.js +1 -0
  221. package/dist/7808.js.map +1 -0
  222. package/dist/781.js +1 -0
  223. package/dist/781.js.map +1 -0
  224. package/dist/8183.js +1 -0
  225. package/dist/8183.js.map +1 -0
  226. package/dist/8196.js +1 -0
  227. package/dist/8196.js.map +1 -0
  228. package/dist/820.js +1 -0
  229. package/dist/820.js.map +1 -0
  230. package/dist/8240.js +1 -0
  231. package/dist/8240.js.map +1 -0
  232. package/dist/8267.js +1 -0
  233. package/dist/8267.js.map +1 -0
  234. package/dist/8472.js +1 -0
  235. package/dist/8472.js.map +1 -0
  236. package/dist/8521.js +1 -0
  237. package/dist/8521.js.map +1 -0
  238. package/dist/8602.js +1 -0
  239. package/dist/8602.js.map +1 -0
  240. package/dist/8607.js +1 -0
  241. package/dist/8607.js.map +1 -0
  242. package/dist/8743.js +1 -0
  243. package/dist/8743.js.map +1 -0
  244. package/dist/8762.js +1 -0
  245. package/dist/8762.js.map +1 -0
  246. package/dist/8781.js +1 -0
  247. package/dist/8781.js.map +1 -0
  248. package/dist/8812.js +1 -0
  249. package/dist/8812.js.map +1 -0
  250. package/dist/8952.js +1 -0
  251. package/dist/8952.js.map +1 -0
  252. package/dist/8985.js +1 -0
  253. package/dist/8985.js.map +1 -0
  254. package/dist/8996.js +1 -0
  255. package/dist/8996.js.map +1 -0
  256. package/dist/9011.js +1 -0
  257. package/dist/9011.js.map +1 -0
  258. package/dist/9049.js +1 -0
  259. package/dist/9049.js.map +1 -0
  260. package/dist/9050.js +1 -0
  261. package/dist/9050.js.map +1 -0
  262. package/dist/9061.js +1 -0
  263. package/dist/9061.js.map +1 -0
  264. package/dist/9087.js +1 -0
  265. package/dist/9087.js.map +1 -0
  266. package/dist/9148.js +1 -0
  267. package/dist/9148.js.map +1 -0
  268. package/dist/9168.js +1 -0
  269. package/dist/9168.js.map +1 -0
  270. package/dist/935.js +1 -0
  271. package/dist/935.js.map +1 -0
  272. package/dist/9425.js +1 -0
  273. package/dist/944.js +1 -0
  274. package/dist/944.js.map +1 -0
  275. package/dist/9443.js +1 -0
  276. package/dist/9443.js.map +1 -0
  277. package/dist/9520.js +1 -0
  278. package/dist/9520.js.map +1 -0
  279. package/dist/9547.js +1 -0
  280. package/dist/9547.js.map +1 -0
  281. package/dist/9549.js +1 -0
  282. package/dist/9549.js.map +1 -0
  283. package/dist/9603.js +1 -0
  284. package/dist/9603.js.map +1 -0
  285. package/dist/9612.js +1 -0
  286. package/dist/9612.js.map +1 -0
  287. package/dist/9621.js +1 -0
  288. package/dist/9621.js.map +1 -0
  289. package/dist/9662.js +1 -0
  290. package/dist/9662.js.map +1 -0
  291. package/dist/9771.js +1 -0
  292. package/dist/9771.js.map +1 -0
  293. package/dist/9774.js +1 -0
  294. package/dist/9774.js.map +1 -0
  295. package/dist/9800.js +1 -0
  296. package/dist/9800.js.map +1 -0
  297. package/dist/9806.js +1 -0
  298. package/dist/9806.js.map +1 -0
  299. package/dist/992.js +1 -0
  300. package/dist/992.js.map +1 -0
  301. package/dist/kenyaemr-esm-admin-app.js +6 -5
  302. package/dist/kenyaemr-esm-admin-app.js.buildmanifest.json +3594 -151
  303. package/dist/kenyaemr-esm-admin-app.js.map +1 -1
  304. package/dist/main.js +6 -31
  305. package/dist/main.js.map +1 -1
  306. package/dist/routes.json +1 -1
  307. package/package.json +5 -7
  308. package/rspack.config.js +1 -1
  309. package/src/components/confirm-modal/confirmation-operation.test.tsx +8 -19
  310. package/src/components/dashboard/dashboard.component.tsx +4 -1
  311. package/src/components/empty-state/empty-state-log.test.tsx +3 -4
  312. package/src/components/facility-setup/constant/index.ts +3 -0
  313. package/src/components/facility-setup/facility-info.component.tsx +247 -108
  314. package/src/components/facility-setup/facility-info.scss +136 -55
  315. package/src/components/facility-setup/facility-setup.component.tsx +2 -2
  316. package/src/components/facility-setup/header/header.component.tsx +4 -10
  317. package/src/components/facility-setup/header/header.scss +3 -9
  318. package/src/components/facility-setup/shared/custom-info.component.tsx +9 -0
  319. package/src/components/facility-setup/shared/custom-section-card.component.tsx +10 -0
  320. package/src/components/facility-setup/shared/custom-status-tag.component.tsx +22 -0
  321. package/src/components/facility-setup/type/index.ts +61 -0
  322. package/src/components/facility-setup/useFacilityRegistry.ts +29 -0
  323. package/src/components/global-property/dashboard/global-property-dashboard.component.tsx +23 -0
  324. package/src/components/global-property/dashboard/global-property-dashboard.scss +6 -0
  325. package/src/components/global-property/hooks/useGlobalProperty.ts +64 -0
  326. package/src/components/global-property/hooks/useLogoUpload.ts +28 -0
  327. package/src/components/global-property/index.ts +14 -0
  328. package/src/components/global-property/modal/delete-global-property-modal.component.tsx +71 -0
  329. package/src/components/global-property/modal/delete-global-property-modal.test.tsx +131 -0
  330. package/src/components/global-property/table/global-property-table.component.tsx +241 -0
  331. package/src/components/global-property/table/global-property-table.scss +44 -0
  332. package/src/components/global-property/table/global-property-table.test.tsx +202 -0
  333. package/src/components/global-property/workspace/global-property-form-schema.ts +32 -0
  334. package/src/components/global-property/workspace/global-property.workspace.scss +40 -0
  335. package/src/components/global-property/workspace/global-property.workspace.test.tsx +172 -0
  336. package/src/components/global-property/workspace/global-property.workspace.tsx +260 -0
  337. package/src/components/global-property/workspace/upload-logo.workspace.scss +61 -0
  338. package/src/components/global-property/workspace/upload-logo.workspace.test.tsx +180 -0
  339. package/src/components/global-property/workspace/upload-logo.workspace.tsx +191 -0
  340. package/src/components/hook/healthWorkerRegistry.ts +78 -0
  341. package/src/components/hook/useProfessionalRegistryEnums.ts +59 -0
  342. package/src/components/locations/forms/add-location/add-location.workspace.tsx +96 -95
  343. package/src/components/locations/forms/search-location/search-location.workspace.tsx +90 -85
  344. package/src/components/locations/tables/locations-table.component.tsx +117 -121
  345. package/src/components/logs-table/operation-log-table.component.tsx +87 -75
  346. package/src/components/logs-table/operation-log.test.tsx +134 -28
  347. package/src/components/modal/hwr-confirmation.modal.scss +80 -4
  348. package/src/components/modal/hwr-confirmation.modal.tsx +118 -128
  349. package/src/components/modal/hwr-sync.modal.tsx +194 -106
  350. package/src/components/users/manage-users/manage-user-role-scope/user-role-scope-workspace/user-role-scope.workspace.tsx +14 -14
  351. package/src/components/users/manage-users/user-details/user-detail.scss +167 -39
  352. package/src/components/users/manage-users/user-details/user-details.component.tsx +130 -122
  353. package/src/components/users/manage-users/user-list/user-list.component.tsx +22 -9
  354. package/src/components/users/manage-users/user-management.workspace.scss +233 -95
  355. package/src/components/users/manage-users/user-management.workspace.tsx +800 -687
  356. package/src/components/users/userManagementFormSchema.tsx +17 -8
  357. package/src/config-schema.ts +48 -68
  358. package/src/index.ts +68 -31
  359. package/src/left-pannel-link.component.tsx +5 -3
  360. package/src/root.component.tsx +13 -13
  361. package/src/routes.json +60 -36
  362. package/src/types/index.ts +40 -3
  363. package/translations/am.json +213 -13
  364. package/translations/en.json +225 -25
  365. package/translations/fr.json +260 -58
  366. package/translations/sw.json +329 -129
  367. package/tsconfig.json +1 -1
  368. package/dist/127.js +0 -1
  369. package/dist/267.js +0 -1
  370. package/dist/267.js.map +0 -1
  371. package/dist/281.js +0 -15
  372. package/dist/281.js.map +0 -1
  373. package/dist/329.js +0 -1
  374. package/dist/329.js.map +0 -1
  375. package/dist/40.js +0 -1
  376. package/dist/472.js +0 -1
  377. package/dist/472.js.map +0 -1
  378. package/dist/478.js +0 -1
  379. package/dist/478.js.map +0 -1
  380. package/dist/585.js +0 -1
  381. package/dist/585.js.map +0 -1
  382. package/dist/630.js +0 -1
  383. package/dist/630.js.map +0 -1
  384. package/dist/675.js +0 -1
  385. package/dist/675.js.map +0 -1
  386. package/dist/706.js +0 -27
  387. package/dist/706.js.map +0 -1
  388. package/dist/729.js +0 -17
  389. package/dist/729.js.map +0 -1
  390. package/dist/774.js +0 -1
  391. package/dist/774.js.map +0 -1
  392. package/dist/847.js +0 -1
  393. package/dist/847.js.map +0 -1
  394. package/dist/85.js +0 -1
  395. package/dist/85.js.map +0 -1
  396. package/dist/882.js +0 -1
  397. package/dist/91.js +0 -1
  398. package/dist/91.js.map +0 -1
  399. package/dist/916.js +0 -1
  400. package/dist/998.js +0 -1
  401. package/dist/998.js.map +0 -1
  402. package/jest.config.js +0 -8
  403. package/src/components/facility-setup/card.component.tsx +0 -16
  404. package/src/components/facility-setup/facility-setup.resource.tsx +0 -7
  405. package/src/components/hook/healthWorkerAdapter.ts +0 -213
  406. package/src/components/hook/useFacilityInfo.tsx +0 -37
@@ -0,0 +1,191 @@
1
+ import React, { useEffect, useState } from 'react';
2
+ import { showSnackbar, useLayoutType, Workspace2, type Workspace2DefinitionProps } from '@openmrs/esm-framework';
3
+ import {
4
+ Button,
5
+ ButtonSet,
6
+ FileUploader,
7
+ Form,
8
+ FormGroup,
9
+ InlineLoading,
10
+ InlineNotification,
11
+ RadioButton,
12
+ RadioButtonGroup,
13
+ Stack,
14
+ } from '@carbon/react';
15
+ import { useTranslation } from 'react-i18next';
16
+ import classNames from 'classnames';
17
+
18
+ import styles from './upload-logo.workspace.scss';
19
+ import { ALLOWED_LOGO_TYPES, MAX_LOGO_SIZE_BYTES, type LogoTarget, uploadLogo } from '../hooks/useLogoUpload';
20
+
21
+ type UploadLogoWorkspaceProps = {
22
+ mutateGlobalProperty?: () => void;
23
+ };
24
+
25
+ const UploadLogoWorkspace: React.FC<Workspace2DefinitionProps<UploadLogoWorkspaceProps, {}, {}>> = ({
26
+ closeWorkspace,
27
+ workspaceProps,
28
+ }) => {
29
+ const { t } = useTranslation();
30
+ const isTablet = useLayoutType() === 'tablet';
31
+ const mutateGlobalProperty = workspaceProps?.mutateGlobalProperty;
32
+
33
+ const [target, setTarget] = useState<LogoTarget>('prescription');
34
+ const [file, setFile] = useState<File | null>(null);
35
+ const [previewUrl, setPreviewUrl] = useState<string | null>(null);
36
+ const [validationError, setValidationError] = useState<string | null>(null);
37
+ const [isSubmitting, setIsSubmitting] = useState(false);
38
+
39
+ useEffect(() => {
40
+ if (!file) {
41
+ setPreviewUrl(null);
42
+ return;
43
+ }
44
+ const url = URL.createObjectURL(file);
45
+ setPreviewUrl(url);
46
+ return () => URL.revokeObjectURL(url);
47
+ }, [file]);
48
+
49
+ const handleFileChange = (selected: File | null) => {
50
+ setValidationError(null);
51
+ if (!selected) {
52
+ setFile(null);
53
+ return;
54
+ }
55
+ if (!ALLOWED_LOGO_TYPES.includes(selected.type)) {
56
+ setValidationError(t('unsupportedImageType', 'Unsupported file type. Accepted: JPEG, PNG, GIF, BMP or WebP.'));
57
+ setFile(null);
58
+ return;
59
+ }
60
+ if (selected.size > MAX_LOGO_SIZE_BYTES) {
61
+ setValidationError(t('imageTooLarge', 'File exceeds the 2 MB maximum size.'));
62
+ setFile(null);
63
+ return;
64
+ }
65
+ setFile(selected);
66
+ };
67
+
68
+ const onSubmit = async (event: React.FormEvent) => {
69
+ event.preventDefault();
70
+ if (!file) {
71
+ setValidationError(t('selectImageFirst', 'Please select an image to upload.'));
72
+ return;
73
+ }
74
+ setIsSubmitting(true);
75
+ try {
76
+ const { savedPath } = await uploadLogo(file, target);
77
+ const fileName = savedPath?.split(/[\\/]/).pop() ?? file.name;
78
+ showSnackbar({
79
+ title: t('success', 'Success'),
80
+ kind: 'success',
81
+ subtitle: t('logoUploaded', 'Image "{{fileName}}" uploaded successfully', { fileName }),
82
+ timeoutInMs: 5000,
83
+ });
84
+ mutateGlobalProperty?.();
85
+ closeWorkspace({ discardUnsavedChanges: true });
86
+ } catch (error: any) {
87
+ showSnackbar({
88
+ title: t('error', 'Error'),
89
+ kind: 'error',
90
+ subtitle: error?.message ?? t('logoUploadError', 'Error uploading image'),
91
+ });
92
+ } finally {
93
+ setIsSubmitting(false);
94
+ }
95
+ };
96
+
97
+ return (
98
+ <Workspace2 title={t('uploadImage', 'Upload image')} hasUnsavedChanges={Boolean(file)}>
99
+ <Form onSubmit={onSubmit} className={styles.form}>
100
+ <div className={styles.formContainer}>
101
+ <Stack gap={5}>
102
+ <InlineNotification
103
+ kind="info"
104
+ lowContrast
105
+ hideCloseButton
106
+ title={t('logoUploadTitle', 'Printed documents logo')}
107
+ subtitle={t(
108
+ 'logoUploadDesc',
109
+ 'Upload a logo used in printed documents. JPEG, PNG, GIF, BMP or WebP, up to 2 MB.',
110
+ )}
111
+ />
112
+
113
+ <FormGroup legendText={t('logoTarget', 'Logo destination')}>
114
+ <RadioButtonGroup
115
+ name="logo-target"
116
+ legendText=""
117
+ valueSelected={target}
118
+ onChange={(value: string) => setTarget(value as LogoTarget)}
119
+ disabled={isSubmitting}>
120
+ <RadioButton
121
+ labelText={t('prescriptionLogo', 'Prescription logo')}
122
+ value="prescription"
123
+ id="logo-target-prescription"
124
+ />
125
+ <RadioButton labelText={t('receiptLogo', 'Receipt logo')} value="receipt" id="logo-target-receipt" />
126
+ </RadioButtonGroup>
127
+ </FormGroup>
128
+
129
+ <FormGroup legendText={t('image', 'Image')}>
130
+ <FileUploader
131
+ labelTitle=""
132
+ labelDescription={t('logoUploaderHint', 'Max file size is 2 MB. Supported: JPEG, PNG, GIF, BMP, WebP.')}
133
+ buttonLabel={t('addFile', 'Add file')}
134
+ buttonKind="tertiary"
135
+ size="md"
136
+ filenameStatus="edit"
137
+ accept={ALLOWED_LOGO_TYPES}
138
+ multiple={false}
139
+ disabled={isSubmitting}
140
+ onChange={(e: { target: HTMLInputElement; addedFiles?: File[] }) => {
141
+ const selected = e.addedFiles?.[0] ?? e.target?.files?.[0] ?? null;
142
+ handleFileChange(selected);
143
+ }}
144
+ onDelete={() => handleFileChange(null)}
145
+ />
146
+ </FormGroup>
147
+
148
+ {validationError && (
149
+ <InlineNotification
150
+ kind="error"
151
+ lowContrast
152
+ hideCloseButton
153
+ title={t('invalidImage', 'Invalid image')}
154
+ subtitle={validationError}
155
+ />
156
+ )}
157
+
158
+ {previewUrl && (
159
+ <div className={styles.previewContainer}>
160
+ <span className={styles.previewLabel}>{t('preview', 'Preview')}</span>
161
+ <img src={previewUrl} alt={t('imagePreview', 'Image preview')} className={styles.preview} />
162
+ </div>
163
+ )}
164
+ </Stack>
165
+ </div>
166
+
167
+ <ButtonSet
168
+ className={classNames({
169
+ [styles.tablet]: isTablet,
170
+ [styles.desktop]: !isTablet,
171
+ })}>
172
+ <Button className={styles.buttonContainer} kind="secondary" onClick={() => closeWorkspace()}>
173
+ {t('cancel', 'Cancel')}
174
+ </Button>
175
+ <Button className={styles.buttonContainer} disabled={!file || isSubmitting} kind="primary" type="submit">
176
+ {isSubmitting ? (
177
+ <span className={styles.inlineLoading}>
178
+ {t('uploading', 'Uploading...')}
179
+ <InlineLoading status="active" iconDescription="Loading" />
180
+ </span>
181
+ ) : (
182
+ t('upload', 'Upload')
183
+ )}
184
+ </Button>
185
+ </ButtonSet>
186
+ </Form>
187
+ </Workspace2>
188
+ );
189
+ };
190
+
191
+ export default UploadLogoWorkspace;
@@ -0,0 +1,78 @@
1
+ import { FetchResponse, openmrsFetch, restBaseUrl } from '@openmrs/esm-framework';
2
+ import useSWR from 'swr';
3
+ import { HWR_API_NO_CREDENTIALS, PROVIDER_NOT_FOUND, RESOURCE_NOT_FOUND, UNKNOWN } from '../../constants';
4
+
5
+ export interface ProfessionalRegistryResponse {
6
+ success: boolean;
7
+ regulator: string;
8
+ identification_type: string;
9
+ identification_number: string;
10
+ professional: {
11
+ membership: {
12
+ id: string;
13
+ full_name: string;
14
+ gender: string;
15
+ first_name: string;
16
+ middle_name: string;
17
+ last_name: string;
18
+ registration_id: string;
19
+ external_reference_id: string;
20
+ licensing_body: string;
21
+ specialty: string;
22
+ is_active: number;
23
+ };
24
+ licenses?: Array<{
25
+ id: string;
26
+ external_reference_id: string;
27
+ license_type: string;
28
+ license_start: string;
29
+ license_end: string;
30
+ }>;
31
+ professional_details?: {
32
+ professional_cadre?: string;
33
+ practice_type?: string;
34
+ educational_qualifications?: string;
35
+ };
36
+ contacts?: {
37
+ phone?: string;
38
+ email?: string;
39
+ postal_address?: string;
40
+ };
41
+ identifiers?: {
42
+ identification_type?: string;
43
+ identification_number?: string;
44
+ };
45
+ };
46
+ }
47
+
48
+ export const searchHealthCareWork = async (
49
+ identifierType: string,
50
+ identifierNumber: string,
51
+ regulator: string,
52
+ ): Promise<ProfessionalRegistryResponse> => {
53
+ const url = `${restBaseUrl}/virtualclaims/professional-registry?${new URLSearchParams({
54
+ identification_number: identifierNumber,
55
+ identification_type: identifierType,
56
+ regulator,
57
+ }).toString()}`;
58
+
59
+ try {
60
+ const response = await openmrsFetch<ProfessionalRegistryResponse>(url);
61
+ if (!response.data?.success || !response.data?.professional) {
62
+ throw new Error(PROVIDER_NOT_FOUND);
63
+ }
64
+ return response.data;
65
+ } catch (err: any) {
66
+ if (err?.message === PROVIDER_NOT_FOUND) {
67
+ throw err;
68
+ }
69
+ const status = err?.response?.status;
70
+ if (status === 401) {
71
+ throw new Error(HWR_API_NO_CREDENTIALS);
72
+ }
73
+ if (status === 404) {
74
+ throw new Error(RESOURCE_NOT_FOUND);
75
+ }
76
+ throw new Error(UNKNOWN);
77
+ }
78
+ };
@@ -0,0 +1,59 @@
1
+ import { FetchResponse, openmrsFetch, restBaseUrl, useSession } from '@openmrs/esm-framework';
2
+ import useSWR from 'swr';
3
+
4
+ export type EnumEntry = {
5
+ code: string;
6
+ label: string;
7
+ };
8
+
9
+ type RegulatorsResponse = {
10
+ count: number;
11
+ regulators: Array<EnumEntry>;
12
+ };
13
+
14
+ type IdentificationTypesResponse = {
15
+ count: number;
16
+ identification_types: Array<EnumEntry>;
17
+ };
18
+
19
+ const ONE_DAY_MS = 24 * 60 * 60 * 1000;
20
+
21
+ export const useProfessionalRegistryRegulators = () => {
22
+ const { authenticated } = useSession();
23
+ const url = `${restBaseUrl}/virtualclaims/professional-registry/regulators`;
24
+
25
+ const { data, error, isLoading } = useSWR<FetchResponse<RegulatorsResponse>>(
26
+ authenticated ? url : null,
27
+ openmrsFetch,
28
+ {
29
+ revalidateOnFocus: false,
30
+ dedupingInterval: ONE_DAY_MS,
31
+ },
32
+ );
33
+
34
+ return {
35
+ regulators: data?.data?.regulators ?? [],
36
+ isLoading,
37
+ error,
38
+ };
39
+ };
40
+
41
+ export const useProfessionalRegistryIdentificationTypes = () => {
42
+ const { authenticated } = useSession();
43
+ const url = `${restBaseUrl}/virtualclaims/professional-registry/identification-types`;
44
+
45
+ const { data, error, isLoading } = useSWR<FetchResponse<IdentificationTypesResponse>>(
46
+ authenticated ? url : null,
47
+ openmrsFetch,
48
+ {
49
+ revalidateOnFocus: false,
50
+ dedupingInterval: ONE_DAY_MS,
51
+ },
52
+ );
53
+
54
+ return {
55
+ identificationTypes: data?.data?.identification_types ?? [],
56
+ isLoading,
57
+ error,
58
+ };
59
+ };
@@ -1,35 +1,36 @@
1
- import React, { useEffect, useMemo } from 'react';
1
+ import React, { useEffect, useMemo, useState } from 'react';
2
2
  import {
3
- type DefaultWorkspaceProps,
4
3
  ResponsiveWrapper,
5
- useLayoutType,
6
- showSnackbar,
7
- useConfig,
4
+ Workspace2,
8
5
  restBaseUrl,
6
+ showSnackbar,
7
+ useLayoutType,
8
+ type Workspace2DefinitionProps,
9
9
  } from '@openmrs/esm-framework';
10
10
  import { useTranslation } from 'react-i18next';
11
11
  import { Controller, useForm } from 'react-hook-form';
12
12
  import {
13
- ButtonSet,
14
13
  Button,
15
- InlineLoading,
16
- TextInput,
14
+ ButtonSet,
15
+ FilterableMultiSelect,
16
+ Form,
17
17
  FormGroup,
18
+ InlineLoading,
18
19
  Stack,
19
- Form,
20
- FilterableMultiSelect,
20
+ TextInput,
21
21
  } from '@carbon/react';
22
- import classNames from 'classnames';
23
- import { z } from 'zod';
24
22
  import { zodResolver } from '@hookform/resolvers/zod';
23
+ import { z } from 'zod';
24
+ import classNames from 'classnames';
25
+ import { mutate } from 'swr';
26
+
25
27
  import styles from './add-location.workspace.scss';
26
28
  import { type LocationResponse } from '../../types';
27
29
  import { extractErrorMessagesFromResponse } from '../../helpers';
28
30
  import { useLocationTags } from '../../hooks/useLocationTags';
29
- import { mutate } from 'swr';
30
31
  import { saveOrUpdateLocation } from '../../hooks/useLocation';
31
32
 
32
- type AddLocationWorkspaceProps = DefaultWorkspaceProps & {
33
+ type AddLocationWorkspaceProps = {
33
34
  location?: LocationResponse;
34
35
  };
35
36
 
@@ -46,16 +47,14 @@ const locationFormSchema = z.object({
46
47
 
47
48
  type LocationFormType = z.infer<typeof locationFormSchema>;
48
49
 
49
- const AddLocationWorkspace: React.FC<AddLocationWorkspaceProps> = ({
50
+ const AddLocationWorkspace: React.FC<Workspace2DefinitionProps<AddLocationWorkspaceProps, {}, {}>> = ({
50
51
  closeWorkspace,
51
- closeWorkspaceWithSavedChanges,
52
- promptBeforeClosing,
53
- location,
52
+ workspaceProps: { location = {} as LocationResponse },
54
53
  }) => {
55
54
  const { t } = useTranslation();
56
55
  const isTablet = useLayoutType() === 'tablet';
57
56
  const { locationTagList: Tags } = useLocationTags();
58
-
57
+ const [hasUnsavedChanges, setHasUnsavedChanges] = useState(false);
59
58
  const hasLocationAttributes = useMemo(() => {
60
59
  return location?.attributes && location.attributes.length > 0;
61
60
  }, [location?.attributes]);
@@ -105,7 +104,7 @@ const AddLocationWorkspace: React.FC<AddLocationWorkspaceProps> = ({
105
104
  }),
106
105
  });
107
106
  handleMutation();
108
- closeWorkspaceWithSavedChanges();
107
+ closeWorkspace({ discardUnsavedChanges: true });
109
108
  } catch (error: any) {
110
109
  const errorMessages = extractErrorMessagesFromResponse(error);
111
110
  showSnackbar({
@@ -117,83 +116,85 @@ const AddLocationWorkspace: React.FC<AddLocationWorkspaceProps> = ({
117
116
  };
118
117
 
119
118
  useEffect(() => {
120
- promptBeforeClosing(() => isDirty);
121
- }, [isDirty, promptBeforeClosing]);
119
+ setHasUnsavedChanges(true);
120
+ }, [isDirty, setHasUnsavedChanges]);
122
121
 
123
122
  return (
124
- <Form onSubmit={handleSubmit(onSubmit)} className={styles.form}>
125
- <div className={styles.formContainer}>
126
- <Stack gap={3}>
127
- <ResponsiveWrapper>
128
- <FormGroup legendText="">
129
- <Controller
130
- control={control}
131
- name="name"
132
- render={({ field }) => (
133
- <TextInput
134
- id="locationName"
135
- placeholder={t('locationPlaceholder', 'Add a location')}
136
- labelText={t('locationName', 'Location Name')}
137
- value={field.value}
138
- onChange={field.onChange}
139
- invalid={!!errors.name?.message}
140
- invalidText={errors.name?.message}
141
- disabled={hasLocationAttributes}
142
- />
143
- )}
144
- />
145
- </FormGroup>
146
- </ResponsiveWrapper>
147
-
148
- <ResponsiveWrapper>
149
- <FormGroup legendText="">
150
- <Controller
151
- control={control}
152
- name="tags"
153
- render={({ field: { onChange, value, ref } }) => (
154
- <FilterableMultiSelect
155
- id="locationTags"
156
- titleText={t('selectTags', 'Select tag(s)')}
157
- placeholder={t('selectTagPlaceholder', 'Select a tag')}
158
- items={Tags || []}
159
- selectedItems={(value || []).map(
160
- (selected) => Tags?.find((tag) => tag.uuid === selected.uuid) || selected,
161
- )}
162
- onChange={({ selectedItems }) => onChange(selectedItems || [])}
163
- itemToString={(item) => (item && typeof item === 'object' ? item.display : '')}
164
- selectionFeedback="top-after-reopen"
165
- invalid={!!errors.tags?.message}
166
- invalidText={errors.tags?.message}
167
- disabled={!Tags?.length}
168
- ref={ref}
169
- />
170
- )}
171
- />
172
- </FormGroup>
173
- </ResponsiveWrapper>
174
- </Stack>
175
- </div>
176
-
177
- <ButtonSet
178
- className={classNames({
179
- [styles.tablet]: isTablet,
180
- [styles.desktop]: !isTablet,
181
- })}>
182
- <Button className={styles.buttonContainer} kind="secondary" onClick={() => closeWorkspace()}>
183
- {t('cancel', 'Cancel')}
184
- </Button>
185
- <Button className={styles.buttonContainer} disabled={isSubmitting || !isDirty} kind="primary" type="submit">
186
- {isSubmitting ? (
187
- <span className={styles.inlineLoading}>
188
- {t('submitting', 'Submitting' + '...')}
189
- <InlineLoading status="active" iconDescription="Loading" />
190
- </span>
191
- ) : (
192
- t('saveAndClose', 'Save & close')
193
- )}
194
- </Button>
195
- </ButtonSet>
196
- </Form>
123
+ <Workspace2 title={t('addLocation', 'Add Location')} hasUnsavedChanges={hasUnsavedChanges}>
124
+ <Form onSubmit={handleSubmit(onSubmit)} className={styles.form}>
125
+ <div className={styles.formContainer}>
126
+ <Stack gap={3}>
127
+ <ResponsiveWrapper>
128
+ <FormGroup legendText="">
129
+ <Controller
130
+ control={control}
131
+ name="name"
132
+ render={({ field }) => (
133
+ <TextInput
134
+ id="locationName"
135
+ placeholder={t('locationPlaceholder', 'Add a location')}
136
+ labelText={t('locationName', 'Location Name')}
137
+ value={field.value}
138
+ onChange={field.onChange}
139
+ invalid={!!errors.name?.message}
140
+ invalidText={errors.name?.message}
141
+ disabled={hasLocationAttributes}
142
+ />
143
+ )}
144
+ />
145
+ </FormGroup>
146
+ </ResponsiveWrapper>
147
+
148
+ <ResponsiveWrapper>
149
+ <FormGroup legendText="">
150
+ <Controller
151
+ control={control}
152
+ name="tags"
153
+ render={({ field: { onChange, value, ref } }) => (
154
+ <FilterableMultiSelect
155
+ id="locationTags"
156
+ titleText={t('selectTags', 'Select tag(s)')}
157
+ placeholder={t('selectTagPlaceholder', 'Select a tag')}
158
+ items={Tags || []}
159
+ selectedItems={(value || []).map(
160
+ (selected) => Tags?.find((tag) => tag.uuid === selected.uuid) || selected,
161
+ )}
162
+ onChange={({ selectedItems }) => onChange(selectedItems || [])}
163
+ itemToString={(item) => (item && typeof item === 'object' ? item.display : '')}
164
+ selectionFeedback="top-after-reopen"
165
+ invalid={!!errors.tags?.message}
166
+ invalidText={errors.tags?.message}
167
+ disabled={!Tags?.length}
168
+ ref={ref}
169
+ />
170
+ )}
171
+ />
172
+ </FormGroup>
173
+ </ResponsiveWrapper>
174
+ </Stack>
175
+ </div>
176
+
177
+ <ButtonSet
178
+ className={classNames({
179
+ [styles.tablet]: isTablet,
180
+ [styles.desktop]: !isTablet,
181
+ })}>
182
+ <Button className={styles.buttonContainer} kind="secondary" onClick={() => closeWorkspace()}>
183
+ {t('cancel', 'Cancel')}
184
+ </Button>
185
+ <Button className={styles.buttonContainer} disabled={isSubmitting || !isDirty} kind="primary" type="submit">
186
+ {isSubmitting ? (
187
+ <span className={styles.inlineLoading}>
188
+ {t('submitting', 'Submitting' + '...')}
189
+ <InlineLoading status="active" iconDescription="Loading" />
190
+ </span>
191
+ ) : (
192
+ t('saveAndClose', 'Save & close')
193
+ )}
194
+ </Button>
195
+ </ButtonSet>
196
+ </Form>
197
+ </Workspace2>
197
198
  );
198
199
  };
199
200