From 8d5cd03d337492b48bfdcf1c28228564574b6e59 Mon Sep 17 00:00:00 2001 From: Blandine Bajard <83599148+BlandineBajard@users.noreply.github.com> Date: Thu, 20 Jan 2022 09:44:19 +0100 Subject: [PATCH 1/2] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 07be01d..3ffd157 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,8 @@ This project was generated with [Angular CLI](https://github.com/angular/angular ## Development server +Run npm install + Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files. ## Code scaffolding From 5904f64103165feaf9bf395437836fb84c332f8b Mon Sep 17 00:00:00 2001 From: HarmandI Date: Thu, 20 Jan 2022 18:01:32 +0100 Subject: [PATCH 2/2] =?UTF-8?q?d=C3=A9but=20add=20Member?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/models/membre.ts | 6 +- .../page-add-member.component.html | 108 ++++++++++++++++++ .../page-add-member.component.scss | 32 ++++++ .../page-add-member.component.ts | 93 ++++++++++++++- .../page-signup/page-signup.component.ts | 11 +- src/app/services/auth.service.ts | 9 +- src/environments/environment.ts | 2 +- 7 files changed, 248 insertions(+), 13 deletions(-) diff --git a/src/app/models/membre.ts b/src/app/models/membre.ts index 798a31c..cea8af4 100644 --- a/src/app/models/membre.ts +++ b/src/app/models/membre.ts @@ -1,10 +1,10 @@ export interface Membre { - firstName: string; - lastName: string; + nom: string; + prenom: string; email: string; password: string; dateNaissance: Date; - teamName: string; profil: boolean; + roleList: string[]; passwordConfirm: string; } diff --git a/src/app/pages/page-add-member/page-add-member.component.html b/src/app/pages/page-add-member/page-add-member.component.html index e91fa55..8614282 100644 --- a/src/app/pages/page-add-member/page-add-member.component.html +++ b/src/app/pages/page-add-member/page-add-member.component.html @@ -1 +1,109 @@ + +
+
+
+

J'inscris un nouveau membre

+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ + +

+ Value : {{ addMemberForm.value | json }} +

+

+ Form valid : {{ addMemberForm.valid }} +

+ +
+
diff --git a/src/app/pages/page-add-member/page-add-member.component.scss b/src/app/pages/page-add-member/page-add-member.component.scss index e69de29..333e617 100644 --- a/src/app/pages/page-add-member/page-add-member.component.scss +++ b/src/app/pages/page-add-member/page-add-member.component.scss @@ -0,0 +1,32 @@ +.login-form { + height: 100vh; + padding-top: 40px; + background-color: #f5f5f5; +} + +.form-signup { + width: 100%; + max-width: 330px; + padding: 15px; + margin: auto; +} + +.form-signup .checkbox { + font-weight: 400; +} + +.form-signup .form-floating:focus-within { + z-index: 2; +} + +.form-signup input[type="email"] { + margin-bottom: -1px; + border-bottom-right-radius: 0; + border-bottom-left-radius: 0; +} + +.form-signup input[type="password"] { + margin-bottom: 10px; + border-top-left-radius: 0; + border-top-right-radius: 0; +} diff --git a/src/app/pages/page-add-member/page-add-member.component.ts b/src/app/pages/page-add-member/page-add-member.component.ts index a77f630..426a262 100644 --- a/src/app/pages/page-add-member/page-add-member.component.ts +++ b/src/app/pages/page-add-member/page-add-member.component.ts @@ -1,4 +1,8 @@ import { Component, OnInit } from '@angular/core'; +import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms'; +import { Router } from '@angular/router'; +import { Membre } from 'src/app/models/membre'; +import { AuthService } from 'src/app/services/auth.service'; @Component({ selector: 'app-page-add-member', @@ -7,9 +11,92 @@ import { Component, OnInit } from '@angular/core'; }) export class PageAddMemberComponent implements OnInit { - constructor() { } - - ngOnInit(): void { + public addMemberForm: FormGroup; + constructor( + private authService: AuthService, + private router: Router, + private fb: FormBuilder + ) { + this.addMemberForm = new FormGroup({}); } + ngOnInit(): void { + // *********************************pensser a changer group car déprécié******************************** + this.addMemberForm = this.fb.group( + { + firstNameFc: new FormControl('', [Validators.required]), + lastNameFc: new FormControl('', [Validators.required]), + dateNaissanceFc: new FormControl('', [Validators.required]), + profilFc: new FormControl('', [Validators.required]), + emailFc: new FormControl('', [ + Validators.email, + Validators.required, + Validators.pattern(/^([\w\.\-_]+)?\w+@[\w-_]+(\.\w+){1,}/gim), + ]), // chercher une meilleure regex + passwordFc: new FormControl('', [ + Validators.minLength(8), + Validators.required, + ]), + passwordConfirmFc: new FormControl('', [ + Validators.minLength(8), + Validators.required, + ]), + }, + { + validator: this.ConfirmedValidator('passwordFc', 'passwordConfirmFc'), + } + ); + } + + public onSubmit(): void { + console.log('value : ', this.addMemberForm.value); + console.log('form : ', this.addMemberForm); + const firstNameValue = this.addMemberForm.value['firstNameFc']; + const lastNameValue = this.addMemberForm.value['lastNameFc']; + const emailValue = this.addMemberForm.value['emailFc']; + const passwordValue = this.addMemberForm.value['passwordFc']; + const dateNaissanceValue = this.addMemberForm.value['dateNaissanceFc']; + const teamNameValue = this.addMemberForm.value['teamNameFc']; + const profilValue = this.addMemberForm.value['profilFc']; + const passwordConfirmValue = this.addMemberForm.value['passwordConfirmFc']; + const teamValue = ['']; + + const membre: Membre = { + nom: firstNameValue, + prenom: lastNameValue, + email: emailValue, + password: passwordValue, + dateNaissance: dateNaissanceValue, + profil: profilValue, + passwordConfirm: passwordConfirmValue, + roleList: ["ROLE_PARENT"] + }; + + + if (membre.email !== '' && membre.password !== '') { + this.authService.signup(membre).subscribe((resp) => { + this.router.navigate(['account/signin']); + }); + } else { + // affichage erreur + } + } + + ConfirmedValidator(controlName: string, matchingControlName: string) { + return (formGroup: FormGroup) => { + const control = formGroup.controls[controlName]; + const matchingControl = formGroup.controls[matchingControlName]; + if ( + matchingControl.errors && + !matchingControl.errors['confirmedValidator'] + ) { + return; + } + if (control.value !== matchingControl.value) { + matchingControl.setErrors({ confirmedValidator: true }); + } else { + matchingControl.setErrors(null); + } + }; + } } diff --git a/src/app/pages/page-signup/page-signup.component.ts b/src/app/pages/page-signup/page-signup.component.ts index 4a5243a..210033c 100644 --- a/src/app/pages/page-signup/page-signup.component.ts +++ b/src/app/pages/page-signup/page-signup.component.ts @@ -25,7 +25,7 @@ export class PageSignupComponent implements OnInit { } ngOnInit(): void { - // *********************************pensser a changer group car déprécié******************************** + // *********************************penser a changer group car déprécié******************************** this.signupForm = this.fb.group( { firstNameFc: new FormControl('', [Validators.required]), @@ -64,21 +64,22 @@ export class PageSignupComponent implements OnInit { const teamNameValue = this.signupForm.value['teamNameFc']; const profilValue = this.signupForm.value['profilFc']; const passwordConfirmValue = this.signupForm.value['passwordConfirmFc']; + const teamValue = ''; const membre: Membre = { - firstName: firstNameValue, - lastName: lastNameValue, + nom: firstNameValue, + prenom: lastNameValue, email: emailValue, password: passwordValue, dateNaissance: dateNaissanceValue, - teamName: teamNameValue, profil: profilValue, passwordConfirm: passwordConfirmValue, + roleList: ["ROLE_PARENT"] }; if (membre.email !== '' && membre.password !== '') { this.authService.signup(membre).subscribe((resp) => { - this.router.navigate(['account/signin']); + this.router.navigate(['accueil']); }); } else { // affichage erreur diff --git a/src/app/services/auth.service.ts b/src/app/services/auth.service.ts index 918bfd9..3c6aa6c 100644 --- a/src/app/services/auth.service.ts +++ b/src/app/services/auth.service.ts @@ -20,7 +20,7 @@ export class AuthService { signup(membre: Membre): Observable { console.log(membre); - return this.http.post(`${this.apiUrl}/creation-compte`, membre); + return this.http.post(`${this.apiUrl}/membres/sign-up`, membre); } signin(email: string, password: string): Observable { @@ -55,4 +55,11 @@ export class AuthService { return this.http.post(`${this.apiUrl}/forgot-psw`, body); } + + addMember(membre: Membre): Observable { + console.log(membre); + + return this.http.post(`${this.apiUrl}/tableau-de-bord`, membre); + } + } diff --git a/src/environments/environment.ts b/src/environments/environment.ts index ecf1531..90149fd 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -4,7 +4,7 @@ export const environment = { production: false, - apiUrl: 'http://localhost:3306', + apiUrl: 'http://localhost:8088', tokenKey: 'TOKEN-ORGANIZEE', };