fonction delete

This commit is contained in:
AlineRinquin 2022-02-15 13:58:06 +01:00
parent 7bed54db11
commit 61cacda89b
5 changed files with 27 additions and 17 deletions

View file

@ -14,6 +14,7 @@ export class FicheContactComponent implements OnInit {
ngOnInit(): void {}
onClickDelete(numPerson: number){
window.alert("Le contact à bien été supprimé!")
this.clickDelete.emit(numPerson);
}
}

View file

@ -33,16 +33,6 @@ export class PageRepertoireComponent implements OnInit {
this.listContact = listContact;
this.listFull = listContact;
});
this.personneid = this.route.snapshot.paramMap.get('id');
console.log(this.personneid);
this.repertoireService
.getContactById(this.personneid)
.subscribe((listContactInfo: any) => {
console.log(listContactInfo);
this.listContactInfo = listContactInfo;
});
}
// Méthode pour récuper ce qui est saisi dans l'input
@ -63,15 +53,20 @@ export class PageRepertoireComponent implements OnInit {
this.listContact = prenom;
}
// Méthode qui au click va ouvrir les détails d'un contat
// Méthode qui au click va ouvrir les détails d'un contact
onClick(personne: any) {
console.log(personne);
this.openDetails = personne;
}
onClickDelete(contact: Contact){
this.repertoireService.deleteContact(contact).subscribe((resp) => {
// Méthode qui au click va supprimer un contact
onClickDelete(contactId: number){
this.repertoireService.deleteContact(contactId).subscribe((resp) => {
if(contactId) {
this.listContact.forEach(contactId => console.log(contactId))
}else{
window.alert("Le contact ne peut pas être supprimé!")
}
this.router.navigate(['repertoire/']);
});
}

View file

@ -27,12 +27,11 @@ export class RepertoireService {
addContact(contact: Contact): Observable<any> {
console.log(contact);
return this.http.post(`${this.apiUrl}/contacts/add`, contact);
}
deleteContact(contact: Contact): Observable<any> {
return this.http.delete(`${this.apiUrl}/contacts/delete/1`);
deleteContact(contactId: number): Observable<any> {
return this.http.delete(`${this.apiUrl}/contacts/delete/${contactId}`);
}
updateContact(contact: Contact): Observable<any> {