diff --git a/src/app/components/fiche-contact/fiche-contact.component.html b/src/app/components/fiche-contact/fiche-contact.component.html index bbbdbef..54d74e8 100644 --- a/src/app/components/fiche-contact/fiche-contact.component.html +++ b/src/app/components/fiche-contact/fiche-contact.component.html @@ -12,7 +12,8 @@
- +

+ {{ personne.couleur }}

{{ personne.prenom }} {{ personne.nom }}

{{ personne.telephone }}

diff --git a/src/app/pages/page-ajout-contact/page-ajout-contact.component.ts b/src/app/pages/page-ajout-contact/page-ajout-contact.component.ts index 7de50de..c6c662c 100644 --- a/src/app/pages/page-ajout-contact/page-ajout-contact.component.ts +++ b/src/app/pages/page-ajout-contact/page-ajout-contact.component.ts @@ -6,6 +6,7 @@ import { Validators, } from '@angular/forms'; import { Router } from '@angular/router'; +import { TokenService } from 'src/app/services/token.service'; import { Contact } from '../../models/contact'; import { RepertoireService } from '../../services/repertoire.service'; @@ -19,6 +20,7 @@ export class PageAjoutContactComponent implements OnInit { constructor( private repertoireService: RepertoireService, + private tokenService: TokenService, private router: Router, private fb: FormBuilder ) { @@ -49,6 +51,7 @@ export class PageAjoutContactComponent implements OnInit { const emailValue = this.ajoutContactForm.value['emailFc']; const dateNaissanceValue = this.ajoutContactForm.value['dateNaissanceFc']; const adresseValue = this.ajoutContactForm.value['adresseFc']; + const teamId = this.tokenService.getCurrentTeamId() const contact: Contact = { id: '', @@ -59,7 +62,7 @@ export class PageAjoutContactComponent implements OnInit { email: emailValue, dateNaissance: dateNaissanceValue, adresse: adresseValue, - team: { id: '1' }, // changer l'id quand la personne est logé => recuperer l'id de la team du membre + team: { id: teamId }, // changer l'id quand la personne est logé => recuperer l'id de la team du membre }; if (contact.nom !== '') { @@ -67,7 +70,7 @@ export class PageAjoutContactComponent implements OnInit { this.router.navigate(['repertoire/']); }); } else { - // affichage erreur + window.alert("Le contact ne peut pas être ajouté!") } } } diff --git a/src/app/pages/page-modifier-contact/page-modifier-contact.component.html b/src/app/pages/page-modifier-contact/page-modifier-contact.component.html index 5ac961b..3b7f16b 100644 --- a/src/app/pages/page-modifier-contact/page-modifier-contact.component.html +++ b/src/app/pages/page-modifier-contact/page-modifier-contact.component.html @@ -4,10 +4,14 @@
+

Modifier ce contact

-

Modifier ce contact

- + +
+ +
{ - return this.http.get(`${this.apiUrl}/contacts/team/1`); + const teamId = this.tokenService.getCurrentTeamId() + return this.http.get(`${this.apiUrl}/contacts/team/${teamId}`); } getContactById(id: any): Observable { @@ -26,7 +29,7 @@ export class RepertoireService { } addContact(contact: Contact): Observable { - console.log(contact); + const teamId = this.tokenService.getCurrentTeamId() return this.http.post(`${this.apiUrl}/contacts/add`, contact); } @@ -35,6 +38,6 @@ export class RepertoireService { } updateContact(contact: Contact): Observable { - return this.http.put(`${this.apiUrl}/contacts/update/1`, contact); + return this.http.put(`${this.apiUrl}/contacts/update/`, contact); } }