fix: invitation geeft enkel classId field terug

This commit is contained in:
Gabriellvl 2025-04-13 19:40:20 +02:00
parent 5624f3bbfe
commit 834e991568
4 changed files with 11 additions and 7 deletions

View file

@ -10,7 +10,7 @@ export function mapToTeacherInvitationDTO(invitation: TeacherInvitation): Teache
return { return {
sender: mapToUserDTO(invitation.sender), sender: mapToUserDTO(invitation.sender),
receiver: mapToUserDTO(invitation.receiver), receiver: mapToUserDTO(invitation.receiver),
class: mapToClassDTO(invitation.class), classId: invitation.class.classId!,
}; };
} }
@ -18,7 +18,7 @@ export function mapToTeacherInvitationDTOIds(invitation: TeacherInvitation): Tea
return { return {
sender: invitation.sender.username, sender: invitation.sender.username,
receiver: invitation.receiver.username, receiver: invitation.receiver.username,
class: invitation.class.classId!, classId: invitation.class.classId!,
}; };
} }

View file

@ -13,6 +13,7 @@ import { makeTestAttachments } from './test_assets/content/attachments.testdata.
import { makeTestQuestions } from './test_assets/questions/questions.testdata.js'; import { makeTestQuestions } from './test_assets/questions/questions.testdata.js';
import { makeTestAnswers } from './test_assets/questions/answers.testdata.js'; import { makeTestAnswers } from './test_assets/questions/answers.testdata.js';
import { makeTestSubmissions } from './test_assets/assignments/submission.testdata.js'; import { makeTestSubmissions } from './test_assets/assignments/submission.testdata.js';
import {Collection} from "@mikro-orm/core";
export async function setupTestApp(): Promise<void> { export async function setupTestApp(): Promise<void> {
dotenv.config({ path: '.env.test' }); dotenv.config({ path: '.env.test' });
@ -28,8 +29,8 @@ export async function setupTestApp(): Promise<void> {
const assignments = makeTestAssignemnts(em, classes); const assignments = makeTestAssignemnts(em, classes);
const groups = makeTestGroups(em, students, assignments); const groups = makeTestGroups(em, students, assignments);
assignments[0].groups = groups.slice(0, 3); assignments[0].groups = new Collection(groups.slice(0, 3));
assignments[1].groups = groups.slice(3, 4); assignments[1].groups = new Collection(groups.slice(3, 4));
const teacherInvitations = makeTestTeacherInvitations(em, teachers, classes); const teacherInvitations = makeTestTeacherInvitations(em, teachers, classes);
const classJoinRequests = makeTestClassJoinRequests(em, students, classes); const classJoinRequests = makeTestClassJoinRequests(em, students, classes);
@ -41,6 +42,9 @@ export async function setupTestApp(): Promise<void> {
const answers = makeTestAnswers(em, teachers, questions); const answers = makeTestAnswers(em, teachers, questions);
const submissions = makeTestSubmissions(em, students, groups); const submissions = makeTestSubmissions(em, students, groups);
console.log("classes", classes);
console.log("invitations", teacherInvitations);
await em.persistAndFlush([ await em.persistAndFlush([
...students, ...students,
...teachers, ...teachers,

View file

@ -4,7 +4,7 @@ import { ClassDTO } from './class';
export interface TeacherInvitationDTO { export interface TeacherInvitationDTO {
sender: string | UserDTO; sender: string | UserDTO;
receiver: string | UserDTO; receiver: string | UserDTO;
class: string | ClassDTO; classId: string;
} }
export interface TeacherInvitationData { export interface TeacherInvitationData {

View file

@ -276,10 +276,10 @@
<tbody> <tbody>
<tr <tr
v-for="i in invitations" v-for="i in invitations"
:key="(i.class as ClassDTO).id" :key="i.classId"
> >
<td> <td>
{{ (i.class as ClassDTO).displayName }} {{ i.classId }} <!-- TODO fetch display name via classId because db only returns classId field -->
</td> </td>
<td>{{ (i.sender as TeacherDTO).firstName + " " + (i.sender as TeacherDTO).lastName }}</td> <td>{{ (i.sender as TeacherDTO).firstName + " " + (i.sender as TeacherDTO).lastName }}</td>
<td class="text-right"> <td class="text-right">