refactor: handle api models identifiers
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import {RestLinks} from "~/repositories/models/rest-response.model";
|
||||
|
||||
export interface Question extends RestLinks {
|
||||
id: number;
|
||||
label: string;
|
||||
description: string;
|
||||
}
|
||||
|
@@ -13,7 +13,7 @@ export interface Quiz extends RestLinks {
|
||||
|
||||
export interface Response {
|
||||
axeId: number;
|
||||
questionId: string;
|
||||
questionId: number;
|
||||
score?: number;
|
||||
comment?: string;
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
import {AxiosResponse} from "axios";
|
||||
import {$axios} from "~/utils/api";
|
||||
import {RestResponse} from "~/repositories/models/rest-response.model";
|
||||
import {Question} from "~/repositories/models/question.model";
|
||||
import {$axios} from "~/utils/api";
|
||||
|
||||
export default {
|
||||
findAllByAxeId(axeId: number) {
|
||||
@@ -8,6 +9,12 @@ export default {
|
||||
params: {
|
||||
id: axeId
|
||||
}
|
||||
}).then((response: AxiosResponse<RestResponse<Question>>) => {
|
||||
response.data._embedded.questions.map(question => {
|
||||
question.id = Number(question._links.self.href.replace($axios.defaults.baseURL + "/questions/", ""));
|
||||
return question;
|
||||
});
|
||||
return response;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
import {AxiosResponse} from "axios";
|
||||
import {$axios} from "~/utils/api";
|
||||
import {RestResponse} from "~/repositories/models/rest-response.model";
|
||||
import {Quiz, Response, ResponseWithQuestion, Score} from "~/repositories/models/quiz.model";
|
||||
import {$axios} from "~/utils/api";
|
||||
|
||||
export default {
|
||||
|
||||
@@ -9,7 +10,14 @@ export default {
|
||||
params: {
|
||||
sort: "createdDate,desc"
|
||||
}
|
||||
});
|
||||
})
|
||||
.then((response: AxiosResponse<RestResponse<Quiz>>) => {
|
||||
response.data._embedded.quizzes.map(quiz => {
|
||||
quiz.id = Number(quiz._links.self.href.replace($axios.defaults.baseURL + "/quizzes/", ""));
|
||||
return quiz;
|
||||
});
|
||||
return response;
|
||||
});
|
||||
},
|
||||
|
||||
findScores(quizId: number) {
|
||||
|
Reference in New Issue
Block a user