diff --git a/.eslintrc.json b/.eslintrc.json index 97885eab..c7d4a5aa 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -19,6 +19,6 @@ } ], "prefer-const": "error", - "react-hooks/exhaustive-deps": "error" + "react-hooks/exhaustive-deps": "off" } } diff --git a/README.md b/README.md index 21761778..7aae359a 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ Shiksha is a next-generation scalable open-source learning solution for teachers This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app). ## new changes + ### Prerequisites diff --git a/app.config.ts b/app.config.ts index 922fc96c..966a9e65 100644 --- a/app.config.ts +++ b/app.config.ts @@ -49,4 +49,4 @@ export const fullWidthPages = [ '/500', '/offline', '/unauthorized', -]; \ No newline at end of file +]; diff --git a/public/locales/en/common.json b/public/locales/en/common.json index 3abe29f4..79c92d2e 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -201,7 +201,7 @@ "MY_PROFILE": "My Profile", "VIEW_MORE": "View More", "VIEW_LESS": "View Less", - "DATA_RANAGE": "Data Range", + "DATA_RANGE": "Data Range", "LEARNER_DETAILS": "Learner Details", "VIEW_DAY_WISE": "View Day-Wise", "SUBMITTED_ON": "Submitted On", @@ -266,8 +266,8 @@ "STEP_2": "Use the calendar to view day-wise attendance of learners", "STEP_3": "Check daily attendance percentage for each Center", "STEP_4": "Mark each day’s attendance of learners", - "STEP_5": "Check Center attendance over the last 7 days", - "STEP_6": "View learners with low attendance in the past 7 days", + "STEP_5": "Check Center attendance over the last {{numberOfDays}} days", + "STEP_6": "View learners with low attendance in the past {{numberOfDays}} days", "PREVIOUS": "Previous", "NEXT": "Next", "SKIP": "Skip", @@ -428,5 +428,10 @@ "MIN_LENGTH_CHARACTERS_ERROR": "Minimum {{minLength}} characters required", "MAX_LENGTH_CHARACTERS_ERROR": "Maximum {{maxLength}} characters allowed", "NUMBER_AND_SPECIAL_CHARACTERS_NOT_ALLOWED": "Numbers and special characters are not allowed" + }, + "COURSE_PLANNER": { + "COURSE_PLANNER": "Course Plan", + "FOUNDATION_COURSE": "Foundation Course", + "MAIN_COURSE": "Main Course" } } diff --git a/public/locales/hi/common.json b/public/locales/hi/common.json index ba4b171c..9f0bbfd1 100644 --- a/public/locales/hi/common.json +++ b/public/locales/hi/common.json @@ -178,7 +178,7 @@ "MY_PROFILE": "मेरी प्रोफ़ाइल", "VIEW_MORE": "अधिक देखें", "VIEW_LESS": "कम देखें", - "DATA_RANAGE": "डेटा रेंज़", + "DATA_RANGE": "डेटा रेंज़", "LEARNER_DETAILS": "विद्यार्थी विवरण", "VIEW_DAY_WISE": "दिन-वार देखें", "SUBMITTED_ON": "प्रस्तुत किया गया", @@ -243,8 +243,8 @@ "STEP_2": "शिक्षार्थियों की दिन-वार उपस्थिति देखने के लिए कैलेंडर का उपयोग करें", "STEP_3": "प्रत्येक केंद्र के लिए दैनिक उपस्थिति प्रतिशत की जाँच करें", "STEP_4": "शिक्षार्थियों की प्रत्येक दिन की उपस्थिति को चिह्नित करें", - "STEP_5": "पिछले 7 दिनों में केंद्र की उपस्थिति की जाँच करें", - "STEP_6": "पिछले 7 दिनों में कम उपस्थिति वाले शिक्षार्थियों को देखें", + "STEP_5": "पिछले {{numberOfDays}} दिनों में केंद्र की उपस्थिति की जाँच करें", + "STEP_6": "पिछले {{numberOfDays}} दिनों में कम उपस्थिति वाले शिक्षार्थियों को देखें", "PREVIOUS": "पिछला", "NEXT": "अगला", "SKIP": "छोड़ें", diff --git a/public/locales/mr/common.json b/public/locales/mr/common.json index 92149696..c931b20d 100644 --- a/public/locales/mr/common.json +++ b/public/locales/mr/common.json @@ -179,7 +179,7 @@ "MY_PROFILE": "माझी प्रोफाइल", "VIEW_MORE": "अधिक पाहा", "VIEW_LESS": "कमी करा", - "DATA_RANAGE": "डेटा श्रेणी", + "DATA_RANGE": "डेटा श्रेणी", "LEARNER_DETAILS": "विद्यार्थी तपशील", "VIEW_DAY_WISE": "दिवस-निहाय पहा", "SUBMITTED_ON": "सादर केले", @@ -243,8 +243,8 @@ "STEP_2": "शिक्षार्थ्यांची दिवसवार उपस्थिती पाहण्यासाठी कॅलेंडर वापरा", "STEP_3": "प्रत्येक केंद्रासाठी दैनंदिन उपस्थिती टक्केवारी तपासा", "STEP_4": "शिक्षार्थ्यांची प्रत्येक दिवसाची उपस्थिती चिन्हांकित करा", - "STEP_5": "शेवटच्या 7 दिवसांत केंद्राची उपस्थिती तपासा", - "STEP_6": "शेवटच्या 7 दिवसांत कमी उपस्थिती असलेले शिक्षार्थी पहा", + "STEP_5": "शेवटच्या {{numberOfDays}} दिवसांत केंद्राची उपस्थिती तपासा", + "STEP_6": "शेवटच्या {{numberOfDays}} दिवसांत कमी उपस्थिती असलेले शिक्षार्थी पहा", "PREVIOUS": "मागील", "NEXT": "पुढे", "SKIP": "वगळा", diff --git a/public/locales/or/common.json b/public/locales/or/common.json index eee54348..0078534b 100644 --- a/public/locales/or/common.json +++ b/public/locales/or/common.json @@ -103,7 +103,7 @@ "AS_OF_TODAY_DATE": "ଆଜି ଅନୁସାରେ {{day_date}}", "LEARNER": "ଶିକ୍ଷାର୍ଥୀ", "ATTENDANCE_COMPARISON": "ଉପସ୍ଥିତି ତୁଳନ", - "CENTER_TYPE":"କେନ୍ଦ୍ର ପ୍ରକାର", + "CENTER_TYPE": "କେନ୍ଦ୍ର ପ୍ରକାର", "BLOCK_AVERAGE_ATTENDANCE": "ବ୍ଲକ ହାରାହାର ଉପସ୍ଥିତି" }, "ATTENDANCE": { @@ -151,7 +151,7 @@ "MY_PROFILE": "ମୋ ପ୍ରୋଫାଇଲ", "VIEW_MORE": "ଅଧିକ ଦେଖନ୍ତୁ", "VIEW_LESS": "କମ୍ ଦେଖନ୍ତୁ", - "DATA_RANAGE": "ଡାଟା ରେଞ୍ଜ", + "DATA_RANGE": "ଡାଟା ରେଞ୍ଜ", "LEARNER_DETAILS": "ଶିକ୍ଷାର୍ଥୀ ବିବରଣୀ", "VIEW_DAY_WISE": "ଦିନ-ଅନୁସାରେ ବିବରଣୀ ଦେଖନ୍ତୁ", "SUBMITTED_ON": "ସବ୍ମିଟ୍/ଦାଖଲ କରାଯାଇଛି", @@ -220,12 +220,10 @@ "REQUEST_TO_DELETE": "ହଟାଇବାକୁ ଅନୁରୋଧ", "RENAME": "ପୁନ ame ନାମ କରନ୍ତୁ", "CENTER_RENAMED": "କେନ୍ଦ୍ରର ନାମ ସଫଳତାର ସହ ଚାଲିଛି!", - "SEND_REQUEST":"ଅନୁରୋଧ ପଠାନ୍ତୁ", + "SEND_REQUEST": "ଅନୁରୋଧ ପଠାନ୍ତୁ", "REQUEST_TO_DELETE_HAS_BEEN_SENT": "ହଟାଇବାକୁ ଅନୁରୋଧ ପଠାଯାଇଛି", "YOU_ARE_SENDING_REQUEST_TO_THE_STATE_ADMIN": "ଆପଣ ଏହି କେନ୍ଦ୍ରଟିକୁ ବିଲୋପ କରିବା ପାଇଁ ରାଜ୍ୟ ପ୍ରଶାସନକୁ ଅନୁରୋଧ ପଠାଉଛନ୍ତି", "THE_USER_BELONGS_TO_THE_FOLLOWING_COHORT": "ୟୁଜର ନିମ୍ନଲିଖିତ ସମୁହର ସଦସ୍ୟ: ", "PLEASE_REMOVE_THE_USER_FROM_COHORT": "ଦୟାକରି ହଟାଇବା ପୂର୍ବରୁ ୟୁଜରକୁ ଏହି ସମୁହଗୁଡିକରୁ କାଢ଼ି ଦିଅନ୍ତୁ।" - - } } - +} diff --git a/src/components/AddFacilitator.tsx b/src/components/AddFacilitator.tsx index d67fb6b6..16e57a82 100644 --- a/src/components/AddFacilitator.tsx +++ b/src/components/AddFacilitator.tsx @@ -1,23 +1,18 @@ -import { FormContext, FormContextType } from '@/utils/app.constant'; import { GenerateSchemaAndUiSchema, customFields, } from '@/components/GeneratedSchemas'; +import { FormContext, FormContextType, RoleId } from '@/utils/app.constant'; import React, { useEffect } from 'react'; -import { Box } from '@mui/material'; import DynamicForm from '@/components/DynamicForm'; -import { Field } from '@/utils/Interfaces'; -import { FormData } from '@/utils/Interfaces'; -import { IChangeEvent } from '@rjsf/core'; -import ISubmitEvent from '@rjsf/core'; -import { RJSFSchema } from '@rjsf/utils'; import SendCredentialModal from '@/components/SendCredentialModal'; -import { serverSideTranslations } from 'next-i18next/serverSideTranslations'; -import { createUser, getFormRead } from '@/services/CreateUserService'; -import { RoleId } from '@/utils/app.constant'; import SimpleModal from '@/components/SimpleModal'; +import { createUser, getFormRead } from '@/services/CreateUserService'; import { generateUsernameAndPassword } from '@/utils/Helper'; +import { Field, FormData } from '@/utils/Interfaces'; +import { IChangeEvent } from '@rjsf/core'; +import { RJSFSchema } from '@rjsf/utils'; import { useTranslation } from 'next-i18next'; interface AddFacilitatorModalprops { @@ -41,10 +36,11 @@ const AddFacilitatorModal: React.FC = ({ FormContextType.TEACHER ); console.log('sortedFields', response); + let centerOptionsList; if (typeof window !== 'undefined' && window.localStorage) { const CenterList = localStorage.getItem('CenterList'); const centerOptions = CenterList ? JSON.parse(CenterList) : []; - var centerOptionsList = centerOptions.map( + centerOptionsList = centerOptions.map( (center: { cohortId: string; cohortName: string }) => ({ value: center.cohortId, label: center.cohortName, @@ -114,7 +110,7 @@ const AddFacilitatorModal: React.FC = ({ const { username, password } = generateUsernameAndPassword('MH', 'F'); - let apiBody: any = { + const apiBody: any = { username: username, password: password, tenantCohortRoleMapping: [ @@ -138,27 +134,25 @@ const AddFacilitatorModal: React.FC = ({ if (typeof fieldValue !== 'object') { apiBody[fieldKey] = fieldValue; } + } else if ( + Object.hasOwn(fieldSchema, 'isDropdown') || + Object.hasOwn(fieldSchema, 'isCheckbox') + ) { + apiBody.customFields.push({ + fieldId: fieldId, + value: [String(fieldValue)], + }); } else { - if ( - fieldSchema?.hasOwnProperty('isDropdown') || - fieldSchema.hasOwnProperty('isCheckbox') - ) { - apiBody.customFields.push({ - fieldId: fieldId, - value: [String(fieldValue)], - }); - } else { - apiBody.customFields.push({ - fieldId: fieldId, - value: String(fieldValue), - }); - } + apiBody.customFields.push({ + fieldId: fieldId, + value: String(fieldValue), + }); } }); if (typeof window !== 'undefined' && window.localStorage) { - var teamLeaderData = JSON.parse( - localStorage.getItem('teamLeadApp') || '' + const teamLeaderData = JSON.parse( + localStorage.getItem('teamLeadApp') ?? '' ); console.log(teamLeaderData); } diff --git a/src/components/AddLeanerModal.tsx b/src/components/AddLeanerModal.tsx index 47538b15..4c76e208 100644 --- a/src/components/AddLeanerModal.tsx +++ b/src/components/AddLeanerModal.tsx @@ -1,22 +1,18 @@ import DynamicForm from '@/components/DynamicForm'; -import React, { useEffect } from 'react'; import { GenerateSchemaAndUiSchema, customFields, } from '@/components/GeneratedSchemas'; -import { IChangeEvent } from '@rjsf/core'; -import ISubmitEvent from '@rjsf/core'; -import { Box, Button, useTheme } from '@mui/material'; -import { RJSFSchema } from '@rjsf/utils'; -import SendCredentialModal from '@/components/SendCredentialModal'; -import { serverSideTranslations } from 'next-i18next/serverSideTranslations'; +import SimpleModal from '@/components/SimpleModal'; import { createUser, getFormRead } from '@/services/CreateUserService'; +import { generateUsernameAndPassword } from '@/utils/Helper'; import { FormData } from '@/utils/Interfaces'; -import { FormContext, FormContextType } from '@/utils/app.constant'; -import SimpleModal from '@/components/SimpleModal'; +import { FormContext, FormContextType, RoleId } from '@/utils/app.constant'; +import { Button, useTheme } from '@mui/material'; +import { IChangeEvent } from '@rjsf/core'; +import { RJSFSchema } from '@rjsf/utils'; +import React, { useEffect } from 'react'; import { useTranslation } from 'react-i18next'; -import { generateUsernameAndPassword } from '@/utils/Helper'; -import { RoleId } from '@/utils/app.constant'; import { showToastMessage } from './Toastify'; interface AddLearnerModalProps { @@ -85,18 +81,18 @@ const AddLearnerModal: React.FC = ({ const formData = data.formData; console.log('Form data submitted:', formData); const schemaProperties = schema.properties; - let cohortId; + let cohortId, teacherData; if (typeof window !== 'undefined' && window.localStorage) { - var teacherData = JSON.parse(localStorage.getItem('teacherApp') || ''); + teacherData = JSON.parse(localStorage.getItem('teacherApp') ?? ''); cohortId = - localStorage.getItem('cohortId') || localStorage.getItem('classId'); + localStorage.getItem('cohortId') ?? localStorage.getItem('classId'); } const { username, password } = generateUsernameAndPassword( teacherData?.state?.stateCode, '' ); - let apiBody: any = { + const apiBody: any = { username: username, password: password, tenantCohortRoleMapping: [ @@ -120,21 +116,19 @@ const AddLearnerModal: React.FC = ({ if (typeof fieldValue !== 'object') { apiBody[fieldKey] = fieldValue; } + } else if ( + Object.hasOwn(fieldSchema, 'isDropdown') || + Object.hasOwn(fieldSchema, 'isCheckbox') + ) { + apiBody.customFields.push({ + fieldId: fieldId, + value: [String(fieldValue)], + }); } else { - if ( - fieldSchema?.hasOwnProperty('isDropdown') || - fieldSchema.hasOwnProperty('isCheckbox') - ) { - apiBody.customFields.push({ - fieldId: fieldId, - value: [String(fieldValue)], - }); - } else { - apiBody.customFields.push({ - fieldId: fieldId, - value: String(fieldValue), - }); - } + apiBody.customFields.push({ + fieldId: fieldId, + value: String(fieldValue), + }); } }); @@ -184,42 +178,40 @@ const AddLearnerModal: React.FC = ({ justifyContent: 'space-between', }} > - <> - - - + + ); @@ -240,29 +232,27 @@ const AddLearnerModal: React.FC = ({ }; return ( - <> - - {schema && uiSchema && ( - - {/* */} - - )} - - + + {schema && uiSchema && ( + + {/* */} + + )} + ); }; diff --git a/src/components/AttendanceStatusListView.tsx b/src/components/AttendanceStatusListView.tsx index 6f4045e5..a7bf2ca0 100644 --- a/src/components/AttendanceStatusListView.tsx +++ b/src/components/AttendanceStatusListView.tsx @@ -1,25 +1,23 @@ +import { Box, Typography } from '@mui/material'; +import React, { useState } from 'react'; import { AttendanceStatusListViewProps, - UserData, - updateCustomField, + UpdateCustomField, } from '../utils/Interfaces'; -import { Box, Typography } from '@mui/material'; -import React, { useState } from 'react'; -import { ATTENDANCE_ENUM } from '../utils/Helper'; -import { BorderBottom } from '@mui/icons-material'; +import { getUserDetails } from '@/services/ProfileService'; +import { Status, names } from '@/utils/app.constant'; import CancelIcon from '@mui/icons-material/Cancel'; //absent import CheckCircleIcon from '@mui/icons-material/CheckCircle'; //present import CheckCircleOutlineIcon from '@mui/icons-material/CheckCircleOutline'; import HighlightOffIcon from '@mui/icons-material/HighlightOff'; -import LearnerModal from './LearnerModal'; -import Link from 'next/link'; -import Loader from './Loader'; -import { getUserDetails } from '@/services/ProfileService'; import { useTheme } from '@mui/material/styles'; import { useTranslation } from 'next-i18next'; +import Link from 'next/link'; +import { ATTENDANCE_ENUM } from '../utils/Helper'; import DropoutLabel from './DropoutLabel'; -import { Status, names } from '@/utils/app.constant'; +import LearnerModal from './LearnerModal'; +import Loader from './Loader'; const AttendanceStatusListView: React.FC = ({ isDisabled = false, @@ -40,7 +38,7 @@ const AttendanceStatusListView: React.FC = ({ height: isBulkAction ? '56px' : '', // width: '100%', // borderBottom: `0.5px solid ${theme.palette.warning[400]}`, - padding: isBulkAction ? '0 8px' : '0 8px', + padding: '0 8px', alignItems: 'center', borderRadius: isBulkAction ? '8px' : 0, // marginBottom: '12px', @@ -61,15 +59,13 @@ const AttendanceStatusListView: React.FC = ({ }; // -----learner profile details---- - const [usersData, setUsersData] = React.useState(null); const [customFieldsData, setCustomFieldsData] = React.useState< - updateCustomField[] + UpdateCustomField[] >([]); const [contactNumber, setContactNumber] = useState(''); const [userName, setUserName] = React.useState(''); const [isModalOpenLearner, setIsModalOpenLearner] = useState(false); const [loading, setLoading] = useState(false); - // const userId = '12345'; // Replace with the actual user ID you want to pass const handleOpenModalLearner = (userId: string) => { if (!showLink) { @@ -93,7 +89,6 @@ const AttendanceStatusListView: React.FC = ({ const data = response?.result; if (data) { const userData = data?.userData; - // setUsersData(userData); setUserName(userData?.name); setContactNumber(userData?.mobile); const customDataFields = userData?.customFields; @@ -181,9 +176,7 @@ const AttendanceStatusListView: React.FC = ({ ) : ( @@ -263,9 +256,7 @@ const AttendanceStatusListView: React.FC = ({ ) : ( diff --git a/src/components/BottomDrawer.tsx b/src/components/BottomDrawer.tsx index a44e3210..cb344164 100644 --- a/src/components/BottomDrawer.tsx +++ b/src/components/BottomDrawer.tsx @@ -42,7 +42,6 @@ const BottomDrawer: React.FC = ({ sx={{ width: 'auto', }} - role="presentation" > = ({ {renderCustomContent?.()} {children} - {optionList.map(({ label, icon, name }, index) => ( - + {optionList.map(({ label, icon, name }) => ( + = ({ const extractNamesAndCohortTypes = ( data: ChildData[] ): NameTypePair[] => { - let nameTypePairs: NameTypePair[] = []; - + const nameTypePairs: NameTypePair[] = []; const recursiveExtract = (items: ChildData[]) => { items.forEach((item) => { const cohortType = item?.customField?.find( (field) => field.label === 'TYPE_OF_COHORT' )?.value || 'Unknown'; - if (item?.cohortId && item && item?.name) { + if (item?.cohortId && item?.name) { nameTypePairs.push({ cohortId: item?.cohortId, name: item?.name, @@ -133,7 +132,7 @@ const CohortSelectionSection: React.FC = ({ return nameTypePairs; }; - if (response && response?.length > 0) { + if (response?.length > 0) { const nameTypePairs = extractNamesAndCohortTypes(response); setCohorts(nameTypePairs); } @@ -292,6 +291,7 @@ const CohortSelectionSection: React.FC = ({ fontWeight: '500', fontSize: '14px', color: '#4D4639', + textTransform: 'capitalize', }} > {cohort.name} @@ -350,9 +350,10 @@ const CohortSelectionSection: React.FC = ({ fontWeight: '500', fontSize: '14px', color: '#4D4639', + textTransform: 'capitalize', }} > - {cohort.name} + {cohort?.name} )) ) : ( diff --git a/src/components/DateRangePopup.tsx b/src/components/DateRangePopup.tsx index 46c5d333..9ea6d4ce 100644 --- a/src/components/DateRangePopup.tsx +++ b/src/components/DateRangePopup.tsx @@ -1,3 +1,4 @@ +import { getDayAndMonthName, getTodayDate } from '@/utils/Helper'; import { Box, Button, @@ -8,23 +9,20 @@ import { MenuList, Modal, Select, - Typography, - useStepContext, + Typography } from '@mui/material'; import React, { useEffect, useState } from 'react'; -import { getDayAndMonthName, getTodayDate } from '@/utils/Helper'; +import useStore from '@/store/store'; import CloseIcon from '@mui/icons-material/Close'; -import { Height } from '@mui/icons-material'; -import Image from 'next/image'; -import ListItemIcon from '@mui/material/ListItemIcon'; -import MonthCalender from './MonthCalender'; -import ReactGA from 'react-ga4'; import WestIcon from '@mui/icons-material/West'; -import checkMark from '../assets/images/checkMark.svg'; -import useStore from '@/store/store'; +import ListItemIcon from '@mui/material/ListItemIcon'; import { useTheme } from '@mui/material/styles'; import { useTranslation } from 'next-i18next'; +import Image from 'next/image'; +import ReactGA from 'react-ga4'; +import checkMark from '../assets/images/checkMark.svg'; +import MonthCalender from './MonthCalender'; const modalStyle = { position: 'absolute', diff --git a/src/components/DeleteSession.tsx b/src/components/DeleteSession.tsx index fb33889f..1528afd4 100644 --- a/src/components/DeleteSession.tsx +++ b/src/components/DeleteSession.tsx @@ -1,10 +1,7 @@ import { Box, - FormControl, - FormControlLabel, - FormLabel, Radio, - RadioGroup, + RadioGroup } from '@mui/material'; import React, { useState } from 'react'; @@ -21,7 +18,6 @@ const DeleteSession = () => { }; return ( - <> { - ); }; diff --git a/src/components/GeneratedSchemas.ts b/src/components/GeneratedSchemas.ts index 3339c6c0..1435e3e7 100644 --- a/src/components/GeneratedSchemas.ts +++ b/src/components/GeneratedSchemas.ts @@ -1,7 +1,7 @@ +import { Field, FieldOption, FormData } from '@/utils/Interfaces'; import { UiSchema } from '@rjsf/utils'; import { JSONSchema7 } from 'json-schema'; import NumberInputField from './form/NumberInputField'; -import { FormData, Field, FieldOption } from '@/utils/Interfaces'; export const customFields = { NumberInputField: NumberInputField, @@ -134,7 +134,7 @@ export const GenerateSchemaAndUiSchema = ( // fieldUiSchema['ui:widget'] = 'select'; // } - if (isMultiSelect && type === 'drop_down') { + if (isMultiSelect && type === 'drop_down' && maxSelections !== 1) { fieldSchema.type = 'array'; fieldSchema.items = { type: 'string', @@ -149,7 +149,24 @@ export const GenerateSchemaAndUiSchema = ( if (maxSelections) { fieldSchema.maxItems = maxSelections; } - fieldUiSchema['ui:widget'] = 'MultiSelectDropdown'; + if (maxSelections === 1) { + fieldUiSchema['ui:widget'] = 'select'; + } else { + fieldUiSchema['ui:widget'] = 'MultiSelectDropdown'; + } + } + + if (isMultiSelect && maxSelections === 1 && type === 'drop_down') { + fieldSchema.type = 'string'; + fieldSchema.isDropdown = true; + fieldSchema.oneOf = options.map((opt: FieldOption) => ({ + const: opt.value, + title: + t(`FORM.${opt.label}`) === `FORM.${opt.label}` + ? opt.label + : t(`FORM.${opt.label}`), + })); + fieldUiSchema['ui:widget'] = 'select'; } if (!isMultiSelect && type === 'drop_down') { diff --git a/src/components/LearnerAttendanceStatsListView.tsx b/src/components/LearnerAttendanceStatsListView.tsx index 3a4f1491..4ecf8e73 100644 --- a/src/components/LearnerAttendanceStatsListView.tsx +++ b/src/components/LearnerAttendanceStatsListView.tsx @@ -1,7 +1,7 @@ -import { Box, Grid, Stack, Typography, useMediaQuery } from '@mui/material'; +import { Box, Grid, Stack, Typography } from '@mui/material'; import React, { useState } from 'react'; import { Status, names } from '@/utils/app.constant'; -import { UserData, updateCustomField } from '@/utils/Interfaces'; +import { UserData, UpdateCustomField } from '@/utils/Interfaces'; import DropoutLabel from './DropoutLabel'; import LearnerModal from './LearnerModal'; @@ -41,7 +41,7 @@ const StudentsStatsList: React.FC = ({ const [userData, setUserData] = React.useState(null); const [customFieldsData, setCustomFieldsData] = React.useState< - updateCustomField[] + UpdateCustomField[] >([]); const [contactNumber, setContactNumber] = useState(''); const [userName, setUserName] = React.useState(''); @@ -144,36 +144,34 @@ const StudentsStatsList: React.FC = ({ {memberStatus === Status.DROPOUT ? ( - <> - - - - - {presentPercent}% - - - - - {classesMissed} - - + + + + + {presentPercent}% + + + + + {classesMissed} + - - + + ) : ( <> diff --git a/src/components/LearnerModal.tsx b/src/components/LearnerModal.tsx index 9e72debf..275793cc 100644 --- a/src/components/LearnerModal.tsx +++ b/src/components/LearnerModal.tsx @@ -170,7 +170,7 @@ const LearnerModal = ({ ? toPascalCase(item.displayValue.join(', ')) : item?.displayValue ? toPascalCase(item.displayValue) - : "-"} + : '-'} {/* */} @@ -198,7 +198,7 @@ const LearnerModal = ({ whiteSpace: 'normal', }} > - {contactNumber ? contactNumber : "-"} + {contactNumber ? contactNumber : '-'} diff --git a/src/components/LearnersListItem.tsx b/src/components/LearnersListItem.tsx index a9642447..48aa2c1f 100644 --- a/src/components/LearnersListItem.tsx +++ b/src/components/LearnersListItem.tsx @@ -2,7 +2,7 @@ import { Box, Typography } from '@mui/material'; import { LearnerListProps, UserData, - updateCustomField, + UpdateCustomField, } from '@/utils/Interfaces'; import React, { useEffect } from 'react'; import { Status, names, Role } from '@/utils/app.constant'; @@ -69,7 +69,7 @@ const LearnersListItem: React.FC = ({ userData: null as UserData | null, userName: '', contactNumber: '', - customFieldsData: [] as updateCustomField[], + customFieldsData: [] as UpdateCustomField[], }); const userStore = useStore(); const theme = useTheme(); @@ -78,7 +78,7 @@ const LearnersListItem: React.FC = ({ const { t } = useTranslation(); const [openCentersModal, setOpenCentersModal] = React.useState(false); const [openDeleteUserModal, setOpenDeleteUserModal] = React.useState(false); -const [centers, setCenters] = React.useState(); + const [centers, setCenters] = React.useState(); const store = manageUserStore(); const CustomLink = styled(Link)(({ theme }) => ({ @@ -95,10 +95,9 @@ const [centers, setCenters] = React.useState(); setReloadState(false); // window.location.reload(); } - const cohorts = userStore.cohorts - const centerList = cohorts.map((cohort: { name: string; }) => cohort.name); - setCenters(centerList); - + const cohorts = userStore.cohorts; + const centerList = cohorts.map((cohort: { name: string }) => cohort.name); + setCenters(centerList); }, [reloadState, setReloadState]); const toggleDrawer = @@ -141,7 +140,7 @@ const [centers, setCenters] = React.useState(); setLearnerState((prevState) => ({ ...prevState, contactNumber: number })); }; - const setCustomFieldsData = (fields: updateCustomField[]) => { + const setCustomFieldsData = (fields: UpdateCustomField[]) => { setLearnerState((prevState) => ({ ...prevState, customFieldsData: fields, @@ -300,7 +299,7 @@ const [centers, setCenters] = React.useState(); acc.push(field); } return acc; - }, [] as updateCustomField[]); + }, [] as UpdateCustomField[]); const getTeamLeadersCenters = async () => {}; diff --git a/src/components/ManageUser.tsx b/src/components/ManageUser.tsx index bc8cae9d..40fa092a 100644 --- a/src/components/ManageUser.tsx +++ b/src/components/ManageUser.tsx @@ -1,52 +1,37 @@ -import React, { useState } from 'react'; import { Button, - FormControl, Grid, - MenuItem, - Select, - TextField, - Typography, + Typography } from '@mui/material'; +import React, { useState } from 'react'; -import Box from '@mui/material/Box'; -import Header from '@/components/Header'; -import InputAdornment from '@mui/material/InputAdornment'; +import BottomDrawer from '@/components/BottomDrawer'; +import ConfirmationModal from '@/components/ConfirmationModal'; import ManageCentersModal from '@/components/ManageCentersModal'; import ManageUsersModal from '@/components/ManageUsersModal'; -import MoreVertIcon from '@mui/icons-material/MoreVert'; -import SearchIcon from '@mui/icons-material/Search'; -import Tab from '@mui/material/Tab'; -import Tabs from '@mui/material/Tabs'; -import { serverSideTranslations } from 'next-i18next/serverSideTranslations'; -import { useRouter } from 'next/router'; -import { useTheme } from '@mui/material/styles'; -import { useTranslation } from 'next-i18next'; -import { useEffect } from 'react'; -import { assignCentersToFacilitator } from '@/services/ManageUser'; -import { cohortList, getCohortList } from '@/services/CohortServices'; import { showToastMessage } from '@/components/Toastify'; -import BottomDrawer from '@/components/BottomDrawer'; -import ApartmentIcon from '@mui/icons-material/Apartment'; +import { cohortList, getCohortList } from '@/services/CohortServices'; +import { Role } from '@/utils/app.constant'; +import AddIcon from '@mui/icons-material/Add'; import DeleteOutlineIcon from '@mui/icons-material/DeleteOutline'; import LocationOnOutlinedIcon from '@mui/icons-material/LocationOnOutlined'; -import { editEditUser } from '@/services/ProfileService'; -import ConfirmationModal from '@/components/ConfirmationModal'; -import { Role, Status } from '@/utils/app.constant'; -import AddIcon from '@mui/icons-material/Add'; -import LearnersList from '@/components/LearnersListItem'; -import Link from 'next/link'; +import MoreVertIcon from '@mui/icons-material/MoreVert'; +import Box from '@mui/material/Box'; +import { useTheme } from '@mui/material/styles'; import { styled } from '@mui/system'; +import { useTranslation } from 'next-i18next'; +import Link from 'next/link'; +import { useRouter } from 'next/router'; +import { useEffect } from 'react'; import manageUserStore from '../store/manageUserStore'; import { getMyUserList } from '@/services/MyClassDetailsService'; -import DeleteUserModal from './DeleteUserModal'; import Image from 'next/image'; import profileALT from '../assets/images/Profile.png'; -import RemoveFacilitatorAlert from './SimpleModal'; -import SimpleModal from './SimpleModal'; import AddFacilitatorModal from './AddFacilitator'; import ReassignModal from './ReassignModal'; +import DeleteUserModal from './DeleteUserModal'; +import SimpleModal from './SimpleModal'; interface Cohort { cohortId: string; diff --git a/src/components/MenuDrawer.tsx b/src/components/MenuDrawer.tsx index 51d44af7..6cf7c4df 100644 --- a/src/components/MenuDrawer.tsx +++ b/src/components/MenuDrawer.tsx @@ -20,6 +20,7 @@ import { Role } from '@/utils/app.constant'; import useStore from '@/store/store'; import { accessGranted } from '@/utils/Helper'; import { accessControl } from '../../app.config'; +import EventAvailableOutlinedIcon from '@mui/icons-material/EventAvailableOutlined'; interface DrawerProps { toggleDrawer: (open: boolean) => () => void; open: boolean; @@ -76,6 +77,7 @@ const MenuDrawer: React.FC = ({ const isDashboard = router.pathname === '/dashboard'; const isTeacherCenter = router.pathname === '/centers'; + const isCoursePlanner = router.pathname === '/course-planner'; // const isManageUser = router.pathname === '/manageUser'; return ( @@ -249,6 +251,41 @@ const MenuDrawer: React.FC = ({ {t('COMMON.OBSERVATIONS_FORMS')} + + + + + {/* - + + diff --git a/src/components/center/RenameCenterModal.tsx b/src/components/center/RenameCenterModal.tsx index 7204a65a..fcf2c14f 100644 --- a/src/components/center/RenameCenterModal.tsx +++ b/src/components/center/RenameCenterModal.tsx @@ -1,26 +1,21 @@ -import React, { useState } from 'react'; +import { renameFacilitator } from '@/services/ManageUser'; +import CloseIcon from '@mui/icons-material/Close'; import { Box, - Typography, - TextField, Button, - Modal, - Fade, Divider, + Fade, IconButton, + Modal, Radio, - RadioGroup, - FormControlLabel, - FormControl, - FormLabel, + TextField, + Typography } from '@mui/material'; -import CloseIcon from '@mui/icons-material/Close'; +import { styled, useTheme } from '@mui/material/styles'; import { useTranslation } from 'next-i18next'; -import { serverSideTranslations } from 'next-i18next/serverSideTranslations'; -import { useTheme, styled } from '@mui/material/styles'; -import { showToastMessage } from '../Toastify'; -import { renameFacilitator } from '@/services/ManageUser'; import { useRouter } from 'next/router'; +import React, { useState } from 'react'; +import { showToastMessage } from '../Toastify'; interface CreateBlockModalProps { open: boolean; diff --git a/src/components/form/NumberInputField.tsx b/src/components/form/NumberInputField.tsx index 59467dc0..412f66c2 100644 --- a/src/components/form/NumberInputField.tsx +++ b/src/components/form/NumberInputField.tsx @@ -1,23 +1,23 @@ import { TextField, useTheme } from '@mui/material'; -import React, { useState } from 'react'; - +import { useState } from 'react'; const NumberInputField = (props: any) => { - const theme = useTheme(); const { onChange, ...rest } = props; - - const [error, setError] = useState(""); + const [error, setError] = useState(''); console.log('NumberInputField', props); const handleChange = (event: any) => { const value = event.target.value; - const regex = props?.schema?.maxLength ? new RegExp(`^\\d{0,${props.schema.maxLength}}$`) : /^\d*$/; + const regex = props?.schema?.maxLength + ? new RegExp(`^\\d{0,${props.schema.maxLength}}$`) + : /^\d*$/; - if (regex.test(value)) { // Allow only up to 10 digits - if (props?.schema?.maxLength ) { + if (regex.test(value)) { + // Allow only up to 10 digits + if (props?.schema?.maxLength) { if (value.length === props.schema.maxLength) { - setError(""); // Clear any existing error + setError(''); // Clear any existing error onChange(Number(value)); } else { setError(`Must be exactly ${props.schema.maxLength} digits`); @@ -34,18 +34,18 @@ const NumberInputField = (props: any) => { // onChange={handleChange} // /> <> - -

{error}

- +

{error}

+ ); }; diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index c4712022..137c1c15 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -5,7 +5,7 @@ import 'react-toastify/dist/ReactToastify.css'; import * as React from 'react'; -import { Button, Container } from '@mui/material'; +import { Button } from '@mui/material'; import { Experimental_CssVarsProvider as CssVarsProvider, useColorScheme, @@ -14,21 +14,21 @@ import { import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; import { initGA, logPageView } from '../utils/googleAnalytics'; -import type { AppProps } from 'next/app'; -import Box from '@mui/material/Box'; import Brightness4Icon from '@mui/icons-material/Brightness4'; import Brightness7Icon from '@mui/icons-material/Brightness7'; -import Head from 'next/head'; +import Box from '@mui/material/Box'; import IconButton from '@mui/material/IconButton'; -import { Poppins } from 'next/font/google'; -import { ToastContainer } from 'react-toastify'; import { UserConfig, appWithTranslation } from 'next-i18next'; -import customTheme from '../styles/customTheme'; -import { telemetryFactory } from '../utils/telemetry'; -import { useEffect } from 'react'; +import type { AppProps } from 'next/app'; +import { Poppins } from 'next/font/google'; +import Head from 'next/head'; import { useRouter } from 'next/router'; +import { useEffect } from 'react'; +import { ToastContainer } from 'react-toastify'; import { fullWidthPages } from '../../app.config'; import nextI18NextConfig from '../../next-i18next.config.js'; +import customTheme from '../styles/customTheme'; +import { telemetryFactory } from '../utils/telemetry'; const queryClient = new QueryClient(); const ColorModeContext = React.createContext({ toggleColorMode: () => {} }); @@ -70,7 +70,7 @@ export function DarkTheme() { function App({ Component, pageProps }: AppProps) { const router = useRouter(); - const isFullWidthPage = fullWidthPages.includes(router.pathname); + const isFullWidthPage = fullWidthPages.includes(router.pathname); useEffect(() => { telemetryFactory.init(); }, []); @@ -148,7 +148,7 @@ function App({ Component, pageProps }: AppProps) { width: !isFullWidthPage ? 'calc(100% - 22rem)' : '100%', marginLeft: !isFullWidthPage ? '351px' : '0', }, - '@media (min-width: 1600px)': { + '@media (min-width: 2000px)': { width: '100%', marginLeft: !isFullWidthPage ? '351px' : '0', }, diff --git a/src/pages/attendance-history.tsx b/src/pages/attendance-history.tsx index 92eb1bc3..93d2c4f4 100644 --- a/src/pages/attendance-history.tsx +++ b/src/pages/attendance-history.tsx @@ -1,9 +1,10 @@ import { - AttendanceParams, - AttendancePercentageProps, - AttendanceStatusListProps, - cohort, -} from '../utils/Interfaces'; + debounce, + getTodayDate, + handleKeyDown, + shortDateFormat, + toPascalCase, +} from '@/utils/Helper'; import { Box, Button, @@ -16,41 +17,40 @@ import { } from '@mui/material'; import React, { useEffect, useRef, useState } from 'react'; import { - debounce, - getTodayDate, - handleKeyDown, - shortDateFormat, - toPascalCase, -} from '@/utils/Helper'; + AttendanceParams, + AttendancePercentageProps, + AttendanceStatusListProps, + cohort, + cohortMemberList +} from '../utils/Interfaces'; -import ArrowDropDownSharpIcon from '@mui/icons-material/ArrowDropDownSharp'; import AttendanceStatus from '@/components/AttendanceStatus'; import AttendanceStatusListView from '@/components/AttendanceStatusListView'; -import ClearIcon from '@mui/icons-material/Clear'; import CohortSelectionSection from '@/components/CohortSelectionSection'; -import Header from '../components/Header'; -import KeyboardBackspaceOutlinedIcon from '@mui/icons-material/KeyboardBackspaceOutlined'; -import Loader from '../components/Loader'; import MarkBulkAttendance from '@/components/MarkBulkAttendance'; import MonthCalender from '@/components/MonthCalender'; -import ReactGA from 'react-ga4'; -import SearchIcon from '@mui/icons-material/Search'; -import SortingModal from '../components/SortingModal'; -import { Status } from '@/utils/app.constant'; +import { showToastMessage } from '@/components/Toastify'; import UpDownButton from '@/components/UpDownButton'; -import { accessControl } from '../../app.config'; -import { attendanceStatusList } from '../services/AttendanceService'; -import { calculatePercentage } from '@/utils/attendanceStats'; -import { cohortMemberList } from '../utils/Interfaces'; import { getMyCohortMemberList } from '@/services/MyClassDetailsService'; +import { Status } from '@/utils/app.constant'; +import { calculatePercentage } from '@/utils/attendanceStats'; import { logEvent } from '@/utils/googleAnalytics'; +import withAccessControl from '@/utils/hoc/withAccessControl'; +import ArrowDropDownSharpIcon from '@mui/icons-material/ArrowDropDownSharp'; +import ClearIcon from '@mui/icons-material/Clear'; +import KeyboardBackspaceOutlinedIcon from '@mui/icons-material/KeyboardBackspaceOutlined'; +import SearchIcon from '@mui/icons-material/Search'; +import { useTheme } from '@mui/material/styles'; +import { useTranslation } from 'next-i18next'; import { serverSideTranslations } from 'next-i18next/serverSideTranslations'; -import { showToastMessage } from '@/components/Toastify'; import { usePathname } from 'next/navigation'; import { useRouter } from 'next/router'; -import { useTheme } from '@mui/material/styles'; -import { useTranslation } from 'next-i18next'; -import withAccessControl from '@/utils/hoc/withAccessControl'; +import ReactGA from 'react-ga4'; +import { accessControl } from '../../app.config'; +import Header from '../components/Header'; +import Loader from '../components/Loader'; +import SortingModal from '../components/SortingModal'; +import { attendanceStatusList } from '../services/AttendanceService'; interface user { memberStatus: string; @@ -79,7 +79,6 @@ const UserAttendanceHistory = () => { const [modalOpen, setModalOpen] = React.useState(false); const [bulkAttendanceStatus, setBulkAttendanceStatus] = React.useState(''); const [status, setStatus] = useState(''); - const [center, setCenter] = useState(''); const [openMarkAttendance, setOpenMarkAttendance] = useState(false); const handleMarkAttendanceModal = () => setOpenMarkAttendance(!openMarkAttendance); @@ -94,7 +93,6 @@ const UserAttendanceHistory = () => { const searchRef = useRef(null); const pathname = usePathname(); - // let userId: string; const currentDate = getTodayDate(); const handleOpen = () => { @@ -108,8 +106,8 @@ const UserAttendanceHistory = () => { useEffect(() => { if (typeof window !== 'undefined' && window.localStorage) { const token = localStorage.getItem('token'); - setClassId(localStorage.getItem('classId') || ''); - const classId = localStorage.getItem('classId') || ''; + setClassId(localStorage.getItem('classId') ?? ''); + const classId = localStorage.getItem('classId') ?? ''; localStorage.setItem('cohortId', classId); setLoading(false); if (token) { @@ -202,7 +200,7 @@ const UserAttendanceHistory = () => { }; const res = await attendanceStatusList(attendanceStatusData); const response = res?.data?.attendanceList; - if (nameUserIdArray && response) { + if (response) { const getUserAttendanceStatus = ( nameUserIdArray: any[], response: any[] @@ -231,7 +229,7 @@ const UserAttendanceHistory = () => { response ); - if (nameUserIdArray && userAttendanceArray) { + if (userAttendanceArray) { const mergeArrays = ( nameUserIdArray: { userId: string; @@ -305,10 +303,6 @@ const UserAttendanceHistory = () => { console.log(status); }, [status]); - // useEffect(() => { - // localStorage.setItem('activeStartDate', activeStartDate.toISOString()); - // }, [activeStartDate]); - useEffect(() => { handleSelectedDateChange(selectedDate); }, []); @@ -317,15 +311,6 @@ const UserAttendanceHistory = () => { setSelectedDate(date); }; - const formatDate = (date: Date | null | undefined) => { - if (!date) { - return ''; - } - const year = date.getFullYear(); - const month = (date.getMonth() + 1).toString().padStart(2, '0'); - const day = date.getDate().toString().padStart(2, '0'); - return `${year}-${month}-${day}`; - }; const getAllDatesInRange = (startDate: string, endDate: string): string[] => { const datesArray: string[] = []; @@ -388,13 +373,6 @@ const UserAttendanceHistory = () => { } }; - const handleSearchFocus = () => { - const scrollSearchBox = searchRef.current; - if (scrollSearchBox) { - scrollSearchBox.scrollIntoView({ block: 'start', behavior: 'smooth' }); - } - }; - const handleSearchSubmit = () => { const filteredList = cohortMemberList?.filter((user: any) => user.name.toLowerCase().includes(searchWord.toLowerCase()) @@ -490,8 +468,6 @@ const UserAttendanceHistory = () => { setDisplayStudentList(updatedAttendanceList); }; - const hadleScroolDown = () => {}; - const inputRef = React.useRef(null); const handleScrollDown = () => { @@ -651,7 +627,6 @@ const UserAttendanceHistory = () => { background: theme.palette.warning.A700, boxShadow: 'none', }} - onFocus={hadleScroolDown} > = () => { - const router = useRouter(); const { t } = useTranslation(); const { push } = useRouter(); const today = new Date(); @@ -116,8 +115,8 @@ const AttendanceOverview: React.FC = () => { useEffect(() => { if (typeof window !== 'undefined' && window.localStorage) { const token = localStorage.getItem('token'); - setClassId(localStorage.getItem('classId') || ''); - const class_Id = localStorage.getItem('classId') || ''; + setClassId(localStorage.getItem('classId') ?? ''); + const class_Id = localStorage.getItem('classId') ?? ''; localStorage.setItem('cohortId', class_Id); setLoading(false); @@ -131,7 +130,6 @@ const AttendanceOverview: React.FC = () => { useEffect(() => { const getAttendanceMarkedDays = async () => { - // const today = new Date(); const todayFormattedDate = formatSelectedDate(new Date()); const lastSeventhDayDate = new Date( today.getTime() - 6 * 24 * 60 * 60 * 1000 @@ -152,7 +150,7 @@ const AttendanceOverview: React.FC = () => { } else { setDateRange(`(${startDay} ${startDayMonth}-${endDay} ${endDayMonth})`); } - const cohortAttendanceData: cohortAttendancePercentParam = { + const cohortAttendanceData: CohortAttendancePercentParam = { limit: 0, page: 0, filters: { @@ -234,7 +232,7 @@ const AttendanceOverview: React.FC = () => { present_percent: resp[userId]?.present_percentage || '0', absent_percent: resp[userId]?.absent_percentage || '0', })); - if (nameUserIdArray && filteredData) { + if (filteredData) { let mergedArray = filteredData.map((attendance) => { const user = nameUserIdArray.find( (user: { userId: string }) => @@ -272,7 +270,7 @@ const AttendanceOverview: React.FC = () => { } if (classId) { const cohortAttendancePercent = async () => { - const cohortAttendanceData: cohortAttendancePercentParam = { + const cohortAttendanceData: CohortAttendancePercentParam = { limit: 0, page: 0, filters: { @@ -286,8 +284,7 @@ const AttendanceOverview: React.FC = () => { }; const res = await getCohortAttendance(cohortAttendanceData); const response = res?.data?.result; - const contextData = - response?.contextId && response?.contextId[classId]; + const contextData = response?.contextId?.[classId]; if (contextData?.present_percentage) { const presentPercentage = contextData?.present_percentage; setPresentPercentage(presentPercentage); @@ -340,7 +337,7 @@ const AttendanceOverview: React.FC = () => { const nameIDAttendanceArray = results .filter( (result) => - !result.error && result.data && result.data.contextId + !result.error && result?.data?.contextId ) .map((result) => { const cohortId = result.cohortId; @@ -483,10 +480,6 @@ const AttendanceOverview: React.FC = () => { label: 'Back Button Clicked', }); }; - const truncate = (str: string, length: number) => { - if (str.length <= length) return str; - return str.slice(0, length) + '...'; - }; const inputRef = React.useRef(null); diff --git a/src/pages/center-session.tsx b/src/pages/center-session.tsx index d5d91afe..8e896bb4 100644 --- a/src/pages/center-session.tsx +++ b/src/pages/center-session.tsx @@ -3,7 +3,6 @@ import React, { useEffect, useState } from 'react'; import Header from '@/components/Header'; import KeyboardBackspaceOutlinedIcon from '@mui/icons-material/KeyboardBackspaceOutlined'; -import Loader from '../components/Loader'; import { Session } from '../utils/Interfaces'; import SessionCardFooter from '@/components/SessionCardFooter'; import SessionsCard from '@/components/SessionCard'; diff --git a/src/pages/centers/[cohortId].tsx b/src/pages/centers/[cohortId].tsx index 017c1568..0ebce89b 100644 --- a/src/pages/centers/[cohortId].tsx +++ b/src/pages/centers/[cohortId].tsx @@ -1,3 +1,4 @@ +import { formatSelectedDate, getTodayDate, toPascalCase } from '@/utils/Helper'; import { Button, IconButton, @@ -7,42 +8,41 @@ import { Typography, } from '@mui/material'; import React, { useEffect, useState } from 'react'; -import { formatSelectedDate, getTodayDate, toPascalCase } from '@/utils/Helper'; -import AddIcon from '@mui/icons-material/Add'; import AddLearnerModal from '@/components/AddLeanerModal'; -import ArrowForwardIcon from '@mui/icons-material/ArrowForward'; -import Box from '@mui/material/Box'; -import CalendarMonthIcon from '@mui/icons-material/CalendarMonth'; import CenterSessionModal from '@/components/CenterSessionModal'; import CohortFacilitatorList from '@/components/CohortFacilitatorList'; import CohortLearnerList from '@/components/CohortLearnerList'; -import { CustomField } from '@/utils/Interfaces'; -import DeleteCenterModal from '@/components/center/DeleteCenterModal'; -import DeleteOutlineOutlinedIcon from '@mui/icons-material/DeleteOutlineOutlined'; import DeleteSession from '@/components/DeleteSession'; -import { GetStaticPaths } from 'next'; import Header from '@/components/Header'; -import KeyboardBackspaceOutlinedIcon from '@mui/icons-material/KeyboardBackspaceOutlined'; -import ModeEditOutlineOutlinedIcon from '@mui/icons-material/ModeEditOutlineOutlined'; -import MoreVertIcon from '@mui/icons-material/MoreVert'; import PlannedSession from '@/components/PlannedSession'; -import ReactGA from 'react-ga4'; -import RenameCenterModal from '@/components/center/RenameCenterModal'; -import Schedule from './../../components/Schedule'; -import { Session } from '../../utils/Interfaces'; import SessionCard from '@/components/SessionCard'; import SessionCardFooter from '@/components/SessionCardFooter'; -import Tab from '@mui/material/Tab'; -import Tabs from '@mui/material/Tabs'; import WeekCalender from '@/components/WeekCalender'; +import DeleteCenterModal from '@/components/center/DeleteCenterModal'; +import RenameCenterModal from '@/components/center/RenameCenterModal'; import { getCohortDetails } from '@/services/CohortServices'; import { getSessions } from '@/services/Sessionservice'; import manageUserStore from '@/store/manageUserStore'; -import { serverSideTranslations } from 'next-i18next/serverSideTranslations'; -import { useRouter } from 'next/router'; +import { CustomField } from '@/utils/Interfaces'; +import AddIcon from '@mui/icons-material/Add'; +import ArrowForwardIcon from '@mui/icons-material/ArrowForward'; +import CalendarMonthIcon from '@mui/icons-material/CalendarMonth'; +import DeleteOutlineOutlinedIcon from '@mui/icons-material/DeleteOutlineOutlined'; +import KeyboardBackspaceOutlinedIcon from '@mui/icons-material/KeyboardBackspaceOutlined'; +import ModeEditOutlineOutlinedIcon from '@mui/icons-material/ModeEditOutlineOutlined'; +import MoreVertIcon from '@mui/icons-material/MoreVert'; +import Box from '@mui/material/Box'; +import Tab from '@mui/material/Tab'; +import Tabs from '@mui/material/Tabs'; import { useTheme } from '@mui/material/styles'; +import { GetStaticPaths } from 'next'; import { useTranslation } from 'next-i18next'; +import { serverSideTranslations } from 'next-i18next/serverSideTranslations'; +import { useRouter } from 'next/router'; +import ReactGA from 'react-ga4'; +import { Session } from '../../utils/Interfaces'; +import Schedule from './../../components/Schedule'; const TeachingCenterDetails = () => { const [value, setValue] = React.useState(1); diff --git a/src/pages/centers/index.tsx b/src/pages/centers/index.tsx index a5f85eaf..cd1c8fff 100644 --- a/src/pages/centers/index.tsx +++ b/src/pages/centers/index.tsx @@ -1,43 +1,39 @@ +import { getCohortList } from '@/services/CohortServices'; +import { accessGranted, toPascalCase } from '@/utils/Helper'; +import { cohort } from '@/utils/Interfaces'; import { Box, Button, FormControl, Grid, InputAdornment, - MenuItem, - Select, Tab, Tabs, TextField, } from '@mui/material'; import React, { useEffect, useState } from 'react'; import FilterModalCenter from '../blocks/components/FilterModalCenter'; -import { accessGranted, toPascalCase } from '@/utils/Helper'; -import { cohort, cohortAttendancePercentParam } from '@/utils/Interfaces'; -import { cohortList, getCohortList } from '@/services/CohortServices'; -import AddIcon from '@mui/icons-material/Add'; -import ChevronRightIcon from '@mui/icons-material/ChevronRight'; -import CreateCenterModal from '@/components/center/CreateCenterModal'; -import ErrorOutlineIcon from '@mui/icons-material/ErrorOutline'; import Header from '@/components/Header'; -import Image from 'next/image'; import Loader from '@/components/Loader'; import ManageUser from '@/components/ManageUser'; -import { Role } from '@/utils/app.constant'; -import SearchIcon from '@mui/icons-material/Search'; -import SmartDisplayOutlinedIcon from '@mui/icons-material/SmartDisplayOutlined'; -import { accessControl } from '../../../app.config'; -import building from '../../assets/images/apartment.png'; -import { serverSideTranslations } from 'next-i18next/serverSideTranslations'; -import { setTimeout } from 'timers'; import { showToastMessage } from '@/components/Toastify'; -import { useRouter } from 'next/router'; +import CreateCenterModal from '@/components/center/CreateCenterModal'; +import teamLeadStore from '@/store/mangageTLStore'; import useStore from '@/store/store'; +import { Role } from '@/utils/app.constant'; +import { ArrowDropDown, Search } from '@mui/icons-material'; +import AddIcon from '@mui/icons-material/Add'; +import ChevronRightIcon from '@mui/icons-material/ChevronRight'; +import SmartDisplayOutlinedIcon from '@mui/icons-material/SmartDisplayOutlined'; import { useTheme } from '@mui/material/styles'; import { useTranslation } from 'next-i18next'; -import { ArrowDropDown, Search } from '@mui/icons-material'; -import teamLeadStore from '@/store/mangageTLStore'; +import { serverSideTranslations } from 'next-i18next/serverSideTranslations'; +import Image from 'next/image'; +import { useRouter } from 'next/router'; +import { setTimeout } from 'timers'; +import { accessControl } from '../../../app.config'; +import building from '../../assets/images/apartment.png'; const TeachingCenters = () => { const [loading, setLoading] = useState(false); @@ -154,7 +150,7 @@ const TeachingCenters = () => { console.log(blockData); setBlockData(blockData); - const cohortData = response.map((res: any) => { + response.map((res: any) => { const centerData = res?.childData.map((child: any) => { const cohortName = child.name; const cohortId = child.cohortId; @@ -248,7 +244,8 @@ const TeachingCenters = () => { {block.blockName} {block?.district && ( - {block.district}, {toPascalCase(block.state)} + {toPascalCase(block?.district)},{' '} + {toPascalCase(block?.state)} )} @@ -402,8 +399,11 @@ const TeachingCenters = () => { onCenterAdded={handleCenterAdded} /> {accessGranted( @@ -594,7 +594,6 @@ const TeachingCenters = () => { accessControl, userRole ) && - cohortsData && cohortsData?.map((cohort: any) => { return ( diff --git a/src/pages/course-planner.tsx b/src/pages/course-planner.tsx new file mode 100644 index 00000000..a1b4e1e8 --- /dev/null +++ b/src/pages/course-planner.tsx @@ -0,0 +1,223 @@ +import Header from '@/components/Header'; +import { + Box, + FormControl, + Grid, + IconButton, + InputBase, + MenuItem, + Paper, + Select, + Tab, + Tabs, + Typography, +} from '@mui/material'; +import React from 'react'; +import { serverSideTranslations } from 'next-i18next/serverSideTranslations'; +import { useTheme } from '@mui/material/styles'; +import { useTranslation } from 'next-i18next'; +import SearchIcon from '@mui/icons-material/Search'; +import KeyboardArrowRightIcon from '@mui/icons-material/KeyboardArrowRight'; +import { CircularProgressbar, buildStyles } from 'react-circular-progressbar'; + +const CoursePlanner = () => { + const [value, setValue] = React.useState(1); + const theme = useTheme(); + const { t } = useTranslation(); + + const inputRef = React.useRef(null); + + const handleScrollDown = () => { + if (inputRef.current) { + const inputRect = inputRef.current.getBoundingClientRect(); + const scrollMargin = 20; + const scrollY = window.scrollY; + const targetY = inputRect.top + scrollY - scrollMargin; + window.scrollTo({ top: targetY - 70, behavior: 'smooth' }); + } + }; + const handleChange = (event: React.SyntheticEvent, newValue: number) => { + setValue(newValue); + }; + return ( + + +
+ + + + {t('COURSE_PLANNER.COURSE_PLANNER')} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {value === 1 && ( + + + + + + + + {/* */} + + + Mathematics {/* will come form API */} + + + + + + + + + + + )} + + + ); +}; +export async function getStaticProps({ locale }: any) { + return { + props: { + ...(await serverSideTranslations(locale, ['common'])), + // Will be passed to the page component as props + }, + }; +} +export default CoursePlanner; diff --git a/src/pages/dashboard.tsx b/src/pages/dashboard.tsx index b461ac24..1068eaaa 100644 --- a/src/pages/dashboard.tsx +++ b/src/pages/dashboard.tsx @@ -1,66 +1,55 @@ 'use client'; -import { - AttendancePercentageProps, - cohort, - cohortAttendancePercentParam, - cohortMemberList, -} from '../utils/Interfaces'; import { Box, Button, Grid, Stack, Typography } from '@mui/material'; -import { CircularProgressbar, buildStyles } from 'react-circular-progressbar'; +import { format, isAfter, isValid, parse, startOfDay } from 'date-fns'; import React, { useEffect } from 'react'; -import { accessControl, lowLearnerAttendanceLimit } from './../../app.config'; +import { CircularProgressbar, buildStyles } from 'react-circular-progressbar'; import { classesMissedAttendancePercentList, getAllCenterAttendance, getCohortAttendance, } from '../services/AttendanceService'; -import { format, isAfter, isValid, parse, startOfDay } from 'date-fns'; import { formatSelectedDate, getTodayDate, shortDateFormat, toPascalCase, } from '../utils/Helper'; +import { + AttendancePercentageProps, + CohortAttendancePercentParam, + cohort, + cohortMemberList, +} from '../utils/Interfaces'; +import { accessControl, lowLearnerAttendanceLimit } from './../../app.config'; - -import ArrowForwardSharpIcon from '@mui/icons-material/ArrowForwardSharp'; +import AttendanceComparison from '@/components/AttendanceComparison'; import CohortSelectionSection from '@/components/CohortSelectionSection'; -import Divider from '@mui/material/Divider'; import GuideTour from '@/components/GuideTour'; -import Header from '../components/Header'; -import Image from 'next/image'; -import Link from 'next/link'; -import Loader from '../components/Loader'; import MarkBulkAttendance from '@/components/MarkBulkAttendance'; import OverviewCard from '@/components/OverviewCard'; -import ReactGA from 'react-ga4'; +import { showToastMessage } from '@/components/Toastify'; import WeekCalender from '@/components/WeekCalender'; -import { calculatePercentage } from '@/utils/attendanceStats'; -import calendar from '../assets/images/calendar.svg'; import { getMyCohortMemberList } from '@/services/MyClassDetailsService'; +import { calculatePercentage } from '@/utils/attendanceStats'; import { logEvent } from '@/utils/googleAnalytics'; -import { modifyAttendanceLimit } from '../../app.config'; -import { serverSideTranslations } from 'next-i18next/serverSideTranslations'; -import { showToastMessage } from '@/components/Toastify'; -import { useCohortList } from '@/services/queries'; -import useDeterminePathColor from '../hooks/useDeterminePathColor'; -import { useRouter } from 'next/navigation'; +import withAccessControl from '@/utils/hoc/withAccessControl'; +import ArrowForwardSharpIcon from '@mui/icons-material/ArrowForwardSharp'; +import Divider from '@mui/material/Divider'; import { useTheme } from '@mui/material/styles'; import { useTranslation } from 'next-i18next'; -import withAccessControl from '@/utils/hoc/withAccessControl'; -import AttendanceComparison from '@/components/AttendanceComparison'; - -// import { Role } from '@/utils/app.constant'; -// import { accessControl } from '../../app.config'; - -// import useStore from '@/store/store'; -// const store = useStore(); -// const userRole: string = store.userRole; +import { serverSideTranslations } from 'next-i18next/serverSideTranslations'; +import Image from 'next/image'; +import Link from 'next/link'; +import { useRouter } from 'next/navigation'; +import ReactGA from 'react-ga4'; +import { modifyAttendanceLimit } from '../../app.config'; +import calendar from '../assets/images/calendar.svg'; +import Header from '../components/Header'; +import Loader from '../components/Loader'; +import useDeterminePathColor from '../hooks/useDeterminePathColor'; -interface DashboardProps { - // buttonText: string; -} +interface DashboardProps {} const Dashboard: React.FC = () => { const { t } = useTranslation(); @@ -97,7 +86,6 @@ const Dashboard: React.FC = () => { const formattedSevenDaysAgo = shortDateFormat(sevenDaysAgo); const [userId, setUserId] = React.useState(null); const [blockName, setBlockName] = React.useState(''); - useEffect(() => { setIsClient(true); @@ -132,7 +120,7 @@ const Dashboard: React.FC = () => { if (typeof window !== 'undefined' && window.localStorage) { const token = localStorage.getItem('token'); const storedUserId = localStorage.getItem('userId'); - setClassId(localStorage.getItem('classId') || ''); + setClassId(localStorage.getItem('classId') ?? ''); if (token) { setIsAuthenticated(true); } else { @@ -142,10 +130,6 @@ const Dashboard: React.FC = () => { } }, []); - const limit = 0; - const page = 0; - const filters = { userId: userId || '' }; - //API for getting student list useEffect(() => { const getCohortMemberList = async () => { @@ -188,7 +172,7 @@ const Dashboard: React.FC = () => { absent: resp[userId].absent, present_percent: resp[userId].present_percentage, })); - if (nameUserIdArray && filteredData) { + if (filteredData) { let mergedArray = filteredData.map((attendance) => { const user = nameUserIdArray.find( (user: { userId: string }) => @@ -224,7 +208,7 @@ const Dashboard: React.FC = () => { } if (classId) { const cohortAttendancePercent = async () => { - const cohortAttendanceData: cohortAttendancePercentParam = { + const cohortAttendanceData: CohortAttendancePercentParam = { limit: 0, page: 0, filters: { @@ -238,8 +222,7 @@ const Dashboard: React.FC = () => { }; const res = await getCohortAttendance(cohortAttendanceData); const response = res?.data?.result; - const contextData = - response?.contextId && response?.contextId[classId]; + const contextData = response?.contextId?.[classId]; if (contextData?.present_percentage) { const presentPercent = contextData?.present_percentage; setCohortPresentPercentage(presentPercent); @@ -290,10 +273,7 @@ const Dashboard: React.FC = () => { console.log('Fetched data:', results); const nameIDAttendanceArray = results - .filter( - (result) => - !result?.error && result?.data && result?.data?.contextId - ) + .filter((result) => !result?.error && result?.data?.contextId) .map((result) => { const cohortId = result?.cohortId; const contextData = result?.data?.contextId[cohortId] || {}; @@ -572,7 +552,7 @@ const Dashboard: React.FC = () => { @@ -893,9 +873,9 @@ const Dashboard: React.FC = () => { - - - + + + {/* { const [loading, setLoading] = React.useState(false); const [selectedDate, setSelectedDate] = useState(new Date()); - const [isAuthenticated, setIsAuthenticated] = React.useState(false); const [open, setOpen] = useState(false); const [modalOpen, setModalOpen] = useState(false); const [attendanceUpdated, setAttendanceUpdated] = useState(false); @@ -95,8 +94,8 @@ const LearnerAttendanceHistory = () => { const getAttendanceStatus = async () => { setLoading(true); try { - const classId = localStorage.getItem('classId') || ''; - const userId = localStorage.getItem('learnerId') || ''; + const classId = localStorage.getItem('classId') ?? ''; + const userId = localStorage.getItem('learnerId') ?? ''; if ( classId !== '' && classId !== undefined && @@ -235,7 +234,7 @@ const LearnerAttendanceHistory = () => { isSelfAttendance={false} currentStatus={ learnerAttendance?.[shortDateFormat(selectedDate)] - ?.attendanceStatus || '' + ?.attendanceStatus ?? '' } handleClose={handleModalClose} onAttendanceUpdate={() => setAttendanceUpdated(!attendanceUpdated)} diff --git a/src/pages/learner/[userId].tsx b/src/pages/learner/[userId].tsx index 94ab3e5f..0ca959de 100644 --- a/src/pages/learner/[userId].tsx +++ b/src/pages/learner/[userId].tsx @@ -33,8 +33,8 @@ import { import { LearnerData, UserData, - cohortAttendancePercentParam, - updateCustomField, + CohortAttendancePercentParam, + UpdateCustomField, } from '@/utils/Interfaces'; import Menu, { MenuProps } from '@mui/material/Menu'; import React, { useEffect, useState } from 'react'; @@ -68,7 +68,7 @@ import { useTranslation } from 'next-i18next'; import withAccessControl from '@/utils/hoc/withAccessControl'; import { accessControl } from '../../../app.config'; -// import { UserData, updateCustomField } from '../utils/Interfaces'; +// import { UserData, UpdateCustomField } from '../utils/Interfaces'; interface QuestionValue { question: string; @@ -107,7 +107,7 @@ const LearnerProfile: React.FC = () => { const [test, setTest] = React.useState('Pre Test'); const [subject, setSubject] = React.useState('English'); const [anchorEl, setAnchorEl] = React.useState(null); - const [customFieldsData, setCustomFieldsData] = useState( + const [customFieldsData, setCustomFieldsData] = useState( [] ); interface OverallAttendance { @@ -320,14 +320,12 @@ const LearnerProfile: React.FC = () => { ? selectedOption.label : field.value ? toPascalCase(field.value) - : "-", + : '-', }; } return { ...field, - displayValue: field.value - ? toPascalCase(field.value) - : "-", + displayValue: field.value ? toPascalCase(field.value) : '-', }; }); @@ -753,7 +751,7 @@ const LearnerProfile: React.FC = () => { setDateRange(`(${startDay} ${startDayMonth}-${endDay} ${endDayMonth})`); } - const cohortAttendanceData: cohortAttendancePercentParam = { + const cohortAttendanceData: CohortAttendancePercentParam = { limit: 0, page: 0, filters: { @@ -1530,10 +1528,7 @@ const LearnerProfile: React.FC = () => { {field?.label && - t( - `FORM.${field.label.toUpperCase()}`, - field.label - )} + t(`FORM.${field.label.toUpperCase()}`, field.label)}