aboutsummaryrefslogtreecommitdiff
path: root/ufund-ui
diff options
context:
space:
mode:
authorsowgro <tpoke.ferrari@gmail.com>2025-04-06 13:27:34 -0400
committersowgro <tpoke.ferrari@gmail.com>2025-04-06 13:27:34 -0400
commita24907d9ca0100798867805a458d8fc870a82e9a (patch)
treead8c74c30638fddb13dbe63a736f34717c11c314 /ufund-ui
parentfd7d46749103d5610dd71ed33cb1e9d133701d4e (diff)
downloadJellySolutions-a24907d9ca0100798867805a458d8fc870a82e9a.tar.gz
JellySolutions-a24907d9ca0100798867805a458d8fc870a82e9a.tar.bz2
JellySolutions-a24907d9ca0100798867805a458d8fc870a82e9a.zip
Add a few missing toasts
Diffstat (limited to 'ufund-ui')
-rw-r--r--ufund-ui/src/app/components/cupboard/cupboard.component.ts15
-rw-r--r--ufund-ui/src/app/components/need-page/need-page.component.ts11
2 files changed, 12 insertions, 14 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);
diff --git a/ufund-ui/src/app/components/need-page/need-page.component.ts b/ufund-ui/src/app/components/need-page/need-page.component.ts
index 0967266..17e330c 100644
--- a/ufund-ui/src/app/components/need-page/need-page.component.ts
+++ b/ufund-ui/src/app/components/need-page/need-page.component.ts
@@ -32,19 +32,15 @@ export class NeedPageComponent implements OnInit {
this.cupboardService.getNeed(id).subscribe(n => this.need = n);
}
- back() {
- window.history.back();
- }
-
add(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);
this.usersService.updateUser(currentUser)
.pipe(catchError((err, _) => {
- console.error(err);
+ let action = {label: "View Basket", onAction: () => this.router.navigate(['/basket'])}
+ this.toastService.sendToast(ToastType.INFO, `"${need.name}" Added to basket`, action)
return of();
}))
.subscribe(() => {
@@ -63,8 +59,7 @@ export class NeedPageComponent implements OnInit {
return of()
}))
.subscribe(() => {
- // this.needs = this.needs.filter(n => n.id !== id)
- this.toastService.sendToast(ToastType.INFO, "Need deleted")
+ this.toastService.sendToast(ToastType.INFO, "Need deleted.")
this.router.navigate(['/cupboard'])
})
// this.refresh();