From 60d187b300defeef19f7a82dcb4e1111e8629480 Mon Sep 17 00:00:00 2001 From: deepvasoya Date: Wed, 21 May 2025 11:54:59 +0530 Subject: [PATCH] fix: super admin dashboard fix: clinic list fitler counts --- src/utils/share.js | 8 ++++---- src/views/ClinicsList/index.jsx | 11 ++++++----- src/views/Dashboard/index.jsx | 12 +++++------- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/utils/share.js b/src/utils/share.js index 139ca3d..5831235 100644 --- a/src/utils/share.js +++ b/src/utils/share.js @@ -31,9 +31,9 @@ export const isBSPortal = () => { return { isSuperAdmin }; }; -export const commonLogoutFunc = async (redirectPath = "/auth/login") => { +export const commonLogoutFunc = async () => { try { - await logout(); + // await logout(); resetLocalStorage(); // Try to delete the Firebase messaging token, but don't let it block logout if it fails try { @@ -42,12 +42,12 @@ export const commonLogoutFunc = async (redirectPath = "/auth/login") => { console.warn('Failed to delete Firebase messaging token:', error); // Continue with logout even if token deletion fails } - window.location.replace(redirectPath); + window.location.replace("/"); } catch (error) { console.error('Error during logout:', error); // Ensure user is still logged out even if there's an error resetLocalStorage(); - window.location.replace(redirectPath); + window.location.replace("/"); } }; diff --git a/src/views/ClinicsList/index.jsx b/src/views/ClinicsList/index.jsx index d879b91..36c20ca 100644 --- a/src/views/ClinicsList/index.jsx +++ b/src/views/ClinicsList/index.jsx @@ -8,8 +8,6 @@ import { differenceInDays, format } from 'date-fns'; import { LoadingButton } from '@mui/lab'; import FileDownloadIcon from '@mui/icons-material/FileDownload'; - - import { useStyles } from "./clinicListStyles"; import { CLINIC_STATUS, CLINIC_TYPE, NOT_AVAILABLE_TEXT, PLAN_STATUS_TYPE } from "../../constants"; import { getClinics } from "../../services/clinics.service"; @@ -32,6 +30,8 @@ const ClinicsList = () => { const showNewPlanAddedModel = Boolean(queryParams.get("isPlanCreated")) ?? false; const [isDownloading, setIsDownloading] = useState(false); + const[totalActive, setTotalActive] = useState(0); + const[totalInactive, setTotalInactive] = useState(0); const [showModel, setShowModel] = useState(false); const [modelType, setModelType] = useState(""); const [rowActionData, setRowActionData] = useState(""); @@ -406,7 +406,8 @@ const ClinicsList = () => { type, }; const resp = await getClinics(params); - console.log(resp) + setTotalActive(resp?.data?.data?.data?.totalRegisteredClinics); + setTotalInactive(resp?.data?.data?.data?.totalRejectedClinics); return { data: resp?.data?.data?.data?.clinics, rowCount: resp?.data?.data?.total, @@ -467,8 +468,8 @@ const ClinicsList = () => { extraComponent={ - - + + {/* */} diff --git a/src/views/Dashboard/index.jsx b/src/views/Dashboard/index.jsx index ea737e4..2caaca9 100644 --- a/src/views/Dashboard/index.jsx +++ b/src/views/Dashboard/index.jsx @@ -80,22 +80,20 @@ function Dashboard() { }; useEffect(() => { - getClinic(); // Determine user role based on user data from login reducer if (user) { // Check if user is a super admin // This logic can be adjusted based on your specific role criteria const isSuperAdmin = user.userType == USER_ROLES.SUPER_ADMIN.toLowerCase(); - - const clinicStatus = user.created_clinics[0].status; - - setIsActive(clinicStatus == "active"); - + if (isSuperAdmin) { - dispatch(setUserRole(USER_ROLES.SUPER_ADMIN, clinicStatus)); + dispatch(setUserRole(USER_ROLES.SUPER_ADMIN, "")); } else { + const clinicStatus = user.created_clinics[0].status; + setIsActive(clinicStatus == "active"); dispatch(setUserRole(USER_ROLES.CLINIC_ADMIN, clinicStatus)); + getClinic(); } } setIsLoading(false);