From 110fef02ead6f39085201da39a447156a03936aa Mon Sep 17 00:00:00 2001 From: Arif Date: Tue, 3 Sep 2024 16:07:48 +0530 Subject: [PATCH] Issue #PS-1775 feat: Course planner API integration to View list of Topics and Sub-Topics --- src/pages/importCsv.tsx | 14 ++++++++------ src/pages/stateDetails.tsx | 7 +++++-- src/pages/subjectDetails.tsx | 13 ++++++++----- src/store/coursePlannerStore.js | 22 ++++++++++++++++++++++ 4 files changed, 43 insertions(+), 13 deletions(-) create mode 100644 src/store/coursePlannerStore.js diff --git a/src/pages/importCsv.tsx b/src/pages/importCsv.tsx index be2ab0fe..7a115c4a 100644 --- a/src/pages/importCsv.tsx +++ b/src/pages/importCsv.tsx @@ -31,9 +31,11 @@ import KeyboardBackspaceOutlinedIcon from '@mui/icons-material/KeyboardBackspace import RadioButtonUncheckedIcon from '@mui/icons-material/RadioButtonUnchecked'; import dayjs from 'dayjs'; import { Role } from "@/utils/app.constant"; +import coursePlannerStore from "@/store/coursePlannerStore"; const ImportCsv = () => { const router = useRouter(); + const store = coursePlannerStore(); const { subject } = router.query; const { t } = useTranslation(); const [subjectDetails, setSubjectDetails] = useState(null); @@ -77,10 +79,10 @@ const ImportCsv = () => { try { setLoading(true); const response = await getTargetedSolutions({ - subject: 'Tamil', + subject: store?.taxanomySubject, class: '4', state: 'Maharashtra', - board: 'TQKR', + board: store?.boardName, type: 'mainCourse', medium: 'Telugu', }); @@ -115,10 +117,10 @@ const ImportCsv = () => { }); const updatedResponse = await getTargetedSolutions({ - subject: 'Tamil', + subject: store?.taxanomySubject, class: '4', state: 'Maharashtra', - board: 'TQKR', + board: store?.boardName, type: 'mainCourse', medium: 'Telugu', }); @@ -175,10 +177,10 @@ const ImportCsv = () => { const handleUpload = async () => { if (selectedFile) { const metaData: CoursePlannerMetaData = { - subject: 'Tamil', + subject: store?.taxanomySubject, class: '4', state: 'Maharashtra', - board: 'TQKR', + board: store?.boardName, type: 'mainCourse', medium: 'Telugu', }; diff --git a/src/pages/stateDetails.tsx b/src/pages/stateDetails.tsx index 22fc9002..b57e4c35 100644 --- a/src/pages/stateDetails.tsx +++ b/src/pages/stateDetails.tsx @@ -20,6 +20,7 @@ import CustomStepper from "@/components/Steper"; import { useTranslation } from "next-i18next"; import Loader from "@/components/Loader"; import { CircularProgressbar, buildStyles } from "react-circular-progressbar"; +import coursePlannerStore from "@/store/coursePlannerStore"; const StateDetails = () => { const router = useRouter(); @@ -36,6 +37,7 @@ const StateDetails = () => { const [selectedOption, setSelectedOption] = useState(""); const [card, setCard] = useState(null); const [boards, setBoards] = useState([]); + const setBoardname = coursePlannerStore((state) => state.setBoardname); useEffect(() => { const fetchData = async () => { @@ -82,11 +84,12 @@ const StateDetails = () => { setSelectedOption(event.target.value); }; - const handleBoardClick = (board: string) => { + const handleBoardClick = (board: string, boardName: string) => { router.push({ pathname: "/subjectDetails", query: { boardId: board, cardId: card.id }, }); + setBoardname(boardName) }; const handleCopyLink = (state: string) => { @@ -161,7 +164,7 @@ const StateDetails = () => { justifyContent: 'space-between' }} onClick={() => { - handleBoardClick(board?.identifier); + handleBoardClick(board?.identifier, board?.name); }} > diff --git a/src/pages/subjectDetails.tsx b/src/pages/subjectDetails.tsx index 3a11e36c..89ee9cd3 100644 --- a/src/pages/subjectDetails.tsx +++ b/src/pages/subjectDetails.tsx @@ -17,6 +17,7 @@ import FilterSearchBar from "@/components/FilterSearchBar"; import Loader from "@/components/Loader"; import { CircularProgressbar, buildStyles } from "react-circular-progressbar"; import { getFrameworkDetails } from "@/services/coursePlanner"; +import coursePlannerStore from "@/store/coursePlannerStore"; // Define Card interface interface Card { @@ -47,7 +48,8 @@ const SubjectDetails = () => { const [subject, setSubject] = useState(); const [medium, setMedium] = useState([]); const [grade, setGrade] = useState([]); - + const setTaxanomySubject = coursePlannerStore((state) => state.setTaxanomySubject); + useEffect(() => { const fetchData = async () => { setTimeout(() => { @@ -105,12 +107,13 @@ const SubjectDetails = () => { router.back(); }; - const handleCopyLink = (subject: string) => {}; + const handleCopyLink = (subject: any) => {}; - const handleCardClick = (subject: string) => { - router.push(`/importCsv?subject=${encodeURIComponent(subject)}`); + const handleCardClick = (subject: any) => { + router.push(`/importCsv?subject=${encodeURIComponent(subject?.name)}`); + setTaxanomySubject(subject?.name); }; - + return ( ({ + boardName: "", + taxanomySubject: "", + setBoardname: (newBoardname) => + set((state) => ({ boardName: newBoardname })), + setTaxanomySubject: (newTaxanomySubject) => + set((state) => ({ taxanomySubject: newTaxanomySubject})), + }), + { + name: "adminApp", + getStorage: () => localStorage, + } + ) +); + +export default coursePlannerStore;