From c104587339425f94d5d58b1ce69c8ebff1820d31 Mon Sep 17 00:00:00 2001 From: vivek kasture Date: Mon, 29 Jul 2024 15:03:14 +0530 Subject: [PATCH] Issue #PS-000 feat: Fixed lint issues and cosmetic changes --- public/locales/en/common.json | 6 +- public/locales/hi/common.json | 6 +- public/locales/mr/common.json | 6 +- public/locales/or/common.json | 2 +- src/components/CohortSelectionSection.tsx | 23 +++--- .../LearnerAttendanceStatsListView.tsx | 4 +- src/pages/centers/index.tsx | 36 ++++----- src/pages/dashboard.tsx | 73 ++++++++----------- src/utils/app.constant.ts | 10 ++- src/utils/tourGuideSteps.ts | 5 +- 10 files changed, 81 insertions(+), 90 deletions(-) diff --git a/public/locales/en/common.json b/public/locales/en/common.json index 565e337e..18aa5491 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -200,7 +200,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", @@ -265,8 +265,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", 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..532cb119 100644 --- a/public/locales/or/common.json +++ b/public/locales/or/common.json @@ -151,7 +151,7 @@ "MY_PROFILE": "ମୋ ପ୍ରୋଫାଇଲ", "VIEW_MORE": "ଅଧିକ ଦେଖନ୍ତୁ", "VIEW_LESS": "କମ୍ ଦେଖନ୍ତୁ", - "DATA_RANAGE": "ଡାଟା ରେଞ୍ଜ", + "DATA_RANGE": "ଡାଟା ରେଞ୍ଜ", "LEARNER_DETAILS": "ଶିକ୍ଷାର୍ଥୀ ବିବରଣୀ", "VIEW_DAY_WISE": "ଦିନ-ଅନୁସାରେ ବିବରଣୀ ଦେଖନ୍ତୁ", "SUBMITTED_ON": "ସବ୍ମିଟ୍/ଦାଖଲ କରାଯାଇଛି", diff --git a/src/components/CohortSelectionSection.tsx b/src/components/CohortSelectionSection.tsx index 905ce26e..8b7bd9e7 100644 --- a/src/components/CohortSelectionSection.tsx +++ b/src/components/CohortSelectionSection.tsx @@ -6,18 +6,18 @@ import { SelectChangeEvent, Typography, } from '@mui/material'; -import React, { useEffect } from 'react'; import { usePathname, useRouter } from 'next/navigation'; +import React, { useEffect } from 'react'; -import Loader from './Loader'; -import ReactGA from 'react-ga4'; +import { getCohortList } from '@/services/CohortServices'; +import useStore from '@/store/store'; import { cohort } from '@/utils/Interfaces'; import { cohortHierarchy } from '@/utils/app.constant'; -import { getCohortList } from '@/services/CohortServices'; -import { showToastMessage } from './Toastify'; import { useTheme } from '@mui/material/styles'; import { useTranslation } from 'next-i18next'; -import useStore from '@/store/store'; +import ReactGA from 'react-ga4'; +import Loader from './Loader'; +import { showToastMessage } from './Toastify'; interface CohortSelectionSectionProps { classId: string; @@ -109,15 +109,14 @@ const CohortSelectionSection: React.FC = ({ 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/LearnerAttendanceStatsListView.tsx b/src/components/LearnerAttendanceStatsListView.tsx index 3a4f1491..ae58b74b 100644 --- a/src/components/LearnerAttendanceStatsListView.tsx +++ b/src/components/LearnerAttendanceStatsListView.tsx @@ -1,4 +1,4 @@ -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'; @@ -144,7 +144,6 @@ const StudentsStatsList: React.FC = ({ {memberStatus === Status.DROPOUT ? ( - <> @@ -173,7 +172,6 @@ const StudentsStatsList: React.FC = ({ - ) : ( <> diff --git a/src/pages/centers/index.tsx b/src/pages/centers/index.tsx index a5f85eaf..369a7ce6 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); diff --git a/src/pages/dashboard.tsx b/src/pages/dashboard.tsx index b461ac24..85a3e6c8 100644 --- a/src/pages/dashboard.tsx +++ b/src/pages/dashboard.tsx @@ -1,55 +1,53 @@ '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, + cohort, + cohortAttendancePercentParam, + 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 { 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'; // import { Role } from '@/utils/app.constant'; // import { accessControl } from '../../app.config'; @@ -97,7 +95,6 @@ const Dashboard: React.FC = () => { const formattedSevenDaysAgo = shortDateFormat(sevenDaysAgo); const [userId, setUserId] = React.useState(null); const [blockName, setBlockName] = React.useState(''); - useEffect(() => { setIsClient(true); @@ -142,10 +139,6 @@ const Dashboard: React.FC = () => { } }, []); - const limit = 0; - const page = 0; - const filters = { userId: userId || '' }; - //API for getting student list useEffect(() => { const getCohortMemberList = async () => { @@ -238,8 +231,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 +282,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 +561,7 @@ const Dashboard: React.FC = () => { @@ -893,9 +882,9 @@ const Dashboard: React.FC = () => { - - - + + + {/* [ { target: 'joyride-step-0', @@ -22,10 +23,10 @@ export const getSteps = (t: TFunction) => [ }, { target: '.joyride-step-5', - content: t('GUIDE_TOUR.STEP_5'), + content: t('GUIDE_TOUR.STEP_5', { numberOfDays: modifyAttendanceLimit + 1 }), }, { target: '.joyride-step-6', - content: t('GUIDE_TOUR.STEP_6'), + content: t('GUIDE_TOUR.STEP_6', { numberOfDays: modifyAttendanceLimit + 1 }), }, ];