From ae4b71534fa9fe81fbcc7b48365267f5921bc1f8 Mon Sep 17 00:00:00 2001 From: Arif Date: Wed, 28 Aug 2024 11:36:18 +0530 Subject: [PATCH] Issue #PS-1775 feat: Course planner API integration to View list of Topics and Sub-Topics --- .env | 4 +++- public/locales/en/common.json | 1 + src/pages/course-planner-detail.tsx | 26 ++++++++++++++------------ src/pages/topic-detail-view.tsx | 2 +- src/services/CoursePlannerService.ts | 10 +++++++--- src/utils/Interfaces.ts | 4 +++- 6 files changed, 29 insertions(+), 18 deletions(-) diff --git a/.env b/.env index 840b1f00..0d396ebc 100644 --- a/.env +++ b/.env @@ -4,4 +4,6 @@ NEXT_PUBLIC_EVENT_BASE_URL=https://event-pratham.tekdinext.com/event-service/eve NEXT_PUBLIC_NOTIFICATION_BASE_URL=https://notification.prathamdigital.org NEXT_PUBLIC_TELEMETRY_URL=https://qa.prathamteacherapp.tekdinext.com NEXT_PUBLIC_MEASUREMENT_ID= G-GNMQZ8Z65Z -NEXT_PUBLIC_TRACKING_API_URL=https://tracking-pratham.tekdinext.com \ No newline at end of file +NEXT_PUBLIC_TRACKING_API_URL=https://tracking-pratham.tekdinext.com +NEXT_PUBLIC_SHIKSHALOKAM_API_URL=https://dev.elevate-apis.shikshalokam.org/project/v1 +NEXT_PUBLIC_SHIKSHALOKAM_TOKEN=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjp7ImlkIjoyNjIsIm5hbWUiOiJ0ZWtkaVRlc3RVc2VyIiwic2Vzc2lvbl9pZCI6NjExNiwib3JnYW5pemF0aW9uX2lkIjoxLCJyb2xlcyI6W3siaWQiOjEyLCJ0aXRsZSI6InByb2dyYW1fZGVzaWduZXIiLCJsYWJlbCI6IlByb2dyYW0gRGVzaWduZXIiLCJ1c2VyX3R5cGUiOjAsInN0YXR1cyI6IkFDVElWRSIsIm9yZ2FuaXphdGlvbl9pZCI6MSwidmlzaWJpbGl0eSI6IlBVQkxJQyJ9LHsiaWQiOjIxLCJ0aXRsZSI6ImRpc3RyaWN0X3Jlc291cmNlX3BlcnNvbiIsImxhYmVsIjoiRGlzdHJpY3QgUmVzb3VyY2UgUGVyc29uIiwidXNlcl90eXBlIjowLCJzdGF0dXMiOiJBQ1RJVkUiLCJvcmdhbml6YXRpb25faWQiOjI0LCJ2aXNpYmlsaXR5IjoiUFVCTElDIn1dfSwiaWF0IjoxNzI0ODI1MDM5LCJleHAiOjE3MjQ5MTE0Mzl9.HAK4_MAo-8tqxcVoLNDRuyNj_S_hqM8X5Pya1gKPXKg \ No newline at end of file diff --git a/public/locales/en/common.json b/public/locales/en/common.json index 85a15e17..f67574f6 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -353,6 +353,7 @@ "TOPIC": "Topic", "SUBTOPIC": "Sub Topic", "FACILITATORS": " Facilitators Pre-requisites", + "LEARNERS": " Learners Pre-requisites", "TITLE": "Title", "DELETE_SESSION": "Delete Session", "SCHEDULE": "Schedule", diff --git a/src/pages/course-planner-detail.tsx b/src/pages/course-planner-detail.tsx index f8a1a6d9..014f4ec6 100644 --- a/src/pages/course-planner-detail.tsx +++ b/src/pages/course-planner-detail.tsx @@ -37,7 +37,7 @@ const CoursePlannerDetail = () => { const [expandedPanels, setExpandedPanels] = useState<{ [key: string]: boolean; }>({ - 'panel1-header': false, + 'panel1-header': true, 'panel2-header': false, // || example for multiple accordions do this dynamically // Add more panels if needed }); @@ -50,16 +50,18 @@ const CoursePlannerDetail = () => { const fetchCourseDetails = useCallback(() => { getTargetedSolutions({ - state: 'Maharashtra', - role: 'Learner,Teacher', - class: '10', - board: 'cbse', - courseType: 'foundationCourse', + subject: "Marathi", + class: "10", + state: "Maharasthra", + board: "NIOS", + type: "foundationCourse", + role: "Teacher", + medium: "English" }).then((response) => { const courseId = response.result.data[0]._id; setCourseDetails(response.result.data); - return getUserProjectDetails({ id: '66c8313f6cf0bfa90315ff2e' }); + return getUserProjectDetails({ id: '66cdb0c86a33880d1f4d60d7' }); }).then((userProjectDetailsResponse) => { setUserProjectDetails(userProjectDetailsResponse.result.tasks); }).catch((error) => { @@ -235,11 +237,11 @@ const CoursePlannerDetail = () => { {userProjectDetails.map((topic:any, index) => ( setExpandedPanels((prev) => ({ ...prev, - [`panel${index}-header`]: !prev[`panel${index}-header`], + [`panel1-header`]: !prev[`panel1-header`], })) } sx={{ @@ -293,7 +295,7 @@ const CoursePlannerDetail = () => { - {getAbbreviatedMonth(topic?.metaInformation.startDate)}, {getAbbreviatedMonth(topic?.metaInformation.endDate)} + {getAbbreviatedMonth(topic?.metaInformation?.startDate)}, {getAbbreviatedMonth(topic?.metaInformation?.endDate)} @@ -354,7 +356,7 @@ const CoursePlannerDetail = () => { borderRadius: '8px', }} > - {getAbbreviatedMonth(subTopic.metaInformation.startDate)} + {getAbbreviatedMonth(subTopic?.metaInformation?.startDate)} { setResources(subTopic); router.push(`/topic-detail-view`); }}> - {`${subTopic.learningResources.length} ${t('COURSE_PLANNER.RESOURCES')}`} + {`${subTopic?.learningResources?.length} ${t('COURSE_PLANNER.RESOURCES')}`} diff --git a/src/pages/topic-detail-view.tsx b/src/pages/topic-detail-view.tsx index b13d4402..ddb8bdf5 100644 --- a/src/pages/topic-detail-view.tsx +++ b/src/pages/topic-detail-view.tsx @@ -151,7 +151,7 @@ const TopicDetailView = () => { fontSize="14px" sx={{ color: theme?.palette?.warning['300'] }} > - {t('CENTER_SESSION.FACILITATORS')} + {t('CENTER_SESSION.LEARNERS')} { export const getTargetedSolutions = async ({ + subject, state, role, + medium, class: className, board, - courseType, + type, }: GetTargetedSolutionsParams): Promise => { - const apiUrl: string = `${process.env.NEXT_PUBLIC_SHIKSHALOKAM_API_URL}/solutions/targetedSolutions?type=improvementProject`; + const apiUrl: string = `${process.env.NEXT_PUBLIC_SHIKSHALOKAM_API_URL}/solutions/targetedSolutions?type=improvementProject¤tScopeOnly=true`; const headers = { 'X-auth-token': process.env.NEXT_PUBLIC_SHIKSHALOKAM_TOKEN, @@ -33,11 +35,13 @@ export const getTargetedSolutions = async ({ }; const data = { + subject, state, role, + medium, class: className, board, - courseType, + type, }; try { diff --git a/src/utils/Interfaces.ts b/src/utils/Interfaces.ts index 0dd921d0..47f6f927 100644 --- a/src/utils/Interfaces.ts +++ b/src/utils/Interfaces.ts @@ -595,11 +595,13 @@ export interface IAssessmentStatusOptions { } export interface GetTargetedSolutionsParams { + subject:string, state: string; role: string; + medium: string class: string; board: string; - courseType: string; + type: string; } export interface GetUserProjectDetailsParams {