refactor: handle api models identifiers

This commit is contained in:
2022-10-10 10:29:25 +02:00
parent baccbf8d56
commit 09ff7433ed
9 changed files with 32 additions and 27 deletions

View File

@@ -9,15 +9,15 @@ import {QuizRate, Response} from "~/repositories/models/quiz.model";
})
export default class Quiz extends VuexModule {
responses = new Map<string, QuizRate>;
questionsRatedPerAxe = new Map<number, { questionId: string; rated: boolean }[]>;
responses = new Map<number, QuizRate>;
questionsRatedPerAxe = new Map<number, { questionId: number; rated: boolean }[]>;
@Mutation
initialize(questions: Map<number, Question[]>) {
questions.forEach((questions, axeId) => this.questionsRatedPerAxe.set(axeId, questions.map(value => {
return {
questionId: value._links.self.href,
rated: this.responses.has(value._links.self.href)
questionId: value.id,
rated: this.responses.has(value.id)
}
})));
}