diff --git a/src/pages/course-planner.tsx b/src/pages/course-planner.tsx index fde9877a..a5e43355 100644 --- a/src/pages/course-planner.tsx +++ b/src/pages/course-planner.tsx @@ -18,20 +18,16 @@ import { useTheme } from '@mui/material/styles'; import { useTranslation } from 'next-i18next'; import { serverSideTranslations } from 'next-i18next/serverSideTranslations'; import { useRouter } from 'next/router'; -import React from 'react'; +import React, { useEffect } from 'react'; import { CircularProgressbar, buildStyles } from 'react-circular-progressbar'; +import { getCoursePlanner } from '@/services/CoursePlannerService'; +import { CoursePlannerData } from '@/utils/Interfaces'; + +// Define a type for the course planner data const CoursePlanner = () => { const [value, setValue] = React.useState(1); - const [subjects, setSubjects] = React.useState([ - { id: 1, subject: 'Mathematics', circular: 10 }, - { id: 2, subject: 'Science', circular: 50 }, - { id: 2, subject: 'History', circular: 30 }, - { id: 2, subject: 'Geography', circular: 60 }, - { id: 2, subject: 'Marathi', circular: 90 }, - { id: 2, subject: 'Hindi', circular: 70 }, - { id: 2, subject: 'Social Science', circular: 80 }, - ]); + const [subjects, setSubjects] = React.useState([]); const theme = useTheme(); const { t } = useTranslation(); const router = useRouter(); @@ -46,11 +42,30 @@ const CoursePlanner = () => { window.scrollTo({ top: targetY - 70, behavior: 'smooth' }); } }; + const handleChange = (event: React.SyntheticEvent, newValue: number) => { setValue(newValue); }; + + useEffect(() => { + const fetchCoursePlanner = async () => { + try { + const response = await getCoursePlanner(); + const transformedData = response.map((item: any) => ({ + ...item, + id: String(item.id), + })); + setSubjects(transformedData); + } catch (error) { + console.error('Error fetching course planner:', error); + } + }; + + fetchCoursePlanner(); + }, []); + return ( - +
@@ -62,9 +77,9 @@ const CoursePlanner = () => { color: '#4D4639', padding: '20px 20px 5px', }} - width={'100%'} + width="100%" > - + {t('COURSE_PLANNER.COURSE_PLANNER')} @@ -138,7 +153,6 @@ const CoursePlanner = () => { aria-label="secondary tabs example" sx={{ fontSize: '14px', - '& .MuiTab-root': { color: '#4D4639', padding: '0 20px', @@ -173,108 +187,112 @@ const CoursePlanner = () => { }} > - {subjects.map((item, index) => { - return ( - + {subjects.map((item) => ( + + { + router.push(`/course-planner-detail`); // Check route + }} + > { - router.push(`/course-planner-detail`); // Check route + display: 'flex', + justifyContent: 'space-between', + alignItems: 'center', }} > - - + + + + + + - - - - - - - {item.circular}% - - + {item.circular}% + + - - {item.subject} - + + {item.subject} - - - + + + - - ); - })} + + + ))} )} + {value === 2 && ( + + No Data Found + + )} ); }; + export async function getStaticProps({ locale }: any) { return { props: { @@ -283,4 +301,5 @@ export async function getStaticProps({ locale }: any) { }, }; } + export default CoursePlanner; diff --git a/src/services/CoursePlannerService.ts b/src/services/CoursePlannerService.ts new file mode 100644 index 00000000..3d38d723 --- /dev/null +++ b/src/services/CoursePlannerService.ts @@ -0,0 +1,17 @@ +import { CoursePlanner } from '../utils/Interfaces'; + +export const getCoursePlanner = (): CoursePlanner[] => { + // TODO: Add API call here + + const CoursePlannerService: CoursePlanner[] = [ + { id: 1, subject: 'Mathematics', circular: 10 }, + { id: 2, subject: 'Science', circular: 50 }, + { id: 3, subject: 'History', circular: 30 }, + { id: 4, subject: 'Geography', circular: 60 }, + { id: 5, subject: 'Marathi', circular: 90 }, + { id: 6, subject: 'Hindi', circular: 70 }, + { id: 7, subject: 'Social Science', circular: 80 }, + ]; + + return CoursePlannerService; +}; diff --git a/src/utils/Interfaces.ts b/src/utils/Interfaces.ts index b914f08f..87192aa5 100644 --- a/src/utils/Interfaces.ts +++ b/src/utils/Interfaces.ts @@ -347,7 +347,16 @@ export interface Session { subtopic?: string; url?: string; } - +export interface CoursePlanner { + id: number; + subject?: string; + circular?:number; +} +export interface CoursePlanner { + id: number; + subject?: string; + circular?:number +} export interface SessionCardFooterProps { item: Session; } @@ -438,3 +447,10 @@ export interface eventFilters { title?: string; status?: []; } + + +export interface CoursePlannerData { + id: string; + subject: string; + circular: number; +};