diff --git a/src/app/signup/student-signup/student-signup.component.html b/src/app/signup/student-signup/student-signup.component.html index 31e460d98d2eb944c214c92d8d263b7074be2824..42ae75a458dce82147f7c54493fae0499a2844c9 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 5f04fc109e6b3325e95958f359deb7c840f079f2..a4507ea872f824be7b742aab0389583141a966cc 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, // ); } + }