From 02858a9af74b5f564b882adf38391dd3a1f5126c Mon Sep 17 00:00:00 2001 From: benal01 Date: Tue, 18 Mar 2025 00:01:16 -0400 Subject: add need to basket --- .../app/components/need-list/need-list.component.html | 2 ++ .../app/components/need-list/need-list.component.ts | 19 +++++++++++++++++++ ufund-ui/src/app/services/users.service.ts | 2 +- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/ufund-ui/src/app/components/need-list/need-list.component.html b/ufund-ui/src/app/components/need-list/need-list.component.html index 07f6735..fce6377 100644 --- a/ufund-ui/src/app/components/need-list/need-list.component.html +++ b/ufund-ui/src/app/components/need-list/need-list.component.html @@ -14,6 +14,7 @@ {{need.name}} + @@ -23,4 +24,5 @@ {{need.name}} + diff --git a/ufund-ui/src/app/components/need-list/need-list.component.ts b/ufund-ui/src/app/components/need-list/need-list.component.ts index b21979f..953904c 100644 --- a/ufund-ui/src/app/components/need-list/need-list.component.ts +++ b/ufund-ui/src/app/components/need-list/need-list.component.ts @@ -96,6 +96,25 @@ export class NeedListComponent { return type === ("MANAGER" as unknown as userType); } + isHelper() { + const type = this.usersService.getCurrentUser()?.type; + console.log(type); + return type === ("HELPER" as unknown as userType); + } + + add(need: Need) { + const currentUser = this.usersService.getCurrentUser(); + if (currentUser) { + this.usersService.updateUser(currentUser.username).subscribe(() => { + const currentUser = this.usersService.getCurrentUser(); + if (currentUser && currentUser.basket) { + currentUser.basket.push(need); + } + }); + } + + } + back() { this.searchResults = []; } diff --git a/ufund-ui/src/app/services/users.service.ts b/ufund-ui/src/app/services/users.service.ts index c570ccf..f3166cc 100644 --- a/ufund-ui/src/app/services/users.service.ts +++ b/ufund-ui/src/app/services/users.service.ts @@ -40,7 +40,7 @@ export class UsersService { return this.http.get(`${this.url}/${id}`, this.httpOptions) } - updateUser(id: number): Observable { + updateUser(id: string): Observable { return this.http.put(`${this.url}/${id}`, this.httpOptions) } -- cgit v1.2.3