From fcb4205dded5e02ada2ea910528004a38277763b Mon Sep 17 00:00:00 2001 From: vivek kasture Date: Wed, 25 Sep 2024 14:24:20 +0530 Subject: [PATCH] Issue #PS-000 fix: Fixed UT issues --- src/pages/course-planner.tsx | 156 +++++++++++++++++++---------------- 1 file changed, 85 insertions(+), 71 deletions(-) diff --git a/src/pages/course-planner.tsx b/src/pages/course-planner.tsx index 9e12459a..80845f5f 100644 --- a/src/pages/course-planner.tsx +++ b/src/pages/course-planner.tsx @@ -1,18 +1,26 @@ import Header from '@/components/Header'; +import { getCohortSearch } from '@/services/CohortServices'; +import coursePlannerStore from '@/store/coursePlannerStore'; +import useStore from '@/store/store'; +import taxonomyStore from '@/store/taxonomyStore'; +import { CoursePlannerConstants } from '@/utils/app.constant'; +import { + filterAndMapAssociationsNew, + findCommonAssociations, + getAssociationsByCodeNew, + getOptionsByCategory, + toPascalCase, +} from '@/utils/Helper'; +import withAccessControl from '@/utils/hoc/withAccessControl'; +import { CoursePlannerData, ICohort } from '@/utils/Interfaces'; import KeyboardArrowRightIcon from '@mui/icons-material/KeyboardArrowRight'; -import SearchIcon from '@mui/icons-material/Search'; import { Box, FormControl, Grid, - IconButton, - InputBase, InputLabel, MenuItem, - Paper, Select, - Tab, - Tabs, Typography, } from '@mui/material'; import { useTheme } from '@mui/material/styles'; @@ -20,25 +28,8 @@ import { useTranslation } from 'next-i18next'; import { serverSideTranslations } from 'next-i18next/serverSideTranslations'; import { useRouter } from 'next/router'; import React, { useEffect, useState } from 'react'; -import { CircularProgressbar, buildStyles } from 'react-circular-progressbar'; -import { getCoursePlanner } from '@/services/CoursePlannerService'; -import { CoursePlannerData } from '@/utils/Interfaces'; -import useCourseStore from '@/store/coursePlannerStore'; -import { getCohortSearch } from '@/services/CohortServices'; -import { CoursePlannerConstants } from '@/utils/app.constant'; -import useStore from '@/store/store'; import { accessControl, frameworkId } from '../../app.config'; -import withAccessControl from '@/utils/hoc/withAccessControl'; -import NoDataFound from '@/components/common/NoDataFound'; -import taxonomyStore from '@/store/taxonomyStore'; -import coursePlannerStore from '@/store/coursePlannerStore'; -import { - filterAndMapAssociationsNew, - findCommonAssociations, - getAssociationsByCodeNew, - getOptionsByCategory, - toPascalCase, -} from '@/utils/Helper'; +import CohortSelectionSection from '@/components/CohortSelectionSection'; const CoursePlanner = () => { const [value, setValue] = React.useState(''); @@ -71,13 +62,20 @@ const CoursePlanner = () => { const [stateOption, setStateOption] = useState([]); const [stateAssociations, setStateAssociations] = useState([]); const setTaxonomySubject = taxonomyStore((state) => state.setTaxonomySubject); + const [classId, setClassId] = useState(''); + const [userId, setUserId] = useState(null); + const [isAuthenticated, setIsAuthenticated] = useState(false); + const [loading, setLoading] = useState(false); + const [isLoading, setIsLoading] = useState(false); + const [cohortsData, setCohortsData] = useState>([]); + const [manipulatedCohortData, setManipulatedCohortData] = + useState>(cohortsData); const handleChange = (event: any) => { setValue(event.target.value); setType(event.target.value); }; - const addQueryParams = (newParams: any) => { // Merge existing query params with new ones const updatedQuery = { ...router.query, ...newParams }; @@ -98,6 +96,13 @@ const CoursePlanner = () => { addQueryParams({ center: event.target.value }); }; + useEffect(() => { + if (classId) { + setSelectedValue(classId); + addQueryParams({ center: classId }); + } + }, [classId]); + useEffect(() => { const subjects = localStorage.getItem('overallCommonSubjects'); if (subjects) { @@ -105,10 +110,10 @@ const CoursePlanner = () => { const parsedData = JSON.parse(subjects); setSubjects(parsedData); } catch (error) { - console.error("Failed to parse subjects from localStorage:", error); + console.error('Failed to parse subjects from localStorage:', error); } } else { - console.log("No subjects found in localStorage."); + console.log('No subjects found in localStorage.'); setSubjects([]); } }, []); @@ -459,7 +464,10 @@ const CoursePlanner = () => { const overallCommonSubjects = await findOverallCommonSubjects(arrays); - localStorage.setItem('overallCommonSubjects', JSON.stringify(overallCommonSubjects)); + localStorage.setItem( + 'overallCommonSubjects', + JSON.stringify(overallCommonSubjects) + ); setSubjects(overallCommonSubjects); } } @@ -491,7 +499,7 @@ const CoursePlanner = () => { - + {/* @@ -534,52 +542,58 @@ const CoursePlanner = () => { - - {/* - - - - - - - */} + */} + + + + + + + + + + + + + Course Type + + + - - Course Type - - -