aboutsummaryrefslogtreecommitdiff
path: root/ufund-ui/src/app/components/cupboard/cupboard.component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'ufund-ui/src/app/components/cupboard/cupboard.component.ts')
-rw-r--r--ufund-ui/src/app/components/cupboard/cupboard.component.ts15
1 files changed, 9 insertions, 6 deletions
diff --git a/ufund-ui/src/app/components/cupboard/cupboard.component.ts b/ufund-ui/src/app/components/cupboard/cupboard.component.ts
index aca1397..f571566 100644
--- a/ufund-ui/src/app/components/cupboard/cupboard.component.ts
+++ b/ufund-ui/src/app/components/cupboard/cupboard.component.ts
@@ -106,16 +106,19 @@ export class CupboardComponent implements OnInit {
}
deleteNeed(id : number) {
- this.cupboardService.deleteNeed(id).subscribe(() => {
- this.toastService.sendToast(ToastType.INFO, "Need deleted.")
- this.needs = this.needs.filter(n => n.id !== id)
- })
- this.refresh();
+ this.cupboardService.deleteNeed(id)
+ .pipe(catchError((ex, _) => {
+ this.toastService.sendToast(ToastType.ERROR, ex.error)
+ return of()
+ }))
+ .subscribe(() => {
+ this.toastService.sendToast(ToastType.INFO, "Need deleted.")
+ this.refresh();
+ })
}
addToBasket(need: Need) {
const currentUser = this.authService.getCurrentUser();
- //console.log("get current user in angular:", currentUser)
if (currentUser) {
if (!currentUser.basket.includes(need.id)) {
currentUser.basket.push(need.id);