diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts
index 4cbae19..4587264 100644
--- a/src/app/app-routing.module.ts
+++ b/src/app/app-routing.module.ts
@@ -20,6 +20,7 @@ import { PageUpdateMemberComponent } from './pages/page-update-member/page-updat
const routes: Routes = [
{ path: '', redirectTo: 'accueil', pathMatch: 'full' },
+ { path: 'modifier-contact/:id', component: PageModifierContactComponent },
{ path: 'compte', component: PageAccountComponent },
{ path: 'accueil', component: PageAccueilComponent },
{ path: 'ajout-membre', component: PageAddMemberComponent },
@@ -35,7 +36,6 @@ const routes: Routes = [
{ path: 'modifier-membre', component: PageUpdateMemberComponent },
{ path: 'ajouter-contact', component: PageAjoutContactComponent },
{ path: 'creation-team', component: PageCreationTeamComponent },
- { path: 'modifier-contact', component: PageModifierContactComponent },
{ path: '**', component: PageNotFoundComponent },
];
diff --git a/src/app/components/fiche-contact/fiche-contact.component.html b/src/app/components/fiche-contact/fiche-contact.component.html
index 42ae5da..1d4eb48 100644
--- a/src/app/components/fiche-contact/fiche-contact.component.html
+++ b/src/app/components/fiche-contact/fiche-contact.component.html
@@ -1,7 +1,7 @@
-
diff --git a/src/app/models/contact.ts b/src/app/models/contact.ts
index 2c632a4..539aab3 100644
--- a/src/app/models/contact.ts
+++ b/src/app/models/contact.ts
@@ -1,8 +1,10 @@
export interface Contact {
+ id: string;
nom: string;
prenom: string;
telephone: string;
email: string;
adresse: string;
dateNaissance: Date;
+ team: any;
}
diff --git a/src/app/pages/page-ajout-contact/page-ajout-contact.component.html b/src/app/pages/page-ajout-contact/page-ajout-contact.component.html
index 30c5a21..981a9c2 100644
--- a/src/app/pages/page-ajout-contact/page-ajout-contact.component.html
+++ b/src/app/pages/page-ajout-contact/page-ajout-contact.component.html
@@ -73,7 +73,7 @@
-
Valider
diff --git a/src/app/pages/page-ajout-contact/page-ajout-contact.component.scss b/src/app/pages/page-ajout-contact/page-ajout-contact.component.scss
index ca7893e..0f5ceb6 100644
--- a/src/app/pages/page-ajout-contact/page-ajout-contact.component.scss
+++ b/src/app/pages/page-ajout-contact/page-ajout-contact.component.scss
@@ -24,3 +24,8 @@
border-bottom-right-radius: 0;
border-bottom-left-radius: 0;
}
+
+.btn-secondary {
+ color: #fff;
+ background-color: #5a1e63 !important;
+}
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 2bb57b1..d99669d 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
@@ -26,7 +26,7 @@ export class PageAjoutContactComponent implements OnInit {
}
ngOnInit(): void {
- // *********************************pensser a changer group car déprécié********************************
+ // *********************************pensser à changer group car déprécié********************************
this.ajoutContactForm = this.fb.group({
lastNameFc: new FormControl('', [Validators.required]),
firstNameFc: new FormControl('', [Validators.required]),
@@ -52,12 +52,14 @@ export class PageAjoutContactComponent implements OnInit {
const adresseValue = this.ajoutContactForm.value['adresseFc'];
const contact: Contact = {
+ id: '',
nom: lastNameValue,
prenom: firstNameValue,
telephone: telephoneValue,
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
};
if (contact.nom !== '') {
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 c5b4b08..5ac961b 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
@@ -2,6 +2,7 @@
+
@@ -58,7 +59,7 @@
id="floatingInputdateNaissance"
placeholder=""
name="dateNaissance"
- formControlName="dateNaissanceFc">
+ formControlName="dateNaissanceFc" value= "{{ listContactInfo.dateNaissance }}">
@@ -69,11 +70,11 @@
id="floatingInputAdresse"
placeholder=""
name="adresse"
- formControlName="adresseFc">
+ formControlName="adresseFc" value= "{{ listContactInfo.adresse }}">
- Valider
diff --git a/src/app/pages/page-modifier-contact/page-modifier-contact.component.scss b/src/app/pages/page-modifier-contact/page-modifier-contact.component.scss
index b3720e0..6709ac8 100644
--- a/src/app/pages/page-modifier-contact/page-modifier-contact.component.scss
+++ b/src/app/pages/page-modifier-contact/page-modifier-contact.component.scss
@@ -24,3 +24,8 @@
border-bottom-right-radius: 0;
border-bottom-left-radius: 0;
}
+
+.btn-secondary {
+ color: #fff;
+ background-color: #5a1e63 !important;
+}
diff --git a/src/app/pages/page-modifier-contact/page-modifier-contact.component.ts b/src/app/pages/page-modifier-contact/page-modifier-contact.component.ts
index 7b1d5e1..0cfa9d9 100644
--- a/src/app/pages/page-modifier-contact/page-modifier-contact.component.ts
+++ b/src/app/pages/page-modifier-contact/page-modifier-contact.component.ts
@@ -5,7 +5,7 @@ import {
FormGroup,
Validators,
} from '@angular/forms';
-import { Router } from '@angular/router';
+import { ActivatedRoute, Router } from '@angular/router';
import { Contact } from '../../models/contact';
import { RepertoireService } from '../../services/repertoire.service';
@@ -17,22 +17,32 @@ import { RepertoireService } from '../../services/repertoire.service';
export class PageModifierContactComponent implements OnInit {
public modifContactForm: FormGroup;
public contactInfo: FormGroup;
+ public listContactInfo: any;
+ public personneid: any;
constructor(
private repertoireService: RepertoireService,
private router: Router,
- private fb: FormBuilder
+ private fb: FormBuilder,
+ private route: ActivatedRoute
) {
this.modifContactForm = new FormGroup({});
this.contactInfo = this.initForm();
-
- // this.repertoireService.getContactById()?.subscribe((contact: Contact) => {
- // this.contactInfo = this.initForm(contact);
- // });
+ this.listContactInfo = '';
}
ngOnInit(): void {
- // *********************************pensser a changer group car déprécié********************************
+ this.personneid = this.route.snapshot.paramMap.get('id'); // récupère l'id du contact à modifier
+ console.log(this.personneid);
+
+ this.repertoireService
+ .getContactById(this.personneid)
+ .subscribe((listContactInfo: any) => {
+ console.log(listContactInfo);
+ this.listContactInfo = listContactInfo;
+ });
+
+ // *********************************pensser à changer group car déprécié********************************
this.modifContactForm = this.fb.group({
lastNameFc: new FormControl('', [Validators.required]),
firstNameFc: new FormControl('', [Validators.required]),
@@ -47,6 +57,7 @@ export class PageModifierContactComponent implements OnInit {
});
}
+ //Méthode qui initialise les champs du formulaire avec les infos de la BDD
private initForm(contact?: Contact): FormGroup {
return this.fb.group({
firstName: [contact ? contact.nom : ''],
@@ -58,6 +69,7 @@ export class PageModifierContactComponent implements OnInit {
});
}
+ //Méthode qui envoie les champs modifiés pour mise à jour
public onSubmit(): void {
console.log('value : ', this.modifContactForm.value);
console.log('form : ', this.modifContactForm);
@@ -69,20 +81,18 @@ export class PageModifierContactComponent implements OnInit {
const adresseValue = this.modifContactForm.value['adresseFc'];
const contact: Contact = {
+ id: this.personneid,
nom: lastNameValue,
prenom: firstNameValue,
telephone: telephoneValue,
email: emailValue,
dateNaissance: dateNaissanceValue,
adresse: adresseValue,
+ team: { id: this.listContactInfo.team.id },
};
- if (contact.nom !== '') {
- this.repertoireService.updateContact(contact).subscribe((resp) => {
- this.router.navigate(['repertoire/']);
- });
- } else {
- // affichage erreur
- }
+ this.repertoireService.updateContact(contact).subscribe((resp) => {
+ this.router.navigate(['repertoire/']);
+ });
}
}
diff --git a/src/app/pages/page-not-found/page-not-found.component.html b/src/app/pages/page-not-found/page-not-found.component.html
index be7d620..575a83b 100644
--- a/src/app/pages/page-not-found/page-not-found.component.html
+++ b/src/app/pages/page-not-found/page-not-found.component.html
@@ -1,11 +1,11 @@
diff --git a/src/app/pages/page-repertoire/page-repertoire.component.ts b/src/app/pages/page-repertoire/page-repertoire.component.ts
index c4fff1b..b7a1859 100644
--- a/src/app/pages/page-repertoire/page-repertoire.component.ts
+++ b/src/app/pages/page-repertoire/page-repertoire.component.ts
@@ -1,4 +1,6 @@
import { Component, OnInit } from '@angular/core';
+import { ActivatedRoute, Router } from '@angular/router';
+import { Contact } from 'src/app/models/contact';
import { RepertoireService } from 'src/app/services/repertoire.service';
@Component({
@@ -9,12 +11,19 @@ import { RepertoireService } from 'src/app/services/repertoire.service';
export class PageRepertoireComponent implements OnInit {
public listContact: any[];
public listFull: any[];
+ public listContactInfo: any;
+ public personneid: any;
keyword: any;
openDetails: any;
- constructor(private repertoireService: RepertoireService) {
+ constructor(
+ private repertoireService: RepertoireService,
+ private router: Router,
+ private route: ActivatedRoute
+ ) {
this.listContact = [];
this.listFull = [];
+ this.listContactInfo = '';
}
ngOnInit(): void {
@@ -23,6 +32,16 @@ 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
@@ -47,4 +66,8 @@ export class PageRepertoireComponent implements OnInit {
console.log(personne);
this.openDetails = personne;
}
+
+ // this.repertoireService.deleteContact(contact).subscribe((resp) => {
+ // this.router.navigate(['repertoire/']);
+ // });
}
diff --git a/src/app/services/repertoire.service.ts b/src/app/services/repertoire.service.ts
index 1b1713a..a452854 100644
--- a/src/app/services/repertoire.service.ts
+++ b/src/app/services/repertoire.service.ts
@@ -21,8 +21,8 @@ export class RepertoireService {
return this.http.get(`${this.apiUrl}/contacts/team/1`);
}
- getContactById(contact: Contact): Observable {
- return this.http.get(`${this.apiUrl}/contacts/{id}`);
+ getContactById(id: any): Observable {
+ return this.http.get(`${this.apiUrl}/contacts/` + id);
}
addContact(contact: Contact): Observable {
@@ -31,8 +31,8 @@ export class RepertoireService {
return this.http.post(`${this.apiUrl}/contacts/add`, contact);
}
- deleteContact() {
- return this.http.delete(`${this.apiUrl}/contacts/delete`);
+ deleteContact(contact: Contact): Observable {
+ return this.http.delete(`${this.apiUrl}/contacts/delete/1`);
}
updateContact(contact: Contact): Observable {
diff --git a/src/assets/images/adresse.jpg b/src/assets/images/adresse.jpg
deleted file mode 100644
index deca31c..0000000
Binary files a/src/assets/images/adresse.jpg and /dev/null differ