feat(project): menambahkan endpoint assignable interns untuk admin atau mentor
This commit is contained in:
@@ -559,6 +559,42 @@ class ProjectService {
|
||||
}
|
||||
}
|
||||
|
||||
async getAssignableInterns(actor = {}) {
|
||||
try {
|
||||
if (!actor?.id) {
|
||||
return error(new BadRequestError("Admin ID is required"));
|
||||
}
|
||||
|
||||
if (actor.role !== "admin" && actor.role !== "mentor") {
|
||||
return error(
|
||||
new ForbiddenError("Access denied: only mentors/admins can view assignable interns")
|
||||
);
|
||||
}
|
||||
|
||||
const interns = await projectRepository.findAssignableInterns();
|
||||
|
||||
const mappedInterns = interns.map((intern) => {
|
||||
const lowongan = intern.lamaran_magang?.lowongan_magang;
|
||||
|
||||
return {
|
||||
id: intern.id,
|
||||
full_name: intern.full_name,
|
||||
email: intern.email,
|
||||
professional_bio: intern.professional_bio || null,
|
||||
position: lowongan?.posisi || intern.intern_position || null,
|
||||
kelompok_peminatan:
|
||||
lowongan?.kelompok_peminatan || intern.intern_interest_group || null,
|
||||
is_active: intern.is_active,
|
||||
is_assignable: true,
|
||||
};
|
||||
});
|
||||
|
||||
return data(mappedInterns);
|
||||
} catch (err) {
|
||||
return error(err);
|
||||
}
|
||||
}
|
||||
|
||||
async assignMember(payload, actor = {}) {
|
||||
try {
|
||||
if (!actor?.id) {
|
||||
|
||||
Reference in New Issue
Block a user