From 28a8fde7d57ee5ef762bd20f41c728966ab74d06 Mon Sep 17 00:00:00 2001
From: Akash Keshav <112591754+domesticchores@users.noreply.github.com>
Date: Tue, 18 Mar 2025 12:59:11 -0400
Subject: connected backend to frontend for funding basket. -ak
---
 .../funding-basket/funding-basket.component.html        | 17 ++++++++---------
 .../funding-basket/funding-basket.component.ts          |  5 ++---
 ufund-ui/src/app/services/users.service.ts              |  9 +++++++--
 3 files changed, 17 insertions(+), 14 deletions(-)
(limited to 'ufund-ui/src/app')
diff --git a/ufund-ui/src/app/components/funding-basket/funding-basket.component.html b/ufund-ui/src/app/components/funding-basket/funding-basket.component.html
index 0a880af..dd02e98 100644
--- a/ufund-ui/src/app/components/funding-basket/funding-basket.component.html
+++ b/ufund-ui/src/app/components/funding-basket/funding-basket.component.html
@@ -2,33 +2,33 @@
 
 
     
-    {{ needCount }}
+    {{ this.usersService.getBasket().getValue().length }}
 
 
-
+
     
There are no needs in the basket
 
 
-
+
     
         
              | 
         
     
     
-        
+        
             | 
                 
                     {{need.name}}
                 
                  
-                
+                
                  
                  
                 
                 
+                (click)="this.usersService.removeNeed(need.id)">Remove Need
                  
              | 
         
@@ -36,6 +36,5 @@
 
 
 
-    
+    
 
\ No newline at end of file
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 bc7f087..061e3fa 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
@@ -14,12 +14,11 @@ import { BehaviorSubject, firstValueFrom } from 'rxjs';
     styleUrl: './funding-basket.component.css'
 })
 export class FundingBasketComponent implements OnInit {
-  basket = new BehaviorSubject([]);
 
   constructor(
     private router: Router,
-    private cupboardService: CupboardService, 
-    private usersService: UsersService
+    protected cupboardService: CupboardService, 
+    protected usersService: UsersService
   ) {}
 
   // this is for login rerouting
diff --git a/ufund-ui/src/app/services/users.service.ts b/ufund-ui/src/app/services/users.service.ts
index a0d316c..62aea79 100644
--- a/ufund-ui/src/app/services/users.service.ts
+++ b/ufund-ui/src/app/services/users.service.ts
@@ -83,12 +83,17 @@ export class UsersService {
             return await firstValueFrom(this.cupboardService.getNeed(needID));
         })
         Promise.all(promiseArr).then(r => this.basket.next(r));
-      }
+    }
     
-      removeNeed(id: number) {
+    removeNeed(id: number) {
         let newArr = this.basket.getValue().filter(v => v.id != id);
         this.basket.next(newArr);
         this.getCurrentUser()!.basket = newArr.map(need => need.id);
         this.updateUser(this.getCurrentUser()!);
     }
+
+    getBasket() {
+        return this.basket;
+    }
+
 }
-- 
cgit v1.2.3