From 22c1c5233796fb73ae73553510dcef1242e47a22 Mon Sep 17 00:00:00 2001
From: Hugo SUBTIL <ext.sopra.husubtil@grandlyon.com>
Date: Wed, 15 Dec 2021 15:24:23 +0100
Subject: [PATCH] fix(structure): last member can now delete himself from
 structure

---
 src/app/profile/profile.component.ts  | 2 +-
 src/app/services/structure.service.ts | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/app/profile/profile.component.ts b/src/app/profile/profile.component.ts
index 0b3b1d36c..0a7e5aa9d 100644
--- a/src/app/profile/profile.component.ts
+++ b/src/app/profile/profile.component.ts
@@ -27,7 +27,7 @@ export class ProfileComponent implements OnInit {
       this.userProfile = profile;
       this.structures = [];
       profile.structuresLink.forEach((structureId) => {
-        this.structureService.getStructureWithOwners(structureId, profile).subscribe((s) => {
+        this.structureService.getStructureWithOwners(structureId, null).subscribe((s) => {
           this.structures.push(s);
         });
       });
diff --git a/src/app/services/structure.service.ts b/src/app/services/structure.service.ts
index d7653393c..71f6417cc 100644
--- a/src/app/services/structure.service.ts
+++ b/src/app/services/structure.service.ts
@@ -191,7 +191,7 @@ export class StructureService {
   }
 
   public getStructureWithOwners(structureId: string, profile: User): Observable<StructureWithOwners> {
-    return this.http.post<any>(`${this.baseUrl}/${structureId}/withOwners`, { emailUser: profile.email });
+    return this.http.post<any>(`${this.baseUrl}/${structureId}/withOwners`, { emailUser: profile?.email });
   }
 
   public sendMailOnStructureError(structureId: string, content: string): Observable<any> {
-- 
GitLab