diff options
author | benal01 <bja4245@rit.edu> | 2025-04-05 13:22:58 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-04-05 13:22:58 -0400 |
commit | 0103ffc6f84d04433943c644ab759c1d04b5e681 (patch) | |
tree | 1cd8fb31b849b4d5be00d4be0e3db92bbbafb5e1 /ufund-ui/src/app/services/users.service.ts | |
parent | 5a5d31896d79a736bce33b7d1aa7b3168ba308a9 (diff) | |
parent | 04db6f32b249ffb17c571cd6b16c8c54397f0be4 (diff) | |
download | JellySolutions-0103ffc6f84d04433943c644ab759c1d04b5e681.tar.gz JellySolutions-0103ffc6f84d04433943c644ab759c1d04b5e681.tar.bz2 JellySolutions-0103ffc6f84d04433943c644ab759c1d04b5e681.zip |
Merge pull request #27 from RIT-SWEN-261-02/need-list-abstraction
Need list abstraction
Diffstat (limited to 'ufund-ui/src/app/services/users.service.ts')
-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); + } + } |