From b1fdd6833b674da76f0842b3b0fcffe6df746524 Mon Sep 17 00:00:00 2001 From: Aidli Melissa <melissa.aidli@student-cs.fr> Date: Tue, 6 Sep 2022 17:46:13 +0200 Subject: [PATCH] Added date of birth + Changed submit --- .../student-signup.component.html | 9 ++- .../student-signup.component.ts | 60 ++++++++++++++----- 2 files changed, 53 insertions(+), 16 deletions(-) diff --git a/src/app/signup/student-signup/student-signup.component.html b/src/app/signup/student-signup/student-signup.component.html index 31e460d..42ae75a 100644 --- a/src/app/signup/student-signup/student-signup.component.html +++ b/src/app/signup/student-signup/student-signup.component.html @@ -18,6 +18,11 @@ <input matInput type="text" formControlName="lastName" placeholder="Nom" required> </mat-form-field> + <!--Date of birth--> + <mat-form-field class="full-width"> + <input matInput type="date" formControlName="dateOfBirth" placeholder="Date de naissance" required> + </mat-form-field> + <!-- Email --> <mat-form-field class="full-width"> <input matInput type="email" formControlName="email" placeholder="Adresse email" required> @@ -26,6 +31,8 @@ </mat-hint> </mat-form-field> + + <mat-form-field class="full-width"> <input matInput type="tel" formControlName="phoneNumber" placeholder="Numéro de téléphone" required> <mat-hint> @@ -54,7 +61,7 @@ <div class="text-center"> <button mat-raised-button color="primary" [disabled]="!formGroup.valid || loading"> - M'inscrire + Suivant <app-load-spinner *ngIf="loading" [block]="false"></app-load-spinner> </button> </div> diff --git a/src/app/signup/student-signup/student-signup.component.ts b/src/app/signup/student-signup/student-signup.component.ts index 5f04fc1..a4507ea 100644 --- a/src/app/signup/student-signup/student-signup.component.ts +++ b/src/app/signup/student-signup/student-signup.component.ts @@ -73,6 +73,7 @@ export class StudentSignupComponent implements OnInit { firstName: '', lastName: '', email: ['', Validators.email], + dateOfBirth:'', phoneNumber: '', gender:'', adressNumber:'', @@ -108,32 +109,60 @@ export class StudentSignupComponent implements OnInit { toggleShowPersonnalDataForm(){ this.showPersonnalDataForm = !this.showPersonnalDataForm; } + submit() { this.loading = true; - const {email,firstName,lastName,phoneNumber} = this.formGroup.value + const {email,firstName,lastName,phoneNumber,dateOfBirth} = this.formGroup.value //const {gender,adressNumber,street,zipCode,city,personnalPhone,parentsPhone,parentsEmail,school,grade,section,specialTeaching,scholarship,fatherActivity,motherActivity,parentsStatus,dependantsNumber} = this.formGroup.value; - const registration: Registration = {email,firstName,lastName,phoneNumber}; + const registration: Registration = {email,firstName,lastName,phoneNumber,dateOfBirth}; // const personnalData: PersonnalData = {gender,adressNumber,street,zipCode,city,personnalPhone,parentsPhone,parentsEmail,school,grade,section,specialTeaching,scholarship,fatherActivity,motherActivity,parentsStatus,dependantsNumber}; const password: string = this.formGroup.controls.password.value; - this.registrationService.create(registration, password).pipe( - mergeMap(() => this.auth.login(registration.email, password)), - tap(() => this.snackBar.open( - `Ton compte a été créé ! Tu es maintenant connecté.`, - 'OK', - { duration: 3000 }, + + // this.registrationService.create(registration, password).pipe( + // mergeMap(() => this.auth.login(registration.email, password)), + // tap(() => this.snackBar.open( + // `Ton compte a été créé ! Tu es maintenant connecté.`, + // 'OK', + // { duration: 3000 }, + // )), + // tap(()=> this.error = ""), + // tap(() => this.loading = false), + // tap(() => { + // setTimeout(()=>{ + // this.router.navigate(['inscription/waiting']) + + // },3000)}) + + // ).subscribe( + // () => {}, + // (error) => { + + + // this.loading=false + + // if(error.error.email){ + // this.error = "Erreur, cet email est déjà utilisé !" + // } + // } + // ); + + + this.registrationService.create(registration, password).pipe(tap(() => this.snackBar.open( + `Les informations sont valides ! Nous allons t'envoyer un mail d'activation.`,'OK', + { duration: 2000 }, )), tap(()=> this.error = ""), tap(() => this.loading = false), tap(() => { - setTimeout(()=>{ - this.router.navigate(['./membres/compte/donnees']) + setTimeout(()=>{ + this.router.navigate(['inscription/waiting']) - },3000)}) - - ).subscribe( - () => {}, - (error) => { + },2000)}) + + ).subscribe( + () => {}, + (error) => { this.loading=false @@ -151,4 +180,5 @@ export class StudentSignupComponent implements OnInit { // (error) => this.loading = false, // ); } + } -- GitLab