+
+
+
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',
};