@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.
- package/package.json +139 -141
- package/src/GlobalErrorBoundary.jsx +31 -0
- package/src/SilentErrorFallback.jsx +68 -0
- package/src/TrackingProviderWrapper.jsx +40 -0
- package/src/_tests_/__mocks__/MockTranslationProvider.jsx +21 -0
- package/src/_tests_/__mocks__/ckeditor.js +45 -0
- package/src/_tests_/__mocks__/fileMock.js +1 -0
- package/src/_tests_/__mocks__/useranalytics.js +5 -0
- package/src/_tests_/views/components/Dashboard/DashboardUI.test.jsx +137 -0
- package/src/_tests_/views/components/Dashboard/DashboardUIMock.js +877 -0
- package/src/_tests_/views/components/ForgotPassword/ForgotPassword.test.jsx +314 -0
- package/src/_tests_/views/components/LocationDirective/LocationDirective.test.jsx.disable +229 -0
- package/src/_tests_/views/components/LocationDirective/mockLocationDirective.js +810 -0
- package/src/_tests_/views/components/LocationType/MockLocationType.js +42259 -0
- package/src/_tests_/views/components/LocationType/addlocationtype.test.jsx.disable +276 -0
- package/src/_tests_/views/components/LocationType/editlocationtype.test.jsx.disable +262 -0
- package/src/_tests_/views/components/LocationType/locationtype.test.jsx.disable +148 -0
- package/src/_tests_/views/components/Profile/UpdateProfileModalData.js +4396 -0
- package/src/_tests_/views/components/Profile/updateprofilemodal.test.jsx +282 -0
- package/src/_tests_/views/components/SideBar/MockSideBar.js +1379 -0
- package/src/_tests_/views/components/SideBar/SideBar.test.jsx +98 -0
- package/src/_tests_/views/components/SystemConfig/ManageSystemConfig/AddManageSystemConfig.test.jsx.disable +164 -0
- package/src/_tests_/views/components/SystemConfig/ManageSystemConfig/UpdateManageSystemConfig.test.jsx.disable +157 -0
- package/src/_tests_/views/components/SystemConfig/MockSystemConfig.js +1280 -0
- package/src/_tests_/views/components/SystemConfig/SystemConfig.test.jsx.disable +165 -0
- package/src/_tests_/views/components/login/Login.test.jsx +276 -0
- package/src/_tests_/views/components/login/MockAuthorise.js +2414 -0
- package/src/_tests_/views/components/login/ServiceResponse.js +595 -0
- package/src/_tests_/views/components/user/MockManageUser.js +7965 -0
- package/src/_tests_/views/components/user/manageuser.test.jsx.disable +989 -0
- package/src/_tests_/views/components/user/mockUsersData.js +582 -0
- package/src/assets/img/OASISLogin.png +0 -0
- package/src/assets/img/bahaarNew.png +0 -0
- package/src/assets/img/dnhdd4K.png +0 -0
- package/src/assets/img/govtofup.png +0 -0
- package/src/assets/img/sewarural4K.png +0 -0
- package/src/assets/img/techo4K.png +0 -0
- package/src/assets/img/up4K.png +0 -0
- package/src/common/HolidayList.jsx +573 -0
- package/src/common/MalaciaousInputUtil.js +23 -0
- package/src/common/SafeHtml.jsx +17 -0
- package/src/common/VersionManager.jsx +109 -0
- package/src/common/constants/PerformanceDashboard.js +514 -0
- package/src/common/constants/app.constant.js +781 -0
- package/src/common/constants/cccVerificationConstants.js +18 -0
- package/src/common/constants/fhsrConstant.js +33 -0
- package/src/common/constants/gvk-verification.constant.js +76 -0
- package/src/common/constants/search.constant.js +23 -0
- package/src/common/constants/teleconsulatationConstant.jsx +1339 -0
- package/src/common/directives/SearchTemplate.jsx +784 -0
- package/src/common/directives/SearchTemplate.scss +14 -0
- package/src/common/dynamicView/DynamicView.jsx +353 -0
- package/src/common/dynamicView/InputFieldComponent.jsx +1501 -0
- package/src/common/dynamicView/InputViewComponent.jsx +298 -0
- package/src/common/dynamicView/InputViewComponent.scss +15 -0
- package/src/common/env.js +5 -0
- package/src/common/filters/locationNameFilter.js +26 -0
- package/src/common/fontAwesomeIcons/FontAwesomeIcons.jsx +27 -0
- package/src/common/fontAwesomeIcons/FontAwesomeIconsNames.js +1968 -0
- package/src/common/fontPreferences/fontSizeProvider.jsx +34 -0
- package/src/common/fontPreferences/fontSizeSelector.jsx +116 -0
- package/src/common/getAssignedFeature/getAssignedFeature.js +32 -0
- package/src/common/interceptors/AxiosInterceptor.js +216 -0
- package/src/common/languageTranslator/TranslationContext.js +5 -0
- package/src/common/languageTranslator/TranslationProvider.jsx +24 -0
- package/src/common/languageTranslator/i18n.js +49 -0
- package/src/common/services/AuthenticateService.js +116 -0
- package/src/common/services/DownloadFile.js +35 -0
- package/src/common/services/ForgotPassword.js +18 -0
- package/src/common/services/FormConfiguratorService.js +195 -0
- package/src/common/services/GlobalApis.js +84 -0
- package/src/common/services/InterceptorNavigationService.js +17 -0
- package/src/common/services/LocationService.js +65 -0
- package/src/common/services/LocationType.js +11 -0
- package/src/common/services/QueryBuilder.js +36 -0
- package/src/common/services/Roles.js +28 -0
- package/src/common/services/SyncWithServer.js +15 -0
- package/src/common/services/SystemConfig.js +15 -0
- package/src/common/services/TranslationService.js +70 -0
- package/src/common/services/TwoFactorService.js +7 -0
- package/src/common/services/Users.js +91 -0
- package/src/common/services/Webtasks.js +27 -0
- package/src/common/services/util/Convert-pad-data-to-API-format.jsx +167 -0
- package/src/common/services/util/Convert-to-UI-format.jsx +82 -0
- package/src/common/services/util/EmptyPrescriptionPadData.jsx +11 -0
- package/src/common/services/util/GeneralUtil.js +456 -0
- package/src/common/services/util/Prescription-pad-util.js +339 -0
- package/src/common/services/util/PrescriptionPadData.js +67 -0
- package/src/common/services/util/PrescriptionpadCommonUtil.js +96 -0
- package/src/common/services/util/ReportFieldUtil.jsx +398 -0
- package/src/common/services/util/WebSocketContext.jsx +261 -0
- package/src/common/syncWithServer/SyncWithServerDialog.jsx +170 -0
- package/src/common/syncWithServer/SyncWithServerDialogSkeleton.jsx +67 -0
- package/src/common/tests/CustomWrapper.jsx +49 -0
- package/src/common/tests/TranslationWrapper.jsx +38 -0
- package/src/common/themeProvider/ColorInputs.jsx +97 -0
- package/src/common/themeProvider/EditableColorInput.jsx +128 -0
- package/src/common/themeProvider/ThemeEditor.jsx +319 -0
- package/src/common/themeProvider/ThemeProvider.jsx +210 -0
- package/src/common/themeProvider/themeConfig.js +558 -0
- package/src/common/toaster/toaster.jsx +30 -0
- package/src/firebaseConfig.js +24 -0
- package/src/global.scss +221 -0
- package/src/hooks/.gitkeep +0 -0
- package/src/hooks/useAESEncryption.js +56 -0
- package/src/hooks/useCaching.js +43 -0
- package/src/hooks/useDebounce.js +34 -0
- package/src/hooks/useDebounceFn.js +50 -0
- package/src/hooks/useDownloadPdf.js +358 -0
- package/src/hooks/useDownloadXlsx.js +55 -0
- package/src/hooks/useListValueFieldValues.js +30 -0
- package/src/hooks/useLocationHierarchies.js +63 -0
- package/src/hooks/useLocationHierarchyTranslate.js +16 -0
- package/src/hooks/useOnline.js +27 -0
- package/src/hooks/usePagination.js +63 -0
- package/src/hooks/useRefreshToken.js +87 -0
- package/src/hooks/useScript.js +25 -0
- package/src/hooks/useStopwatch.js +75 -0
- package/src/hooks/useTrackEvent.js +22 -0
- package/src/hooks/useWebAudioRecorder.js +115 -0
- package/src/layout/LoaderComponet.jsx +22 -0
- package/src/layout/LoaderContext.jsx +29 -0
- package/src/layout/mainLayout/AdaptiveZoom.jsx +27 -0
- package/src/layout/mainLayout/Chatbot.jsx +243 -0
- package/src/layout/mainLayout/Layout.jsx +445 -0
- package/src/layout/mainLayout/Profile/UpdateProfileModal.jsx +684 -0
- package/src/layout/mainLayout/header/LogoutModal.jsx +131 -0
- package/src/layout/mainLayout/header/Navbar.jsx +1677 -0
- package/src/layout/mainLayout/header/Navbar.scss +4 -0
- package/src/layout/mainLayout/header/index.js +0 -0
- package/src/layout/mainLayout/sidebar/SideBar.jsx +1402 -0
- package/src/layout/mainLayout/sidebar/Sidebar.css +159 -0
- package/src/layout/mainLayout/sidebar/index.js +0 -0
- package/src/logo.svg +1 -0
- package/src/reportWebVitals.js +13 -0
- package/src/setupFirebaseMessaging.js +28 -0
- package/src/setupTests.js +8 -0
- package/src/store/actions/AuthenticationActions.js +0 -0
- package/src/store/actions/ReportsActions.js +0 -0
- package/src/store/actions/TranslationAction.js +0 -0
- package/src/store/index.js +8 -0
- package/src/store/reducer.js +46 -0
- package/src/store/reducers/AuthenticationReducer.js +50 -0
- package/src/store/reducers/CalendarEventReducer.js +41 -0
- package/src/store/reducers/ConditionClipboardReducer.js +45 -0
- package/src/store/reducers/FeatureReducer.js +27 -0
- package/src/store/reducers/FormConfiguratorReducer.js +38 -0
- package/src/store/reducers/LoadingReducer.js +20 -0
- package/src/store/reducers/MembersAuthenticationReducer.js +28 -0
- package/src/store/reducers/PrescriptionPadReducer.js +329 -0
- package/src/store/reducers/QuestionaireReducer.js +29 -0
- package/src/store/reducers/ReportsReducer.js +24 -0
- package/src/store/reducers/SkeletonReducer.js +20 -0
- package/src/store/reducers/ThemeReducer.js +106 -0
- package/src/store/reducers/TranslationReducer.js +126 -0
- package/src/store/reducers/dashboardEditorSlice.js +77 -0
- package/src/store/reducers/districtHealthDashboardSlice.js +58 -0
- package/src/store/reducers/immunizationSlice.js +234 -0
- package/src/store/slices/dashboardPagesSlice.js +51 -0
- package/src/utils/.gitkeep +0 -0
- package/src/utils/FormConstants.js +2629 -0
- package/src/utils/GujaratTopoChart.jsx +483 -0
- package/src/utils/UUIDgenerator.js +8 -0
- package/src/utils/appointment-utils/appointment-utils.js +123 -0
- package/src/utils/feature.js +42 -0
- package/src/utils/getThemeColor.js +12 -0
- package/src/utils/localStorageHelper.js +11 -0
- package/src/utils/notifications/enable-push-notifications.js +27 -0
- package/src/utils/resolveAppliedStyle.js +11 -0
- package/src/utils/themeConfigs.js +1483 -0
- package/src/views/custom-components/.gitkeep +0 -0
- package/src/views/custom-components/AgIconButton/RIf.jsx +14 -0
- package/src/views/custom-components/AgIconButton/button.jsx +108 -0
- package/src/views/custom-components/AgIconButton/waterDrop.jsx +95 -0
- package/src/views/custom-components/AgIconButton/waterDrop.scss +37 -0
- package/src/views/custom-components/AlertPlaceholder.jsx +32 -0
- package/src/views/custom-components/AllFaIconsSelector.jsx +56 -0
- package/src/views/custom-components/CkEditor/CkEditor.js +102 -0
- package/src/views/custom-components/CustomAccordion.jsx +72 -0
- package/src/views/custom-components/CustomActionIcons.jsx +118 -0
- package/src/views/custom-components/CustomAutoComplete.jsx +188 -0
- package/src/views/custom-components/CustomCheckBox.jsx +60 -0
- package/src/views/custom-components/CustomConfirmationModal.jsx +118 -0
- package/src/views/custom-components/CustomCountrySelect.jsx +129 -0
- package/src/views/custom-components/CustomDatePicker.jsx +122 -0
- package/src/views/custom-components/CustomDropdown.jsx +191 -0
- package/src/views/custom-components/CustomFileUpload.jsx +387 -0
- package/src/views/custom-components/CustomFullCalendar.jsx +514 -0
- package/src/views/custom-components/CustomInfiniteScroll.jsx +126 -0
- package/src/views/custom-components/CustomRadioComponent.jsx +65 -0
- package/src/views/custom-components/CustomStatsComponent.jsx +114 -0
- package/src/views/custom-components/CustomSvgUpload.jsx +170 -0
- package/src/views/custom-components/CustomSwitch.jsx +37 -0
- package/src/views/custom-components/CustomTabPanel.jsx +19 -0
- package/src/views/custom-components/CustomTextArea.jsx +62 -0
- package/src/views/custom-components/CustomTextArea.scss +27 -0
- package/src/views/custom-components/CustomTextField.jsx +116 -0
- package/src/views/custom-components/CustomToggleSwitch.jsx +138 -0
- package/src/views/custom-components/CustomTooltip.jsx +51 -0
- package/src/views/custom-components/CustomZoomImage.jsx +134 -0
- package/src/views/custom-components/CustomizedTable/CustomizedTableV2.jsx +1407 -0
- package/src/views/custom-components/CustomizedTable/VirtualizeTableBody.jsx +295 -0
- package/src/views/custom-components/CustomizedTable/helper.jsx +159 -0
- package/src/views/custom-components/CustomizedTable.jsx +532 -0
- package/src/views/custom-components/EditInputField.jsx +174 -0
- package/src/views/custom-components/FieldDescription.jsx +22 -0
- package/src/views/custom-components/FileDisplayComponent.jsx +138 -0
- package/src/views/custom-components/FormItem.jsx +53 -0
- package/src/views/custom-components/GenericChart.jsx +80 -0
- package/src/views/custom-components/InfoBadge.jsx +60 -0
- package/src/views/custom-components/PostgresEditor.jsx +801 -0
- package/src/views/custom-components/ResizableEditAutocompleteField.jsx +249 -0
- package/src/views/custom-components/ResizableEditInputField.jsx +215 -0
- package/src/views/custom-components/ResizeableEditSelectField.jsx +197 -0
- package/src/views/custom-components/SideOverlay.jsx +113 -0
- package/src/views/custom-components/SideOverlay.scss +42 -0
- package/src/views/custom-components/calendar.scss +571 -0
- package/src/views/feature-components/.gitkeep +0 -0
- package/src/views/feature-components/Dashboard/DashboardUI.jsx +1043 -0
- package/src/views/feature-components/Dashboard/DhnddModal/AshaDataQualityVerificationModal.jsx +278 -0
- package/src/views/feature-components/Dashboard/PinFeatureModal.jsx +143 -0
- package/src/views/feature-components/Dashboard/QuickLinks.jsx +163 -0
- package/src/views/feature-components/Dashboard/Taskbar.jsx +56 -0
- package/src/views/feature-components/Dashboard/WebtasksFilterForm.jsx +109 -0
- package/src/views/feature-components/Dashboard/WidgetCard.jsx +161 -0
- package/src/views/feature-components/Dashboard/actionModal.jsx +263 -0
- package/src/views/feature-components/Dashboard/ekavachModal/HealthWorkerIncorrectDetailsModal.jsx +332 -0
- package/src/views/feature-components/Dashboard/ekavachModal/MoMaternalDeathVerifcationModal.jsx +275 -0
- package/src/views/feature-components/Dashboard/ekavachModal/MoVerficationForChildScreeningMoadal.jsx +566 -0
- package/src/views/feature-components/FeatureUsageAnalytics/FeatureUsageAnalytics.jsx +989 -0
- package/src/views/feature-components/Features/NewServerManagement.jsx +217 -0
- package/src/views/feature-components/Features/ServerManagement.scss +120 -0
- package/src/views/feature-components/ForgotPassword/ForgotPassword.jsx +226 -0
- package/src/views/feature-components/LocationDirective/LocationDirective.jsx +992 -0
- package/src/views/feature-components/LocationDirective/LocationDirectiveV2.jsx +909 -0
- package/src/views/feature-components/NotFound.jsx +66 -0
- package/src/views/feature-components/Onboarding/Onboarding.jsx +1400 -0
- package/src/views/feature-components/Skeletons.js +115 -0
- package/src/views/feature-components/Unauthorized.jsx +48 -0
- package/src/views/feature-components/VerifyRoute.jsx +88 -0
- package/src/views/feature-components/YearlyRecap/YearlyRecap.jsx +357 -0
- package/src/views/feature-components/YearlyRecap/components/RecapSlide.jsx +183 -0
- package/src/views/feature-components/YearlyRecap/languageTranslator/TranslationContext.js +5 -0
- package/src/views/feature-components/YearlyRecap/languageTranslator/TranslationProvider.jsx +26 -0
- package/src/views/feature-components/YearlyRecap/languageTranslator/i18n.js +46 -0
- package/src/views/feature-components/YearlyRecap/languageTranslator/translations.json +167 -0
- package/src/views/feature-components/YearlyRecap/slides/IntroSlide.jsx +233 -0
- package/src/views/feature-components/YearlyRecap/slides/MaternalHealthSlide.jsx +146 -0
- package/src/views/feature-components/YearlyRecap/slides/MetricSlide.jsx +227 -0
- package/src/views/feature-components/YearlyRecap/slides/OutroSlide.jsx +701 -0
- package/src/views/feature-components/YearlyRecap/slides/ReachSlide.jsx +273 -0
- package/src/views/feature-components/login/Login.jsx +840 -0
- package/src/views/feature-components/login/Login.scss +154 -0
- package/src/views/feature-components/login/LoginConfigurator.jsx +1149 -0
- package/src/views/feature-components/login/TwoFactorSetupModal.jsx +411 -0
- package/src/views/feature-components/login/simplifyMenu.js +45 -0
- package/src/views/feature-components/system-config/ManageSystemConfigs.jsx +284 -0
- package/src/views/feature-components/system-config/SystemConfig.jsx +299 -0
- package/src/views/feature-components/users/ChangePasswordModal.jsx +243 -0
- package/src/views/feature-components/users/PasswordField.jsx +56 -0
- package/dist/index.css +0 -1
- package/dist/index.js +0 -32001
- package/dist/index.js.map +0 -1
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
import { createSlice } from '@reduxjs/toolkit';
|
|
2
|
+
import { emptyPrescriptionPadData } from '@/common/services/util/EmptyPrescriptionPadData';
|
|
3
|
+
|
|
4
|
+
const initialState = {
|
|
5
|
+
currentPrescription: {
|
|
6
|
+
medicationsArr: [],
|
|
7
|
+
symptomsArr: [],
|
|
8
|
+
diagnosisArr: [],
|
|
9
|
+
labInvestigationsArr: [],
|
|
10
|
+
advicesArr: [],
|
|
11
|
+
vaccineArr: [],
|
|
12
|
+
procedureArr: [],
|
|
13
|
+
oeData: [],
|
|
14
|
+
prescriptionOnExaminationResults: [],
|
|
15
|
+
soapNotes: {},
|
|
16
|
+
isUpdated: false, // to prevent duplicate auto-save on adding new items
|
|
17
|
+
prescriptionStatus: '',
|
|
18
|
+
isCurrentPrescriptionPadUpdated: false,
|
|
19
|
+
isFetchAndSetPrescription: false,
|
|
20
|
+
selectedOETemplateId: null,
|
|
21
|
+
},
|
|
22
|
+
prescriptionId: null,
|
|
23
|
+
patientPastPrescriptions: {
|
|
24
|
+
id: '',
|
|
25
|
+
appointmentId: '',
|
|
26
|
+
appointmentResponse: {},
|
|
27
|
+
medicationsArr: [],
|
|
28
|
+
symptomsArr: [],
|
|
29
|
+
diagnosisArr: [],
|
|
30
|
+
labInvestigationsArr: [],
|
|
31
|
+
vaccineArr: [],
|
|
32
|
+
procedureArr: [],
|
|
33
|
+
advicesArr: [],
|
|
34
|
+
oeData: [],
|
|
35
|
+
soapNotes: {},
|
|
36
|
+
isPastPrescriptionPadUpdated: false,
|
|
37
|
+
},
|
|
38
|
+
prescriptionIndex: -1,
|
|
39
|
+
hasUpdates: false,
|
|
40
|
+
templateNameInfo: {
|
|
41
|
+
selectedMenuItemLabel: '',
|
|
42
|
+
templateLabel: '',
|
|
43
|
+
},
|
|
44
|
+
templateMenus: [],
|
|
45
|
+
removedPrescriptionPadData: { ...emptyPrescriptionPadData },
|
|
46
|
+
draftedPrescriptionPayloadInLocalStorage: null,
|
|
47
|
+
selectedPrescriptionId: null,
|
|
48
|
+
pdfLanguageMap: {},
|
|
49
|
+
createdOrUpdatedPrescription: null,
|
|
50
|
+
prescriptionTranscript: '',
|
|
51
|
+
isPatientVaccinePresent: false,
|
|
52
|
+
categorySearch: false,
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const prescriptionPadSlice = createSlice({
|
|
56
|
+
name: 'prescriptionPad',
|
|
57
|
+
initialState,
|
|
58
|
+
reducers: {
|
|
59
|
+
setPrescriptionPadData(state, action) {
|
|
60
|
+
state.currentPrescription = {
|
|
61
|
+
medicationsArr: action.payload.medicationsArr,
|
|
62
|
+
symptomsArr: action.payload.symptomsArr,
|
|
63
|
+
diagnosisArr: action.payload.diagnosisArr,
|
|
64
|
+
labInvestigationsArr: action.payload.labInvestigationsArr,
|
|
65
|
+
vaccineArr: action.payload.vaccineArr,
|
|
66
|
+
procedureArr: action.payload.procedureArr,
|
|
67
|
+
advicesArr: action.payload.advicesArr,
|
|
68
|
+
oeData: action.payload.oeData,
|
|
69
|
+
soapNotes: action.payload.soapNotes,
|
|
70
|
+
isUpdated: action.payload.isUpdated || false,
|
|
71
|
+
prescriptionOnExaminationResults: action.payload.prescriptionOnExaminationResults,
|
|
72
|
+
isCurrentPrescriptionPadUpdated: action.payload.isCurrentPrescriptionPadUpdated || false,
|
|
73
|
+
isFetchAndSetPrescription: action.payload.isFetchAndSetPrescription || false,
|
|
74
|
+
prescriptionStatus: action.payload.prescriptionStatus || state.currentPrescription?.prescriptionStatus,
|
|
75
|
+
selectedOETemplateId: action.payload.selectedOETemplateId || state.currentPrescription?.selectedOETemplateId,
|
|
76
|
+
};
|
|
77
|
+
},
|
|
78
|
+
updateMedications(state, action) {
|
|
79
|
+
const prescriptionIndex = Number.isInteger(action.payload.prescriptionIndex)
|
|
80
|
+
? action.payload.prescriptionIndex
|
|
81
|
+
: -1;
|
|
82
|
+
if (prescriptionIndex === -1) {
|
|
83
|
+
state.currentPrescription.medicationsArr = state.currentPrescription.medicationsArr.map((item, i) =>
|
|
84
|
+
i === action.payload.index ? { ...item, [action.payload.field]: action.payload.value } : item
|
|
85
|
+
);
|
|
86
|
+
state.currentPrescription.isUpdated = false;
|
|
87
|
+
state.currentPrescription.isCurrentPrescriptionPadUpdated = true;
|
|
88
|
+
} else {
|
|
89
|
+
state.patientPastPrescriptions.medicationsArr = state.patientPastPrescriptions.medicationsArr.map((item, i) =>
|
|
90
|
+
i === action.payload.index ? { ...item, [action.payload.field]: action.payload.value } : item
|
|
91
|
+
);
|
|
92
|
+
state.patientPastPrescriptions.isPastPrescriptionPadUpdated = true;
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
setMedications(state, action) {
|
|
96
|
+
state.currentPrescription.medicationsArr = action.payload;
|
|
97
|
+
state.currentPrescription.isUpdated = false;
|
|
98
|
+
state.currentPrescription.isCurrentPrescriptionPadUpdated = true;
|
|
99
|
+
},
|
|
100
|
+
setSymptoms(state, action) {
|
|
101
|
+
const prescriptionIndex = Number.isInteger(action.payload.prescriptionIndex)
|
|
102
|
+
? action.payload.prescriptionIndex
|
|
103
|
+
: -1;
|
|
104
|
+
if (prescriptionIndex === -1) {
|
|
105
|
+
state.currentPrescription.symptomsArr = state.currentPrescription.symptomsArr?.map((item, i) =>
|
|
106
|
+
i === action.payload.index ? { ...item, [action.payload.field]: action.payload.value } : item
|
|
107
|
+
);
|
|
108
|
+
state.currentPrescription.isUpdated = false;
|
|
109
|
+
state.currentPrescription.isCurrentPrescriptionPadUpdated = true;
|
|
110
|
+
} else {
|
|
111
|
+
state.patientPastPrescriptions.symptomsArr = state.patientPastPrescriptions.symptomsArr?.map((item, i) =>
|
|
112
|
+
i === action.payload.index ? { ...item, [action.payload.field]: action.payload.value } : item
|
|
113
|
+
);
|
|
114
|
+
state.patientPastPrescriptions.isPastPrescriptionPadUpdated = true;
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
setVaccine(state, action) {
|
|
118
|
+
const prescriptionIndex = Number.isInteger(action.payload.prescriptionIndex)
|
|
119
|
+
? action.payload.prescriptionIndex
|
|
120
|
+
: -1;
|
|
121
|
+
if (prescriptionIndex === -1) {
|
|
122
|
+
state.currentPrescription.vaccineArr = state.currentPrescription.vaccineArr.map((item, i) =>
|
|
123
|
+
i === action.payload.index ? { ...item, [action.payload.field]: action.payload.value } : item
|
|
124
|
+
);
|
|
125
|
+
state.currentPrescription.isUpdated = false;
|
|
126
|
+
state.currentPrescription.isCurrentPrescriptionPadUpdated = true;
|
|
127
|
+
} else {
|
|
128
|
+
state.patientPastPrescriptions.vaccineArr = state.patientPastPrescriptions.vaccineArr.map((item, i) =>
|
|
129
|
+
i === action.payload.index ? { ...item, [action.payload.field]: action.payload.value } : item
|
|
130
|
+
);
|
|
131
|
+
state.patientPastPrescriptions.isPastPrescriptionPadUpdated = true;
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
setProcedure(state, action) {
|
|
135
|
+
const prescriptionIndex = Number.isInteger(action.payload.prescriptionIndex)
|
|
136
|
+
? action.payload.prescriptionIndex
|
|
137
|
+
: -1;
|
|
138
|
+
if (prescriptionIndex === -1) {
|
|
139
|
+
state.currentPrescription.procedureArr = state.currentPrescription.procedureArr.map((item, i) =>
|
|
140
|
+
i === action.payload.index ? { ...item, [action.payload.field]: action.payload.value } : item
|
|
141
|
+
);
|
|
142
|
+
state.currentPrescription.isUpdated = false;
|
|
143
|
+
state.currentPrescription.isCurrentPrescriptionPadUpdated = true;
|
|
144
|
+
} else {
|
|
145
|
+
state.patientPastPrescriptions.procedureArr = state.patientPastPrescriptions.procedureArr.map((item, i) =>
|
|
146
|
+
i === action.payload.index ? { ...item, [action.payload.field]: action.payload.value } : item
|
|
147
|
+
);
|
|
148
|
+
state.patientPastPrescriptions.isPastPrescriptionPadUpdated = true;
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
setDiagnosis(state, action) {
|
|
152
|
+
const prescriptionIndex = Number.isInteger(action.payload.prescriptionIndex)
|
|
153
|
+
? action.payload.prescriptionIndex
|
|
154
|
+
: -1;
|
|
155
|
+
|
|
156
|
+
if (prescriptionIndex === -1) {
|
|
157
|
+
state.currentPrescription.diagnosisArr = state.currentPrescription.diagnosisArr.map((item, i) =>
|
|
158
|
+
i === action.payload.index ? { ...item, [action.payload.field]: action.payload.value } : item
|
|
159
|
+
);
|
|
160
|
+
state.currentPrescription.isUpdated = false;
|
|
161
|
+
state.currentPrescription.isCurrentPrescriptionPadUpdated = true;
|
|
162
|
+
} else {
|
|
163
|
+
state.patientPastPrescriptions.diagnosisArr = state.patientPastPrescriptions.diagnosisArr.map((item, i) =>
|
|
164
|
+
i === action.payload.index ? { ...item, [action.payload.field]: action.payload.value } : item
|
|
165
|
+
);
|
|
166
|
+
state.patientPastPrescriptions.isPastPrescriptionPadUpdated = true;
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
setLabInvestigations(state, action) {
|
|
170
|
+
const prescriptionIndex = Number.isInteger(action.payload.prescriptionIndex)
|
|
171
|
+
? action.payload.prescriptionIndex
|
|
172
|
+
: -1;
|
|
173
|
+
if (prescriptionIndex === -1) {
|
|
174
|
+
state.currentPrescription.labInvestigationsArr = state.currentPrescription.labInvestigationsArr.map(
|
|
175
|
+
(item, i) => (i === action.payload.index ? { ...item, [action.payload.field]: action.payload.value } : item)
|
|
176
|
+
);
|
|
177
|
+
state.currentPrescription.isUpdated = false;
|
|
178
|
+
state.currentPrescription.isCurrentPrescriptionPadUpdated = true;
|
|
179
|
+
} else {
|
|
180
|
+
state.patientPastPrescriptions.labInvestigationsArr = state.patientPastPrescriptions.labInvestigationsArr.map(
|
|
181
|
+
(item, i) => (i === action.payload.index ? { ...item, [action.payload.field]: action.payload.value } : item)
|
|
182
|
+
);
|
|
183
|
+
state.patientPastPrescriptions.isPastPrescriptionPadUpdated = true;
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
updateAdvices(state, action) {
|
|
187
|
+
const prescriptionIndex = Number.isInteger(action.payload.prescriptionIndex)
|
|
188
|
+
? action.payload.prescriptionIndex
|
|
189
|
+
: -1;
|
|
190
|
+
if (prescriptionIndex === -1) {
|
|
191
|
+
state.currentPrescription.advicesArr = state.currentPrescription.advicesArr.map((item, i) =>
|
|
192
|
+
i === action.payload.index ? { ...item, displayName: action.payload.value } : item
|
|
193
|
+
);
|
|
194
|
+
state.currentPrescription.isUpdated = false;
|
|
195
|
+
state.currentPrescription.isCurrentPrescriptionPadUpdated = true;
|
|
196
|
+
} else {
|
|
197
|
+
state.patientPastPrescriptions.advicesArr = state.patientPastPrescriptions.advicesArr.map((item, i) =>
|
|
198
|
+
i === action.payload.index ? { ...item, displayName: action.payload.value } : item
|
|
199
|
+
);
|
|
200
|
+
state.patientPastPrescriptions.isPastPrescriptionPadUpdated = true;
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
setAdvices(state, action) {
|
|
204
|
+
state.currentPrescription.advicesArr = action.payload;
|
|
205
|
+
state.currentPrescription.isUpdated = false;
|
|
206
|
+
state.currentPrescription.isCurrentPrescriptionPadUpdated = true;
|
|
207
|
+
},
|
|
208
|
+
setPrescriptionId(state, action) {
|
|
209
|
+
state.prescriptionId = action.payload;
|
|
210
|
+
state.currentPrescription.isUpdated = false;
|
|
211
|
+
state.currentPrescription.isCurrentPrescriptionPadUpdated = true;
|
|
212
|
+
},
|
|
213
|
+
setSoapNotes(state, action) {
|
|
214
|
+
const { prescriptionIndex, ...soapNoteData } = action.payload;
|
|
215
|
+
const pIndex = Number.isInteger(prescriptionIndex) ? prescriptionIndex : -1;
|
|
216
|
+
if (pIndex === -1) {
|
|
217
|
+
state.currentPrescription.soapNotes = soapNoteData;
|
|
218
|
+
state.currentPrescription.isUpdated = false;
|
|
219
|
+
state.currentPrescription.isCurrentPrescriptionPadUpdated = true;
|
|
220
|
+
} else {
|
|
221
|
+
state.patientPastPrescriptions.soapNotes = soapNoteData;
|
|
222
|
+
state.patientPastPrescriptions.isPastPrescriptionPadUpdated = true;
|
|
223
|
+
}
|
|
224
|
+
},
|
|
225
|
+
setCategorySearch(state, action) {
|
|
226
|
+
state.categorySearch = action.payload;
|
|
227
|
+
},
|
|
228
|
+
setPatientPastPrescriptions(state, action) {
|
|
229
|
+
state.patientPastPrescriptions = action.payload;
|
|
230
|
+
},
|
|
231
|
+
setPrescriptionIndex(state, action) {
|
|
232
|
+
state.prescriptionIndex = action.payload;
|
|
233
|
+
},
|
|
234
|
+
setHasUpdates(state, action) {
|
|
235
|
+
state.hasUpdates = action.payload;
|
|
236
|
+
},
|
|
237
|
+
setTemplateNameInfo(state, action) {
|
|
238
|
+
state.templateNameInfo = action.payload;
|
|
239
|
+
},
|
|
240
|
+
setTemplateMenus(state, action) {
|
|
241
|
+
state.templateMenus = action.payload;
|
|
242
|
+
},
|
|
243
|
+
setRemovedPrescriptionPadData(state, action) {
|
|
244
|
+
state.removedPrescriptionPadData = action.payload;
|
|
245
|
+
},
|
|
246
|
+
setDraftedPrescriptionPayloadInLocalStorage(state, action) {
|
|
247
|
+
state.draftedPrescriptionPayloadInLocalStorage = action.payload;
|
|
248
|
+
},
|
|
249
|
+
setSelectedPrescriptionId(state, action) {
|
|
250
|
+
state.selectedPrescriptionId = action.payload;
|
|
251
|
+
},
|
|
252
|
+
setPdfLanguageMap(state, action) {
|
|
253
|
+
state.pdfLanguageMap = action.payload;
|
|
254
|
+
},
|
|
255
|
+
setCreatedOrUpdatedPrescription(state, action) {
|
|
256
|
+
state.createdOrUpdatedPrescription = action.payload;
|
|
257
|
+
},
|
|
258
|
+
setPrescriptionTranscript(state, action) {
|
|
259
|
+
state.prescriptionTranscript = action.payload;
|
|
260
|
+
},
|
|
261
|
+
setIsPatientVaccinePresent(state, action) {
|
|
262
|
+
state.isPatientVaccinePresent = action.payload;
|
|
263
|
+
},
|
|
264
|
+
setSelectedOETemplateId(state, action) {
|
|
265
|
+
state.currentPrescription.selectedOETemplateId = action.payload;
|
|
266
|
+
},
|
|
267
|
+
setPrescriptionOnExaminationResults(state, action) {
|
|
268
|
+
state.currentPrescription.prescriptionOnExaminationResults = action.payload;
|
|
269
|
+
},
|
|
270
|
+
},
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
export const {
|
|
274
|
+
setPrescriptionPadData,
|
|
275
|
+
updateMedications,
|
|
276
|
+
setMedications,
|
|
277
|
+
setSymptoms,
|
|
278
|
+
setDiagnosis,
|
|
279
|
+
setLabInvestigations,
|
|
280
|
+
updateAdvices,
|
|
281
|
+
setAdvices,
|
|
282
|
+
setPrescriptionId,
|
|
283
|
+
setSoapNotes,
|
|
284
|
+
setPatientPastPrescriptions,
|
|
285
|
+
setPrescriptionIndex,
|
|
286
|
+
setHasUpdates,
|
|
287
|
+
setVaccine,
|
|
288
|
+
setProcedure,
|
|
289
|
+
setTemplateNameInfo,
|
|
290
|
+
setTemplateMenus,
|
|
291
|
+
setRemovedPrescriptionPadData,
|
|
292
|
+
setDraftedPrescriptionPayloadInLocalStorage,
|
|
293
|
+
setSelectedPrescriptionId,
|
|
294
|
+
setPdfLanguageMap,
|
|
295
|
+
setCreatedOrUpdatedPrescription,
|
|
296
|
+
setPrescriptionTranscript,
|
|
297
|
+
setIsPatientVaccinePresent,
|
|
298
|
+
setSelectedOETemplateId,
|
|
299
|
+
setPrescriptionOnExaminationResults,
|
|
300
|
+
setCategorySearch,
|
|
301
|
+
} = prescriptionPadSlice.actions;
|
|
302
|
+
export const prescriptionPadReducer = prescriptionPadSlice.reducer;
|
|
303
|
+
|
|
304
|
+
export const getPrescriptionPadData = (state) => state.prescriptionPad?.currentPrescription;
|
|
305
|
+
export const getFieldData = (state, key) => state.prescriptionPad[key];
|
|
306
|
+
export const getSymptoms = (state) => state.prescriptionPad.currentPrescription?.symptomsArr;
|
|
307
|
+
export const getDiagnosis = (state) => state.prescriptionPad.currentPrescription?.diagnosisArr;
|
|
308
|
+
export const getLabInvestigations = (state) => state.prescriptionPad.currentPrescription?.labInvestigationsArr;
|
|
309
|
+
export const getAdvices = (state) => state.prescriptionPad.currentPrescription?.advicesArr;
|
|
310
|
+
export const getPrescriptionId = (state) => state.prescriptionPad.prescriptionId;
|
|
311
|
+
export const getMedications = (state) => state.prescriptionPad.currentPrescription?.medicationsArr;
|
|
312
|
+
export const getSoapNotes = (state) => state.prescriptionPad.currentPrescription?.soapNotes;
|
|
313
|
+
export const getPatientPastPrescriptions = (state) => state.prescriptionPad.patientPastPrescriptions;
|
|
314
|
+
export const getPrescriptionIndex = (state) => state.prescriptionPad.prescriptionIndex;
|
|
315
|
+
export const getHasUpdates = (state) => state.prescriptionPad.hasUpdates;
|
|
316
|
+
export const getVaccines = (state) => state.prescriptionPad.currentPrescription?.vaccineArr;
|
|
317
|
+
export const getProcedures = (state) => state.prescriptionPad.currentPrescription?.procedureArr;
|
|
318
|
+
export const getTemplateNameInfo = (state) => state.prescriptionPad.templateNameInfo;
|
|
319
|
+
export const getTemplateMenus = (state) => state.prescriptionPad.templateMenus;
|
|
320
|
+
export const getRemovedPrescriptionPadData = (state) => state.prescriptionPad.removedPrescriptionPadData;
|
|
321
|
+
export const getDraftedPrescriptionPayloadInLocalStorage = (state) =>
|
|
322
|
+
state.prescriptionPad.draftedPrescriptionPayloadInLocalStorage;
|
|
323
|
+
export const getSelectedPrescriptionId = (state) => state.prescriptionPad.selectedPrescriptionId;
|
|
324
|
+
export const getPdfLanguageMap = (state) => state.prescriptionPad.pdfLanguageMap;
|
|
325
|
+
export const getCreatedOrUpdatedPrescription = (state) => state.prescriptionPad.createdOrUpdatedPrescription;
|
|
326
|
+
export const getPrescriptionTranscript = (state) => state.prescriptionPad.prescriptionTranscript;
|
|
327
|
+
export const getIsPatientVaccinePresent = (state) => state.prescriptionPad.isPatientVaccinePresent;
|
|
328
|
+
export const getSelectedOETemplateId = (state) => state.prescriptionPad.currentPrescription?.selectedOETemplateId;
|
|
329
|
+
export const getCategorySearch = (state) => state.prescriptionPad.categorySearch;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { createSlice } from "@reduxjs/toolkit";
|
|
2
|
+
|
|
3
|
+
const initialState = {};
|
|
4
|
+
|
|
5
|
+
const questionnaireSlice = createSlice({
|
|
6
|
+
name: "questionnaire",
|
|
7
|
+
initialState,
|
|
8
|
+
reducers: {
|
|
9
|
+
setQuestionnaire: (state, { payload: { meta, response } }) => {
|
|
10
|
+
state[meta.hash] = {
|
|
11
|
+
meta: { ...(state[meta.hash] ? state[meta.hash].meta : {}), ...meta },
|
|
12
|
+
response: response !== undefined ? response : state[meta.hash]?.response,
|
|
13
|
+
};
|
|
14
|
+
},
|
|
15
|
+
removeQuestionnaire: (state, { payload: hash }) => {
|
|
16
|
+
delete state[hash];
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
export const { setQuestionnaire, removeQuestionnaire } = questionnaireSlice.actions;
|
|
22
|
+
|
|
23
|
+
export const getQuestionnaireResponse = (hash) => {
|
|
24
|
+
return (state) => {
|
|
25
|
+
return state.questionnaire[hash];
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const questionnaireReducer = questionnaireSlice.reducer;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { createSlice } from '@reduxjs/toolkit';
|
|
2
|
+
|
|
3
|
+
const initialState = {
|
|
4
|
+
reportData: [],
|
|
5
|
+
filterObj: {}
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
const ReportsSlice = createSlice({
|
|
9
|
+
name: 'ReportsSlice',
|
|
10
|
+
initialState,
|
|
11
|
+
reducers: {
|
|
12
|
+
setReportData: (state, action) => {
|
|
13
|
+
state.reportData = action.payload;
|
|
14
|
+
},
|
|
15
|
+
setFilterObj: (state, action) => {
|
|
16
|
+
state.filterObj = action.payload;
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
export const { setReportData, setFilterObj } = ReportsSlice.actions;
|
|
22
|
+
export const getFilterObj = (state) => state.Reports.filterObj;
|
|
23
|
+
|
|
24
|
+
export default ReportsSlice.reducer;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { createSlice } from '@reduxjs/toolkit';
|
|
2
|
+
|
|
3
|
+
const initialState = {
|
|
4
|
+
useSkeleton: true,
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
const SkeletonSlice = createSlice({
|
|
8
|
+
name: 'Skeleton',
|
|
9
|
+
initialState,
|
|
10
|
+
reducers: {
|
|
11
|
+
setUseSkeleton: (state, action) => {
|
|
12
|
+
state.useSkeleton = action.payload;
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export const { setUseSkeleton } = SkeletonSlice.actions;
|
|
18
|
+
export const getUseSkeleton = (state) => state.Skeleton.useSkeleton;
|
|
19
|
+
|
|
20
|
+
export default SkeletonSlice.reducer;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { createSlice } from '@reduxjs/toolkit';
|
|
2
|
+
import { lightThemeConfig, darkThemeConfig } from '@/common/themeProvider/themeConfig';
|
|
3
|
+
|
|
4
|
+
const getStorageValue = (key, defaultValue) => {
|
|
5
|
+
try {
|
|
6
|
+
const item = localStorage.getItem(key);
|
|
7
|
+
if (item === null) return defaultValue;
|
|
8
|
+
return JSON.parse(item);
|
|
9
|
+
} catch {
|
|
10
|
+
return defaultValue;
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const getThemeCache = () => getStorageValue('theme_config', {});
|
|
15
|
+
|
|
16
|
+
const initialState = {
|
|
17
|
+
mode: localStorage.getItem('theme') || 'light',
|
|
18
|
+
configs: {
|
|
19
|
+
light: lightThemeConfig,
|
|
20
|
+
dark: darkThemeConfig,
|
|
21
|
+
},
|
|
22
|
+
personilizedThemes: getThemeCache().personalized || false,
|
|
23
|
+
canSetPersonilisedTheme: getStorageValue('theme_existence', false),
|
|
24
|
+
isThemeLoading: false,
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const themeSlice = createSlice({
|
|
28
|
+
name: 'theme',
|
|
29
|
+
initialState,
|
|
30
|
+
reducers: {
|
|
31
|
+
toggleTheme: (state) => {
|
|
32
|
+
const newMode = state.mode === 'light' ? 'dark' : 'light';
|
|
33
|
+
state.mode = newMode;
|
|
34
|
+
localStorage.setItem('theme', newMode);
|
|
35
|
+
document.documentElement.classList.toggle('dark', newMode === 'dark');
|
|
36
|
+
},
|
|
37
|
+
setTheme: (state, action) => {
|
|
38
|
+
const newMode = action.payload;
|
|
39
|
+
state.mode = newMode;
|
|
40
|
+
localStorage.setItem('theme', newMode);
|
|
41
|
+
document.documentElement.classList.toggle('dark', newMode === 'dark');
|
|
42
|
+
},
|
|
43
|
+
updateThemeConfig: (state, action) => {
|
|
44
|
+
const { themeType, config } = action.payload;
|
|
45
|
+
state.configs[themeType] = config;
|
|
46
|
+
|
|
47
|
+
// Sync with local cache
|
|
48
|
+
try {
|
|
49
|
+
const currentCache = JSON.parse(localStorage.getItem('theme_config') || '{}');
|
|
50
|
+
const cacheWithoutLegacyTheme = { ...currentCache };
|
|
51
|
+
delete cacheWithoutLegacyTheme.theme;
|
|
52
|
+
const cacheKey = state.personilizedThemes ? 'userTheme' : 'implementationTheme';
|
|
53
|
+
const currentTheme = cacheWithoutLegacyTheme[cacheKey] ? JSON.parse(cacheWithoutLegacyTheme[cacheKey]) : {};
|
|
54
|
+
localStorage.setItem(
|
|
55
|
+
'theme_config',
|
|
56
|
+
JSON.stringify({
|
|
57
|
+
...cacheWithoutLegacyTheme,
|
|
58
|
+
[cacheKey]: JSON.stringify({
|
|
59
|
+
...currentTheme,
|
|
60
|
+
[themeType]: config,
|
|
61
|
+
}),
|
|
62
|
+
})
|
|
63
|
+
);
|
|
64
|
+
} catch (e) {
|
|
65
|
+
console.error('Error syncing theme config to local storage:', e);
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
setPersonilizedThemes: (state, action) => {
|
|
69
|
+
state.personilizedThemes = action.payload;
|
|
70
|
+
|
|
71
|
+
// Sync with local cache
|
|
72
|
+
try {
|
|
73
|
+
const currentCache = JSON.parse(localStorage.getItem('theme_config') || '{}');
|
|
74
|
+
const cacheWithoutLegacyTheme = { ...currentCache };
|
|
75
|
+
delete cacheWithoutLegacyTheme.theme;
|
|
76
|
+
localStorage.setItem(
|
|
77
|
+
'theme_config',
|
|
78
|
+
JSON.stringify({
|
|
79
|
+
...cacheWithoutLegacyTheme,
|
|
80
|
+
personalized: action.payload,
|
|
81
|
+
})
|
|
82
|
+
);
|
|
83
|
+
} catch (e) {
|
|
84
|
+
console.error('Error syncing personalized status to local storage:', e);
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
updateCanSetPersonalizedTheme: (state, action) => {
|
|
88
|
+
state.canSetPersonilisedTheme = action.payload;
|
|
89
|
+
},
|
|
90
|
+
setIsLoadingTheme: (state, action) => {
|
|
91
|
+
state.isThemeLoading = action.payload;
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
export const {
|
|
97
|
+
toggleTheme,
|
|
98
|
+
setTheme,
|
|
99
|
+
updateThemeConfig,
|
|
100
|
+
setPersonilizedThemes,
|
|
101
|
+
updateCanSetPersonalizedTheme,
|
|
102
|
+
setIsLoadingTheme,
|
|
103
|
+
} = themeSlice.actions;
|
|
104
|
+
|
|
105
|
+
export const getThemeMode = (state) => state.theme.mode;
|
|
106
|
+
export default themeSlice.reducer;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { createSlice } from '@reduxjs/toolkit';
|
|
2
|
+
|
|
3
|
+
const normalizeLanguageKey = (langKey) => (typeof langKey === 'string' ? langKey.toLowerCase() : langKey);
|
|
4
|
+
|
|
5
|
+
const getInitialState = () => {
|
|
6
|
+
const translations = {};
|
|
7
|
+
const loadedNamespaces = {};
|
|
8
|
+
try {
|
|
9
|
+
const storageKeys = Array.from({ length: localStorage.length }, (_, i) => localStorage.key(i));
|
|
10
|
+
storageKeys.forEach((key) => {
|
|
11
|
+
if (key && key.startsWith('translation_all_')) {
|
|
12
|
+
const langKey = normalizeLanguageKey(key.replace('translation_all_', ''));
|
|
13
|
+
const data = JSON.parse(localStorage.getItem(key) || '{}');
|
|
14
|
+
translations[langKey] = {
|
|
15
|
+
...(translations[langKey] || {}),
|
|
16
|
+
...(data.nested || {}),
|
|
17
|
+
};
|
|
18
|
+
loadedNamespaces[langKey] = [...new Set([...(loadedNamespaces[langKey] || []), ...(data.namespaces || [])])];
|
|
19
|
+
|
|
20
|
+
const normalizedKey = `translation_all_${langKey}`;
|
|
21
|
+
if (key !== normalizedKey) {
|
|
22
|
+
localStorage.removeItem(key);
|
|
23
|
+
localStorage.setItem(
|
|
24
|
+
normalizedKey,
|
|
25
|
+
JSON.stringify({
|
|
26
|
+
nested: translations[langKey],
|
|
27
|
+
namespaces: loadedNamespaces[langKey],
|
|
28
|
+
})
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
} catch (e) {
|
|
34
|
+
console.error('Error hydrating translations:', e);
|
|
35
|
+
}
|
|
36
|
+
return { translations, loadedNamespaces };
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const hyd = getInitialState();
|
|
40
|
+
|
|
41
|
+
const initialState = {
|
|
42
|
+
translations: hyd.translations,
|
|
43
|
+
loadedNamespaces: hyd.loadedNamespaces,
|
|
44
|
+
pageTitle: 'General',
|
|
45
|
+
translationLanguage: 'en',
|
|
46
|
+
languageMap: {},
|
|
47
|
+
loadingNamespaces: {}, // Tracks active fetches by 'langKey:namespace'
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const TranlationSlice = createSlice({
|
|
51
|
+
name: 'TranslationReducer',
|
|
52
|
+
initialState,
|
|
53
|
+
reducers: {
|
|
54
|
+
setTranslation: (state, action) => {
|
|
55
|
+
const { namespace, keys } = action.payload;
|
|
56
|
+
const langKey = normalizeLanguageKey(action.payload.langKey);
|
|
57
|
+
|
|
58
|
+
if (!langKey) return;
|
|
59
|
+
|
|
60
|
+
if (!state.translations[langKey]) {
|
|
61
|
+
state.translations[langKey] = {};
|
|
62
|
+
}
|
|
63
|
+
if (!state.loadedNamespaces[langKey]) {
|
|
64
|
+
state.loadedNamespaces[langKey] = [];
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Nested append
|
|
68
|
+
state.translations[langKey][namespace] = keys;
|
|
69
|
+
|
|
70
|
+
// Track namespace
|
|
71
|
+
if (!state.loadedNamespaces[langKey].includes(namespace)) {
|
|
72
|
+
state.loadedNamespaces[langKey].push(namespace);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Sync to unified local storage
|
|
76
|
+
try {
|
|
77
|
+
localStorage.setItem(
|
|
78
|
+
`translation_all_${langKey}`,
|
|
79
|
+
JSON.stringify({
|
|
80
|
+
nested: state.translations[langKey],
|
|
81
|
+
namespaces: state.loadedNamespaces[langKey],
|
|
82
|
+
})
|
|
83
|
+
);
|
|
84
|
+
} catch (e) {
|
|
85
|
+
console.error('Error syncing translations to local storage:', e);
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
setTranslationLanguage: (state, action) => {
|
|
89
|
+
const translationLanguage = normalizeLanguageKey(action.payload);
|
|
90
|
+
state.translationLanguage = translationLanguage;
|
|
91
|
+
},
|
|
92
|
+
setPageTitle: (state, action) => {
|
|
93
|
+
const pageTitle = action.payload;
|
|
94
|
+
state.pageTitle = pageTitle;
|
|
95
|
+
},
|
|
96
|
+
setlanguageMap: (state, action) => {
|
|
97
|
+
const languageMap = Object.entries(action.payload || {}).reduce((acc, [id, langKey]) => {
|
|
98
|
+
acc[id] = normalizeLanguageKey(langKey);
|
|
99
|
+
return acc;
|
|
100
|
+
}, {});
|
|
101
|
+
state.languageMap = languageMap;
|
|
102
|
+
},
|
|
103
|
+
startLoadingNamespace: (state, action) => {
|
|
104
|
+
const { namespace } = action.payload;
|
|
105
|
+
const langKey = normalizeLanguageKey(action.payload.langKey);
|
|
106
|
+
state.loadingNamespaces[`${langKey}:${namespace}`] = true;
|
|
107
|
+
},
|
|
108
|
+
finishLoadingNamespace: (state, action) => {
|
|
109
|
+
const { namespace } = action.payload;
|
|
110
|
+
const langKey = normalizeLanguageKey(action.payload.langKey);
|
|
111
|
+
delete state.loadingNamespaces[`${langKey}:${namespace}`];
|
|
112
|
+
},
|
|
113
|
+
resetStore: () => initialState,
|
|
114
|
+
},
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
export const {
|
|
118
|
+
setTranslation,
|
|
119
|
+
setTranslationLanguage,
|
|
120
|
+
setPageTitle,
|
|
121
|
+
setlanguageMap,
|
|
122
|
+
startLoadingNamespace,
|
|
123
|
+
finishLoadingNamespace,
|
|
124
|
+
} = TranlationSlice.actions;
|
|
125
|
+
|
|
126
|
+
export default TranlationSlice.reducer;
|