diff options
author | Akash Keshav <112591754+domesticchores@users.noreply.github.com> | 2025-03-18 14:32:56 -0400 |
---|---|---|
committer | Akash Keshav <112591754+domesticchores@users.noreply.github.com> | 2025-03-18 14:32:56 -0400 |
commit | 054857f51d1397d1122219e407a25c18472733f6 (patch) | |
tree | 64ec50ae57294653108f5207cb5ff1c14b9f7437 | |
parent | fe04a7078f6b381d45715f80662628410ca8dc72 (diff) | |
download | JellySolutions-054857f51d1397d1122219e407a25c18472733f6.tar.gz JellySolutions-054857f51d1397d1122219e407a25c18472733f6.tar.bz2 JellySolutions-054857f51d1397d1122219e407a25c18472733f6.zip |
add alert on duplicate entry
-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!") + } + } |