fix: super admin dashboard
fix: clinic list fitler counts
This commit is contained in:
parent
35f21f2749
commit
60d187b300
|
|
@ -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("/");
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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={
|
||||
<Box className={classes.tabsBox}>
|
||||
<Tabs value={type} onChange={handleTabsChange}>
|
||||
<Tab value={CLINIC_TYPE.UNREGISTERED} label="Unregistered (2)" />
|
||||
<Tab value={CLINIC_TYPE.REGISTERED} label="Registered (2)" />
|
||||
<Tab value={CLINIC_TYPE.UNREGISTERED} label={`Unregistered (${totalInactive})`} />
|
||||
<Tab value={CLINIC_TYPE.REGISTERED} label={`Registered (${totalActive})`} />
|
||||
{/* <Tab value={COMPANY_TYPE.SUBSCRIBED} label="Subscribers" /> */}
|
||||
</Tabs>
|
||||
</Box>
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue