|
|
@ -8,8 +8,10 @@ import {
|
|
|
|
Validators,
|
|
|
|
Validators,
|
|
|
|
} from '@angular/forms';
|
|
|
|
} from '@angular/forms';
|
|
|
|
import { Router } from '@angular/router';
|
|
|
|
import { Router } from '@angular/router';
|
|
|
|
|
|
|
|
import { Subscription } from 'rxjs';
|
|
|
|
import { User } from '../../model/User';
|
|
|
|
import { User } from '../../model/User';
|
|
|
|
import { LocalStorageService } from '../../services/local-storage/local-storage.service';
|
|
|
|
import { LocalStorageService } from '../../services/local-storage/local-storage.service';
|
|
|
|
|
|
|
|
import { ModalService } from '../../services/modal/modal.service';
|
|
|
|
import { RegisterService } from '../../services/register/register.service';
|
|
|
|
import { RegisterService } from '../../services/register/register.service';
|
|
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
@Component({
|
|
|
@ -22,11 +24,14 @@ export class RegisterPageComponent {
|
|
|
|
user: User = { login: '', password: '' };
|
|
|
|
user: User = { login: '', password: '' };
|
|
|
|
errorMessage: string = '';
|
|
|
|
errorMessage: string = '';
|
|
|
|
isRegisterModalOpen: boolean = false;
|
|
|
|
isRegisterModalOpen: boolean = false;
|
|
|
|
|
|
|
|
modalId: string = 'register-modal';
|
|
|
|
|
|
|
|
private modalSub!: Subscription;
|
|
|
|
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
constructor(
|
|
|
|
private registerService: RegisterService,
|
|
|
|
private registerService: RegisterService,
|
|
|
|
private fb: FormBuilder,
|
|
|
|
private fb: FormBuilder,
|
|
|
|
private localStorageService: LocalStorageService,
|
|
|
|
private localStorageService: LocalStorageService,
|
|
|
|
|
|
|
|
private modalService: ModalService,
|
|
|
|
private router: Router
|
|
|
|
private router: Router
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
this.userForm = this.fb.group(
|
|
|
|
this.userForm = this.fb.group(
|
|
|
@ -45,6 +50,18 @@ export class RegisterPageComponent {
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
|
|
|
|
this.modalSub = this.modalService
|
|
|
|
|
|
|
|
.getModalState(this.modalId)
|
|
|
|
|
|
|
|
.subscribe((open) => {
|
|
|
|
|
|
|
|
this.isRegisterModalOpen = open;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ngOnDestroy() {
|
|
|
|
|
|
|
|
this.modalSub.unsubscribe();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
passwordMatchValidator(formGroup: FormGroup) {
|
|
|
|
passwordMatchValidator(formGroup: FormGroup) {
|
|
|
|
const password = formGroup.get('password')?.value;
|
|
|
|
const password = formGroup.get('password')?.value;
|
|
|
|
const verifyPassword = formGroup.get('verifyPassword')?.value;
|
|
|
|
const verifyPassword = formGroup.get('verifyPassword')?.value;
|
|
|
@ -80,10 +97,15 @@ export class RegisterPageComponent {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
openRegisterModal() {
|
|
|
|
openRegisterModal() {
|
|
|
|
this.isRegisterModalOpen = true;
|
|
|
|
this.modalService.openModal(this.modalId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
closeRegisterModal() {
|
|
|
|
closeRegisterModal() {
|
|
|
|
this.isRegisterModalOpen = false;
|
|
|
|
this.modalService.closeModal(this.modalId);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
openLoginModal() {
|
|
|
|
|
|
|
|
this.modalService.closeModal(this.modalId);
|
|
|
|
|
|
|
|
this.modalService.openModal('login-modal');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|