Skip to content

Commit

Permalink
web: fix handling of non-generic questions
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs committed May 9, 2024
1 parent fa2045e commit 8fe1f5e
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions web/src/client/questions.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function buildQuestion(httpQuestion) {

if (httpQuestion.withPassword) {
question.type = QUESTION_TYPES.withPassword;
question.password = httpQuestion.withPassword.Password;
question.password = httpQuestion.withPassword.password;
}

return question;
Expand Down Expand Up @@ -74,7 +74,7 @@ class QuestionsClient {
async getQuestions() {
const response = await this.client.get("/questions");
if (!response.ok) {
console.log("Failed to get questions: ", response);
console.warn("Failed to get questions: ", response);
return [];
}
const questions = await response.json();
Expand All @@ -87,11 +87,9 @@ class QuestionsClient {
* @param {Object} question
*/
answer(question) {
let answer;
const answer = { generic: { answer: question.answer } };
if (question.type === QUESTION_TYPES.withPassword) {
answer = { withPassword: { password: question.password } };
} else {
answer = { generic: { answer: question.answer } };
answer.withPassword = { password: question.password };
}

const path = `/questions/${question.id}/answer`;
Expand Down

0 comments on commit 8fe1f5e

Please sign in to comment.