diff options
Diffstat (limited to 'ufund-ui/src/app')
| -rw-r--r-- | ufund-ui/src/app/components/funding-basket/funding-basket.component.ts | 45 | ||||
| -rw-r--r-- | ufund-ui/src/app/services/users.service.ts | 9 | 
2 files changed, 29 insertions, 25 deletions
diff --git a/ufund-ui/src/app/components/funding-basket/funding-basket.component.ts b/ufund-ui/src/app/components/funding-basket/funding-basket.component.ts index 7f086ec..66b9fd1 100644 --- a/ufund-ui/src/app/components/funding-basket/funding-basket.component.ts +++ b/ufund-ui/src/app/components/funding-basket/funding-basket.component.ts @@ -42,7 +42,7 @@ export class FundingBasketComponent implements OnInit {        let contribution = c as HTMLInputElement;        console.log(contribution.value, contribution.id);        contribution.setAttribute("style",""); -      if ( contribution.value == '' || contribution.valueAsNumber < 0) { +      if ( contribution.value == '' || contribution.valueAsNumber <= 0) {          this.isValid = false;          contribution.setAttribute("style","color: #ff0000");        } @@ -53,30 +53,27 @@ export class FundingBasketComponent implements OnInit {          let need = await firstValueFrom(this.cupboardService.getNeed(+contribution.id));          need.current +=+ contribution.value;          console.log(need); -        this.usersService.removeNeed(need.id); +        this.usersService.removeNeed(+need.id);          this.cupboardService.updateNeed(need.id, need) -                    .pipe(catchError((ex, r) => { -                        console.log(ex.status); -                        if (ex.status == 500) { -                            this.statusText.next("Fields cannot be blank"); -                        } else if (ex.status == 400) { -                            this.statusText.next("Goal must be greater than 0"); -                        } else { -                            this.statusText.next("Error on creating need"); -                        } -                        return new Observable<string>(); -                    })) -                    .subscribe( -                        (result) => { -                            if (result) { -                                console.log("need updated successfully"); -                                //this.needList?.refresh() -                            } else { -                                console.log("need update failed"); -                            } -                        } -         -                    ); +            .pipe(catchError((ex, r) => { +                console.log(ex.status); +                if (ex.status == 500) { +                    this.statusText.next('Fields cannot be blank'); +                } else if (ex.status == 400) { +                    this.statusText.next('Goal must be greater than 0'); +                } else { +                    this.statusText.next('Error on creating need'); +                } +                return new Observable<string>(); +            })) +            .subscribe((result) => { +                if (result) { +                    console.log('need updated successfully'); +                    //this.needList?.refresh() +                } else { +                    console.log('need update failed'); +                } +            });        }      }    } diff --git a/ufund-ui/src/app/services/users.service.ts b/ufund-ui/src/app/services/users.service.ts index 62aea79..ddbd322 100644 --- a/ufund-ui/src/app/services/users.service.ts +++ b/ufund-ui/src/app/services/users.service.ts @@ -45,6 +45,7 @@ export class UsersService {      }      updateUser(user: User): Observable<User> { +        console.log("REMOVING USER IN ANGULAR: ", user)          console.log(user, user.basket)          console.log(this.apiKey) @@ -89,7 +90,13 @@ export class UsersService {          let newArr = this.basket.getValue().filter(v => v.id != id);          this.basket.next(newArr);          this.getCurrentUser()!.basket = newArr.map(need => need.id); -        this.updateUser(this.getCurrentUser()!); +        console.log(this.getCurrentUser()!.basket) +        this.updateUser(this.getCurrentUser()!).subscribe(() => { +            this.refreshBasket(); +            error: (err: any) => { +              console.error(err); +            } +          });      }      getBasket() {  | 
