diff options
| author | Akash Keshav <112591754+domesticchores@users.noreply.github.com> | 2025-03-18 11:41:04 -0400 | 
|---|---|---|
| committer | Akash Keshav <112591754+domesticchores@users.noreply.github.com> | 2025-03-18 11:41:04 -0400 | 
| commit | 0b41684e57c79374aee3a564307cd4fdef603e7c (patch) | |
| tree | 63d8f94f6671d6a162d71a0b310bb26af4864961 /ufund-ui | |
| parent | bd41fc58b5537a12072625bbf75baf75d5ed2274 (diff) | |
| download | JellySolutions-0b41684e57c79374aee3a564307cd4fdef603e7c.tar.gz JellySolutions-0b41684e57c79374aee3a564307cd4fdef603e7c.tar.bz2 JellySolutions-0b41684e57c79374aee3a564307cd4fdef603e7c.zip  | |
THE UPDATE USER WORKS! -ak
Diffstat (limited to 'ufund-ui')
3 files changed, 11 insertions, 11 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..46e09f0 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,15 +105,14 @@ 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"); -        } +      currentUser.basket.push(need.id); +      console.log("pushed to basket: " + currentUser.basket) +      this.usersService.updateUser(currentUser).subscribe(() => { +        console.log("rah");          error: (err: any) => {            console.error(err);          } diff --git a/ufund-ui/src/app/services/users.service.ts b/ufund-ui/src/app/services/users.service.ts index bc31870..2a95202 100644 --- a/ufund-ui/src/app/services/users.service.ts +++ b/ufund-ui/src/app/services/users.service.ts @@ -40,10 +40,11 @@ export class UsersService {          return this.http.get<User>(`${this.url}/${id}`, this.httpOptions)      } -    updateUser(id: string, user: User): Observable<User> { -        console.log(id, user) +    updateUser(user: User): Observable<User> { +        console.log(user, user.basket)          console.log(this.apiKey) -        return this.http.put<User>(`${this.url}/${id}`,user, this.httpOptions) +         +        return this.http.put<User>(`${this.url}/${user.username}`,user, this.httpOptions2)      }      deleteUser(id: number): Observable<boolean> {  | 
