Skip to content

Commit

Permalink
Merge pull request #341 from suvarnakale/shiksha-2.0
Browse files Browse the repository at this point in the history
Issue #PS-1101 feat: showing list of centers and block for team leade…
  • Loading branch information
itsvick authored Jul 3, 2024
2 parents 8973e5d + 8407869 commit 87b3a1d
Show file tree
Hide file tree
Showing 5 changed files with 540 additions and 127 deletions.
2 changes: 2 additions & 0 deletions public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@
"CENTER_ATTENDANCE": "Center Attendance",
"MY_TIMETABLE": "My Timetable",
"MY_TEACHING_CENTERS": "My Teaching Centers",
"TEACHING_CENTERS": "Teaching Centers",
"UPCOMING_EXTRA_SESSION": "Upcoming Extra Sessions",
"BACK_TO_TOP": "Back to Top",
"LAST_SEVEN_DAYS_RANGE": "Last 7 Days {{date_range}}",
Expand Down Expand Up @@ -254,6 +255,7 @@
"SEARCH_BLOCKS": "Search Blocks"
},
"CENTERS": {
"CENTERS": "Centers",
"REGULAR_CENTERS": "Regular Centers",
"REMOTE_CENTERS": "Remote Center",
"REGULAR": "Regular",
Expand Down
92 changes: 61 additions & 31 deletions src/pages/manageUser.tsx → src/components/ManageUser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ import LocationOnOutlinedIcon from '@mui/icons-material/LocationOnOutlined';
import { editEditUser } from '@/services/ProfileService';
import ConfirmationModal from '@/components/ConfirmationModal';
import { Status } from '@/utils/app.constant';
import AddIcon from '@mui/icons-material/Add';

import LearnersList from '@/components/LearnersList';
import Link from 'next/link';
interface Cohort {
cohortId: string;
parentId: string;
Expand Down Expand Up @@ -110,8 +112,8 @@ const learnersList = [
},
];
interface ManageUsersProps {
reloadState: boolean;
setReloadState: React.Dispatch<React.SetStateAction<boolean>>;
reloadState?: boolean;
setReloadState?: React.Dispatch<React.SetStateAction<boolean>>;
}

const manageUsers: React.FC<ManageUsersProps> = ({
Expand Down Expand Up @@ -386,20 +388,26 @@ const manageUsers: React.FC<ManageUsersProps> = ({
setReassignBlockRequestModalOpen(false);
};

const handleLearnerFullProfile = () => {
// router.push(`/learner/${userId}`);
router.push(`/profile`);
};
const noop = () => {};

return (
<>
<Header />
<Box sx={{ padding: '0 18px' }} className="mt--4">
<Box
{/* <Header /> */}
<Box>
{/* <Box
textAlign={'left'}
fontSize={'22px'}
p={'18px 0'}
color={theme?.palette?.warning['300']}
>
{t('COMMON.MANAGE_USERS')}
</Box>
</Box> */}
</Box>
<Box sx={{ width: '100%' }}>
{/* <Box sx={{ width: '100%' }}>
<Tabs
value={value}
onChange={handleChange}
Expand Down Expand Up @@ -431,7 +439,7 @@ const manageUsers: React.FC<ManageUsersProps> = ({
<Tab value={1} label={t('COMMON.FACILITATORS')} />
<Tab value={2} label={t('COMMON.LEARNERS')} />
</Tabs>
</Box>
</Box> */}
<Box>
{value === 1 && (
<>
Expand Down Expand Up @@ -483,6 +491,25 @@ const manageUsers: React.FC<ManageUsersProps> = ({
</FormControl>
</Box>
</Grid>
<Box mt={'18px'} px={'18px'}>
<Button
sx={{
border: '1px solid #1E1B16',
borderRadius: '100px',
height: '40px',
width: '8rem',
color: theme.palette.error.contrastText,
}}
className="text-1E"
endIcon={<AddIcon />}
>
{t('COMMON.ADD_NEW')}
</Button>
{/* <Box sx={{ display: 'flex', gap: '5px' }}>
<ErrorOutlineIcon style={{ fontSize: '15px' }} />
<Box className="fs-12 fw-500 ">{t('COMMON.ADD_CENTER')}</Box>
</Box> */}
</Box>
</Grid>

<Box>
Expand Down Expand Up @@ -510,14 +537,17 @@ const manageUsers: React.FC<ManageUsersProps> = ({
justifyContent={'space-between'}
sx={{ cursor: 'pointer' }}
>
<Box onClick={() => handleModalToggle(user)}>
<Box
// onClick={() => handleModalToggle(user)}
onClick={() => handleLearnerFullProfile()}
>
<Box
sx={{
fontSize: '16px',
color: theme.palette.warning['300'],
}}
>
{user.name}
<Link href={'/profile'}>{user.name}</Link>
</Box>

<Box display={'flex'}>
Expand Down Expand Up @@ -588,15 +618,15 @@ const manageUsers: React.FC<ManageUsersProps> = ({
),
name: 'reassign-block-request',
},
{
label: t('COMMON.REASSIGN_CENTERS'),
icon: (
<ApartmentIcon
sx={{ color: theme.palette.warning['300'] }}
/>
),
name: 'reassign-centers',
},
// {
// label: t('COMMON.REASSIGN_CENTERS'),
// icon: (
// <ApartmentIcon
// sx={{ color: theme.palette.warning['300'] }}
// />
// ),
// name: 'reassign-centers',
// },
{
label: t('COMMON.DELETE_USER'),
icon: (
Expand Down Expand Up @@ -654,7 +684,7 @@ const manageUsers: React.FC<ManageUsersProps> = ({
</Box>

<ConfirmationModal
message={t('BLOCKS.BLOCK_REQUEST')}
message={t('CENTERS.BLOCK_REQUEST')}
buttonNames={{
primary: t('COMMON.SEND_REQUEST'),
secondary: t('COMMON.CANCEL'),
Expand Down Expand Up @@ -725,16 +755,16 @@ const manageUsers: React.FC<ManageUsersProps> = ({
enrollmentId={data.enrollmentNumber}
cohortMembershipId={data.cohortMembershipId}
statusReason={data.statusReason}
reloadState={reloadState}
setReloadState={setReloadState}
reloadState={reloadState || false}
setReloadState={setReloadState || noop}
block={data.block}
center={data.center}
userId={data.userId}
/>
))}

<ConfirmationModal
message={t('BLOCKS.BLOCK_REQUEST')}
message={t('CENTERS.BLOCK_REQUEST')}
handleAction={handleReassignBlockRequest}
buttonNames={{
primary: t('COMMON.SEND_REQUEST'),
Expand All @@ -749,12 +779,12 @@ const manageUsers: React.FC<ManageUsersProps> = ({
</>
);
};
export async function getStaticProps({ locale }: any) {
return {
props: {
...(await serverSideTranslations(locale, ['common'])),
// Will be passed to the page component as props
},
};
}
// export async function getStaticProps({ locale }: any) {
// return {
// props: {
// ...(await serverSideTranslations(locale, ['common'])),
// // Will be passed to the page component as props
// },
// };
// }
export default manageUsers;
15 changes: 11 additions & 4 deletions src/components/MenuDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const MenuDrawer: React.FC<DrawerProps> = ({
}) => {
const theme = useTheme<any>();
const [isOpen, setIsOpen] = useState(open);
const [isTeamLeader, setIsTeamLeader] = useState(false);
const { t } = useTranslation();
const router = useRouter();

Expand All @@ -39,6 +40,10 @@ const MenuDrawer: React.FC<DrawerProps> = ({
if (typeof window !== 'undefined' && window.localStorage) {
const lang = localStorage.getItem('preferredLanguage') || 'en';
setLanguage(lang);
const role = localStorage.getItem('role');
if (role === 'Team Leader') {
setIsTeamLeader(true);
}
}
}, [setLanguage]);

Expand All @@ -63,7 +68,7 @@ const MenuDrawer: React.FC<DrawerProps> = ({

const isDashboard = router.pathname === '/dashboard';
const isTeacherCenter = router.pathname === '/centers';
const isManageUser = router.pathname === '/manageUser';
// const isManageUser = router.pathname === '/manageUser';

return (
<Drawer
Expand Down Expand Up @@ -201,7 +206,9 @@ const MenuDrawer: React.FC<DrawerProps> = ({
router.push(`/centers`); // Check route
}}
>
{t('DASHBOARD.MY_TEACHING_CENTERS')}
{isTeamLeader
? t('DASHBOARD.TEACHING_CENTERS')
: t('DASHBOARD.MY_TEACHING_CENTERS')}
</Button>
</Box>
<Box sx={{ marginTop: '12px' }}>
Expand All @@ -226,7 +233,7 @@ const MenuDrawer: React.FC<DrawerProps> = ({
{t('COMMON.OBSERVATIONS_FORMS')}
</Button>
</Box>
<Box sx={{ marginTop: '12px' }}>
{/* <Box sx={{ marginTop: '12px' }}>
<Button
className="fs-14"
sx={{
Expand Down Expand Up @@ -254,7 +261,7 @@ const MenuDrawer: React.FC<DrawerProps> = ({
>
{t('COMMON.MANAGE_USERS')}
</Button>
</Box>
</Box> */}
</Box>
</Drawer>
);
Expand Down
Loading

0 comments on commit 87b3a1d

Please sign in to comment.