From 9a873e8b70a0b0345037a92b7290e355ef47e538 Mon Sep 17 00:00:00 2001 From: ttpl-rt-217 Date: Tue, 3 Dec 2024 15:01:43 +0530 Subject: [PATCH 1/5] grid Ui issue fix --- src/pages/course-planner/index.tsx | 34 ++++++++++++++---------------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/src/pages/course-planner/index.tsx b/src/pages/course-planner/index.tsx index ccdf74ee..c01d1d66 100644 --- a/src/pages/course-planner/index.tsx +++ b/src/pages/course-planner/index.tsx @@ -202,27 +202,21 @@ const Foundation = () => { {loading ? ( ) : ( - + {t("MASTER.STATE")} - + {role === "Central Admin CCTA" ? stateNames.map((stateName) => ( - + { {/* Add any icon or text for the copy link button */} - + + )) : store?.matchingstate && ( - + { {/* Add any icon or text for the copy link button */} - + + )} - + )} From fcc662f6cf237dc55cab659ea497b25c08f601b8 Mon Sep 17 00:00:00 2001 From: ttpl-rt-217 Date: Tue, 3 Dec 2024 15:15:44 +0530 Subject: [PATCH 2/5] grid Ui issue fix --- src/pages/course-planner/index.tsx | 4 ++-- src/pages/stateDetails.tsx | 19 ++++++++----------- src/pages/subjectDetails.tsx | 10 +++++----- 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/src/pages/course-planner/index.tsx b/src/pages/course-planner/index.tsx index c01d1d66..e0ee956e 100644 --- a/src/pages/course-planner/index.tsx +++ b/src/pages/course-planner/index.tsx @@ -215,8 +215,6 @@ const Foundation = () => { ? stateNames.map((stateName) => ( { "&:hover": { backgroundColor: "#D0C5B4", }, + marginTop: "8px" }} onClick={() => handleCardClick(stateName)} > @@ -268,6 +267,7 @@ const Foundation = () => { "&:hover": { backgroundColor: "#D0C5B4", }, + marginTop:"8px" }} onClick={() => handleCardClick(store.matchingstate.name) diff --git a/src/pages/stateDetails.tsx b/src/pages/stateDetails.tsx index 75a85f15..6759e1cd 100644 --- a/src/pages/stateDetails.tsx +++ b/src/pages/stateDetails.tsx @@ -75,7 +75,7 @@ const StateDetails = () => { - + {state || "States"} @@ -86,24 +86,21 @@ const StateDetails = () => { > Boards: - + {boards.map((board: any, index: number) => ( { handleBoardClick(board.code, board.name); diff --git a/src/pages/subjectDetails.tsx b/src/pages/subjectDetails.tsx index bcd7d913..9cf54751 100644 --- a/src/pages/subjectDetails.tsx +++ b/src/pages/subjectDetails.tsx @@ -821,14 +821,15 @@ const SubjectDetails = () => { sx={{ display: "flex", alignItems: "center", - marginLeft: "10px", marginTop: "16px", marginBottom: "16px", + gap:'5px' }} + onClick={handleBackClick} > - + - + {boardName} {/* Boardasahskj @@ -858,7 +859,6 @@ const SubjectDetails = () => { backgroundColor: "#EAF2FF", transform: "scale(1.02)", }, - marginTop: "12px", }} onClick={() => handleCardClick(subj)} > @@ -883,7 +883,7 @@ const SubjectDetails = () => { Select Medium, Grade, and Type From c2fd75fd2ea4cdc8a1b0fc3cd37325c43ee7524d Mon Sep 17 00:00:00 2001 From: Arif-tekdi-technologies Date: Tue, 3 Dec 2024 15:33:03 +0530 Subject: [PATCH 3/5] Issue #0000 feat: Course planner targettedSolution fixes --- src/pages/importCsv.tsx | 10 +- src/services/coursePlanner.ts | 267 +++++++++++++++++----------------- src/utils/Interfaces.ts | 2 +- 3 files changed, 143 insertions(+), 136 deletions(-) diff --git a/src/pages/importCsv.tsx b/src/pages/importCsv.tsx index 415081aa..bf0a2da4 100644 --- a/src/pages/importCsv.tsx +++ b/src/pages/importCsv.tsx @@ -75,9 +75,9 @@ const ImportCsv = () => { const response = await getTargetedSolutions({ subject: tstore?.taxonomySubject, class: tstore?.taxonomyGrade, - state: tstore?.state, + state: localStorage.getItem("selectedState") || tstore?.state, board: tstore?.board, - type: tstore?.taxonomyType, + courseType: tstore?.taxonomyType, medium: tstore?.taxonomyMedium, }); @@ -115,9 +115,9 @@ const ImportCsv = () => { const updatedResponse = await getTargetedSolutions({ subject: tstore?.taxonomySubject, class: tstore?.taxonomyGrade, - state: tstore?.state, + state: localStorage.getItem("selectedState") || tstore?.state, board: tstore?.board, - type: tstore?.taxonomyType, + courseType: tstore?.taxonomyType, medium: tstore?.taxonomyMedium, }); setLoading(false); @@ -185,7 +185,7 @@ const ImportCsv = () => { const metaData: CoursePlannerMetaData = { subject: tstore?.taxonomySubject, class: tstore?.taxonomyGrade, - state: tstore?.state, + state: localStorage.getItem("selectedState") || tstore?.state, board: tstore?.board, type: tstore?.taxonomyType, medium: tstore?.taxonomyMedium, diff --git a/src/services/coursePlanner.ts b/src/services/coursePlanner.ts index 8087a453..45402da7 100644 --- a/src/services/coursePlanner.ts +++ b/src/services/coursePlanner.ts @@ -1,11 +1,14 @@ -import { CoursePlannerMetaData, GetSolutionDetailsParams, GetTargetedSolutionsParams, GetUserProjectTemplateParams } from "@/utils/Interfaces"; +import { + CoursePlannerMetaData, + GetSolutionDetailsParams, + GetTargetedSolutionsParams, + GetUserProjectTemplateParams, +} from "@/utils/Interfaces"; import { get, post } from "./RestClient"; -import axios from 'axios'; +import axios from "axios"; import { FRAMEWORK_ID } from "../../app.config"; import { URL_CONFIG } from "@/utils/url.config"; - - export const getChannelDetails = async (): Promise => { const apiUrl: string = `/api/framework/v1/read/${FRAMEWORK_ID}`; @@ -13,159 +16,163 @@ export const getChannelDetails = async (): Promise => { const response = await axios.get(apiUrl); return response?.data; } catch (error) { - console.error('Error in getting Channel Details', error); + console.error("Error in getting Channel Details", error); return error; } }; -export const getFrameworkDetails = async (frameworkId: string): Promise => { +export const getFrameworkDetails = async ( + frameworkId: string +): Promise => { const apiUrl: string = `/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); + 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_MIDDLEWARE_URL}/prathamservice/v1/course-planner/upload`; - const formData = new FormData(); - formData.append('file', file); - formData.append('metaData', JSON.stringify(metaData)); - try { - const response = await post(apiUrl, formData, { - }); - return response?.data; - } catch (error) { - console.error('Error uploading course planner', error); - throw error; - } - }; +export const uploadCoursePlanner = async ( + file: File, + metaData: CoursePlannerMetaData +): Promise => { + const apiUrl: string = `${process.env.NEXT_PUBLIC_MIDDLEWARE_URL}/prathamservice/v1/course-planner/upload`; + const formData = new FormData(); + formData.append("file", file); + formData.append("metaData", JSON.stringify(metaData)); + try { + const response = await post(apiUrl, formData, {}); + return response?.data; + } catch (error) { + console.error("Error uploading course planner", error); + throw error; + } +}; + +export const getTargetedSolutions = async ({ + subject, + state, + medium, + class: className, + board, + courseType, +}: GetTargetedSolutionsParams): Promise => { + const apiUrl: string = `${process.env.NEXT_PUBLIC_COURSE_PLANNER_API_URL}/solutions/targetedSolutions?type=improvementProject¤tScopeOnly=true`; + const headers = { + "X-auth-token": localStorage.getItem("token"), + "Content-Type": "application/json", + }; - export const getTargetedSolutions = async ({ + const data = { subject, state, medium, class: className, board, - type, - }: GetTargetedSolutionsParams): Promise => { - const apiUrl: string = `${process.env.NEXT_PUBLIC_COURSE_PLANNER_API_URL}/solutions/targetedSolutions?type=improvementProject¤tScopeOnly=true`; - - const headers = { - 'X-auth-token': localStorage.getItem('token'), - 'Content-Type': 'application/json', - }; - - const data = { - subject, - state, - - medium, - class: className, - board, - type, - }; - - try { - const response = await axios.post(apiUrl, data, { headers }); - return response?.data; - } catch (error) { - console.error('Error in getting Targeted Solutions', error); - return error; - } + courseType, }; - interface GetUserProjectDetailsParams { - id: string; + + try { + const response = await axios.post(apiUrl, data, { headers }); + return response?.data; + } catch (error) { + console.error("Error in getting Targeted Solutions", error); + return error; } - - export const getUserProjectDetails = async ({ id }: GetUserProjectDetailsParams): Promise => { - const apiUrl: string = `${process.env.NEXT_PUBLIC_COURSE_PLANNER_API_URL}/userProjects/details/${id}`; - - const headers = { - 'Authorization': localStorage.getItem('token'), - 'Content-Type': 'application/json', - 'x-auth-token': localStorage.getItem('token'), - - }; - - try { - const response = await axios.post(apiUrl, {}, { headers }); - return response?.data; - } catch (error) { - console.error('Error in getting User Project Details', error); - return error; - } +}; +interface GetUserProjectDetailsParams { + id: string; +} + +export const getUserProjectDetails = async ({ + id, +}: GetUserProjectDetailsParams): Promise => { + const apiUrl: string = `${process.env.NEXT_PUBLIC_COURSE_PLANNER_API_URL}/userProjects/details/${id}`; + + const headers = { + Authorization: localStorage.getItem("token"), + "Content-Type": "application/json", + "x-auth-token": localStorage.getItem("token"), }; - - - export const getSolutionDetails = async ({ id, role }: GetSolutionDetailsParams): Promise => { - const apiUrl: string = `${process.env.NEXT_PUBLIC_COURSE_PLANNER_API_URL}/solutions/details/${id}`; - - const headers = { - 'X-auth-token': localStorage.getItem('token'), - 'Content-Type': 'application/json', - }; - - const data = { - role, - }; - - try { - const response = await axios.post(apiUrl, data, { headers }); - return response?.data; - } catch (error) { - console.error('Error in getting Solution Details', error); - return error; - } + + try { + const response = await axios.post(apiUrl, {}, { headers }); + return response?.data; + } catch (error) { + console.error("Error in getting User Project Details", error); + return error; + } +}; + +export const getSolutionDetails = async ({ + id, + role, +}: GetSolutionDetailsParams): Promise => { + const apiUrl: string = `${process.env.NEXT_PUBLIC_COURSE_PLANNER_API_URL}/solutions/details/${id}`; + + const headers = { + "X-auth-token": localStorage.getItem("token"), + "Content-Type": "application/json", }; - - export const getUserProjectTemplate = async ({ - templateId, - solutionId, + + const data = { role, - }: GetUserProjectTemplateParams): Promise => { - const apiUrl: string = `${process.env.NEXT_PUBLIC_COURSE_PLANNER_API_URL}/userProjects/details?templateId=${templateId}&solutionId=${solutionId}`; - - const headers = { - 'X-auth-token': localStorage.getItem('token'), - 'Content-Type': 'application/json', - }; - - const data = { - role, - }; - - try { - const response = await axios.post(apiUrl, data, { headers }); - return response?.data; - } catch (error) { - console.error('Error in getting User Project Details', error); - throw error; - } }; - - export const getContentHierarchy = async ({ - doId, - }: { - doId: string; - }): Promise => { - const apiUrl: string = `${URL_CONFIG.API.CONTENT_HIERARCHY}/${doId}`; - - try { - console.log('Request data', apiUrl); - const response = await get(apiUrl); - // console.log('response', response); - return response; - } catch (error) { - console.error('Error in getContentHierarchy Service', error); - throw error; - } + + try { + const response = await axios.post(apiUrl, data, { headers }); + return response?.data; + } catch (error) { + console.error("Error in getting Solution Details", error); + return error; + } +}; + +export const getUserProjectTemplate = async ({ + templateId, + solutionId, + role, +}: GetUserProjectTemplateParams): Promise => { + const apiUrl: string = `${process.env.NEXT_PUBLIC_COURSE_PLANNER_API_URL}/userProjects/details?templateId=${templateId}&solutionId=${solutionId}`; + + const headers = { + "X-auth-token": localStorage.getItem("token"), + "Content-Type": "application/json", + }; + + const data = { + role, }; - \ No newline at end of file + + try { + const response = await axios.post(apiUrl, data, { headers }); + return response?.data; + } catch (error) { + console.error("Error in getting User Project Details", error); + throw error; + } +}; + +export const getContentHierarchy = async ({ + doId, +}: { + doId: string; +}): Promise => { + const apiUrl: string = `${URL_CONFIG.API.CONTENT_HIERARCHY}/${doId}`; + + try { + console.log("Request data", apiUrl); + const response = await get(apiUrl); + // console.log('response', response); + return response; + } catch (error) { + console.error("Error in getContentHierarchy Service", error); + throw error; + } +}; diff --git a/src/utils/Interfaces.ts b/src/utils/Interfaces.ts index 7a0b3f04..d8dea478 100644 --- a/src/utils/Interfaces.ts +++ b/src/utils/Interfaces.ts @@ -97,7 +97,7 @@ export interface GetTargetedSolutionsParams { medium: string; class: string; board: string; - type: string; + courseType: string; } export interface GetSolutionDetailsParams { From 655e8d9907a968e65b3ce8ed96585649c8b89496 Mon Sep 17 00:00:00 2001 From: Akshata Katwal Date: Tue, 3 Dec 2024 15:37:14 +0530 Subject: [PATCH 4/5] Issue feat:Call fetch district method after update district --- src/pages/district.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pages/district.tsx b/src/pages/district.tsx index 02ac6eed..d8142233 100644 --- a/src/pages/district.tsx +++ b/src/pages/district.tsx @@ -82,6 +82,8 @@ const District: React.FC = () => { const [pageSizeArray, setPageSizeArray] = useState([5, 10, 20, 50]); const [sortBy, setSortBy] = useState<[string, string]>(["name", "asc"]); const [searchKeyword, setSearchKeyword] = useState(""); + const [fetchDistrict, setFetchDistrict] = useState(true); + const [paginationCount, setPaginationCount] = useState(Numbers.ZERO); const [stateCode, setStateCode] = useState(); const [stateValue, setStateValue] = useState(""); @@ -161,7 +163,7 @@ const District: React.FC = () => { useEffect(() => { fetchDistricts(); - }, []); + }, [fetchDistrict]); // get cohort id of state const getStatecohorts = async () => { let userId: any; @@ -559,6 +561,7 @@ const District: React.FC = () => { }); showToastMessage(t("COMMON.DISTRICT_UPDATED_SUCCESS"), "success"); + setFetchDistrict(!fetchDistrict); const windowUrl = window.location.pathname; const cleanedUrl = windowUrl.replace(/^\//, ''); const env = cleanedUrl.split("/")[0]; From 4f7a3b98a37590f00ef585e7950b4fea49eb06a9 Mon Sep 17 00:00:00 2001 From: Akshata Katwal Date: Tue, 3 Dec 2024 15:49:18 +0530 Subject: [PATCH 5/5] update pr --- src/pages/login.tsx | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/pages/login.tsx b/src/pages/login.tsx index 8d4aae04..634a9ee8 100644 --- a/src/pages/login.tsx +++ b/src/pages/login.tsx @@ -77,7 +77,15 @@ const LoginPage = () => { const token = localStorage.getItem("token"); if (token) { + const { locale } = router; + if(locale) + { + router.push("/centers", undefined, { locale: locale }); + } + else router.push("/centers"); + + } } }, []); @@ -152,9 +160,25 @@ const LoginPage = () => { // router.push("/centers"); if (userInfo?.role === Role.SCTA || userInfo?.role === Role.CCTA) { window.location.href = "/course-planner"; + const { locale } = router; + if(locale) + { + router.push("/course-planner", undefined, { locale: locale }); + } + else + router.push("/course-planner"); + } else { - window.location.href = "/centers"; + //window.location.href = "/centers"; + const { locale } = router; + if(locale) + { + router.push("/centers", undefined, { locale: locale }); + } + else + router.push("/centers"); + } }