ui-soxo-bootstrap-core 2.6.56 → 2.6.59

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 (422) hide show
  1. package/.babelrc +8 -8
  2. package/.github/workflows/npm-publish.yml +41 -41
  3. package/.husky/pre-commit +11 -11
  4. package/.prettierrc.json +10 -10
  5. package/DEVELOPER_GUIDE.md +294 -294
  6. package/PUBLISHING.md +333 -333
  7. package/babel.config.js +2 -2
  8. package/core/components/component-loader/component-loader.js +125 -125
  9. package/core/components/component-wrapper/component-wrapper.js +121 -121
  10. package/core/components/external-window/DEVELOPER_GUIDE.md +705 -705
  11. package/core/components/external-window/external-window.js +236 -236
  12. package/core/components/external-window/external-window.test.js +80 -80
  13. package/core/components/extra-info/extra-info-details.js +155 -155
  14. package/core/components/extra-info/extra-info-details.scss +26 -26
  15. package/core/components/extra-info/extra-info.js +134 -134
  16. package/core/components/index.js +14 -14
  17. package/core/components/landing-api/landing-api.js +733 -728
  18. package/core/components/landing-api/landing-api.scss +41 -41
  19. package/core/components/license-management/license-alert.js +97 -97
  20. package/core/components/menu-template-api/menu-template-api.js +321 -321
  21. package/core/components/root-application-api/root-application-api.js +174 -174
  22. package/core/index.js +13 -13
  23. package/core/lib/Store.js +375 -369
  24. package/core/lib/components/application-bootstrap/application-bootstrap.js +115 -115
  25. package/core/lib/components/approval-form/approval-form.js +280 -280
  26. package/core/lib/components/approval-form/approval-form.scss +183 -183
  27. package/core/lib/components/approval-list/approval-list.js +143 -143
  28. package/core/lib/components/approval-list/approval-list.scss +2 -2
  29. package/core/lib/components/approval-list/components/request-card/request-card.js +42 -42
  30. package/core/lib/components/approval-list/components/request-card/request-card.scss +30 -30
  31. package/core/lib/components/camera/camera.js +230 -230
  32. package/core/lib/components/camera/camera.scss +86 -86
  33. package/core/lib/components/comment-block/comment-block.js +138 -138
  34. package/core/lib/components/comment-block/comment-block.scss +3 -3
  35. package/core/lib/components/confirm-modal/confirm-modal.js +82 -82
  36. package/core/lib/components/confirm-modal/confirm-modal.scss +2 -2
  37. package/core/lib/components/consent/consent.js +67 -67
  38. package/core/lib/components/consent/pdf-signature.js +299 -299
  39. package/core/lib/components/consent/signature-pad.js +227 -227
  40. package/core/lib/components/consent/signature-pad.scss +23 -23
  41. package/core/lib/components/file-upload/file-upload.js +133 -133
  42. package/core/lib/components/finger-print-reader/finger-print-reader.js +295 -295
  43. package/core/lib/components/finger-print-reader/finger-print-reader.scss +47 -47
  44. package/core/lib/components/finger-print-search/finger-print-search.js +200 -200
  45. package/core/lib/components/finger-print-search/finger-print-search.scss +47 -47
  46. package/core/lib/components/global-header/animations.js +18 -18
  47. package/core/lib/components/global-header/global-header.js +293 -293
  48. package/core/lib/components/global-header/global-header.scss +399 -399
  49. package/core/lib/components/header/generic-header.js +76 -76
  50. package/core/lib/components/header/generic-header.scss +99 -99
  51. package/core/lib/components/image-preview/image-preview.js +33 -33
  52. package/core/lib/components/image-wrapper/image-wrapper.js +108 -108
  53. package/core/lib/components/image-wrapper/image-wrapper.scss +12 -12
  54. package/core/lib/components/index.js +206 -206
  55. package/core/lib/components/landing/landing.js +403 -403
  56. package/core/lib/components/language-switcher/language-switcher.js +49 -49
  57. package/core/lib/components/menu-context/menu-context.js +69 -69
  58. package/core/lib/components/menu-template/menu-template.js +249 -249
  59. package/core/lib/components/menu-template/menu-template.scss +9 -9
  60. package/core/lib/components/modal-search/modal-search.js +153 -153
  61. package/core/lib/components/modal-search/modal-search.scss +78 -78
  62. package/core/lib/components/modal-wrapper/modal-manager.js +15 -15
  63. package/core/lib/components/modal-wrapper/modal-wrapper.js +108 -108
  64. package/core/lib/components/modal-wrapper/modal-wrapper.scss +13 -13
  65. package/core/lib/components/notice-board/notice-board.js +132 -132
  66. package/core/lib/components/notice-board/notice-board.scss +65 -65
  67. package/core/lib/components/page-container/page-container.js +55 -55
  68. package/core/lib/components/page-container/page-container.scss +8 -8
  69. package/core/lib/components/page-header/page-header.js +23 -23
  70. package/core/lib/components/page-header/page-header.scss +17 -17
  71. package/core/lib/components/pdf-viewer/pdf-viewer.js +56 -56
  72. package/core/lib/components/portlet-table/components/table-actions/table-actions.js +58 -58
  73. package/core/lib/components/portlet-table/components/table-actions/table-actions.scss +1 -1
  74. package/core/lib/components/portlet-table/components/table-data/table-data.js +106 -106
  75. package/core/lib/components/portlet-table/portlet-table.js +63 -63
  76. package/core/lib/components/portlet-table/portlet-table.scss +90 -90
  77. package/core/lib/components/progress-bar/progress-bar.js +58 -58
  78. package/core/lib/components/progress-bar/progress-bar.scss +15 -15
  79. package/core/lib/components/request-form/request-form.js +110 -110
  80. package/core/lib/components/root-application/root-application.js +70 -70
  81. package/core/lib/components/rupee/rupee.js +14 -14
  82. package/core/lib/components/script-input/script-input.js +169 -169
  83. package/core/lib/components/script-input/script-input.scss +8 -8
  84. package/core/lib/components/sidemenu/animations.js +51 -51
  85. package/core/lib/components/sidemenu/sidemenu.js +632 -632
  86. package/core/lib/components/sidemenu/sidemenu.scss +314 -314
  87. package/core/lib/components/spotlight-search/spotlight-search.component.js +635 -635
  88. package/core/lib/components/spotlight-search/spotlight-search.component.scss +78 -78
  89. package/core/lib/components/table-wrapper/table-wrapper.js +135 -135
  90. package/core/lib/components/table-wrapper/table-wrapper.scss +72 -72
  91. package/core/lib/components/ui_elements/Loader.js +12 -12
  92. package/core/lib/components/ui_elements/Notify.js +12 -12
  93. package/core/lib/components/ui_elements/PlaceHolder.js +33 -33
  94. package/core/lib/components/web-camera/web-camera.js +161 -161
  95. package/core/lib/components/web-camera/web-camera.scss +28 -28
  96. package/core/lib/core.md +9 -9
  97. package/core/lib/elements/Elements.md +2 -2
  98. package/core/lib/elements/basic/LoggedUserRedirect.js +21 -21
  99. package/core/lib/elements/basic/PrivateRoute.js +16 -16
  100. package/core/lib/elements/basic/button/Button.md +43 -43
  101. package/core/lib/elements/basic/button/button.js +170 -170
  102. package/core/lib/elements/basic/card/Card.md +15 -15
  103. package/core/lib/elements/basic/card/card.js +40 -40
  104. package/core/lib/elements/basic/card/card.scss +13 -13
  105. package/core/lib/elements/basic/checkbox/checkbox.js +23 -23
  106. package/core/lib/elements/basic/col/col.js +15 -15
  107. package/core/lib/elements/basic/copy-to-clipboard/Readme.md +40 -40
  108. package/core/lib/elements/basic/copy-to-clipboard/copy-to-clipboard.js +61 -61
  109. package/core/lib/elements/basic/country-phone-input/Readme.md +98 -98
  110. package/core/lib/elements/basic/country-phone-input/country-phone-input.js +81 -81
  111. package/core/lib/elements/basic/country-phone-input/phone-input.scss +75 -75
  112. package/core/lib/elements/basic/datepicker/datepicker.js +33 -33
  113. package/core/lib/elements/basic/dragabble-wrapper/draggable-wrapper.js +203 -203
  114. package/core/lib/elements/basic/empty/empty.js +14 -14
  115. package/core/lib/elements/basic/fingerprint-protrected/fingerprint-protected.js +118 -118
  116. package/core/lib/elements/basic/fingerprint-protrected/fingerprint-protected.scss +10 -10
  117. package/core/lib/elements/basic/form/form.js +70 -70
  118. package/core/lib/elements/basic/form/form.scss +3 -3
  119. package/core/lib/elements/basic/image/image.js +45 -45
  120. package/core/lib/elements/basic/image/image.scss +17 -17
  121. package/core/lib/elements/basic/image/readme.md +26 -26
  122. package/core/lib/elements/basic/image-viewer/image-viewer.js +108 -108
  123. package/core/lib/elements/basic/image-viewer/image-viewer.scss +7 -7
  124. package/core/lib/elements/basic/input/input.js +81 -81
  125. package/core/lib/elements/basic/input/readme.md +77 -77
  126. package/core/lib/elements/basic/json-input/json-input.js +51 -51
  127. package/core/lib/elements/basic/menu-dashboard/menu-dashboard.js +216 -216
  128. package/core/lib/elements/basic/menu-dashboard/menu-dashboard.scss +28 -28
  129. package/core/lib/elements/basic/menu-tree/menu-tree.js +127 -127
  130. package/core/lib/elements/basic/modal/modal.js +64 -64
  131. package/core/lib/elements/basic/modal/readme.md +62 -62
  132. package/core/lib/elements/basic/popconfirm/popconfirm.js +17 -17
  133. package/core/lib/elements/basic/popover/popover.js +12 -12
  134. package/core/lib/elements/basic/radio/radio.js +18 -18
  135. package/core/lib/elements/basic/rangepicker/rangepicker.js +141 -141
  136. package/core/lib/elements/basic/rangepicker/rangepicker.scss +24 -24
  137. package/core/lib/elements/basic/rangepicker/readme.md +81 -81
  138. package/core/lib/elements/basic/reference-select/readme.md +18 -18
  139. package/core/lib/elements/basic/reference-select/reference-select.js +341 -337
  140. package/core/lib/elements/basic/row/row.js +15 -15
  141. package/core/lib/elements/basic/select/select.js +46 -46
  142. package/core/lib/elements/basic/select-box/readme.md +52 -52
  143. package/core/lib/elements/basic/select-box/select-box.js +63 -63
  144. package/core/lib/elements/basic/skeleton/readme.md +35 -35
  145. package/core/lib/elements/basic/skeleton/skeleton.js +35 -35
  146. package/core/lib/elements/basic/skeleton/skeleton.scss +53 -53
  147. package/core/lib/elements/basic/space/space.js +12 -12
  148. package/core/lib/elements/basic/switch/readme.md +29 -29
  149. package/core/lib/elements/basic/switch/switch.js +67 -67
  150. package/core/lib/elements/basic/tab/tab.js +14 -14
  151. package/core/lib/elements/basic/table/readme.md +8 -8
  152. package/core/lib/elements/basic/table/table.js +95 -95
  153. package/core/lib/elements/basic/tag/tag.js +63 -63
  154. package/core/lib/elements/basic/tag/tag.scss +2 -2
  155. package/core/lib/elements/basic/timeline/timeline.js +13 -13
  156. package/core/lib/elements/basic/title/readme.md +20 -20
  157. package/core/lib/elements/basic/title/title.js +37 -37
  158. package/core/lib/elements/basic/user-search/user-search.js +192 -192
  159. package/core/lib/elements/complex/barcode/barcode.js +27 -27
  160. package/core/lib/elements/complex/bargraph/bar-graph.js +262 -262
  161. package/core/lib/elements/complex/basic-table/basic-table.js +110 -110
  162. package/core/lib/elements/complex/basic-table/basic-table.scss +4 -4
  163. package/core/lib/elements/complex/date-display/date-display.js +37 -37
  164. package/core/lib/elements/complex/error-boundary/error-boundary.js +29 -29
  165. package/core/lib/elements/complex/google-location-input/map-container-library-load.js +92 -92
  166. package/core/lib/elements/complex/google-map/google-map.js +230 -230
  167. package/core/lib/elements/complex/google-map/google-map.scss +13 -13
  168. package/core/lib/elements/complex/line-graph/line-graph.js +108 -108
  169. package/core/lib/elements/complex/location-search-input/location-search-input.js +100 -100
  170. package/core/lib/elements/complex/pie-chart/pie-chart.js +202 -202
  171. package/core/lib/elements/complex/qr-code/qr-code.js +29 -29
  172. package/core/lib/elements/complex/qrscanner/qrscanner.js +57 -57
  173. package/core/lib/elements/complex/search-debounce/search-debounce.js +37 -37
  174. package/core/lib/elements/complex/statistic-card/dashboard-statistic-card.js +75 -75
  175. package/core/lib/elements/complex/statistic-card/statistic-card.js +28 -28
  176. package/core/lib/elements/index.js +226 -226
  177. package/core/lib/hooks/device-detect.js +25 -25
  178. package/core/lib/hooks/index.js +9 -9
  179. package/core/lib/hooks/use-location.js +33 -33
  180. package/core/lib/hooks/use-otp-timer.js +80 -80
  181. package/core/lib/hooks/use-window-size.js +34 -34
  182. package/core/lib/i18n.js +69 -69
  183. package/core/lib/index.js +106 -106
  184. package/core/lib/introduction.md +73 -73
  185. package/core/lib/js-styleguide.md +4112 -4112
  186. package/core/lib/models/actions/actions.js +127 -127
  187. package/core/lib/models/actions/components/action-detail/action-detail.js +190 -190
  188. package/core/lib/models/actions/components/custom-actions/custom-actions.js +185 -185
  189. package/core/lib/models/attachments/attachments.js +231 -231
  190. package/core/lib/models/base-loader.js +99 -99
  191. package/core/lib/models/base.js +716 -716
  192. package/core/lib/models/branches/branches.js +125 -125
  193. package/core/lib/models/checklists/checklists.js +114 -114
  194. package/core/lib/models/columns/columns.js +169 -169
  195. package/core/lib/models/columns/components/columns-add/columns-add.js +171 -171
  196. package/core/lib/models/comments/comments.js +213 -213
  197. package/core/lib/models/departments/departments.js +107 -107
  198. package/core/lib/models/financial-years/financial_years.js +127 -127
  199. package/core/lib/models/forms/components/form-creator/form-creator.js +667 -667
  200. package/core/lib/models/forms/components/form-creator/form-creator.scss +39 -39
  201. package/core/lib/models/forms/components/form-detail/form-detail.js +224 -224
  202. package/core/lib/models/forms/forms.js +121 -121
  203. package/core/lib/models/index.js +203 -203
  204. package/core/lib/models/invoice-numbers/invoice_numbers.js +204 -204
  205. package/core/lib/models/lookup-types/components/lookup-detail/lookup-detail.js +145 -145
  206. package/core/lib/models/lookup-types/lookup-types.js +113 -113
  207. package/core/lib/models/lookup-values/components/lookup-values-add/lookup-values-add.js +126 -126
  208. package/core/lib/models/lookup-values/lookup-values.js +107 -107
  209. package/core/lib/models/menu-roles/menu-roles.js +127 -127
  210. package/core/lib/models/menus/components/menu-add/menu-add.js +228 -228
  211. package/core/lib/models/menus/components/menu-detail/menu-detail.js +170 -170
  212. package/core/lib/models/menus/components/menu-list/menu-list.js +550 -550
  213. package/core/lib/models/menus/components/menu-list/menu-list.scss +5 -5
  214. package/core/lib/models/menus/components/menu-roles-add/menu-roles-add.js +183 -183
  215. package/core/lib/models/menus/menus.js +499 -499
  216. package/core/lib/models/models/components/model-detail/model-detail.js +137 -137
  217. package/core/lib/models/models/components/models.js +128 -128
  218. package/core/lib/models/modules/modules.js +204 -204
  219. package/core/lib/models/outbox/outbox.js +73 -73
  220. package/core/lib/models/pages/pages.js +107 -107
  221. package/core/lib/models/permissions/permissions.js +71 -71
  222. package/core/lib/models/process/components/process-add/process-add.js +181 -181
  223. package/core/lib/models/process/components/process-dashboard/process-dashboard.js +1068 -1068
  224. package/core/lib/models/process/components/process-dashboard/process-dashboard.scss +66 -66
  225. package/core/lib/models/process/components/process-detail/process-detail.js +140 -140
  226. package/core/lib/models/process/components/process-timeline/process-timeline.js +139 -139
  227. package/core/lib/models/process/components/task-detail/task-detail.js +240 -240
  228. package/core/lib/models/process/components/task-detail/task-detail.scss +27 -27
  229. package/core/lib/models/process/components/task-form/task-form.js +528 -528
  230. package/core/lib/models/process/components/task-form/task-form.scss +7 -7
  231. package/core/lib/models/process/components/task-list/task-list.js +221 -221
  232. package/core/lib/models/process/components/task-list/task-list.scss +14 -14
  233. package/core/lib/models/process/components/task-overview/task-overview.js +299 -299
  234. package/core/lib/models/process/components/task-overview-legacy/task-overview-legacy.js +192 -192
  235. package/core/lib/models/process/components/task-routes/task-routes.js +45 -45
  236. package/core/lib/models/process/components/task-status/task-status.js +175 -175
  237. package/core/lib/models/process/components/task-status/task-status.scss +11 -11
  238. package/core/lib/models/process/process.js +780 -780
  239. package/core/lib/models/process-transactions/process-transactions.js +123 -123
  240. package/core/lib/models/roles/roles.js +106 -106
  241. package/core/lib/models/scripts/scripts.js +111 -111
  242. package/core/lib/models/step-transactions/step-transcations.js +147 -147
  243. package/core/lib/models/steps/components/step-add/step-add.js +261 -261
  244. package/core/lib/models/steps/components/step-detail/step-detail.js +157 -157
  245. package/core/lib/models/steps/steps.js +356 -356
  246. package/core/lib/models/user-preferences/user-preferences.js +83 -83
  247. package/core/lib/models/users/components/user-add/user-add.js +226 -226
  248. package/core/lib/models/users/users.js +119 -119
  249. package/core/lib/modules/business/launch-page/launch-page.js +29 -29
  250. package/core/lib/modules/business/launch-page/launch-page.scss +5 -5
  251. package/core/lib/modules/business/slots/slots.js +231 -231
  252. package/core/lib/modules/business/slots/slots.scss +108 -108
  253. package/core/lib/modules/forms/components/field-customizer/field-customizer.js +138 -138
  254. package/core/lib/modules/forms/components/field-selector/field-selector.js +157 -157
  255. package/core/lib/modules/forms/components/field-selector/field-selector.scss +25 -25
  256. package/core/lib/modules/forms/components/form-display/form-display.js +203 -203
  257. package/core/lib/modules/forms/components/form-display/form-display.scss +9 -9
  258. package/core/lib/modules/forms/components/tab-customizer/tab-customizer.js +124 -124
  259. package/core/lib/modules/generic/generic-add/generic-add.js +213 -213
  260. package/core/lib/modules/generic/generic-detail/generic-detail.js +199 -199
  261. package/core/lib/modules/generic/generic-edit/generic-edit.js +120 -120
  262. package/core/lib/modules/generic/generic-list/ExportReactCSV.js +508 -508
  263. package/core/lib/modules/generic/generic-list/fonts/NotoSansBold.js +8 -8
  264. package/core/lib/modules/generic/generic-list/fonts/NotoSansRegular.js +15 -15
  265. package/core/lib/modules/generic/generic-list/generic-list.js +705 -705
  266. package/core/lib/modules/generic/generic-list/generic-list.scss +68 -68
  267. package/core/lib/modules/generic/generic-upload/generic-upload.js +483 -483
  268. package/core/lib/modules/generic/table-settings/table-settings.js +226 -226
  269. package/core/lib/modules/generic/table-settings/table-settings.scss +37 -37
  270. package/core/lib/modules/index.js +52 -52
  271. package/core/lib/modules/modules-routes/module-routes.js +35 -35
  272. package/core/lib/pages/change-password/change-password.js +204 -204
  273. package/core/lib/pages/change-password/change-password.scss +73 -73
  274. package/core/lib/pages/homepage/homepage.js +53 -53
  275. package/core/lib/pages/index.js +19 -19
  276. package/core/lib/pages/login/commnication-mode-selection.js +46 -46
  277. package/core/lib/pages/login/communication-mode-selection.scss +60 -60
  278. package/core/lib/pages/login/login.js +872 -872
  279. package/core/lib/pages/login/login.scss +353 -353
  280. package/core/lib/pages/login/reset-password.js +124 -124
  281. package/core/lib/pages/login/reset-password.scss +31 -31
  282. package/core/lib/pages/manage-users/manage-users.js +429 -429
  283. package/core/lib/pages/manage-users/manage-users.scss +25 -25
  284. package/core/lib/pages/profile/profile.js +247 -247
  285. package/core/lib/pages/profile/profile.scss +107 -107
  286. package/core/lib/pages/profile/theme-config.js +18 -18
  287. package/core/lib/pages/profile/themes-backup.json +310 -310
  288. package/core/lib/pages/profile/themes.json +254 -254
  289. package/core/lib/pages/register/register.js +176 -176
  290. package/core/lib/pages/register/register.scss +128 -128
  291. package/core/lib/react-styleguide.md +756 -756
  292. package/core/lib/utils/api/api.utils.js +207 -207
  293. package/core/lib/utils/api/readme.md +426 -426
  294. package/core/lib/utils/async.js +35 -35
  295. package/core/lib/utils/common/common.utils.js +237 -237
  296. package/core/lib/utils/common/readme.md +30 -30
  297. package/core/lib/utils/date/date.utils.js +295 -295
  298. package/core/lib/utils/date/readme.md +2 -2
  299. package/core/lib/utils/firebase.support.utils.js +98 -98
  300. package/core/lib/utils/firebase.utils.js +808 -808
  301. package/core/lib/utils/font-awesome.utils.js +168 -168
  302. package/core/lib/utils/form/form.utils.js +255 -255
  303. package/core/lib/utils/generic/generic.utils.js +70 -70
  304. package/core/lib/utils/http/auth.helper.js +95 -95
  305. package/core/lib/utils/http/http.utils.js +190 -190
  306. package/core/lib/utils/http/readme.md +14 -14
  307. package/core/lib/utils/index.js +43 -43
  308. package/core/lib/utils/location/location.utils.js +137 -137
  309. package/core/lib/utils/location/readme.md +18 -18
  310. package/core/lib/utils/modal.utils.js +15 -15
  311. package/core/lib/utils/notification.utils.js +34 -34
  312. package/core/lib/utils/pwa/pwa.utils.js +88 -88
  313. package/core/lib/utils/script.utils.js +235 -235
  314. package/core/lib/utils/setting.utils.js +68 -68
  315. package/core/lib/utils/upload.utils.js +29 -29
  316. package/core/models/Preference/Preferences.js +46 -46
  317. package/core/models/base/base.js +403 -403
  318. package/core/models/base-clone-loader.js +107 -107
  319. package/core/models/base-clone.js +187 -187
  320. package/core/models/base-loader.js +97 -97
  321. package/core/models/core-scripts/core-scripts.js +179 -179
  322. package/core/models/dashboard/dashboard.js +201 -201
  323. package/core/models/detail-loader.js +88 -88
  324. package/core/models/doctor/components/doctor-add/doctor-add.js +432 -432
  325. package/core/models/doctor/components/doctor-add/doctor-add.scss +32 -32
  326. package/core/models/groups.js +82 -82
  327. package/core/models/index.js +100 -100
  328. package/core/models/lookup-types/components/lookup-detail/lookup-detail.js +129 -129
  329. package/core/models/lookup-types/lookup-types.js +96 -96
  330. package/core/models/lookup-values/components/lookup-values-modal/lookup-values-modal.js +95 -95
  331. package/core/models/lookup-values/lookup-values.js +92 -92
  332. package/core/models/menu-roles/components/menu-roles-add/menu-roles-add.js +153 -153
  333. package/core/models/menu-roles/menu-roles.js +158 -158
  334. package/core/models/menus/components/menu-add/menu-add.js +315 -315
  335. package/core/models/menus/components/menu-add/menu-add.scss +31 -31
  336. package/core/models/menus/components/menu-detail/menu-detail.js +263 -263
  337. package/core/models/menus/components/menu-list/menu-list.js +392 -392
  338. package/core/models/menus/components/menu-lists/menu-lists.js +647 -647
  339. package/core/models/menus/components/menu-lists/menu-lists.scss +73 -73
  340. package/core/models/menus/menus.js +338 -338
  341. package/core/models/model-columns.js +121 -121
  342. package/core/models/models/components/model-detail/model-add.js +120 -120
  343. package/core/models/models/components/model-detail/model-detail.js +133 -133
  344. package/core/models/models/models.js +154 -154
  345. package/core/models/pages/components/page-add/page-add.js +163 -163
  346. package/core/models/pages/components/page-add/page-add.scss +30 -30
  347. package/core/models/pages/components/page-details/page-details.js +209 -209
  348. package/core/models/pages/components/page-list/page-list.js +248 -248
  349. package/core/models/pages/pages.js +142 -142
  350. package/core/models/pages.js +142 -142
  351. package/core/models/roles/components/role-add/menu-label.js +14 -14
  352. package/core/models/roles/components/role-add/menu-tree.js +127 -127
  353. package/core/models/roles/components/role-add/role-add.js +230 -230
  354. package/core/models/roles/components/role-add/role-add.scss +4 -4
  355. package/core/models/roles/components/role-list/role-list.js +406 -406
  356. package/core/models/roles/roles.js +199 -199
  357. package/core/models/staff/components/staff-add/staff-add.js +455 -455
  358. package/core/models/user-roles/components/user-roles-add/user-roles-add.js +149 -149
  359. package/core/models/user-roles/user-roles.js +113 -113
  360. package/core/models/users/components/assign-role/assign-role.js +428 -428
  361. package/core/models/users/components/assign-role/assign-role.scss +281 -281
  362. package/core/models/users/components/assign-role/avatar-props.js +45 -45
  363. package/core/models/users/components/user-add/user-add.js +847 -847
  364. package/core/models/users/components/user-add/user-edit.js +110 -110
  365. package/core/models/users/components/user-detail/user-detail.js +236 -236
  366. package/core/models/users/components/user-list/user-list.js +397 -397
  367. package/core/models/users/users.js +379 -379
  368. package/core/modules/Informations/change-info/change-info.js +618 -618
  369. package/core/modules/Informations/change-info/change-info.scss +134 -134
  370. package/core/modules/dashboard/components/dashboard-card/animations.js +64 -64
  371. package/core/modules/dashboard/components/dashboard-card/dashboard-card.js +197 -197
  372. package/core/modules/dashboard/components/dashboard-card/menu-dashboard-card.js +430 -430
  373. package/core/modules/dashboard/components/dashboard-card/menu-dashboard-card.scss +59 -59
  374. package/core/modules/dashboard/components/pop-query-dashboard/pop-query-dashboard.js +66 -66
  375. package/core/modules/generic/components/generic-add/generic-add.js +121 -121
  376. package/core/modules/generic/components/generic-add/generic-add.scss +13 -13
  377. package/core/modules/generic/components/generic-add-modal/generic-add-modal.js +125 -125
  378. package/core/modules/generic/components/generic-add-modal/generic-add-modal.scss +13 -13
  379. package/core/modules/generic/components/generic-detail/generic-detail.js +184 -184
  380. package/core/modules/generic/components/generic-detail/generic-detail.scss +25 -25
  381. package/core/modules/generic/components/generic-edit/generic-edit.js +123 -123
  382. package/core/modules/generic/components/generic-list/generic-list.js +335 -335
  383. package/core/modules/generic/components/generic-list/generic-list.scss +35 -35
  384. package/core/modules/index.js +42 -42
  385. package/core/modules/module-routes/module-routes.js +37 -37
  386. package/core/modules/reporting/components/index.js +6 -6
  387. package/core/modules/reporting/components/reporting-dashboard/README.md +316 -316
  388. package/core/modules/reporting/components/reporting-dashboard/adavance-search/advance-search.js +271 -271
  389. package/core/modules/reporting/components/reporting-dashboard/adavance-search/advance-search.scss +76 -76
  390. package/core/modules/reporting/components/reporting-dashboard/display-columns/build-display-columns.js +90 -90
  391. package/core/modules/reporting/components/reporting-dashboard/display-columns/build-display-columns.test.js +74 -74
  392. package/core/modules/reporting/components/reporting-dashboard/display-columns/display-cell-renderer.js +404 -404
  393. package/core/modules/reporting/components/reporting-dashboard/display-columns/display-cell-renderer.test.js +179 -179
  394. package/core/modules/reporting/components/reporting-dashboard/reporting-dashboard.js +652 -652
  395. package/core/modules/reporting/components/reporting-dashboard/reporting-dashboard.scss +215 -215
  396. package/core/modules/reporting/components/reporting-dashboard/reporting-table.js +537 -522
  397. package/core/modules/steps/action-buttons.js +92 -92
  398. package/core/modules/steps/action-buttons.scss +62 -62
  399. package/core/modules/steps/chat-assistant.js +141 -141
  400. package/core/modules/steps/narration.js +192 -192
  401. package/core/modules/steps/openai-realtime.js +275 -275
  402. package/core/modules/steps/progress-storage.js +140 -140
  403. package/core/modules/steps/readme.md +167 -167
  404. package/core/modules/steps/steps.js +1597 -1597
  405. package/core/modules/steps/steps.scss +1051 -1051
  406. package/core/modules/steps/timeline.js +56 -56
  407. package/core/modules/steps/voice-navigation.js +709 -709
  408. package/core/pages/homepage-api/homepage-api.js +106 -106
  409. package/core/pages/homepage-api/homepage-api.scss +233 -233
  410. package/core/pages/homepage-api/menu-dashboard.js +169 -169
  411. package/core/pages/homepage-api/menu-dashboard.scss +11 -11
  412. package/core/translation.json +53 -53
  413. package/core/translations.json +19 -19
  414. package/core/utils/script.utils.js +129 -129
  415. package/core/utils/settings.utils.js +25 -25
  416. package/eslint.config.mjs +79 -79
  417. package/index.js +35 -35
  418. package/jest.config.js +7 -7
  419. package/jest.setup.js +1 -1
  420. package/package.json +125 -125
  421. package/tsconfig.json +26 -26
  422. package/webpack.config.js +173 -173
@@ -1,847 +1,847 @@
1
- import React, { useState, useEffect, useContext } from 'react';
2
-
3
- import { useLocation } from 'react-router-dom';
4
-
5
- import { Skeleton, Typography, message, Switch, Form, Input, Select, Checkbox, Row, Col } from 'antd';
6
-
7
- import AsyncSelect from 'react-select/async';
8
-
9
- import { Table, Card, Button, JSONInput, GlobalContext, safeJSON, CountryPhoneInput, phoneValidator } from './../../../../lib/';
10
-
11
- import { ModelsAPI, PagesAPI, RolesAPI } from '../../..';
12
-
13
- import { UsersAPI } from '../../..';
14
- import DoctorAdd from '../../../doctor/components/doctor-add/doctor-add';
15
- import StaffAdd from '../../../staff/components/staff-add/staff-add';
16
-
17
- const { Title } = Typography;
18
-
19
- const { Option } = Select;
20
-
21
- const UserAdd = ({ model, callback, edit, history, formContent, match, additional_queries, props, mode = 'Add', attributes }) => {
22
- /**Getting user data */
23
- const { user = {} } = useContext(GlobalContext);
24
- // let mode = 'Add';
25
-
26
- const [disabled, setDisabled] = useState(true);
27
-
28
- const [selectedOption, setSelectedOption] = useState(null);
29
- // for selected branches
30
- const [selectedBranches, setSelectedBranches] = useState([]);
31
-
32
- // for default branch
33
- // const [defaultBranch, setDefaultBranch] = useState(null);
34
- //Need to check this condition
35
- const [authentication, setAuthentication] = useState(true);
36
-
37
- /**To store user values */
38
- const [users, setUsers] = useState([]);
39
- const [doctorID, setDoctorID] = useState(false);
40
- const [selectedDoctor, setSelectedDoctor] = useState(null);
41
- const [staffID, setStaffID] = useState(false);
42
- const [selectedStaff, setSelectedStaff] = useState(null);
43
- const [staffList, setStaffList] = useState([]);
44
- /**Converting to JSON */
45
- const firmDetails = safeJSON(user?.firm?.f_otherdetails1) ?? {};
46
-
47
- /**Variable for cheaking mandatory condition of mobile*/
48
- let mobileRequired;
49
-
50
- /**If mode is mobile and fa is 'MND' or 'USR' then mobile is mandatory */
51
- if (((firmDetails && firmDetails.FA === 'MND') || (firmDetails && firmDetails.FA === 'USR')) && firmDetails.mode === 'mobile') {
52
- mobileRequired = true;
53
- } else {
54
- mobileRequired = false;
55
- }
56
-
57
- if (formContent?.id) {
58
- mode = 'Edit';
59
- } else if (formContent?.copy) {
60
- mode = 'Copy';
61
- }
62
-
63
- if (formContent?.attributes) {
64
- if (typeof formContent.attributes === 'string') {
65
- if (formContent.attributes !== '') {
66
- formContent.attributes = JSON.parse(formContent.attributes);
67
- } else {
68
- if (formContent) {
69
- formContent.attributes = {};
70
- }
71
- }
72
- }
73
- } else {
74
- if (formContent) {
75
- formContent.attributes = {};
76
- }
77
- }
78
-
79
- const [loading, setLoading] = useState(true);
80
- // user type state
81
- const [userType, setUserType] = useState('general');
82
- // state for branches list
83
- const [branches, setBranches] = useState([]);
84
- // designation list state
85
- const [designations, setDesignations] = useState([]);
86
- // department list state
87
- const [departments, setDepartments] = useState([]);
88
- // doctor list state
89
- const [doctorList, setDoctorList] = useState([]);
90
- // for role list
91
- const [roles, setRoles] = useState([]);
92
-
93
- const [form] = Form.useForm();
94
-
95
- const [body, setBody] = useState(formContent);
96
-
97
- const [isPasswordVisible, setIsPasswordVisible] = useState(false);
98
-
99
- // state for doctor and staff visibility
100
- const [doctorVisible, setDoctorVisible] = useState(false);
101
- const [staffVisible, setStaffVisible] = useState(false);
102
-
103
- const formData = {
104
- ...body,
105
- /**If panel is open then takes password in body */
106
- password: !isPasswordVisible ? '' : body.password,
107
- };
108
-
109
- let passwordRegex;
110
- let passwordRegexMessage;
111
-
112
- if (props && props?.passwordRegex && props?.passwordRegexMessage) {
113
- passwordRegex = props.passwordRegex;
114
- passwordRegexMessage = props.passwordRegexMessage;
115
- } else if (process.env.REACT_APP_PASSWORD_REGEX && process.env.REACT_APP_PASSWORD_REGEX_MESSAGE) {
116
- passwordRegex = process.env.REACT_APP_PASSWORD_REGEX;
117
- passwordRegexMessage = process.env.REACT_APP_PASSWORD_REGEX_MESSAGE;
118
- } else {
119
- passwordRegex = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[!@#$%^&*(),.?":{}|<>])[A-Za-z\d!@#$%^&*(),.?":{}|<>]{8,}$/;
120
- passwordRegexMessage =
121
- 'Password must be at least 8 characters long and contain atleast one uppercase letter, one lowercase letter, one digit and one special character';
122
- }
123
-
124
- useEffect(() => {
125
- if (!loading && formContent) {
126
- form.resetFields(); // clear previous values
127
- form.setFieldsValue(formContent);
128
- }
129
- }, [loading, formContent]);
130
-
131
- useEffect(() => {
132
- if (formContent?.auth_user) {
133
- setSelectedOption({
134
- value: formContent.auth_user,
135
- label: formContent.auth_user, // Add a helper function to capitalize
136
- });
137
- }
138
- }, [formContent?.auth_user]);
139
-
140
- useEffect(() => {
141
- loadUsers();
142
-
143
- setLoading(false);
144
-
145
- if (firmDetails) {
146
- /**if firmmas.otherdetails - 2FA == MND, then, 2FA option will be enabled by default and read-only */
147
- if (firmDetails.FA == 'MND') {
148
- setAuthentication(true);
149
-
150
- setDisabled(true);
151
-
152
- /**if firmmas.otherdetails - 2FA == OPT, then, 2FA option will be enabled by default and editable */
153
- } else if (firmDetails.FA == 'USR') {
154
- /** If user has FA set to false , then disable authentication */
155
- if (formContent?.FA !== undefined) {
156
- setAuthentication(formContent?.FA);
157
- }
158
- setDisabled(true);
159
-
160
- /**if firmmas.otherdetails - 2FA == NAP, then, 2FA option will be disabled by default and read-only*/
161
- } else if (firmDetails.FA == 'NAP') {
162
- setAuthentication(false);
163
-
164
- setDisabled(true);
165
- }
166
- }
167
- }, []);
168
-
169
- useEffect(() => {
170
- if (!loading && formContent?.role_id && roles.length > 0) {
171
- const roleId = Number(formContent.role_id);
172
-
173
- if (!Number.isNaN(roleId)) {
174
- form.setFieldsValue({ role_id: roleId });
175
- }
176
- }
177
- }, [loading, formContent, roles]);
178
-
179
- /**
180
- *Define the options dynamically
181
- */
182
- const getUserTypeOptions = () => [
183
- { label: 'General', value: 'GEN' },
184
- { label: 'Doctor', value: 'RAD' },
185
- { label: 'Radiographer', value: 'TECH' },
186
- { label: 'Staff', value: 'STAFF' },
187
- ];
188
-
189
- /**
190
- * Get Branch List
191
- */
192
- const getBranches = () => {
193
- setLoading(true);
194
- UsersAPI.getBranches().then(async (result) => {
195
- const details = await result.result.map((ele) => {
196
- return {
197
- ...ele,
198
- ...(ele.br_otherdet1 ? JSON.parse(ele.br_otherdet1) : {}),
199
- };
200
- });
201
- setBranches(details);
202
- setLoading(false);
203
- });
204
- };
205
-
206
- /** Get Designation List */
207
- const getDesignations = () => {
208
- setLoading(true);
209
- UsersAPI.getDesignations()
210
- .then((result) => {
211
- if (result?.success && Array.isArray(result.result)) {
212
- const details = result.result.map((ele) => ({
213
- label: ele.dg_desc?.trim() || '',
214
- value: ele.dg_code,
215
- }));
216
- setDesignations(details);
217
- } else {
218
- setDesignations([]);
219
- }
220
- })
221
- .catch((error) => {
222
- setDesignations([]);
223
- })
224
- .finally(() => setLoading(false));
225
- };
226
-
227
- /**
228
- * get role lists
229
- */
230
- function getRoles() {
231
- RolesAPI.getRole()
232
- .then((res) => {
233
- const activeRoles = Array.isArray(res.result) ? res.result.filter((r) => r.active === 'Y') : [];
234
- setRoles(activeRoles);
235
- })
236
- .catch(() => setRoles([]));
237
- }
238
-
239
- /** Get Department List */
240
- const getDepartments = () => {
241
- setLoading(true);
242
- UsersAPI.getDepartments()
243
- .then((result) => {
244
- if (result?.success && Array.isArray(result.result)) {
245
- const details = result.result.map((ele) => ({
246
- label: ele.dp_desc?.trim() || '',
247
- value: ele.dp_id,
248
- }));
249
- setDepartments(details);
250
- } else {
251
- setDepartments([]);
252
- }
253
- })
254
- .catch((error) => {
255
- setDepartments([]);
256
- })
257
- .finally(() => setLoading(false));
258
- };
259
-
260
- /** Get Doctor List */
261
- const getDoctors = () => {
262
- UsersAPI.getDoctors()
263
- .then((res) => {
264
- if (res?.success && Array.isArray(res.result)) {
265
- const list = res.result.map((doc) => ({
266
- label: `${doc.do_name} (${doc.do_code})`,
267
- value: doc.do_code,
268
- }));
269
- setDoctorList(list);
270
- }
271
- })
272
- .catch((err) => console.error('Doctor API Error:', err));
273
- };
274
- /** Get staff List */
275
- const getStaff = () => {
276
- UsersAPI.getAllStaff()
277
- .then((res) => {
278
- if (Array.isArray(res)) {
279
- const list = res.map((staff) => ({
280
- label: `${staff.shortName || 'No Name'} (${staff.id})`,
281
- value: staff.id,
282
- }));
283
-
284
- setStaffList(list);
285
- } else {
286
- console.error('API did not return an array!');
287
- }
288
- })
289
- .catch((err) => console.error('staff API Error:', err));
290
- };
291
-
292
- // Function to handle user type change
293
- const handleUserTypeChange = (value) => {
294
- setUserType(value);
295
-
296
- if (value === 'RAD') {
297
- getDoctors(); // load doctor list
298
- } else {
299
- form.setFieldsValue({ default_code: undefined });
300
- }
301
- if (value === 'STAFF') {
302
- getStaff(); // load staff list
303
- } else {
304
- form.setFieldsValue({ staff_code: undefined });
305
- }
306
- };
307
-
308
- useEffect(() => {
309
- getBranches();
310
- getDesignations();
311
- getDepartments();
312
- getRoles();
313
- getDoctors(); // load doctor list
314
- getStaff();
315
- }, []);
316
-
317
- useEffect(() => {
318
- if (formContent && formContent.user_type) {
319
- form.setFieldsValue({ user_type: formContent.user_type });
320
- setUserType(formContent.user_type);
321
-
322
- if (formContent.user_type === 'RAD' && formContent.doctor_code) {
323
- form.setFieldsValue({ default_code: formContent.doctor_code });
324
- }
325
- if (formContent.user_type === 'STAFF' && formContent.staff_code) {
326
- form.setFieldsValue({ staff_code: formContent.staff_code });
327
- }
328
- }
329
- if (!formContent) return;
330
-
331
- const org =
332
- typeof formContent.organization_details === 'string' ? JSON.parse(formContent.organization_details) : formContent.organization_details;
333
-
334
- // normalize branch ids to NUMBER
335
- const branchIds = (org?.branch_ids || []).map(Number);
336
-
337
- // find default branch pointer
338
- const defaultBranchObj = org?.branch?.find((br) => br.defaultBranch);
339
-
340
- // extract dbPtr (branch code)
341
- const defaultBranchCode = defaultBranchObj?.branch_id ? Number(defaultBranchObj.branch_id) : undefined;
342
-
343
- // state (for filtering)
344
- setSelectedBranches(branchIds);
345
-
346
- // form values
347
- form.setFieldsValue({
348
- selectedBranches: branchIds,
349
- defaultBranch: defaultBranchCode,
350
- });
351
- }, [formContent, form]);
352
- // Generate branch options for Select component
353
- const branchOptions = branches.map((branch) => ({
354
- label: branch.br_desc,
355
- value: branch.br_code,
356
- }));
357
-
358
- /**
359
- * Submit values
360
- */
361
- const onSubmit = (values) => {
362
- const mobileData = values.mobile;
363
-
364
- const mobileWithCountryCode = `+${mobileData.code.dialCode}${mobileData.value}`;
365
-
366
- values.defaultBranch = String(values.defaultBranch);
367
-
368
- /**If PanelOpen is open and edit mode then password will be existing password else new password*/
369
- if (!isPasswordVisible && mode === 'Edit') {
370
- values.password = body.password;
371
- }
372
- values.user_type = values.user_type;
373
-
374
- if (values.user_type === 'RAD') {
375
- values.doctor_code = values.default_code;
376
- } else {
377
- values.doctor_code = null;
378
- }
379
- if (values.user_type === 'STAFF') {
380
- values.staff_code = values.staff_code;
381
- } else {
382
- values.staff_code = null;
383
- }
384
- values = {
385
- ...values,
386
- auth_type: 'LDAP',
387
- mobile: mobileWithCountryCode,
388
- FA: formContent?.FA === false ? false : authentication,
389
-
390
- };
391
-
392
- setLoading(true);
393
-
394
- let id = formContent?.id;
395
- if (props?.ldap && selectedOption && selectedOption.value) {
396
- values = {
397
- ...values,
398
-
399
- addAllBranches: props.ldap.addAllBranches,
400
- auth_user: selectedOption.value,
401
- auth_type: 'LDAP',
402
- FA: formContent?.FA === false ? false : authentication,
403
- };
404
- }
405
-
406
- if (values.attributes && typeof values === 'object') {
407
- values = {
408
- ...values,
409
-
410
- auth_type: 'LDAP',
411
-
412
- attributes: JSON.stringify(values.attributes),
413
- };
414
- }
415
-
416
- if (id) {
417
- // Update of model
418
-
419
- UsersAPI.updateUser({ id, formBody: values }).then((result) => {
420
- if (result.success) message.success(result.message);
421
- else message.error(result.message);
422
-
423
- setLoading(false);
424
-
425
- callback();
426
- });
427
- } else {
428
- // Append the additional queries to the object
429
- // additional_queries.forEach(({ field, value }) => {
430
- // values[field] = value;
431
- // });
432
- if (Array.isArray(additional_queries)) {
433
- additional_queries.forEach(({ field, value }) => {
434
- values[field] = value;
435
- });
436
- }
437
-
438
- // add new model
439
- UsersAPI.create(values).then((result) => {
440
- setLoading(false);
441
-
442
- if (result.success) {
443
- message.success(result.message);
444
- // close modal
445
- callback();
446
- } else {
447
- message.error(result.message);
448
- }
449
- });
450
- }
451
- };
452
-
453
- /**
454
- * Function on handle change
455
- * @param {*} selected
456
- */
457
- const handleCheackChange = (e) => {
458
- setIsPasswordVisible(e.target.checked);
459
- };
460
-
461
- function changeView(result) {
462
- setAuthentication(result);
463
- }
464
-
465
- /**
466
- * Function to add load userrs
467
- */
468
- function loadUsers() {
469
- // UsersAPI.getLdapUsers().then((result) => {
470
- // setUsers(result.result);
471
- // });
472
- }
473
-
474
- // Transform array into react-select options
475
- let options = users.map((item) => ({
476
- value: item.name,
477
- label: item.name, // Capitalize the first letter
478
- }));
479
-
480
- /**
481
- * Function on handle change
482
- * @param {*} selected
483
- */
484
- const handleChange = (selected) => {
485
- setSelectedOption(selected);
486
- };
487
- /**
488
- *
489
- * @param {*} inputValue
490
- * @param {*} callback
491
- */
492
-
493
- const loadOptions = (inputValue, callback) => {
494
- // Filter options based on input
495
- const filteredOptions = options.filter((option) => option.label.toLowerCase().includes(inputValue.toLowerCase()));
496
- callback(filteredOptions);
497
- };
498
-
499
- return (
500
- <section className="collection-add">
501
- <Title level={4}>{mode} User</Title>
502
-
503
- {loading ? (
504
- <Skeleton />
505
- ) : (
506
- <Form initialValues={formData} form={form} layout="vertical" onFinish={onSubmit}>
507
- {/* user type */}
508
- <Row gutter={16}>
509
- <Col span={6}>
510
- <Form.Item
511
- name="user_type"
512
- label="User Type"
513
- allowClear
514
- showSearch
515
- initialValue="GEN"
516
- rules={[{ required: true, message: 'Please select a user type' }]}
517
- >
518
- <Select options={getUserTypeOptions()} onChange={handleUserTypeChange} />
519
- </Form.Item>
520
- </Col>
521
- <Col span={12}>
522
- {/* username */}
523
- <Form.Item name={'name'} label="Name" rules={[{ required: true, message: 'Please enter your user name' }]}>
524
- <Input placeholder="Enter Name" autoFocus />
525
- </Form.Item>
526
- </Col>
527
- <Col span={6}>
528
- {' '}
529
- {/* Show extra dropdown only if user type is Doctor */}
530
- {userType === 'RAD' && (
531
- <Form.Item
532
- name="default_code"
533
- preserve={false}
534
- label="Default Code"
535
- rules={[{ required: true, message: 'Please select a default code' }]}
536
- >
537
- <Select
538
- placeholder="Select Code"
539
- options={doctorList}
540
- showSearch
541
- optionFilterProp="label"
542
- onChange={(value) => {
543
- form.setFieldsValue({ default_code: value });
544
- }}
545
- dropdownRender={(menu) => (
546
- <>
547
- {menu}
548
- <div
549
- style={{
550
- padding: '8px',
551
- cursor: 'pointer',
552
- borderTop: '1px solid #f0f0f0',
553
- color: '#1890ff',
554
- }}
555
- onClick={() => setDoctorVisible(true)}
556
- >
557
- + Add New Doctor
558
- </div>
559
- </>
560
- )}
561
- />
562
- </Form.Item>
563
- )}
564
- {userType === 'STAFF' && (
565
- <Form.Item name="staff_code" label="Staff Code" rules={[{ required: true, message: 'Please select a staff code' }]}>
566
- <Select
567
- placeholder="Select Code"
568
- options={staffList}
569
- showSearch
570
- optionFilterProp="label"
571
- onChange={(value) => {
572
- form.setFieldsValue({ staff_code: value });
573
- }}
574
- dropdownRender={(menu) => (
575
- <>
576
- {menu}
577
- <div
578
- style={{
579
- padding: '8px',
580
- cursor: 'pointer',
581
- borderTop: '1px solid #f0f0f0',
582
- color: '#1890ff',
583
- }}
584
- onClick={() => setStaffVisible(true)}
585
- >
586
- + Add New Staff
587
- </div>
588
- </>
589
- )}
590
- />
591
- </Form.Item>
592
- )}
593
- </Col>
594
- </Row>
595
- <Row gutter={16}>
596
- <Col span={8}>
597
- {/* email */}
598
- <Form.Item name={'email'} label="User Name / Email" rules={[{ required: true, message: 'Please enter your email' }]}>
599
- <Input placeholder="Enter Email Address" />
600
- </Form.Item>
601
- </Col>
602
-
603
- <Col span={8}>
604
- {/* Mobile */}
605
- <Form.Item
606
- name="mobile"
607
- label="Mobile"
608
- validateTrigger="onBlur"
609
- rules={[{ required: true, message: 'Mobile number required' }, { validator: phoneValidator }]}
610
- >
611
- <CountryPhoneInput defaultCountryCode={process.env.REACT_APP_COUNTRYCODE} enableSearch inputStyle={{ width: '100%' }} />
612
- </Form.Item>
613
- </Col>
614
- <Col span={8}>
615
- {/* Designation */}
616
- <Form.Item name="designation" label="Designation">
617
- <Select placeholder="Select Designation" options={designations} allowClear showSearch optionFilterProp="label" />
618
- </Form.Item>
619
- </Col>
620
- </Row>
621
- <Row gutter={16}>
622
- {' '}
623
- <Col span={8}>
624
- {/* Department */}
625
- <Form.Item name="department" label="Department">
626
- <Select placeholder="Select Department" options={departments} allowClear showSearch optionFilterProp="label" />
627
- </Form.Item>
628
- </Col>
629
- <Col span={8}>
630
- {/* Branch */}
631
- <Form.Item label="Branches" name="selectedBranches" rules={[{ required: true, message: 'Please select at least one branch' }]}>
632
- <Select
633
- mode="multiple"
634
- placeholder="Select Branches"
635
- options={branchOptions}
636
- allowClear
637
- showSearch
638
- optionFilterProp="label"
639
- onChange={(value) => {
640
- const normalized = value.map(Number);
641
- setSelectedBranches(normalized);
642
-
643
- const currentDefault = form.getFieldValue('defaultBranch');
644
- if (currentDefault && !normalized.includes(currentDefault)) {
645
- form.setFieldsValue({ defaultBranch: undefined });
646
- }
647
- }}
648
- />
649
- </Form.Item>
650
- </Col>
651
- <Col span={8}>
652
- {/* Default Branch */}
653
- <Form.Item label="Default Branch" name="defaultBranch" rules={[{ required: true, message: 'Please select default branch' }]}>
654
- <Select placeholder="Select Default Branch">
655
- {branchOptions
656
- .filter((opt) => selectedBranches.includes(Number(opt.value)))
657
- .map((opt) => (
658
- <Option key={opt.value} value={Number(opt.value)}>
659
- {opt.label}
660
- </Option>
661
- ))}
662
- </Select>
663
- </Form.Item>
664
- </Col>
665
- </Row>
666
- <Row gutter={16}>
667
- <Col span={8}>
668
- <Form.Item name="user_group" label="User Group" rules={[{ required: true, message: 'Please enter your user group' }]}>
669
- <Input placeholder="Enter User Group" />
670
- </Form.Item>
671
- </Col>
672
- <Col span={8}>
673
- {formContent?.id ? (
674
- <>
675
- {/* <Form.Item>
676
- <div style={{ display: 'flex', alignItems: 'center', gap: '8px' }}>
677
- <Checkbox onChange={handleCheackChange} />
678
- <span>Select the option if you want to change the password</span>
679
- </div>
680
- </Form.Item> */}
681
-
682
- {isPasswordVisible && (
683
- <Form.Item
684
- name="password"
685
- label="Password"
686
- rules={[
687
- { required: true, message: 'Please enter your password' },
688
- { pattern: passwordRegex, message: passwordRegexMessage },
689
- ]}
690
- >
691
- <Input.Password placeholder="Enter password" autoComplete="new-password" />
692
- </Form.Item>
693
- )}
694
- </>
695
- ) : (
696
- <Form.Item
697
- name="password"
698
- label="Password"
699
- rules={[
700
- {
701
- required: true,
702
- message: 'Please enter your password',
703
- },
704
- {
705
- pattern: new RegExp(passwordRegex),
706
- message: passwordRegexMessage,
707
- },
708
- ]}
709
- >
710
- <Input.Password visibilityToggle={false} placeholder="Enter password" autoComplete="new-password" />
711
- </Form.Item>
712
- )}
713
- </Col>
714
- {/* </Form.Item> */}
715
-
716
- {/* Path */}
717
- {/* <Form.Item name="password" label="Password"
718
- rules={[
719
- {
720
- required: true,
721
- message: 'Please enter your password',
722
- },
723
- {
724
- pattern: new RegExp(passwordRegex),
725
- message: passwordRegexMessage,
726
- },
727
- ]}>
728
- <Input.Password visibilityToggle={false} placeholder="Enter password" autoComplete='new-password' />
729
- </Form.Item> */}
730
- {/* Path Ends */}
731
-
732
- {/* Path */}
733
-
734
- {/* <Col span={8}>
735
- <Form.Item name="role_id" label="Role" rules={[{ required: true, message: 'Please select a Role' }]}>
736
- <Select placeholder="Select Role">
737
- {roles.map((role) => (
738
- <Option key={role.id} value={role.id}>
739
- {role.name}
740
- </Option>
741
- ))}
742
- </Select>
743
- </Form.Item>
744
- </Col> */}
745
-
746
- {/* <Form.Item name="mobile" label="Mobile" required={mobileRequired}>
747
- <Input placeholder="Enter Mobile" />
748
- </Form.Item> */}
749
-
750
- {props?.ldap && (
751
- <>
752
- <Form.Item name="auth_type" label="auth_type">
753
- <Input placeholder="Enter auth_type" value={'LDAP'} disabled />
754
-
755
- {/* <Select
756
-
757
- placeholder="Auth Type"
758
- defaultValue={'LDAP'}
759
- // value={formContent && formContent.auth_type?formContent.auth_type:'LDAP'}
760
- allowClear
761
- // style={{ width: '60%' }}
762
- >
763
- <Option value={props.user_type}>
764
- {props.user_type}
765
- </Option>
766
- </Select> */}
767
-
768
- {/* <div style={{ display: 'flex', justifyContent: 'space-between' }}>
769
-
770
- <div style={{ width: '40%' }}>
771
-
772
- </div>
773
-
774
-
775
-
776
- </div> */}
777
- </Form.Item>
778
-
779
- {/* Path */}
780
- <Form.Item name="auth_user" label="User Name" required>
781
- <Input placeholder="Enter User Name" />
782
- </Form.Item>
783
- </>
784
- )}
785
- </Row>
786
- <Row gutter={16}>
787
- <Col span={8}>
788
- <Form.Item>
789
- <div style={{ display: 'flex', alignItems: 'center', gap: '8px' }}>
790
- <Switch
791
- disabled={disabled}
792
- // defaultChecked={view}
793
- onChange={changeView}
794
- checked={authentication}
795
- // disabled={disabled}
796
- defaultChecked
797
- // checkedChildren={<OrderedListOutlined />}
798
- // unCheckedChildren={<PicCenterOutlined />}
799
- />
800
- <span>Enable Two Factor Authentication</span>
801
- </div>
802
- </Form.Item>
803
- </Col>
804
- <Col span={8}>
805
- {/* <label>User Status</label> */}
806
- <Form.Item
807
- name="active"
808
- valuePropName="checked"
809
- getValueFromEvent={(e) => (e.target.checked ? true : false)}
810
- getValueProps={(value) => ({ checked: value === true })}
811
- style={{ marginBottom: 0 }}
812
- >
813
- <Checkbox>Active</Checkbox>
814
- </Form.Item>
815
- </Col>
816
- </Row>
817
- {/* Path Ends */}
818
-
819
- {/* Path */}
820
- {/* <Form.Item name="active" label="Active" required>
821
- <Switch />
822
- </Form.Item> */}
823
- {/* Path Ends */}
824
-
825
- <Form.Item>
826
- <Button loading={loading} htmlType={'submit'} type="primary">
827
- Submit
828
- </Button>
829
- </Form.Item>
830
- </Form>
831
- )}
832
- {/* Render DoctorAdd OUTSIDE the Select */}
833
- <DoctorAdd
834
- visible={doctorVisible}
835
- onCancel={() => setDoctorVisible(false)}
836
- // attributes={attributes}
837
- doctorData={selectedDoctor}
838
- doctorId={doctorID}
839
- onSuccess={getDoctors}
840
- />
841
-
842
- <StaffAdd visible={staffVisible} onCancel={() => setStaffVisible(false)} staffData={selectedStaff} staffId={staffID} onSuccess={getStaff} />
843
- </section>
844
- );
845
- };
846
-
847
- export default UserAdd;
1
+ import React, { useState, useEffect, useContext } from 'react';
2
+
3
+ import { useLocation } from 'react-router-dom';
4
+
5
+ import { Skeleton, Typography, message, Switch, Form, Input, Select, Checkbox, Row, Col } from 'antd';
6
+
7
+ import AsyncSelect from 'react-select/async';
8
+
9
+ import { Table, Card, Button, JSONInput, GlobalContext, safeJSON, CountryPhoneInput, phoneValidator } from './../../../../lib/';
10
+
11
+ import { ModelsAPI, PagesAPI, RolesAPI } from '../../..';
12
+
13
+ import { UsersAPI } from '../../..';
14
+ import DoctorAdd from '../../../doctor/components/doctor-add/doctor-add';
15
+ import StaffAdd from '../../../staff/components/staff-add/staff-add';
16
+
17
+ const { Title } = Typography;
18
+
19
+ const { Option } = Select;
20
+
21
+ const UserAdd = ({ model, callback, edit, history, formContent, match, additional_queries, props, mode = 'Add', attributes }) => {
22
+ /**Getting user data */
23
+ const { user = {} } = useContext(GlobalContext);
24
+ // let mode = 'Add';
25
+
26
+ const [disabled, setDisabled] = useState(true);
27
+
28
+ const [selectedOption, setSelectedOption] = useState(null);
29
+ // for selected branches
30
+ const [selectedBranches, setSelectedBranches] = useState([]);
31
+
32
+ // for default branch
33
+ // const [defaultBranch, setDefaultBranch] = useState(null);
34
+ //Need to check this condition
35
+ const [authentication, setAuthentication] = useState(true);
36
+
37
+ /**To store user values */
38
+ const [users, setUsers] = useState([]);
39
+ const [doctorID, setDoctorID] = useState(false);
40
+ const [selectedDoctor, setSelectedDoctor] = useState(null);
41
+ const [staffID, setStaffID] = useState(false);
42
+ const [selectedStaff, setSelectedStaff] = useState(null);
43
+ const [staffList, setStaffList] = useState([]);
44
+ /**Converting to JSON */
45
+ const firmDetails = safeJSON(user?.firm?.f_otherdetails1) ?? {};
46
+
47
+ /**Variable for cheaking mandatory condition of mobile*/
48
+ let mobileRequired;
49
+
50
+ /**If mode is mobile and fa is 'MND' or 'USR' then mobile is mandatory */
51
+ if (((firmDetails && firmDetails.FA === 'MND') || (firmDetails && firmDetails.FA === 'USR')) && firmDetails.mode === 'mobile') {
52
+ mobileRequired = true;
53
+ } else {
54
+ mobileRequired = false;
55
+ }
56
+
57
+ if (formContent?.id) {
58
+ mode = 'Edit';
59
+ } else if (formContent?.copy) {
60
+ mode = 'Copy';
61
+ }
62
+
63
+ if (formContent?.attributes) {
64
+ if (typeof formContent.attributes === 'string') {
65
+ if (formContent.attributes !== '') {
66
+ formContent.attributes = JSON.parse(formContent.attributes);
67
+ } else {
68
+ if (formContent) {
69
+ formContent.attributes = {};
70
+ }
71
+ }
72
+ }
73
+ } else {
74
+ if (formContent) {
75
+ formContent.attributes = {};
76
+ }
77
+ }
78
+
79
+ const [loading, setLoading] = useState(true);
80
+ // user type state
81
+ const [userType, setUserType] = useState('general');
82
+ // state for branches list
83
+ const [branches, setBranches] = useState([]);
84
+ // designation list state
85
+ const [designations, setDesignations] = useState([]);
86
+ // department list state
87
+ const [departments, setDepartments] = useState([]);
88
+ // doctor list state
89
+ const [doctorList, setDoctorList] = useState([]);
90
+ // for role list
91
+ const [roles, setRoles] = useState([]);
92
+
93
+ const [form] = Form.useForm();
94
+
95
+ const [body, setBody] = useState(formContent);
96
+
97
+ const [isPasswordVisible, setIsPasswordVisible] = useState(false);
98
+
99
+ // state for doctor and staff visibility
100
+ const [doctorVisible, setDoctorVisible] = useState(false);
101
+ const [staffVisible, setStaffVisible] = useState(false);
102
+
103
+ const formData = {
104
+ ...body,
105
+ /**If panel is open then takes password in body */
106
+ password: !isPasswordVisible ? '' : body.password,
107
+ };
108
+
109
+ let passwordRegex;
110
+ let passwordRegexMessage;
111
+
112
+ if (props && props?.passwordRegex && props?.passwordRegexMessage) {
113
+ passwordRegex = props.passwordRegex;
114
+ passwordRegexMessage = props.passwordRegexMessage;
115
+ } else if (process.env.REACT_APP_PASSWORD_REGEX && process.env.REACT_APP_PASSWORD_REGEX_MESSAGE) {
116
+ passwordRegex = process.env.REACT_APP_PASSWORD_REGEX;
117
+ passwordRegexMessage = process.env.REACT_APP_PASSWORD_REGEX_MESSAGE;
118
+ } else {
119
+ passwordRegex = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[!@#$%^&*(),.?":{}|<>])[A-Za-z\d!@#$%^&*(),.?":{}|<>]{8,}$/;
120
+ passwordRegexMessage =
121
+ 'Password must be at least 8 characters long and contain atleast one uppercase letter, one lowercase letter, one digit and one special character';
122
+ }
123
+
124
+ useEffect(() => {
125
+ if (!loading && formContent) {
126
+ form.resetFields(); // clear previous values
127
+ form.setFieldsValue(formContent);
128
+ }
129
+ }, [loading, formContent]);
130
+
131
+ useEffect(() => {
132
+ if (formContent?.auth_user) {
133
+ setSelectedOption({
134
+ value: formContent.auth_user,
135
+ label: formContent.auth_user, // Add a helper function to capitalize
136
+ });
137
+ }
138
+ }, [formContent?.auth_user]);
139
+
140
+ useEffect(() => {
141
+ loadUsers();
142
+
143
+ setLoading(false);
144
+
145
+ if (firmDetails) {
146
+ /**if firmmas.otherdetails - 2FA == MND, then, 2FA option will be enabled by default and read-only */
147
+ if (firmDetails.FA == 'MND') {
148
+ setAuthentication(true);
149
+
150
+ setDisabled(true);
151
+
152
+ /**if firmmas.otherdetails - 2FA == OPT, then, 2FA option will be enabled by default and editable */
153
+ } else if (firmDetails.FA == 'USR') {
154
+ /** If user has FA set to false , then disable authentication */
155
+ if (formContent?.FA !== undefined) {
156
+ setAuthentication(formContent?.FA);
157
+ }
158
+ setDisabled(true);
159
+
160
+ /**if firmmas.otherdetails - 2FA == NAP, then, 2FA option will be disabled by default and read-only*/
161
+ } else if (firmDetails.FA == 'NAP') {
162
+ setAuthentication(false);
163
+
164
+ setDisabled(true);
165
+ }
166
+ }
167
+ }, []);
168
+
169
+ useEffect(() => {
170
+ if (!loading && formContent?.role_id && roles.length > 0) {
171
+ const roleId = Number(formContent.role_id);
172
+
173
+ if (!Number.isNaN(roleId)) {
174
+ form.setFieldsValue({ role_id: roleId });
175
+ }
176
+ }
177
+ }, [loading, formContent, roles]);
178
+
179
+ /**
180
+ *Define the options dynamically
181
+ */
182
+ const getUserTypeOptions = () => [
183
+ { label: 'General', value: 'GEN' },
184
+ { label: 'Doctor', value: 'RAD' },
185
+ { label: 'Radiographer', value: 'TECH' },
186
+ { label: 'Staff', value: 'STAFF' },
187
+ ];
188
+
189
+ /**
190
+ * Get Branch List
191
+ */
192
+ const getBranches = () => {
193
+ setLoading(true);
194
+ UsersAPI.getBranches().then(async (result) => {
195
+ const details = await result.result.map((ele) => {
196
+ return {
197
+ ...ele,
198
+ ...(ele.br_otherdet1 ? JSON.parse(ele.br_otherdet1) : {}),
199
+ };
200
+ });
201
+ setBranches(details);
202
+ setLoading(false);
203
+ });
204
+ };
205
+
206
+ /** Get Designation List */
207
+ const getDesignations = () => {
208
+ setLoading(true);
209
+ UsersAPI.getDesignations()
210
+ .then((result) => {
211
+ if (result?.success && Array.isArray(result.result)) {
212
+ const details = result.result.map((ele) => ({
213
+ label: ele.dg_desc?.trim() || '',
214
+ value: ele.dg_code,
215
+ }));
216
+ setDesignations(details);
217
+ } else {
218
+ setDesignations([]);
219
+ }
220
+ })
221
+ .catch((error) => {
222
+ setDesignations([]);
223
+ })
224
+ .finally(() => setLoading(false));
225
+ };
226
+
227
+ /**
228
+ * get role lists
229
+ */
230
+ function getRoles() {
231
+ RolesAPI.getRole()
232
+ .then((res) => {
233
+ const activeRoles = Array.isArray(res.result) ? res.result.filter((r) => r.active === 'Y') : [];
234
+ setRoles(activeRoles);
235
+ })
236
+ .catch(() => setRoles([]));
237
+ }
238
+
239
+ /** Get Department List */
240
+ const getDepartments = () => {
241
+ setLoading(true);
242
+ UsersAPI.getDepartments()
243
+ .then((result) => {
244
+ if (result?.success && Array.isArray(result.result)) {
245
+ const details = result.result.map((ele) => ({
246
+ label: ele.dp_desc?.trim() || '',
247
+ value: ele.dp_id,
248
+ }));
249
+ setDepartments(details);
250
+ } else {
251
+ setDepartments([]);
252
+ }
253
+ })
254
+ .catch((error) => {
255
+ setDepartments([]);
256
+ })
257
+ .finally(() => setLoading(false));
258
+ };
259
+
260
+ /** Get Doctor List */
261
+ const getDoctors = () => {
262
+ UsersAPI.getDoctors()
263
+ .then((res) => {
264
+ if (res?.success && Array.isArray(res.result)) {
265
+ const list = res.result.map((doc) => ({
266
+ label: `${doc.do_name} (${doc.do_code})`,
267
+ value: doc.do_code,
268
+ }));
269
+ setDoctorList(list);
270
+ }
271
+ })
272
+ .catch((err) => console.error('Doctor API Error:', err));
273
+ };
274
+ /** Get staff List */
275
+ const getStaff = () => {
276
+ UsersAPI.getAllStaff()
277
+ .then((res) => {
278
+ if (Array.isArray(res)) {
279
+ const list = res.map((staff) => ({
280
+ label: `${staff.shortName || 'No Name'} (${staff.id})`,
281
+ value: staff.id,
282
+ }));
283
+
284
+ setStaffList(list);
285
+ } else {
286
+ console.error('API did not return an array!');
287
+ }
288
+ })
289
+ .catch((err) => console.error('staff API Error:', err));
290
+ };
291
+
292
+ // Function to handle user type change
293
+ const handleUserTypeChange = (value) => {
294
+ setUserType(value);
295
+
296
+ if (value === 'RAD') {
297
+ getDoctors(); // load doctor list
298
+ } else {
299
+ form.setFieldsValue({ default_code: undefined });
300
+ }
301
+ if (value === 'STAFF') {
302
+ getStaff(); // load staff list
303
+ } else {
304
+ form.setFieldsValue({ staff_code: undefined });
305
+ }
306
+ };
307
+
308
+ useEffect(() => {
309
+ getBranches();
310
+ getDesignations();
311
+ getDepartments();
312
+ getRoles();
313
+ getDoctors(); // load doctor list
314
+ getStaff();
315
+ }, []);
316
+
317
+ useEffect(() => {
318
+ if (formContent && formContent.user_type) {
319
+ form.setFieldsValue({ user_type: formContent.user_type });
320
+ setUserType(formContent.user_type);
321
+
322
+ if (formContent.user_type === 'RAD' && formContent.doctor_code) {
323
+ form.setFieldsValue({ default_code: formContent.doctor_code });
324
+ }
325
+ if (formContent.user_type === 'STAFF' && formContent.staff_code) {
326
+ form.setFieldsValue({ staff_code: formContent.staff_code });
327
+ }
328
+ }
329
+ if (!formContent) return;
330
+
331
+ const org =
332
+ typeof formContent.organization_details === 'string' ? JSON.parse(formContent.organization_details) : formContent.organization_details;
333
+
334
+ // normalize branch ids to NUMBER
335
+ const branchIds = (org?.branch_ids || []).map(Number);
336
+
337
+ // find default branch pointer
338
+ const defaultBranchObj = org?.branch?.find((br) => br.defaultBranch);
339
+
340
+ // extract dbPtr (branch code)
341
+ const defaultBranchCode = defaultBranchObj?.branch_id ? Number(defaultBranchObj.branch_id) : undefined;
342
+
343
+ // state (for filtering)
344
+ setSelectedBranches(branchIds);
345
+
346
+ // form values
347
+ form.setFieldsValue({
348
+ selectedBranches: branchIds,
349
+ defaultBranch: defaultBranchCode,
350
+ });
351
+ }, [formContent, form]);
352
+ // Generate branch options for Select component
353
+ const branchOptions = branches.map((branch) => ({
354
+ label: branch.br_desc,
355
+ value: branch.br_code,
356
+ }));
357
+
358
+ /**
359
+ * Submit values
360
+ */
361
+ const onSubmit = (values) => {
362
+ const mobileData = values.mobile;
363
+
364
+ const mobileWithCountryCode = `+${mobileData.code.dialCode}${mobileData.value}`;
365
+
366
+ values.defaultBranch = String(values.defaultBranch);
367
+
368
+ /**If PanelOpen is open and edit mode then password will be existing password else new password*/
369
+ if (!isPasswordVisible && mode === 'Edit') {
370
+ values.password = body.password;
371
+ }
372
+ values.user_type = values.user_type;
373
+
374
+ if (values.user_type === 'RAD') {
375
+ values.doctor_code = values.default_code;
376
+ } else {
377
+ values.doctor_code = null;
378
+ }
379
+ if (values.user_type === 'STAFF') {
380
+ values.staff_code = values.staff_code;
381
+ } else {
382
+ values.staff_code = null;
383
+ }
384
+ values = {
385
+ ...values,
386
+ auth_type: 'LDAP',
387
+ mobile: mobileWithCountryCode,
388
+ FA: formContent?.FA === false ? false : authentication,
389
+
390
+ };
391
+
392
+ setLoading(true);
393
+
394
+ let id = formContent?.id;
395
+ if (props?.ldap && selectedOption && selectedOption.value) {
396
+ values = {
397
+ ...values,
398
+
399
+ addAllBranches: props.ldap.addAllBranches,
400
+ auth_user: selectedOption.value,
401
+ auth_type: 'LDAP',
402
+ FA: formContent?.FA === false ? false : authentication,
403
+ };
404
+ }
405
+
406
+ if (values.attributes && typeof values === 'object') {
407
+ values = {
408
+ ...values,
409
+
410
+ auth_type: 'LDAP',
411
+
412
+ attributes: JSON.stringify(values.attributes),
413
+ };
414
+ }
415
+
416
+ if (id) {
417
+ // Update of model
418
+
419
+ UsersAPI.updateUser({ id, formBody: values }).then((result) => {
420
+ if (result.success) message.success(result.message);
421
+ else message.error(result.message);
422
+
423
+ setLoading(false);
424
+
425
+ callback();
426
+ });
427
+ } else {
428
+ // Append the additional queries to the object
429
+ // additional_queries.forEach(({ field, value }) => {
430
+ // values[field] = value;
431
+ // });
432
+ if (Array.isArray(additional_queries)) {
433
+ additional_queries.forEach(({ field, value }) => {
434
+ values[field] = value;
435
+ });
436
+ }
437
+
438
+ // add new model
439
+ UsersAPI.create(values).then((result) => {
440
+ setLoading(false);
441
+
442
+ if (result.success) {
443
+ message.success(result.message);
444
+ // close modal
445
+ callback();
446
+ } else {
447
+ message.error(result.message);
448
+ }
449
+ });
450
+ }
451
+ };
452
+
453
+ /**
454
+ * Function on handle change
455
+ * @param {*} selected
456
+ */
457
+ const handleCheackChange = (e) => {
458
+ setIsPasswordVisible(e.target.checked);
459
+ };
460
+
461
+ function changeView(result) {
462
+ setAuthentication(result);
463
+ }
464
+
465
+ /**
466
+ * Function to add load userrs
467
+ */
468
+ function loadUsers() {
469
+ // UsersAPI.getLdapUsers().then((result) => {
470
+ // setUsers(result.result);
471
+ // });
472
+ }
473
+
474
+ // Transform array into react-select options
475
+ let options = users.map((item) => ({
476
+ value: item.name,
477
+ label: item.name, // Capitalize the first letter
478
+ }));
479
+
480
+ /**
481
+ * Function on handle change
482
+ * @param {*} selected
483
+ */
484
+ const handleChange = (selected) => {
485
+ setSelectedOption(selected);
486
+ };
487
+ /**
488
+ *
489
+ * @param {*} inputValue
490
+ * @param {*} callback
491
+ */
492
+
493
+ const loadOptions = (inputValue, callback) => {
494
+ // Filter options based on input
495
+ const filteredOptions = options.filter((option) => option.label.toLowerCase().includes(inputValue.toLowerCase()));
496
+ callback(filteredOptions);
497
+ };
498
+
499
+ return (
500
+ <section className="collection-add">
501
+ <Title level={4}>{mode} User</Title>
502
+
503
+ {loading ? (
504
+ <Skeleton />
505
+ ) : (
506
+ <Form initialValues={formData} form={form} layout="vertical" onFinish={onSubmit}>
507
+ {/* user type */}
508
+ <Row gutter={16}>
509
+ <Col span={6}>
510
+ <Form.Item
511
+ name="user_type"
512
+ label="User Type"
513
+ allowClear
514
+ showSearch
515
+ initialValue="GEN"
516
+ rules={[{ required: true, message: 'Please select a user type' }]}
517
+ >
518
+ <Select options={getUserTypeOptions()} onChange={handleUserTypeChange} />
519
+ </Form.Item>
520
+ </Col>
521
+ <Col span={12}>
522
+ {/* username */}
523
+ <Form.Item name={'name'} label="Name" rules={[{ required: true, message: 'Please enter your user name' }]}>
524
+ <Input placeholder="Enter Name" autoFocus />
525
+ </Form.Item>
526
+ </Col>
527
+ <Col span={6}>
528
+ {' '}
529
+ {/* Show extra dropdown only if user type is Doctor */}
530
+ {userType === 'RAD' && (
531
+ <Form.Item
532
+ name="default_code"
533
+ preserve={false}
534
+ label="Default Code"
535
+ rules={[{ required: true, message: 'Please select a default code' }]}
536
+ >
537
+ <Select
538
+ placeholder="Select Code"
539
+ options={doctorList}
540
+ showSearch
541
+ optionFilterProp="label"
542
+ onChange={(value) => {
543
+ form.setFieldsValue({ default_code: value });
544
+ }}
545
+ dropdownRender={(menu) => (
546
+ <>
547
+ {menu}
548
+ <div
549
+ style={{
550
+ padding: '8px',
551
+ cursor: 'pointer',
552
+ borderTop: '1px solid #f0f0f0',
553
+ color: '#1890ff',
554
+ }}
555
+ onClick={() => setDoctorVisible(true)}
556
+ >
557
+ + Add New Doctor
558
+ </div>
559
+ </>
560
+ )}
561
+ />
562
+ </Form.Item>
563
+ )}
564
+ {userType === 'STAFF' && (
565
+ <Form.Item name="staff_code" label="Staff Code" rules={[{ required: true, message: 'Please select a staff code' }]}>
566
+ <Select
567
+ placeholder="Select Code"
568
+ options={staffList}
569
+ showSearch
570
+ optionFilterProp="label"
571
+ onChange={(value) => {
572
+ form.setFieldsValue({ staff_code: value });
573
+ }}
574
+ dropdownRender={(menu) => (
575
+ <>
576
+ {menu}
577
+ <div
578
+ style={{
579
+ padding: '8px',
580
+ cursor: 'pointer',
581
+ borderTop: '1px solid #f0f0f0',
582
+ color: '#1890ff',
583
+ }}
584
+ onClick={() => setStaffVisible(true)}
585
+ >
586
+ + Add New Staff
587
+ </div>
588
+ </>
589
+ )}
590
+ />
591
+ </Form.Item>
592
+ )}
593
+ </Col>
594
+ </Row>
595
+ <Row gutter={16}>
596
+ <Col span={8}>
597
+ {/* email */}
598
+ <Form.Item name={'email'} label="User Name / Email" rules={[{ required: true, message: 'Please enter your email' }]}>
599
+ <Input placeholder="Enter Email Address" />
600
+ </Form.Item>
601
+ </Col>
602
+
603
+ <Col span={8}>
604
+ {/* Mobile */}
605
+ <Form.Item
606
+ name="mobile"
607
+ label="Mobile"
608
+ validateTrigger="onBlur"
609
+ rules={[{ required: true, message: 'Mobile number required' }, { validator: phoneValidator }]}
610
+ >
611
+ <CountryPhoneInput defaultCountryCode={process.env.REACT_APP_COUNTRYCODE} enableSearch inputStyle={{ width: '100%' }} />
612
+ </Form.Item>
613
+ </Col>
614
+ <Col span={8}>
615
+ {/* Designation */}
616
+ <Form.Item name="designation" label="Designation">
617
+ <Select placeholder="Select Designation" options={designations} allowClear showSearch optionFilterProp="label" />
618
+ </Form.Item>
619
+ </Col>
620
+ </Row>
621
+ <Row gutter={16}>
622
+ {' '}
623
+ <Col span={8}>
624
+ {/* Department */}
625
+ <Form.Item name="department" label="Department">
626
+ <Select placeholder="Select Department" options={departments} allowClear showSearch optionFilterProp="label" />
627
+ </Form.Item>
628
+ </Col>
629
+ <Col span={8}>
630
+ {/* Branch */}
631
+ <Form.Item label="Branches" name="selectedBranches" rules={[{ required: true, message: 'Please select at least one branch' }]}>
632
+ <Select
633
+ mode="multiple"
634
+ placeholder="Select Branches"
635
+ options={branchOptions}
636
+ allowClear
637
+ showSearch
638
+ optionFilterProp="label"
639
+ onChange={(value) => {
640
+ const normalized = value.map(Number);
641
+ setSelectedBranches(normalized);
642
+
643
+ const currentDefault = form.getFieldValue('defaultBranch');
644
+ if (currentDefault && !normalized.includes(currentDefault)) {
645
+ form.setFieldsValue({ defaultBranch: undefined });
646
+ }
647
+ }}
648
+ />
649
+ </Form.Item>
650
+ </Col>
651
+ <Col span={8}>
652
+ {/* Default Branch */}
653
+ <Form.Item label="Default Branch" name="defaultBranch" rules={[{ required: true, message: 'Please select default branch' }]}>
654
+ <Select placeholder="Select Default Branch">
655
+ {branchOptions
656
+ .filter((opt) => selectedBranches.includes(Number(opt.value)))
657
+ .map((opt) => (
658
+ <Option key={opt.value} value={Number(opt.value)}>
659
+ {opt.label}
660
+ </Option>
661
+ ))}
662
+ </Select>
663
+ </Form.Item>
664
+ </Col>
665
+ </Row>
666
+ <Row gutter={16}>
667
+ <Col span={8}>
668
+ <Form.Item name="user_group" label="User Group" rules={[{ required: true, message: 'Please enter your user group' }]}>
669
+ <Input placeholder="Enter User Group" />
670
+ </Form.Item>
671
+ </Col>
672
+ <Col span={8}>
673
+ {formContent?.id ? (
674
+ <>
675
+ {/* <Form.Item>
676
+ <div style={{ display: 'flex', alignItems: 'center', gap: '8px' }}>
677
+ <Checkbox onChange={handleCheackChange} />
678
+ <span>Select the option if you want to change the password</span>
679
+ </div>
680
+ </Form.Item> */}
681
+
682
+ {isPasswordVisible && (
683
+ <Form.Item
684
+ name="password"
685
+ label="Password"
686
+ rules={[
687
+ { required: true, message: 'Please enter your password' },
688
+ { pattern: passwordRegex, message: passwordRegexMessage },
689
+ ]}
690
+ >
691
+ <Input.Password placeholder="Enter password" autoComplete="new-password" />
692
+ </Form.Item>
693
+ )}
694
+ </>
695
+ ) : (
696
+ <Form.Item
697
+ name="password"
698
+ label="Password"
699
+ rules={[
700
+ {
701
+ required: true,
702
+ message: 'Please enter your password',
703
+ },
704
+ {
705
+ pattern: new RegExp(passwordRegex),
706
+ message: passwordRegexMessage,
707
+ },
708
+ ]}
709
+ >
710
+ <Input.Password visibilityToggle={false} placeholder="Enter password" autoComplete="new-password" />
711
+ </Form.Item>
712
+ )}
713
+ </Col>
714
+ {/* </Form.Item> */}
715
+
716
+ {/* Path */}
717
+ {/* <Form.Item name="password" label="Password"
718
+ rules={[
719
+ {
720
+ required: true,
721
+ message: 'Please enter your password',
722
+ },
723
+ {
724
+ pattern: new RegExp(passwordRegex),
725
+ message: passwordRegexMessage,
726
+ },
727
+ ]}>
728
+ <Input.Password visibilityToggle={false} placeholder="Enter password" autoComplete='new-password' />
729
+ </Form.Item> */}
730
+ {/* Path Ends */}
731
+
732
+ {/* Path */}
733
+
734
+ {/* <Col span={8}>
735
+ <Form.Item name="role_id" label="Role" rules={[{ required: true, message: 'Please select a Role' }]}>
736
+ <Select placeholder="Select Role">
737
+ {roles.map((role) => (
738
+ <Option key={role.id} value={role.id}>
739
+ {role.name}
740
+ </Option>
741
+ ))}
742
+ </Select>
743
+ </Form.Item>
744
+ </Col> */}
745
+
746
+ {/* <Form.Item name="mobile" label="Mobile" required={mobileRequired}>
747
+ <Input placeholder="Enter Mobile" />
748
+ </Form.Item> */}
749
+
750
+ {props?.ldap && (
751
+ <>
752
+ <Form.Item name="auth_type" label="auth_type">
753
+ <Input placeholder="Enter auth_type" value={'LDAP'} disabled />
754
+
755
+ {/* <Select
756
+
757
+ placeholder="Auth Type"
758
+ defaultValue={'LDAP'}
759
+ // value={formContent && formContent.auth_type?formContent.auth_type:'LDAP'}
760
+ allowClear
761
+ // style={{ width: '60%' }}
762
+ >
763
+ <Option value={props.user_type}>
764
+ {props.user_type}
765
+ </Option>
766
+ </Select> */}
767
+
768
+ {/* <div style={{ display: 'flex', justifyContent: 'space-between' }}>
769
+
770
+ <div style={{ width: '40%' }}>
771
+
772
+ </div>
773
+
774
+
775
+
776
+ </div> */}
777
+ </Form.Item>
778
+
779
+ {/* Path */}
780
+ <Form.Item name="auth_user" label="User Name" required>
781
+ <Input placeholder="Enter User Name" />
782
+ </Form.Item>
783
+ </>
784
+ )}
785
+ </Row>
786
+ <Row gutter={16}>
787
+ <Col span={8}>
788
+ <Form.Item>
789
+ <div style={{ display: 'flex', alignItems: 'center', gap: '8px' }}>
790
+ <Switch
791
+ disabled={disabled}
792
+ // defaultChecked={view}
793
+ onChange={changeView}
794
+ checked={authentication}
795
+ // disabled={disabled}
796
+ defaultChecked
797
+ // checkedChildren={<OrderedListOutlined />}
798
+ // unCheckedChildren={<PicCenterOutlined />}
799
+ />
800
+ <span>Enable Two Factor Authentication</span>
801
+ </div>
802
+ </Form.Item>
803
+ </Col>
804
+ <Col span={8}>
805
+ {/* <label>User Status</label> */}
806
+ <Form.Item
807
+ name="active"
808
+ valuePropName="checked"
809
+ getValueFromEvent={(e) => (e.target.checked ? true : false)}
810
+ getValueProps={(value) => ({ checked: value === true })}
811
+ style={{ marginBottom: 0 }}
812
+ >
813
+ <Checkbox>Active</Checkbox>
814
+ </Form.Item>
815
+ </Col>
816
+ </Row>
817
+ {/* Path Ends */}
818
+
819
+ {/* Path */}
820
+ {/* <Form.Item name="active" label="Active" required>
821
+ <Switch />
822
+ </Form.Item> */}
823
+ {/* Path Ends */}
824
+
825
+ <Form.Item>
826
+ <Button loading={loading} htmlType={'submit'} type="primary">
827
+ Submit
828
+ </Button>
829
+ </Form.Item>
830
+ </Form>
831
+ )}
832
+ {/* Render DoctorAdd OUTSIDE the Select */}
833
+ <DoctorAdd
834
+ visible={doctorVisible}
835
+ onCancel={() => setDoctorVisible(false)}
836
+ // attributes={attributes}
837
+ doctorData={selectedDoctor}
838
+ doctorId={doctorID}
839
+ onSuccess={getDoctors}
840
+ />
841
+
842
+ <StaffAdd visible={staffVisible} onCancel={() => setStaffVisible(false)} staffData={selectedStaff} staffId={staffID} onSuccess={getStaff} />
843
+ </section>
844
+ );
845
+ };
846
+
847
+ export default UserAdd;