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

Merge branch 'feat/claimStructure' into 'dev'

Feat/claim structure

See merge request web-et-numerique/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_client!50
parents 7f13e370 216124eb
No related branches found
No related tags found
3 merge requests!68Recette,!67Dev,!50Feat/claim structure
Showing
with 493 additions and 282 deletions
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { TestBed } from '@angular/core/testing'; import { TestBed } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing'; import { RouterTestingModule } from '@angular/router/testing';
import { AppComponent } from './app.component'; import { AppComponent } from './app.component';
...@@ -5,7 +6,7 @@ import { AppComponent } from './app.component'; ...@@ -5,7 +6,7 @@ import { AppComponent } from './app.component';
describe('AppComponent', () => { describe('AppComponent', () => {
beforeEach(async () => { beforeEach(async () => {
await TestBed.configureTestingModule({ await TestBed.configureTestingModule({
imports: [RouterTestingModule], imports: [RouterTestingModule, HttpClientTestingModule],
declarations: [AppComponent], declarations: [AppComponent],
}).compileComponents(); }).compileComponents();
}); });
......
This diff is collapsed.
form { .form {
position: fixed; position: fixed;
background: white; background: white;
width: 100vh; width: 50vw;
height: 100vh; height: 100vh;
top: 0; top: 0;
z-index: 9999; z-index: 9999;
......
import { HttpClientTestingModule } from '@angular/common/http/testing'; import { HttpClientTestingModule } from '@angular/common/http/testing';
import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing';
import { FormArray, FormControl, FormGroup, Validators } from '@angular/forms'; import { FormArray, FormControl, FormGroup, FormsModule, ReactiveFormsModule, Validators } from '@angular/forms';
import { Time } from '../models/time.model'; import { Time } from '../models/time.model';
import { SharedModule } from '../shared/shared.module';
import { FormComponent } from './form.component'; import { FormComponent } from './form.component';
fdescribe('FormComponent', () => { describe('FormComponent', () => {
let component: FormComponent; let component: FormComponent;
let fixture: ComponentFixture<FormComponent>; let fixture: ComponentFixture<FormComponent>;
beforeEach(async () => { beforeEach(async () => {
await TestBed.configureTestingModule({ await TestBed.configureTestingModule({
declarations: [FormComponent], declarations: [FormComponent],
imports: [HttpClientTestingModule], imports: [HttpClientTestingModule, FormsModule, ReactiveFormsModule, SharedModule],
}).compileComponents(); }).compileComponents();
}); });
......
...@@ -11,6 +11,7 @@ import { EquipmentAccess } from '../shared/enum/equipmentAccess.enum'; ...@@ -11,6 +11,7 @@ import { EquipmentAccess } from '../shared/enum/equipmentAccess.enum';
import { WeekDayEnum } from '../shared/enum/weekDay.enum'; import { WeekDayEnum } from '../shared/enum/weekDay.enum';
import { typeStructureEnum } from '../shared/enum/typeStructure.enum'; import { typeStructureEnum } from '../shared/enum/typeStructure.enum';
import { FonctionContactEnum } from '../shared/enum/fonctionContact.enum'; import { FonctionContactEnum } from '../shared/enum/fonctionContact.enum';
import { ProfileService } from '../profile/services/profile.service';
import { User } from '../models/user.model'; import { User } from '../models/user.model';
@Component({ @Component({
...@@ -20,9 +21,13 @@ import { User } from '../models/user.model'; ...@@ -20,9 +21,13 @@ import { User } from '../models/user.model';
}) })
export class FormComponent implements OnInit { export class FormComponent implements OnInit {
@Input() public idStructure?: number; @Input() public idStructure?: number;
@Input() public isEditMode: boolean;
@Input() public profile?: User; @Input() public profile?: User;
@Output() closeEvent = new EventEmitter<Structure>(); @Output() closeEvent = new EventEmitter<Structure>();
public structureForm: FormGroup; public structureForm: FormGroup;
public userAlreadyExist = false;
public equipmentAccess = EquipmentAccess; public equipmentAccess = EquipmentAccess;
public weekDay = WeekDayEnum; public weekDay = WeekDayEnum;
public typeStructure = typeStructureEnum; public typeStructure = typeStructureEnum;
...@@ -35,7 +40,11 @@ export class FormComponent implements OnInit { ...@@ -35,7 +40,11 @@ export class FormComponent implements OnInit {
public equipmentsAndServices: Category; public equipmentsAndServices: Category;
public proceduresAccompaniment: Category; public proceduresAccompaniment: Category;
public structureId: number; public structureId: number;
constructor(private structureService: StructureService, private searchService: SearchService) {} constructor(
private structureService: StructureService,
private searchService: SearchService,
private profileService: ProfileService
) {}
ngOnInit(): void { ngOnInit(): void {
if (this.idStructure) { if (this.idStructure) {
...@@ -75,6 +84,7 @@ export class FormComponent implements OnInit { ...@@ -75,6 +84,7 @@ export class FormComponent implements OnInit {
} }
}); });
}); });
this.searchService.getCategoriesTraining().subscribe((t) => { this.searchService.getCategoriesTraining().subscribe((t) => {
this.categoryTraining = t; this.categoryTraining = t;
}); });
...@@ -143,6 +153,13 @@ export class FormComponent implements OnInit { ...@@ -143,6 +153,13 @@ export class FormComponent implements OnInit {
equipmentsDetails: new FormControl(structure.equipmentsDetails), equipmentsDetails: new FormControl(structure.equipmentsDetails),
equipmentsAccessType: this.loadArrayForCheckbox(structure.equipmentsAccessType, false), equipmentsAccessType: this.loadArrayForCheckbox(structure.equipmentsAccessType, false),
}); });
// Disable form when it's to claim.
if (!this.isEditMode && this.idStructure) {
Object.keys(this.structureForm.controls).forEach((controlName) => {
this.structureForm.controls[controlName].disable();
});
}
} }
private loadArrayForCheckbox(array: string[], isRequired: boolean): FormArray { private loadArrayForCheckbox(array: string[], isRequired: boolean): FormArray {
...@@ -151,7 +168,6 @@ export class FormComponent implements OnInit { ...@@ -151,7 +168,6 @@ export class FormComponent implements OnInit {
isRequired ? Validators.required : Validators.nullValidator isRequired ? Validators.required : Validators.nullValidator
); );
} }
public getStructureControl(nameControl: string): AbstractControl { public getStructureControl(nameControl: string): AbstractControl {
return this.structureForm.get(nameControl); return this.structureForm.get(nameControl);
} }
...@@ -186,8 +202,8 @@ export class FormComponent implements OnInit { ...@@ -186,8 +202,8 @@ export class FormComponent implements OnInit {
} }
private createTime(time: Time): FormGroup { private createTime(time: Time): FormGroup {
return new FormGroup({ return new FormGroup({
openning: new FormControl(time.openning, Validators.required), openning: new FormControl(time.openning),
closing: new FormControl(time.closing, Validators.required), closing: new FormControl(time.closing),
}); });
} }
...@@ -228,24 +244,34 @@ export class FormComponent implements OnInit { ...@@ -228,24 +244,34 @@ export class FormComponent implements OnInit {
} }
return false; return false;
} }
public onSubmitClaim(accountForm: FormGroup): void {
if (!this.structureForm.invalid && accountForm.valid) {
this.profileService.createUserandLinkStructure(this.structureId, accountForm.value).subscribe((user) => {
this.closeEvent.emit(this.structureForm.value);
});
}
}
public onSubmitClaimWithAccount(): void {
this.structureService
.claimStructureWithAccount(this.structureId, this.profile.email)
.subscribe((structuresLinked) => {
this.profile.structuresLink = structuresLinked;
this.profileService.setProfile(this.profile);
this.closeEvent.emit(this.structureForm.value);
});
}
public onSubmit(structureForm: FormGroup): void { public onSubmit(structureForm: FormGroup): void {
if (structureForm.valid) { if (structureForm.valid) {
if (this.structureId) { if (this.structureId) {
this.structureService.postStructure(this.structureId, structureForm.value).subscribe( this.structureService.editStructure(this.structureId, structureForm.value).subscribe((structure: Structure) => {
(structure: Structure) => { this.closeEvent.emit(structure);
this.closeEvent.emit(structure); });
},
(err) => {}
);
} else { } else {
this.structureService.createStructure(structureForm.value, this.profile).subscribe( this.structureService.createStructure(structureForm.value, this.profile).subscribe((structure: Structure) => {
(structure: Structure) => { this.closeEvent.emit(structure);
this.closeEvent.emit(structure); });
},
(err) => {}
);
} }
} else {
} }
} }
} }
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing'; import { RouterTestingModule } from '@angular/router/testing';
...@@ -9,7 +10,7 @@ describe('HeaderComponent', () => { ...@@ -9,7 +10,7 @@ describe('HeaderComponent', () => {
beforeEach(async () => { beforeEach(async () => {
await TestBed.configureTestingModule({ await TestBed.configureTestingModule({
imports: [RouterTestingModule], imports: [RouterTestingModule, HttpClientTestingModule],
declarations: [HeaderComponent], declarations: [HeaderComponent],
}).compileComponents(); }).compileComponents();
}); });
......
...@@ -22,22 +22,22 @@ describe('MapService', () => { ...@@ -22,22 +22,22 @@ describe('MapService', () => {
}); });
it('should add marker to map with icon ic_marker.png', () => { it('should add marker to map with icon ic_marker.png', () => {
const marker = service.createMarker(45.764043, 4.835659, 1); const marker = service.createMarker(45.764043, 4.835659, 1);
expect(marker.getIcon().options.iconSize).toEqual([35, 41]); expect(marker.getIcon().options.iconSize).toEqual([19, 24]);
expect(marker.getIcon().options.iconAnchor).toEqual([13, 41]); expect(marker.getIcon().options.iconAnchor).toEqual([9, 0]);
}); });
it('should cerate marker with tooltip', () => { it('should cerate marker with popup', () => {
const marker = service.createMarker(45.764043, 4.835659, 1, '<p>Hello <br/>World !</p>'); const marker = service.createMarker(45.764043, 4.835659, 1, null, '<p>Hello <br/>World !</p>');
expect(marker.getTooltip().getContent()).toEqual('<p>Hello <br/>World !</p>'); expect(marker.getPopup().getContent()).toEqual('<p>Hello <br/>World !</p>');
}); });
it('should get marker', () => { it('should get marker', () => {
const marker = service.createMarker(45.764043, 4.835659, 1, '<p>Hello <br/>World !</p>'); const marker = service.createMarker(45.764043, 4.835659, 1, 53, '<p>Hello <br/>World !</p>');
expect(marker).toEqual(service.getMarker(1)); expect(marker).toEqual(service.getMarker(53));
}); });
it('should not get marker, with missing id', () => { it('should not get marker, with missing id', () => {
service.createMarker(45.764043, 4.835659, 1, '<p>Hello <br/>World !</p>'); service.createMarker(45.764043, 4.835659, 1, null, '<p>Hello <br/>World !</p>');
expect(service.getMarker(2)).toEqual(null); expect(service.getMarker(2)).toEqual(null);
}); });
it('should not get marker, empty', () => { it('should not get marker, empty', () => {
......
...@@ -4,6 +4,12 @@ ...@@ -4,6 +4,12 @@
<div *ngIf="userProfile" fxLayout="column" fxLayoutAlign="center" fxLayoutGap="10px"> <div *ngIf="userProfile" fxLayout="column" fxLayoutAlign="center" fxLayoutGap="10px">
<p>Id: {{ userProfile._id }}</p> <p>Id: {{ userProfile._id }}</p>
<p>Email: {{ userProfile.email }}</p> <p>Email: {{ userProfile.email }}</p>
<p>
Mes structures :
<span *ngFor="let structureId of userProfile.structuresLink">
<b>{{ structureId }}</b>
</span>
</p>
<button (click)="toogleAddStructure()">Ajouter une structure</button> <button (click)="toogleAddStructure()">Ajouter une structure</button>
<button (click)="toogleChangeEmail()">Changer d'email</button> <button (click)="toogleChangeEmail()">Changer d'email</button>
<form <form
......
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ReactiveFormsModule } from '@angular/forms';
import { ProfileComponent } from './profile.component'; import { ProfileComponent } from './profile.component';
...@@ -8,9 +10,9 @@ describe('ProfileComponent', () => { ...@@ -8,9 +10,9 @@ describe('ProfileComponent', () => {
beforeEach(async () => { beforeEach(async () => {
await TestBed.configureTestingModule({ await TestBed.configureTestingModule({
declarations: [ ProfileComponent ] declarations: [ProfileComponent],
}) imports: [HttpClientTestingModule, ReactiveFormsModule],
.compileComponents(); }).compileComponents();
}); });
beforeEach(() => { beforeEach(() => {
......
...@@ -2,7 +2,6 @@ import { HttpClient } from '@angular/common/http'; ...@@ -2,7 +2,6 @@ import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { User } from '../../models/user.model'; import { User } from '../../models/user.model';
import { AuthService } from '../../services/auth.service';
@Injectable({ @Injectable({
providedIn: 'root', providedIn: 'root',
...@@ -10,27 +9,37 @@ import { AuthService } from '../../services/auth.service'; ...@@ -10,27 +9,37 @@ import { AuthService } from '../../services/auth.service';
export class ProfileService { export class ProfileService {
private readonly baseUrl = 'api/users'; private readonly baseUrl = 'api/users';
private currentProfile: User = null; private currentProfile: User = null;
constructor(private http: HttpClient, private authService: AuthService) {} constructor(private http: HttpClient) {}
public async getProfile(): Promise<User> { public async getProfile(): Promise<User> {
// Get profil by API only on first time // Get profil by API only on first time
if (!this.currentProfile && this.authService.isLoggedIn()) { if (!this.currentProfile) {
const profile = await this.http.get<User>(`${this.baseUrl}/profile`).toPromise(); const profile = await this.http.get<User>(`${this.baseUrl}/profile`).toPromise();
this.currentProfile = profile; this.currentProfile = profile;
} }
return this.currentProfile; return this.currentProfile;
} }
public setProfile(profile: User): void {
this.currentProfile = profile;
}
public isLinkedToStructure(idStructure: number): boolean { public isLinkedToStructure(idStructure: number): boolean {
if (!this.authService.isLoggedIn()) {
this.currentProfile = null;
}
if (!this.currentProfile) { if (!this.currentProfile) {
return false; return false;
} }
return this.currentProfile.structuresLink.includes(idStructure); return this.currentProfile.structuresLink.includes(idStructure);
} }
public removeProfile(): void {
this.currentProfile = null;
}
public createUserandLinkStructure(id: number, body: User): Observable<User> {
body.structuresLink = [id];
return this.http.post<any>(`${this.baseUrl}`, body);
}
public changePassword(newPassword: string, oldPassword: string): Observable<User> { public changePassword(newPassword: string, oldPassword: string): Observable<User> {
return this.http.post<any>(`${this.baseUrl}/change-password`, { newPassword, oldPassword }); return this.http.post<any>(`${this.baseUrl}/change-password`, { newPassword, oldPassword });
} }
......
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { ResetEmailComponent } from './reset-email.component'; import { ResetEmailComponent } from './reset-email.component';
...@@ -9,6 +11,7 @@ describe('ResetEmailComponent', () => { ...@@ -9,6 +11,7 @@ describe('ResetEmailComponent', () => {
beforeEach(async () => { beforeEach(async () => {
await TestBed.configureTestingModule({ await TestBed.configureTestingModule({
declarations: [ResetEmailComponent], declarations: [ResetEmailComponent],
imports: [RouterTestingModule, HttpClientTestingModule],
}).compileComponents(); }).compileComponents();
}); });
......
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ReactiveFormsModule } from '@angular/forms';
import { RouterTestingModule } from '@angular/router/testing';
import { ResetPasswordComponent } from './reset-password.component'; import { ResetPasswordComponent } from './reset-password.component';
...@@ -8,9 +11,9 @@ describe('ResetPasswordComponent', () => { ...@@ -8,9 +11,9 @@ describe('ResetPasswordComponent', () => {
beforeEach(async () => { beforeEach(async () => {
await TestBed.configureTestingModule({ await TestBed.configureTestingModule({
declarations: [ ResetPasswordComponent ] declarations: [ResetPasswordComponent],
}) imports: [ReactiveFormsModule, HttpClientTestingModule, RouterTestingModule],
.compileComponents(); }).compileComponents();
}); });
beforeEach(() => { beforeEach(() => {
......
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { TestBed } from '@angular/core/testing'; import { TestBed } from '@angular/core/testing';
import { AuthService } from './auth.service'; import { AuthService } from './auth.service';
...@@ -6,7 +7,9 @@ describe('AuthService', () => { ...@@ -6,7 +7,9 @@ describe('AuthService', () => {
let service: AuthService; let service: AuthService;
beforeEach(() => { beforeEach(() => {
TestBed.configureTestingModule({}); TestBed.configureTestingModule({
imports: [HttpClientTestingModule],
});
service = TestBed.inject(AuthService); service = TestBed.inject(AuthService);
}); });
......
...@@ -17,24 +17,33 @@ import { User } from '../models/user.model'; ...@@ -17,24 +17,33 @@ import { User } from '../models/user.model';
providedIn: 'root', providedIn: 'root',
}) })
export class StructureService { export class StructureService {
private readonly baseUrl = 'api/structures';
constructor(private http: HttpClient) {} constructor(private http: HttpClient) {}
public createStructure(structure: Structure, profile: User): Observable<Structure> { public createStructure(structure: Structure, profile: User): Observable<Structure> {
const idUser = profile.email; const idUser = profile.email;
return this.http.post('/api/structures', { structure, idUser }).pipe(map((item: Structure) => new Structure(item))); return this.http.post(`${this.baseUrl}`, { structure, idUser }).pipe(map((item: Structure) => new Structure(item)));
} }
public postStructure(id: number, structure: Structure): Observable<Structure> { public editStructure(id: number, structure: Structure): Observable<Structure> {
structure.updatedAt = new Date().toString(); structure.updatedAt = new Date().toString();
return this.http.post('/api/structures/' + id, structure).pipe(map((item: Structure) => new Structure(item))); return this.http.put(`${this.baseUrl}/${id}`, structure).pipe(map((item: Structure) => new Structure(item)));
}
public isClaimed(id: number): Observable<any> {
return this.http.get(`${this.baseUrl}/${id}/isClaimed`);
}
public claimStructureWithAccount(id: number, email: string): Observable<number[]> {
return this.http.post<any>(`${this.baseUrl}/${id}/claim`, { email });
} }
public getStructure(id: number): Observable<Structure> { public getStructure(id: number): Observable<Structure> {
return this.http.get('/api/structures/' + id).pipe(map((item: any) => new Structure(item))); return this.http.get(`${this.baseUrl}/${id}`).pipe(map((item: any) => new Structure(item)));
} }
public getStructures(filters: Filter[]): Observable<Structure[]> { public getStructures(filters: Filter[]): Observable<Structure[]> {
if (filters && filters.length > 0) { if (filters && filters.length > 0) {
let requestUrl = '/api/structures/search'; let requestUrl = `${this.baseUrl}/search`;
const queryString = _.find(filters, { name: 'query' }); const queryString = _.find(filters, { name: 'query' });
if (queryString) { if (queryString) {
_.remove(filters, { name: 'query' }); _.remove(filters, { name: 'query' });
...@@ -45,7 +54,7 @@ export class StructureService { ...@@ -45,7 +54,7 @@ export class StructureService {
.post(requestUrl, { filters: formatedFilters }) .post(requestUrl, { filters: formatedFilters })
.pipe(map((data: any[]) => data.map((item) => new Structure(item)))); .pipe(map((data: any[]) => data.map((item) => new Structure(item))));
} else { } else {
return this.http.get('/api/structures').pipe(map((data: any[]) => data.map((item) => new Structure(item)))); return this.http.get(`${this.baseUrl}`).pipe(map((data: any[]) => data.map((item) => new Structure(item))));
} }
} }
......
<form [formGroup]="accountForm" *ngIf="accountForm" (ngSubmit)="onSubmit(accountForm)">
<div class="form-group">
<label for="email">Email</label>
<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="password">Mot de passe</label>
<input type="password" autocomplete="on" formControlName="password" class="form-control" />
<app-validator-form
*ngIf="submitted"
[nameControl]="'password'"
[control]="getAccountControl('password')"
></app-validator-form>
</div>
<div class="form-group">
<label for="confirmPassword">Confirmation du mot de passe</label>
<input type="password" autocomplete="on" formControlName="confirmPassword" class="form-control" />
<app-validator-form
*ngIf="submitted"
[nameControl]="'password'"
[control]="getAccountControl('confirmPassword')"
></app-validator-form>
</div>
<div class="form-group">
<button class="btn btn-primary" type="submit">Valider</button>
</div>
</form>
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { FormControl, FormGroup, Validators } from '@angular/forms';
import { MustMatch } from '../../validator/form';
import { CreateAccountFormComponent } from './create-account-form.component';
describe('CreateAccountFormComponent', () => {
let component: CreateAccountFormComponent;
let fixture: ComponentFixture<CreateAccountFormComponent>;
const accountForm = new FormGroup(
{
email: new FormControl('test@test.fr', Validators.required),
password: new FormControl('Testaze123!', [
Validators.required,
Validators.pattern(/^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#$%^&*])(?=.{8,})/),
]),
confirmPassword: new FormControl('Testaze123!'),
},
[MustMatch('password', 'confirmPassword')]
);
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [CreateAccountFormComponent],
}).compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(CreateAccountFormComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
it('should emit the form', () => {
spyOn(component.submitForm, 'emit');
component.onSubmit(accountForm);
expect(component.submitForm.emit).toHaveBeenCalled();
expect(component.submitForm.emit).toHaveBeenCalledWith(accountForm);
});
it('should return control', () => {
component.accountForm = accountForm;
const result = component.getAccountControl('email');
const control = accountForm.get('email');
expect(result).toEqual(control);
});
});
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { AbstractControl, FormControl, FormGroup, Validators } from '@angular/forms';
import { MustMatch } from '../../validator/form';
@Component({
selector: 'app-create-account-form',
templateUrl: './create-account-form.component.html',
styleUrls: ['./create-account-form.component.scss'],
})
export class CreateAccountFormComponent implements OnInit {
constructor() {}
public accountForm: FormGroup;
public submitted: boolean = false;
@Output() public submitForm = new EventEmitter<FormGroup>();
ngOnInit(): void {
this.accountForm = new FormGroup(
{
email: new FormControl('', Validators.required),
password: new FormControl('', [
Validators.required,
Validators.pattern(/^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#$%^&*])(?=.{8,})/),
]),
confirmPassword: new FormControl(''),
},
[MustMatch('password', 'confirmPassword')]
);
}
public onSubmit(accountForm: FormGroup) {
this.submitted = true;
if (accountForm.valid) {
this.submitForm.emit(accountForm);
}
}
public getAccountControl(nameControl: string): AbstractControl {
return this.accountForm.get(nameControl);
}
}
...@@ -5,6 +5,7 @@ import { SignUpModalComponent } from './signup-modal/signup-modal.component'; ...@@ -5,6 +5,7 @@ import { SignUpModalComponent } from './signup-modal/signup-modal.component';
import { SignInModalComponent } from './signin-modal/signin-modal.component'; import { SignInModalComponent } from './signin-modal/signin-modal.component';
import { SvgIconComponent } from './svg-icon/svg-icon.component'; import { SvgIconComponent } from './svg-icon/svg-icon.component';
import { ValidatorFormComponent } from './validator-form/validator-form.component'; import { ValidatorFormComponent } from './validator-form/validator-form.component';
import { CreateAccountFormComponent } from './create-account-form/create-account-form.component';
// tslint:disable-next-line: max-line-length // tslint:disable-next-line: max-line-length
export { export {
...@@ -15,6 +16,7 @@ export { ...@@ -15,6 +16,7 @@ export {
ValidatorFormComponent, ValidatorFormComponent,
SignUpModalComponent, SignUpModalComponent,
SignInModalComponent, SignInModalComponent,
CreateAccountFormComponent,
}; };
// tslint:disable-next-line:variable-name // tslint:disable-next-line:variable-name
...@@ -26,4 +28,5 @@ export const SharedComponents = [ ...@@ -26,4 +28,5 @@ export const SharedComponents = [
ValidatorFormComponent, ValidatorFormComponent,
SignUpModalComponent, SignUpModalComponent,
SignInModalComponent, SignInModalComponent,
CreateAccountFormComponent,
]; ];
...@@ -24,13 +24,11 @@ describe('LogoCardComponent', () => { ...@@ -24,13 +24,11 @@ describe('LogoCardComponent', () => {
}); });
it('should return logo name with a string input', () => { it('should return logo name with a string input', () => {
const logoCaf = component.getLogoKey(Demarches.caf); const logoCaf = component.getName('accompagnantCaf');
const logoCarsat = component.getLogoKey(Demarches.carsat); const logoCarsat = component.getName('carsat');
const logoCpam = component.getLogoKey(Demarches.cpam); const logoCpam = component.getName('cpam');
const logoOther = component.getLogoKey(Demarches.other); expect(logoCaf).toEqual(Demarches.accompagnantCaf);
expect(logoCaf).toEqual('caf'); expect(logoCarsat).toEqual(Demarches.carsat);
expect(logoCarsat).toEqual('carsat'); expect(logoCpam).toEqual(Demarches.cpam);
expect(logoCpam).toEqual('cpam');
expect(logoOther).toEqual('other');
}); });
}); });
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