diff options
author | benal01 <bja4245@rit.edu> | 2025-03-18 00:01:16 -0400 |
---|---|---|
committer | benal01 <bja4245@rit.edu> | 2025-03-18 00:01:16 -0400 |
commit | 02858a9af74b5f564b882adf38391dd3a1f5126c (patch) | |
tree | 5287b0e4ae9fd2e3ae5219ea304f0cf9e6ad7c48 | |
parent | 2ee4d91af8262c978120b0d540a86386309b4e54 (diff) | |
download | JellySolutions-02858a9af74b5f564b882adf38391dd3a1f5126c.tar.gz JellySolutions-02858a9af74b5f564b882adf38391dd3a1f5126c.tar.bz2 JellySolutions-02858a9af74b5f564b882adf38391dd3a1f5126c.zip |
add need to basket
3 files changed, 22 insertions, 1 deletions
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}} </a> <button (click)="delete(need.id)" *ngIf="isManager()">Delete</button> + <button (click)="add(need)" *ngIf="isHelper()">Add To Basket</button> </div> </div> </div> @@ -23,4 +24,5 @@ {{need.name}} </a> <button (click)="delete(need.id)" *ngIf="isManager()">Delete</button> + <button (click)="add(need)" *ngIf="isHelper()">Add To Basket</button> </li> 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<User>(`${this.url}/${id}`, this.httpOptions) } - updateUser(id: number): Observable<User> { + updateUser(id: string): Observable<User> { return this.http.put<User>(`${this.url}/${id}`, this.httpOptions) } |