-
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 f63276c..c5b4b08 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
@@ -1 +1,82 @@
-
page-modifier-contact works!
+
+
\ No newline at end of file
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 e69de29..b3720e0 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
@@ -0,0 +1,26 @@
+.login-form {
+ height: 100vh;
+ padding-top: 40px;
+ background-color: #f5f5f5;
+}
+
+.form-modifContact {
+ width: 100%;
+ max-width: 330px;
+ padding: 15px;
+ margin: auto;
+}
+
+.form-modifContact .checkbox {
+ font-weight: 400;
+}
+
+.form-modifContact .form-floating:focus-within {
+ z-index: 2;
+}
+
+.form-modifContact input[type="email"] {
+ margin-bottom: -1px;
+ border-bottom-right-radius: 0;
+ border-bottom-left-radius: 0;
+}
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 b5c46df..7b1d5e1 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
@@ -1,15 +1,88 @@
import { Component, OnInit } from '@angular/core';
+import {
+ FormBuilder,
+ FormControl,
+ FormGroup,
+ Validators,
+} from '@angular/forms';
+import { Router } from '@angular/router';
+import { Contact } from '../../models/contact';
+import { RepertoireService } from '../../services/repertoire.service';
@Component({
selector: 'app-page-modifier-contact',
templateUrl: './page-modifier-contact.component.html',
- styleUrls: ['./page-modifier-contact.component.scss']
+ styleUrls: ['./page-modifier-contact.component.scss'],
})
export class PageModifierContactComponent implements OnInit {
+ public modifContactForm: FormGroup;
+ public contactInfo: FormGroup;
- constructor() { }
+ constructor(
+ private repertoireService: RepertoireService,
+ private router: Router,
+ private fb: FormBuilder
+ ) {
+ this.modifContactForm = new FormGroup({});
+ this.contactInfo = this.initForm();
- ngOnInit(): void {
+ // this.repertoireService.getContactById()?.subscribe((contact: Contact) => {
+ // this.contactInfo = this.initForm(contact);
+ // });
}
+ ngOnInit(): void {
+ // *********************************pensser a changer group car déprécié********************************
+ this.modifContactForm = this.fb.group({
+ lastNameFc: new FormControl('', [Validators.required]),
+ firstNameFc: new FormControl('', [Validators.required]),
+ telephoneFc: new FormControl('', [Validators.required]),
+ emailFc: new FormControl('', [
+ Validators.email,
+ Validators.required,
+ Validators.pattern(/^([\w\.\-_]+)?\w+@[\w-_]+(\.\w+){1,}/gim),
+ ]), // chercher une meilleure regex
+ dateNaissanceFc: new FormControl('', [Validators.required]),
+ adresseFc: new FormControl('', [Validators.required]),
+ });
+ }
+
+ private initForm(contact?: Contact): FormGroup {
+ return this.fb.group({
+ firstName: [contact ? contact.nom : ''],
+ lastName: [contact ? contact.prenom : ''],
+ telephone: [contact ? contact.telephone : ''],
+ email: [contact ? contact.email : ''],
+ dateNaissance: [contact ? contact.dateNaissance : ''],
+ adresse: [contact ? contact.adresse : ''],
+ });
+ }
+
+ public onSubmit(): void {
+ console.log('value : ', this.modifContactForm.value);
+ console.log('form : ', this.modifContactForm);
+ const firstNameValue = this.modifContactForm.value['firstNameFc'];
+ const lastNameValue = this.modifContactForm.value['lastNameFc'];
+ const telephoneValue = this.modifContactForm.value['telephoneFc'];
+ const emailValue = this.modifContactForm.value['emailFc'];
+ const dateNaissanceValue = this.modifContactForm.value['dateNaissanceFc'];
+ const adresseValue = this.modifContactForm.value['adresseFc'];
+
+ const contact: Contact = {
+ nom: lastNameValue,
+ prenom: firstNameValue,
+ telephone: telephoneValue,
+ email: emailValue,
+ dateNaissance: dateNaissanceValue,
+ adresse: adresseValue,
+ };
+
+ if (contact.nom !== '') {
+ this.repertoireService.updateContact(contact).subscribe((resp) => {
+ this.router.navigate(['repertoire/']);
+ });
+ } else {
+ // affichage erreur
+ }
+ }
}
diff --git a/src/app/services/repertoire.service.ts b/src/app/services/repertoire.service.ts
index eb07eda..1b1713a 100644
--- a/src/app/services/repertoire.service.ts
+++ b/src/app/services/repertoire.service.ts
@@ -21,6 +21,10 @@ export class RepertoireService {
return this.http.get(`${this.apiUrl}/contacts/team/1`);
}
+ getContactById(contact: Contact): Observable
{
+ return this.http.get(`${this.apiUrl}/contacts/{id}`);
+ }
+
addContact(contact: Contact): Observable {
console.log(contact);
@@ -31,7 +35,7 @@ export class RepertoireService {
return this.http.delete(`${this.apiUrl}/contacts/delete`);
}
- // updateContact(){
- // return this.http.put(`${this.apiUrl}/contacts/update/1`);
- // }
+ updateContact(contact: Contact): Observable {
+ return this.http.put(`${this.apiUrl}/contacts/update/1`, contact);
+ }
}
From a723a02a56d7cbf0644a827380df4fdc4b4895fb Mon Sep 17 00:00:00 2001
From: AlineRinquin <90188226+AlineRinquin@users.noreply.github.com>
Date: Sun, 23 Jan 2022 15:08:17 +0100
Subject: [PATCH 2/2] Fonctionn modifier contact ok
---
src/app/app-routing.module.ts | 2 +-
.../fiche-contact.component.html | 2 +-
src/app/models/contact.ts | 2 +
.../page-ajout-contact.component.html | 2 +-
.../page-ajout-contact.component.scss | 5 +++
.../page-ajout-contact.component.ts | 4 +-
.../page-modifier-contact.component.html | 15 +++----
.../page-modifier-contact.component.scss | 5 +++
.../page-modifier-contact.component.ts | 38 +++++++++++-------
.../page-not-found.component.html | 4 +-
.../page-repertoire.component.ts | 25 +++++++++++-
src/app/services/repertoire.service.ts | 8 ++--
src/assets/images/adresse.jpg | Bin 11538 -> 0 bytes
13 files changed, 80 insertions(+), 32 deletions(-)
delete mode 100644 src/assets/images/adresse.jpg
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 @@
-
+
Modifier
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 }}">