Skip to content

Commit

Permalink
Issue #PS-000 feat: Fixed lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
itsvick committed Jul 31, 2024
1 parent 67e245a commit cd54353
Show file tree
Hide file tree
Showing 18 changed files with 39 additions and 37 deletions.
2 changes: 1 addition & 1 deletion src/components/AttendanceComparison.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ const AttendanceComparison: React.FC = () => {
</RadioGroup>
</FormControl>
<Box sx={{ mt: 2 }}>
<Typography align="left">
<Typography align="left" sx={{marginBottom: '16px'}}>
{t('DASHBOARD.BLOCK_AVERAGE_ATTENDANCE')}:{' '}
{averageAttendance.toFixed(2)}%
</Typography>
Expand Down
4 changes: 2 additions & 2 deletions src/pages/attendance-history.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
AttendancePercentageProps,
AttendanceStatusListProps,
cohort,
cohortMemberList
CohortMemberList
} from '../utils/Interfaces';

import AttendanceStatus from '@/components/AttendanceStatus';
Expand Down Expand Up @@ -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: {
Expand Down
4 changes: 2 additions & 2 deletions src/pages/centers/index.tsx
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -40,7 +40,7 @@ const TeachingCenters = () => {
const { t } = useTranslation();
const theme = useTheme<any>();
const router = useRouter();
const [cohortsData, setCohortsData] = useState<Array<cohort>>([]);
const [cohortsData, setCohortsData] = useState<Array<ICohort>>([]);
const [value, setValue] = useState(1);
const [blockData, setBlockData] = useState<
{ bockName: string; district?: string; blockId: string; state?: string }[]
Expand Down
4 changes: 2 additions & 2 deletions src/pages/dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
AttendancePercentageProps,
CohortAttendancePercentParam,
cohort,
cohortMemberList,
CohortMemberList,
} from '../utils/Interfaces';
import { accessControl, lowLearnerAttendanceLimit } from './../../app.config';

Expand Down Expand Up @@ -349,7 +349,7 @@ const Dashboard: React.FC<DashboardProps> = () => {
useEffect(() => {
const getAttendanceStats = async () => {
if (classId !== '' && classId !== 'all') {
const cohortMemberRequest: cohortMemberList = {
const cohortMemberRequest: CohortMemberList = {
limit: 300,
page: 0,
filters: {
Expand Down
5 changes: 0 additions & 5 deletions src/pages/learner-attendance-history.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ const LearnerAttendanceHistory = () => {
const [loading, setLoading] = React.useState(false);
const [selectedDate, setSelectedDate] = useState<Date>(new Date());
const [open, setOpen] = useState(false);
const [modalOpen, setModalOpen] = useState(false);
const [attendanceUpdated, setAttendanceUpdated] = useState(false);
const [learnerAttendance, setLearnerAttendance] = useState<
LearnerAttendanceData | undefined
Expand Down Expand Up @@ -77,10 +76,6 @@ const LearnerAttendanceHistory = () => {
});
};

const handleModalOpen = () => {
setModalOpen(true);
};

const handleModalClose = () => {
setOpen(false);
logEvent({
Expand Down
8 changes: 3 additions & 5 deletions src/pages/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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
Expand All @@ -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';
}
Expand Down Expand Up @@ -354,7 +352,7 @@ const LoginPage = () => {
onChange={(e) => setRememberMe(e.target.checked)}
checked={rememberMe}
/>
<span
<span role='checkbox'
style={{
cursor: 'pointer',
color: theme.palette.warning['300'],
Expand Down
4 changes: 2 additions & 2 deletions src/services/AssesmentService.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {
AssessmentListServiceParam,
gerDoIdServiceParam,
GetDoIdServiceParam,
} from '@/utils/Interfaces';
import { post } from './RestClient';

Expand All @@ -22,7 +22,7 @@ export const AssesmentListService = async ({

export const getDoIdForAssesmentDetails = async ({
filters,
}: gerDoIdServiceParam): Promise<any> => {
}: GetDoIdServiceParam): Promise<any> => {
const apiUrl: string =
'https://sunbirdsaas.com/api/content/v1/search?orgdetails=orgName%2Cemail&licenseDetails=name%2Cdescription%2Curl';

Expand Down
1 change: 0 additions & 1 deletion src/services/CreateUserService.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { get, post } from './RestClient';
import { CreateUserParam } from '../utils/Interfaces';

export const getFormRead = async (
context: string,
Expand Down
10 changes: 5 additions & 5 deletions src/services/MyClassDetailsService.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Role, Status } from '@/utils/app.constant';
import {
cohortMemberList,
CohortMemberList,
UpdateCohortMemberStatusParams,
UserList,
} from '../utils/Interfaces';
Expand All @@ -10,7 +10,7 @@ const fetchCohortMemberList = async ({
limit,
page,
filters,
}: cohortMemberList): Promise<any> => {
}: CohortMemberList): Promise<any> => {
const apiUrl: string = `${process.env.NEXT_PUBLIC_BASE_URL}/cohortmember/list`;
try {
const response = await post(apiUrl, {
Expand Down Expand Up @@ -52,7 +52,7 @@ export const getMyCohortMemberList = async ({
limit,
page,
filters,
}: cohortMemberList): Promise<any> => {
}: CohortMemberList): Promise<any> => {
const studentFilters = {
...filters,
role: Role.STUDENT,
Expand All @@ -65,7 +65,7 @@ export const getMyCohortFacilitatorList = async ({
limit,
page,
filters,
}: cohortMemberList): Promise<any> => {
}: CohortMemberList): Promise<any> => {
const studentFilters = {
...filters,
role: Role.TEACHER,
Expand All @@ -78,7 +78,7 @@ export const getFacilitatorList = async ({
limit,
page,
filters,
}: cohortMemberList): Promise<any> => {
}: CohortMemberList): Promise<any> => {
return fetchCohortMemberList({ limit, page, filters });
};

Expand Down
1 change: 1 addition & 0 deletions src/store/manageUserStore.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-unused-vars */
import { create } from 'zustand';
import { persist } from 'zustand/middleware';

Expand Down
1 change: 1 addition & 0 deletions src/store/mangageTLStore.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-unused-vars */
import { create } from 'zustand';
import { persist } from 'zustand/middleware';

Expand Down
1 change: 1 addition & 0 deletions src/store/reassignLearnerStore.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-unused-vars */
import { create } from 'zustand';
import { persist } from 'zustand/middleware';

Expand Down
1 change: 1 addition & 0 deletions src/store/store.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-unused-vars */
import { create } from 'zustand';
import { persist } from 'zustand/middleware';

Expand Down
3 changes: 1 addition & 2 deletions src/utils/Helper.ts
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down Expand Up @@ -110,7 +109,7 @@ export const debounce = <T extends (...args: any[]) => any>(
let timeout: ReturnType<typeof setTimeout> | undefined;
return function (this: ThisParameterType<T>, ...args: Parameters<T>) {
const context = this;
clearTimeout(timeout!);
clearTimeout(timeout);
if (immediate && !timeout) func.apply(context, args);
timeout = setTimeout(() => {
timeout = undefined;
Expand Down
11 changes: 6 additions & 5 deletions src/utils/Interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-unused-vars */
export interface AttendanceParams {
userId: string;
attendanceDate: string;
Expand Down Expand Up @@ -74,7 +75,7 @@ export interface CohortListParam {
filters: Filters;
}

export interface cohortMemberList {
export interface CohortMemberList {
limit: number;
page: number;
filters: {
Expand Down Expand Up @@ -103,7 +104,7 @@ export interface UserData {
mobile?: string;
}

export interface UserDatas {
export interface IUserData {
name?: any;
}

Expand Down Expand Up @@ -148,7 +149,7 @@ export interface PlannedModalProps {

export interface ScheduleModalProps {
handleClick?: (selection: string) => void;
clickedBox?: String | null;
clickedBox?: string | null;
}

export interface AttendanceStatusListProps {
Expand Down Expand Up @@ -215,7 +216,7 @@ export interface UpdateCustomField {
isEditable?: boolean;
order: number;
}
export interface cohort {
export interface ICohort {
presentPercentage: number;
cohortId: string;
name: string;
Expand Down Expand Up @@ -259,7 +260,7 @@ export interface CohortAttendancePercentParam {
facets: Array<string>;
sort?: Array<string>;
}
export interface gerDoIdServiceParam {
export interface GetDoIdServiceParam {
filters: {
program?: string | string[];
se_boards?: (string | null)[];
Expand Down
6 changes: 3 additions & 3 deletions src/utils/attendanceStats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<number> => {
const response = await getMyCohortMemberList(cohortMemberRequest);
const totalStudentsCount = response?.result?.totalCount;
Expand Down Expand Up @@ -50,7 +50,7 @@ type Result = {
};

export const calculatePercentage = async (
cohortMemberRequest: cohortMemberList,
cohortMemberRequest: CohortMemberList,
attendanceRequest: AttendancePercentageProps
): Promise<Result> => {
const totalStudentsCount = await getTotalStudentCount(cohortMemberRequest);
Expand Down
7 changes: 6 additions & 1 deletion src/utils/hoc/withAccessControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Role } from '../app.constant';
const withAccessControl =
(action: string, accessControl: { [key: string]: Role[] }) =>
(Component: React.ComponentType<any>) => {
return (props: any) => {
const WrappedComponent = (props: any) => {
const store = useStore();
const userRole = store.userRole;
const router = useRouter();
Expand All @@ -28,6 +28,11 @@ const withAccessControl =

return <Component {...props} />;
};

// Setting the display name for better debugging and developer tools
WrappedComponent.displayName = `withAccessControl(${Component.displayName ?? Component.name ?? 'Component'})`;

return WrappedComponent;
};

export default withAccessControl;
3 changes: 2 additions & 1 deletion src/utils/telemetry.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: [],
};
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit cd54353

Please sign in to comment.