Skip to content

Commit

Permalink
remove admin when member is removed
Browse files Browse the repository at this point in the history
  • Loading branch information
katelovestocode committed Dec 8, 2023
1 parent 252bdd5 commit e49fcbf
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/company/company.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export class CompanyService {
try {
const company = await this.companyRepository.findOne({
where: { id: companyId },
relations: ['owner', 'members'],
relations: ['owner', 'members', 'admins'],
})

if (!company) {
Expand All @@ -173,7 +173,8 @@ export class CompanyService {
)
}

company.members = company.members.filter((user) => user.id !== userId)
company.members = company.members.filter((user) => user.id !== userId);
company.admins = company.admins.filter((admin) => admin.id !== userId);
const updated = await this.companyRepository.save(company)

return {
Expand Down

0 comments on commit e49fcbf

Please sign in to comment.