From cd54353fbe8fb5d4e382f0651a7f372603b0c4dc Mon Sep 17 00:00:00 2001 From: vivek kasture Date: Wed, 31 Jul 2024 11:58:19 +0530 Subject: [PATCH] Issue #PS-000 feat: Fixed lint issues --- src/components/AttendanceComparison.tsx | 2 +- src/pages/attendance-history.tsx | 4 ++-- src/pages/centers/index.tsx | 4 ++-- src/pages/dashboard.tsx | 4 ++-- src/pages/learner-attendance-history.tsx | 5 ----- src/pages/login.tsx | 8 +++----- src/services/AssesmentService.ts | 4 ++-- src/services/CreateUserService.ts | 1 - src/services/MyClassDetailsService.ts | 10 +++++----- src/store/manageUserStore.js | 1 + src/store/mangageTLStore.js | 1 + src/store/reassignLearnerStore.js | 1 + src/store/store.js | 1 + src/utils/Helper.ts | 3 +-- src/utils/Interfaces.ts | 11 ++++++----- src/utils/attendanceStats.ts | 6 +++--- src/utils/hoc/withAccessControl.tsx | 7 ++++++- src/utils/telemetry.js | 3 ++- 18 files changed, 39 insertions(+), 37 deletions(-) diff --git a/src/components/AttendanceComparison.tsx b/src/components/AttendanceComparison.tsx index 5c4a47e4..ab9b5afc 100644 --- a/src/components/AttendanceComparison.tsx +++ b/src/components/AttendanceComparison.tsx @@ -161,7 +161,7 @@ const AttendanceComparison: React.FC = () => { - + {t('DASHBOARD.BLOCK_AVERAGE_ATTENDANCE')}:{' '} {averageAttendance.toFixed(2)}% diff --git a/src/pages/attendance-history.tsx b/src/pages/attendance-history.tsx index 93d2c4f4..1b0f4067 100644 --- a/src/pages/attendance-history.tsx +++ b/src/pages/attendance-history.tsx @@ -21,7 +21,7 @@ import { AttendancePercentageProps, AttendanceStatusListProps, cohort, - cohortMemberList + CohortMemberList } from '../utils/Interfaces'; import AttendanceStatus from '@/components/AttendanceStatus'; @@ -122,7 +122,7 @@ const UserAttendanceHistory = () => { const getAttendanceStats = async () => { if (classId !== '' && classId !== undefined) { console.log('classId', classId); - const cohortMemberRequest: cohortMemberList = { + const cohortMemberRequest: CohortMemberList = { limit: 300, page: 0, filters: { diff --git a/src/pages/centers/index.tsx b/src/pages/centers/index.tsx index cd1c8fff..62b25504 100644 --- a/src/pages/centers/index.tsx +++ b/src/pages/centers/index.tsx @@ -1,6 +1,6 @@ import { getCohortList } from '@/services/CohortServices'; import { accessGranted, toPascalCase } from '@/utils/Helper'; -import { cohort } from '@/utils/Interfaces'; +import { ICohort } from '@/utils/Interfaces'; import { Box, Button, @@ -40,7 +40,7 @@ const TeachingCenters = () => { const { t } = useTranslation(); const theme = useTheme(); const router = useRouter(); - const [cohortsData, setCohortsData] = useState>([]); + const [cohortsData, setCohortsData] = useState>([]); const [value, setValue] = useState(1); const [blockData, setBlockData] = useState< { bockName: string; district?: string; blockId: string; state?: string }[] diff --git a/src/pages/dashboard.tsx b/src/pages/dashboard.tsx index 1068eaaa..125b51fb 100644 --- a/src/pages/dashboard.tsx +++ b/src/pages/dashboard.tsx @@ -19,7 +19,7 @@ import { AttendancePercentageProps, CohortAttendancePercentParam, cohort, - cohortMemberList, + CohortMemberList, } from '../utils/Interfaces'; import { accessControl, lowLearnerAttendanceLimit } from './../../app.config'; @@ -349,7 +349,7 @@ const Dashboard: React.FC = () => { useEffect(() => { const getAttendanceStats = async () => { if (classId !== '' && classId !== 'all') { - const cohortMemberRequest: cohortMemberList = { + const cohortMemberRequest: CohortMemberList = { limit: 300, page: 0, filters: { diff --git a/src/pages/learner-attendance-history.tsx b/src/pages/learner-attendance-history.tsx index a204ca49..f91d32b0 100644 --- a/src/pages/learner-attendance-history.tsx +++ b/src/pages/learner-attendance-history.tsx @@ -38,7 +38,6 @@ const LearnerAttendanceHistory = () => { const [loading, setLoading] = React.useState(false); const [selectedDate, setSelectedDate] = useState(new Date()); const [open, setOpen] = useState(false); - const [modalOpen, setModalOpen] = useState(false); const [attendanceUpdated, setAttendanceUpdated] = useState(false); const [learnerAttendance, setLearnerAttendance] = useState< LearnerAttendanceData | undefined @@ -77,10 +76,6 @@ const LearnerAttendanceHistory = () => { }); }; - const handleModalOpen = () => { - setModalOpen(true); - }; - const handleModalClose = () => { setOpen(false); logEvent({ diff --git a/src/pages/login.tsx b/src/pages/login.tsx index 37ff718d..b7fe907e 100644 --- a/src/pages/login.tsx +++ b/src/pages/login.tsx @@ -12,6 +12,7 @@ import React, { useEffect, useRef, useState } from 'react'; import ReactGA from 'react-ga4'; import { showToastMessage } from '@/components/Toastify'; +import manageUserStore from '@/store/manageUserStore'; import useStore from '@/store/store'; import { logEvent } from '@/utils/googleAnalytics'; import { telemetryFactory } from '@/utils/telemetry'; @@ -28,12 +29,9 @@ import appLogo from '../../public/images/appLogo.png'; import Loader from '../components/Loader'; import { login } from '../services/LoginService'; import { getUserId } from '../services/ProfileService'; -import manageUserStore from '@/store/manageUserStore'; const LoginPage = () => { const { t } = useTranslation(); - const store = useStore(); - const userStore = manageUserStore(); const setUserId = manageUserStore((state) => state.setUserId); const setUserRole = useStore( (state: { setUserRole: any }) => state.setUserRole @@ -60,7 +58,7 @@ const LoginPage = () => { if (typeof window !== 'undefined' && window.localStorage) { let lang; if (localStorage.getItem('preferredLanguage')) { - lang = localStorage.getItem('preferredLanguage') || 'en'; + lang = localStorage.getItem('preferredLanguage') ?? 'en'; } else { lang = 'en'; } @@ -354,7 +352,7 @@ const LoginPage = () => { onChange={(e) => setRememberMe(e.target.checked)} checked={rememberMe} /> - => { +}: GetDoIdServiceParam): Promise => { const apiUrl: string = 'https://sunbirdsaas.com/api/content/v1/search?orgdetails=orgName%2Cemail&licenseDetails=name%2Cdescription%2Curl'; diff --git a/src/services/CreateUserService.ts b/src/services/CreateUserService.ts index d116cc62..6ee71625 100644 --- a/src/services/CreateUserService.ts +++ b/src/services/CreateUserService.ts @@ -1,5 +1,4 @@ import { get, post } from './RestClient'; -import { CreateUserParam } from '../utils/Interfaces'; export const getFormRead = async ( context: string, diff --git a/src/services/MyClassDetailsService.ts b/src/services/MyClassDetailsService.ts index 92c4b436..fdd6c2d5 100644 --- a/src/services/MyClassDetailsService.ts +++ b/src/services/MyClassDetailsService.ts @@ -1,6 +1,6 @@ import { Role, Status } from '@/utils/app.constant'; import { - cohortMemberList, + CohortMemberList, UpdateCohortMemberStatusParams, UserList, } from '../utils/Interfaces'; @@ -10,7 +10,7 @@ const fetchCohortMemberList = async ({ limit, page, filters, -}: cohortMemberList): Promise => { +}: CohortMemberList): Promise => { const apiUrl: string = `${process.env.NEXT_PUBLIC_BASE_URL}/cohortmember/list`; try { const response = await post(apiUrl, { @@ -52,7 +52,7 @@ export const getMyCohortMemberList = async ({ limit, page, filters, -}: cohortMemberList): Promise => { +}: CohortMemberList): Promise => { const studentFilters = { ...filters, role: Role.STUDENT, @@ -65,7 +65,7 @@ export const getMyCohortFacilitatorList = async ({ limit, page, filters, -}: cohortMemberList): Promise => { +}: CohortMemberList): Promise => { const studentFilters = { ...filters, role: Role.TEACHER, @@ -78,7 +78,7 @@ export const getFacilitatorList = async ({ limit, page, filters, -}: cohortMemberList): Promise => { +}: CohortMemberList): Promise => { return fetchCohortMemberList({ limit, page, filters }); }; diff --git a/src/store/manageUserStore.js b/src/store/manageUserStore.js index b7e68ab5..5d99e23d 100644 --- a/src/store/manageUserStore.js +++ b/src/store/manageUserStore.js @@ -1,3 +1,4 @@ +/* eslint-disable no-unused-vars */ import { create } from 'zustand'; import { persist } from 'zustand/middleware'; diff --git a/src/store/mangageTLStore.js b/src/store/mangageTLStore.js index d31adf61..591e6ea0 100644 --- a/src/store/mangageTLStore.js +++ b/src/store/mangageTLStore.js @@ -1,3 +1,4 @@ +/* eslint-disable no-unused-vars */ import { create } from 'zustand'; import { persist } from 'zustand/middleware'; diff --git a/src/store/reassignLearnerStore.js b/src/store/reassignLearnerStore.js index c35c13d7..b580c0d8 100644 --- a/src/store/reassignLearnerStore.js +++ b/src/store/reassignLearnerStore.js @@ -1,3 +1,4 @@ +/* eslint-disable no-unused-vars */ import { create } from 'zustand'; import { persist } from 'zustand/middleware'; diff --git a/src/store/store.js b/src/store/store.js index d773d830..670bdbba 100644 --- a/src/store/store.js +++ b/src/store/store.js @@ -1,3 +1,4 @@ +/* eslint-disable no-unused-vars */ import { create } from 'zustand'; import { persist } from 'zustand/middleware'; diff --git a/src/utils/Helper.ts b/src/utils/Helper.ts index ee51d50a..d2b863dc 100644 --- a/src/utils/Helper.ts +++ b/src/utils/Helper.ts @@ -1,7 +1,6 @@ import { Role, Status } from './app.constant'; import FingerprintJS from 'fingerprintjs2'; -import { i18n } from 'next-i18next'; import { CustomField } from './Interfaces'; export const ATTENDANCE_ENUM = { @@ -110,7 +109,7 @@ export const debounce = any>( let timeout: ReturnType | undefined; return function (this: ThisParameterType, ...args: Parameters) { const context = this; - clearTimeout(timeout!); + clearTimeout(timeout); if (immediate && !timeout) func.apply(context, args); timeout = setTimeout(() => { timeout = undefined; diff --git a/src/utils/Interfaces.ts b/src/utils/Interfaces.ts index bb8b8bcd..09231d9e 100644 --- a/src/utils/Interfaces.ts +++ b/src/utils/Interfaces.ts @@ -1,3 +1,4 @@ +/* eslint-disable no-unused-vars */ export interface AttendanceParams { userId: string; attendanceDate: string; @@ -74,7 +75,7 @@ export interface CohortListParam { filters: Filters; } -export interface cohortMemberList { +export interface CohortMemberList { limit: number; page: number; filters: { @@ -103,7 +104,7 @@ export interface UserData { mobile?: string; } -export interface UserDatas { +export interface IUserData { name?: any; } @@ -148,7 +149,7 @@ export interface PlannedModalProps { export interface ScheduleModalProps { handleClick?: (selection: string) => void; - clickedBox?: String | null; + clickedBox?: string | null; } export interface AttendanceStatusListProps { @@ -215,7 +216,7 @@ export interface UpdateCustomField { isEditable?: boolean; order: number; } -export interface cohort { +export interface ICohort { presentPercentage: number; cohortId: string; name: string; @@ -259,7 +260,7 @@ export interface CohortAttendancePercentParam { facets: Array; sort?: Array; } -export interface gerDoIdServiceParam { +export interface GetDoIdServiceParam { filters: { program?: string | string[]; se_boards?: (string | null)[]; diff --git a/src/utils/attendanceStats.ts b/src/utils/attendanceStats.ts index 6d88c343..f79e8148 100644 --- a/src/utils/attendanceStats.ts +++ b/src/utils/attendanceStats.ts @@ -2,11 +2,11 @@ import { getMyCohortMemberList } from '../services/MyClassDetailsService'; import { attendanceInPercentageStatusList } from '../services/AttendanceService'; import { AttendancePercentageProps, - cohortMemberList, + CohortMemberList, } from '../utils/Interfaces'; const getTotalStudentCount = async ( - cohortMemberRequest: cohortMemberList + cohortMemberRequest: CohortMemberList ): Promise => { const response = await getMyCohortMemberList(cohortMemberRequest); const totalStudentsCount = response?.result?.totalCount; @@ -50,7 +50,7 @@ type Result = { }; export const calculatePercentage = async ( - cohortMemberRequest: cohortMemberList, + cohortMemberRequest: CohortMemberList, attendanceRequest: AttendancePercentageProps ): Promise => { const totalStudentsCount = await getTotalStudentCount(cohortMemberRequest); diff --git a/src/utils/hoc/withAccessControl.tsx b/src/utils/hoc/withAccessControl.tsx index d822086b..c1ba8e5a 100644 --- a/src/utils/hoc/withAccessControl.tsx +++ b/src/utils/hoc/withAccessControl.tsx @@ -6,7 +6,7 @@ import { Role } from '../app.constant'; const withAccessControl = (action: string, accessControl: { [key: string]: Role[] }) => (Component: React.ComponentType) => { - return (props: any) => { + const WrappedComponent = (props: any) => { const store = useStore(); const userRole = store.userRole; const router = useRouter(); @@ -28,6 +28,11 @@ const withAccessControl = return ; }; + + // Setting the display name for better debugging and developer tools + WrappedComponent.displayName = `withAccessControl(${Component.displayName ?? Component.name ?? 'Component'})`; + + return WrappedComponent; }; export default withAccessControl; diff --git a/src/utils/telemetry.js b/src/utils/telemetry.js index 811648fd..0be6cd82 100644 --- a/src/utils/telemetry.js +++ b/src/utils/telemetry.js @@ -33,7 +33,7 @@ const telemetryConfig = { sid: generateUUID(), batchsize: 1, mode: '', - host: hostURL, //TODO: Change this host and endpoint properly + host: hostURL, endpoint: '/telemetry/v1/telemetry', tags: [], }; @@ -207,6 +207,7 @@ function getEventContext(eventInput) { return eventContextData; } +// eslint-disable-next-line no-unused-vars function getRollUpData(data = []) { const rollUp = {}; data.forEach((element, index) => (rollUp['l' + (index + 1)] = element));