Skip to content
Snippets Groups Projects
Unverified Commit 266b849c authored by Secteur Geek's avatar Secteur Geek Committed by GitHub
Browse files

Revert "Testbranch (#66)" (#67)

This reverts commit 6cfa4b90.
parent 6cfa4b90
No related branches found
No related tags found
No related merge requests found
{
"python.pythonPath": "C:\\Users\\feliv\\anaconda3\\python.exe"
}
\ No newline at end of file
import { FormControl, FormGroupDirective, NgForm } from '@angular/forms';
import { ErrorStateMatcher } from '@angular/material';
// From: https://stackoverflow.com/a/51606362
export class EmailErrorStateMatcher implements ErrorStateMatcher {
isErrorState(control: FormControl | null, form: FormGroupDirective | NgForm | null): boolean {
const invalidParent = !!(control && control.parent && control.parent.invalid && control.parent.dirty);
return (control && control.dirty && invalidParent);
}
}
\ No newline at end of file
...@@ -3,4 +3,3 @@ export * from './registration.service'; ...@@ -3,4 +3,3 @@ export * from './registration.service';
export * from './personnalData.model'; export * from './personnalData.model';
export * from './personnalData.service'; export * from './personnalData.service';
export * from './password.matcher'; export * from './password.matcher';
export * from './email.matcher';
...@@ -26,15 +26,6 @@ ...@@ -26,15 +26,6 @@
</mat-hint> </mat-hint>
</mat-form-field> </mat-form-field>
<!-- Confirm Email -->
<mat-form-field class="full-width">
<input matInput type="email" formControlName="emailConfirm" placeholder="Confirmer l'adresse email"
[errorStateMatcher]="emailMatcher">
<mat-error *ngIf="formGroup.hasError('emailsDifferent')">
Les adresses emails doivent être identiques.
</mat-error>
</mat-form-field>
<mat-form-field class="full-width"> <mat-form-field class="full-width">
<input matInput type="tel" formControlName="phoneNumber" placeholder="Numéro de téléphone" required> <input matInput type="tel" formControlName="phoneNumber" placeholder="Numéro de téléphone" required>
<mat-hint> <mat-hint>
...@@ -55,7 +46,7 @@ ...@@ -55,7 +46,7 @@
<!-- Confirm password --> <!-- Confirm password -->
<mat-form-field class="full-width"> <mat-form-field class="full-width">
<input matInput type="password" formControlName="passwordConfirm" placeholder="Confirmer le mot de passe" <input matInput type="password" formControlName="passwordConfirm" placeholder="Confirmer le mot de passe"
[errorStateMatcher]="passwordMatcher"> [errorStateMatcher]="matcher">
<mat-error *ngIf="formGroup.hasError('passwordsDifferent')"> <mat-error *ngIf="formGroup.hasError('passwordsDifferent')">
Les mots de passe doivent être identiques. Les mots de passe doivent être identiques.
</mat-error> </mat-error>
......
...@@ -4,7 +4,7 @@ import { Router } from '@angular/router'; ...@@ -4,7 +4,7 @@ import { Router } from '@angular/router';
import { MatSnackBar } from '@angular/material'; import { MatSnackBar } from '@angular/material';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { tap, mergeMap } from 'rxjs/operators'; import { tap, mergeMap } from 'rxjs/operators';
import { Registration, RegistrationService, PasswordErrorStateMatcher, EmailErrorStateMatcher, PersonnalData, PersonnalDataService } from '../core'; import { Registration, RegistrationService, PasswordErrorStateMatcher,PersonnalData,PersonnalDataService } from '../core';
import { AuthService } from 'app/core'; import { AuthService } from 'app/core';
...@@ -52,8 +52,7 @@ export class StudentSignupComponent implements OnInit { ...@@ -52,8 +52,7 @@ export class StudentSignupComponent implements OnInit {
{id:"no",name:"Non"}, {id:"no",name:"Non"},
] ]
passwordMatcher = new PasswordErrorStateMatcher(); matcher = new PasswordErrorStateMatcher();
emailMatcher = new EmailErrorStateMatcher();
constructor( constructor(
private registrationService: RegistrationService, private registrationService: RegistrationService,
...@@ -75,7 +74,6 @@ export class StudentSignupComponent implements OnInit { ...@@ -75,7 +74,6 @@ export class StudentSignupComponent implements OnInit {
firstName: '', firstName: '',
lastName: '', lastName: '',
email: ['', Validators.email], email: ['', Validators.email],
emailConfirm: '',
phoneNumber: '', phoneNumber: '',
gender:'', gender:'',
adressNumber:'', adressNumber:'',
...@@ -99,7 +97,7 @@ export class StudentSignupComponent implements OnInit { ...@@ -99,7 +97,7 @@ export class StudentSignupComponent implements OnInit {
agree: [false, Validators.required], agree: [false, Validators.required],
filledForm: false, filledForm: false,
acceptedConditions: false, acceptedConditions: false,
}, { validator:[(group) => this.checkPasswords(group), (group)=>this.checkEmails(group)] }) }, { validator: (group) => this.checkPasswords(group)},)
console.log(this.formGroup.value.agree) console.log(this.formGroup.value.agree)
} }
...@@ -108,17 +106,15 @@ export class StudentSignupComponent implements OnInit { ...@@ -108,17 +106,15 @@ export class StudentSignupComponent implements OnInit {
const passwordConfirm = group.controls.passwordConfirm.value; const passwordConfirm = group.controls.passwordConfirm.value;
return password === passwordConfirm ? null : { passwordsDifferent: true }; return password === passwordConfirm ? null : { passwordsDifferent: true };
} }
private checkEmails(group: FormGroup): null | any { toggleShowPersonnalDataForm(){
const email = group.controls.email.value; this.showPersonnalDataForm = !this.showPersonnalDataForm;
const emailConfirm = group.controls.emailConfirm.value;
return email === emailConfirm ? null : { emailsDifferent: true };
} }
submit() { submit() {
this.loading = true; this.loading = true;
const {email,firstName,lastName,phoneNumber} = this.formGroup.value const {email,firstName,lastName,phoneNumber} = 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};
// 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; const password: string = this.formGroup.controls.password.value;
this.registrationService.create(registration, password).pipe( this.registrationService.create(registration, password).pipe(
...@@ -134,8 +130,7 @@ export class StudentSignupComponent implements OnInit { ...@@ -134,8 +130,7 @@ export class StudentSignupComponent implements OnInit {
setTimeout(()=>{ setTimeout(()=>{
this.router.navigate(['./membres']) this.router.navigate(['./membres'])
}, 3000) },3000)})
})
).subscribe( ).subscribe(
() => {}, () => {},
...@@ -148,7 +143,6 @@ export class StudentSignupComponent implements OnInit { ...@@ -148,7 +143,6 @@ export class StudentSignupComponent implements OnInit {
this.error = "Erreur, cet email est déjà utilisé !" this.error = "Erreur, cet email est déjà utilisé !"
} }
} }
); );
// this.personnalDataService.create(personnalData).pipe( // this.personnalDataService.create(personnalData).pipe(
// tap(() => this.loading = false), // tap(() => this.loading = false),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment