From e49fcbf0842ec12574c8116c16fbe89d7477fb43 Mon Sep 17 00:00:00 2001 From: vaskevichk Date: Fri, 8 Dec 2023 10:58:37 +0200 Subject: [PATCH] remove admin when member is removed --- src/company/company.service.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/company/company.service.ts b/src/company/company.service.ts index e34c656..413ca21 100644 --- a/src/company/company.service.ts +++ b/src/company/company.service.ts @@ -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) { @@ -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 {