diff options
Diffstat (limited to 'ufund-ui/src/app/components/need-list')
| -rw-r--r-- | ufund-ui/src/app/components/need-list/need-list.component.ts | 20 | 
1 files changed, 12 insertions, 8 deletions
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 2764c7e..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 @@ -109,14 +109,18 @@ export class NeedListComponent {      const currentUser = this.usersService.getCurrentUser();      //console.log("get current user in angular:", currentUser)      if (currentUser) { -      currentUser.basket.push(need.id); -      //console.log("pushed to basket: " + currentUser.basket) -      this.usersService.updateUser(currentUser).subscribe(() => { -        this.usersService.refreshBasket(); -        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!") +      } +            }  | 
