refactor: joinrequests uit classdto
This commit is contained in:
		
							parent
							
								
									db3c531038
								
							
						
					
					
						commit
						6c3dbc99bb
					
				
					 4 changed files with 7 additions and 4 deletions
				
			
		|  | @ -10,7 +10,6 @@ export function mapToClassDTO(cls: Class): ClassDTO { | ||||||
|         displayName: cls.displayName, |         displayName: cls.displayName, | ||||||
|         teachers: cls.teachers.map((teacher) => teacher.username), |         teachers: cls.teachers.map((teacher) => teacher.username), | ||||||
|         students: cls.students.map((student) => student.username), |         students: cls.students.map((student) => student.username), | ||||||
|         joinRequests: [], // TODO
 |  | ||||||
|     }; |     }; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -67,6 +67,11 @@ export async function getClassStudents(classId: string, full: boolean): Promise< | ||||||
|     return cls.students.map((student) => student.username); |     return cls.students.map((student) => student.username); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | export async function getClassStudentsDTO(classId: string): Promise<StudentDTO[]> { | ||||||
|  |     const cls = await fetchClass(classId); | ||||||
|  |     return cls.students.map(mapToStudentDTO); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| export async function getClassTeachers(classId: string, full: boolean): Promise<TeacherDTO[] | string[]> { | export async function getClassTeachers(classId: string, full: boolean): Promise<TeacherDTO[] | string[]> { | ||||||
|     const cls = await fetchClass(classId); |     const cls = await fetchClass(classId); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -22,7 +22,7 @@ import { Question } from '../entities/questions/question.entity.js'; | ||||||
| import { ClassJoinRequestRepository } from '../data/classes/class-join-request-repository.js'; | import { ClassJoinRequestRepository } from '../data/classes/class-join-request-repository.js'; | ||||||
| import { Student } from '../entities/users/student.entity.js'; | import { Student } from '../entities/users/student.entity.js'; | ||||||
| import { NotFoundException } from '../exceptions/not-found-exception.js'; | import { NotFoundException } from '../exceptions/not-found-exception.js'; | ||||||
| import { getClassStudents } from './classes.js'; | import {getClassStudents, getClassStudentsDTO} from './classes.js'; | ||||||
| import { TeacherDTO } from '@dwengo-1/common/interfaces/teacher'; | import { TeacherDTO } from '@dwengo-1/common/interfaces/teacher'; | ||||||
| import { ClassDTO } from '@dwengo-1/common/interfaces/class'; | import { ClassDTO } from '@dwengo-1/common/interfaces/class'; | ||||||
| import { StudentDTO } from '@dwengo-1/common/interfaces/student'; | import { StudentDTO } from '@dwengo-1/common/interfaces/student'; | ||||||
|  | @ -99,7 +99,7 @@ export async function getStudentsByTeacher(username: string, full: boolean): Pro | ||||||
| 
 | 
 | ||||||
|     const classIds: string[] = classes.map((cls) => cls.id); |     const classIds: string[] = classes.map((cls) => cls.id); | ||||||
| 
 | 
 | ||||||
|     const students: StudentDTO[] = (await Promise.all(classIds.map(async (id) => getClassStudents(id)))).flat(); |     const students: StudentDTO[] = (await Promise.all(classIds.map(async (id) => await getClassStudentsDTO(id)))).flat(); | ||||||
|     if (full) { |     if (full) { | ||||||
|         return students; |         return students; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | @ -3,5 +3,4 @@ export interface ClassDTO { | ||||||
|     displayName: string; |     displayName: string; | ||||||
|     teachers: string[]; |     teachers: string[]; | ||||||
|     students: string[]; |     students: string[]; | ||||||
|     joinRequests: string[]; |  | ||||||
| } | } | ||||||
|  |  | ||||||
		Reference in a new issue
	
	 Gabriellvl
						Gabriellvl