From 361f73f967475089e995b62079316bd91232570e Mon Sep 17 00:00:00 2001 From: benal01 Date: Mon, 17 Mar 2025 23:44:37 -0400 Subject: implemetation of needs from API call --- .../components/funding-basket/funding-basket.component.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/ufund-ui/src/app/components/funding-basket/funding-basket.component.ts b/ufund-ui/src/app/components/funding-basket/funding-basket.component.ts index d3b0a7f..418158f 100644 --- a/ufund-ui/src/app/components/funding-basket/funding-basket.component.ts +++ b/ufund-ui/src/app/components/funding-basket/funding-basket.component.ts @@ -31,15 +31,16 @@ export class FundingBasketComponent implements return; } this.cupboardService.getNeeds().subscribe(n => this.needs = n) - this.usersService.getCurrentUser()?.subscribe(user => { - this.user = user; - this.getBasketNeeds(); - }); + const currentUser = this.usersService.getCurrentUser(); + if (currentUser) { + this.user = currentUser; + } + this.getBasketNeeds(); } getBasketNeeds(): void { - if (this.user && this.user.cupboard) { - this.user.cupboard.forEach(need => { + if (this.user && this.needs) { + this.needs.forEach(need => { if (this.isInBasket(need)){ this.basket.push(need); } -- cgit v1.2.3