diff --git a/src/components/AttendanceComparison.tsx b/src/components/AttendanceComparison.tsx index 3b90d96b..d71e95c5 100644 --- a/src/components/AttendanceComparison.tsx +++ b/src/components/AttendanceComparison.tsx @@ -144,17 +144,17 @@ const AttendanceComparison: React.FC = ({ padding: 2, borderRadius: 5, border: '1px solid #D0C5B4', - marginTop: '20px', + marginTop: '10px', }} > {t('DASHBOARD.ATTENDANCE_COMPARISON')} - + {blockName} {t('DASHBOARD.BLOCK')} - + {t('DASHBOARD.CENTER_TYPE')} = ({ - + = ({ `${value}%`} - display="none" + height={0} /> `${value}%`} /> @@ -239,7 +239,7 @@ const AttendanceComparison: React.FC = ({ { const router = useRouter(); const { cohortId }: any = router.query; const { t } = useTranslation(); + const [role, setRole] = React.useState(''); const store = manageUserStore(); const setDistrictCode = manageUserStore( @@ -82,7 +83,7 @@ const TeachingCenterDetails = () => { const setBlockId = manageUserStore( (state: { setBlockId: any }) => state.setBlockId ); - const role = localStorage.getItem('role'); + const [open, setOpen] = React.useState(false); const theme = useTheme(); const [selectedDate, setSelectedDate] = @@ -132,6 +133,13 @@ const TeachingCenterDetails = () => { (state) => state.setRemoveCohortId ); + useEffect(() => { + if (typeof window !== 'undefined' && window.localStorage) { + const role = localStorage.getItem('role'); + setRole(role); + } + }, []); + useEffect(() => { const getCohortData = async () => { const response = await getCohortDetails(cohortId); diff --git a/src/pages/dashboard.tsx b/src/pages/dashboard.tsx index 13c8fd87..9532f62a 100644 --- a/src/pages/dashboard.tsx +++ b/src/pages/dashboard.tsx @@ -87,7 +87,8 @@ const Dashboard: React.FC = () => { const formattedSevenDaysAgo = shortDateFormat(sevenDaysAgo); const [userId, setUserId] = React.useState(null); const [blockName, setBlockName] = React.useState(''); - const role = localStorage.getItem('role'); + const [role, setRole] = React.useState(''); + useEffect(() => { setIsClient(true); const calculateDateRange = () => { @@ -120,6 +121,8 @@ const Dashboard: React.FC = () => { useEffect(() => { if (typeof window !== 'undefined' && window.localStorage) { const token = localStorage.getItem('token'); + const role = localStorage.getItem('role'); + setRole(role); const storedUserId = localStorage.getItem('userId'); setClassId(localStorage.getItem('classId') ?? ''); if (token) {