@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,701 @@
1
+ import React, { useEffect, useRef, useState } from 'react';
2
+ import { Box, Typography, Button, Card, Divider, CircularProgress } from '@mui/material';
3
+ import { motion, AnimatePresence } from 'framer-motion';
4
+ import html2canvas from 'html2canvas';
5
+ import FontAwesomeIcons from '@/common/fontAwesomeIcons/FontAwesomeIcons';
6
+
7
+ import { useTranslateProvider } from '@/common/languageTranslator/TranslationContext';
8
+
9
+ import RecapSlide from '../components/RecapSlide';
10
+ import PropTypes from 'prop-types';
11
+ // import { margin } from '@mui/system';
12
+
13
+ const METRIC_CONFIG = [
14
+ {
15
+ key: 'immunisation',
16
+ label: 'Immunisation Services',
17
+ providedKey: 'immunisationServicesProvided',
18
+ pctKey: 'immunisationServicesTopPct',
19
+ rankLabelKey: 'immunisationRankLabel',
20
+ icon: 'faSyringe',
21
+ color: '#54626dff',
22
+ },
23
+ {
24
+ key: 'anc',
25
+ label: 'Antenatal Care',
26
+ providedKey: 'ancServicesProvided',
27
+ pctKey: 'ancServicesTopPct',
28
+ rankLabelKey: 'ancRankLabel',
29
+ icon: 'faPersonPregnant',
30
+ color: '#EC407A',
31
+ },
32
+ {
33
+ key: 'pnc',
34
+ label: 'Postnatal Care',
35
+ providedKey: 'pncServicesProvided',
36
+ pctKey: 'pncServicesTopPct',
37
+ rankLabelKey: 'pncRankLabel',
38
+ icon: 'faHeart',
39
+ color: '#FF9800',
40
+ },
41
+ {
42
+ key: 'child',
43
+ label: 'Child Health',
44
+ providedKey: 'csProvided',
45
+ pctKey: 'csServicesTopPct',
46
+ rankLabelKey: 'csRankLabel',
47
+ icon: 'faBaby',
48
+ color: '#66BB6A',
49
+ },
50
+ {
51
+ key: 'npcb',
52
+ label: 'NPCB',
53
+ providedKey: 'npcbServicesProvided',
54
+ pctKey: 'npcbServicesTopPct',
55
+ rankLabelKey: 'npcbRankLabel',
56
+ icon: 'faEye',
57
+ color: '#E67E22',
58
+ },
59
+ {
60
+ key: 'cbac',
61
+ label: 'CBAC',
62
+ providedKey: 'cbacServicesProvided',
63
+ pctKey: 'cbacServicesTopPct',
64
+ rankLabelKey: 'cbacRankLabel',
65
+ icon: 'faClipboardList',
66
+ color: '#9C27B0',
67
+ },
68
+ {
69
+ key: 'ncd',
70
+ label: 'NCD',
71
+ providedKey: 'ncdServicesProvided',
72
+ pctKey: 'ncdServicesTopPct',
73
+ rankLabelKey: 'ncdRankLabel',
74
+ icon: 'faHeartPulse',
75
+ color: '#009688',
76
+ },
77
+ {
78
+ key: 'abha',
79
+ label: 'ABHA',
80
+ providedKey: 'abhaServicesProvided',
81
+ pctKey: 'abhaServicesTopPct',
82
+ rankLabelKey: 'abhaRankLabel',
83
+ icon: 'faIdCard',
84
+ color: '#3F51B5',
85
+ },
86
+ ];
87
+
88
+ const getClosingMessage = (translate, { hero, secondary, totalActive }) => {
89
+ if (!hero) {
90
+ return {
91
+ title: translate('Every contribution matters'),
92
+ subtitle: translate('Your presence supported the healthcare system this year.'),
93
+ };
94
+ }
95
+
96
+ if (totalActive === 1) {
97
+ return {
98
+ title: translate('Your focus on {{label}} made a real difference', {
99
+ label: translate(hero.label).toLowerCase(),
100
+ }),
101
+ subtitle: translate('Consistent effort builds strong outcomes.'),
102
+ };
103
+ }
104
+
105
+ if (secondary.length >= 2) {
106
+ return {
107
+ title: translate('You made an impact across multiple services'),
108
+ subtitle: translate('Balanced efforts like yours strengthen community health.'),
109
+ };
110
+ }
111
+
112
+ return {
113
+ title: translate('You supported care beyond what’s shown here'),
114
+ subtitle: translate('Every visit, follow-up, and record counted.'),
115
+ };
116
+ };
117
+
118
+ const getTopAchievements = (metrics) => {
119
+ const scored = METRIC_CONFIG.map((m) => {
120
+ const provided = metrics[m.providedKey];
121
+ const pct = metrics[m.pctKey];
122
+
123
+ if (!provided || pct == null) return null;
124
+
125
+ const impactScore = provided * 10;
126
+ const percentileScore = 100 - pct;
127
+ const score = impactScore + percentileScore;
128
+
129
+ return {
130
+ ...m,
131
+ provided,
132
+ pct,
133
+ showRankLabel: pct < 50,
134
+ rankLabel: pct < 50 ? metrics[m.rankLabelKey] : null,
135
+ score,
136
+ };
137
+ })
138
+ .filter(Boolean)
139
+ .sort((a, b) => b.score - a.score);
140
+
141
+ return {
142
+ hero: scored[0] || null,
143
+ secondary: scored.slice(1, 4),
144
+ totalActive: scored.length,
145
+ };
146
+ };
147
+
148
+ /* -------------------- CELEBRATION CONFETTI -------------------- */
149
+
150
+ const ConfettiPiece = ({ side }) => {
151
+ const fromLeft = side === 'left';
152
+
153
+ const angleDeg = fromLeft ? 20 + Math.random() * 70 : 90 + Math.random() * 70;
154
+
155
+ const angle = (angleDeg * Math.PI) / 180;
156
+ const distance = 220 + Math.random() * 260;
157
+
158
+ const dx = Math.cos(angle) * distance;
159
+ const dy = Math.sin(angle) * distance;
160
+
161
+ const startY = -40 + Math.random() * 30;
162
+
163
+ return (
164
+ <motion.div
165
+ initial={{
166
+ x: fromLeft ? 0 : '100vw',
167
+ y: startY,
168
+ opacity: 1,
169
+ rotate: Math.random() * 360,
170
+ }}
171
+ animate={{
172
+ x: fromLeft ? dx : `calc(100vw + ${dx}px)`,
173
+ y: dy,
174
+ opacity: 0,
175
+ rotate: 360 + Math.random() * 360,
176
+ }}
177
+ transition={{
178
+ duration: 4,
179
+ ease: 'easeOut',
180
+ }}
181
+ style={{
182
+ position: 'absolute',
183
+ top: 0,
184
+ left: 0,
185
+ width: 8,
186
+ height: 12,
187
+ backgroundColor: ['#FFD54F', '#FF8A65', '#9575CD', '#4DB6AC'][Math.floor(Math.random() * 4)],
188
+ borderRadius: 2,
189
+ pointerEvents: 'none',
190
+ zIndex: 6,
191
+ }}
192
+ />
193
+ );
194
+ };
195
+
196
+ const ConfettiBurst = ({ active }) => {
197
+ if (!active) return null;
198
+
199
+ return (
200
+ <Box
201
+ sx={{
202
+ position: 'absolute',
203
+ inset: 0,
204
+ overflow: 'hidden',
205
+ pointerEvents: 'none',
206
+ zIndex: 6,
207
+ }}
208
+ >
209
+ {Array.from({ length: 60 }).map((_, i) => (
210
+ <ConfettiPiece key={`l-${i}`} side="left" />
211
+ ))}
212
+ {Array.from({ length: 60 }).map((_, i) => (
213
+ <ConfettiPiece key={`r-${i}`} side="right" />
214
+ ))}
215
+ </Box>
216
+ );
217
+ };
218
+
219
+ /* -------------------- DECORATIVE BUBBLES -------------------- */
220
+
221
+ const CelebrationBubble = ({ size, color, top, left, delay }) => (
222
+ <motion.div
223
+ initial={{ scale: 0, opacity: 0 }}
224
+ animate={{ scale: 1, opacity: 0.9 }}
225
+ transition={{ delay, duration: 1.2, ease: 'easeOut' }}
226
+ style={{
227
+ position: 'absolute',
228
+ width: size,
229
+ height: size,
230
+ borderRadius: '50%',
231
+ background: color,
232
+ top,
233
+ left,
234
+ filter: 'blur(0.5px)',
235
+ zIndex: 1,
236
+ }}
237
+ />
238
+ );
239
+
240
+ const AnimatedHero = ({ hero }) => {
241
+ const { translate } = useTranslateProvider();
242
+ return (
243
+ <motion.div
244
+ initial={{ scale: 0.85, opacity: 0 }}
245
+ animate={{ scale: 1, opacity: 1 }}
246
+ transition={{ duration: 0.8, ease: 'easeOut' }}
247
+ style={{
248
+ textAlign: 'center',
249
+ padding: 8,
250
+ borderRadius: 16,
251
+ background: `${hero.color}18`,
252
+ position: 'relative',
253
+ overflow: 'hidden',
254
+ }}
255
+ >
256
+ {/* Glow pulse */}
257
+ <motion.div
258
+ initial={{ opacity: 0 }}
259
+ animate={{ opacity: [0, 0.4, 0] }}
260
+ transition={{ duration: 2.4, repeat: Infinity }}
261
+ style={{
262
+ position: 'absolute',
263
+ inset: -20,
264
+ background: `radial-gradient(circle, ${hero.color}55, transparent 70%)`,
265
+ zIndex: 0,
266
+ }}
267
+ />
268
+
269
+ <Box
270
+ sx={{
271
+ position: 'relative',
272
+ zIndex: 1,
273
+ display: 'flex',
274
+ alignItems: 'center',
275
+ gap: 1,
276
+ justifyContent: 'center',
277
+ }}
278
+ >
279
+ <FontAwesomeIcons iconName={hero.icon} style={{ fontSize: '32px', color: hero.color, marginRight: '1rem' }} />
280
+
281
+ <Box>
282
+ <motion.div initial={{ y: 10, opacity: 0 }} animate={{ y: 0, opacity: 1 }} transition={{ delay: 0.3 }}>
283
+ <Typography variant="h2" fontWeight={900} color={hero.color}>
284
+ {hero.provided}
285
+ </Typography>
286
+ </motion.div>
287
+
288
+ <Typography fontWeight={700}>{hero.label}</Typography>
289
+ <Typography variant="caption" sx={{ opacity: 0.7 }}>
290
+ {translate(hero.rankLabel)}
291
+ </Typography>
292
+ </Box>
293
+ </Box>
294
+ </motion.div>
295
+ );
296
+ };
297
+
298
+ const FallbackCard = ({ translate }) => (
299
+ <Box sx={{ textAlign: 'center', p: 3 }}>
300
+ <Typography variant="h3">🤍</Typography>
301
+ <Typography variant="h6" fontWeight={800} sx={{ mt: 1 }}>
302
+ {translate('Thank you for being part of the system')}
303
+ </Typography>
304
+ <Typography variant="body2" sx={{ opacity: 0.7, mt: 1 }}>
305
+ {translate('Your role enables care delivery.')}
306
+ </Typography>
307
+ </Box>
308
+ );
309
+
310
+ const SummaryCard = ({ data, cardRef, translate }) => {
311
+ const { hero, secondary, totalActive } = getTopAchievements(data);
312
+ const closing = getClosingMessage(translate, {
313
+ hero,
314
+ secondary,
315
+ totalActive,
316
+ });
317
+
318
+ return (
319
+ <Card
320
+ ref={cardRef}
321
+ sx={{
322
+ width: '100%',
323
+ maxWidth: 340,
324
+ mx: 'auto',
325
+ p: 2,
326
+ borderRadius: 4,
327
+ background: 'linear-gradient(180deg, #ffffff 0%, #f8fbff 100%)',
328
+ boxShadow: '0 14px 30px rgba(0,0,0,0.15)',
329
+ }}
330
+ >
331
+ <Typography variant="h6" fontWeight={900} align="center" sx={{ textTransform: 'uppercase' }}>
332
+ {data.name}
333
+ </Typography>
334
+
335
+ <Divider sx={{ my: 2 }} />
336
+
337
+ {!hero && <FallbackCard translate={translate} />}
338
+
339
+ {hero && (
340
+ <>
341
+ {/* HERO */}
342
+ <AnimatedHero hero={{ ...hero, label: translate(hero.label) }} />
343
+
344
+ {/* SECONDARY */}
345
+ {secondary.length > 0 && (
346
+ <Box sx={{ mt: 2 }}>
347
+ {secondary.map((item) => (
348
+ <Box
349
+ key={item.key}
350
+ sx={{
351
+ display: 'flex',
352
+ alignItems: 'center',
353
+ justifyContent: 'space-between',
354
+ gap: 1.4,
355
+ mb: 1.2,
356
+ p: 1.8,
357
+ borderRadius: 2,
358
+ background: `${item.color}12`,
359
+ }}
360
+ >
361
+ <Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>
362
+ <FontAwesomeIcons iconName={item.icon} style={{ fontSize: '22px', color: item.color }} />
363
+
364
+ <Box sx={{ marginLeft: 1 }}>
365
+ <Typography fontWeight={700}>{translate(item.label)}</Typography>
366
+ <Typography variant="caption" sx={{ opacity: 0.6 }}>
367
+ {translate(item.rankLabel)}
368
+ </Typography>
369
+ </Box>
370
+ </Box>
371
+ <Typography fontWeight={700} variant="h4" sx={{ pr: 1 }}>
372
+ {item.provided}
373
+ </Typography>
374
+ </Box>
375
+ ))}
376
+ </Box>
377
+ )}
378
+ </>
379
+ )}
380
+
381
+ {/* CLOSING */}
382
+ <Divider sx={{ my: 2 }} />
383
+
384
+ <Typography variant="body2" align="center" fontWeight={700}>
385
+ 🌟 {closing.title}
386
+ </Typography>
387
+ <Typography variant="caption" align="center" display="block" sx={{ opacity: 0.6, mt: 0.5 }}>
388
+ {closing.subtitle}
389
+ </Typography>
390
+ </Card>
391
+ );
392
+ };
393
+
394
+ /* -------------------- OUTRO SLIDE -------------------- */
395
+
396
+ const OutroSlide = ({ data, onPrev, isActive }) => {
397
+ const { translate } = useTranslateProvider();
398
+ const [step, setStep] = useState(0);
399
+ const [showConfetti, setShowConfetti] = useState(false);
400
+ const cardRef = useRef(null);
401
+
402
+ const [isSharing, setIsSharing] = useState(false);
403
+
404
+ useEffect(() => {
405
+ if (!isActive) return;
406
+
407
+ setStep(0);
408
+ setShowConfetti(false);
409
+ setIsSharing(false);
410
+
411
+ const t1 = setTimeout(() => setStep(1), 1000);
412
+ const t2 = setTimeout(() => setStep(2), 2200);
413
+ const t3 = setTimeout(() => setShowConfetti(true), 2500);
414
+
415
+ return () => {
416
+ clearTimeout(t1);
417
+ clearTimeout(t2);
418
+ clearTimeout(t3);
419
+ };
420
+ }, [isActive]);
421
+
422
+ const downloadCard = async () => {
423
+ if (cardRef.current) {
424
+ try {
425
+ const canvas = await html2canvas(cardRef.current, {
426
+ useCORS: true,
427
+ scale: 3,
428
+ backgroundColor: '#f8fbff',
429
+ });
430
+ const dataUrl = canvas.toDataURL('image/png');
431
+ const link = document.createElement('a');
432
+ link.href = dataUrl;
433
+ link.download = `my-recap-${Date.now()}.png`;
434
+ link.click();
435
+ } catch (err) {
436
+ console.error('Download failed:', err);
437
+ }
438
+ }
439
+ };
440
+
441
+ const getCardFile = async () => {
442
+ if (!cardRef.current) {
443
+ console.log('[Share] cardRef.current is null');
444
+ return null;
445
+ }
446
+ try {
447
+ console.log('[Share] Generating canvas...');
448
+ const canvas = await html2canvas(cardRef.current, {
449
+ useCORS: true,
450
+ scale: 2,
451
+ backgroundColor: '#f8fbff',
452
+ logging: true,
453
+ });
454
+ console.log('[Share] Canvas generated, converting to blob...');
455
+ return new Promise((resolve) => {
456
+ canvas.toBlob((blob) => {
457
+ if (!blob) {
458
+ console.log('[Share] Blob generation failed');
459
+ resolve(null);
460
+ return;
461
+ }
462
+ console.log('[Share] Blob created, size:', blob.size);
463
+ const file = new File([blob], `recap-${Date.now()}.png`, {
464
+ type: 'image/png',
465
+ });
466
+ resolve(file);
467
+ }, 'image/png');
468
+ });
469
+ } catch (error) {
470
+ console.error('[Share] Error generating card image:', error);
471
+ return null;
472
+ }
473
+ };
474
+
475
+ const shareToWhatsApp = async () => {
476
+ if (isSharing) return;
477
+ setIsSharing(true);
478
+ console.log('[Share] Starting shareToWhatsApp...');
479
+ try {
480
+ const file = await getCardFile();
481
+
482
+ if (navigator.share) {
483
+ console.log('[Share] navigator.share exists');
484
+ try {
485
+ const canShare = navigator.canShare ? navigator.canShare({ files: [file] }) : true;
486
+ console.log('[Share] canShare result:', canShare);
487
+
488
+ if (file && canShare) {
489
+ console.log('[Share] Attempting to share file via system share...');
490
+ await navigator.share({
491
+ files: [file],
492
+ title: translate('My 2025 Recap'),
493
+ text: `${translate('Here’sasnapshotoftheworkIdidthisyear.')}\n${window.location.href}`,
494
+ });
495
+ console.log('[Share] WhatsApp file share successful');
496
+ return;
497
+ }
498
+ } catch (fileErr) {
499
+ console.log('[Share] WhatsApp file share failed, falling back to URL:', fileErr);
500
+ }
501
+ }
502
+
503
+ // Fallback for desktop or browsers that don't support file sharing
504
+ console.log('[Share] Falling back to WhatsApp URL...');
505
+ const text = `${translate('My 2025 Recap')}\n${translate('Here’sasnapshotoftheworkIdidthisyear.')}\n${window.location.href}`;
506
+ const url = `https://wa.me/?text=${encodeURIComponent(text)}`;
507
+ window.open(url, '_blank');
508
+ console.log('[Share] WhatsApp URL opened');
509
+ } catch (err) {
510
+ if (err.name !== 'AbortError') {
511
+ console.error('[Share] WhatsApp share failed:', err);
512
+ }
513
+ } finally {
514
+ setIsSharing(false);
515
+ }
516
+ };
517
+
518
+ return (
519
+ <RecapSlide
520
+ showNext={false}
521
+ onPrev={onPrev}
522
+ bgGradient="linear-gradient(to top, #fff1eb 0%, #ace0f9 100%)"
523
+ isActive={isActive}
524
+ >
525
+ <AnimatePresence>
526
+ {isActive && (
527
+ <Box
528
+ sx={{
529
+ position: 'relative',
530
+ height: '100%',
531
+ width: '100%',
532
+ display: 'flex',
533
+ flexDirection: 'column',
534
+ alignItems: 'center',
535
+ textAlign: 'center',
536
+ overflowY: 'auto',
537
+ overflowX: 'hidden',
538
+ scrollbarWidth: 'none',
539
+ '&::-webkit-scrollbar': {
540
+ display: 'none',
541
+ },
542
+ py: 2,
543
+ }}
544
+ >
545
+ <ConfettiBurst active={showConfetti} />
546
+
547
+ <CelebrationBubble size={220} color="#CFE9FF" top="-15%" left="-10%" delay={0.2} />
548
+ <CelebrationBubble size={180} color="#FFD6C9" top="70%" left="75%" delay={0.4} />
549
+ <CelebrationBubble size={140} color="#E1BEE7" top="10%" left="80%" delay={0.6} />
550
+
551
+ {/* ✅ Centering Wrapper */}
552
+ <Box
553
+ sx={{
554
+ marginTop: 'auto',
555
+ marginBottom: 'auto',
556
+ display: 'flex',
557
+ flexDirection: 'column',
558
+ alignItems: 'center',
559
+ width: '100%',
560
+ zIndex: 2,
561
+ }}
562
+ >
563
+ {/* ✅ LAYOUT ANIMATED CONTAINER */}
564
+ <motion.div
565
+ layout
566
+ transition={{
567
+ layout: {
568
+ duration: 1.2,
569
+ ease: 'easeInOut',
570
+ },
571
+ }}
572
+ style={{
573
+ display: 'flex',
574
+ flexDirection: 'column',
575
+ alignItems: 'center',
576
+ }}
577
+ >
578
+ {/* Heading */}
579
+ <motion.div
580
+ layout
581
+ initial={{ opacity: 0 }}
582
+ animate={{ opacity: 1 }}
583
+ transition={{ opacity: { duration: 0.8 } }}
584
+ >
585
+ <Typography variant="h4" fontWeight={900} sx={{ mb: 1, mt: 2 }}>
586
+ {translate('Happy New Year! 🎉')}
587
+ </Typography>
588
+ <Typography variant="body1" sx={{ color: '#444' }}>
589
+ {translate('Thank you for everything you did this year.')}
590
+ </Typography>
591
+ </motion.div>
592
+
593
+ {/* Card */}
594
+ {step >= 1 && (
595
+ <motion.div
596
+ layout
597
+ initial={{ opacity: 0, y: 20 }}
598
+ animate={{ opacity: 1, y: 0 }}
599
+ transition={{
600
+ opacity: { duration: 0.8 },
601
+ y: { duration: 0.8, ease: 'easeOut' },
602
+ }}
603
+ style={{ marginTop: 12 }}
604
+ >
605
+ <SummaryCard data={data} cardRef={cardRef} translate={translate} />
606
+ </motion.div>
607
+ )}
608
+ </motion.div>
609
+
610
+ {/* Actions */}
611
+ {step >= 2 && (
612
+ <motion.div
613
+ initial={{ opacity: 0 }}
614
+ animate={{ opacity: 1 }}
615
+ transition={{ delay: 0.2 }}
616
+ style={{
617
+ display: 'flex',
618
+ flexDirection: 'column',
619
+ gap: 12,
620
+ marginTop: 20,
621
+ width: '100%',
622
+ maxWidth: 340,
623
+ paddingBottom: '1rem',
624
+ }}
625
+ >
626
+ <Box sx={{ display: 'flex', gap: 2, width: '100%' }}>
627
+ <Button
628
+ variant="contained"
629
+ fullWidth
630
+ startIcon={
631
+ isSharing ? (
632
+ <CircularProgress size={20} color="inherit" />
633
+ ) : (
634
+ <FontAwesomeIcons iconName="faShareNodes" />
635
+ )
636
+ }
637
+ onClick={shareToWhatsApp}
638
+ disabled={isSharing}
639
+ sx={{ borderRadius: 6, py: 1 }}
640
+ >
641
+ {isSharing ? translate('Processing...') : translate('Share')}
642
+ </Button>
643
+
644
+ <Button
645
+ variant="outlined"
646
+ fullWidth
647
+ startIcon={<FontAwesomeIcons iconName="faDownload" />}
648
+ onClick={downloadCard}
649
+ disabled={isSharing}
650
+ sx={{ borderRadius: 6, py: 1 }}
651
+ >
652
+ {translate('Download')}
653
+ </Button>
654
+ </Box>
655
+ </motion.div>
656
+ )}
657
+ </Box>
658
+ </Box>
659
+ )}
660
+ </AnimatePresence>
661
+ </RecapSlide>
662
+ );
663
+ };
664
+
665
+ ConfettiBurst.propTypes = {
666
+ active: PropTypes.bool,
667
+ };
668
+
669
+ CelebrationBubble.propTypes = {
670
+ size: PropTypes.any,
671
+ color: PropTypes.any,
672
+ top: PropTypes.any,
673
+ left: PropTypes.any,
674
+ delay: PropTypes.any,
675
+ };
676
+
677
+ AnimatedHero.propTypes = {
678
+ hero: PropTypes.object,
679
+ };
680
+
681
+ FallbackCard.propTypes = {
682
+ translate: PropTypes.func,
683
+ };
684
+
685
+ ConfettiPiece.propTypes = {
686
+ side: PropTypes.any,
687
+ };
688
+
689
+ SummaryCard.propTypes = {
690
+ data: PropTypes.any,
691
+ cardRef: PropTypes.object,
692
+ translate: PropTypes.func,
693
+ };
694
+
695
+ OutroSlide.propTypes = {
696
+ data: PropTypes.any,
697
+ onPrev: PropTypes.func,
698
+ isActive: PropTypes.bool,
699
+ };
700
+
701
+ export default OutroSlide;