diff --git a/backend/src/data/themes.ts b/backend/src/data/themes.ts index b0fc930c..edbdb113 100644 --- a/backend/src/data/themes.ts +++ b/backend/src/data/themes.ts @@ -1,7 +1,4 @@ -export interface Theme { - title: string; - hruids: string[]; -} +import {Theme} from "dwengo-1-common/src/interfaces/theme"; export const themes: Theme[] = [ { diff --git a/common/src/interfaces/theme.d.ts b/common/src/interfaces/theme.d.ts new file mode 100644 index 00000000..5334b775 --- /dev/null +++ b/common/src/interfaces/theme.d.ts @@ -0,0 +1,4 @@ +export interface Theme { + title: string; + hruids: string[]; +} diff --git a/frontend/src/controllers/themes.ts b/frontend/src/controllers/themes.ts index d6c8be98..7804f2b7 100644 --- a/frontend/src/controllers/themes.ts +++ b/frontend/src/controllers/themes.ts @@ -1,11 +1,12 @@ import { BaseController } from "@/controllers/base-controller.ts"; +import type {Theme} from "dwengo-1-common/src/interfaces/theme"; export class ThemeController extends BaseController { constructor() { super("theme"); } - async getAll(language: string | null = null): Promise { + async getAll(language: string | null = null): Promise { const query = language ? { language } : undefined; return this.get("/", query); } diff --git a/frontend/src/queries/teachers.ts b/frontend/src/queries/teachers.ts index 3ab1f39b..3bd625b1 100644 --- a/frontend/src/queries/teachers.ts +++ b/frontend/src/queries/teachers.ts @@ -43,7 +43,7 @@ export function useTeachersQuery( ): UseQueryReturnType { return useQuery({ queryKey: computed(() => TEACHERS_QUERY_KEY(toValue(full))), - queryFn: () => teacherController.getAll(toValue(full)), + queryFn: async () => teacherController.getAll(toValue(full)), }); } @@ -52,7 +52,7 @@ export function useTeacherQuery( ): UseQueryReturnType { return useQuery({ queryKey: computed(() => TEACHER_QUERY_KEY(toValue(username)!)), - queryFn: () => teacherController.getByUsername(toValue(username)!), + queryFn: async () => teacherController.getByUsername(toValue(username)!), enabled: () => Boolean(toValue(username)), }); } @@ -63,7 +63,7 @@ export function useTeacherClassesQuery( ): UseQueryReturnType { 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)), }); } @@ -74,7 +74,7 @@ export function useTeacherStudentsQuery( ): UseQueryReturnType { 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)), }); } @@ -85,7 +85,7 @@ export function useTeacherQuestionsQuery( ): UseQueryReturnType { 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)), }); } @@ -96,7 +96,7 @@ export function useTeacherJoinRequestsQuery( ): UseQueryReturnType { 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)), }); } @@ -110,7 +110,7 @@ export function useCreateTeacherMutation(): UseMutationReturnType< const queryClient = useQueryClient(); return useMutation({ - mutationFn: (data: TeacherDTO) => teacherController.createTeacher(data), + mutationFn: async (data: TeacherDTO) => teacherController.createTeacher(data), onSuccess: async () => { await queryClient.invalidateQueries({ queryKey: ["teachers"] }); }, @@ -126,7 +126,7 @@ export function useDeleteTeacherMutation(): UseMutationReturnType< const queryClient = useQueryClient(); return useMutation({ - mutationFn: (username: string) => teacherController.deleteTeacher(username), + mutationFn: async (username: string) => teacherController.deleteTeacher(username), onSuccess: async (deletedTeacher) => { await queryClient.invalidateQueries({ queryKey: ["teachers"] }); await queryClient.invalidateQueries({ queryKey: TEACHER_QUERY_KEY(deletedTeacher.teacher.username) }); @@ -143,7 +143,7 @@ export function useUpdateJoinRequestMutation(): UseMutationReturnType< const queryClient = useQueryClient(); return useMutation({ - mutationFn: ({ teacherUsername, classId, studentUsername, accepted }) => + mutationFn: async ({ teacherUsername, classId, studentUsername, accepted }) => teacherController.updateStudentJoinRequest(teacherUsername, classId, studentUsername, accepted), onSuccess: async (deletedJoinRequest) => { const username = deletedJoinRequest.request.requester; diff --git a/frontend/src/queries/themes.ts b/frontend/src/queries/themes.ts index 65bf9237..dcd251e7 100644 --- a/frontend/src/queries/themes.ts +++ b/frontend/src/queries/themes.ts @@ -1,10 +1,11 @@ -import { useQuery } from "@tanstack/vue-query"; +import {useQuery, type UseQueryReturnType} from "@tanstack/vue-query"; import { type MaybeRefOrGetter, toValue } from "vue"; import { ThemeController } from "@/controllers/themes.ts"; +import type {Theme} from "dwengo-1-common/src/interfaces/theme"; const themeController = new ThemeController(); -export function useThemeQuery(language: MaybeRefOrGetter) { +export function useThemeQuery(language: MaybeRefOrGetter): UseQueryReturnType { return useQuery({ queryKey: ["themes", language], queryFn: async () => { @@ -15,7 +16,7 @@ export function useThemeQuery(language: MaybeRefOrGetter) { }); } -export function useThemeHruidsQuery(themeKey: MaybeRefOrGetter) { +export function useThemeHruidsQuery(themeKey: MaybeRefOrGetter): UseQueryReturnType { return useQuery({ queryKey: ["theme-hruids", themeKey], queryFn: async () => themeController.getHruidsByKey(toValue(themeKey)!),