Skip to content

Commit

Permalink
Issue #0000 feat: Course planner targettedSolution fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Arif-tekdi-technologies committed Dec 3, 2024
1 parent 5f26a83 commit c2fd75f
Show file tree
Hide file tree
Showing 3 changed files with 143 additions and 136 deletions.
10 changes: 5 additions & 5 deletions src/pages/importCsv.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand Down
267 changes: 137 additions & 130 deletions src/services/coursePlanner.ts
Original file line number Diff line number Diff line change
@@ -1,171 +1,178 @@
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<any> => {
const apiUrl: string = `/api/framework/v1/read/${FRAMEWORK_ID}`;

try {
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<any> => {
export const getFrameworkDetails = async (
frameworkId: string
): Promise<any> => {
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<any> => {
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<any> => {
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<any> => {
const apiUrl: string = `${process.env.NEXT_PUBLIC_COURSE_PLANNER_API_URL}/solutions/targetedSolutions?type=improvementProject&currentScopeOnly=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<any> => {
const apiUrl: string = `${process.env.NEXT_PUBLIC_COURSE_PLANNER_API_URL}/solutions/targetedSolutions?type=improvementProject&currentScopeOnly=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<any> => {
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<any> => {
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<any> => {
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<any> => {
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<any> => {
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<any> => {
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<any> => {
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<any> => {
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;
}
};
2 changes: 1 addition & 1 deletion src/utils/Interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export interface GetTargetedSolutionsParams {
medium: string;
class: string;
board: string;
type: string;
courseType: string;
}

export interface GetSolutionDetailsParams {
Expand Down

0 comments on commit c2fd75f

Please sign in to comment.