style: fix linting issues met Prettier

This commit is contained in:
Lint Action 2025-04-13 18:59:56 +00:00
parent a824cdff94
commit 783c91b2e3
11 changed files with 112 additions and 93 deletions

View file

@ -1,13 +1,13 @@
import {fetchTeacher} from "./teachers";
import {getTeacherInvitationRepository} from "../data/repositories";
import {mapToInvitation, mapToTeacherInvitationDTO} from "../interfaces/teacher-invitation";
import {addClassTeacher, fetchClass} from "./classes";
import {TeacherInvitationData, TeacherInvitationDTO} from "@dwengo-1/common/interfaces/teacher-invitation";
import {ConflictException} from "../exceptions/conflict-exception";
import {Teacher} from "../entities/users/teacher.entity";
import {Class} from "../entities/classes/class.entity";
import {NotFoundException} from "../exceptions/not-found-exception";
import {TeacherInvitation} from "../entities/classes/teacher-invitation.entity";
import { fetchTeacher } from './teachers';
import { getTeacherInvitationRepository } from '../data/repositories';
import { mapToInvitation, mapToTeacherInvitationDTO } from '../interfaces/teacher-invitation';
import { addClassTeacher, fetchClass } from './classes';
import { TeacherInvitationData, TeacherInvitationDTO } from '@dwengo-1/common/interfaces/teacher-invitation';
import { ConflictException } from '../exceptions/conflict-exception';
import { Teacher } from '../entities/users/teacher.entity';
import { Class } from '../entities/classes/class.entity';
import { NotFoundException } from '../exceptions/not-found-exception';
import { TeacherInvitation } from '../entities/classes/teacher-invitation.entity';
export async function getAllInvitations(username: string, by: boolean): Promise<TeacherInvitationDTO[]> {
const teacher = await fetchTeacher(username);
@ -29,12 +29,12 @@ export async function createInvitation(data: TeacherInvitationData): Promise<Tea
const cls = await fetchClass(data.class);
if (!cls.teachers.contains(sender)){
throw new ConflictException("The teacher sending the invite is not part of the class");
if (!cls.teachers.contains(sender)) {
throw new ConflictException('The teacher sending the invite is not part of the class');
}
const newInvitation = mapToInvitation(sender, receiver, cls);
await teacherInvitationRepository.save(newInvitation, {preventOverwrite: true});
await teacherInvitationRepository.save(newInvitation, { preventOverwrite: true });
return mapToTeacherInvitationDTO(newInvitation);
}
@ -43,14 +43,19 @@ async function fetchInvitation(sender: Teacher, receiver: Teacher, cls: Class):
const teacherInvitationRepository = getTeacherInvitationRepository();
const invite = await teacherInvitationRepository.findBy(cls, sender, receiver);
if (!invite){
throw new NotFoundException("Teacher invite not found");
if (!invite) {
throw new NotFoundException('Teacher invite not found');
}
return invite;
}
export async function deleteInvitationFor(usernameSender: string, usernameReceiver: string, classId: string, accepted: boolean): Promise<TeacherInvitationDTO> {
export async function deleteInvitationFor(
usernameSender: string,
usernameReceiver: string,
classId: string,
accepted: boolean
): Promise<TeacherInvitationDTO> {
const teacherInvitationRepository = getTeacherInvitationRepository();
const sender = await fetchTeacher(usernameSender);
const receiver = await fetchTeacher(usernameReceiver);
@ -60,12 +65,9 @@ export async function deleteInvitationFor(usernameSender: string, usernameReceiv
const invitation = await fetchInvitation(sender, receiver, cls);
await teacherInvitationRepository.deleteBy(cls, sender, receiver);
if (accepted){
if (accepted) {
await addClassTeacher(classId, usernameReceiver);
}
return mapToTeacherInvitationDTO(invitation);
}