Skip to content

Commit

Permalink
Integrate Coderabbitai suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelmbabhazi committed Jan 14, 2025
1 parent 2624429 commit 8f28602
Showing 1 changed file with 13 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,31 +159,21 @@ export class RequestApprovalMutationComponent extends TranslationBaseComponent i
}

closeDialog(requestApproval?: IRequestApproval) {
const members: any[] = [];
const listEmployees: any[] = [];

if (requestApproval?.teams && this.teams) {
this.teams.forEach((i) => {
requestApproval.teams.forEach((e: any) => {
if (e === i.id) {
i.members?.forEach((id) => {
members.push(id.employeeId);
});
}
});
});
}
if (requestApproval?.employees) {
requestApproval.employees.forEach((e) => {
if (!members.includes(e)) {
listEmployees.push(e);
}
});
}
if (requestApproval) {
requestApproval.employees = listEmployees;
if (!requestApproval) {
return this.dialogRef.close(requestApproval);
}

const teamMemberIds = new Set(
requestApproval.teams
?.flatMap((reqTeam) =>
this.teams?.find((team) => team.id === reqTeam.id)?.members?.map((member) => member.employeeId)
)
.filter(Boolean) ?? []
);

requestApproval.employees =
requestApproval.employees?.filter((reqEmployee) => !teamMemberIds.has(reqEmployee.id)) ?? [];

this.onReset();
this.dialogRef.close(requestApproval);
}
Expand Down

0 comments on commit 8f28602

Please sign in to comment.