fix: json body controller + type errors query voor student

This commit is contained in:
Gabriellvl 2025-04-05 17:41:22 +02:00
parent 524de10d73
commit 575ec2a47d
2 changed files with 3 additions and 3 deletions

View file

@ -70,7 +70,7 @@ export class StudentController extends BaseController {
}
async createJoinRequest(username: string, classId: string): Promise<JoinRequestResponse> {
return this.post<JoinRequestResponse>(`/${username}/joinRequests}`, classId);
return this.post<JoinRequestResponse>(`/${username}/joinRequests`, { classId });
}
async deleteJoinRequest(username: string, classId: string): Promise<JoinRequestResponse> {

View file

@ -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) });