diff --git a/public/locales/en/common.json b/public/locales/en/common.json index 4d1c5dce..6fd3529f 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -113,6 +113,11 @@ "MY_PROFILE": "My Profile", "VIEW_MORE": "View More", "VIEW_LESS": "View Less", - "DATA_RANAGE": "Data Range" + "DATA_RANAGE": "Data Range", + "LEARNER_DETAILS": "Learner Details", + "VIEW_DAY_WISE": "View Day-Wise", + "SUBMITTED_ON": "Submitted On", + "MARK_OBTAINED": "Mark Obtained", + "TOTAL_QUESTIONS":"Total Questions" } } diff --git a/public/locales/hi/common.json b/public/locales/hi/common.json index 1227198e..38bf7eaf 100644 --- a/public/locales/hi/common.json +++ b/public/locales/hi/common.json @@ -44,7 +44,6 @@ "LEARNER_NAME": "शिक्षार्थी का नाम", "DATE_RANGE": "तिथि सीमा", "SELECT_AN_OPTION": "कोई विकल्प चुनें" - }, "LOGIN_PAGE": { "USERNAME": "उपयोगकर्ता नाम", @@ -114,6 +113,11 @@ "MY_PROFILE": "मेरी प्रोफ़ाइल", "VIEW_MORE": "अधिक देखें", "VIEW_LESS": "कम देखें", - "DATA_RANAGE": "डेटा रेंज़" + "DATA_RANAGE": "डेटा रेंज़", + "LEARNER_DETAILS": "विद्यार्थी विवरण", + "VIEW_DAY_WISE": "दिन-वार देखें", + "SUBMITTED_ON": "प्रस्तुत किया गया", + "MARK_OBTAINED": "प्राप्त अंक", + "TOTAL_QUESTIONS": "कुल प्रश्न" } } diff --git a/public/locales/mr/common.json b/public/locales/mr/common.json index 3d846a3e..88ce44b1 100644 --- a/public/locales/mr/common.json +++ b/public/locales/mr/common.json @@ -43,8 +43,6 @@ "LEARNER_NAME": "शिकणाऱ्याचे नाव", "DATE_RANGE": "तारीख श्रेणी", "SELECT_AN_OPTION": "एक पर्याय निवडा" - - }, "LOGIN_PAGE": { "USERNAME": "वापरकर्ता नाव", @@ -110,6 +108,11 @@ "MY_PROFILE": "माझी प्रोफाइल", "VIEW_MORE": "अधिक पाहा", "VIEW_LESS": "कमी करा", - "DATA_RANAGE": "डेटा श्रेणी" + "DATA_RANAGE": "डेटा श्रेणी", + "LEARNER_DETAILS": "विद्यार्थी तपशील", + "VIEW_DAY_WISE": "दिवस-निहाय पहा", + "SUBMITTED_ON": "सादर केलेले", + "MARK_OBTAINED": "प्राप्त गुण", + "TOTAL_QUESTIONS": "एकूण प्रश्न" } } diff --git a/src/components/MarkBulkAttendance.tsx b/src/components/MarkBulkAttendance.tsx index 9c2982ae..6ba263e7 100644 --- a/src/components/MarkBulkAttendance.tsx +++ b/src/components/MarkBulkAttendance.tsx @@ -100,7 +100,7 @@ const MarkBulkAttendace: React.FC = ({ setLoading(true); try { if (classId) { - const limit = 0; + const limit = 300; const page = 0; const filters = { cohortId: classId }; const response = await getMyCohortMemberList({ @@ -119,7 +119,7 @@ const MarkBulkAttendace: React.FC = ({ const formatSelectedDate = shortDateFormat(selectedDate); const userAttendanceStatusList = async () => { const attendanceStatusData: AttendanceStatusListProps = { - limit: 0, + limit: 300, page: 0, filters: { fromDate: formatSelectedDate, diff --git a/src/pages/attendance-history.tsx b/src/pages/attendance-history.tsx index c095224f..341d551f 100644 --- a/src/pages/attendance-history.tsx +++ b/src/pages/attendance-history.tsx @@ -232,7 +232,7 @@ const UserAttendanceHistory = () => { setLoading(true); try { if (classId) { - let limit = 0; + let limit = 300; let page = 0; let filters = { cohortId: classId }; const response = await getMyCohortMemberList({ @@ -251,7 +251,7 @@ const UserAttendanceHistory = () => { if (nameUserIdArray && (selectedDate || currentDate)) { const userAttendanceStatusList = async () => { const attendanceStatusData: AttendanceStatusListProps = { - limit: 0, + limit: 300, page: 0, filters: { fromDate: shortDateFormat(selectedDate || currentDate), diff --git a/src/pages/attendance-overview.tsx b/src/pages/attendance-overview.tsx index 6c37541a..9fddae29 100644 --- a/src/pages/attendance-overview.tsx +++ b/src/pages/attendance-overview.tsx @@ -113,7 +113,7 @@ const AttendanceOverview: React.FC = () => { setLoading(true); try { if (classId) { - let limit = 0; + let limit = 300; let page = 0; let filters = { cohortId: classId }; const response = await getMyCohortMemberList({ @@ -313,6 +313,7 @@ const AttendanceOverview: React.FC = () => { value={classId} onChange={handleCohortSelection} displayEmpty + disabled = {cohortsData?.length == 1 ? true : false} inputProps={{ 'aria-label': 'Without label' }} className="SelectLanguages fs-14 fw-500" style={{ diff --git a/src/pages/dashboard.tsx b/src/pages/dashboard.tsx index 9f2a1d04..ff0f55ad 100644 --- a/src/pages/dashboard.tsx +++ b/src/pages/dashboard.tsx @@ -56,7 +56,6 @@ import useDeterminePathColor from '../hooks/useDeterminePathColor'; import { useRouter } from 'next/navigation'; import { useTheme } from '@mui/material/styles'; import { useTranslation } from 'next-i18next'; -import MarkBulkAttendance from '@/components/MarkBulkAttendance'; interface State extends SnackbarOrigin { openModal: boolean; @@ -166,7 +165,7 @@ const Dashboard: React.FC = () => { setLoading(true); try { if (classId) { - let limit = 0; + let limit = 300; let page = 0; let filters = { cohortId: classId }; const response = await getMyCohortMemberList({ @@ -185,7 +184,7 @@ const Dashboard: React.FC = () => { if (nameUserIdArray && (selectedDate || currentDate)) { const userAttendanceStatusList = async () => { const attendanceStatusData: AttendanceStatusListProps = { - limit: 0, + limit: 300, page: 0, filters: { fromDate: selectedDate || currentDate, @@ -316,8 +315,8 @@ const Dashboard: React.FC = () => { const fromDateFormatted = shortDateFormat(startDate); const toDateFormatted = shortDateFormat(endDate); const attendanceRequest: AttendancePercentageProps = { - limit: 2, - page: 1, + limit: 300, + page: 0, filters: { contextId: classId, fromDate: fromDateFormatted, @@ -527,6 +526,7 @@ const Dashboard: React.FC = () => { onChange={handleCohortSelection} displayEmpty inputProps={{ 'aria-label': 'Without label' }} + disabled = {cohortsData?.length == 1 ? true : false} className="SelectLanguages fs-14 fw-500" style={{ borderRadius: '0.5rem', @@ -891,7 +891,7 @@ const Dashboard: React.FC = () => { - + {/* = () => { }} /> - + */} )} diff --git a/src/pages/learner-profile/[userId].tsx b/src/pages/learner-profile/[userId].tsx index 43002bc2..a401611c 100644 --- a/src/pages/learner-profile/[userId].tsx +++ b/src/pages/learner-profile/[userId].tsx @@ -50,6 +50,8 @@ import { serverSideTranslations } from 'next-i18next/serverSideTranslations'; import { useParams } from 'next/navigation'; import { useRouter } from 'next/router'; import { useTranslation } from 'next-i18next'; +import { classesMissedAttendancePercentList } from '@/services/AttendanceService'; +import DateRangePopup from '@/components/DateRangePopup'; // import { UserData, updateCustomField } from '../utils/Interfaces'; @@ -69,17 +71,17 @@ const LearnerProfile: React.FC = () => { const theme = useTheme(); const router = useRouter(); - const { userId } = router.query; + const { userId }: any = router.query; const [userData, setUserData] = useState(null); - const [attendanceReport, setAttendanceReport] = useState(null); + // const [attendanceReport, setAttendanceReport] = useState(null); const [limit, setLimit] = useState(10); const [page, setPage] = useState(1); const [filter, setFilter] = useState({}); const [maritalStatus, setMaritalStatus] = useState(''); const [currentDate, setCurrentDate] = React.useState(getTodayDate); const [selectedIndex, setSelectedIndex] = useState(null); - const [selectedValue, setSelectedValue] = useState(''); + // const [selectedValue, setSelectedValue] = useState(''); const [assesmentData, setAssesmentData] = useState([]); const [questionData, setQuestionData] = useState([]); const [age, setAge] = React.useState(''); @@ -89,8 +91,21 @@ const LearnerProfile: React.FC = () => { const [customFieldsData, setCustomFieldsData] = useState( [] ); + interface OverallAttendance { + absent?: any; // Adjust the type according to your actual data + present?: any; + absent_percentage: any; + present_percentage: any; + // Add other properties as needed + } + const [isFromDate, setIsFromDate] = useState(getTodayDate()); + const [isToDate, setIsToDate] = useState(getTodayDate()); const [submittedOn, setSubmitedOn] = useState(); - + const [overallAttendance, setOverallAttendance] = + useState(); + const [selectedValue, setSelectedValue] = React.useState( + t('COMMON.AS_OF_TODAY') + ); const open = Boolean(anchorEl); const handleClick = (event: React.MouseEvent) => { // set""AnchorEl(event.currentTarget); @@ -104,13 +119,6 @@ const LearnerProfile: React.FC = () => { const handleOpenEdit = () => setOpenEdit(true); const handleCloseEdit = () => setOpenEdit(false); - // const handleListItemClick = ( - // event: React.MouseEvent, - // index: Number - // ) => { - // setSelectedIndex(index); - // }; - const [openModal, setOpenModal] = React.useState(false); const handleOpenModal = () => setOpenModal(true); const handleCloseModal = () => setOpenModal(false); @@ -142,20 +150,46 @@ const LearnerProfile: React.FC = () => { setSubject(event.target.value); }; - const handleMenuItemClick = (index: any, value: any) => { - setSelectedIndex(index); - setSelectedValue(value); - console.log('Selected Value:', value); // You can use this value as needed + const handleDateRangeSelected = ({ fromDate, toDate }: any) => { + console.log('Date Range Selected:', { fromDate, toDate }); + setIsFromDate(fromDate); + setIsToDate(toDate); + getAttendaceData(fromDate, toDate); + // Handle the date range values as needed }; - const menuItems = [ - 'Last 7 Days(18 - 25 may)', - 'As Of Today, 25 may', - 'Last Month', - 'Last 6 Month', - 'Custom Range', + t('COMMON.LAST_SEVEN_DAYS'), + t('COMMON.AS_OF_TODAY'), + t('COMMON.AS_OF_LAST_WEEK'), + t('COMMON.LAST_MONTH'), + t('COMMON.LAST_SIX_MONTHS'), + t('COMMON.CUSTOM_RANGE'), ]; + const getAttendaceData = async (fromDates: any, toDates: any) => { + console.log('dates', fromDates, toDates); + let fromDate = fromDates; + let toDate = toDates; + let filters = { + // contextId: classId, + fromDate, + toDate, + userId: userId, + // scope: 'student', + }; + const response = await classesMissedAttendancePercentList({ + filters, + facets: ['userId'], + }); + if (response?.statusCode === 200) { + console.log('response for userData', response?.data?.result); + const userData = response?.data.result.userId[userId]; + setOverallAttendance(userData); + + // if (setOverallAttendance) + } + }; + const fetchUserDetails = async () => { if (typeof window !== 'undefined' && window.localStorage) { const user: any = userId; @@ -190,7 +224,7 @@ const LearnerProfile: React.FC = () => { const testReportDetails = async () => { let filters = { - userId: '4bc64b4d-c3c6-4a23-b9f3-15c70ed8ffb6', + userId: userId, }; let pagination = { pageSize: 1, @@ -222,6 +256,7 @@ const LearnerProfile: React.FC = () => { totalScore: 0, length: data.length, questions: [], + totalQuestions: 0, }; data.forEach((item: any) => { @@ -247,10 +282,15 @@ const LearnerProfile: React.FC = () => { return questionValues; } - // Usage example + // questionValues const questionValues = getQuestionValues(assesmentData); useEffect(() => { + const today = new Date(); + const formatDate = (date: Date) => date.toISOString().split('T')[0]; + let toDay = formatDate(today); + + getAttendaceData(toDay, toDay); fetchUserDetails(); testReportDetails(); }, []); @@ -264,14 +304,15 @@ const LearnerProfile: React.FC = () => {
- + @@ -291,7 +332,9 @@ const LearnerProfile: React.FC = () => { fontSize: '12px', }} > - {userData?.district},{userData?.state} + {userData?.district && userData?.state + ? `${userData.district}, ${userData.state}` + : `${userData?.district || ''}${userData?.state || ''}`} @@ -323,7 +366,7 @@ const LearnerProfile: React.FC = () => { variant="h6" gutterBottom > - Attendance Overview + {t('ATTENDANCE.ATTENDANCE_OVERVIEW')} { variant="h6" gutterBottom > - View Day-Wise + {t('PROFILE.VIEW_DAY_WISE')} { - - - + { variant="h6" gutterBottom > - {'As of today' + ' ' + formatDate(currentDate)} + {selectedValue} { @@ -408,7 +441,7 @@ const LearnerProfile: React.FC = () => { @@ -433,7 +466,7 @@ const LearnerProfile: React.FC = () => { fontSize={'16px'} sx={{ color: theme.palette.warning.main }} > - Learner Details + {t('PROFILE.LEARNER_DETAILS')} - + */} ); }; + export async function getStaticProps({ locale }: any) { return { props: { diff --git a/src/pages/teacher-profile.tsx b/src/pages/teacher-profile.tsx index d76e85c5..9a5d39b7 100644 --- a/src/pages/teacher-profile.tsx +++ b/src/pages/teacher-profile.tsx @@ -58,17 +58,19 @@ const TeacherProfile = () => { const [gender, setGender] = React.useState(''); const [isAuthenticated, setIsAuthenticated] = React.useState(false); - const handleFieldChange = (fieldId: string, value: string, type: string) => { - const updatedFields: any = [...updatedCustomFields]; - const index = updatedFields.findIndex( - (field: any) => field.fieldId === fieldId - ); + const handleFieldChange = ( + fieldId: string, + value: string | string[], + type: string + ) => { + const updatedFields = [...updatedCustomFields]; + const index = updatedFields.findIndex((field) => field.fieldId === fieldId); if (index !== -1) { if (type === 'checkbox' && Array.isArray(value)) { updatedFields[index].values = value; } else { - updatedFields[index].value = value; + updatedFields[index].value = value as string; } updatedFields[index].type = type; } else { @@ -76,8 +78,8 @@ const TeacherProfile = () => { fieldId, type, ...(type === 'checkbox' && Array.isArray(value) - ? { value } - : { values: value }), + ? { values: value } + : { value: value as string }), }; updatedFields.push(newField); } @@ -88,22 +90,20 @@ const TeacherProfile = () => { const handleCheckboxChange = ( fieldId: string, optionName: string, - checked: any + checked: boolean ) => { - const existingField: any = updatedCustomFields?.find( + const existingField = updatedCustomFields.find( (field: any) => field.fieldId === fieldId ); - let updatedValues = []; + let updatedValues: string[] = []; - if (existingField) { - updatedValues = existingField.values || []; + if (existingField && Array.isArray(existingField.values)) { + updatedValues = [...existingField.values]; if (checked) { updatedValues.push(optionName); } else { - updatedValues = updatedValues.filter( - (value: any) => value !== optionName - ); + updatedValues = updatedValues.filter((value) => value !== optionName); } } else { if (checked) { @@ -226,6 +226,16 @@ const TeacherProfile = () => { setImage(newImageUrl); }; + const techSubjectsField = customFieldsData?.find( + (field) => field.label === 'Subjects I Teach' + ); + const mainSubjectsField = customFieldsData?.find( + (field) => field.label === 'My Main Subjects' + ); + + const techSubjects = techSubjectsField?.value?.split(', ') || []; + const mainSubjects = mainSubjectsField?.value?.split(', ') || []; + return ( { {userData?.name} - + {userData?.district || userData?.state ? ( + + ) : ( + '' + )} + - {userData?.district},{userData?.state} + {userData?.district && userData?.state + ? `${userData.district}, ${userData.state}` + : `${userData?.district || ''}${userData?.state || ''}`} @@ -344,18 +361,81 @@ const TeacherProfile = () => { {customFieldsData && customFieldsData?.map((item, i) => ( - - {/* question */} - - {item?.label} - - - {/* value */} - - {item?.value} - - + <> + {item?.label !== 'Subjects I Teach' && + item?.label !== 'My Main Subjects' ? ( + + {/* question */} + + {item?.label} + + + {/* value */} + + {item?.value} + + + ) : null} + ))} + + + + Subjects I Teach + + + + + {techSubjects?.map((subject, index) => ( + + ))} + {mainSubjects + .filter((subject) => !techSubjects.includes(subject)) + .map((subject, index) => ( + + + + ))} + + + + { handleFieldChange( field.fieldId, e.target.value, - field?.type + field.type ); }} /> @@ -489,32 +569,36 @@ const TeacherProfile = () => { margin={0} color={'#4D4639'} > - {field?.label} + {field.label} - {field?.options?.map((option: any) => ( - + {console.log( + 'updatedCustomFields Data ', + updatedCustomFields + )} + {field.options.map((option: any) => ( + f.fieldId === field.fieldId - ) - ?.values?.includes(option?.name) || false + )?.values || [] + ).includes(option.name) || false } onChange={(e) => handleCheckboxChange( field.fieldId, - option?.name, + option.name, e.target.checked ) } /> } - label={option?.name} + label={option.name} /> ))} @@ -523,13 +607,13 @@ const TeacherProfile = () => { - {field?.label} + {field.label} @@ -551,6 +632,7 @@ const TeacherProfile = () => { ) : null} ))} + diff --git a/src/utils/app.constant.ts b/src/utils/app.constant.ts new file mode 100644 index 00000000..5019d103 --- /dev/null +++ b/src/utils/app.constant.ts @@ -0,0 +1 @@ +export const limit:number = 300; \ No newline at end of file