From 575ec2a47d54bbee5959c8ba51ad95ef0124a0f7 Mon Sep 17 00:00:00 2001 From: Gabriellvl Date: Sat, 5 Apr 2025 17:41:22 +0200 Subject: [PATCH] fix: json body controller + type errors query voor student --- frontend/src/controllers/students.ts | 2 +- frontend/src/queries/students.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/src/controllers/students.ts b/frontend/src/controllers/students.ts index f74f02da..e9da9c74 100644 --- a/frontend/src/controllers/students.ts +++ b/frontend/src/controllers/students.ts @@ -70,7 +70,7 @@ export class StudentController extends BaseController { } async createJoinRequest(username: string, classId: string): Promise { - return this.post(`/${username}/joinRequests}`, classId); + return this.post(`/${username}/joinRequests`, { classId }); } async deleteJoinRequest(username: string, classId: string): Promise { diff --git a/frontend/src/queries/students.ts b/frontend/src/queries/students.ts index 822083d9..6e6bfe5b 100644 --- a/frontend/src/queries/students.ts +++ b/frontend/src/queries/students.ts @@ -179,7 +179,7 @@ export function useCreateJoinRequestMutation(): UseMutationReturnType< mutationFn: async ({ username, classId }) => studentController.createJoinRequest(username, classId), onSuccess: async (newJoinRequest) => { await queryClient.invalidateQueries({ - queryKey: studentJoinRequestsQueryKey(newJoinRequest.request.requester), + queryKey: studentJoinRequestsQueryKey(newJoinRequest.request.requester.username), }); }, }); @@ -196,7 +196,7 @@ export function useDeleteJoinRequestMutation(): UseMutationReturnType< return useMutation({ mutationFn: async ({ username, classId }) => studentController.deleteJoinRequest(username, classId), onSuccess: async (deletedJoinRequest) => { - const username = deletedJoinRequest.request.requester; + const username = deletedJoinRequest.request.requester.username; const classId = deletedJoinRequest.request.class; await queryClient.invalidateQueries({ queryKey: studentJoinRequestsQueryKey(username) }); await queryClient.invalidateQueries({ queryKey: studentJoinRequestQueryKey(username, classId) });