avancées et bloquage sur delete
This commit is contained in:
parent
b7e4e1ad18
commit
4b90b0e1b2
@ -30,7 +30,7 @@ const routes: Routes = [
|
||||
{ path: 'ajout-membre', canActivate: [AuthGuard], component: PageAddMemberComponent },
|
||||
{ path: 'agenda', canActivate: [AuthGuard], component: PageAgendaComponent },
|
||||
{ path: 'tableau-de-bord', canActivate: [AuthGuard], component: PageDashboardComponent },
|
||||
{ path: 'supprimer-membre', canActivate: [AuthGuard], component: PageDeleteMemberComponent },
|
||||
{ path: 'supprimer-membre/:id', canActivate: [AuthGuard], component: PageDeleteMemberComponent },
|
||||
{ path: 'password-oublie', component: PageForgotPasswordComponent },
|
||||
{ path: 'menu', canActivate: [AuthGuard], component: PageMenuSemaineComponent },
|
||||
{ path: 'repertoire', canActivate: [AuthGuard], component: PageRepertoireComponent },
|
||||
|
@ -11,7 +11,7 @@
|
||||
routerLinkActive="active-custom">
|
||||
Modifier
|
||||
</button><button button type="button" class="btn btn-primary px-4"
|
||||
routerLink="../supprimer-membre"
|
||||
routerLink="../supprimer-membre/{{membre.id}}"
|
||||
routerLinkActive="active-custom">
|
||||
Supprimer
|
||||
</button>
|
||||
|
@ -1,5 +1,4 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
import { MembreService } from 'src/app/services/membre.service';
|
||||
import { TeamService } from 'src/app/services/team.service';
|
||||
import { TokenService } from 'src/app/services/token.service';
|
||||
@ -19,8 +18,7 @@ export class PageAccountComponent implements OnInit {
|
||||
|
||||
constructor(private membreService: MembreService,
|
||||
private teamService: TeamService,
|
||||
private tokenService: TokenService,
|
||||
private router: Router) {
|
||||
private tokenService: TokenService) {
|
||||
this.listMembres = [];
|
||||
this.parent = false;
|
||||
}
|
||||
@ -46,16 +44,4 @@ export class PageAccountComponent implements OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
/** 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();
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@
|
||||
id = "bouton-ajout"
|
||||
type="button"
|
||||
class="btn btn-primary btn-lg bouton-non"
|
||||
routerLink="../compte"
|
||||
routerLink="/compte"
|
||||
routerLinkActive="active-custom"
|
||||
>Non, je ne souhaite pas supprimer ce compte
|
||||
</button>
|
||||
@ -22,7 +22,7 @@
|
||||
id = "bouton-ajout"
|
||||
type="button"
|
||||
class="btn btn-primary btn-lg bouton-oui"
|
||||
(clickDelete)="onClickDelete($event)"
|
||||
(clickDelete)="onClickDelete()"
|
||||
>Oui, je souhaite supprimer ce compte
|
||||
</button>
|
||||
</div>
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { Component, EventEmitter, OnInit, Output } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
import { ActivatedRoute, 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';
|
||||
@ -12,13 +12,31 @@ import { TokenService } from 'src/app/services/token.service';
|
||||
export class PageDeleteMemberComponent implements OnInit {
|
||||
@Output() clickDelete = new EventEmitter();
|
||||
parent: boolean;
|
||||
public membreId: any;
|
||||
public membreInfos: any;
|
||||
|
||||
constructor(private membreService: MembreService, private tokenService: TokenService) {
|
||||
|
||||
constructor(private membreService: MembreService,
|
||||
private tokenService: TokenService,
|
||||
private router: Router,
|
||||
private route: ActivatedRoute) {
|
||||
this.membreInfos = '';
|
||||
this.parent = false;
|
||||
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
/** Pour récuperer l'id du membre à modifier **/
|
||||
this.membreId = this.route.snapshot.paramMap.get('id');
|
||||
|
||||
/** Appel Api **/
|
||||
this.membreService
|
||||
.getMembreId(this.membreId)
|
||||
.subscribe((membreInfos: any) => {
|
||||
this.membreInfos = membreInfos;
|
||||
console.log(membreInfos.id);
|
||||
});
|
||||
|
||||
const roleUser = this.tokenService.getRole();
|
||||
|
||||
if(roleUser == "ROLE_PARENT"){
|
||||
@ -27,9 +45,11 @@ export class PageDeleteMemberComponent implements OnInit {
|
||||
|
||||
}
|
||||
|
||||
onClickDelete(membreId: any){
|
||||
window.alert("Le profil à bien été supprimé!")
|
||||
this.clickDelete.emit(membreId);
|
||||
/** Suppresion d'un membre au clik */
|
||||
onClickDelete(): void {
|
||||
console.log(this.membreInfos);
|
||||
this.membreService.deleteMembre(this.membreInfos.id).subscribe((resp) => {
|
||||
return resp
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ export class PageUpdateMemberComponent implements OnInit {
|
||||
console.log(membre);
|
||||
|
||||
this.membreService.updateMembre(membre)?.subscribe((resp) => {
|
||||
//this.router.navigate(['compte']);
|
||||
this.router.navigate(['compte']);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -45,8 +45,8 @@ export class MembreService {
|
||||
}
|
||||
}
|
||||
|
||||
deleteMembre(membreId: number): Observable<any>{
|
||||
return this.http.delete(`${this.apiUrl}/membres/delete/${membreId}`);
|
||||
deleteMembre(membre: Membre): Observable<any>{
|
||||
return this.http.delete(`${this.apiUrl}/membres/delete/${membre.id}`);
|
||||
}
|
||||
|
||||
updateMembre(membre: Membre): Observable<any> | void {
|
||||
|
Loading…
Reference in New Issue
Block a user