import { ChangeDetectionStrategy, Component } from '@angular/core';
import { Role } from '@msfa-models/role.model';
import { UserService } from '@msfa-services/api/user.service';
import { Observable } from 'rxjs';
import { filter, map } from 'rxjs/operators';

@Component({
  selector: 'msfa-accessibility',
  templateUrl: './accessibility.component.html',
  styleUrls: ['./accessibility.component.scss'],
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class AccessibilityComponent {
  userFullName$: Observable<string> = this.userService.user$.pipe(
    filter(user => !!user),
    map(userName => userName.fullName)
  );
  userRoles$: Observable<Role[]> = this.userService.userRoles$;

  constructor(private userService: UserService) {}

  isAuthorizedUser(userRoles: Role[]): boolean {
    return !!userRoles.length;
  }
}
