Skip to content
Snippets Groups Projects
Commit f58fedeb authored by Bastien DUMONT's avatar Bastien DUMONT :angel:
Browse files

fix: add members

parent c4b45b38
No related branches found
No related tags found
4 merge requests!418V2.1.0,!400V2.0,!371Resolve "Mauvaise gestion d'ajout de membre",!230V2.0
......@@ -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;
......
......@@ -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);
});
});
});
}
}
}
......@@ -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>
......
......@@ -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) => {
......
......@@ -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);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment