@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,532 @@
|
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { Pagination, Paper, TablePagination, Box, Typography, Checkbox } from '@mui/material';
|
|
4
|
+
import Grid from '@mui/material/Grid2';
|
|
5
|
+
|
|
6
|
+
import { styled } from '@mui/material/styles';
|
|
7
|
+
import Table from '@mui/material/Table';
|
|
8
|
+
import TableBody from '@mui/material/TableBody';
|
|
9
|
+
import TableCell, { tableCellClasses } from '@mui/material/TableCell';
|
|
10
|
+
import TableContainer from '@mui/material/TableContainer';
|
|
11
|
+
import TableHead from '@mui/material/TableHead';
|
|
12
|
+
import TableRow from '@mui/material/TableRow';
|
|
13
|
+
import { Stack } from '@mui/system';
|
|
14
|
+
import CustomInfiniteScroll from '@/views/custom-components/CustomInfiniteScroll';
|
|
15
|
+
import { useTranslateProvider } from '@/common/languageTranslator/TranslationContext';
|
|
16
|
+
import { useSelector } from 'react-redux';
|
|
17
|
+
import CustomActionIcons from './CustomActionIcons';
|
|
18
|
+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
19
|
+
import { faArrowDownShortWide, faArrowUpWideShort } from '@fortawesome/free-solid-svg-icons';
|
|
20
|
+
|
|
21
|
+
import SafeHtml from '@/common/SafeHtml.jsx';
|
|
22
|
+
|
|
23
|
+
import { getUseSkeleton } from '@/store/reducers/SkeletonReducer';
|
|
24
|
+
const StyledTableContainer = styled(TableContainer)(() => ({
|
|
25
|
+
borderRadius: '12px',
|
|
26
|
+
'&::-webkit-scrollbar': {
|
|
27
|
+
width: '50px',
|
|
28
|
+
},
|
|
29
|
+
scrollbarWidth: 'thin',
|
|
30
|
+
}));
|
|
31
|
+
|
|
32
|
+
export const StyledTableCell = styled(TableCell)(() => ({
|
|
33
|
+
[`&.${tableCellClasses.head}`]: {
|
|
34
|
+
border: 'none',
|
|
35
|
+
minWidth: '80px',
|
|
36
|
+
fontSize: '0.875rem',
|
|
37
|
+
position: 'sticky',
|
|
38
|
+
padding: '12px',
|
|
39
|
+
top: 0,
|
|
40
|
+
zIndex: 2,
|
|
41
|
+
cursor: 'pointer', // Add cursor pointer to indicate clickability
|
|
42
|
+
whiteSpace: 'nowrap', // Prevents header text from wrapping
|
|
43
|
+
color: '#FFFFFF',
|
|
44
|
+
'&:first-of-type': {
|
|
45
|
+
borderTopLeftRadius: '12px',
|
|
46
|
+
borderBottomLeftRadius: '12px',
|
|
47
|
+
},
|
|
48
|
+
'&:last-of-type': {
|
|
49
|
+
borderTopRightRadius: '12px',
|
|
50
|
+
borderBottomRightRadius: '12px',
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
[`&.${tableCellClasses.body}`]: {
|
|
54
|
+
borderBottom: '.1px solid #ccc',
|
|
55
|
+
// borderRight: '.1px solid #ccc',
|
|
56
|
+
padding: '10px',
|
|
57
|
+
verticalAlign: 'top',
|
|
58
|
+
fontSize: '0.8125 rem',
|
|
59
|
+
maxWidth: 400,
|
|
60
|
+
height: 50,
|
|
61
|
+
wordWrap: 'break-word', // Ensures that the text will wrap onto the next line
|
|
62
|
+
whiteSpace: 'normal', // Allows text to wrap to the next line
|
|
63
|
+
},
|
|
64
|
+
}));
|
|
65
|
+
|
|
66
|
+
export const StyledTableRow = styled(TableRow)(() => {
|
|
67
|
+
const currentMode = useSelector((state) => state.theme.mode);
|
|
68
|
+
return {
|
|
69
|
+
'&:hover': {
|
|
70
|
+
// Excludes the first row (header)
|
|
71
|
+
backgroundColor: currentMode !== 'dark' ? '#D7E5EA' : '#3F5A66',
|
|
72
|
+
transform: 'translateY(-1px)', // Expands vertically while keeping width constant
|
|
73
|
+
transition: 'transform 0.15s ease-out, background-color 0.15s ease-out, box-shadow 0.15s ease-out',
|
|
74
|
+
boxShadow: '0px 4px 8px rgba(0, 0, 0, 0.1), 0px -4px 8px rgba(0, 0, 0, 0.1)', // Shadow on top & bottom
|
|
75
|
+
},
|
|
76
|
+
'&:not(:first-child):hover td': {
|
|
77
|
+
// Exclude header from scaling effect
|
|
78
|
+
transform: 'scaleY(1.05)', // Slightly increase content size
|
|
79
|
+
transition: 'transform 0.15s ',
|
|
80
|
+
},
|
|
81
|
+
'&:last-child td, &:last-child th': {
|
|
82
|
+
borderBottom: '.1px solid #ccc', // Add bottom border to the last row
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
const CustomizedTable = ({
|
|
88
|
+
columns,
|
|
89
|
+
tableData,
|
|
90
|
+
actions,
|
|
91
|
+
rowsPerPageInTable = 10,
|
|
92
|
+
displayPageSelect = false,
|
|
93
|
+
noPagination,
|
|
94
|
+
doNotShowTableHead,
|
|
95
|
+
fontSize,
|
|
96
|
+
loadMore,
|
|
97
|
+
hasMore,
|
|
98
|
+
handleSort,
|
|
99
|
+
sortOrder,
|
|
100
|
+
selectRows = false,
|
|
101
|
+
setSelectedRows,
|
|
102
|
+
selectedRows = [],
|
|
103
|
+
handleToggleStatus,
|
|
104
|
+
selectedRowsUnique = 'id',
|
|
105
|
+
disableHtml = false,
|
|
106
|
+
conditionCheckObj = {}, //contains objects to check for conditional actions. i.e. {editableLocationTypes, deletableLocationTypes}
|
|
107
|
+
dataTestId,
|
|
108
|
+
customHeight,
|
|
109
|
+
totalRows, // New prop for server-side total count
|
|
110
|
+
currentPage: propCurrentPage, // Controlled page from parent
|
|
111
|
+
onPageChange, // Callback for page changes
|
|
112
|
+
isLoading,
|
|
113
|
+
strip = true,
|
|
114
|
+
...props
|
|
115
|
+
}) => {
|
|
116
|
+
const useSkeleton = useSelector(getUseSkeleton);
|
|
117
|
+
if (selectRows) {
|
|
118
|
+
columns = [{ field: 'rowSelect' }, ...columns];
|
|
119
|
+
}
|
|
120
|
+
const { translate } = useTranslateProvider();
|
|
121
|
+
const [internalPage, setInternalPage] = useState(0);
|
|
122
|
+
const [rowsPerPage, setRowsPerPage] = useState(rowsPerPageInTable);
|
|
123
|
+
const [rowsPerPageOptionsArray, setRowsPerPageOptionsArray] = useState(null);
|
|
124
|
+
const [rowData, setRowData] = useState(tableData);
|
|
125
|
+
const [selectAllChecked, setSelectAllChecked] = useState(
|
|
126
|
+
selectedRows?.length === rowData?.length && rowData?.length > 0
|
|
127
|
+
);
|
|
128
|
+
const conditionCheckObject = conditionCheckObj;
|
|
129
|
+
useEffect(() => {
|
|
130
|
+
setRowData(() => tableData);
|
|
131
|
+
}, [tableData]);
|
|
132
|
+
useEffect(() => {
|
|
133
|
+
setSelectAllChecked(selectedRows?.length === rowData?.length && rowData?.length > 0);
|
|
134
|
+
}, [selectedRows]);
|
|
135
|
+
const numOptions = 5;
|
|
136
|
+
|
|
137
|
+
const page = propCurrentPage !== undefined ? propCurrentPage : internalPage;
|
|
138
|
+
// Use controlled page if provided, else internal state
|
|
139
|
+
// setPage(Page);
|
|
140
|
+
|
|
141
|
+
// Handle page change
|
|
142
|
+
const handlePageChange = (newPage) => {
|
|
143
|
+
if (onPageChange) {
|
|
144
|
+
onPageChange(newPage); // Parent handles API call
|
|
145
|
+
} else {
|
|
146
|
+
setInternalPage(newPage); // Internal state for client-side
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
// console.log(tableData)
|
|
150
|
+
|
|
151
|
+
useEffect(() => {
|
|
152
|
+
if (rowsPerPageInTable && rowData) {
|
|
153
|
+
setInternalPage(0);
|
|
154
|
+
if (rowData.length <= rowsPerPageInTable) {
|
|
155
|
+
setRowsPerPageOptionsArray([rowsPerPageInTable]);
|
|
156
|
+
} else {
|
|
157
|
+
const increment = Math.ceil((rowData.length - rowsPerPageInTable) / (numOptions - 1));
|
|
158
|
+
const rowsPerPageOptions = [rowsPerPageInTable];
|
|
159
|
+
for (let i = 1; i < numOptions - 1; i++) {
|
|
160
|
+
const option = rowsPerPageInTable + i * increment;
|
|
161
|
+
rowsPerPageOptions.push(option);
|
|
162
|
+
}
|
|
163
|
+
rowsPerPageOptions.push(rowData.length);
|
|
164
|
+
setRowsPerPageOptionsArray(rowsPerPageOptions);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}, [rowsPerPageInTable, rowData]);
|
|
168
|
+
|
|
169
|
+
const getFieldValue = (obj, field) => {
|
|
170
|
+
const fieldParts = field.split('.');
|
|
171
|
+
let value = obj;
|
|
172
|
+
for (const part of fieldParts) {
|
|
173
|
+
value = value?.[part];
|
|
174
|
+
if (value === undefined) return '';
|
|
175
|
+
}
|
|
176
|
+
return value;
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
const handleChangeRowsPerPage = (event) => {
|
|
180
|
+
setRowsPerPage(parseInt(event.target.value, 10));
|
|
181
|
+
setInternalPage(0);
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
const handleSelectAll = () => {
|
|
185
|
+
if (selectedRows.length === rowData.length) {
|
|
186
|
+
setSelectedRows([]);
|
|
187
|
+
} else {
|
|
188
|
+
setSelectedRows([...rowData]);
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
const handleRowSelect = (row) => {
|
|
193
|
+
setSelectedRows((prev) => {
|
|
194
|
+
const isIncluded = prev.find((item) => item[selectedRowsUnique] === row[selectedRowsUnique]);
|
|
195
|
+
if (isIncluded) {
|
|
196
|
+
return prev.filter((item) => item[selectedRowsUnique] !== row[selectedRowsUnique]);
|
|
197
|
+
} else {
|
|
198
|
+
return [...prev, row]; // Add row if not already selected
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
const renderTableBody = () => {
|
|
204
|
+
return isLoading && useSkeleton ? (
|
|
205
|
+
<div className="bg-gray-300 animate-pulse rounded-sm w-full h-100 "></div>
|
|
206
|
+
) : (
|
|
207
|
+
<Table aria-label="Customized Table" data-testid={dataTestId} {...props}>
|
|
208
|
+
{!doNotShowTableHead && (
|
|
209
|
+
<TableHead>
|
|
210
|
+
<TableRow>
|
|
211
|
+
{columns?.map(
|
|
212
|
+
(column, index) =>
|
|
213
|
+
!column.hide && (
|
|
214
|
+
<StyledTableCell
|
|
215
|
+
key={index + 1}
|
|
216
|
+
align={column.align ? column.align : 'center'}
|
|
217
|
+
onClick={() => column.sortable && handleSort(column.field)}
|
|
218
|
+
sx={{
|
|
219
|
+
backgroundColor: (theme) => theme.palette.custom?.tableHeader,
|
|
220
|
+
}}
|
|
221
|
+
>
|
|
222
|
+
<Box
|
|
223
|
+
sx={{
|
|
224
|
+
display: 'flex',
|
|
225
|
+
alignItems: 'center',
|
|
226
|
+
justifyContent: column.align ? column.align : 'center',
|
|
227
|
+
}}
|
|
228
|
+
>
|
|
229
|
+
{selectRows && column.field === 'rowSelect' ? (
|
|
230
|
+
<Checkbox color="primary" checked={selectAllChecked} onChange={() => handleSelectAll()} />
|
|
231
|
+
) : (
|
|
232
|
+
<>
|
|
233
|
+
<Typography variant="caption" className="font-bold" sx={{ fontSize: '0.875rem' }}>
|
|
234
|
+
{translate(column?.label)}
|
|
235
|
+
</Typography>
|
|
236
|
+
{column.sortable &&
|
|
237
|
+
(sortOrder === 'asc' ? (
|
|
238
|
+
<FontAwesomeIcon className="ml-[5px]" icon={faArrowDownShortWide} />
|
|
239
|
+
) : (
|
|
240
|
+
<FontAwesomeIcon className="ml-[5px] text-[1rem]" icon={faArrowUpWideShort} />
|
|
241
|
+
))}
|
|
242
|
+
</>
|
|
243
|
+
)}
|
|
244
|
+
</Box>
|
|
245
|
+
</StyledTableCell>
|
|
246
|
+
)
|
|
247
|
+
)}
|
|
248
|
+
</TableRow>
|
|
249
|
+
</TableHead>
|
|
250
|
+
)}
|
|
251
|
+
|
|
252
|
+
<TableBody>
|
|
253
|
+
{rowData && rowData.length ? (
|
|
254
|
+
(() =>
|
|
255
|
+
rowsPerPage > 0 && !noPagination && !onPageChange
|
|
256
|
+
? rowData.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage)
|
|
257
|
+
: rowData)().map((row, rowIndex) => (
|
|
258
|
+
<StyledTableRow
|
|
259
|
+
key={rowIndex + 1}
|
|
260
|
+
sx={(theme) => ({
|
|
261
|
+
backgroundColor: strip && rowIndex % 2 !== 0 ? theme.palette.custom.gray4 : 'inherit',
|
|
262
|
+
})}
|
|
263
|
+
>
|
|
264
|
+
{columns.map(
|
|
265
|
+
(column, colIndex) =>
|
|
266
|
+
!column.hide && (
|
|
267
|
+
<React.Fragment key={`${column.field}-${colIndex}`}>
|
|
268
|
+
<StyledTableCell
|
|
269
|
+
className={`px-4 leading-7 ${fontSize ? `text-[${fontSize}] !important` : ''}`}
|
|
270
|
+
style={{
|
|
271
|
+
textAlign: column.align ? column.align : 'center',
|
|
272
|
+
cursor: column.onClick ? 'pointer' : 'default',
|
|
273
|
+
color: column.onClick ? 'blue' : 'inherit',
|
|
274
|
+
textDecoration: column.onClick ? 'underline' : 'none',
|
|
275
|
+
}}
|
|
276
|
+
data-testid={`tableData-row-${rowIndex}-column-${colIndex}`}
|
|
277
|
+
onClick={column.onClick ? () => column.onClick(row, rowIndex) : undefined}
|
|
278
|
+
>
|
|
279
|
+
{selectRows && column.field === 'rowSelect' && (
|
|
280
|
+
<Checkbox
|
|
281
|
+
color="primary"
|
|
282
|
+
checked={
|
|
283
|
+
!!selectedRows.find((item) => item[selectedRowsUnique] === row[selectedRowsUnique])
|
|
284
|
+
}
|
|
285
|
+
onChange={() => handleRowSelect(row)}
|
|
286
|
+
/>
|
|
287
|
+
)}
|
|
288
|
+
|
|
289
|
+
{column.field === 'statusCheckbox' && (
|
|
290
|
+
<Checkbox color="primary" checked={!!row.status} onChange={() => handleToggleStatus(row)} />
|
|
291
|
+
)}
|
|
292
|
+
{column.field === 'Actions' && actions && typeof actions === 'function' && (
|
|
293
|
+
<div
|
|
294
|
+
style={{ display: 'flex', gap: '2px', alignItems: 'center', justifyContent: 'center' }}
|
|
295
|
+
>
|
|
296
|
+
{actions(row).map(
|
|
297
|
+
(action, actionIndex) =>
|
|
298
|
+
(action?.condition ? action.condition(row, conditionCheckObject) : true) && (
|
|
299
|
+
<CustomActionIcons
|
|
300
|
+
disabled={action.disabled === true ? row.state !== 'ACTIVE' : false}
|
|
301
|
+
row={row}
|
|
302
|
+
key={actionIndex + 1}
|
|
303
|
+
icon={action.icon}
|
|
304
|
+
menuClick={action.menuClick}
|
|
305
|
+
menuItems={action.menuItems}
|
|
306
|
+
onClick={() => {
|
|
307
|
+
if (!(action.disabled === true ? row.state !== 'ACTIVE' : false)) {
|
|
308
|
+
action?.onClick(row, rowIndex);
|
|
309
|
+
}
|
|
310
|
+
}}
|
|
311
|
+
/>
|
|
312
|
+
)
|
|
313
|
+
)}
|
|
314
|
+
</div>
|
|
315
|
+
)}
|
|
316
|
+
|
|
317
|
+
{column.field === 'Actions' && actions && typeof actions !== 'function' && (
|
|
318
|
+
<div
|
|
319
|
+
style={{ display: 'flex', gap: '2px', alignItems: 'center', justifyContent: 'center' }}
|
|
320
|
+
>
|
|
321
|
+
{actions.map(
|
|
322
|
+
(action, actionIndex) =>
|
|
323
|
+
(action?.condition ? action.condition(row, conditionCheckObject) : true) && (
|
|
324
|
+
<CustomActionIcons
|
|
325
|
+
disabled={action.disabled === true ? row.state !== 'ACTIVE' : false}
|
|
326
|
+
row={row}
|
|
327
|
+
key={actionIndex + 1}
|
|
328
|
+
icon={action.icon}
|
|
329
|
+
menuClick={action.menuClick}
|
|
330
|
+
menuItems={action.menuItems}
|
|
331
|
+
onClick={() => {
|
|
332
|
+
if (!(action.disabled === true ? row.state !== 'ACTIVE' : false)) {
|
|
333
|
+
action?.onClick(row, rowIndex);
|
|
334
|
+
}
|
|
335
|
+
}}
|
|
336
|
+
/>
|
|
337
|
+
)
|
|
338
|
+
)}
|
|
339
|
+
</div>
|
|
340
|
+
)}
|
|
341
|
+
|
|
342
|
+
{column.render ? (
|
|
343
|
+
column.render(row, rowIndex)
|
|
344
|
+
) : (
|
|
345
|
+
<>
|
|
346
|
+
{(getFieldValue(row, column.field) || getFieldValue(row, column.field) === 0) &&
|
|
347
|
+
column.field !== 'Actions' &&
|
|
348
|
+
column.field !== 'rowSelect'
|
|
349
|
+
? (() =>
|
|
350
|
+
!disableHtml ? (
|
|
351
|
+
<div
|
|
352
|
+
style={{
|
|
353
|
+
fontSize: '0.875rem',
|
|
354
|
+
fontWeight: column.isBold ? 'bold' : 'normal', // Apply bold styling
|
|
355
|
+
}}
|
|
356
|
+
dangerouslySetInnerHTML={{ __html: getFieldValue(row, column.field) }}
|
|
357
|
+
/>
|
|
358
|
+
) : (
|
|
359
|
+
<span style={{ fontWeight: column.isBold ? 'bold' : 'normal' }}>
|
|
360
|
+
{getFieldValue(row, column.field)}
|
|
361
|
+
</span>
|
|
362
|
+
))()
|
|
363
|
+
: ''}
|
|
364
|
+
{!(getFieldValue(row, column.field) || getFieldValue(row, column.field) === 0) &&
|
|
365
|
+
column.field !== 'Actions' &&
|
|
366
|
+
column.field !== 'Sr. No.' &&
|
|
367
|
+
column.field !== 'rowSelect' &&
|
|
368
|
+
column.field !== 'statusCheckbox' &&
|
|
369
|
+
'NA'}
|
|
370
|
+
</>
|
|
371
|
+
)}
|
|
372
|
+
{column.field === 'Sr. No.' && rowIndex + 1}
|
|
373
|
+
</StyledTableCell>
|
|
374
|
+
</React.Fragment>
|
|
375
|
+
)
|
|
376
|
+
)}
|
|
377
|
+
</StyledTableRow>
|
|
378
|
+
))
|
|
379
|
+
) : (
|
|
380
|
+
<StyledTableRow>
|
|
381
|
+
<StyledTableCell
|
|
382
|
+
className={`px-4 leading-7 ${fontSize ? `text-[${fontSize}] !important` : ''} border-b-0 border-r-0`}
|
|
383
|
+
>
|
|
384
|
+
{isLoading && useSkeleton ? (
|
|
385
|
+
<div className="animate-pulse bg-gray-300 w-full h-100"></div>
|
|
386
|
+
) : (
|
|
387
|
+
translate('No Records Available')
|
|
388
|
+
)}
|
|
389
|
+
</StyledTableCell>
|
|
390
|
+
</StyledTableRow>
|
|
391
|
+
)}
|
|
392
|
+
</TableBody>
|
|
393
|
+
</Table>
|
|
394
|
+
);
|
|
395
|
+
};
|
|
396
|
+
|
|
397
|
+
return (
|
|
398
|
+
<>
|
|
399
|
+
<StyledTableContainer
|
|
400
|
+
component={Paper}
|
|
401
|
+
style={{ position: 'relative', overflow: 'auto' }}
|
|
402
|
+
sx={{ maxHeight: customHeight ? `calc(100vh - ${150 + customHeight}px)` : `calc(100vh - 150px)` }}
|
|
403
|
+
>
|
|
404
|
+
{noPagination ? (
|
|
405
|
+
<CustomInfiniteScroll
|
|
406
|
+
// pageStart={0}
|
|
407
|
+
loadMore={loadMore}
|
|
408
|
+
hasMore={hasMore}
|
|
409
|
+
renderTableBody={renderTableBody}
|
|
410
|
+
noPagination={noPagination}
|
|
411
|
+
customHeight={customHeight}
|
|
412
|
+
// loader={
|
|
413
|
+
// <div
|
|
414
|
+
// key={0}
|
|
415
|
+
// style={{
|
|
416
|
+
// display: 'flex',
|
|
417
|
+
// justifyContent: 'center',
|
|
418
|
+
// alignItems: 'center',
|
|
419
|
+
// padding: '20px',
|
|
420
|
+
// }}
|
|
421
|
+
// >
|
|
422
|
+
// <CircularProgress />
|
|
423
|
+
// </div>
|
|
424
|
+
// }
|
|
425
|
+
useWindow={false}
|
|
426
|
+
/>
|
|
427
|
+
) : (
|
|
428
|
+
renderTableBody()
|
|
429
|
+
)}
|
|
430
|
+
</StyledTableContainer>
|
|
431
|
+
{!noPagination && !isLoading && (
|
|
432
|
+
<Grid container justifyContent={'space-between'} sx={{ width: '100%' }}>
|
|
433
|
+
<Grid>
|
|
434
|
+
{rowsPerPageOptionsArray && rowsPerPageOptionsArray.length > 0 && (
|
|
435
|
+
<TablePagination
|
|
436
|
+
component="div"
|
|
437
|
+
count={totalRows !== undefined ? totalRows : (() => (rowData ? rowData.length : 0))()}
|
|
438
|
+
page={page}
|
|
439
|
+
onPageChange={(event, newPage) => handlePageChange(newPage)}
|
|
440
|
+
sx={{
|
|
441
|
+
'& .MuiTablePagination-actions': {
|
|
442
|
+
visibility: 'hidden',
|
|
443
|
+
},
|
|
444
|
+
'& .MuiSelect-select': {
|
|
445
|
+
padding: '6px 32px 6px 16px',
|
|
446
|
+
},
|
|
447
|
+
'& .MuiTablePagination-input, & .MuiTablePagination-selectLabel': {
|
|
448
|
+
display: displayPageSelect ? undefined : 'none',
|
|
449
|
+
},
|
|
450
|
+
}}
|
|
451
|
+
labelRowsPerPage="Items per page"
|
|
452
|
+
labelDisplayedRows={({ from, to, count }) => `${from}-${to} of ${count} items`}
|
|
453
|
+
rowsPerPage={rowsPerPage}
|
|
454
|
+
onRowsPerPageChange={handleChangeRowsPerPage}
|
|
455
|
+
rowsPerPageOptions={rowsPerPageOptionsArray}
|
|
456
|
+
/>
|
|
457
|
+
)}
|
|
458
|
+
</Grid>
|
|
459
|
+
<Grid alignItems={'center'} display={'flex'}>
|
|
460
|
+
<Stack>
|
|
461
|
+
<Pagination
|
|
462
|
+
count={
|
|
463
|
+
totalRows !== undefined
|
|
464
|
+
? Math.ceil(totalRows / rowsPerPage)
|
|
465
|
+
: (() => (rowData ? Math.ceil(rowData.length / rowsPerPage) : 0))()
|
|
466
|
+
}
|
|
467
|
+
page={page + 1}
|
|
468
|
+
onChange={(event, newPage) => {
|
|
469
|
+
handlePageChange(newPage - 1); // Convert to 0-based index
|
|
470
|
+
}}
|
|
471
|
+
showFirstButton
|
|
472
|
+
showLastButton
|
|
473
|
+
sx={{
|
|
474
|
+
'& .MuiPaginationItem-root.Mui-selected': {
|
|
475
|
+
backgroundColor: '#004C70',
|
|
476
|
+
color: '#FFFFFF',
|
|
477
|
+
},
|
|
478
|
+
'& .MuiPaginationItem-root.Mui-selected:hover': {
|
|
479
|
+
backgroundColor: '#678ea0',
|
|
480
|
+
},
|
|
481
|
+
}}
|
|
482
|
+
/>
|
|
483
|
+
</Stack>
|
|
484
|
+
</Grid>
|
|
485
|
+
</Grid>
|
|
486
|
+
)}
|
|
487
|
+
|
|
488
|
+
{!noPagination && isLoading && useSkeleton && (
|
|
489
|
+
<div className="w-full justify-between flex-wrap flex flex-row mt-4">
|
|
490
|
+
<div className="flex-wrap flex flex-row">
|
|
491
|
+
<div className="bg-gray-300 animate-pulse rounded-sm h-[36px] w-[100px] mr-2 mb-2"></div>
|
|
492
|
+
</div>
|
|
493
|
+
|
|
494
|
+
<div className="flex">
|
|
495
|
+
<div className="bg-gray-300 animate-pulse rounded-sm h-[32px] w-[180px] m-0.5"></div>
|
|
496
|
+
</div>
|
|
497
|
+
</div>
|
|
498
|
+
)}
|
|
499
|
+
</>
|
|
500
|
+
);
|
|
501
|
+
};
|
|
502
|
+
|
|
503
|
+
CustomizedTable.propTypes = {
|
|
504
|
+
columns: PropTypes.any,
|
|
505
|
+
tableData: PropTypes.any,
|
|
506
|
+
actions: PropTypes.any,
|
|
507
|
+
rowsPerPageInTable: PropTypes.any,
|
|
508
|
+
displayPageSelect: PropTypes.any,
|
|
509
|
+
noPagination: PropTypes.any,
|
|
510
|
+
doNotShowTableHead: PropTypes.any,
|
|
511
|
+
fontSize: PropTypes.any,
|
|
512
|
+
loadMore: PropTypes.any,
|
|
513
|
+
hasMore: PropTypes.any,
|
|
514
|
+
handleSort: PropTypes.any,
|
|
515
|
+
sortOrder: PropTypes.any,
|
|
516
|
+
conditionCheckObj: PropTypes.any,
|
|
517
|
+
disableHtml: PropTypes.any,
|
|
518
|
+
dataTestId: PropTypes.any,
|
|
519
|
+
customHeight: PropTypes.any,
|
|
520
|
+
totalRows: PropTypes.any,
|
|
521
|
+
currentPage: PropTypes.any,
|
|
522
|
+
onPageChange: PropTypes.any,
|
|
523
|
+
selectRows: PropTypes.any,
|
|
524
|
+
setSelectedRows: PropTypes.any,
|
|
525
|
+
selectedRows: PropTypes.any,
|
|
526
|
+
selectedRowsUnique: PropTypes.any,
|
|
527
|
+
isLoading: PropTypes.any,
|
|
528
|
+
handleToggleStatus: PropTypes.any,
|
|
529
|
+
strip: PropTypes.any,
|
|
530
|
+
};
|
|
531
|
+
|
|
532
|
+
export default CustomizedTable;
|