diff options
author | sowgro <tpoke.ferrari@gmail.com> | 2025-03-30 14:44:04 -0400 |
---|---|---|
committer | sowgro <tpoke.ferrari@gmail.com> | 2025-03-30 14:44:04 -0400 |
commit | 42725635e70426c4d2923c680609da8277c693ea (patch) | |
tree | 423c338e9711690095e9b9022a2e76e55c657f11 /ufund-ui | |
parent | 9fba1c4af3c9b5aad206ec76469c1625125ea799 (diff) | |
download | JellySolutions-42725635e70426c4d2923c680609da8277c693ea.tar.gz JellySolutions-42725635e70426c4d2923c680609da8277c693ea.tar.bz2 JellySolutions-42725635e70426c4d2923c680609da8277c693ea.zip |
fix imports in need-list.component.ts
Diffstat (limited to 'ufund-ui')
-rw-r--r-- | ufund-ui/src/app/components/need-list/need-list.component.ts | 25 |
1 files changed, 15 insertions, 10 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 2bbacb0..66e53e8 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 @@ -3,6 +3,8 @@ import {Need} from '../../models/Need'; import {CupboardService} from '../../services/cupboard.service'; import { UsersService } from '../../services/users.service'; import { userType } from '../../models/User'; +import {AuthService} from '../../services/auth.service'; +import {catchError, of} from 'rxjs'; interface sortAlgo { (a: Need,b: Need): number; @@ -72,7 +74,8 @@ export class NeedListComponent { constructor( private cupboardService: CupboardService, - private usersService: UsersService + private usersService: UsersService, + private authService: AuthService ) {} refresh() { @@ -148,12 +151,12 @@ export class NeedListComponent { } isManager() { - const type = this.usersService.getCurrentUser()?.type; + const type = this.authService.getCurrentUser()?.type; return type === ("MANAGER" as unknown as userType); } isHelper() { - const type = this.usersService.getCurrentUser()?.type; + const type = this.authService.getCurrentUser()?.type; return type === ("HELPER" as unknown as userType); } @@ -165,17 +168,19 @@ export class NeedListComponent { } add(need: Need) { - const currentUser = this.usersService.getCurrentUser(); + const currentUser = this.authService.getCurrentUser(); //console.log("get current user in angular:", currentUser) if (currentUser) { 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); - } - }); + this.usersService.updateUser(currentUser) + .pipe(catchError((err, _) => { + console.error(err); + return of(); + })) + .subscribe(() => { + this.usersService.refreshBasket(); + }); } else { window.alert("This need is already in your basket!") } |