style: fix linting issues met Prettier
This commit is contained in:
		
							parent
							
								
									5cea6929f9
								
							
						
					
					
						commit
						a8895cc429
					
				
					 12 changed files with 104 additions and 121 deletions
				
			
		|  | @ -1,40 +1,39 @@ | |||
| import type {AnswerData, AnswerDTO, AnswerId} from "@dwengo-1/common/interfaces/answer"; | ||||
| import {BaseController} from "@/controllers/base-controller.ts"; | ||||
| import type {QuestionId} from "@dwengo-1/common/interfaces/question"; | ||||
| 
 | ||||
| import type { AnswerData, AnswerDTO, AnswerId } from "@dwengo-1/common/interfaces/answer"; | ||||
| import { BaseController } from "@/controllers/base-controller.ts"; | ||||
| import type { QuestionId } from "@dwengo-1/common/interfaces/question"; | ||||
| 
 | ||||
| export interface AnswersResponse { | ||||
|     answers: AnswerDTO[] | AnswerId[] | ||||
|     answers: AnswerDTO[] | AnswerId[]; | ||||
| } | ||||
| 
 | ||||
| export interface AnswerResponse { | ||||
|     answer: AnswerDTO | ||||
|     answer: AnswerDTO; | ||||
| } | ||||
| 
 | ||||
| export class AnswerController extends BaseController { | ||||
|     constructor(questionId: QuestionId) { | ||||
|         this.loId = questionId.learningObjectIdentifier; | ||||
|         this.sequenceNumber = questionId.sequenceNumber; | ||||
|         super(`learningObject/${loId.hruid}/:${loId.version}/questions/${this.sequenceNumber}/answers`) | ||||
|         super(`learningObject/${loId.hruid}/:${loId.version}/questions/${this.sequenceNumber}/answers`); | ||||
|     } | ||||
| 
 | ||||
|     async getAll(full = true): Promise<AnswersResponse> { | ||||
|         return this.get<AnswersResponse>("/", {lang: this.loId.lang, full}); | ||||
|         return this.get<AnswersResponse>("/", { lang: this.loId.lang, full }); | ||||
|     } | ||||
| 
 | ||||
|     async getBy(seq: number): Promise<AnswerResponse> { | ||||
|         return this.get<AnswerResponse>(`/${seq}`, {lang: this.loId.lang}); | ||||
|         return this.get<AnswerResponse>(`/${seq}`, { lang: this.loId.lang }); | ||||
|     } | ||||
| 
 | ||||
|     async create(answerData: AnswerData): Promise<AnswerResponse> { | ||||
|         return this.post<AnswerResponse>("/", answerData, {lang: this.loId.lang}); | ||||
|         return this.post<AnswerResponse>("/", answerData, { lang: this.loId.lang }); | ||||
|     } | ||||
| 
 | ||||
|     async remove(seq: number): Promise<AnswerResponse> { | ||||
|         return this.delete<AnswerResponse>(`/${seq}`, {lang: this.loId.lang}); | ||||
|         return this.delete<AnswerResponse>(`/${seq}`, { lang: this.loId.lang }); | ||||
|     } | ||||
| 
 | ||||
|     async update(seq: number, answerData: AnswerData): Promise<AnswerResponse> { | ||||
|         return this.put<AnswerResponse>(`/${seq}`, answerData,{lang: this.loId.lang}); | ||||
|         return this.put<AnswerResponse>(`/${seq}`, answerData, { lang: this.loId.lang }); | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -28,13 +28,13 @@ export abstract class BaseController { | |||
|     } | ||||
| 
 | ||||
|     protected async delete<T>(path: string, queryParams?: QueryParams): Promise<T> { | ||||
|         const response = await apiClient.delete<T>(this.absolutePathFor(path), { params: queryParams} ); | ||||
|         const response = await apiClient.delete<T>(this.absolutePathFor(path), { params: queryParams }); | ||||
|         BaseController.assertSuccessResponse(response); | ||||
|         return response.data; | ||||
|     } | ||||
| 
 | ||||
|     protected async put<T>(path: string, body: unknown, queryParams?: QueryParams): Promise<T> { | ||||
|         const response = await apiClient.put<T>(this.absolutePathFor(path), body, { params: queryParams}); | ||||
|         const response = await apiClient.put<T>(this.absolutePathFor(path), body, { params: queryParams }); | ||||
|         BaseController.assertSuccessResponse(response); | ||||
|         return response.data; | ||||
|     } | ||||
|  |  | |||
|  | @ -1,6 +1,6 @@ | |||
| import type {QuestionData, QuestionDTO, QuestionId} from "@dwengo-1/common/interfaces/question"; | ||||
| import {BaseController} from "@/controllers/base-controller.ts"; | ||||
| import type {LearningObjectIdentifierDTO} from "@dwengo-1/common/interfaces/learning-content"; | ||||
| import type { QuestionData, QuestionDTO, QuestionId } from "@dwengo-1/common/interfaces/question"; | ||||
| import { BaseController } from "@/controllers/base-controller.ts"; | ||||
| import type { LearningObjectIdentifierDTO } from "@dwengo-1/common/interfaces/learning-content"; | ||||
| 
 | ||||
| export interface QuestionsResponse { | ||||
|     questions: QuestionDTO[] | QuestionId[]; | ||||
|  | @ -17,22 +17,22 @@ export class QuestionController extends BaseController { | |||
|     } | ||||
| 
 | ||||
|     async getAll(full = true): Promise<QuestionsResponse> { | ||||
|         return this.get<QuestionsResponse>("/", {lang: this.loId.lang, full}); | ||||
|         return this.get<QuestionsResponse>("/", { lang: this.loId.lang, full }); | ||||
|     } | ||||
| 
 | ||||
|     async getBy(sequenceNumber: number): Promise<QuestionResponse> { | ||||
|         return this.get<QuestionResponse>(`/${sequenceNumber}`, {lang: this.loId.lang}); | ||||
|         return this.get<QuestionResponse>(`/${sequenceNumber}`, { lang: this.loId.lang }); | ||||
|     } | ||||
| 
 | ||||
|     async create(questionData: QuestionData): Promise<QuestionResponse> { | ||||
|         return this.post<QuestionResponse>("/", questionData, {lang: this.loId.lang}) | ||||
|         return this.post<QuestionResponse>("/", questionData, { lang: this.loId.lang }); | ||||
|     } | ||||
| 
 | ||||
|     async remove(sequenceNumber: number): Promise<QuestionResponse> { | ||||
|         return this.delete<QuestionResponse>(`/${sequenceNumber}`, {lang: this.loId.lang}); | ||||
|         return this.delete<QuestionResponse>(`/${sequenceNumber}`, { lang: this.loId.lang }); | ||||
|     } | ||||
| 
 | ||||
|     async update(sequenceNumber: number, questionData: QuestionData): Promise<QuestionResponse> { | ||||
|         return this.put<QuestionResponse>(`/${sequenceNumber}`, questionData, {lang: this.loId.lang}); | ||||
|         return this.put<QuestionResponse>(`/${sequenceNumber}`, questionData, { lang: this.loId.lang }); | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -1,13 +1,8 @@ | |||
| import type { QuestionId} from "@dwengo-1/common/dist/interfaces/question.ts"; | ||||
| import { type MaybeRefOrGetter, toValue} from "vue"; | ||||
| import { | ||||
|     useMutation, | ||||
|     type UseMutationReturnType, | ||||
|     useQuery, | ||||
|     type UseQueryReturnType | ||||
| } from "@tanstack/vue-query"; | ||||
| import {AnswerController, type AnswerResponse, type AnswersResponse} from "@/controllers/answers.ts"; | ||||
| import type {AnswerData} from "@dwengo-1/common/dist/interfaces/answer.ts"; | ||||
| import type { QuestionId } from "@dwengo-1/common/dist/interfaces/question.ts"; | ||||
| import { type MaybeRefOrGetter, toValue } from "vue"; | ||||
| import { useMutation, type UseMutationReturnType, useQuery, type UseQueryReturnType } from "@tanstack/vue-query"; | ||||
| import { AnswerController, type AnswerResponse, type AnswersResponse } from "@/controllers/answers.ts"; | ||||
| import type { AnswerData } from "@dwengo-1/common/dist/interfaces/answer.ts"; | ||||
| 
 | ||||
| // TODO caching
 | ||||
| 
 | ||||
|  | @ -23,7 +18,7 @@ export function useAnswersQuery( | |||
| 
 | ||||
| export function useAnswerQuery( | ||||
|     questionId: MaybeRefOrGetter<QuestionId>, | ||||
|     sequenceNumber: MaybeRefOrGetter<number> | ||||
|     sequenceNumber: MaybeRefOrGetter<number>, | ||||
| ): UseQueryReturnType<AnswerResponse, Error> { | ||||
|     return useQuery({ | ||||
|         queryFn: async () => new AnswerController(toValue(questionId)).getBy(toValue(sequenceNumber)), | ||||
|  | @ -49,9 +44,8 @@ export function useDeleteAnswerMutation( | |||
| 
 | ||||
| export function useUpdateAnswerMutation( | ||||
|     questionId: MaybeRefOrGetter<QuestionId>, | ||||
| ): UseMutationReturnType<AnswerResponse, Error, { answerData: AnswerData, seq: number }, unknown> { | ||||
| ): UseMutationReturnType<AnswerResponse, Error, { answerData: AnswerData; seq: number }, unknown> { | ||||
|     return useMutation({ | ||||
|         mutationFn: async (data, seq) => new AnswerController(toValue(questionId)).update(seq, data), | ||||
|     }); | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,17 +1,19 @@ | |||
| import {QuestionController, type QuestionResponse, type QuestionsResponse} from "@/controllers/questions.ts"; | ||||
| import type {QuestionData, QuestionId} from "@dwengo-1/common/interfaces/question"; | ||||
| import type {LearningObjectIdentifierDTO} from "@dwengo-1/common/interfaces/learning-content"; | ||||
| import {computed, type MaybeRefOrGetter, toValue} from "vue"; | ||||
| import { QuestionController, type QuestionResponse, type QuestionsResponse } from "@/controllers/questions.ts"; | ||||
| import type { QuestionData, QuestionId } from "@dwengo-1/common/interfaces/question"; | ||||
| import type { LearningObjectIdentifierDTO } from "@dwengo-1/common/interfaces/learning-content"; | ||||
| import { computed, type MaybeRefOrGetter, toValue } from "vue"; | ||||
| import { | ||||
|     useMutation, | ||||
|     type UseMutationReturnType, | ||||
|     useQuery, | ||||
|     useQueryClient, | ||||
|     type UseQueryReturnType | ||||
|     type UseQueryReturnType, | ||||
| } from "@tanstack/vue-query"; | ||||
| 
 | ||||
| 
 | ||||
| export function questionsQueryKey(loId: LearningObjectIdentifierDTO, full: boolean): [string, string, number, string, boolean] { | ||||
| export function questionsQueryKey( | ||||
|     loId: LearningObjectIdentifierDTO, | ||||
|     full: boolean, | ||||
| ): [string, string, number, string, boolean] { | ||||
|     return ["questions", loId.hruid, loId.version, loId.language, full]; | ||||
| } | ||||
| 
 | ||||
|  | @ -65,7 +67,7 @@ export function useUpdateQuestionMutation( | |||
|     const sequenceNumber = toValue(questionId).sequenceNumber; | ||||
| 
 | ||||
|     return useMutation({ | ||||
|         mutationFn: async ( data ) => new QuestionController(loId).update(sequenceNumber, data), | ||||
|         mutationFn: async (data) => new QuestionController(loId).update(sequenceNumber, data), | ||||
|         onSuccess: async () => { | ||||
|             await queryClient.invalidateQueries({ queryKey: questionsQueryKey(toValue(loId), true) }); | ||||
|             await queryClient.invalidateQueries({ queryKey: questionsQueryKey(toValue(loId), false) }); | ||||
|  |  | |||
		Reference in a new issue
	
	 Lint Action
						Lint Action