diff options
author | Gunther6070 <haydenhartman10@yahoo.com> | 2025-03-31 20:28:35 -0400 |
---|---|---|
committer | Gunther6070 <haydenhartman10@yahoo.com> | 2025-03-31 20:28:35 -0400 |
commit | e1ef22279baccb4b2a5a1ecbb5222e4008d4d523 (patch) | |
tree | b00669f1787c59374c536baa87b9eafcda5da85d /ufund-ui/src/app/components/login/login.component.ts | |
parent | b7539414ac6aa8efd423a3a9a0a2b5586757e19c (diff) | |
download | JellySolutions-e1ef22279baccb4b2a5a1ecbb5222e4008d4d523.tar.gz JellySolutions-e1ef22279baccb4b2a5a1ecbb5222e4008d4d523.tar.bz2 JellySolutions-e1ef22279baccb4b2a5a1ecbb5222e4008d4d523.zip |
Added toasts for error handling
Diffstat (limited to 'ufund-ui/src/app/components/login/login.component.ts')
-rw-r--r-- | ufund-ui/src/app/components/login/login.component.ts | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/ufund-ui/src/app/components/login/login.component.ts b/ufund-ui/src/app/components/login/login.component.ts index 4dcaedd..0177f67 100644 --- a/ufund-ui/src/app/components/login/login.component.ts +++ b/ufund-ui/src/app/components/login/login.component.ts @@ -1,8 +1,8 @@ import {Component, OnInit} from '@angular/core' import {UsersService} from '../../services/users.service'; import {ActivatedRoute, Router} from '@angular/router'; -import {BehaviorSubject} from 'rxjs'; import {AuthService} from '../../services/auth.service'; +import {ToastsService, ToastType} from '../../services/toasts.service'; @Component({ selector: 'app-login', @@ -13,13 +13,13 @@ import {AuthService} from '../../services/auth.service'; export class LoginComponent implements OnInit { protected next?: string | null; - protected statusText = new BehaviorSubject("") constructor( protected usersService: UsersService, protected router: Router, private route: ActivatedRoute, - private authService: AuthService + private authService: AuthService, + private toastService: ToastsService ) {} ngOnInit() { @@ -38,7 +38,7 @@ export class LoginComponent implements OnInit { let key = this.authService.getApiKey() localStorage.setItem("credential", JSON.stringify({username: username, key: key})) }).catch(ex => { - this.statusText.next("Unable to login: " + friendlyHttpStatus[ex.status]) + this.toastService.sendToast(ToastType.ERROR, "Unable to login: " + friendlyHttpStatus[ex.status]) console.log(ex) }) } @@ -50,9 +50,9 @@ export class LoginComponent implements OnInit { } this.usersService.createUser(username, password).then(() => { - this.statusText.next("Account created, click login.") + this.toastService.sendToast(ToastType.INFO, "Account created, click login.") }).catch(ex => { - this.statusText.next("Unable to create account: " + friendlyHttpStatus[ex.status]) + this.toastService.sendToast(ToastType.ERROR, "Unable to create account: " + friendlyHttpStatus[ex.status]) console.log(ex) }) } |