From cebddfe818f0519b3f57ef65c619d7d1d81783f7 Mon Sep 17 00:00:00 2001 From: Sonja Galovic Date: Mon, 16 May 2022 17:14:00 +0200 Subject: Registracija: resen problem da jedan popup zakloni drugi (obavestenje ispod polja). Izmene u column-table. --- .../register-modal/register-modal.component.html | 2 ++ .../register-modal/register-modal.component.ts | 21 +++++++++++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) (limited to 'frontend/src/app/_modals/register-modal') diff --git a/frontend/src/app/_modals/register-modal/register-modal.component.html b/frontend/src/app/_modals/register-modal/register-modal.component.html index 0c791a61..5182198c 100644 --- a/frontend/src/app/_modals/register-modal/register-modal.component.html +++ b/frontend/src/app/_modals/register-modal/register-modal.component.html @@ -33,6 +33,7 @@

Unesite ispravno korisničko ime.

+

Uneto korisničko ime je zauzeto.

@@ -42,6 +43,7 @@

Unesite ispravno e-mail adresu.

+

Uneta e-mail adresa je zauzeta.

diff --git a/frontend/src/app/_modals/register-modal/register-modal.component.ts b/frontend/src/app/_modals/register-modal/register-modal.component.ts index a5c6ddc6..b1129668 100644 --- a/frontend/src/app/_modals/register-modal/register-modal.component.ts +++ b/frontend/src/app/_modals/register-modal/register-modal.component.ts @@ -25,9 +25,11 @@ export class RegisterModalComponent implements OnInit { wrongEmailBool: boolean = false; wrongPass1Bool: boolean = false; wrongPass2Bool: boolean = false; + usernameAlreadyExistsBool: boolean = false; + emailAlreadyExistsBool: boolean = false; pattName: RegExp = /^[a-zA-ZšŠđĐčČćĆžŽ]+([ \-][a-zA-ZšŠđĐčČćĆžŽ]+)*$/; - pattUsername: RegExp = /^[a-zA-Z0-9]{6,18}$/; + pattUsername: RegExp = /^[a-zA-Z0-9]{4,18}$/; pattTwoSpaces: RegExp = / /; pattEmail: RegExp = /^[a-zA-Z0-9]+([\.\-\+][a-zA-Z0-9]+)*\@([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}$/; pattPassword: RegExp = /.{6,30}$/; @@ -59,7 +61,7 @@ export class RegisterModalComponent implements OnInit { } resetData() { this.firstName = this.lastName = this.username = this.email = this.pass1 = this.pass2 = ''; - this.wrongFirstNameBool = this.wrongLastNameBool = this.wrongUsernameBool = this.wrongEmailBool = this.wrongPass1Bool = this.wrongPass2Bool = false; + this.wrongFirstNameBool = this.wrongLastNameBool = this.wrongUsernameBool = this.wrongEmailBool = this.wrongPass1Bool = this.wrongPass2Bool = this.usernameAlreadyExistsBool = this.emailAlreadyExistsBool = false; this.password1Shown = false; this.password2Shown = false; } @@ -160,10 +162,13 @@ export class RegisterModalComponent implements OnInit { dateCreated:new Date() } + this.authService.register(user) .subscribe( (response) => { if (response == 'User added') { + this.usernameAlreadyExistsBool = false; + this.emailAlreadyExistsBool = false; //nakon sto je registrovan, nek bude ulogovan this.authService.login(this.username, this.pass1).subscribe((response) => { @@ -174,12 +179,16 @@ export class RegisterModalComponent implements OnInit { }, (error) => console.warn(error)); } else if (response == 'Email Already Exists') { - shared.openDialog("Greška!", "Nalog sa unetim email-om već postoji!"); - (document.getElementById('email')).focus(); + /*shared.openDialog("Greška!", "Nalog sa unetim email-om već postoji!"); + (document.getElementById('email')).focus();*/ + this.usernameAlreadyExistsBool = false; + this.emailAlreadyExistsBool = true; } else if (response == 'Username Already Exists') { - shared.openDialog("Greška!", "Nalog sa unetim korisničkim imenom već postoji!"); - (document.getElementById('username-register')).focus(); + /*shared.openDialog("Greška!", "Nalog sa unetim korisničkim imenom već postoji!"); + (document.getElementById('username-register')).focus();*/ + this.emailAlreadyExistsBool = false; + this.usernameAlreadyExistsBool = true; } } ); -- cgit v1.2.3