From eab9eca5458d05b57e605d7edc104f52533736fa Mon Sep 17 00:00:00 2001 From: Arif Date: Thu, 22 Aug 2024 18:54:17 +0530 Subject: [PATCH] Issue #PS-1775 feat: Course planner API integration to View list of Topics and Sub-Topics --- src/pages/course-planner-detail.tsx | 460 +++++++--------------------- 1 file changed, 110 insertions(+), 350 deletions(-) diff --git a/src/pages/course-planner-detail.tsx b/src/pages/course-planner-detail.tsx index 3810dafd..71ab7382 100644 --- a/src/pages/course-planner-detail.tsx +++ b/src/pages/course-planner-detail.tsx @@ -42,7 +42,7 @@ const CoursePlannerDetail = () => { const [modalOpen, setModalOpen] = React.useState(false); const [courseDetails, setCourseDetails] = useState(null); - const [userProjectDetails, setUserProjectDetails] = useState(null); + const [userProjectDetails, setUserProjectDetails] = useState([]); const fetchCourseDetails = useCallback(() => { getTargetedSolutions({ @@ -57,7 +57,7 @@ const CoursePlannerDetail = () => { return getUserProjectDetails({ id: courseId }); }).then((userProjectDetailsResponse) => { - setUserProjectDetails(userProjectDetailsResponse); + setUserProjectDetails(userProjectDetailsResponse.result.tasks); }).catch((error) => { console.error('Error fetching course planner:', error); }); @@ -109,6 +109,9 @@ const CoursePlannerDetail = () => { // setModalOpen(true); // }; + console.log(userProjectDetails); + + return ( <>
@@ -218,50 +221,87 @@ const CoursePlannerDetail = () => { - ( + + + setExpandedPanels((prev) => ({ + ...prev, + [`panel${index}-header`]: !prev[`panel${index}-header`], + })) + } + sx={{ + boxShadow: 'none', + background: '#F1E7D9', + border: 'none', + transition: '0.3s', + }} + > + + } + aria-controls={`panel${index}-content`} + id={`panel${index}-header`} + className="accordion-summary" sx={{ - borderRadius: '8px', + px: '16px', + m: 0, + '&.Mui-expanded': { + minHeight: '48px', + }, }} > - - setExpandedPanels((prev) => ({ - ...prev, - 'panel1-header': !prev['panel1-header'], - })) - } + - - } - aria-controls="panel1-content" - id="panel1-header" - className="accordion-summary" + + + + {`Topic ${index + 1} - ${topic.name}`} + + + + {/* Here you can add dynamic date or other information if needed */} + Jan, Feb + + + + + {topic.children.map((subTopic:any) => ( + { display: 'flex', justifyContent: 'space-between', alignItems: 'center', - gap: '5px', - }} - > - - - Topic 1 - Real Numbers {/* will come from API */} - - - - Jan, Feb {/* will come from API */} - - - - - - - { - router.push(`/topic-detail-view`); - }} - > - The Fundamental Theorem of Arithmetic - {/* will come from API */} - - - - JAN - - - - - { router.push(`/topic-detail-view`); }} > - - 5 {t('COURSE_PLANNER.RESOURCES')} - - + {subTopic.name} - - - - { - router.push(`/topic-detail-view`); + padding: '5px', + background: ' #C1D6FF', + fontSize: '12px', + fontWeight: '500', + color: '#4D4639', + borderRadius: '8px', }} > - Irrational Numbers - {/* will come from API */} + JAN - - - JAN - - - - - { - router.push(`/topic-detail-view`); - }} - > - - 4 {t('COURSE_PLANNER.RESOURCES')} - - + /> - - - - - - - - - setExpandedPanels((prev) => ({ - ...prev, - 'panel2-header': !prev['panel2-header'], - })) - } - sx={{ - boxShadow: 'none', - background: '#F1E7D9', - border: 'none', - transition: '0.3s', - }} - > - - } - aria-controls="panel1-content" - id="panel2-header" - className="accordion-summary" - sx={{ - px: '16px', - m: 0, - '&.Mui-expanded': { - minHeight: '48px', - }, - }} - > - - - - Topic 2 - Polynomials {/* will come from API */} - - - - Jan, Feb {/* will come from API */} - - - - - - { + router.push(`/topic-detail-view`); }} > - - { - router.push(`/topic-detail-view`); - }} - > - Zeroes of a Polynomial - Geometrical Meaning - {/* will come from API */} - - - - JAN - - - - - { - router.push(`/topic-detail-view`); - }} - > - - 2 {t('COURSE_PLANNER.RESOURCES')} - - + + {`${subTopic.children.length} ${t('COURSE_PLANNER.RESOURCES')}`} + - - - - + + ))} + + + + ))} +