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/cupboard/cupboard.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/cupboard/cupboard.component.ts')
-rw-r--r-- | ufund-ui/src/app/components/cupboard/cupboard.component.ts | 21 |
1 files changed, 11 insertions, 10 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() })) |