@argusoft/medplat-app-shell 1.0.6 → 1.0.8

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 (264) hide show
  1. package/package.json +139 -141
  2. package/src/GlobalErrorBoundary.jsx +31 -0
  3. package/src/SilentErrorFallback.jsx +68 -0
  4. package/src/TrackingProviderWrapper.jsx +40 -0
  5. package/src/_tests_/__mocks__/MockTranslationProvider.jsx +21 -0
  6. package/src/_tests_/__mocks__/ckeditor.js +45 -0
  7. package/src/_tests_/__mocks__/fileMock.js +1 -0
  8. package/src/_tests_/__mocks__/useranalytics.js +5 -0
  9. package/src/_tests_/views/components/Dashboard/DashboardUI.test.jsx +137 -0
  10. package/src/_tests_/views/components/Dashboard/DashboardUIMock.js +877 -0
  11. package/src/_tests_/views/components/ForgotPassword/ForgotPassword.test.jsx +314 -0
  12. package/src/_tests_/views/components/LocationDirective/LocationDirective.test.jsx.disable +229 -0
  13. package/src/_tests_/views/components/LocationDirective/mockLocationDirective.js +810 -0
  14. package/src/_tests_/views/components/LocationType/MockLocationType.js +42259 -0
  15. package/src/_tests_/views/components/LocationType/addlocationtype.test.jsx.disable +276 -0
  16. package/src/_tests_/views/components/LocationType/editlocationtype.test.jsx.disable +262 -0
  17. package/src/_tests_/views/components/LocationType/locationtype.test.jsx.disable +148 -0
  18. package/src/_tests_/views/components/Profile/UpdateProfileModalData.js +4396 -0
  19. package/src/_tests_/views/components/Profile/updateprofilemodal.test.jsx +282 -0
  20. package/src/_tests_/views/components/SideBar/MockSideBar.js +1379 -0
  21. package/src/_tests_/views/components/SideBar/SideBar.test.jsx +98 -0
  22. package/src/_tests_/views/components/SystemConfig/ManageSystemConfig/AddManageSystemConfig.test.jsx.disable +164 -0
  23. package/src/_tests_/views/components/SystemConfig/ManageSystemConfig/UpdateManageSystemConfig.test.jsx.disable +157 -0
  24. package/src/_tests_/views/components/SystemConfig/MockSystemConfig.js +1280 -0
  25. package/src/_tests_/views/components/SystemConfig/SystemConfig.test.jsx.disable +165 -0
  26. package/src/_tests_/views/components/login/Login.test.jsx +276 -0
  27. package/src/_tests_/views/components/login/MockAuthorise.js +2414 -0
  28. package/src/_tests_/views/components/login/ServiceResponse.js +595 -0
  29. package/src/_tests_/views/components/user/MockManageUser.js +7965 -0
  30. package/src/_tests_/views/components/user/manageuser.test.jsx.disable +989 -0
  31. package/src/_tests_/views/components/user/mockUsersData.js +582 -0
  32. package/src/assets/img/OASISLogin.png +0 -0
  33. package/src/assets/img/bahaarNew.png +0 -0
  34. package/src/assets/img/dnhdd4K.png +0 -0
  35. package/src/assets/img/govtofup.png +0 -0
  36. package/src/assets/img/sewarural4K.png +0 -0
  37. package/src/assets/img/techo4K.png +0 -0
  38. package/src/assets/img/up4K.png +0 -0
  39. package/src/common/HolidayList.jsx +573 -0
  40. package/src/common/MalaciaousInputUtil.js +23 -0
  41. package/src/common/SafeHtml.jsx +17 -0
  42. package/src/common/VersionManager.jsx +109 -0
  43. package/src/common/constants/PerformanceDashboard.js +514 -0
  44. package/src/common/constants/app.constant.js +781 -0
  45. package/src/common/constants/cccVerificationConstants.js +18 -0
  46. package/src/common/constants/fhsrConstant.js +33 -0
  47. package/src/common/constants/gvk-verification.constant.js +76 -0
  48. package/src/common/constants/search.constant.js +23 -0
  49. package/src/common/constants/teleconsulatationConstant.jsx +1339 -0
  50. package/src/common/directives/SearchTemplate.jsx +784 -0
  51. package/src/common/directives/SearchTemplate.scss +14 -0
  52. package/src/common/dynamicView/DynamicView.jsx +353 -0
  53. package/src/common/dynamicView/InputFieldComponent.jsx +1501 -0
  54. package/src/common/dynamicView/InputViewComponent.jsx +298 -0
  55. package/src/common/dynamicView/InputViewComponent.scss +15 -0
  56. package/src/common/env.js +5 -0
  57. package/src/common/filters/locationNameFilter.js +26 -0
  58. package/src/common/fontAwesomeIcons/FontAwesomeIcons.jsx +27 -0
  59. package/src/common/fontAwesomeIcons/FontAwesomeIconsNames.js +1968 -0
  60. package/src/common/fontPreferences/fontSizeProvider.jsx +34 -0
  61. package/src/common/fontPreferences/fontSizeSelector.jsx +116 -0
  62. package/src/common/getAssignedFeature/getAssignedFeature.js +32 -0
  63. package/src/common/interceptors/AxiosInterceptor.js +216 -0
  64. package/src/common/languageTranslator/TranslationContext.js +5 -0
  65. package/src/common/languageTranslator/TranslationProvider.jsx +24 -0
  66. package/src/common/languageTranslator/i18n.js +49 -0
  67. package/src/common/services/AuthenticateService.js +116 -0
  68. package/src/common/services/DownloadFile.js +35 -0
  69. package/src/common/services/ForgotPassword.js +18 -0
  70. package/src/common/services/FormConfiguratorService.js +195 -0
  71. package/src/common/services/GlobalApis.js +84 -0
  72. package/src/common/services/InterceptorNavigationService.js +17 -0
  73. package/src/common/services/LocationService.js +65 -0
  74. package/src/common/services/LocationType.js +11 -0
  75. package/src/common/services/QueryBuilder.js +36 -0
  76. package/src/common/services/Roles.js +28 -0
  77. package/src/common/services/SyncWithServer.js +15 -0
  78. package/src/common/services/SystemConfig.js +15 -0
  79. package/src/common/services/TranslationService.js +70 -0
  80. package/src/common/services/TwoFactorService.js +7 -0
  81. package/src/common/services/Users.js +91 -0
  82. package/src/common/services/Webtasks.js +27 -0
  83. package/src/common/services/util/Convert-pad-data-to-API-format.jsx +167 -0
  84. package/src/common/services/util/Convert-to-UI-format.jsx +82 -0
  85. package/src/common/services/util/EmptyPrescriptionPadData.jsx +11 -0
  86. package/src/common/services/util/GeneralUtil.js +456 -0
  87. package/src/common/services/util/Prescription-pad-util.js +339 -0
  88. package/src/common/services/util/PrescriptionPadData.js +67 -0
  89. package/src/common/services/util/PrescriptionpadCommonUtil.js +96 -0
  90. package/src/common/services/util/ReportFieldUtil.jsx +398 -0
  91. package/src/common/services/util/WebSocketContext.jsx +261 -0
  92. package/src/common/syncWithServer/SyncWithServerDialog.jsx +170 -0
  93. package/src/common/syncWithServer/SyncWithServerDialogSkeleton.jsx +67 -0
  94. package/src/common/tests/CustomWrapper.jsx +49 -0
  95. package/src/common/tests/TranslationWrapper.jsx +38 -0
  96. package/src/common/themeProvider/ColorInputs.jsx +97 -0
  97. package/src/common/themeProvider/EditableColorInput.jsx +128 -0
  98. package/src/common/themeProvider/ThemeEditor.jsx +319 -0
  99. package/src/common/themeProvider/ThemeProvider.jsx +210 -0
  100. package/src/common/themeProvider/themeConfig.js +558 -0
  101. package/src/common/toaster/toaster.jsx +30 -0
  102. package/src/firebaseConfig.js +24 -0
  103. package/src/global.scss +221 -0
  104. package/src/hooks/.gitkeep +0 -0
  105. package/src/hooks/useAESEncryption.js +56 -0
  106. package/src/hooks/useCaching.js +43 -0
  107. package/src/hooks/useDebounce.js +34 -0
  108. package/src/hooks/useDebounceFn.js +50 -0
  109. package/src/hooks/useDownloadPdf.js +358 -0
  110. package/src/hooks/useDownloadXlsx.js +55 -0
  111. package/src/hooks/useListValueFieldValues.js +30 -0
  112. package/src/hooks/useLocationHierarchies.js +63 -0
  113. package/src/hooks/useLocationHierarchyTranslate.js +16 -0
  114. package/src/hooks/useOnline.js +27 -0
  115. package/src/hooks/usePagination.js +63 -0
  116. package/src/hooks/useRefreshToken.js +87 -0
  117. package/src/hooks/useScript.js +25 -0
  118. package/src/hooks/useStopwatch.js +75 -0
  119. package/src/hooks/useTrackEvent.js +22 -0
  120. package/src/hooks/useWebAudioRecorder.js +115 -0
  121. package/src/layout/LoaderComponet.jsx +22 -0
  122. package/src/layout/LoaderContext.jsx +29 -0
  123. package/src/layout/mainLayout/AdaptiveZoom.jsx +27 -0
  124. package/src/layout/mainLayout/Chatbot.jsx +243 -0
  125. package/src/layout/mainLayout/Layout.jsx +445 -0
  126. package/src/layout/mainLayout/Profile/UpdateProfileModal.jsx +684 -0
  127. package/src/layout/mainLayout/header/LogoutModal.jsx +131 -0
  128. package/src/layout/mainLayout/header/Navbar.jsx +1677 -0
  129. package/src/layout/mainLayout/header/Navbar.scss +4 -0
  130. package/src/layout/mainLayout/header/index.js +0 -0
  131. package/src/layout/mainLayout/sidebar/SideBar.jsx +1402 -0
  132. package/src/layout/mainLayout/sidebar/Sidebar.css +159 -0
  133. package/src/layout/mainLayout/sidebar/index.js +0 -0
  134. package/src/logo.svg +1 -0
  135. package/src/reportWebVitals.js +13 -0
  136. package/src/setupFirebaseMessaging.js +28 -0
  137. package/src/setupTests.js +8 -0
  138. package/src/store/actions/AuthenticationActions.js +0 -0
  139. package/src/store/actions/ReportsActions.js +0 -0
  140. package/src/store/actions/TranslationAction.js +0 -0
  141. package/src/store/index.js +8 -0
  142. package/src/store/reducer.js +46 -0
  143. package/src/store/reducers/AuthenticationReducer.js +50 -0
  144. package/src/store/reducers/CalendarEventReducer.js +41 -0
  145. package/src/store/reducers/ConditionClipboardReducer.js +45 -0
  146. package/src/store/reducers/FeatureReducer.js +27 -0
  147. package/src/store/reducers/FormConfiguratorReducer.js +38 -0
  148. package/src/store/reducers/LoadingReducer.js +20 -0
  149. package/src/store/reducers/MembersAuthenticationReducer.js +28 -0
  150. package/src/store/reducers/PrescriptionPadReducer.js +329 -0
  151. package/src/store/reducers/QuestionaireReducer.js +29 -0
  152. package/src/store/reducers/ReportsReducer.js +24 -0
  153. package/src/store/reducers/SkeletonReducer.js +20 -0
  154. package/src/store/reducers/ThemeReducer.js +106 -0
  155. package/src/store/reducers/TranslationReducer.js +126 -0
  156. package/src/store/reducers/dashboardEditorSlice.js +77 -0
  157. package/src/store/reducers/districtHealthDashboardSlice.js +58 -0
  158. package/src/store/reducers/immunizationSlice.js +234 -0
  159. package/src/store/slices/dashboardPagesSlice.js +51 -0
  160. package/src/store/slices/dashboardSlice.js +14 -0
  161. package/src/utils/.gitkeep +0 -0
  162. package/src/utils/FormConstants.js +2629 -0
  163. package/src/utils/GujaratTopoChart.jsx +483 -0
  164. package/src/utils/UUIDgenerator.js +8 -0
  165. package/src/utils/appointment-utils/appointment-utils.js +123 -0
  166. package/src/utils/feature.js +42 -0
  167. package/src/utils/getThemeColor.js +12 -0
  168. package/src/utils/localStorageHelper.js +11 -0
  169. package/src/utils/notifications/enable-push-notifications.js +27 -0
  170. package/src/utils/resolveAppliedStyle.js +11 -0
  171. package/src/utils/themeConfigs.js +1483 -0
  172. package/src/views/custom-components/.gitkeep +0 -0
  173. package/src/views/custom-components/AgIconButton/RIf.jsx +14 -0
  174. package/src/views/custom-components/AgIconButton/button.jsx +108 -0
  175. package/src/views/custom-components/AgIconButton/waterDrop.jsx +95 -0
  176. package/src/views/custom-components/AgIconButton/waterDrop.scss +37 -0
  177. package/src/views/custom-components/AlertPlaceholder.jsx +32 -0
  178. package/src/views/custom-components/AllFaIconsSelector.jsx +56 -0
  179. package/src/views/custom-components/CkEditor/CkEditor.js +102 -0
  180. package/src/views/custom-components/CustomAccordion.jsx +72 -0
  181. package/src/views/custom-components/CustomActionIcons.jsx +118 -0
  182. package/src/views/custom-components/CustomAutoComplete.jsx +188 -0
  183. package/src/views/custom-components/CustomCheckBox.jsx +60 -0
  184. package/src/views/custom-components/CustomConfirmationModal.jsx +118 -0
  185. package/src/views/custom-components/CustomCountrySelect.jsx +129 -0
  186. package/src/views/custom-components/CustomDatePicker.jsx +122 -0
  187. package/src/views/custom-components/CustomDropdown.jsx +191 -0
  188. package/src/views/custom-components/CustomFileUpload.jsx +387 -0
  189. package/src/views/custom-components/CustomFullCalendar.jsx +514 -0
  190. package/src/views/custom-components/CustomInfiniteScroll.jsx +126 -0
  191. package/src/views/custom-components/CustomRadioComponent.jsx +65 -0
  192. package/src/views/custom-components/CustomStatsComponent.jsx +114 -0
  193. package/src/views/custom-components/CustomSvgUpload.jsx +170 -0
  194. package/src/views/custom-components/CustomSwitch.jsx +37 -0
  195. package/src/views/custom-components/CustomTabPanel.jsx +19 -0
  196. package/src/views/custom-components/CustomTextArea.jsx +62 -0
  197. package/src/views/custom-components/CustomTextArea.scss +27 -0
  198. package/src/views/custom-components/CustomTextField.jsx +116 -0
  199. package/src/views/custom-components/CustomToggleSwitch.jsx +138 -0
  200. package/src/views/custom-components/CustomTooltip.jsx +51 -0
  201. package/src/views/custom-components/CustomZoomImage.jsx +134 -0
  202. package/src/views/custom-components/CustomizedTable/CustomizedTableV2.jsx +1407 -0
  203. package/src/views/custom-components/CustomizedTable/VirtualizeTableBody.jsx +295 -0
  204. package/src/views/custom-components/CustomizedTable/helper.jsx +159 -0
  205. package/src/views/custom-components/CustomizedTable.jsx +532 -0
  206. package/src/views/custom-components/EditInputField.jsx +174 -0
  207. package/src/views/custom-components/FieldDescription.jsx +22 -0
  208. package/src/views/custom-components/FileDisplayComponent.jsx +138 -0
  209. package/src/views/custom-components/FormItem.jsx +53 -0
  210. package/src/views/custom-components/GenericChart.jsx +80 -0
  211. package/src/views/custom-components/InfoBadge.jsx +60 -0
  212. package/src/views/custom-components/PostgresEditor.jsx +801 -0
  213. package/src/views/custom-components/ResizableEditAutocompleteField.jsx +249 -0
  214. package/src/views/custom-components/ResizableEditInputField.jsx +215 -0
  215. package/src/views/custom-components/ResizeableEditSelectField.jsx +197 -0
  216. package/src/views/custom-components/SideOverlay.jsx +113 -0
  217. package/src/views/custom-components/SideOverlay.scss +42 -0
  218. package/src/views/custom-components/calendar.scss +571 -0
  219. package/src/views/feature-components/.gitkeep +0 -0
  220. package/src/views/feature-components/Dashboard/DashboardUI.jsx +1043 -0
  221. package/src/views/feature-components/Dashboard/DhnddModal/AshaDataQualityVerificationModal.jsx +278 -0
  222. package/src/views/feature-components/Dashboard/PinFeatureModal.jsx +143 -0
  223. package/src/views/feature-components/Dashboard/QuickLinks.jsx +163 -0
  224. package/src/views/feature-components/Dashboard/Taskbar.jsx +56 -0
  225. package/src/views/feature-components/Dashboard/WebtasksFilterForm.jsx +109 -0
  226. package/src/views/feature-components/Dashboard/WidgetCard.jsx +161 -0
  227. package/src/views/feature-components/Dashboard/actionModal.jsx +263 -0
  228. package/src/views/feature-components/Dashboard/ekavachModal/HealthWorkerIncorrectDetailsModal.jsx +332 -0
  229. package/src/views/feature-components/Dashboard/ekavachModal/MoMaternalDeathVerifcationModal.jsx +275 -0
  230. package/src/views/feature-components/Dashboard/ekavachModal/MoVerficationForChildScreeningMoadal.jsx +566 -0
  231. package/src/views/feature-components/FeatureUsageAnalytics/FeatureUsageAnalytics.jsx +989 -0
  232. package/src/views/feature-components/Features/NewServerManagement.jsx +217 -0
  233. package/src/views/feature-components/Features/ServerManagement.scss +120 -0
  234. package/src/views/feature-components/ForgotPassword/ForgotPassword.jsx +226 -0
  235. package/src/views/feature-components/LocationDirective/LocationDirective.jsx +992 -0
  236. package/src/views/feature-components/LocationDirective/LocationDirectiveV2.jsx +909 -0
  237. package/src/views/feature-components/NotFound.jsx +66 -0
  238. package/src/views/feature-components/Onboarding/Onboarding.jsx +1400 -0
  239. package/src/views/feature-components/Skeletons.js +115 -0
  240. package/src/views/feature-components/Unauthorized.jsx +48 -0
  241. package/src/views/feature-components/VerifyRoute.jsx +88 -0
  242. package/src/views/feature-components/YearlyRecap/YearlyRecap.jsx +357 -0
  243. package/src/views/feature-components/YearlyRecap/components/RecapSlide.jsx +183 -0
  244. package/src/views/feature-components/YearlyRecap/languageTranslator/TranslationContext.js +5 -0
  245. package/src/views/feature-components/YearlyRecap/languageTranslator/TranslationProvider.jsx +26 -0
  246. package/src/views/feature-components/YearlyRecap/languageTranslator/i18n.js +46 -0
  247. package/src/views/feature-components/YearlyRecap/languageTranslator/translations.json +167 -0
  248. package/src/views/feature-components/YearlyRecap/slides/IntroSlide.jsx +233 -0
  249. package/src/views/feature-components/YearlyRecap/slides/MaternalHealthSlide.jsx +146 -0
  250. package/src/views/feature-components/YearlyRecap/slides/MetricSlide.jsx +227 -0
  251. package/src/views/feature-components/YearlyRecap/slides/OutroSlide.jsx +701 -0
  252. package/src/views/feature-components/YearlyRecap/slides/ReachSlide.jsx +273 -0
  253. package/src/views/feature-components/login/Login.jsx +840 -0
  254. package/src/views/feature-components/login/Login.scss +154 -0
  255. package/src/views/feature-components/login/LoginConfigurator.jsx +1149 -0
  256. package/src/views/feature-components/login/TwoFactorSetupModal.jsx +411 -0
  257. package/src/views/feature-components/login/simplifyMenu.js +45 -0
  258. package/src/views/feature-components/system-config/ManageSystemConfigs.jsx +284 -0
  259. package/src/views/feature-components/system-config/SystemConfig.jsx +299 -0
  260. package/src/views/feature-components/users/ChangePasswordModal.jsx +243 -0
  261. package/src/views/feature-components/users/PasswordField.jsx +56 -0
  262. package/dist/index.css +0 -1
  263. package/dist/index.js +0 -32001
  264. package/dist/index.js.map +0 -1
@@ -0,0 +1,174 @@
1
+ import React, { useState, useEffect, useRef } from 'react';
2
+ import { TextField, FormHelperText, FormControl } from '@mui/material';
3
+ import PropTypes from 'prop-types';
4
+ import { showToast } from '@/common/toaster/toaster';
5
+ import { containsMaliciousPattern } from '@/common/MalaciaousInputUtil';
6
+
7
+ const EditInputField = ({
8
+ name,
9
+ error,
10
+ style,
11
+ errorText,
12
+ initialValue = '',
13
+ handleUpdate,
14
+ isEditable = false,
15
+ index,
16
+ field,
17
+ textLimitations,
18
+ isTeleconsultation = false,
19
+ ...restProps
20
+ }) => {
21
+ const [readOnly, setReadOnly] = useState(initialValue === null ? false : true);
22
+ const [background, setBackground] = useState('transparent');
23
+ const [value, setValue] = useState(initialValue);
24
+ const inputRef = useRef < HTMLInputElement > null;
25
+
26
+ useEffect(() => {
27
+ if (initialValue === null) {
28
+ inputRef.current?.focus();
29
+ }
30
+ setBackground(readOnly ? '#004C700D' : '#e3e3e3');
31
+ }, [readOnly]);
32
+
33
+ const handleDoubleClick = () => {
34
+ isEditable && setReadOnly(false);
35
+ if (inputRef.current && isEditable) {
36
+ inputRef.current.focus();
37
+ inputRef.current.setSelectionRange(value?.length ?? 0, value?.length ?? 0);
38
+ }
39
+ };
40
+
41
+ const formatDuration = (input) => {
42
+ // Regular expression to match numeric part
43
+ const matchNumeric = input?.match(/\d+/);
44
+ const numericPart = matchNumeric ? parseInt(matchNumeric[0]) : null;
45
+
46
+ if (numericPart === null) {
47
+ return '';
48
+ }
49
+
50
+ // Regular expression to match string part
51
+ const matchString = input?.match(/([^0-9]+)\b/);
52
+ const stringPart = matchString ? matchString[0].trim() : '';
53
+
54
+ let durationUnit;
55
+ switch (stringPart.toLowerCase().charAt(0)) {
56
+ case 'm':
57
+ durationUnit = 'Month';
58
+ break;
59
+ case 'w':
60
+ durationUnit = 'Week';
61
+ break;
62
+ case 'y':
63
+ durationUnit = 'Year';
64
+ break;
65
+ default:
66
+ durationUnit = 'Day';
67
+ break;
68
+ }
69
+
70
+ return `${numericPart} ${durationUnit}${numericPart > 1 ? 's' : ''}`;
71
+ };
72
+
73
+ const handleChange = (event) => {
74
+ const inputValue = event.target.value;
75
+
76
+ if (containsMaliciousPattern(inputValue)) {
77
+ showToast({ message: 'HTML or script content is not allowed', type: 'warn' });
78
+ return;
79
+ }
80
+ setValue(event.target.value);
81
+ };
82
+
83
+ const handleKeyPress = async (event) => {
84
+ if (event.key === 'Enter') {
85
+ if (field === 'duration' || field === 'since') {
86
+ const formattedDuration = formatDuration(event.target.value);
87
+ setValue(formattedDuration);
88
+ await handleUpdate(index, field, formattedDuration);
89
+ } else {
90
+ await handleUpdate(index, field, event.target.value);
91
+ }
92
+ setReadOnly(true);
93
+ }
94
+ };
95
+
96
+ return (
97
+ <div className="w-full" style={{ cursor: isEditable ? 'pointer' : 'default' }} onDoubleClick={handleDoubleClick}>
98
+ <FormControl sx={{ width: '100%' }}>
99
+ <TextField
100
+ variant="outlined"
101
+ sx={{
102
+ // Root class for the input field
103
+ '& .MuiOutlinedInput-root': {
104
+ backgroundColor: readOnly ? 'transparent' : isTeleconsultation ? 'rgba(0, 0, 0, 0.6)' : '#e3e3e3',
105
+ borderRadius: '0px',
106
+ },
107
+ '& .MuiOutlinedInput-input': {
108
+ paddingTop: readOnly ? '0px !important' : '5px !important',
109
+ paddingBottom: readOnly ? '0px !important' : '5px !important',
110
+ paddingRight: '0px !important',
111
+ paddingLeft: readOnly ? '0px !important' : '10px !important',
112
+ fontFamily: 'IBM Plex Mono',
113
+ fontSize: { md: '14px', lg: '14px', xl: '14px' },
114
+ lineHeight: '18px',
115
+ color: isTeleconsultation ? (readOnly ? '#ffffff' : '#ffffff') : '#485772',
116
+ fontWeight: '500',
117
+ borderRadius: '0px',
118
+ backgroundColor: 'transparent',
119
+ cursor: isEditable ? (readOnly ? 'pointer' : undefined) : 'default',
120
+ },
121
+ '& .MuiOutlinedInput-notchedOutline': {
122
+ border: 'none ',
123
+ },
124
+
125
+ // Class for the label of the input field
126
+ }}
127
+ error={error}
128
+ style={{ ...style }}
129
+ inputRef={inputRef}
130
+ value={value}
131
+ onKeyDown={async (e) => {
132
+ await handleKeyPress(e);
133
+ }}
134
+ onBlur={async (event) => {
135
+ setReadOnly(true);
136
+ await handleUpdate(index, field, event.target.value);
137
+ }}
138
+ inputProps={{
139
+ maxLength: textLimitations?.maxLength,
140
+ readOnly: readOnly,
141
+ backgroundcolor: background,
142
+ }}
143
+ size="small"
144
+ multiline={textLimitations?.multiline}
145
+ maxRows={textLimitations?.maxRows}
146
+ onChange={handleChange}
147
+ {...restProps}
148
+ />
149
+ {error && (
150
+ <FormHelperText error id={`standard-weight-helper-text-${name}`}>
151
+ {errorText}
152
+ </FormHelperText>
153
+ )}
154
+ </FormControl>
155
+ </div>
156
+ );
157
+ };
158
+
159
+ export default EditInputField;
160
+
161
+
162
+ EditInputField.propTypes = {
163
+ name: PropTypes.any,
164
+ error: PropTypes.any,
165
+ style: PropTypes.any,
166
+ errorText: PropTypes.any,
167
+ initialValue: PropTypes.any,
168
+ handleUpdate: PropTypes.any,
169
+ isEditable: PropTypes.any,
170
+ index: PropTypes.any,
171
+ field: PropTypes.any,
172
+ textLimitations: PropTypes.any,
173
+ isTeleconsultation: PropTypes.any,
174
+ };
@@ -0,0 +1,22 @@
1
+ import React from "react";
2
+ import FontAwesomeIcons from "@/common/fontAwesomeIcons/FontAwesomeIcons";
3
+ import { Box, Tooltip } from "@mui/material";
4
+ import PropTypes from "prop-types";
5
+
6
+ const FieldDescription = ({ title, size = "md", sx }) => {
7
+ return (
8
+ <Tooltip title={title} arrow>
9
+ <Box component={"span"} sx={{ color: "info.main", ...sx }}>
10
+ <FontAwesomeIcons iconName="faCircleQuestion" size={size} />
11
+ </Box>
12
+ </Tooltip>
13
+ );
14
+ };
15
+
16
+ FieldDescription.propTypes = {
17
+ title: PropTypes.node.isRequired,
18
+ size: PropTypes.string,
19
+ sx: PropTypes.object,
20
+ };
21
+
22
+ export default FieldDescription;
@@ -0,0 +1,138 @@
1
+ import { Divider, Typography } from '@mui/material';
2
+ import { useQuery } from '@tanstack/react-query';
3
+ import PropTypes from 'prop-types';
4
+ import downloadFile from '@/common/services/DownloadFile';
5
+ import { useTranslateProvider } from '@/common/languageTranslator/TranslationContext';
6
+ import { FormConfiguratorService } from '@/common/services/FormConfiguratorService';
7
+ import { useMemo, useEffect, useRef } from 'react';
8
+ import { showToast } from '@/common/toaster/toaster';
9
+
10
+ const FileDisplayComponent = ({ versionReferenceUUID, mediaUUID, documentUuid, multimediaType, onError, style }) => {
11
+ const { translate } = useTranslateProvider();
12
+ const errorToastShownRef = useRef(false);
13
+
14
+ const fileIdentifier = documentUuid || `${versionReferenceUUID}-${mediaUUID}`;
15
+
16
+ useEffect(() => {
17
+ errorToastShownRef.current = false;
18
+ }, [fileIdentifier]);
19
+
20
+ const isEnabled = Boolean(documentUuid || (versionReferenceUUID && mediaUUID));
21
+
22
+ useEffect(() => {
23
+ if (!isEnabled) {
24
+ errorToastShownRef.current = true;
25
+ showToast({
26
+ type: 'error',
27
+ message: 'File does not exist or has been removed.',
28
+ });
29
+ onError?.();
30
+ }
31
+ }, []);
32
+
33
+ const { data, status } = useQuery({
34
+ queryKey: ['fileInfo', documentUuid, versionReferenceUUID, mediaUUID],
35
+ queryFn: () => {
36
+ if (documentUuid) {
37
+ return FormConfiguratorService.getFileByUUID(documentUuid).then((res) => res.data);
38
+ }
39
+ return downloadFile(versionReferenceUUID, mediaUUID);
40
+ },
41
+ enabled: isEnabled,
42
+ cacheTime: 1000 * 60 * 30,
43
+ staleTime: 1000 * 60 * 10,
44
+ retry: false,
45
+ });
46
+
47
+ useEffect(() => {
48
+ if (status === 'error' && !errorToastShownRef.current) {
49
+ errorToastShownRef.current = true;
50
+ showToast({
51
+ type: 'error',
52
+ message: 'File does not exist or has been removed.',
53
+ });
54
+ onError?.();
55
+ }
56
+ }, [status]);
57
+
58
+ const styling = {
59
+ maxWidth: '100%',
60
+ maxHeight: '100%',
61
+ objectFit: 'contain',
62
+ };
63
+
64
+ const file = (fileType, dataUrl, image) => {
65
+ const mime = fileType?.mime?.toLowerCase() || '';
66
+ if (mime.startsWith('video')) {
67
+ return (
68
+ <video width="320" height="240" controls>
69
+ <source src={dataUrl} type="video/mp4" />
70
+ </video>
71
+ );
72
+ } else if (mime.startsWith('audio')) {
73
+ return <audio src={dataUrl} controls autoPlay />;
74
+ } else if (mime.startsWith('image')) {
75
+ return <img src={dataUrl} alt="Not Found" style={styling}></img>;
76
+ } else if (mime === 'application/xml') {
77
+ return <img src={'data:image/svg+xml;base64,' + image.split(',')[1]} alt="Not Found" style={style}></img>;
78
+ } else {
79
+ return (
80
+ <>
81
+ <Divider />
82
+ <Typography color="error" align="center">
83
+ {translate('Can not be viewed. Not image, audio, or video')}
84
+ </Typography>
85
+ </>
86
+ );
87
+ }
88
+ };
89
+
90
+ const resolvedData = useMemo(() => {
91
+ if (!data) return null;
92
+ if (data.dataUrl) {
93
+ return data;
94
+ }
95
+ if (data instanceof Blob) {
96
+ const dataUrl = URL.createObjectURL(data);
97
+ let mimeType = data.type;
98
+ if ((!mimeType || mimeType === 'application/octet-stream') && multimediaType) {
99
+ const typeMap = {
100
+ VIDEO: 'video/mp4',
101
+ IMAGE: 'image/jpeg',
102
+ AUDIO: 'audio/mpeg',
103
+ };
104
+ mimeType = typeMap[multimediaType.toUpperCase()] || mimeType;
105
+ }
106
+ return {
107
+ dataUrl,
108
+ fileType: { mime: mimeType },
109
+ };
110
+ }
111
+ return null;
112
+ }, [data, multimediaType]);
113
+
114
+ return (
115
+ <>
116
+ {status === 'pending' ? (
117
+ <Typography align="center">{translate('Loading')}...</Typography>
118
+ ) : resolvedData ? (
119
+ file(resolvedData.fileType, resolvedData.dataUrl, resolvedData.image)
120
+ ) : (
121
+ <Typography color="error" align="center">
122
+ {translate('Error while loading')}
123
+ </Typography>
124
+ )}
125
+ </>
126
+ );
127
+ };
128
+
129
+ FileDisplayComponent.propTypes = {
130
+ mediaUUID: PropTypes.any,
131
+ versionReferenceUUID: PropTypes.any,
132
+ documentUuid: PropTypes.string,
133
+ multimediaType: PropTypes.string,
134
+ onError: PropTypes.func,
135
+ style: PropTypes.object,
136
+ };
137
+
138
+ export default FileDisplayComponent;
@@ -0,0 +1,53 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { Tooltip, Typography } from '@mui/material';
4
+ import { useTranslateProvider } from '@/common/languageTranslator/TranslationContext';
5
+ import Grid from '@mui/material/Grid2';
6
+
7
+ export const FormItem = ({
8
+ label,
9
+ additionalLabel = '',
10
+ children,
11
+ required = false,
12
+ direction = 'column',
13
+ tooltip,
14
+ labelWidth = '25%',
15
+ childrenWidth = '75%',
16
+ }) => {
17
+ const { translate } = useTranslateProvider();
18
+
19
+ return (
20
+ <Grid className={`flex w-full ${direction === 'column' ? 'flex-col' : 'flex-col md:flex-row gap-4'}`}>
21
+ <Grid
22
+ className="flex items-start"
23
+ sx={{
24
+ width: direction === 'column' ? '100%' : { xs: '100%', md: labelWidth },
25
+ }}
26
+ >
27
+ <Tooltip title={translate(tooltip)} arrow placement="top">
28
+ <Typography variant="overline" component="div" sx={{ width: '100%', lineHeight: 1.3 }}>
29
+ <div className="flex items-start gap-1 flex-wrap break-words">
30
+ <span>
31
+ {translate(label)} {required && <span className="text-red-500">*</span>}
32
+ </span>
33
+ {additionalLabel}
34
+ </div>
35
+ </Typography>
36
+ </Tooltip>
37
+ </Grid>
38
+
39
+ <Grid sx={{ width: direction === 'column' ? '100%' : { xs: '100%', md: childrenWidth } }}>{children}</Grid>
40
+ </Grid>
41
+ );
42
+ };
43
+
44
+ FormItem.propTypes = {
45
+ label: PropTypes.any,
46
+ children: PropTypes.any,
47
+ required: PropTypes.any,
48
+ direction: PropTypes.any,
49
+ tooltip: PropTypes.any,
50
+ labelWidth: PropTypes.any,
51
+ childrenWidth: PropTypes.any,
52
+ additionalLabel: PropTypes.any,
53
+ };
@@ -0,0 +1,80 @@
1
+ import {
2
+ BarChart,
3
+ LineChart,
4
+ Bar,
5
+ Line,
6
+ CartesianGrid,
7
+ XAxis,
8
+ YAxis,
9
+ Tooltip,
10
+ Legend,
11
+ ResponsiveContainer,
12
+ } from 'recharts';
13
+ import { Typography } from '@mui/material';
14
+ import Grid from '@mui/material/Grid2';
15
+ import MuiToolTip from '@mui/material/Tooltip';
16
+ import PropTypes from 'prop-types';
17
+ import { useTranslateProvider } from '@/common/languageTranslator/TranslationContext';
18
+
19
+ const GenericChart = ({
20
+ chartType,
21
+ data,
22
+ xAxis = {},
23
+ yAxis = {},
24
+ series = [],
25
+ onChartClick,
26
+ title,
27
+ tooltip,
28
+ margin = { top: 20, right: 30, left: 10, bottom: 5 },
29
+ dataTestId,
30
+ }) => {
31
+ const ChartComponent = chartType === 'bar' ? BarChart : LineChart;
32
+ const { translate } = useTranslateProvider();
33
+ return (
34
+ <Grid className="flex flex-col justify-center items-center space-y-2 py-2 w-full">
35
+ {tooltip ? (
36
+ <MuiToolTip title={tooltip} arrow placement="auto">
37
+ <Typography className="font-bold text-gray-600" data-testid={`${dataTestId}-title`}>
38
+ {translate(title)}
39
+ </Typography>
40
+ </MuiToolTip>
41
+ ) : (
42
+ <Typography className="font-bold text-gray-600" data-testid={`${dataTestId}-title`}>
43
+ {translate(title)}
44
+ </Typography>
45
+ )}
46
+
47
+ <Grid className="w-full overflow-x-auto">
48
+ <Grid className="min-w-[700px]">
49
+ <ResponsiveContainer width="100%" height={350} data-testid={`${dataTestId}-chart`}>
50
+ <ChartComponent data={data} onClick={onChartClick} margin={margin}>
51
+ <CartesianGrid strokeDasharray="3 3" />
52
+ <XAxis {...xAxis} />
53
+ <YAxis {...yAxis} />
54
+ <Tooltip />
55
+ <Legend layout="horizontal" verticalAlign="top" align="center" wrapperStyle={{ paddingBottom: 20 }} />
56
+ {series.map((s, index) =>
57
+ chartType === 'bar' ? <Bar key={index} {...s} /> : <Line key={index} {...s} />
58
+ )}
59
+ </ChartComponent>
60
+ </ResponsiveContainer>
61
+ </Grid>
62
+ </Grid>
63
+ </Grid>
64
+ );
65
+ };
66
+
67
+ GenericChart.propTypes = {
68
+ chartType: PropTypes.oneOf(['bar', 'line']).isRequired,
69
+ data: PropTypes.array.isRequired,
70
+ xAxis: PropTypes.object,
71
+ yAxis: PropTypes.object,
72
+ series: PropTypes.arrayOf(PropTypes.object).isRequired,
73
+ onChartClick: PropTypes.func,
74
+ title: PropTypes.string.isRequired,
75
+ tooltip: PropTypes.string,
76
+ margin: PropTypes.object,
77
+ dataTestId: PropTypes.string,
78
+ };
79
+
80
+ export default GenericChart;
@@ -0,0 +1,60 @@
1
+ import { Avatar, Stack, Tooltip, Typography } from '@mui/material';
2
+ import PropTypes from 'prop-types';
3
+ import React from 'react';
4
+
5
+ const InfoBadge = ({
6
+ label,
7
+ value,
8
+ color = 'primary.main',
9
+ tooltipValue = '',
10
+ showTooltip = false,
11
+ valueSize = 30,
12
+ fontSize = '1rem',
13
+ }) => (
14
+ <Stack direction="row" spacing={1} alignItems="center">
15
+ <Typography variant="button" fontWeight={'bold'}>
16
+ {label}
17
+ </Typography>
18
+ {showTooltip ? (
19
+ <Tooltip title={tooltipValue} arrow>
20
+ <Avatar
21
+ sx={{
22
+ width: valueSize,
23
+ height: valueSize,
24
+ borderRadius: '0.5rem',
25
+ bgcolor: color,
26
+ fontSize: fontSize,
27
+ fontWeight: 'bold',
28
+ }}
29
+ >
30
+ {value}
31
+ </Avatar>
32
+ </Tooltip>
33
+ ) : (
34
+ <Avatar
35
+ sx={{
36
+ width: 30,
37
+ height: 30,
38
+ borderRadius: 2,
39
+ bgcolor: color,
40
+ fontSize: '1rem',
41
+ fontWeight: 'bold',
42
+ }}
43
+ >
44
+ {value}
45
+ </Avatar>
46
+ )}
47
+ </Stack>
48
+ );
49
+
50
+ InfoBadge.propTypes = {
51
+ label: PropTypes.any,
52
+ value: PropTypes.any,
53
+ color: PropTypes.any,
54
+ tooltipValue: PropTypes.any,
55
+ showTooltip: PropTypes.any,
56
+ valueSize: PropTypes.any,
57
+ fontSize: PropTypes.any,
58
+ };
59
+
60
+ export default InfoBadge;