diff --git a/src/app/profile/profile-structure/profile-structure.component.html b/src/app/profile/profile-structure/profile-structure.component.html index fd6d350160f597957aba170085f877a86fb898ac..82acb144439cb89eaff2001fd11545d564276946 100644 --- a/src/app/profile/profile-structure/profile-structure.component.html +++ b/src/app/profile/profile-structure/profile-structure.component.html @@ -133,15 +133,6 @@ <app-profile-structure-member *ngFor="let member of members; let i = index" [member]="member" /> </div> </div> - <div *ngIf="!isPublic && members.length === 0 && !isPending" class="call-to-action"> - <app-button - [iconBtn]="'add'" - [text]="'Ajouter un membre'" - [style]="buttonTypeEnum.SecondaryUltraWide" - [routerLinkActive]="'active'" - (click)="addMemberModalOpened = true" - /> - </div> <div *ngIf="!isPublic && !this.personalOffer && userProfile.job?.hasPersonalOffer && !isPending" class="call-to-action" @@ -156,8 +147,3 @@ </div> </div> </div> -<app-structure-add-member-modal - [opened]="addMemberModalOpened && !isPending" - [structure]="structureWithOwners" - (closed)="closeAddMemberModal($event)" -/> diff --git a/src/app/profile/profile-structure/profile-structure.component.ts b/src/app/profile/profile-structure/profile-structure.component.ts index 9a7de2a0a41d0df921cea4152a6bd290ac760a9e..89c924064a239b0295ec65f52d2a09c6d4adae5a 100644 --- a/src/app/profile/profile-structure/profile-structure.component.ts +++ b/src/app/profile/profile-structure/profile-structure.component.ts @@ -55,15 +55,11 @@ export class ProfileStructureComponent implements OnInit { async ngOnInit(): Promise<void> { this.structureForm = new formUtils().createStructureForm(this.structureWithOwners.structure, true); - this.structureWithOwners.owners - .filter((owner) => { - return owner._id !== this.userProfile._id; - }) - .forEach((owner) => { - this.userService.getUser(owner._id).subscribe((res) => { - this.members.push(res); - }); + this.structureWithOwners.owners.forEach((owner) => { + this.userService.getUser(owner._id).subscribe((user) => { + this.members.push(user); }); + }); this.structure = new Structure(this.structureWithOwners.structure); this.personalOffer = await this.getSharedPersonalOffer(); } @@ -120,22 +116,6 @@ export class ProfileStructureComponent implements OnInit { : address.street + ' - ' + address.commune; } - public closeAddMemberModal(memberAddRequested: boolean): void { - this.addMemberModalOpened = false; - if (memberAddRequested) { - this.ngOnInit(); - this.structureService - .getStructureWithOwners(this.structureWithOwners.structure._id, this.userProfile) - .subscribe((result) => { - this.structureWithOwners = result; - result.owners.forEach((owner) => { - this.userService.getUser(owner._id).subscribe((res) => { - this.members.push(res); - }); - }); - }); - } - } public getFormattedDate(): string { if (this.joinRequestDate) { return DateTime.fromISO(this.joinRequestDate, { zone: 'Europe/Paris' }).toFormat('dd/MM/yyyy'); diff --git a/src/app/profile/profile.component.ts b/src/app/profile/profile.component.ts index 211b69258f2b2b0f3dcb84154441661e4192863b..c0a19627b9de4db44596867ebc7cfcf7fd14624d 100644 --- a/src/app/profile/profile.component.ts +++ b/src/app/profile/profile.component.ts @@ -72,7 +72,7 @@ export class ProfileComponent implements OnInit { this.userProfile.structuresLink.forEach((structureId) => { structures$.push( - this.structureService.getStructureWithOwners(structureId, null).pipe( + this.structureService.getStructureWithOwners(structureId).pipe( tap((structure) => { this.structures.push(structure); }) @@ -88,7 +88,7 @@ export class ProfileComponent implements OnInit { this.structures = []; this.userProfile.pendingStructuresLink.forEach((pending: pendingStructureLink) => { structures$.push( - this.structureService.getStructureWithOwners(pending.id, null).pipe( + this.structureService.getStructureWithOwners(pending.id).pipe( tap((structure) => { this.pendingStructures.push(structure); }) diff --git a/src/app/profile/structure-edition-summary/structure-edition-summary.component.html b/src/app/profile/structure-edition-summary/structure-edition-summary.component.html index 081a360c36a6ee6c21f74b58ebef7ab803497d1c..15cdad98c889e113afefa2247e09e416ef452d35 100644 --- a/src/app/profile/structure-edition-summary/structure-edition-summary.component.html +++ b/src/app/profile/structure-edition-summary/structure-edition-summary.component.html @@ -691,20 +691,10 @@ /> </div> <div *ngIf="members" class="content"> - <div *ngIf="profileService.isAdmin()"> - <div [ngPlural]="members.length"> - <ng-template ngPluralCase="0">Aucun membre</ng-template> - <ng-template ngPluralCase="1">1 membre</ng-template> - <ng-template ngPluralCase="other">{{ members.length }} membres</ng-template> - </div> - </div> - <div *ngIf="!profileService.isAdmin()"> - <div [ngPlural]="members.length"> - <ng-template ngPluralCase="0">Aucun membre</ng-template> - <ng-template ngPluralCase="1">Aucun autre membre</ng-template> - <ng-template ngPluralCase="2">1 membre</ng-template> - <ng-template ngPluralCase="other">{{ members.length - 1 }} membres</ng-template> - </div> + <div [ngPlural]="members.length"> + <ng-template ngPluralCase="0">Aucun membre</ng-template> + <ng-template ngPluralCase="1">1 membre</ng-template> + <ng-template ngPluralCase="other">{{ members.length }} membres</ng-template> </div> </div> </div> diff --git a/src/app/profile/structure-edition-summary/structure-edition-summary.component.ts b/src/app/profile/structure-edition-summary/structure-edition-summary.component.ts index d90b7ed5e581d5b7fb58801822d87b75ede90a64..f4a6562b452ab4544e0c7f443b4b6d17c10edb64 100644 --- a/src/app/profile/structure-edition-summary/structure-edition-summary.component.ts +++ b/src/app/profile/structure-edition-summary/structure-edition-summary.component.ts @@ -70,7 +70,7 @@ export class StructureEditionSummaryComponent implements OnInit { if (updatedAt < sixMonthsAgo) this.isUpdateStructure = true; this.structureService - .getStructureWithOwners(data.structure._id, null) + .getStructureWithOwners(data.structure._id) .subscribe((result) => (this.members = result.owners)); } }); diff --git a/src/app/profile/structure-members-management/structure-members-management.component.html b/src/app/profile/structure-members-management/structure-members-management.component.html index 5034bb3ce6c1141b9dec93f5788ceee3ea80e748..70499f35b9d0438247a347cd7b8fdf1d15b56cff 100644 --- a/src/app/profile/structure-members-management/structure-members-management.component.html +++ b/src/app/profile/structure-members-management/structure-members-management.component.html @@ -42,6 +42,7 @@ </div> </div> <app-button + *ngIf="currentProfile._id !== member._id" class="button-member" tabindex="0" [style]="buttonTypeEnum.Secondary" diff --git a/src/app/profile/structure-members-management/structure-members-management.component.ts b/src/app/profile/structure-members-management/structure-members-management.component.ts index e7f614ad53967b24fa3dc071ed8ff404ae8883ba..972d23f5620d276815650220afe2b1ad91e26e5b 100644 --- a/src/app/profile/structure-members-management/structure-members-management.component.ts +++ b/src/app/profile/structure-members-management/structure-members-management.component.ts @@ -28,6 +28,7 @@ export class StructureMembersManagementComponent implements OnInit { public cancelAddTempUserModalOpened = false; public buttonTypeEnum = ButtonType; public isLoading = true; + public currentProfile: User; constructor( private route: ActivatedRoute, @@ -40,9 +41,9 @@ export class StructureMembersManagementComponent implements OnInit { this.route.data.subscribe(async (data) => { if (data.structure) { this.structure = new Structure(data.structure); - let currentProfile = await this.profileService.getProfile(); + this.currentProfile = await this.profileService.getProfile(); this.structureService - .getStructureWithOwners(data.structure._id, currentProfile) + .getStructureWithOwners(data.structure._id) .pipe(finalize(() => (this.isLoading = false))) .subscribe((s) => { this.structureWithOwners = s; diff --git a/src/app/profile/structures-management/structures-management.component.ts b/src/app/profile/structures-management/structures-management.component.ts index 69c81f6c53674ab12370428b1666aeb6abf0c4b9..ae3a5ee0131390367ca89b645b860d17d2f7924c 100644 --- a/src/app/profile/structures-management/structures-management.component.ts +++ b/src/app/profile/structures-management/structures-management.component.ts @@ -52,7 +52,7 @@ export class StructuresManagementComponent implements OnInit { this.userProfile.structuresLink.forEach((structureId) => { structures$.push( - this.structureService.getStructureWithOwners(structureId, null).pipe( + this.structureService.getStructureWithOwners(structureId).pipe( tap((structure) => { this.structures.push(structure); }) diff --git a/src/app/services/structure.service.ts b/src/app/services/structure.service.ts index 5136c999d8af8ef4592b74add3cc8a629c3f2ccd..6555db827e67d456a3da86a31cbfef2c8ed9e648 100644 --- a/src/app/services/structure.service.ts +++ b/src/app/services/structure.service.ts @@ -100,8 +100,8 @@ export class StructureService { }); } - public getStructureWithOwners(structureId: string, profile: User): Observable<StructureWithOwners> { - return this.http.post<any>(`${this.baseUrl}/${structureId}/withOwners`, { emailUser: profile?.email }); + public getStructureWithOwners(structureId: string): Observable<StructureWithOwners> { + return this.http.get<StructureWithOwners>(`${this.baseUrl}/${structureId}/withOwners`); } public getTempUsers(structureId: string): Observable<TempUser[]> { diff --git a/src/app/structure-list/components/structure-details/structure-details.component.ts b/src/app/structure-list/components/structure-details/structure-details.component.ts index 0fda98b523064c18002bf7cf0732059af2f83314..89ffc57736330a8ea3918dd910e042dd51794418 100644 --- a/src/app/structure-list/components/structure-details/structure-details.component.ts +++ b/src/app/structure-list/components/structure-details/structure-details.component.ts @@ -108,7 +108,7 @@ export class StructureDetailsComponent implements OnInit { private async initForm(): Promise<void> { if (this.userIsLoggedIn()) { this.currentProfile = await this.profileService.getProfile(); - this.structureService.getStructureWithOwners(this.structure._id, this.currentProfile).subscribe((res) => { + this.structureService.getStructureWithOwners(this.structure._id).subscribe((res) => { this.structureAdmins = res.owners; }); } diff --git a/src/app/structure/structure-exclude/structure-exclude.component.ts b/src/app/structure/structure-exclude/structure-exclude.component.ts index 06753c30763cca608cf1617eff35d3d7be8895e2..8d74f465518ff0d332265fed232efd64b7d4af64 100644 --- a/src/app/structure/structure-exclude/structure-exclude.component.ts +++ b/src/app/structure/structure-exclude/structure-exclude.component.ts @@ -35,7 +35,7 @@ export class StructureExcludeComponent implements OnInit { this.userService.getUser(params.get('userId')).subscribe((res) => { this.newMemberName = res.name + ' ' + res.surname; }); - this.structureService.getStructureWithOwners(params.get('id'), null).subscribe((res) => { + this.structureService.getStructureWithOwners(params.get('id')).subscribe((res) => { this.structure = res.structure; const owners = res.owners; const isOwner = owners.find((owner) => owner._id === params.get('userId'));