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.ts14
1 files changed, 13 insertions, 1 deletions
diff --git a/ufund-ui/src/app/components/cupboard/cupboard.component.ts b/ufund-ui/src/app/components/cupboard/cupboard.component.ts
index a4f8db2..bde8e27 100644
--- a/ufund-ui/src/app/components/cupboard/cupboard.component.ts
+++ b/ufund-ui/src/app/components/cupboard/cupboard.component.ts
@@ -8,6 +8,7 @@ import {AuthService} from '../../services/auth.service';
import {ToastsService, ToastType} from '../../services/toasts.service';
import {UsersService} from '../../services/users.service';
import {SortingAlgoArrays} from './sorting';
+import {Router} from '@angular/router';
@Component({
selector: 'app-cupboard',
@@ -33,7 +34,8 @@ export class CupboardComponent implements OnInit {
private cupboardService: CupboardService,
private authService: AuthService,
private toastService: ToastsService,
- private usersService: UsersService
+ protected usersService: UsersService,
+ private router: Router
) {}
ngOnInit(): void {
@@ -42,6 +44,8 @@ export class CupboardComponent implements OnInit {
// this.refresh()
this.search(null)
});
+ this.authService.getCurrentUserSubject().subscribe(
+ () => this.usersService.refreshBasket())
}
refresh() {
@@ -121,6 +125,8 @@ export class CupboardComponent implements OnInit {
return of();
}))
.subscribe(() => {
+ let action = {label: "View Basket", onAction: () => this.router.navigate(['/basket'])}
+ this.toastService.sendToast(ToastType.INFO, `"${need.name}" Added to basket`, action)
this.usersService.refreshBasket();
});
} else {
@@ -137,6 +143,12 @@ export class CupboardComponent implements OnInit {
return this.authService.getCurrentUser()?.type === userType.HELPER
}
+ inBasket(basket: Need[] | null, need: Need) {
+ console.log(basket)
+ console.log(need)
+ return basket?.map(r => r.id).includes(need.id);
+ }
+
// --------------- FORM STUFF NOT IMPLEMENTED YET --------------- //
// async updateSearchResults() {