import {Component, Input, OnInit} from '@angular/core';
import {Employee, EmployeePermission, mapped_permissions} from "../../model/employee";

@Component({
  selector: 'cre-permissions-list',
  templateUrl: './permissions-list.component.html',
  styleUrls: ['./permissions-list.component.sass']
})
export class PermissionsListComponent implements OnInit {
  @Input() employee: Employee

  // @ts-ignore
  private _permissions = Object.values(mapped_permissions).flatMap(p => p)

  constructor() {
  }

  ngOnInit(): void {
  }

  get permissions(): EmployeePermission[] {
    return this._permissions.filter(p => this.employee.permissions.indexOf(p.permission) >= 0).map(p => p.description)
  }
}
