diff options
author | sowgro <tpoke.ferrari@gmail.com> | 2025-04-05 14:37:01 -0400 |
---|---|---|
committer | sowgro <tpoke.ferrari@gmail.com> | 2025-04-05 14:37:01 -0400 |
commit | c2e7b170bfa0678a6ff4576d07388778f30084b0 (patch) | |
tree | 57fc334bea1bc15f8b971d499338497dd3fa7388 /ufund-ui/src/app/services/users.service.ts | |
parent | 7cedd8713d30fedcc9fc486a49d4804f37ab8765 (diff) | |
parent | 0103ffc6f84d04433943c644ab759c1d04b5e681 (diff) | |
download | JellySolutions-c2e7b170bfa0678a6ff4576d07388778f30084b0.tar.gz JellySolutions-c2e7b170bfa0678a6ff4576d07388778f30084b0.tar.bz2 JellySolutions-c2e7b170bfa0678a6ff4576d07388778f30084b0.zip |
Merge branch 'main' into need-image
# Conflicts:
# ufund-ui/src/app/components/need-list/need-list.component.ts
# ufund-ui/src/app/components/need-page/need-page.component.html
Diffstat (limited to '')
-rw-r--r-- | ufund-ui/src/app/services/users.service.ts | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/ufund-ui/src/app/services/users.service.ts b/ufund-ui/src/app/services/users.service.ts index 080c394..35d080d 100644 --- a/ufund-ui/src/app/services/users.service.ts +++ b/ufund-ui/src/app/services/users.service.ts @@ -1,7 +1,7 @@ import { Injectable } from '@angular/core'; import {HttpClient, HttpHeaders} from '@angular/common/http'; import {BehaviorSubject, catchError, firstValueFrom, Observable, of} from 'rxjs'; -import {User} from '../models/User'; +import {User, userType} from '../models/User'; import { Need } from '../models/Need'; import { CupboardService } from './cupboard.service'; import {AuthService} from './auth.service'; @@ -34,7 +34,9 @@ export class UsersService { private http: HttpClient, private cupboardService: CupboardService, private authService: AuthService - ) {} + ) { + authService.getCurrentUserSubject().subscribe(() => this.refreshBasket()) + } async createUser(username:string, password:string) { await firstValueFrom(this.http.post<User>(this.url, {username: username, password: password}, this.httpOptions())) @@ -84,4 +86,16 @@ export class UsersService { return this.basket; } + isManager() { + return this.authService.getCurrentUser()?.type === userType.MANAGER + } + + isHelper() { + return this.authService.getCurrentUser()?.type === userType.HELPER + } + + inBasket(basket: Need[] | null, need: Need) { + return basket?.map(r => r.id).includes(need.id); + } + } |