Skip to content
Snippets Groups Projects
Commit bb7afe84 authored by Hugo SUBTIL's avatar Hugo SUBTIL
Browse files

Merge branch 'feat/creationCompte' into 'dev'

feat(createAccount)  : Update create account form

See merge request web-et-numerique/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_client!52
parents 72874c9d 001e1c86
No related branches found
No related tags found
3 merge requests!68Recette,!67Dev,!52feat(createAccount) : Update create account form
export class User {
_id: string;
email: string;
name: string;
surname: string;
phone: string;
password?: string;
emailVerified: boolean;
role: number;
......
......@@ -4,6 +4,21 @@
<input type="email" autocomplete="on" formControlName="email" class="form-control" />
<app-validator-form *ngIf="submitted" [control]="getAccountControl('email')"></app-validator-form>
</div>
<div class="form-group">
<label for="surname">Nom</label>
<input type="text" formControlName="surname" class="form-control" />
<app-validator-form *ngIf="submitted" [control]="getAccountControl('surname')"></app-validator-form>
</div>
<div class="form-group">
<label for="name">Prénom</label>
<input type="text" formControlName="name" class="form-control" />
<app-validator-form *ngIf="submitted" [control]="getAccountControl('name')"></app-validator-form>
</div>
<div class="form-group">
<label for="phone">Téléphone</label>
<input type="text" formControlName="phone" class="form-control" (input)="modifyPhoneInput($event.target.value)" />
<app-validator-form *ngIf="submitted" [control]="getAccountControl('phone')"></app-validator-form>
</div>
<div class="form-group">
<label for="password">Mot de passe</label>
<input type="password" autocomplete="on" formControlName="password" class="form-control" />
......
......@@ -17,6 +17,9 @@ export class CreateAccountFormComponent implements OnInit {
this.accountForm = new FormGroup(
{
email: new FormControl('', Validators.required),
name: new FormControl('', Validators.required),
surname: new FormControl('', Validators.required),
phone: new FormControl('', [Validators.required, Validators.pattern('([0-9]{2} ){4}[0-9]{2}')]), //NOSONAR
password: new FormControl('', [
Validators.required,
Validators.pattern(/^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#$%^&*])(?=.{8,})/), //NOSONAR
......@@ -37,4 +40,14 @@ export class CreateAccountFormComponent implements OnInit {
public getAccountControl(nameControl: string): AbstractControl {
return this.accountForm.get(nameControl);
}
public modifyPhoneInput(phoneNumber: string): void {
// Take length of phone number without spaces.
let phoneNoSpace = phoneNumber.replace(/\s/g, '');
// Check to refresh every 2 number.
if (phoneNoSpace.length % 2 == 0) {
// Add space every 2 number
this.accountForm.get('phone').setValue(phoneNoSpace.replace(/(?!^)(?=(?:\d{2})+$)/g, ' ')); //NOSONAR
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment