diff options
| author | Hayden Hartman <haydenhartman10@gmail.com> | 2025-03-18 17:17:23 -0400 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-18 17:17:23 -0400 | 
| commit | db9e4a8c26dc5252cfe0974843bc391c57edd07d (patch) | |
| tree | 0c8aba41ae378fe04e8312ab9eff48656732c9c8 /ufund-ui/src/app/components/need-list | |
| parent | c7c4e037d655762cc6b394a460effbcd8816d175 (diff) | |
| parent | 7a5396b65fcde8153c8eeae565bfecb7de37b23f (diff) | |
| download | JellySolutions-db9e4a8c26dc5252cfe0974843bc391c57edd07d.tar.gz JellySolutions-db9e4a8c26dc5252cfe0974843bc391c57edd07d.tar.bz2 JellySolutions-db9e4a8c26dc5252cfe0974843bc391c57edd07d.zip  | |
Merge pull request #14 from RIT-SWEN-261-02/funding_basketv2.1
funding-basket merge
Diffstat (limited to '')
| -rw-r--r-- | ufund-ui/src/app/components/need-list/need-list.component.html | 2 | ||||
| -rw-r--r-- | ufund-ui/src/app/components/need-list/need-list.component.ts | 25 | 
2 files changed, 15 insertions, 12 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 4a67dfa..36c12d0 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 @@ -24,5 +24,5 @@          {{need.name}}      </a>      <button (click)="delete(need.id)" *ngIf="isManager()">Delete</button> -    <!-- <button (click)="add(need)" *ngIf="isHelper()">Add To Basket</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 e1c0de1..25f05d6 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 @@ -105,19 +105,22 @@ export class NeedListComponent {      return type === ("HELPER" as unknown as userType);    } -  add(need: number) { +  add(need: Need) {      const currentUser = this.usersService.getCurrentUser(); +    //console.log("get current user in angular:", currentUser)      if (currentUser) { -      this.usersService.updateUser(currentUser.username, currentUser).subscribe(() => { -        const currentUser = this.usersService.getCurrentUser(); -        if (currentUser && currentUser.basket) { -          currentUser.basket.push(need); -          console.log("added to basket"); -        } -        error: (err: any) => { -          console.error(err); -        } -      }); +      if (!currentUser.basket.includes(need.id)) { +        currentUser.basket.push(need.id); +        this.usersService.updateUser(currentUser).subscribe(() => { +          this.usersService.refreshBasket(); +          error: (err: any) => { +            console.error(err); +          } +        }); +      } else { +        window.alert("This need is already in your basket!") +      } +            }  | 
