fix(intern): menerapkan fallback posisi intern ke snapshot tabal user

This commit is contained in:
Muhammad Zhafran Ilham
2026-07-01 18:30:04 +07:00
parent c31c91fb8a
commit b21f5ad5d9
3 changed files with 18 additions and 5 deletions
+13 -2
View File
@@ -124,8 +124,13 @@ class AuthService {
} }
const { password, ...userWithoutPassword } = user; const { password, ...userWithoutPassword } = user;
const lowongan = user.lamaran_magang?.lowongan_magang;
return data(userWithoutPassword); return data({
...userWithoutPassword,
position: lowongan?.posisi || user.intern_position || null,
kelompok_peminatan: lowongan?.kelompok_peminatan || user.intern_interest_group || null,
});
} else { } else {
return error(new NotFoundError('Role tidak valid')); return error(new NotFoundError('Role tidak valid'));
} }
@@ -262,7 +267,13 @@ class AuthService {
}); });
const { password: _, ...userWithoutPassword } = updatedUser; const { password: _, ...userWithoutPassword } = updatedUser;
return data(userWithoutPassword); const lowongan = updatedUser.lamaran_magang?.lowongan_magang;
return data({
...userWithoutPassword,
position: lowongan?.posisi || updatedUser.intern_position || null,
kelompok_peminatan: lowongan?.kelompok_peminatan || updatedUser.intern_interest_group || null,
});
} else { } else {
if (imageFile?.filename) { if (imageFile?.filename) {
const { deleteFileIfExists } = require('../../../helpers/utils/fileHelper'); const { deleteFileIfExists } = require('../../../helpers/utils/fileHelper');
@@ -184,6 +184,8 @@ class ProjectRepository {
full_name: true, full_name: true,
email: true, email: true,
professional_bio: true, professional_bio: true,
intern_position: true,
intern_interest_group: true,
is_active: true, is_active: true,
lamaran_magang: { lamaran_magang: {
select: { select: {
@@ -393,8 +393,8 @@ class ProjectService {
full_name: user.full_name, full_name: user.full_name,
email: user.email, email: user.email,
professional_bio: user.professional_bio || null, professional_bio: user.professional_bio || null,
position: lowongan?.posisi || null, position: lowongan?.posisi || user.intern_position || null,
kelompok_peminatan: lowongan?.kelompok_peminatan || null, kelompok_peminatan: lowongan?.kelompok_peminatan || user.intern_interest_group || null,
}, },
created_at: member.created_at, created_at: member.created_at,
updated_at: member.updated_at, updated_at: member.updated_at,
@@ -540,7 +540,7 @@ class ProjectService {
const mappedInterns = interns.map((intern) => { const mappedInterns = interns.map((intern) => {
const activeMembership = intern.project_members?.[0] || null; const activeMembership = intern.project_members?.[0] || null;
const projectName = activeMembership?.project?.project_name || "Unassigned"; const projectName = activeMembership?.project?.project_name || "Unassigned";
const role = intern.lamaran_magang?.lowongan_magang?.posisi || "-"; const role = intern.lamaran_magang?.lowongan_magang?.posisi || intern.intern_position || "-";
return { return {
id: intern.id, id: intern.id,