diff --git a/src/app/profile/profile-structure/profile-structure.component.scss b/src/app/profile/profile-structure/profile-structure.component.scss index 83aa6b65361644d92ac9d067e459fd6fba609839..d68ea7797bf995ed3c6038a47ff3540247793dbf 100644 --- a/src/app/profile/profile-structure/profile-structure.component.scss +++ b/src/app/profile/profile-structure/profile-structure.component.scss @@ -4,7 +4,7 @@ @import '../../../assets/scss/shapes'; .structureCard { - padding: 8px 16px 8px 8px; + padding: 8px 0; border: 1px solid $grey-5; border-radius: 4px; overflow: hidden; @@ -15,6 +15,7 @@ } .collapseHeader { + padding: 0 0.5rem; cursor: pointer; p { margin: 0 !important; @@ -35,7 +36,7 @@ } .collapseContent { - padding: 0 10px; + padding: 0 1rem; .infoSection { @include lato-regular-14; diff --git a/src/app/profile/profile-structure/profile-structure.component.ts b/src/app/profile/profile-structure/profile-structure.component.ts index a036f6366e35152c45047d62f7a2f4342817e388..758518d79d9d7de1745c105c1d8d9cf53e446c3e 100644 --- a/src/app/profile/profile-structure/profile-structure.component.ts +++ b/src/app/profile/profile-structure/profile-structure.component.ts @@ -6,6 +6,7 @@ import { structureFormStep } from '../../form/form-view/structure-form/structure import { Structure } from '../../models/structure.model'; import { StructureWithOwners } from '../../models/structureWithOwners.model'; import { NotificationService } from '../../services/notification.service'; +import { StructureService } from '../../services/structure.service'; import { ButtonType } from '../../shared/components/button/buttonType.enum'; import { SearchService } from '../../structure-list/services/search.service'; import { formUtils } from '../../utils/formUtils'; @@ -44,6 +45,7 @@ export class ProfileStructureComponent implements OnInit { private userService: UserService, private notificationService: NotificationService, private searchService: SearchService, + private structureService: StructureService, public utils: Utils ) {} @@ -108,7 +110,16 @@ export class ProfileStructureComponent implements OnInit { this.addMemberModalOpenned = false; if (memberAddRequested) { this.ngOnInit(); - this.notificationService.showSuccess(`La demande d'ajout a bien été effectuée`, ''); + 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); + }); + }); + }); } } } diff --git a/src/app/profile/structure-add-member-modal/structure-add-member-modal.component.html b/src/app/profile/structure-add-member-modal/structure-add-member-modal.component.html index b8aea48a543f61363a0a4fcbeadd75682275d74b..1096cda7183885bf8a546c81cce577776cd62090 100644 --- a/src/app/profile/structure-add-member-modal/structure-add-member-modal.component.html +++ b/src/app/profile/structure-add-member-modal/structure-add-member-modal.component.html @@ -20,12 +20,11 @@ <div class="buttons" fxLayout="row" fxLayoutAlign="space-between center"> <app-button [text]="'Annuler'" (action)="closeModal(false)"></app-button> <app-button - [text]="'Valider'" + [text]="'Ajouter'" [disabled]="formAddAccount.invalid" (action)="addOwner()" [style]="buttonTypeEnum.Primary" - > - </app-button> + ></app-button> </div> </form> </div> diff --git a/src/app/profile/structure-add-member-modal/structure-add-member-modal.component.ts b/src/app/profile/structure-add-member-modal/structure-add-member-modal.component.ts index 66f7e5d3fb069bd09693eb35e9929f5070ff593a..26f8329f613a7b6742574af8eca6c4c9808def10 100644 --- a/src/app/profile/structure-add-member-modal/structure-add-member-modal.component.ts +++ b/src/app/profile/structure-add-member-modal/structure-add-member-modal.component.ts @@ -2,6 +2,7 @@ import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; import { AbstractControl, FormBuilder, FormGroup, Validators } from '@angular/forms'; import { StructureWithOwners } from '../../models/structureWithOwners.model'; import { TempUser } from '../../models/temp-user.model'; +import { NotificationService } from '../../services/notification.service'; import { StructureService } from '../../services/structure.service'; import { ButtonType } from '../../shared/components/button/buttonType.enum'; import { CustomRegExp } from '../../utils/CustomRegExp'; @@ -18,7 +19,11 @@ export class StructureAddMemberModalComponent implements OnInit { public formAddAccount: FormGroup; public ownerAlreadyLinked = false; - constructor(private formBuilder: FormBuilder, private structureService: StructureService) {} + constructor( + private formBuilder: FormBuilder, + private structureService: StructureService, + private notificationService: NotificationService + ) {} ngOnInit(): void { this.formAddAccount = this.formBuilder.group({ @@ -43,7 +48,12 @@ export class StructureAddMemberModalComponent implements OnInit { const user = new TempUser(); user.email = this.fAddAccount.email.value; this.structureService.addOwnerToStructure(user, this.structure.structure._id).subscribe( - () => { + (res) => { + if ((res as TempUser).email) { + this.notificationService.showSuccess("La demande d'ajout a bien été effectuée"); + } else { + this.notificationService.showSuccess('Le membre a bien été ajouté'); + } this.closed.emit(true); }, (err) => { diff --git a/src/app/services/structure.service.ts b/src/app/services/structure.service.ts index 0224f445a2de3000ab262b163b77216c7488047b..2c75cb37560cb273c09f56a1e9e61ae74e7aea36 100644 --- a/src/app/services/structure.service.ts +++ b/src/app/services/structure.service.ts @@ -72,7 +72,7 @@ export class StructureService { public removeOwnerFromStructure(idOwner: string, idStructure: string): Observable<any> { return this.http.delete<any>(`${this.baseUrl}/${idStructure}/owner/${idOwner}`); } - public addOwnerToStructure(user: TempUser, idStructure: string): Observable<any> { + public addOwnerToStructure(user: TempUser, idStructure: string): Observable<string[] | TempUser> { return this.http.post<any>(`${this.baseUrl}/${idStructure}/addOwner`, user); }