Skip to content

Commit

Permalink
Refactor ActivityDTO to include course information for applicants
Browse files Browse the repository at this point in the history
  • Loading branch information
FelipeCarillo committed May 10, 2024
1 parent dfccb8a commit bf59dfc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
13 changes: 8 additions & 5 deletions src/core/repositories/database/dtos/ActivityDTO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,23 @@ export class ActivityDTO {
})) : []
}) : undefined
})) : [],
applicants: activity.applications ? activity.applications.map(application => ({
applicants: activity.applications?.map((application: { id?: number; activity_id: string; user: UserProps; status: number; } ) => ({
id: application.user.id,
status: application.status,
status: Boolean(application.status),
user: application.user ? new User({
id: application.user.id,
name: application.user.name,
email: application.user.email,
user_type: application.user.user_type.id,
course: application.user.course,
semester_course: application.user.semester_course,
course: application.user.course ? new Course({
id: application.user.course.id,
name: application.user.course.name
}) : null,
semester_course: application.user.semester,
created_at: application.user.created_at,
updated_at: application.user.updated_at
}) : undefined
})) : []
}))
});
}
}
10 changes: 5 additions & 5 deletions src/core/repositories/database/dtos/UserDTO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ class UserProps {
id: number;
name: string;
};
course:
{
id: number,
name: string
} | null;
course:
{
id: number,
name: string
} | null;
semester: number | null;
created_at: Date;
updated_at: Date;
Expand Down

0 comments on commit bf59dfc

Please sign in to comment.