From b45bc19ba7f1f57aac8e06c896d73b2af73585b8 Mon Sep 17 00:00:00 2001 From: piratefinn Date: Thu, 24 Aug 2017 17:09:01 +0100 Subject: [PATCH] Basic Error messages and some correct valid added to login & register --- src/app/auth/login.component.html | 12 +++++++++++- src/app/auth/login.component.ts | 5 +++++ src/app/auth/register.component.html | 13 ++++++++++++- src/app/auth/register.component.ts | 11 ++++++++++- 4 files changed, 38 insertions(+), 3 deletions(-) diff --git a/src/app/auth/login.component.html b/src/app/auth/login.component.html index d105d32..a30d712 100644 --- a/src/app/auth/login.component.html +++ b/src/app/auth/login.component.html @@ -16,9 +16,19 @@ +
+
+ + +
+
- +
diff --git a/src/app/auth/login.component.ts b/src/app/auth/login.component.ts index b3d8f6d..829de5d 100644 --- a/src/app/auth/login.component.ts +++ b/src/app/auth/login.component.ts @@ -12,6 +12,7 @@ import 'rxjs/add/operator/map'; export class LoginComponent implements OnInit { signin: FormGroup; returnUrl: string; + loginStatus: any; constructor( private route: ActivatedRoute, @@ -52,10 +53,14 @@ export class LoginComponent implements OnInit { .subscribe( result => { console.log('logged in!'); + this.loginStatus = "success"; + console.log(this.loginStatus); this.router.navigate([this.returnUrl]); }, error => { console.log( error._body ); + this.loginStatus = "send_failed"; + console.log(this.loginStatus); } ); } diff --git a/src/app/auth/register.component.html b/src/app/auth/register.component.html index e311d4b..a54fb0a 100644 --- a/src/app/auth/register.component.html +++ b/src/app/auth/register.component.html @@ -130,10 +130,21 @@
- +
Please Select a User Type
+
+ + + +
diff --git a/src/app/auth/register.component.ts b/src/app/auth/register.component.ts index eeb4c7e..83846bc 100644 --- a/src/app/auth/register.component.ts +++ b/src/app/auth/register.component.ts @@ -16,6 +16,7 @@ export class RegisterComponent { customerForm: ValidationManager; organisationForm: ValidationManager; years: Object[]; + registerStatus: any; constructor( private http: Http, @@ -57,6 +58,8 @@ export class RegisterComponent { console.log(this.signupForm.isValid()); if (!this.signupForm.isValid() && !this.customerForm.isValid()) { console.log("Not Valid!"); + this.registerStatus = "validation_failed"; + console.log(this.registerStatus); return; } let signupForm = this.signupForm.getForm().value; @@ -90,6 +93,8 @@ export class RegisterComponent { console.log(this.signupForm.isValid()); if (!this.signupForm.isValid() || !this.organisationForm.isValid()) { console.log("Not Valid!"); + this.registerStatus = "validation_failed"; + console.log(this.registerStatus); return; } let signupForm = this.signupForm.getForm().value; @@ -112,10 +117,14 @@ export class RegisterComponent { .subscribe( result => { console.log('registered!'); - this.router.navigate(['/dashboard']); + this.registerStatus = "success"; + console.log(this.registerStatus); + this.router.navigate(['/dashboard']); }, error => { console.log( error._body ); + this.registerStatus = "send_failed"; + console.log(this.registerStatus); } ); }