aboutsummaryrefslogtreecommitdiff
path: root/ufund-ui/src
diff options
context:
space:
mode:
authorGunther6070 <haydenhartman10@yahoo.com>2025-03-31 20:28:35 -0400
committerGunther6070 <haydenhartman10@yahoo.com>2025-03-31 20:28:35 -0400
commite1ef22279baccb4b2a5a1ecbb5222e4008d4d523 (patch)
treeb00669f1787c59374c536baa87b9eafcda5da85d /ufund-ui/src
parentb7539414ac6aa8efd423a3a9a0a2b5586757e19c (diff)
downloadJellySolutions-e1ef22279baccb4b2a5a1ecbb5222e4008d4d523.tar.gz
JellySolutions-e1ef22279baccb4b2a5a1ecbb5222e4008d4d523.tar.bz2
JellySolutions-e1ef22279baccb4b2a5a1ecbb5222e4008d4d523.zip
Added toasts for error handling
Diffstat (limited to 'ufund-ui/src')
-rw-r--r--ufund-ui/src/app/components/cupboard/cupboard.component.ts21
-rw-r--r--ufund-ui/src/app/components/login/login.component.ts12
-rw-r--r--ufund-ui/src/app/components/signup/signup.component.ts4
3 files changed, 20 insertions, 17 deletions
diff --git a/ufund-ui/src/app/components/cupboard/cupboard.component.ts b/ufund-ui/src/app/components/cupboard/cupboard.component.ts
index 9c8a173..653edd4 100644
--- a/ufund-ui/src/app/components/cupboard/cupboard.component.ts
+++ b/ufund-ui/src/app/components/cupboard/cupboard.component.ts
@@ -1,10 +1,11 @@
-import {Component, Input, OnInit, ViewChild} from '@angular/core';
+import {Component, OnInit, ViewChild} from '@angular/core';
import { CupboardService } from '../../services/cupboard.service';
import { Need, GoalType } from '../../models/Need';
import { userType } from '../../models/User';
-import { BehaviorSubject, catchError, of } from 'rxjs';
+import { catchError, of } from 'rxjs';
import { NeedListComponent } from '../need-list/need-list.component';
import {AuthService} from '../../services/auth.service';
+import {ToastsService, ToastType} from '../../services/toasts.service';
@Component({
selector: 'app-cupboard',
@@ -15,14 +16,14 @@ import {AuthService} from '../../services/auth.service';
export class CupboardComponent implements OnInit {
- protected statusText = new BehaviorSubject("")
selectedForm = "create";
needs: any;
@ViewChild("needList") needList?: NeedListComponent
constructor(
private cupboardService: CupboardService,
- private authService: AuthService
+ private authService: AuthService,
+ private toastService: ToastsService
) {}
ngOnInit(): void {
@@ -99,11 +100,11 @@ export class CupboardComponent implements OnInit {
this.cupboardService.updateNeed(need.id, need)
.pipe(catchError((ex, _) => {
if (ex.status == 500) {
- this.statusText.next("Fields cannot be blank");
+ this.toastService.sendToast(ToastType.INFO, 'Fields cannot be blank');
} else if (ex.status == 400) {
- this.statusText.next("Goal must be greater than 0");
+ this.toastService.sendToast(ToastType.INFO, "Goal must be greater than 0");
} else {
- this.statusText.next("Error on creating need");
+ this.toastService.sendToast(ToastType.INFO, "Error on creating need");
}
return of()
}))
@@ -138,11 +139,11 @@ export class CupboardComponent implements OnInit {
this.cupboardService.createNeed(need)
.pipe(catchError((ex, _) => {
if (ex.status == 500) {
- this.statusText.next("Fields cannot be blank");
+ this.toastService.sendToast(ToastType.INFO, "Fields cannot be blank");
} else if (ex.status == 400) {
- this.statusText.next("Goal must be greater than 0");
+ this.toastService.sendToast(ToastType.INFO, "Goal must be greater than 0");
} else {
- this.statusText.next("Error on creating need");
+ this.toastService.sendToast(ToastType.INFO, "Error on creating need");
}
return of()
}))
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)
})
}
diff --git a/ufund-ui/src/app/components/signup/signup.component.ts b/ufund-ui/src/app/components/signup/signup.component.ts
index 1ab863d..5ec84ae 100644
--- a/ufund-ui/src/app/components/signup/signup.component.ts
+++ b/ufund-ui/src/app/components/signup/signup.component.ts
@@ -2,6 +2,7 @@ import {Component} from '@angular/core';
import {UsersService} from '../../services/users.service';
import {Router} from '@angular/router';
import {BehaviorSubject} from 'rxjs';
+import {ToastsService, ToastType} from '../../services/toasts.service';
class PasswordRequirements {
sixLong: {title: string, value: boolean} = {title: 'Is 6 characters or longer' , value: false}
@@ -34,6 +35,7 @@ export class SignupComponent {
constructor(
protected usersService: UsersService,
protected router: Router,
+ protected toastService: ToastsService
) {}
signup(username: string | null, password: string | null) {
@@ -45,7 +47,7 @@ export class SignupComponent {
this.usersService.createUser(username, password).then(() => {
this.showSuccessMessage.next(true);
}).catch(ex => {
- this.statusText.next("Unable to create account: " + friendlyHttpStatus[ex.status])
+ this.toastService.sendToast(ToastType.INFO, "Unable to create account: " + friendlyHttpStatus[ex.status])
console.log(ex)
})
}