@argusoft/medplat-app-shell 1.0.6 → 1.0.7

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 (263) 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/utils/.gitkeep +0 -0
  161. package/src/utils/FormConstants.js +2629 -0
  162. package/src/utils/GujaratTopoChart.jsx +483 -0
  163. package/src/utils/UUIDgenerator.js +8 -0
  164. package/src/utils/appointment-utils/appointment-utils.js +123 -0
  165. package/src/utils/feature.js +42 -0
  166. package/src/utils/getThemeColor.js +12 -0
  167. package/src/utils/localStorageHelper.js +11 -0
  168. package/src/utils/notifications/enable-push-notifications.js +27 -0
  169. package/src/utils/resolveAppliedStyle.js +11 -0
  170. package/src/utils/themeConfigs.js +1483 -0
  171. package/src/views/custom-components/.gitkeep +0 -0
  172. package/src/views/custom-components/AgIconButton/RIf.jsx +14 -0
  173. package/src/views/custom-components/AgIconButton/button.jsx +108 -0
  174. package/src/views/custom-components/AgIconButton/waterDrop.jsx +95 -0
  175. package/src/views/custom-components/AgIconButton/waterDrop.scss +37 -0
  176. package/src/views/custom-components/AlertPlaceholder.jsx +32 -0
  177. package/src/views/custom-components/AllFaIconsSelector.jsx +56 -0
  178. package/src/views/custom-components/CkEditor/CkEditor.js +102 -0
  179. package/src/views/custom-components/CustomAccordion.jsx +72 -0
  180. package/src/views/custom-components/CustomActionIcons.jsx +118 -0
  181. package/src/views/custom-components/CustomAutoComplete.jsx +188 -0
  182. package/src/views/custom-components/CustomCheckBox.jsx +60 -0
  183. package/src/views/custom-components/CustomConfirmationModal.jsx +118 -0
  184. package/src/views/custom-components/CustomCountrySelect.jsx +129 -0
  185. package/src/views/custom-components/CustomDatePicker.jsx +122 -0
  186. package/src/views/custom-components/CustomDropdown.jsx +191 -0
  187. package/src/views/custom-components/CustomFileUpload.jsx +387 -0
  188. package/src/views/custom-components/CustomFullCalendar.jsx +514 -0
  189. package/src/views/custom-components/CustomInfiniteScroll.jsx +126 -0
  190. package/src/views/custom-components/CustomRadioComponent.jsx +65 -0
  191. package/src/views/custom-components/CustomStatsComponent.jsx +114 -0
  192. package/src/views/custom-components/CustomSvgUpload.jsx +170 -0
  193. package/src/views/custom-components/CustomSwitch.jsx +37 -0
  194. package/src/views/custom-components/CustomTabPanel.jsx +19 -0
  195. package/src/views/custom-components/CustomTextArea.jsx +62 -0
  196. package/src/views/custom-components/CustomTextArea.scss +27 -0
  197. package/src/views/custom-components/CustomTextField.jsx +116 -0
  198. package/src/views/custom-components/CustomToggleSwitch.jsx +138 -0
  199. package/src/views/custom-components/CustomTooltip.jsx +51 -0
  200. package/src/views/custom-components/CustomZoomImage.jsx +134 -0
  201. package/src/views/custom-components/CustomizedTable/CustomizedTableV2.jsx +1407 -0
  202. package/src/views/custom-components/CustomizedTable/VirtualizeTableBody.jsx +295 -0
  203. package/src/views/custom-components/CustomizedTable/helper.jsx +159 -0
  204. package/src/views/custom-components/CustomizedTable.jsx +532 -0
  205. package/src/views/custom-components/EditInputField.jsx +174 -0
  206. package/src/views/custom-components/FieldDescription.jsx +22 -0
  207. package/src/views/custom-components/FileDisplayComponent.jsx +138 -0
  208. package/src/views/custom-components/FormItem.jsx +53 -0
  209. package/src/views/custom-components/GenericChart.jsx +80 -0
  210. package/src/views/custom-components/InfoBadge.jsx +60 -0
  211. package/src/views/custom-components/PostgresEditor.jsx +801 -0
  212. package/src/views/custom-components/ResizableEditAutocompleteField.jsx +249 -0
  213. package/src/views/custom-components/ResizableEditInputField.jsx +215 -0
  214. package/src/views/custom-components/ResizeableEditSelectField.jsx +197 -0
  215. package/src/views/custom-components/SideOverlay.jsx +113 -0
  216. package/src/views/custom-components/SideOverlay.scss +42 -0
  217. package/src/views/custom-components/calendar.scss +571 -0
  218. package/src/views/feature-components/.gitkeep +0 -0
  219. package/src/views/feature-components/Dashboard/DashboardUI.jsx +1043 -0
  220. package/src/views/feature-components/Dashboard/DhnddModal/AshaDataQualityVerificationModal.jsx +278 -0
  221. package/src/views/feature-components/Dashboard/PinFeatureModal.jsx +143 -0
  222. package/src/views/feature-components/Dashboard/QuickLinks.jsx +163 -0
  223. package/src/views/feature-components/Dashboard/Taskbar.jsx +56 -0
  224. package/src/views/feature-components/Dashboard/WebtasksFilterForm.jsx +109 -0
  225. package/src/views/feature-components/Dashboard/WidgetCard.jsx +161 -0
  226. package/src/views/feature-components/Dashboard/actionModal.jsx +263 -0
  227. package/src/views/feature-components/Dashboard/ekavachModal/HealthWorkerIncorrectDetailsModal.jsx +332 -0
  228. package/src/views/feature-components/Dashboard/ekavachModal/MoMaternalDeathVerifcationModal.jsx +275 -0
  229. package/src/views/feature-components/Dashboard/ekavachModal/MoVerficationForChildScreeningMoadal.jsx +566 -0
  230. package/src/views/feature-components/FeatureUsageAnalytics/FeatureUsageAnalytics.jsx +989 -0
  231. package/src/views/feature-components/Features/NewServerManagement.jsx +217 -0
  232. package/src/views/feature-components/Features/ServerManagement.scss +120 -0
  233. package/src/views/feature-components/ForgotPassword/ForgotPassword.jsx +226 -0
  234. package/src/views/feature-components/LocationDirective/LocationDirective.jsx +992 -0
  235. package/src/views/feature-components/LocationDirective/LocationDirectiveV2.jsx +909 -0
  236. package/src/views/feature-components/NotFound.jsx +66 -0
  237. package/src/views/feature-components/Onboarding/Onboarding.jsx +1400 -0
  238. package/src/views/feature-components/Skeletons.js +115 -0
  239. package/src/views/feature-components/Unauthorized.jsx +48 -0
  240. package/src/views/feature-components/VerifyRoute.jsx +88 -0
  241. package/src/views/feature-components/YearlyRecap/YearlyRecap.jsx +357 -0
  242. package/src/views/feature-components/YearlyRecap/components/RecapSlide.jsx +183 -0
  243. package/src/views/feature-components/YearlyRecap/languageTranslator/TranslationContext.js +5 -0
  244. package/src/views/feature-components/YearlyRecap/languageTranslator/TranslationProvider.jsx +26 -0
  245. package/src/views/feature-components/YearlyRecap/languageTranslator/i18n.js +46 -0
  246. package/src/views/feature-components/YearlyRecap/languageTranslator/translations.json +167 -0
  247. package/src/views/feature-components/YearlyRecap/slides/IntroSlide.jsx +233 -0
  248. package/src/views/feature-components/YearlyRecap/slides/MaternalHealthSlide.jsx +146 -0
  249. package/src/views/feature-components/YearlyRecap/slides/MetricSlide.jsx +227 -0
  250. package/src/views/feature-components/YearlyRecap/slides/OutroSlide.jsx +701 -0
  251. package/src/views/feature-components/YearlyRecap/slides/ReachSlide.jsx +273 -0
  252. package/src/views/feature-components/login/Login.jsx +840 -0
  253. package/src/views/feature-components/login/Login.scss +154 -0
  254. package/src/views/feature-components/login/LoginConfigurator.jsx +1149 -0
  255. package/src/views/feature-components/login/TwoFactorSetupModal.jsx +411 -0
  256. package/src/views/feature-components/login/simplifyMenu.js +45 -0
  257. package/src/views/feature-components/system-config/ManageSystemConfigs.jsx +284 -0
  258. package/src/views/feature-components/system-config/SystemConfig.jsx +299 -0
  259. package/src/views/feature-components/users/ChangePasswordModal.jsx +243 -0
  260. package/src/views/feature-components/users/PasswordField.jsx +56 -0
  261. package/dist/index.css +0 -1
  262. package/dist/index.js +0 -32001
  263. package/dist/index.js.map +0 -1
@@ -0,0 +1,114 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { useTranslateProvider } from '@/common/languageTranslator/TranslationContext';
4
+ import { useTheme } from '@mui/material/styles'; // Added MUI hooks
5
+
6
+ const CustomStatsComponent = ({
7
+ title,
8
+ value,
9
+ bgColor,
10
+ titleColor,
11
+ valueColor,
12
+ onClick,
13
+ width = '100%',
14
+ height = 'auto',
15
+ minWidth = '',
16
+ minHeight = '',
17
+ selected = false,
18
+ selectedBgColor,
19
+ selectedTitleColor = 'white',
20
+ selectedValueColor = 'white',
21
+ bottomIndicator = false,
22
+ }) => {
23
+ const { translate } = useTranslateProvider();
24
+ const theme = useTheme();
25
+ const isDark = theme.palette.mode === 'dark';
26
+
27
+ const defaultBg = isDark ? theme.palette.background.paper : 'white';
28
+ const defaultTitleColor = isDark ? theme.palette.text.secondary : '#64748b'; // slate-500
29
+ const defaultValueColor = isDark ? theme.palette.text.primary : '#1e293b'; // slate-800
30
+ const borderColor = isDark ? theme.palette.divider : 'rgb(243 244 246)';
31
+
32
+ return (
33
+ <div
34
+ onClick={onClick}
35
+ key={title}
36
+ role="button"
37
+ tabIndex={0}
38
+ className={`
39
+ relative flex flex-col rounded-2xl border
40
+ cursor-pointer transition-all duration-300 ease-in-out
41
+ hover:shadow-xl hover:-translate-y-1 active:scale-[0.98]
42
+ overflow-hidden
43
+ `}
44
+ style={{
45
+ borderColor: borderColor,
46
+ backgroundColor: selected ? selectedBgColor || theme.palette.primary.main : bgColor || defaultBg,
47
+ width: width,
48
+ height: height,
49
+ minWidth: minWidth,
50
+ minHeight: minHeight,
51
+ paddingBottom: '10px'
52
+ }}
53
+ >
54
+ <div className="px-5 pt-3 flex flex-col h-full relative">
55
+ {/* Title Section (Top) */}
56
+ {title && (
57
+ <p
58
+ className="text-[10px] font-black uppercase tracking-[0.1em]"
59
+ style={{
60
+ color: selected ? selectedTitleColor : titleColor || defaultTitleColor,
61
+ }}
62
+ >
63
+ {translate(title)}
64
+ </p>
65
+ )}
66
+
67
+ {/* Value and Badge Row */}
68
+ <div className="flex items-center">
69
+ {value !== undefined && (
70
+ <h3
71
+ className="text-2xl font-black tracking-tight"
72
+ style={{
73
+ color: selected ? selectedValueColor : valueColor || defaultValueColor,
74
+ }}
75
+ >
76
+ {value}
77
+ </h3>
78
+ )}
79
+ </div>
80
+ </div>
81
+
82
+ {/* Bottom Indicator */}
83
+ {bottomIndicator && (
84
+ <div
85
+ className="absolute bottom-0 left-5 right-5 h-[3px] rounded-t-full"
86
+ style={{
87
+ backgroundColor: typeof bottomIndicator === 'string' ? bottomIndicator : theme.palette.primary.main,
88
+ }}
89
+ />
90
+ )}
91
+ </div>
92
+ );
93
+ };
94
+
95
+ export default CustomStatsComponent;
96
+
97
+ CustomStatsComponent.propTypes = {
98
+ title: PropTypes.string,
99
+ value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
100
+ onClick: PropTypes.func,
101
+ width: PropTypes.string,
102
+ height: PropTypes.string,
103
+ minWidth: PropTypes.string,
104
+ minHeight: PropTypes.string,
105
+ bgColor: PropTypes.string,
106
+ titleColor: PropTypes.string,
107
+ valueColor: PropTypes.string,
108
+ selected: PropTypes.bool,
109
+ selectedBgColor: PropTypes.string,
110
+ selectedTitleColor: PropTypes.string,
111
+ selectedValueColor: PropTypes.string,
112
+ selectedIconBgColor: PropTypes.string,
113
+ bottomIndicator: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
114
+ };
@@ -0,0 +1,170 @@
1
+ import { showToast } from '@/common/toaster/toaster';
2
+ import { FormControl, Grid2, IconButton, Typography } from '@mui/material';
3
+ import { Box } from '@mui/system';
4
+ import { default as React, useEffect, useRef, useState } from 'react';
5
+ import { get } from 'react-hook-form';
6
+ import PropTypes from 'prop-types';
7
+ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
8
+ import { faSquarePlus, faTrash } from '@fortawesome/free-solid-svg-icons';
9
+
10
+ import SafeHtml from '@/common/SafeHtml.jsx';
11
+
12
+ const CustomSvgUpload = ({
13
+ onUpload,
14
+ formControl,
15
+ name,
16
+ errors,
17
+ accept = '*',
18
+ disabled = false,
19
+ dataTestId = 'file-upload',
20
+ }) => {
21
+ const [svgString, setSvgString] = useState('');
22
+ const [svgStringDisplay, setSvgStringDisplay] = useState('');
23
+ const error = get(errors, name);
24
+ const fileInputRef = useRef(null);
25
+
26
+ const handleFileUpload = (event) => {
27
+ if (disabled) return;
28
+ if (svgStringDisplay && svgString) {
29
+ showToast({ message: 'Max no of files reached', type: 'error' });
30
+ return;
31
+ }
32
+ try {
33
+ const file = event.target.files[0];
34
+ if (!file) return;
35
+
36
+ if (fileInputRef.current) fileInputRef.current.value = '';
37
+ if (!file.type.includes('svg') && !file.name.toLowerCase().endsWith('.svg')) {
38
+ showToast({ message: 'Only SVG files are allowed', type: 'error' });
39
+ setSvgString('');
40
+ setSvgStringDisplay('');
41
+ if (onUpload) onUpload(null);
42
+ return;
43
+ }
44
+
45
+ const reader = new FileReader();
46
+ reader.onload = (e) => {
47
+ let svgContent = e.target.result;
48
+ setSvgString(svgContent);
49
+
50
+ let parser = new DOMParser();
51
+ let doc = parser.parseFromString(svgContent, 'image/svg+xml');
52
+ let svgElement = doc.documentElement;
53
+
54
+ let viewBox = svgElement.getAttribute('viewBox');
55
+ if (!viewBox) {
56
+ let width = svgElement.getAttribute('width') || '512';
57
+ let height = svgElement.getAttribute('height') || '512';
58
+ svgElement.setAttribute('viewBox', `0 0 ${width} ${height}`);
59
+ }
60
+
61
+ svgElement.setAttribute('width', '80');
62
+ svgElement.setAttribute('height', '80');
63
+
64
+ setSvgStringDisplay(new XMLSerializer().serializeToString(svgElement));
65
+ if (onUpload) onUpload(svgContent);
66
+ };
67
+ reader.readAsText(file);
68
+ } catch (error) {
69
+ console.log(error);
70
+ }
71
+ };
72
+
73
+ useEffect(() => {
74
+ let svg = formControl.getValues(name);
75
+ if (svg) {
76
+ setSvgString(svg);
77
+ let parser = new DOMParser();
78
+ let doc = parser.parseFromString(svg, 'image/svg+xml');
79
+ let svgElement = doc.documentElement;
80
+
81
+ let viewBox = svgElement.getAttribute('viewBox');
82
+ if (!viewBox) {
83
+ let width = svgElement.getAttribute('width') || '512';
84
+ let height = svgElement.getAttribute('height') || '512';
85
+ svgElement.setAttribute('viewBox', `0 0 ${width} ${height}`);
86
+ }
87
+
88
+ svgElement.setAttribute('width', '80');
89
+ svgElement.setAttribute('height', '80');
90
+
91
+ setSvgStringDisplay(new XMLSerializer().serializeToString(svgElement));
92
+ }
93
+ }, [formControl.getValues(name)]);
94
+
95
+ return (
96
+ <Box>
97
+ <FormControl fullWidth error={!!error}>
98
+ <Grid2 container spacing={2} sx={{ alignItems: 'center' }}>
99
+ <Grid2
100
+ size={2}
101
+ sx={{
102
+ alignItems: 'center',
103
+ alignSelf: 'center',
104
+ height: '80px',
105
+ width: '80px',
106
+ border: '2px dashed #ccc',
107
+ display: 'flex',
108
+ justifyContent: 'center',
109
+ textAlign: 'center',
110
+ backgroundColor: (theme) => theme.palette.background.paper,
111
+ overflow: 'hidden',
112
+ }}
113
+ >
114
+ {svgStringDisplay ? (
115
+ <div dangerouslySetInnerHTML={{ __html: svgStringDisplay }} />
116
+ ) : (
117
+ <Typography variant="body2" sx={{ color: '#999' }}>
118
+ <IconButton component="label" variant="contained" size="small">
119
+ <FontAwesomeIcon icon={faSquarePlus} />
120
+ <input
121
+ type="file"
122
+ style={{
123
+ opacity: 0,
124
+ position: 'absolute',
125
+ cursor: disabled ? 'not-allowed' : 'pointer',
126
+ }}
127
+ onChange={handleFileUpload}
128
+ required={true}
129
+ accept={accept}
130
+ ref={fileInputRef}
131
+ disabled={disabled}
132
+ data-testid={dataTestId}
133
+ />
134
+ </IconButton>
135
+ </Typography>
136
+ )}
137
+ </Grid2>
138
+
139
+ {svgString && svgStringDisplay && (
140
+ <IconButton
141
+ variant="contained"
142
+ size="small"
143
+ color="error"
144
+ onClick={() => {
145
+ onUpload(null);
146
+ setSvgString(null);
147
+ setSvgStringDisplay(null);
148
+ }}
149
+ >
150
+ <FontAwesomeIcon icon={faTrash} />
151
+ </IconButton>
152
+ )}
153
+ </Grid2>
154
+ {error && <p className="error-helper-text">{error?.message}</p>}
155
+ </FormControl>
156
+ </Box>
157
+ );
158
+ };
159
+
160
+ CustomSvgUpload.propTypes = {
161
+ onUpload: PropTypes.any,
162
+ formControl: PropTypes.any,
163
+ name: PropTypes.any,
164
+ errors: PropTypes.any,
165
+ accept: PropTypes.any,
166
+ dataTestId: PropTypes.any,
167
+ disabled: PropTypes.bool,
168
+ };
169
+
170
+ export default CustomSvgUpload;
@@ -0,0 +1,37 @@
1
+ import { styled, Switch } from '@mui/material';
2
+
3
+ const CustomSwitch = styled(Switch)(({ theme }) => ({
4
+ padding: 8,
5
+ scale: '1.3',
6
+ '& .MuiSwitch-track': {
7
+ borderRadius: 22 / 2,
8
+ '&::before, &::after': {
9
+ content: '""',
10
+ position: 'absolute',
11
+ top: '50%',
12
+ transform: 'translateY(-50%)',
13
+ width: 16,
14
+ height: 16,
15
+ },
16
+ '&::before': {
17
+ backgroundImage: `url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16" viewBox="0 0 24 24"><path fill="${encodeURIComponent(
18
+ theme.palette.getContrastText(theme.palette.primary.dark)
19
+ )}" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"/></svg>')`,
20
+ left: 12,
21
+ },
22
+ '&::after': {
23
+ backgroundImage: `url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16" viewBox="0 0 24 24"><path fill="${encodeURIComponent(
24
+ theme.palette.getContrastText(theme.palette.primary.dark)
25
+ )}" d="M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z" /></svg>')`,
26
+ right: 12,
27
+ },
28
+ },
29
+ '& .MuiSwitch-thumb': {
30
+ boxShadow: 'none',
31
+ width: 16,
32
+ height: 16,
33
+ margin: 2,
34
+ },
35
+ }));
36
+
37
+ export default CustomSwitch;
@@ -0,0 +1,19 @@
1
+ import { Box } from '@mui/material';
2
+ import PropTypes from 'prop-types';
3
+
4
+ const CustomTabPanel = (props) => {
5
+ const { children, value, index, ...other } = props;
6
+ return (
7
+ <div role="tabpanel" hidden={value !== index} id={`profile-tabpanel-${index}`} {...other}>
8
+ {value === index && <Box sx={{ p: 3 }}>{children}</Box>}
9
+ </div>
10
+ );
11
+ };
12
+
13
+ CustomTabPanel.propTypes = {
14
+ children: PropTypes.node,
15
+ index: PropTypes.number.isRequired,
16
+ value: PropTypes.number.isRequired,
17
+ };
18
+
19
+ export default CustomTabPanel;
@@ -0,0 +1,62 @@
1
+ import React from 'react';
2
+ import { FormControl, TextareaAutosize } from '@mui/material';
3
+ import { Controller, get } from 'react-hook-form';
4
+ import '@/views/custom-components/CustomTextArea.scss';
5
+ import PropTypes from 'prop-types';
6
+ // import { sanitizeRichText } from '@/common/MalaciaousInputUtil';
7
+ export default function CustomTextArea({
8
+ name,
9
+ minRows,
10
+ control,
11
+ disabled,
12
+ errors,
13
+ rules = {},
14
+ className,
15
+ dataTestId,
16
+ sx,
17
+ ...props
18
+ }) {
19
+ const error = get(errors, name);
20
+ return (
21
+ <FormControl fullWidth>
22
+ <Controller
23
+ name={name}
24
+ rules={rules}
25
+ control={control}
26
+ render={({ field }) => (
27
+ <TextareaAutosize
28
+ {...field}
29
+ minRows={minRows}
30
+ // onBlur={(e) => {
31
+ // const cleanValue = sanitizeRichText(e.target.value);
32
+ // field.onChange(cleanValue);
33
+
34
+ // field.onBlur();
35
+ // }}
36
+ disabled={disabled}
37
+ data-testid={dataTestId}
38
+ className={`custom-textarea ${className} ${error ? 'error-textarea' : 'custom-textarea-without-error'}`}
39
+ sx={{ ...sx, borderRadius: 2 }}
40
+ {...props}
41
+ />
42
+ )}
43
+ />
44
+ {error && (
45
+ <div data-testid="custom-error-message" className="error-helper-text">
46
+ {error?.message}
47
+ </div>
48
+ )}
49
+ </FormControl>
50
+ );
51
+ }
52
+ CustomTextArea.propTypes = {
53
+ name: PropTypes.any,
54
+ rules: PropTypes.any,
55
+ minRows: PropTypes.any,
56
+ control: PropTypes.any,
57
+ disabled: PropTypes.any,
58
+ errors: PropTypes.any,
59
+ className: PropTypes.any,
60
+ dataTestId: PropTypes.any,
61
+ sx: PropTypes.any,
62
+ };
@@ -0,0 +1,27 @@
1
+ .MuiFormControl-root .error-textarea {
2
+ border-color: red !important;
3
+ border-style: solid;
4
+ }
5
+
6
+ .MuiFormControl-root .error-textarea:focus {
7
+ outline-color: red;
8
+ }
9
+
10
+ .custom-textarea {
11
+ font-size: 14px !important;
12
+ margin-top: 8px;
13
+ border: 1px solid rgb(174, 174, 174) !important;
14
+ border-radius: 10px;
15
+ padding: 10px;
16
+ transition:
17
+ border-color 0.2s ease,
18
+ box-shadow 0.2s ease;
19
+ }
20
+
21
+ .custom-textarea-without-error:hover {
22
+ border-color: black !important;
23
+ }
24
+
25
+ .custom-textarea-without-error:focus {
26
+ outline-color: #11b666;
27
+ }
@@ -0,0 +1,116 @@
1
+ // CustomTextField.jsx
2
+ import React from 'react';
3
+ import { TextField, FormControl } from '@mui/material';
4
+ import PropTypes from 'prop-types';
5
+ import { Controller, get } from 'react-hook-form';
6
+ import { showToast } from '@/common/toaster/toaster';
7
+ import { containsMaliciousPattern } from '@/common/MalaciaousInputUtil';
8
+
9
+ const CustomTextField = ({
10
+ control,
11
+ id,
12
+ name,
13
+ errors,
14
+ onChange,
15
+ successMessage,
16
+ onBlur,
17
+ size = 'small',
18
+ rules = null,
19
+ dataTestId,
20
+ endAdornment,
21
+ fullWidth = true,
22
+ ...props
23
+ }) => {
24
+ // Ensure `errors` is properly defined and contains the relevant field
25
+ const error = get(errors, name); // Get the error for the specific field
26
+
27
+ return (
28
+ <FormControl fullWidth={fullWidth}>
29
+ <Controller
30
+ name={name}
31
+ control={control}
32
+ rules={rules}
33
+ render={({ field }) => (
34
+ <TextField
35
+ {...field}
36
+ id={id}
37
+ name={name}
38
+ error={!!error}
39
+ helperText=""
40
+ size={size}
41
+ fullWidth
42
+ slotProps={{
43
+ input: {
44
+ endAdornment: endAdornment ? <>{endAdornment}</> : null,
45
+ },
46
+ }}
47
+ onChange={(e) => {
48
+ let value = e.target.value;
49
+ if (containsMaliciousPattern(value)) {
50
+ showToast({ message: 'HTML or script content is not allowed', type: 'warn' });
51
+ return;
52
+ }
53
+ // Convert to number if type is number
54
+ if (props.type === 'number' && value) {
55
+ value = Number(value);
56
+ }
57
+
58
+ field.onChange(value);
59
+ onChange?.({ ...e, target: { ...e.target, value } }); // also call external onChange if any
60
+ }}
61
+ onBlur={(e) => {
62
+ let value = e.target.value;
63
+ if (onBlur) {
64
+ onBlur(e);
65
+ } else if (name === 'code' && value && !props.disableUpperCase) {
66
+ value = value.toUpperCase();
67
+ field.onChange(value);
68
+ }
69
+ field.onBlur(e);
70
+ }}
71
+ sx={{
72
+ backgroundColor: '#F8FAFC',
73
+ '& .MuiInputLabel-root': {
74
+ fontSize: '14px',
75
+ },
76
+ '& .MuiInputBase-input': {
77
+ fontSize: '14px',
78
+ },
79
+ }}
80
+ data-testid={dataTestId}
81
+ {...props}
82
+ />
83
+ )}
84
+ />
85
+ {!error && successMessage && (
86
+ <p data-testid="custom-success-message" className="success-helper-text">
87
+ {successMessage}
88
+ </p>
89
+ )}
90
+ {error && (
91
+ <p data-testid="custom-error-message" className="error-helper-text">
92
+ {error?.message}
93
+ </p>
94
+ )}
95
+ </FormControl>
96
+ );
97
+ };
98
+
99
+ CustomTextField.propTypes = {
100
+ control: PropTypes.any,
101
+ id: PropTypes.any,
102
+ name: PropTypes.any,
103
+ errors: PropTypes.any,
104
+ onChange: PropTypes.any,
105
+ size: PropTypes.any,
106
+ onBlur: PropTypes.any,
107
+ rules: PropTypes.any,
108
+ successMessage: PropTypes.any,
109
+ type: PropTypes.any,
110
+ dataTestId: PropTypes.any,
111
+ fullWidth: PropTypes.any,
112
+ endAdornment: PropTypes.any,
113
+ disableUpperCase: PropTypes.any,
114
+ };
115
+
116
+ export default CustomTextField;
@@ -0,0 +1,138 @@
1
+ import React, { useState, useRef, useEffect } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { Controller, get } from 'react-hook-form';
4
+ import { useTheme } from '@mui/material';
5
+ import { useTranslateProvider } from '@/common/languageTranslator/TranslationContext';
6
+
7
+ const ToggleUI = ({ value, onChange, options = [], disabled = false, hasError = false }) => {
8
+ const theme = useTheme();
9
+ const { translate } = useTranslateProvider();
10
+
11
+ const [highlightStyle, setHighlightStyle] = useState({
12
+ width: 0,
13
+ left: 0,
14
+ opacity: 0,
15
+ });
16
+ const containerRef = useRef(null);
17
+ const itemsRef = useRef([]);
18
+
19
+ const updateHighlight = () => {
20
+ const index = options.findIndex((opt) => opt.value === value);
21
+
22
+ if (index !== -1 && itemsRef.current[index]) {
23
+ const currentTab = itemsRef.current[index];
24
+ setHighlightStyle({
25
+ width: currentTab.offsetWidth,
26
+ left: currentTab.offsetLeft,
27
+ opacity: 1,
28
+ });
29
+ }
30
+ };
31
+
32
+ useEffect(() => {
33
+ updateHighlight();
34
+ window.addEventListener('resize', updateHighlight);
35
+ return () => window.removeEventListener('resize', updateHighlight);
36
+ }, [value, options]);
37
+
38
+ const activeColor = theme?.palette?.primary?.main || '#3b82f6';
39
+
40
+ return (
41
+ <div
42
+ ref={containerRef}
43
+ className={`
44
+ relative inline-flex items-center rounded-full p-1
45
+ border shadow-inner select-none transition-colors duration-200
46
+ ${disabled ? 'opacity-60 pointer-events-none' : ''}
47
+ `}
48
+ style={{
49
+ borderColor: hasError ? theme.palette.error.main : theme.palette.divider,
50
+ backgroundColor: hasError
51
+ ? theme.palette.mode === 'dark'
52
+ ? theme.palette.error.dark + '22'
53
+ : '#fef2f2'
54
+ : theme.palette.action.hover,
55
+ }}
56
+ >
57
+ <div
58
+ className="absolute h-[calc(100%-8px)] rounded-full transition-all duration-300 ease-[cubic-bezier(0.4,0,0.2,1)] shadow-md"
59
+ style={{
60
+ width: highlightStyle.width,
61
+ transform: `translateX(${highlightStyle.left}px)`,
62
+ backgroundColor: activeColor,
63
+ opacity: highlightStyle.opacity,
64
+ top: 4,
65
+ left: 0,
66
+ }}
67
+ />
68
+
69
+ {options.map((option, idx) => {
70
+ const isActive = value === option.value;
71
+ return (
72
+ <button
73
+ key={option.value}
74
+ ref={(el) => (itemsRef.current[idx] = el)}
75
+ type="button"
76
+ onClick={() => {
77
+ if (!disabled) onChange(option.value);
78
+ }}
79
+ className="relative z-10 px-4 py-1 text-sm font-semibold rounded-full transition-colors duration-200 focus:outline-none whitespace-nowrap"
80
+ style={{
81
+ color: isActive ? '#ffffff' : theme.palette.text.secondary,
82
+ }}
83
+ >
84
+ {/* Translate the label */}
85
+ {translate ? translate(option.label) : option.label}
86
+ </button>
87
+ );
88
+ })}
89
+ </div>
90
+ );
91
+ };
92
+
93
+ ToggleUI.propTypes = {
94
+ value: PropTypes.any,
95
+ onChange: PropTypes.func,
96
+ options: PropTypes.array,
97
+ disabled: PropTypes.bool,
98
+ hasError: PropTypes.bool,
99
+ };
100
+
101
+ export default function CustomToggleSwitch({ control, name, rules, errors, options, ...props }) {
102
+ const error = name && errors ? get(errors, name) : null;
103
+ return (
104
+ <div className="flex flex-col items-start">
105
+ {control ? (
106
+ <Controller
107
+ name={name}
108
+ control={control}
109
+ rules={rules}
110
+ render={({ field: { value, onChange } }) => (
111
+ <ToggleUI {...props} value={value} onChange={onChange} options={options} hasError={!!error} />
112
+ )}
113
+ />
114
+ ) : (
115
+ <ToggleUI {...props} options={options} hasError={!!error} />
116
+ )}
117
+
118
+ {error && <p className="error-helper-text">{error.message}</p>}
119
+ </div>
120
+ );
121
+ }
122
+
123
+ CustomToggleSwitch.propTypes = {
124
+ control: PropTypes.object,
125
+ name: PropTypes.string,
126
+ rules: PropTypes.object,
127
+ errors: PropTypes.object,
128
+ value: PropTypes.any,
129
+ onChange: PropTypes.func,
130
+ options: PropTypes.arrayOf(
131
+ PropTypes.shape({
132
+ label: PropTypes.string.isRequired,
133
+ value: PropTypes.any.isRequired,
134
+ })
135
+ ).isRequired,
136
+ theme: PropTypes.object,
137
+ disabled: PropTypes.bool,
138
+ };