✨ completed routing for questions
This commit is contained in:
parent
7e00f24fbd
commit
b22140ba3f
11 changed files with 115 additions and 47 deletions
43
frontend/src/api/getUserQuestions.ts
Normal file
43
frontend/src/api/getUserQuestions.ts
Normal file
|
@ -0,0 +1,43 @@
|
|||
interface Question {
|
||||
QuestionID: number;
|
||||
QuestionText: string;
|
||||
}
|
||||
|
||||
interface Answer {
|
||||
AnswerID: number;
|
||||
QuestionID: number;
|
||||
IsChatGPT: boolean;
|
||||
AnswerText: string;
|
||||
}
|
||||
|
||||
interface QuestionAnswerPair {
|
||||
Question: Question;
|
||||
Answers: Answer[];
|
||||
}
|
||||
|
||||
interface QAData {
|
||||
questions: QuestionAnswerPair[];
|
||||
}
|
||||
|
||||
export const getUserQuestions = (respondentID: number): Promise<QAData> => {
|
||||
let url = `http://localhost:8080/userquestions?respondentID=${respondentID}`;
|
||||
|
||||
const response = fetch(url, {
|
||||
method: "GET",
|
||||
})
|
||||
.then((response) => {
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP error! Status: ${response.status}`);
|
||||
}
|
||||
return response.json();
|
||||
})
|
||||
.then((data) => {
|
||||
console.log(data);
|
||||
localStorage.setItem("userQuestions", JSON.stringify(data));
|
||||
return data;
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log(error);
|
||||
});
|
||||
return response;
|
||||
};
|
|
@ -7,7 +7,7 @@ export const postUserformData = (
|
|||
education: string,
|
||||
healthcare_personnel: string,
|
||||
gender: string
|
||||
): postUserformDataReponse => {
|
||||
): Promise<postUserformDataReponse> => {
|
||||
let url = "http://localhost:8080/submitform";
|
||||
let personnel = healthcare_personnel == "Ja" ? true : false;
|
||||
|
||||
|
|
Reference in a new issue