diff --git a/.env b/.env index 8af8660d..e14fbac6 100644 --- a/.env +++ b/.env @@ -4,5 +4,5 @@ NEXT_PUBLIC_TELEMETRY_URL=https://qa.prathamteacherapp.tekdinext.com NEXT_PUBLIC_NOTIFICATION_BASE_URL=https://notification.prathamdigital.org # NEXT_PUBLIC_NOTIFICATION_BASE_URL=https://qa.prathamteacherapp.tekdinext.com/notification-service NEXT_PUBLIC_SHIKSHALOKAM_API_URL=https://dev.elevate-apis.shikshalokam.org/project/v1 -NEXT_PUBLIC_SHIKSHALOKAM_TOKEN=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjp7ImlkIjoyNjIsIm5hbWUiOiJ0ZWtkaVRlc3RVc2VyIiwic2Vzc2lvbl9pZCI6NjE5NSwib3JnYW5pemF0aW9uX2lkIjoxLCJyb2xlcyI6W3siaWQiOjEyLCJ0aXRsZSI6InByb2dyYW1fZGVzaWduZXIiLCJsYWJlbCI6IlByb2dyYW0gRGVzaWduZXIiLCJ1c2VyX3R5cGUiOjAsInN0YXR1cyI6IkFDVElWRSIsIm9yZ2FuaXphdGlvbl9pZCI6MSwidmlzaWJpbGl0eSI6IlBVQkxJQyJ9LHsiaWQiOjIxLCJ0aXRsZSI6ImRpc3RyaWN0X3Jlc291cmNlX3BlcnNvbiIsImxhYmVsIjoiRGlzdHJpY3QgUmVzb3VyY2UgUGVyc29uIiwidXNlcl90eXBlIjowLCJzdGF0dXMiOiJBQ1RJVkUiLCJvcmdhbml6YXRpb25faWQiOjI0LCJ2aXNpYmlsaXR5IjoiUFVCTElDIn1dfSwiaWF0IjoxNzI0OTI0ODQxLCJleHAiOjE3MjUwMTEyNDF9.832p0WvwJUxa0upAPXufjclF1lDU9NmzMdILLz54afk - +NEXT_PUBLIC_SUNBIRDSAAS_API_URL=https://sunbirdsaas.com +NEXT_PUBLIC_SHIKSHALOKAM_TOKEN=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjp7ImlkIjoyNjIsIm5hbWUiOiJ0ZWtkaVRlc3RVc2VyIiwic2Vzc2lvbl9pZCI6NjI2OSwib3JnYW5pemF0aW9uX2lkIjoxLCJyb2xlcyI6W3siaWQiOjEyLCJ0aXRsZSI6InByb2dyYW1fZGVzaWduZXIiLCJsYWJlbCI6IlByb2dyYW0gRGVzaWduZXIiLCJ1c2VyX3R5cGUiOjAsInN0YXR1cyI6IkFDVElWRSIsIm9yZ2FuaXphdGlvbl9pZCI6MSwidmlzaWJpbGl0eSI6IlBVQkxJQyJ9LHsiaWQiOjIxLCJ0aXRsZSI6ImRpc3RyaWN0X3Jlc291cmNlX3BlcnNvbiIsImxhYmVsIjoiRGlzdHJpY3QgUmVzb3VyY2UgUGVyc29uIiwidXNlcl90eXBlIjowLCJzdGF0dXMiOiJBQ1RJVkUiLCJvcmdhbml6YXRpb25faWQiOjI0LCJ2aXNpYmlsaXR5IjoiUFVCTElDIn1dfSwiaWF0IjoxNzI1MDA0MzI0LCJleHAiOjE3MjUwOTA3MjR9.70SVO8SFauUfeleWHFraai70WPLZSbka2QeEAykSALs \ No newline at end of file diff --git a/src/pages/course-planner/foundation.tsx b/src/pages/course-planner/foundation.tsx index 31c11f73..62436028 100644 --- a/src/pages/course-planner/foundation.tsx +++ b/src/pages/course-planner/foundation.tsx @@ -18,6 +18,7 @@ import { useTranslation } from "next-i18next"; import ProtectedRoute from "../../components/ProtectedRoute"; import cardData from "@/data/cardData"; import Loader from "@/components/Loader"; +import { getChannelDetails } from "@/services/coursePlanner"; const Foundation = () => { const router = useRouter(); @@ -38,12 +39,30 @@ const Foundation = () => { const fetchData = async () => { setTimeout(() => { setLoading(false); - }, 2000); + }, 1000); }; fetchData(); }, []); + useEffect(() => { + const fetchChannelDetails = async () => { + try { + const data = await getChannelDetails(); + console.log(data?.result?.channel?.frameworks); + localStorage.setItem("channelDetails", JSON.stringify(data?.result?.channel?.frameworks)) + } catch (err) { + console.log(err); + + } finally { + setLoading(false); + } + }; + + fetchChannelDetails(); + }, []); + + const handleCardClick = (id: any) => { router.push(`/stateDetails?cardId=${id}`); }; diff --git a/src/pages/csvDetails.tsx b/src/pages/csvDetails.tsx index beb494fb..3c680f03 100644 --- a/src/pages/csvDetails.tsx +++ b/src/pages/csvDetails.tsx @@ -32,7 +32,7 @@ const FileDetails = () => { setSelectedFile({ name: fileName } as File); } setLoading(false); - }, 2000); // Simulated loading time + }, 1000); // Simulated loading time }; fetchFileData(); diff --git a/src/pages/importCsv.tsx b/src/pages/importCsv.tsx index 2b608aa5..c2d172b1 100644 --- a/src/pages/importCsv.tsx +++ b/src/pages/importCsv.tsx @@ -66,7 +66,7 @@ const ImportCsv = () => { } } setLoading(false); - }, 2000); // Simulated loading time + }, 1000); // Simulated loading time }; fetchData(); @@ -77,13 +77,12 @@ const ImportCsv = () => { try { setLoading(true); const response = await getTargetedSolutions({ - subject: 'Marathi', - class: '10', + subject: 'Assamese', + class: '6', state: 'Maharashtra', - board: 'ISEB', + board: 'AAKR', type: 'mainCourse', - role: 'Teacher', - medium: 'Hindi', + medium: 'Assamese', }); const courseData = response.result.data[0]; @@ -116,13 +115,12 @@ const ImportCsv = () => { }); const updatedResponse = await getTargetedSolutions({ - subject: 'Marathi', - class: '10', + subject: 'Assamese', + class: '6', state: 'Maharashtra', - board: 'ISEB', + board: 'AAKR', type: 'mainCourse', - role: 'Teacher', - medium: 'Hindi', + medium: 'Assamese', }); setLoading(false); return updatedResponse.result.data[0]._id; @@ -177,13 +175,12 @@ const ImportCsv = () => { const handleUpload = async () => { if (selectedFile) { const metaData: CoursePlannerMetaData = { - subject: "Marathi", - class: "10", - state: "Maharashtra", - board: "ISEB", - type: "mainCourse", - role: "Teacher", - medium: "Hindi", + subject: 'Assamese', + class: '6', + state: 'Maharashtra', + board: 'AAKR', + type: 'mainCourse', + medium: 'Assamese', }; const result = await uploadCoursePlanner(selectedFile, metaData) @@ -321,7 +318,6 @@ const ImportCsv = () => { showGradeMedium={false} showFoundaitonCourse={false} /> - { const router = useRouter(); - const { cardId } = router.query; + const { boardId, cardId } = router.query; const { t } = useTranslation(); const theme = useTheme(); const isSmallScreen = useMediaQuery(theme.breakpoints.down("sm")); @@ -35,14 +35,28 @@ const StateDetails = () => { const [searchQuery, setSearchQuery] = useState(""); const [selectedOption, setSelectedOption] = useState(""); const [card, setCard] = useState(null); + const [boards, setBoards] = useState([]); useEffect(() => { const fetchData = async () => { setTimeout(() => { const foundCard = cardData.find((c) => c.id === cardId); setCard(foundCard); + + + if (typeof window !== 'undefined') { + const channel = localStorage.getItem('channelDetails'); + + if (channel) { + const parsedBoards = JSON.parse(channel); + setBoards(parsedBoards); + } else { + console.error('No channel details found in localStorage.'); + } + } + setLoading(false); - }, 2000); + }, 1000); }; fetchData(); @@ -129,85 +143,80 @@ const StateDetails = () => { - {card.boards?.map((board: string, index: number) => ( - - { - if (typeof board === "string") { - handleBoardClick(board); - } - }} - > - - - - - {board} - - - - - - - - {card.boardsUploaded} / {card.totalBoards}{" "} - {t("COURSE_PLANNER.SUBJECTS_UPLOADED")} - - - - - - + {boards.map((board: any, index: number) => ( + + { + handleBoardClick(board?.identifier); + }} + > + + + + + {board?.name} + + + + + - - ))}{" "} - + + {card.boardsUploaded} / {card.totalBoards}{" "} + {t("COURSE_PLANNER.SUBJECTS_UPLOADED")} + + + + + + + + + ))} + + ); }; diff --git a/src/pages/subjectDetails.tsx b/src/pages/subjectDetails.tsx index 34c27595..1cf29c59 100644 --- a/src/pages/subjectDetails.tsx +++ b/src/pages/subjectDetails.tsx @@ -16,6 +16,7 @@ import { serverSideTranslations } from "next-i18next/serverSideTranslations"; import FilterSearchBar from "@/components/FilterSearchBar"; import Loader from "@/components/Loader"; import { CircularProgressbar, buildStyles } from "react-circular-progressbar"; +import { getFrameworkDetails } from "@/services/coursePlanner"; // Define Card interface interface Card { @@ -43,6 +44,9 @@ const SubjectDetails = () => { const [loading, setLoading] = useState(true); const [card, setCard] = useState(null); + const [subject, setSubject] = useState(); + const [medium, setMedium] = useState([]); + const [grade, setGrade] = useState([]); useEffect(() => { const fetchData = async () => { @@ -60,12 +64,37 @@ const SubjectDetails = () => { setCard(null); } setLoading(false); - }, 2000); + }, 1000); }; fetchData(); }, [cardId]); + + useEffect(() => { + const fetchFrameworkDetails = async () => { + if (typeof boardId === 'string') { + try { + const data = await getFrameworkDetails(boardId); + console.log(data?.result?.framework); + setSubject(data?.result?.framework?.categories[0]); + setMedium(data?.result?.framework?.categories[1]); + setGrade(data?.result?.framework?.categories[2]); + } catch (err) { + console.error('Failed to fetch framework details'); + } finally { + setLoading(false); + } + } else { + console.error('Invalid boardId'); + setLoading(false); + } + }; + + fetchFrameworkDetails(); + }, [boardId]); + + if (loading) { return ; } @@ -83,7 +112,7 @@ const SubjectDetails = () => { const handleCardClick = (subject: string) => { router.push(`/importCsv?subject=${encodeURIComponent(subject)}`); }; - + return ( { - {card.subjects?.map((subject, index) => ( - handleCardClick(subject)} - > - - - {subject} - - - - - {/* {subject.uploaded} / {subject.total} {"topics uploaded"} */} - - - - - - - ))} + {subject?.terms?.map((subj:any, index:any) => ( + handleCardClick(subj)} + > + + + {subj?.name} {/* Use subj.name */} + + + + {/* {subj.uploaded} / {subj.total} {"topics uploaded"} */} + + + + + + + ))} + + ); }; diff --git a/src/services/coursePlanner.ts b/src/services/coursePlanner.ts index c2fb7a12..fcbbe323 100644 --- a/src/services/coursePlanner.ts +++ b/src/services/coursePlanner.ts @@ -2,6 +2,32 @@ import { CoursePlannerMetaData, GetSolutionDetailsParams, GetTargetedSolutionsPa import { post } from "./RestClient"; import axios from 'axios'; + + +export const getChannelDetails = async (): Promise => { + const apiUrl: string = `${process.env.NEXT_PUBLIC_SUNBIRDSAAS_API_URL}/api/channel/v1/read/01369885294383923244`; + + try { + const response = await axios.get(apiUrl); + return response?.data; + } catch (error) { + console.error('Error in getting Channel Details', error); + return error; + } +}; + +export const getFrameworkDetails = async (frameworkId: string): Promise => { + const apiUrl: string = `${process.env.NEXT_PUBLIC_SUNBIRDSAAS_API_URL}/api/framework/v1/read/${frameworkId}?categories=gradeLevel,medium,class,subject`; + + try { + const response = await axios.get(apiUrl); + return response?.data; + } catch (error) { + console.error('Error in getting Framework Details', error); + return error; + } +}; + export const uploadCoursePlanner = async (file: File, metaData: CoursePlannerMetaData): Promise => { const apiUrl: string = `${process.env.NEXT_PUBLIC_TELEMETRY_URL}/user/v1/course-planner/upload`; const formData = new FormData(); @@ -22,7 +48,7 @@ export const uploadCoursePlanner = async (file: File, metaData: CoursePlannerMet export const getTargetedSolutions = async ({ subject, state, - role, + medium, class: className, board, @@ -38,7 +64,7 @@ export const uploadCoursePlanner = async (file: File, metaData: CoursePlannerMet const data = { subject, state, - role, + medium, class: className, board, diff --git a/src/utils/Interfaces.ts b/src/utils/Interfaces.ts index 87fd9b4c..3754cea3 100644 --- a/src/utils/Interfaces.ts +++ b/src/utils/Interfaces.ts @@ -82,7 +82,7 @@ export interface CoursePlannerMetaData { state: any; board: string; type: string; - role: string; + medium: string; } @@ -90,7 +90,7 @@ export interface CoursePlannerMetaData { export interface GetTargetedSolutionsParams { subject:string, state: string; - role: string; + medium: string class: string; board: string;