Skip to content

Commit

Permalink
Merge pull request #365 from shreyas1434shinde/centerSession
Browse files Browse the repository at this point in the history
Issue #PS-1344 fix: Center Sessions UI Implementation
  • Loading branch information
itsvick authored Jul 10, 2024
2 parents 1c49f58 + 7395bb6 commit 0922854
Show file tree
Hide file tree
Showing 11 changed files with 326 additions and 21 deletions.
8 changes: 7 additions & 1 deletion public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,13 @@
"USER_DELETED_PERMANENTLY": "User Successfully Deleted!",
"OBSERVATIONS_FORMS": "Observations and Forms",
"OTHER_REASON": "Other Reason",
"OTHER_REASON_PLACEHOLDER": "Enter Other Reason"
"OTHER_REASON_PLACEHOLDER": "Enter Other Reason",
"CENTER_SESSIONS": "Center Sessions",
"SCHEDULE_NEW": "Schedule New",
"UPCOMING_EXTRA_SESSION": "Upcoming Extra Sessions",
"NO_SESSIONS_SCHEDULED": "No sessions scheduled",
"TO_BE_TAUGHT": "What is going to be taught:",
"SELECT_TOPIC": "Select Topic, Sub-topic"
},
"LOGIN_PAGE": {
"USERNAME": "Username",
Expand Down
12 changes: 9 additions & 3 deletions public/locales/hi/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,13 @@
"LEARNER_MARKED_DROPOUT": "शिक्षार्थी को ड्रॉप आउट के रूप में चिह्नित किया गया",
"LEARNER_UNMARKED_DROPOUT": "शिक्षार्थी को ड्रॉपआउट के रूप में अनचिह्नित किया गया",
"LEARNER_REMOVED": "शिक्षार्थी को हटा दिया गया है",
"DELETE_USER": "उपयोगकर्ता को स्थायी रूप से हटाएं"
"DELETE_USER": "उपयोगकर्ता को स्थायी रूप से हटाएं",
"CENTER_SESSIONS": "केंद्र सत्र",
"SCHEDULE_NEW": "शेड्यूल नया",
"UPCOMING_EXTRA_SESSION": "आगामी अतिरिक्त सत्र",
"NO_SESSIONS_SCHEDULED": "कोई सत्र निर्धारित नहीं है",
"TO_BE_TAUGHT": "क्या सिखाया जाएगा:",
"SELECT_TOPIC": "विषय, उप-विषय चुनें"
},
"LOGIN_PAGE": {
"USERNAME": "उपयोगकर्ता नाम",
Expand Down Expand Up @@ -256,7 +262,7 @@
"REGULAR": "नियमित",
"REMOTE": "दूरस्थ",
"NEW_CENTER": "नया केंद्र",
"UNIT_NAME": "इकाई नाम",
"NOTE": "नोट: यह केंद्र का नाम होगा"
"UNIT_NAME": "इकाई नाम",
"NOTE": "नोट: यह केंद्र का नाम होगा"
}
}
19 changes: 12 additions & 7 deletions public/locales/mr/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,13 @@
"LEARNER_MARKED_DROPOUT": "शिकणाऱ्याला ड्रॉप आऊट म्हणून चिन्हांकित केले",
"LEARNER_UNMARKED_DROPOUT": "शिकणाऱ्याला ड्रॉपआउट म्हणून अनचिन्हांकित केले",
"LEARNER_REMOVED": "शिकणाऱ्याचे हटवले गेले आहे",
"DELETE_USER": "वापरकर्त्यास कायमचे हटवा"
"DELETE_USER": "वापरकर्त्यास कायमचे हटवा",
"CENTER_SESSIONS": "केंद्र सत्र",
"SCHEDULE_NEW": "नवीन वेळापत्रक",
"UPCOMING_EXTRA_SESSION": "आगामी अतिरिक्त सत्र",
"NO_SESSIONS_SCHEDULED": "कोणतेही सत्र शेड्यूल केलेले नाही",
"TO_BE_TAUGHT": "काय शिकवले जाईल:",
"SELECT_TOPIC": "विषय, उप-विषय निवडा"
},
"LOGIN_PAGE": {
"USERNAME": "वापरकर्तानाव",
Expand Down Expand Up @@ -256,9 +262,8 @@
"CENTER_TYPE": "केंद्र प्रकार",
"REGULAR": "नियमित",
"REMOTE": "दूरस्थ",
"NEW_CENTER": "नवीन केंद्र",
"UNIT_NAME": "युनिट नाव",
"NOTE": "टीप: हे केंद्राचे नाव असेल"
}
}

"NEW_CENTER": "नवीन केंद्र",
"UNIT_NAME": "युनिट नाव",
"NOTE": "टीप: हे केंद्राचे नाव असेल"
}
}
49 changes: 49 additions & 0 deletions src/components/SessionCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { Box, Typography } from '@mui/material';
import { Session, SessionsCardProps } from '@/utils/Interfaces';

import EditOutlined from '@mui/icons-material/EditOutlined';
import React from 'react';
import { useTheme } from '@mui/material/styles';

const SessionsCard: React.FC<SessionsCardProps> = ({ data, children }) => {
const theme = useTheme<any>();
return (
<Box
sx={{
border: `1px solid ${theme.palette.warning['A100']}`,
borderRadius: '8px',
marginBottom: '16px',
}}
>
<Box
sx={{
display: 'flex',
justifyContent: 'space-between',
padding: '8px 16px',
}}
>
<Box>
<Typography
color={theme.palette.warning['300']}
fontWeight={'400'}
textAlign={'left'}
fontSize={'16px'}
>
{data?.subject}
</Typography>

<Typography fontWeight={'400'} textAlign={'left'} fontSize={'14px'}>
{data?.time}
</Typography>
<Typography fontWeight={'400'} textAlign={'left'} fontSize={'14px'}>
{data?.teacherName}
</Typography>
</Box>
<EditOutlined />
</Box>
<Box>{children}</Box>
</Box>
);
};

export default SessionsCard;
96 changes: 96 additions & 0 deletions src/components/SessionCardFooter.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
import Accordion from '@mui/material/Accordion';
import AccordionDetails from '@mui/material/AccordionDetails';
import AccordionSummary from '@mui/material/AccordionSummary';
import ArrowForwardIcon from '@mui/icons-material/ArrowForward';
import Box from '@mui/material/Box';
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
import MenuBookIcon from '@mui/icons-material/MenuBook';
import PriorityHighIcon from '@mui/icons-material/PriorityHigh';
import React from 'react';
import { SessionCardFooterProps } from '../utils/Interfaces';
import SubdirectoryArrowRightIcon from '@mui/icons-material/SubdirectoryArrowRight';
import Typography from '@mui/material/Typography';
import { useTheme } from '@mui/material/styles';
import { useTranslation } from 'react-i18next';

const SessionCardFooter: React.FC<SessionCardFooterProps> = ({ item }) => {
const theme = useTheme();
const { t } = useTranslation();

return item?.topic ? (
<Box
sx={{
background: theme.palette.background.default,
padding: '4px 16px',
borderRadius: '8px',
}}
>
<Accordion
defaultExpanded
sx={{
boxShadow: 'none',
border: 'none',
background: 'none',
}}
>
<AccordionSummary
expandIcon={<ExpandMoreIcon />}
aria-controls="panel1-content"
id="panel1-header"
className="accordion-summary"
sx={{ px: 0, m: 0 }}
>
<Typography fontWeight="500" fontSize="14px" className="text-7C">
{t('COMMON.TO_BE_TAUGHT')}
</Typography>
</AccordionSummary>
<AccordionDetails sx={{ padding: '0px' }}>
<Box sx={{ display: 'flex', gap: '10px' }}>
<MenuBookIcon />
<Typography color={theme.palette.secondary.main} variant="h5">
{item?.topic}
</Typography>
</Box>
<Box
sx={{
display: 'flex',
gap: '10px',
marginTop: '5px',
marginLeft: '10px',
}}
>
<SubdirectoryArrowRightIcon />
<Typography color={theme.palette.secondary.main} variant="h5">
{item?.subtopic}
</Typography>
</Box>
</AccordionDetails>
</Accordion>
</Box>
) : (
<Box
sx={{
display: 'flex',
justifyContent: 'space-between',
background: theme.palette.background.default,
padding: '8px 16px',
borderRadius: '8px',
}}
>
<Box sx={{ display: 'flex', alignItems: 'center' }}>
<PriorityHighIcon sx={{ color: theme.palette.error.main }} />
<Box
fontSize={'14px'}
fontWeight={500}
color={theme.palette.secondary.main}
ml={1}
>
{t('COMMON.SELECT_TOPIC')}
</Box>
</Box>
<ArrowForwardIcon />
</Box>
);
};

export default SessionCardFooter;
102 changes: 93 additions & 9 deletions src/pages/centers/[cohortId].tsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,52 @@
import { Button, Typography } from '@mui/material';
import React, { useEffect } from 'react';
import { formatSelectedDate, getTodayDate, toPascalCase } from '@/utils/Helper';

import Accordion from '@mui/material/Accordion';
import AccordionDetails from '@mui/material/AccordionDetails';
import AccordionSummary from '@mui/material/AccordionSummary';
import AddIcon from '@mui/icons-material/Add';
import AddLeanerModal from '@/components/AddLeanerModal';
import ArrowForwardIcon from '@mui/icons-material/ArrowForward';
import Box from '@mui/material/Box';
import CohortLearnerList from '@/components/CohortLearnerList';
import { CustomField } from '@/utils/Interfaces';
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
import { GetStaticPaths } from 'next';
import Header from '@/components/Header';
import KeyboardBackspaceOutlinedIcon from '@mui/icons-material/KeyboardBackspaceOutlined';
import MenuBookIcon from '@mui/icons-material/MenuBook';
import PriorityHighIcon from '@mui/icons-material/PriorityHigh';
import { Session } from '../../utils/Interfaces';
import SessionCard from '@/components/SessionCard';
import SessionCardFooter from '@/components/SessionCardFooter';
import SubdirectoryArrowRightIcon from '@mui/icons-material/SubdirectoryArrowRight';
import Tab from '@mui/material/Tab';
import Tabs from '@mui/material/Tabs';
import WeekCalender from '@/components/WeekCalender';
import { getCohortDetails } from '@/services/CohortServices';
import { getSessions } from '@/services/Sessionservice';
import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
import { useRouter } from 'next/router';
import { useTheme } from '@mui/material/styles';
import { useTranslation } from 'next-i18next';
import { toPascalCase } from '@/utils/Helper';

const TeachingCenterDetails = () => {
const [value, setValue] = React.useState(1);
const [showDetails, setShowDetails] = React.useState(false);
const [classId, setClassId] = React.useState('');
const router = useRouter();
const { cohortId }: any = router.query;
const { t } = useTranslation();
const theme = useTheme<any>();
const [selectedDate, setSelectedDate] =
React.useState<string>(getTodayDate());

const [cohortDetails, setCohortDetails] = React.useState<any>({});
const [reloadState, setReloadState] = React.useState<boolean>(false);
const [sessions, setSessions] = React.useState<Session[]>();
const [percentageAttendanceData, setPercentageAttendanceData] =
React.useState<any>(null);

useEffect(() => {
const getCohortData = async () => {
Expand All @@ -41,20 +60,31 @@ const TeachingCenterDetails = () => {

if (cohortData?.customField?.length) {
const district = cohortData.customField.find(
(item: CustomField) => item.label === "District"
(item: CustomField) => item.label === 'District'
);
const state = cohortData.customField.find(
(item: CustomField) => item.label === 'State'
);

cohortData.address = `${toPascalCase(district?.value)}, ${toPascalCase(state?.value)}` || '';
cohortData.address =
`${toPascalCase(district?.value)}, ${toPascalCase(state?.value)}` ||
'';
}
setCohortDetails(cohortData);
}
};
getCohortData();
}, []);

useEffect(() => {
const getSessionsData = async () => {
const response: Session[] = await getSessions('cohortId'); // Todo add dynamic cohortId
setSessions(response);
};

getSessionsData();
}, []);

const handleChange = (event: React.SyntheticEvent, newValue: number) => {
setValue(newValue);
};
Expand All @@ -63,6 +93,11 @@ const TeachingCenterDetails = () => {
window.history.back();
};

const showDetailsHandle = (dayStr: string) => {
setSelectedDate(formatSelectedDate(dayStr));
setShowDetails(true);
};

return (
<>
<Header />
Expand Down Expand Up @@ -91,14 +126,12 @@ const TeachingCenterDetails = () => {
(cohortDetails?.centerType)
</Typography>
)}
<Box>
</Box>

<Box>
<Typography textAlign={'left'} fontSize={'11px'} fontWeight={500}>
{cohortDetails?.address}
</Typography>
</Box>

</Box>
</Box>
</Box>
</Box>
Expand Down Expand Up @@ -131,11 +164,62 @@ const TeachingCenterDetails = () => {
},
}}
>
<Tab value={1} label={t('COMMON.LEARNER_LIST')} />
<Tab value={1} label={t('COMMON.CENTER_SESSIONS')} />
<Tab value={2} label={t('COMMON.LEARNER_LIST')} />
</Tabs>
</Box>

{value === 1 && (
<>
<Box mt={3} px={'18px'}>
<Button
sx={{
border: `1px solid ${theme.palette.error.contrastText}`,
borderRadius: '100px',
height: '40px',
width: '163px',
color: theme.palette.error.contrastText,
}}
className="text-1E"
endIcon={<AddIcon />}
>
{t('COMMON.SCHEDULE_NEW')}
</Button>
</Box>
<Box mt={3} px={'18px'}>
<Box
className="fs-14 fw-500"
sx={{ color: theme.palette.warning['300'] }}
>
{t('COMMON.UPCOMING_EXTRA_SESSION')}
</Box>
<Box
className="fs-12 fw-400 italic"
sx={{ color: theme.palette.warning['300'] }}
>
{t('COMMON.NO_SESSIONS_SCHEDULED')}
</Box>
</Box>
<Box>
<WeekCalender
showDetailsHandle={showDetailsHandle}
data={percentageAttendanceData}
disableDays={classId === 'all' ? true : false}
classId={classId}
/>
</Box>
<Box mt={3} px="18px">
{sessions &&
sessions.map((item: Session, index: number) => (
<SessionCard data={item} key={item.id}>
<SessionCardFooter item={item} />
</SessionCard>
))}
</Box>
</>
)}
<Box>
{value === 1 && (
{value === 2 && (
<>
<Box mt={3} px={'18px'}>
<Button
Expand Down
Empty file.
Loading

0 comments on commit 0922854

Please sign in to comment.