avancées
This commit is contained in:
parent
4a4c511fcd
commit
b7e4e1ad18
@ -15,12 +15,14 @@ export class PageAccountComponent implements OnInit {
|
||||
public listMembres: any[];
|
||||
currentUser: any;
|
||||
currentTeam: any;
|
||||
parent: boolean;
|
||||
|
||||
constructor(private membreService: MembreService,
|
||||
private teamService: TeamService,
|
||||
private tokenService: TokenService,
|
||||
private router: Router) {
|
||||
this.listMembres = [];
|
||||
this.parent = false;
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
@ -36,5 +38,24 @@ export class PageAccountComponent implements OnInit {
|
||||
this.membreService.getMembresByTeamId()?.subscribe((membres: any[]) => {
|
||||
this.listMembres = membres;
|
||||
});
|
||||
|
||||
/***Gestion des limatations en fonction du role (parent ou enfant) */
|
||||
const roleUser = this.tokenService.getRole();
|
||||
if(roleUser == "ROLE_PARENT"){
|
||||
this.parent = true;
|
||||
}
|
||||
}
|
||||
|
||||
/** Méthode qui au click va supprimer un contact en faisant appel au service dédié dans Membre Service **/
|
||||
onClickDelete(membreId: number){
|
||||
this.membreService.deleteMembre(membreId).subscribe((resp) => {
|
||||
if(membreId) {
|
||||
this.listMembres.forEach(membreId => console.log(membreId))
|
||||
}else{
|
||||
window.alert("Le profil ne peut pas être supprimé!")
|
||||
}
|
||||
this.router.navigate(['compte/']);
|
||||
});
|
||||
window.location.reload();
|
||||
}
|
||||
}
|
||||
|
@ -22,8 +22,7 @@
|
||||
id = "bouton-ajout"
|
||||
type="button"
|
||||
class="btn btn-primary btn-lg bouton-oui"
|
||||
|
||||
|
||||
(clickDelete)="onClickDelete($event)"
|
||||
>Oui, je souhaite supprimer ce compte
|
||||
</button>
|
||||
</div>
|
||||
|
@ -1,4 +1,6 @@
|
||||
import { Component, EventEmitter, OnInit, Output } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
import { Membre } from 'src/app/models/membre';
|
||||
import { MembreService } from 'src/app/services/membre.service';
|
||||
import { TokenService } from 'src/app/services/token.service';
|
||||
|
||||
@ -11,12 +13,23 @@ export class PageDeleteMemberComponent implements OnInit {
|
||||
@Output() clickDelete = new EventEmitter();
|
||||
parent: boolean;
|
||||
|
||||
constructor(private tokenService: TokenService, private membreService: MembreService) {
|
||||
this.parent = false;
|
||||
constructor(private membreService: MembreService, private tokenService: TokenService) {
|
||||
this.parent = false;
|
||||
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
const roleUser = this.tokenService.getRole();
|
||||
|
||||
if(roleUser == "ROLE_PARENT"){
|
||||
this.parent = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
onClickDelete(membreId: any){
|
||||
window.alert("Le profil à bien été supprimé!")
|
||||
this.clickDelete.emit(membreId);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -45,8 +45,8 @@ export class MembreService {
|
||||
}
|
||||
}
|
||||
|
||||
deleteMembre(membre: Membre): Observable<any>{
|
||||
return this.http.delete(`${this.apiUrl}/membres/delete/${membre.id}`);
|
||||
deleteMembre(membreId: number): Observable<any>{
|
||||
return this.http.delete(`${this.apiUrl}/membres/delete/${membreId}`);
|
||||
}
|
||||
|
||||
updateMembre(membre: Membre): Observable<any> | void {
|
||||
|
Loading…
Reference in New Issue
Block a user