Skip to content

Commit

Permalink
Issue #PS-1775 feat: Course planner API integration to View list of T…
Browse files Browse the repository at this point in the history
…opics and Sub-Topics
  • Loading branch information
Aar-if committed Aug 28, 2024
1 parent dc3c792 commit ae4b715
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 18 deletions.
4 changes: 3 additions & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -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
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
1 change: 1 addition & 0 deletions public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
26 changes: 14 additions & 12 deletions src/pages/course-planner-detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
Expand All @@ -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) => {
Expand Down Expand Up @@ -235,11 +237,11 @@ const CoursePlannerDetail = () => {
{userProjectDetails.map((topic:any, index) => (
<Box key={topic._id} sx={{ borderRadius: '8px', mb: 2 }}>
<Accordion
expanded={expandedPanels[`panel${index}-header`] || false}
expanded={expandedPanels[`panel1-header`] || false}
onChange={() =>
setExpandedPanels((prev) => ({
...prev,
[`panel${index}-header`]: !prev[`panel${index}-header`],
[`panel1-header`]: !prev[`panel1-header`],
}))
}
sx={{
Expand Down Expand Up @@ -293,7 +295,7 @@ const CoursePlannerDetail = () => {
</Typography>
</Box>
<Typography fontWeight="600" fontSize="12px" color="#7C766F">
{getAbbreviatedMonth(topic?.metaInformation.startDate)}, {getAbbreviatedMonth(topic?.metaInformation.endDate)}
{getAbbreviatedMonth(topic?.metaInformation?.startDate)}, {getAbbreviatedMonth(topic?.metaInformation?.endDate)}
</Typography>
</Box>
</AccordionSummary>
Expand Down Expand Up @@ -354,7 +356,7 @@ const CoursePlannerDetail = () => {
borderRadius: '8px',
}}
>
{getAbbreviatedMonth(subTopic.metaInformation.startDate)}
{getAbbreviatedMonth(subTopic?.metaInformation?.startDate)}
</Box>
<CheckCircleIcon
onClick={toggleDrawer(true)}
Expand Down Expand Up @@ -383,7 +385,7 @@ const CoursePlannerDetail = () => {
setResources(subTopic);
router.push(`/topic-detail-view`);
}}>
{`${subTopic.learningResources.length} ${t('COURSE_PLANNER.RESOURCES')}`}
{`${subTopic?.learningResources?.length} ${t('COURSE_PLANNER.RESOURCES')}`}
</Box>
<ArrowForwardIcon sx={{ fontSize: '16px' }} />
</Box>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/topic-detail-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ const TopicDetailView = () => {
fontSize="14px"
sx={{ color: theme?.palette?.warning['300'] }}
>
{t('CENTER_SESSION.FACILITATORS')}
{t('CENTER_SESSION.LEARNERS')}
</Typography>
</AccordionSummary>
<AccordionDetails
Expand Down
10 changes: 7 additions & 3 deletions src/services/CoursePlannerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,29 @@ export const getCoursePlanner = (): CoursePlanner[] => {


export const getTargetedSolutions = async ({
subject,
state,
role,
medium,
class: className,
board,
courseType,
type,
}: GetTargetedSolutionsParams): Promise<any> => {
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&currentScopeOnly=true`;

const headers = {
'X-auth-token': process.env.NEXT_PUBLIC_SHIKSHALOKAM_TOKEN,
'Content-Type': 'application/json',
};

const data = {
subject,
state,
role,
medium,
class: className,
board,
courseType,
type,
};

try {
Expand Down
4 changes: 3 additions & 1 deletion src/utils/Interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit ae4b715

Please sign in to comment.