@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,284 @@
|
|
|
1
|
+
import { useSelector } from 'react-redux';
|
|
2
|
+
import { getUseSkeleton } from '@/store/reducers/SkeletonReducer';
|
|
3
|
+
import { useTranslateProvider } from '@/common/languageTranslator/TranslationContext';
|
|
4
|
+
import {
|
|
5
|
+
checkSystemConfigExists,
|
|
6
|
+
getSystemConfigsByKey,
|
|
7
|
+
postSystemConfig,
|
|
8
|
+
updateSystemConfig,
|
|
9
|
+
} from '@/common/services/SystemConfig';
|
|
10
|
+
import { showToast } from '@/common/toaster/toaster';
|
|
11
|
+
import CustomTextField from '@/views/custom-components/CustomTextField';
|
|
12
|
+
import FontAwesomeIcons from '@/common/fontAwesomeIcons/FontAwesomeIcons';
|
|
13
|
+
import { yupResolver } from '@hookform/resolvers/yup';
|
|
14
|
+
import { Box, Button, Stack, Typography } from '@mui/material';
|
|
15
|
+
import Grid from '@mui/material/Grid2';
|
|
16
|
+
import PropTypes from 'prop-types';
|
|
17
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
18
|
+
import { useForm } from 'react-hook-form';
|
|
19
|
+
import { useNavigate, useParams } from 'react-router';
|
|
20
|
+
import useTrackEvent from '@/hooks/useTrackEvent';
|
|
21
|
+
import * as Yup from 'yup';
|
|
22
|
+
/**
|
|
23
|
+
* @module ManageSystemConfig
|
|
24
|
+
* @returns {JSX.Element}
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
export default function ManageSystemConfig() {
|
|
28
|
+
const formRef = useRef(null);
|
|
29
|
+
const submitRef = useRef(false);
|
|
30
|
+
const trackEvent = useTrackEvent();
|
|
31
|
+
const { key } = useParams();
|
|
32
|
+
const navigate = useNavigate();
|
|
33
|
+
const validationSchema = Yup.object().shape({
|
|
34
|
+
key: Yup.string().required('Enter System Key'),
|
|
35
|
+
value: Yup.string().required('Enter Value'),
|
|
36
|
+
});
|
|
37
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
38
|
+
const { translate } = useTranslateProvider();
|
|
39
|
+
|
|
40
|
+
const {
|
|
41
|
+
control,
|
|
42
|
+
setValue,
|
|
43
|
+
handleSubmit,
|
|
44
|
+
reset,
|
|
45
|
+
formState: { errors },
|
|
46
|
+
} = useForm({
|
|
47
|
+
defaultValues: {
|
|
48
|
+
key: '',
|
|
49
|
+
value: '',
|
|
50
|
+
},
|
|
51
|
+
resolver: yupResolver(validationSchema),
|
|
52
|
+
mode: 'onChange',
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Handles closing the current view and navigating to the system configuration management page.
|
|
57
|
+
* @function handleClose
|
|
58
|
+
* @returns {void}
|
|
59
|
+
*/
|
|
60
|
+
|
|
61
|
+
const handleClose = () => {
|
|
62
|
+
!key && reset();
|
|
63
|
+
navigate('/ui/medplat/manage/systemconfigs');
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Handles form submission to check if a system configuration with the given key exists, and if not, submits a new system configuration.
|
|
68
|
+
* @async
|
|
69
|
+
* @function onSubmit
|
|
70
|
+
* @param {Object} values - The form values to be submitted.
|
|
71
|
+
* @param {string} values.key - The unique key for the system configuration.
|
|
72
|
+
* @param {string} values.otherField - Other fields in the form, as defined by the form schema.
|
|
73
|
+
* @returns {Promise<void>} - A promise that resolves when the submission is complete.
|
|
74
|
+
*/
|
|
75
|
+
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
let form = formRef.current;
|
|
78
|
+
|
|
79
|
+
return () => {
|
|
80
|
+
trackEvent('conversion_event', { form, form_name: 'Manage System Config', submit: submitRef.current }); //Use the current ref value
|
|
81
|
+
};
|
|
82
|
+
}, []);
|
|
83
|
+
|
|
84
|
+
const onSubmit = async (values) => {
|
|
85
|
+
try {
|
|
86
|
+
const { data: check } = await checkSystemConfigExists({
|
|
87
|
+
code: 'check_if_system_configuration_exists',
|
|
88
|
+
parameters: {
|
|
89
|
+
key: values.key,
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
if (check.result[0]?.count === 0 && !key) {
|
|
93
|
+
await postSystemConfig({
|
|
94
|
+
code: `system_config_add`,
|
|
95
|
+
parameters: {
|
|
96
|
+
...values,
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
showToast({
|
|
100
|
+
message: `System Configiration Added successfully`,
|
|
101
|
+
type: 'success',
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
submitRef.current = true;
|
|
105
|
+
handleClose();
|
|
106
|
+
} else if (
|
|
107
|
+
(check.result[0]?.count === 1 && key === values.key) ||
|
|
108
|
+
(check.result[0]?.count === 0 && key !== values.key)
|
|
109
|
+
) {
|
|
110
|
+
await updateSystemConfig({
|
|
111
|
+
code: 'system_config_update',
|
|
112
|
+
parameters: {
|
|
113
|
+
...values,
|
|
114
|
+
oldKey: key,
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
showToast({
|
|
118
|
+
message: `System Configuration Updated successfully`,
|
|
119
|
+
type: 'success',
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
submitRef.current = true;
|
|
123
|
+
handleClose();
|
|
124
|
+
} else if (check.result[0]?.count === 1 && key !== values.key) {
|
|
125
|
+
showToast({
|
|
126
|
+
message: 'Same key already Exists',
|
|
127
|
+
type: 'error',
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
} catch (error) {
|
|
131
|
+
showToast({
|
|
132
|
+
message: error?.message,
|
|
133
|
+
type: 'error',
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Effect hook to fetch and populate system configuration data when the component is mounted.
|
|
140
|
+
* @async
|
|
141
|
+
* @function useEffect
|
|
142
|
+
* @returns {void}
|
|
143
|
+
*/
|
|
144
|
+
|
|
145
|
+
useEffect(() => {
|
|
146
|
+
const getInitialData = async () => {
|
|
147
|
+
try {
|
|
148
|
+
setIsLoading((cur) => !cur);
|
|
149
|
+
if (key) {
|
|
150
|
+
const { data } = await getSystemConfigsByKey({
|
|
151
|
+
code: 'retrieve_system_configuration_by_key',
|
|
152
|
+
parameters: {
|
|
153
|
+
key,
|
|
154
|
+
},
|
|
155
|
+
});
|
|
156
|
+
if (!data.result.length) {
|
|
157
|
+
showToast({ type: 'error', message: 'error loading initial data' });
|
|
158
|
+
handleClose();
|
|
159
|
+
}
|
|
160
|
+
setValue('key', data.result[0]?.key);
|
|
161
|
+
setValue('value', data.result[0]?.value);
|
|
162
|
+
setValue('isActive', data.result[0]?.isActive);
|
|
163
|
+
}
|
|
164
|
+
setIsLoading((cur) => !cur);
|
|
165
|
+
} catch (error) {
|
|
166
|
+
console.error(error);
|
|
167
|
+
showToast({ type: 'error', message: 'error loading initial data' });
|
|
168
|
+
setIsLoading((cur) => !cur);
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
getInitialData();
|
|
172
|
+
}, [key, setValue]);
|
|
173
|
+
return (
|
|
174
|
+
<form onSubmit={handleSubmit(onSubmit)} data-testid="managesystemconfigs-form" ref={formRef}>
|
|
175
|
+
<ManageSystemConfigSkeleton isLoading={isLoading}>
|
|
176
|
+
<Grid container className="flex flex-col border border-gray-300 mt-6 bg-white">
|
|
177
|
+
<Grid borderBottom={'1px solid #ccc'} bgcolor={'#eee'}>
|
|
178
|
+
<Typography variant="body2" className="p-2.5 font-bold font-sans text-customBlue text-lg tracking-[0.5px]">
|
|
179
|
+
{translate('System Config Details')}
|
|
180
|
+
</Typography>
|
|
181
|
+
</Grid>
|
|
182
|
+
|
|
183
|
+
<Grid container spacing={2} className="flex flex-col p-[15px]">
|
|
184
|
+
<Grid className="flex flex-row justify-between w-[50%]">
|
|
185
|
+
<Typography variant="body2">
|
|
186
|
+
{translate('System Key')}
|
|
187
|
+
<span className="text-red-500 ml-1">*</span>
|
|
188
|
+
</Typography>
|
|
189
|
+
<Box width={'70%'}>
|
|
190
|
+
<CustomTextField
|
|
191
|
+
control={control}
|
|
192
|
+
name="key"
|
|
193
|
+
id="key"
|
|
194
|
+
label="Enter System Key"
|
|
195
|
+
errors={errors}
|
|
196
|
+
dataTestId="managesystemconfigs-key-field"
|
|
197
|
+
/>
|
|
198
|
+
</Box>
|
|
199
|
+
</Grid>
|
|
200
|
+
<Grid className="flex flex-row justify-between w-[50%]">
|
|
201
|
+
<Typography variant="body2">
|
|
202
|
+
{translate('Value')}
|
|
203
|
+
<span className="text-red-500 ml-1">*</span>
|
|
204
|
+
</Typography>
|
|
205
|
+
<Box width={'70%'}>
|
|
206
|
+
<CustomTextField
|
|
207
|
+
control={control}
|
|
208
|
+
id="value"
|
|
209
|
+
name="value"
|
|
210
|
+
label="Key Value"
|
|
211
|
+
errors={errors}
|
|
212
|
+
dataTestId="managesystemconfigs-value-field"
|
|
213
|
+
/>
|
|
214
|
+
</Box>
|
|
215
|
+
</Grid>
|
|
216
|
+
</Grid>
|
|
217
|
+
<Grid borderTop={'1px solid #ccc'}>
|
|
218
|
+
<Stack direction="row" spacing={2} justifyContent="flex-end" mt={1.5} mb={1.5} mr={1.5}>
|
|
219
|
+
<Button
|
|
220
|
+
variant="contained"
|
|
221
|
+
color="primary"
|
|
222
|
+
size="small"
|
|
223
|
+
type="submit"
|
|
224
|
+
data-testid="managesystemconfigs-submit-btn"
|
|
225
|
+
>
|
|
226
|
+
<FontAwesomeIcons iconName="faPrint" />
|
|
227
|
+
<Typography variant="caption">{key ? `${translate('Update')}` : `${translate('Add')}`}</Typography>
|
|
228
|
+
</Button>
|
|
229
|
+
<Button
|
|
230
|
+
variant="contained"
|
|
231
|
+
color="secondary"
|
|
232
|
+
size="small"
|
|
233
|
+
onClick={handleClose}
|
|
234
|
+
data-testid="managesystemconfigs-close-btn"
|
|
235
|
+
>
|
|
236
|
+
{translate('Close')}
|
|
237
|
+
</Button>
|
|
238
|
+
</Stack>
|
|
239
|
+
</Grid>
|
|
240
|
+
</Grid>
|
|
241
|
+
</ManageSystemConfigSkeleton>
|
|
242
|
+
</form>
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
const ManageSystemConfigSkeleton = ({ children, isLoading }) => {
|
|
247
|
+
const useSkeleton = useSelector(getUseSkeleton);
|
|
248
|
+
if (!useSkeleton) {
|
|
249
|
+
return children;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
if (!isLoading) {
|
|
253
|
+
return children;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
return (
|
|
257
|
+
<div className="flex flex-col w-full bg-white border border-gray-300 mr-8 my-4">
|
|
258
|
+
<div className="px-4 py-2 flex space-x-3 items-center justify-between ">
|
|
259
|
+
<div className="bg-gray-300 animate-pulse rounded-sm w-40 h-10"></div>
|
|
260
|
+
</div>
|
|
261
|
+
<hr></hr>
|
|
262
|
+
<div className="flex flex-col w-full space-y-4 p-4">
|
|
263
|
+
<div className="flex flex-row ">
|
|
264
|
+
<button className="bg-gray-300 animate-pulse rounded-sm w-40 h-10 mr-[100px]"></button>
|
|
265
|
+
<button className="bg-gray-300 animate-pulse rounded-sm w-[300px] h-10 "></button>
|
|
266
|
+
</div>
|
|
267
|
+
<div className="flex flex-row ">
|
|
268
|
+
<button className="bg-gray-300 animate-pulse rounded-sm w-40 h-10 mr-[100px]"></button>
|
|
269
|
+
<button className="bg-gray-300 animate-pulse rounded-sm w-[300px] h-10 "></button>
|
|
270
|
+
</div>
|
|
271
|
+
</div>
|
|
272
|
+
<hr></hr>
|
|
273
|
+
<div className="px-2 py-2 w-full flex space-x-3 items-center justify-end ">
|
|
274
|
+
<div className="bg-gray-300 animate-pulse rounded-sm w-20 h-10"></div>
|
|
275
|
+
<div className="bg-gray-300 animate-pulse rounded-sm w-20 h-10"></div>
|
|
276
|
+
</div>
|
|
277
|
+
</div>
|
|
278
|
+
);
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
ManageSystemConfigSkeleton.propTypes = {
|
|
282
|
+
children: PropTypes.any,
|
|
283
|
+
isLoading: PropTypes.any,
|
|
284
|
+
};
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import { useSelector } from "react-redux";
|
|
2
|
+
import { getUseSkeleton } from "@/store/reducers/SkeletonReducer";
|
|
3
|
+
import { useTranslateProvider } from '@/common/languageTranslator/TranslationContext';
|
|
4
|
+
import { getSystemConfigs, updateSystemConfig } from '@/common/services/SystemConfig';
|
|
5
|
+
import { showToast } from '@/common/toaster/toaster';
|
|
6
|
+
import { getAssignedFeatures } from '@/utils/feature';
|
|
7
|
+
import CustomConfirmationModal from '@/views/custom-components/CustomConfirmationModal';
|
|
8
|
+
import CustomizedTable from '@/views/custom-components/CustomizedTable/CustomizedTableV2';
|
|
9
|
+
import { faBars, faPen } from '@fortawesome/free-solid-svg-icons';
|
|
10
|
+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
11
|
+
import { Button, Paper, TableContainer, TextField, Typography } from '@mui/material';
|
|
12
|
+
import Grid from '@mui/material/Grid2';
|
|
13
|
+
import PropTypes from 'prop-types';
|
|
14
|
+
import React, { useEffect, useState } from 'react';
|
|
15
|
+
import { useNavigate } from 'react-router';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @module SystemConfig
|
|
19
|
+
* @returns {JSX.Element}
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
export default function SystemConfig() {
|
|
23
|
+
const [data, setData] = useState([]);
|
|
24
|
+
const [searchQuery, setSearchQuery] = useState('');
|
|
25
|
+
const [debouncedQuery, setDebouncedQuery] = useState(searchQuery);
|
|
26
|
+
const [canAddRight, setCanAddRight] = useState('');
|
|
27
|
+
const [open, setOpen] = useState(false);
|
|
28
|
+
const [rowData, setRowData] = useState({});
|
|
29
|
+
const navigate = useNavigate();
|
|
30
|
+
const { translate } = useTranslateProvider();
|
|
31
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
32
|
+
const updatedData = data?.map((config) => {
|
|
33
|
+
return {
|
|
34
|
+
...config,
|
|
35
|
+
state: config?.state ? 'ACTIVE' : 'INACTIVE',
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const filterData = updatedData?.filter(
|
|
40
|
+
(item) =>
|
|
41
|
+
item.key.toLowerCase().includes(debouncedQuery.toLowerCase()) ||
|
|
42
|
+
item.value.toLowerCase().includes(debouncedQuery.toLowerCase())
|
|
43
|
+
);
|
|
44
|
+
const defaultColumns = [
|
|
45
|
+
{ field: 'key', label: 'Key', align: 'left', sortable: true, sortOrder: 'asc' },
|
|
46
|
+
{ field: 'value', label: 'Value', align: 'left' },
|
|
47
|
+
{ field: 'state', label: 'State' },
|
|
48
|
+
{ field: 'Actions', label: 'Actions' },
|
|
49
|
+
];
|
|
50
|
+
|
|
51
|
+
const [columns, setColumns] = useState(defaultColumns);
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Handles the navigation to the edit page for a system configuration.
|
|
55
|
+
* @function handleEdit
|
|
56
|
+
* @param {Object} row - The row object containing details of the system configuration.
|
|
57
|
+
* @param {string} row.key - The key of the system configuration to edit.
|
|
58
|
+
*/
|
|
59
|
+
|
|
60
|
+
const handleEdit = (row) => {
|
|
61
|
+
const url = `/ui/medplat/manage/systemconfigs/managesystemconfig/${row.key}`;
|
|
62
|
+
navigate(url);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Handles the status update of a system configuration.
|
|
67
|
+
* @async
|
|
68
|
+
* @function handleOpenStatusModal
|
|
69
|
+
* @param {Object} row - The row object containing details of the system configuration.
|
|
70
|
+
* @param {string} row.key - The key of the system configuration to update.
|
|
71
|
+
* @param {string} row.value - The value of the system configuration to update.
|
|
72
|
+
* @param {string} row.state - The current state of the system configuration ('ACTIVE' or 'INACTIVE').
|
|
73
|
+
* @throws {Error} Throws an error if the update or data retrieval fails.
|
|
74
|
+
*/
|
|
75
|
+
|
|
76
|
+
const handleOpenStatusModal = async (row) => {
|
|
77
|
+
try {
|
|
78
|
+
setIsLoading((cur) => !cur);
|
|
79
|
+
const { key, value } = row;
|
|
80
|
+
await updateSystemConfig({
|
|
81
|
+
code: 'system_config_update',
|
|
82
|
+
parameters: {
|
|
83
|
+
key,
|
|
84
|
+
value,
|
|
85
|
+
isActive: row.state !== 'ACTIVE',
|
|
86
|
+
oldKey: key,
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
const { data } = await getSystemConfigs({
|
|
90
|
+
code: 'system_configs_retrieve_all',
|
|
91
|
+
parameters: {},
|
|
92
|
+
});
|
|
93
|
+
setData(data.result);
|
|
94
|
+
setOpen(false);
|
|
95
|
+
setIsLoading((cur) => !cur);
|
|
96
|
+
} catch (error) {
|
|
97
|
+
console.error(error);
|
|
98
|
+
showToast({ type: 'error', message: 'error toggling status' });
|
|
99
|
+
setIsLoading((cur) => !cur);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Handles sorting of data based on the current sort order.
|
|
105
|
+
* @async
|
|
106
|
+
* @function handleSort
|
|
107
|
+
* @returns {void}
|
|
108
|
+
*/
|
|
109
|
+
|
|
110
|
+
const handleSort = async (column) => {
|
|
111
|
+
const newOrder = column.sortOrder === 'asc' ? 'desc' : 'asc';
|
|
112
|
+
const Data =
|
|
113
|
+
newOrder === 'asc'
|
|
114
|
+
? data.toSorted((a, b) => a.key?.localeCompare(b.key))
|
|
115
|
+
: data.toSorted((a, b) => b.key?.localeCompare(a.key));
|
|
116
|
+
setData(Data);
|
|
117
|
+
setColumns((prev) =>
|
|
118
|
+
prev.map((col) => {
|
|
119
|
+
if (col.field === column.field) {
|
|
120
|
+
return { ...col, sortOrder: newOrder };
|
|
121
|
+
}
|
|
122
|
+
return col;
|
|
123
|
+
})
|
|
124
|
+
);
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
const actions = (row) => [
|
|
128
|
+
{
|
|
129
|
+
label: '',
|
|
130
|
+
icon: <FontAwesomeIcon icon={faPen} />,
|
|
131
|
+
onClick: handleEdit,
|
|
132
|
+
disabled: true,
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
label: '',
|
|
136
|
+
icon: <FontAwesomeIcon icon={faBars} />,
|
|
137
|
+
menuItems: [
|
|
138
|
+
{
|
|
139
|
+
label: translate(row.state === 'ACTIVE' ? 'Mark as Inactive' : 'Mark as Active'),
|
|
140
|
+
onClick: (row) => {
|
|
141
|
+
setOpen(true);
|
|
142
|
+
setRowData(row);
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
],
|
|
146
|
+
},
|
|
147
|
+
];
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Effect hook to handle debouncing of the search query.
|
|
151
|
+
* @async
|
|
152
|
+
* @function useEffect
|
|
153
|
+
* @param {string} searchQuery - The current search query input by the user.
|
|
154
|
+
* @returns {void}
|
|
155
|
+
*/
|
|
156
|
+
|
|
157
|
+
useEffect(() => {
|
|
158
|
+
const handler = setTimeout(() => {
|
|
159
|
+
setDebouncedQuery(searchQuery);
|
|
160
|
+
}, 300);
|
|
161
|
+
|
|
162
|
+
return () => {
|
|
163
|
+
clearTimeout(handler);
|
|
164
|
+
};
|
|
165
|
+
}, [searchQuery]);
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Effect hook to fetch and set system configurations and feature rights when the component is mounted.
|
|
169
|
+
* @async
|
|
170
|
+
* @function useEffect
|
|
171
|
+
* @returns {void}
|
|
172
|
+
*/
|
|
173
|
+
|
|
174
|
+
const allConfigs = async () => {
|
|
175
|
+
try {
|
|
176
|
+
setIsLoading((cur) => !cur);
|
|
177
|
+
if (!canAddRight) {
|
|
178
|
+
const { data: rights } = await getAssignedFeatures('techo.manage.systemconfigs');
|
|
179
|
+
setCanAddRight(JSON.parse(rights).canAdd);
|
|
180
|
+
}
|
|
181
|
+
const { data } = await getSystemConfigs({
|
|
182
|
+
code: 'system_configs_retrieve_all',
|
|
183
|
+
parameters: {},
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
setData(data.result);
|
|
187
|
+
setIsLoading((cur) => !cur);
|
|
188
|
+
} catch {
|
|
189
|
+
showToast({
|
|
190
|
+
type: 'error',
|
|
191
|
+
message: 'Error Loading in System Configuration Data',
|
|
192
|
+
});
|
|
193
|
+
setIsLoading((cur) => !cur);
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
useEffect(() => {
|
|
197
|
+
allConfigs();
|
|
198
|
+
}, []);
|
|
199
|
+
|
|
200
|
+
return (
|
|
201
|
+
<Grid container className="w-[99%] my-4 flex flex-col" spacing={2}>
|
|
202
|
+
<SystemConfigSkeleton isLoading={isLoading}>
|
|
203
|
+
<Grid
|
|
204
|
+
container
|
|
205
|
+
className=" flex flex-col items-start justify-center md:flex-row md:justify-between md:items-center w-full"
|
|
206
|
+
spacing={1}
|
|
207
|
+
>
|
|
208
|
+
<Grid>
|
|
209
|
+
<Typography
|
|
210
|
+
variant="body2"
|
|
211
|
+
className="font-bold font-sans text-lg text-customBlue uppercase"
|
|
212
|
+
data-testid="notification-list-typography-title"
|
|
213
|
+
>
|
|
214
|
+
{translate('System Configuration')}
|
|
215
|
+
</Typography>
|
|
216
|
+
</Grid>
|
|
217
|
+
|
|
218
|
+
<Grid className="flex space-x-3 flex-col md:flex-row ">
|
|
219
|
+
<TextField
|
|
220
|
+
name="searchQuery"
|
|
221
|
+
id="searchQuery"
|
|
222
|
+
placeholder="Search Text"
|
|
223
|
+
size="small"
|
|
224
|
+
value={searchQuery}
|
|
225
|
+
onChange={(e) => setSearchQuery(e.target.value)}
|
|
226
|
+
sx={{
|
|
227
|
+
backgroundColor: 'white',
|
|
228
|
+
'& .MuiInputBase-root': {
|
|
229
|
+
height: '2.2em',
|
|
230
|
+
width: '190px',
|
|
231
|
+
},
|
|
232
|
+
}}
|
|
233
|
+
data-testid="systemconfig-textfield-search-query"
|
|
234
|
+
/>
|
|
235
|
+
{canAddRight && (
|
|
236
|
+
<Grid>
|
|
237
|
+
<Button
|
|
238
|
+
size="small"
|
|
239
|
+
variant="contained"
|
|
240
|
+
onClick={() => navigate('/ui/medplat/manage/systemconfigs/managesystemconfig')}
|
|
241
|
+
data-testid="systemconfig-button-add"
|
|
242
|
+
>
|
|
243
|
+
{translate('Add')}
|
|
244
|
+
</Button>
|
|
245
|
+
</Grid>
|
|
246
|
+
)}
|
|
247
|
+
</Grid>
|
|
248
|
+
</Grid>
|
|
249
|
+
</SystemConfigSkeleton>
|
|
250
|
+
<Grid className="w-full">
|
|
251
|
+
<TableContainer component={Paper}>
|
|
252
|
+
<CustomizedTable
|
|
253
|
+
columns={columns}
|
|
254
|
+
tableData={filterData}
|
|
255
|
+
paginationConfig={{ pagination: false }}
|
|
256
|
+
actions={actions}
|
|
257
|
+
handleSort={handleSort}
|
|
258
|
+
dataTestId="systemconfig-customizedtable-main"
|
|
259
|
+
// customHeight="max-h-128"
|
|
260
|
+
isLoading={isLoading}
|
|
261
|
+
/>
|
|
262
|
+
</TableContainer>
|
|
263
|
+
</Grid>
|
|
264
|
+
<CustomConfirmationModal
|
|
265
|
+
open={open}
|
|
266
|
+
description={'Are you sure you want to change the state of this System configuration ?'}
|
|
267
|
+
title={'CONFIRM ACTION'}
|
|
268
|
+
handleClick={() => handleOpenStatusModal(rowData)}
|
|
269
|
+
handleClose={() => setOpen(false)}
|
|
270
|
+
dataTestId="systemconfig-modal-confirmation"
|
|
271
|
+
/>
|
|
272
|
+
</Grid>
|
|
273
|
+
);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
export const SystemConfigSkeleton = ({ children, isLoading }) => {
|
|
277
|
+
const useSkeleton = useSelector(getUseSkeleton);
|
|
278
|
+
if (!useSkeleton) {
|
|
279
|
+
return children;
|
|
280
|
+
}
|
|
281
|
+
if (!isLoading) {
|
|
282
|
+
return children;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
return (
|
|
286
|
+
<div className="flex w-full items-center justify-between space-x-2 my-4">
|
|
287
|
+
<div className="bg-gray-300 rounded-sm animate-pulse w-60 h-10"></div>
|
|
288
|
+
<div className="flex space-x-3">
|
|
289
|
+
<div className="bg-gray-300 rounded-sm animate-pulse w-40 h-10"></div>
|
|
290
|
+
<div className="bg-gray-300 rounded-sm animate-pulse w-20 h-10"></div>
|
|
291
|
+
</div>
|
|
292
|
+
</div>
|
|
293
|
+
);
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
SystemConfigSkeleton.propTypes = {
|
|
297
|
+
children: PropTypes.any,
|
|
298
|
+
isLoading: PropTypes.any,
|
|
299
|
+
};
|