diff --git a/backend/src/controllers/teachers.ts b/backend/src/controllers/teachers.ts index c7b05f9f..5022dddb 100644 --- a/backend/src/controllers/teachers.ts +++ b/backend/src/controllers/teachers.ts @@ -10,11 +10,11 @@ import { getTeacherQuestions, updateClassJoinRequestStatus, } from '../services/teachers.js'; -import { ClassDTO } from '../interfaces/class.js'; -import { StudentDTO } from '../interfaces/student.js'; -import { QuestionDTO, QuestionId } from '../interfaces/question.js'; -import { TeacherDTO } from '../interfaces/teacher.js'; import { requireFields } from './error-helper.js'; +import {TeacherDTO} from "dwengo-1-common/src/interfaces/teacher"; +import {ClassDTO} from "dwengo-1-common/src/interfaces/class"; +import {StudentDTO} from "dwengo-1-common/src/interfaces/student"; +import {QuestionDTO, QuestionId} from "dwengo-1-common/src/interfaces/question"; export async function getAllTeachersHandler(req: Request, res: Response): Promise { const full = req.query.full === 'true'; diff --git a/backend/src/interfaces/answer.ts b/backend/src/interfaces/answer.ts index f268730a..aff16d76 100644 --- a/backend/src/interfaces/answer.ts +++ b/backend/src/interfaces/answer.ts @@ -16,10 +16,10 @@ export function mapToAnswerDTO(answer: Answer): AnswerDTO { }; } -export function mapToAnswerId(answer: AnswerDTO): AnswerId { +export function mapToAnswerDTOId(answer: Answer): AnswerId { return { author: answer.author.username, toQuestion: mapToQuestionDTOId(answer.toQuestion), - sequenceNumber: answer.sequenceNumber, + sequenceNumber: answer.sequenceNumber!, }; } diff --git a/backend/src/interfaces/question.ts b/backend/src/interfaces/question.ts index e4b1eb8f..04846bb9 100644 --- a/backend/src/interfaces/question.ts +++ b/backend/src/interfaces/question.ts @@ -1,6 +1,7 @@ import { Question } from '../entities/questions/question.entity.js'; import { mapToStudentDTO } from './student.js'; import { QuestionDTO, QuestionId } from 'dwengo-1-common/src/interfaces/question'; +import {LearningObjectIdentifier} from "../entities/content/learning-object-identifier"; function getLearningObjectIdentifier(question: Question): LearningObjectIdentifier { return { diff --git a/backend/src/interfaces/student-request.ts b/backend/src/interfaces/student-request.ts index ec6dd41e..4424f913 100644 --- a/backend/src/interfaces/student-request.ts +++ b/backend/src/interfaces/student-request.ts @@ -1,16 +1,12 @@ -import { mapToStudentDTO, StudentDTO } from './student.js'; +import { mapToStudentDTO } from './student.js'; import { ClassJoinRequest, ClassJoinRequestStatus } from '../entities/classes/class-join-request.entity.js'; import { getClassJoinRequestRepository } from '../data/repositories.js'; import { Student } from '../entities/users/student.entity.js'; import { Class } from '../entities/classes/class.entity.js'; +import {ClassJoinRequestDTO} from "dwengo-1-common/src/interfaces/class-join-request"; -export interface StudentRequestDTO { - requester: StudentDTO; - class: string; - status: ClassJoinRequestStatus; -} -export function mapToStudentRequestDTO(request: ClassJoinRequest): StudentRequestDTO { +export function mapToStudentRequestDTO(request: ClassJoinRequest): ClassJoinRequestDTO { return { requester: mapToStudentDTO(request.requester), class: request.class.classId!, diff --git a/backend/src/services/questions.ts b/backend/src/services/questions.ts index 589ae115..55fb8710 100644 --- a/backend/src/services/questions.ts +++ b/backend/src/services/questions.ts @@ -1,11 +1,13 @@ import { getAnswerRepository, getQuestionRepository } from '../data/repositories.js'; -import {mapToQuestionDTO, mapToQuestionDTOId, QuestionDTO, QuestionId} from '../interfaces/question.js'; +import {mapToQuestionDTO, mapToQuestionDTOId } from '../interfaces/question.js'; import { Question } from '../entities/questions/question.entity.js'; import { Answer } from '../entities/questions/answer.entity.js'; -import { AnswerDTO, AnswerId, mapToAnswerDTO, mapToAnswerDTOId } from '../interfaces/answer.js'; +import {mapToAnswerDTO, mapToAnswerDTOId} from '../interfaces/answer.js'; import { QuestionRepository } from '../data/questions/question-repository.js'; import { LearningObjectIdentifier } from '../entities/content/learning-object-identifier.js'; import { mapToStudent } from '../interfaces/student.js'; +import {QuestionDTO, QuestionId} from "dwengo-1-common/src/interfaces/question"; +import {AnswerDTO, AnswerId} from "dwengo-1-common/src/interfaces/answer"; export async function getAllQuestions(id: LearningObjectIdentifier, full: boolean): Promise { const questionRepository: QuestionRepository = getQuestionRepository(); diff --git a/backend/tests/controllers/students.test.ts b/backend/tests/controllers/students.test.ts index cf72f28c..b0ab3299 100644 --- a/backend/tests/controllers/students.test.ts +++ b/backend/tests/controllers/students.test.ts @@ -19,7 +19,7 @@ import { NotFoundException } from '../../src/exceptions/not-found-exception.js'; import { BadRequestException } from '../../src/exceptions/bad-request-exception.js'; import { ConflictException } from '../../src/exceptions/conflict-exception.js'; import { EntityAlreadyExistsException } from '../../src/exceptions/entity-already-exists-exception.js'; -import { StudentDTO } from '../../src/interfaces/student.js'; +import {StudentDTO} from "dwengo-1-common/src/interfaces/student"; describe('Student controllers', () => { let req: Partial; diff --git a/backend/tests/controllers/teachers.test.ts b/backend/tests/controllers/teachers.test.ts index a0b5f648..10e618b1 100644 --- a/backend/tests/controllers/teachers.test.ts +++ b/backend/tests/controllers/teachers.test.ts @@ -15,7 +15,8 @@ import { import { BadRequestException } from '../../src/exceptions/bad-request-exception.js'; import { EntityAlreadyExistsException } from '../../src/exceptions/entity-already-exists-exception.js'; import { getStudentRequestsHandler } from '../../src/controllers/students.js'; -import { TeacherDTO } from '../../src/interfaces/teacher.js'; +import {TeacherDTO} from "dwengo-1-common/src/interfaces/teacher"; + describe('Teacher controllers', () => { let req: Partial; diff --git a/common/src/interfaces/class-join-request.d.ts b/common/src/interfaces/class-join-request.d.ts new file mode 100644 index 00000000..090646a8 --- /dev/null +++ b/common/src/interfaces/class-join-request.d.ts @@ -0,0 +1,7 @@ +import {StudentDTO} from "./student"; + +export interface ClassJoinRequestDTO { + requester: StudentDTO; + class: string; + status: ClassJoinRequestStatus; +} diff --git a/common/src/interfaces/student.d.ts b/common/src/interfaces/student.d.ts index cb13d3c2..7ec628b4 100644 --- a/common/src/interfaces/student.d.ts +++ b/common/src/interfaces/student.d.ts @@ -3,10 +3,4 @@ export interface StudentDTO { username: string; firstName: string; lastName: string; - endpoints?: { - classes: string; - questions: string; - invitations: string; - groups: string; - }; } diff --git a/frontend/src/controllers/assignments.ts b/frontend/src/controllers/assignments.ts new file mode 100644 index 00000000..7b275c25 --- /dev/null +++ b/frontend/src/controllers/assignments.ts @@ -0,0 +1,3 @@ +import type {AssignmentDTO} from "dwengo-1-common/src/interfaces/assignment"; + +export type AssignmentsResponse = { assignments: AssignmentDTO[] }; // TODO ID diff --git a/frontend/src/controllers/classes.ts b/frontend/src/controllers/classes.ts new file mode 100644 index 00000000..79475e00 --- /dev/null +++ b/frontend/src/controllers/classes.ts @@ -0,0 +1,3 @@ +import type {ClassDTO} from "dwengo-1-common/src/interfaces/class"; + +export type ClassesResponse = { classes: ClassDTO[] | string[] }; diff --git a/frontend/src/controllers/groups.ts b/frontend/src/controllers/groups.ts new file mode 100644 index 00000000..bf946080 --- /dev/null +++ b/frontend/src/controllers/groups.ts @@ -0,0 +1,3 @@ +import type {GroupDTO} from "dwengo-1-common/src/interfaces/group"; + +export type GroupsResponse = { groups: GroupDTO[] }; // | TODO id diff --git a/frontend/src/controllers/questions.ts b/frontend/src/controllers/questions.ts new file mode 100644 index 00000000..40be2f37 --- /dev/null +++ b/frontend/src/controllers/questions.ts @@ -0,0 +1,3 @@ +import type {QuestionDTO, QuestionId} from "dwengo-1-common/src/interfaces/question"; + +export type QuestionsResponse = { questions: QuestionDTO[] | QuestionId[] } diff --git a/frontend/src/controllers/students.ts b/frontend/src/controllers/students.ts index 425bc018..d221f5d3 100644 --- a/frontend/src/controllers/students.ts +++ b/frontend/src/controllers/students.ts @@ -1,59 +1,72 @@ import { BaseController } from "@/controllers/base-controller.ts"; +import type {StudentDTO} from "dwengo-1-common/src/interfaces/student"; +import type {ClassesResponse} from "@/controllers/classes.ts"; +import type {AssignmentsResponse} from "@/controllers/assignments.ts"; +import type {GroupsResponse} from "@/controllers/groups.ts"; +import type {SubmissionsResponse} from "@/controllers/submissions.ts"; +import type {QuestionsResponse} from "@/controllers/questions.ts"; +import type {ClassJoinRequestDTO} from "dwengo-1-common/src/interfaces/class-join-request"; + +export type StudentsResponse = { students: StudentDTO[] | string[] }; +export type StudentResponse = { student: StudentDTO }; +export type JoinRequestsResponse = { requests: ClassJoinRequestDTO[] }; +export type JoinRequestResponse = { request: ClassJoinRequestDTO }; + export class StudentController extends BaseController { constructor() { super("student"); } - getAll(full = true) { - return this.get<{ students: any[] }>("/", { full }); + async getAll(full = true): Promise { + return this.get("/", { full }); } - getByUsername(username: string) { - return this.get<{ student: any }>(`/${username}`); + async getByUsername(username: string): Promise { + return this.get(`/${username}`); } - createStudent(data: any) { - return this.post("/", data); + async createStudent(data: StudentDTO): Promise { + return this.post("/", data); } - deleteStudent(username: string) { - return this.delete(`/${username}`); + async deleteStudent(username: string): Promise { + return this.delete(`/${username}`); } - getClasses(username: string, full = true) { - return this.get<{ classes: any[] }>(`/${username}/classes`, { full }); + async getClasses(username: string, full = true): Promise { + return this.get(`/${username}/classes`, { full }); } - getAssignments(username: string, full = true) { - return this.get<{ assignments: any[] }>(`/${username}/assignments`, { full }); + async getAssignments(username: string, full = true): Promise { + return this.get(`/${username}/assignments`, { full }); } - getGroups(username: string, full = true) { - return this.get<{ groups: any[] }>(`/${username}/groups`, { full }); + async getGroups(username: string, full = true): Promise { + return this.get(`/${username}/groups`, { full }); } - getSubmissions(username: string) { - return this.get<{ submissions: any[] }>(`/${username}/submissions`); + async getSubmissions(username: string): Promise { + return this.get(`/${username}/submissions`); } - getQuestions(username: string, full = true) { - return this.get<{ questions: any[] }>(`/${username}/questions`, { full }); + async getQuestions(username: string, full = true): Promise { + return this.get(`/${username}/questions`, { full }); } - getJoinRequests(username: string) { - return this.get<{ requests: any[] }>(`/${username}/joinRequests`); + async getJoinRequests(username: string): Promise { + return this.get(`/${username}/joinRequests`); } - getJoinRequest(username: string, classId: string) { - return this.get<{ request: any[] }>(`/${username}/joinRequests/${classId}`); + async getJoinRequest(username: string, classId: string): Promise { + return this.get(`/${username}/joinRequests/${classId}`); } - createJoinRequest(username: string, classId: string) { - return this.post(`/${username}/joinRequests}`, classId); + async createJoinRequest(username: string, classId: string): Promise { + return this.post(`/${username}/joinRequests}`, classId); } - deleteJoinRequest(username: string, classId: string) { - return this.delete(`/${username}/joinRequests/${classId}`); + async deleteJoinRequest(username: string, classId: string): Promise { + return this.delete(`/${username}/joinRequests/${classId}`); } } diff --git a/frontend/src/controllers/submissions.ts b/frontend/src/controllers/submissions.ts new file mode 100644 index 00000000..f3f23f85 --- /dev/null +++ b/frontend/src/controllers/submissions.ts @@ -0,0 +1,3 @@ +import {type SubmissionDTO, SubmissionDTOId} from "dwengo-1-common/src/interfaces/submission"; + +export type SubmissionsResponse = { submissions: SubmissionDTO[] | SubmissionDTOId[] }; diff --git a/frontend/src/controllers/teachers.ts b/frontend/src/controllers/teachers.ts index cdbacae7..f6162818 100644 --- a/frontend/src/controllers/teachers.ts +++ b/frontend/src/controllers/teachers.ts @@ -1,44 +1,52 @@ import { BaseController } from "@/controllers/base-controller.ts"; +import type {JoinRequestResponse, JoinRequestsResponse, StudentsResponse} from "@/controllers/students.ts"; +import type {QuestionsResponse} from "@/controllers/questions.ts"; +import type {ClassesResponse} from "@/controllers/classes.ts"; +import type {TeacherDTO} from "dwengo-1-common/src/interfaces/teacher"; + +export type TeachersResponse = { teachers: TeacherDTO[] | string[] }; +export type TeacherResponse = { teacher: TeacherDTO | string }; + export class TeacherController extends BaseController { constructor() { super("teacher"); } - getAll(full = false) { - return this.get<{ teachers: any[] }>("/", { full }); + async getAll(full = false): Promise { + return this.get("/", { full }); } - getByUsername(username: string) { - return this.get(`/${username}`); + async getByUsername(username: string): Promise { + return this.get(`/${username}`); } - createTeacher(data: any) { - return this.post("/", data); + async createTeacher(data: any): Promise { + return this.post("/", data); } - deleteTeacher(username: string) { - return this.delete(`/${username}`); + async deleteTeacher(username: string): Promise { + return this.delete(`/${username}`); } - getClasses(username: string, full = false) { - return this.get(`/${username}/classes`, { full }); + async getClasses(username: string, full = false): Promise { + return this.get(`/${username}/classes`, { full }); } - getStudents(username: string, full = false) { - return this.get<{ students: any[] }>(`/${username}/students`, { full }); + async getStudents(username: string, full = false): Promise { + return this.get(`/${username}/students`, { full }); } - getQuestions(username: string, full = false) { - return this.get<{ questions: any[] }>(`/${username}/questions`, { full }); + async getQuestions(username: string, full = false): Promise { + return this.get(`/${username}/questions`, { full }); } - getStudentJoinRequests(username: string, classId: string) { - return this.get<{ joinRequests: any[] }>(`/${username}/joinRequests/${classId}`); + async getStudentJoinRequests(username: string, classId: string): Promise { + return this.get(`/${username}/joinRequests/${classId}`); } - updateStudentJoinRequest(teacherUsername: string, classId: string, studentUsername: string, accepted: boolean) { - return this.put(`/${teacherUsername}/joinRequests/${classId}/${studentUsername}`, accepted); + async updateStudentJoinRequest(teacherUsername: string, classId: string, studentUsername: string, accepted: boolean): Promise { + return this.put(`/${teacherUsername}/joinRequests/${classId}/${studentUsername}`, accepted); } // GetInvitations(id: string) {return this.get<{ invitations: string[] }>(`/${id}/invitations`);} diff --git a/frontend/src/queries/students.ts b/frontend/src/queries/students.ts index d1f06fa6..810c5529 100644 --- a/frontend/src/queries/students.ts +++ b/frontend/src/queries/students.ts @@ -18,14 +18,14 @@ const STUDENT_JOIN_REQUESTS_QUERY_KEY = (username: string) => ["student-join-req export function useStudentsQuery(full: MaybeRefOrGetter = true) { return useQuery({ queryKey: computed(() => STUDENTS_QUERY_KEY(toValue(full))), - queryFn: () => studentController.getAll(toValue(full)), + queryFn: async () => studentController.getAll(toValue(full)), }); } export function useStudentQuery(username: MaybeRefOrGetter) { return useQuery({ queryKey: computed(() => STUDENT_QUERY_KEY(toValue(username)!)), - queryFn: () => studentController.getByUsername(toValue(username)!), + queryFn: async () => studentController.getByUsername(toValue(username)!), enabled: () => Boolean(toValue(username)), }); } @@ -36,7 +36,7 @@ export function useStudentClassesQuery( ) { return useQuery({ queryKey: computed(() => STUDENT_CLASSES_QUERY_KEY(toValue(username)!, toValue(full))), - queryFn: () => studentController.getClasses(toValue(username)!, toValue(full)), + queryFn: async () => studentController.getClasses(toValue(username)!, toValue(full)), enabled: () => Boolean(toValue(username)), }); } @@ -47,7 +47,7 @@ export function useStudentAssignmentsQuery( ) { return useQuery({ queryKey: computed(() => STUDENT_ASSIGNMENTS_QUERY_KEY(toValue(username)!, toValue(full))), - queryFn: () => studentController.getAssignments(toValue(username)!, toValue(full)), + queryFn: async () => studentController.getAssignments(toValue(username)!, toValue(full)), enabled: () => Boolean(toValue(username)), }); } @@ -58,7 +58,7 @@ export function useStudentGroupsQuery( ) { return useQuery({ queryKey: computed(() => STUDENT_GROUPS_QUERY_KEY(toValue(username)!, toValue(full))), - queryFn: () => studentController.getGroups(toValue(username)!, toValue(full)), + queryFn: async () => studentController.getGroups(toValue(username)!, toValue(full)), enabled: () => Boolean(toValue(username)), }); } @@ -66,7 +66,7 @@ export function useStudentGroupsQuery( export function useStudentSubmissionsQuery(username: MaybeRefOrGetter) { return useQuery({ queryKey: computed(() => STUDENT_SUBMISSIONS_QUERY_KEY(toValue(username)!)), - queryFn: () => studentController.getSubmissions(toValue(username)!), + queryFn: async () => studentController.getSubmissions(toValue(username)!), enabled: () => Boolean(toValue(username)), }); } @@ -77,7 +77,7 @@ export function useStudentQuestionsQuery( ) { return useQuery({ queryKey: computed(() => STUDENT_QUESTIONS_QUERY_KEY(toValue(username)!, toValue(full))), - queryFn: () => studentController.getQuestions(toValue(username)!, toValue(full)), + queryFn: async () => studentController.getQuestions(toValue(username)!, toValue(full)), enabled: () => Boolean(toValue(username)), }); } @@ -86,7 +86,7 @@ export function useCreateStudentMutation() { const queryClient = useQueryClient(); return useMutation({ - mutationFn: (data: any) => studentController.createStudent(data), + mutationFn: async (data: any) => studentController.createStudent(data), onSuccess: () => { await queryClient.invalidateQueries({ queryKey: ["students"] }); }, @@ -103,7 +103,7 @@ export function useDeleteStudentMutation() { const queryClient = useQueryClient(); return useMutation({ - mutationFn: (username: string) => studentController.deleteStudent(username), + mutationFn: async (username: string) => studentController.deleteStudent(username), onSuccess: () => { await queryClient.invalidateQueries({ queryKey: ["students"] }); }, @@ -116,7 +116,7 @@ export function useDeleteStudentMutation() { export function useStudentJoinRequestsQuery(username: MaybeRefOrGetter) { return useQuery({ queryKey: computed(() => STUDENT_JOIN_REQUESTS_QUERY_KEY(toValue(username)!)), - queryFn: () => studentController.getJoinRequests(toValue(username)!), + queryFn: async () => studentController.getJoinRequests(toValue(username)!), enabled: () => Boolean(toValue(username)), }); } @@ -127,7 +127,7 @@ export function useStudentJoinRequestQuery( ) { return useQuery({ queryKey: computed(() => STUDENT_JOIN_REQUESTS_QUERY_KEY(toValue(username)!)), - queryFn: () => studentController.getJoinRequest(toValue(username)!, toValue(classId)!), + queryFn: async () => studentController.getJoinRequest(toValue(username)!, toValue(classId)!), enabled: () => Boolean(toValue(username)), }); } @@ -139,7 +139,7 @@ export function useCreateJoinRequestMutation() { const queryClient = useQueryClient(); return useMutation({ - mutationFn: ({ username, classId }: { username: string; classId: string }) => + mutationFn: async ({ username, classId }: { username: string; classId: string }) => studentController.createJoinRequest(username, classId), onSuccess: (_, { username }) => { await queryClient.invalidateQueries({ queryKey: STUDENT_JOIN_REQUESTS_QUERY_KEY(username) }); @@ -157,7 +157,7 @@ export function useDeleteJoinRequestMutation() { const queryClient = useQueryClient(); return useMutation({ - mutationFn: ({ username, classId }: { username: string; classId: string }) => + mutationFn: async ({ username, classId }: { username: string; classId: string }) => studentController.deleteJoinRequest(username, classId), onSuccess: (_, { username }) => { await queryClient.invalidateQueries({ queryKey: STUDENT_JOIN_REQUESTS_QUERY_KEY(username) }); diff --git a/frontend/src/queries/teachers.ts b/frontend/src/queries/teachers.ts index f8ba0f6a..3daf9e1f 100644 --- a/frontend/src/queries/teachers.ts +++ b/frontend/src/queries/teachers.ts @@ -16,14 +16,14 @@ const JOIN_REQUESTS_QUERY_KEY = (username: string, classId: string) => ["join-re export function useTeachersQuery(full: MaybeRefOrGetter = false) { return useQuery({ queryKey: computed(() => TEACHERS_QUERY_KEY(toValue(full))), - queryFn: () => teacherController.getAll(toValue(full)), + queryFn: async () => teacherController.getAll(toValue(full)), }); } export function useTeacherQuery(username: MaybeRefOrGetter) { return useQuery({ queryKey: computed(() => TEACHER_QUERY_KEY(toValue(username)!)), - queryFn: () => teacherController.getByUsername(toValue(username)!), + queryFn: async () => teacherController.getByUsername(toValue(username)!), enabled: () => Boolean(toValue(username)), }); } @@ -34,7 +34,7 @@ export function useTeacherClassesQuery( ) { return useQuery({ queryKey: computed(() => TEACHER_CLASSES_QUERY_KEY(toValue(username)!, toValue(full))), - queryFn: () => teacherController.getClasses(toValue(username)!, toValue(full)), + queryFn: async () => teacherController.getClasses(toValue(username)!, toValue(full)), enabled: () => Boolean(toValue(username)), }); } @@ -45,7 +45,7 @@ export function useTeacherStudentsQuery( ) { return useQuery({ queryKey: computed(() => TEACHER_STUDENTS_QUERY_KEY(toValue(username)!, toValue(full))), - queryFn: () => teacherController.getStudents(toValue(username)!, toValue(full)), + queryFn: async () => teacherController.getStudents(toValue(username)!, toValue(full)), enabled: () => Boolean(toValue(username)), }); } @@ -56,7 +56,7 @@ export function useTeacherQuestionsQuery( ) { return useQuery({ queryKey: computed(() => TEACHER_QUESTIONS_QUERY_KEY(toValue(username)!, toValue(full))), - queryFn: () => teacherController.getQuestions(toValue(username)!, toValue(full)), + queryFn: async () => teacherController.getQuestions(toValue(username)!, toValue(full)), enabled: () => Boolean(toValue(username)), }); } @@ -67,7 +67,7 @@ export function useTeacherJoinRequestsQuery( ) { return useQuery({ queryKey: computed(() => JOIN_REQUESTS_QUERY_KEY(toValue(username)!, toValue(classId)!)), - queryFn: () => teacherController.getStudentJoinRequests(toValue(username)!, toValue(classId)!), + queryFn: async () => teacherController.getStudentJoinRequests(toValue(username)!, toValue(classId)!), enabled: () => Boolean(toValue(username)) && Boolean(toValue(classId)), }); } @@ -76,7 +76,7 @@ export function useCreateTeacherMutation() { const queryClient = useQueryClient(); return useMutation({ - mutationFn: (data: any) => teacherController.createTeacher(data), + mutationFn: async (data: any) => teacherController.createTeacher(data), onSuccess: () => { await queryClient.invalidateQueries({ queryKey: ["teachers"] }); }, @@ -90,7 +90,7 @@ export function useDeleteTeacherMutation() { const queryClient = useQueryClient(); return useMutation({ - mutationFn: (username: string) => teacherController.deleteTeacher(username), + mutationFn: async (username: string) => teacherController.deleteTeacher(username), onSuccess: () => { await queryClient.invalidateQueries({ queryKey: ["teachers"] }); }, @@ -104,7 +104,7 @@ export function useUpdateJoinRequestMutation() { const queryClient = useQueryClient(); return useMutation({ - mutationFn: ({ + mutationFn: async ({ teacherUsername, classId, studentUsername, diff --git a/frontend/src/queries/themes.ts b/frontend/src/queries/themes.ts index 17264a96..65bf9237 100644 --- a/frontend/src/queries/themes.ts +++ b/frontend/src/queries/themes.ts @@ -7,7 +7,7 @@ const themeController = new ThemeController(); export function useThemeQuery(language: MaybeRefOrGetter) { return useQuery({ queryKey: ["themes", language], - queryFn: () => { + queryFn: async () => { const lang = toValue(language); return themeController.getAll(lang); }, @@ -18,7 +18,7 @@ export function useThemeQuery(language: MaybeRefOrGetter) { export function useThemeHruidsQuery(themeKey: MaybeRefOrGetter) { return useQuery({ queryKey: ["theme-hruids", themeKey], - queryFn: () => themeController.getHruidsByKey(toValue(themeKey)!), + queryFn: async () => themeController.getHruidsByKey(toValue(themeKey)!), enabled: Boolean(themeKey), }); } diff --git a/tsconfig.json b/tsconfig.json index b41449cf..29c81809 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -120,6 +120,6 @@ // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ "skipLibCheck": true, /* Skip type checking all .d.ts files. */ - "resolveJsonModule": true + "resolveJsonModule": true, } }