import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
import { Feature } from '@msfa-enums/feature.enum';
import { IconType } from '@msfa-enums/icon-type.enum';
import { RoleEnum } from '@msfa-enums/role.enum';
import { environment } from '@msfa-environment';
import { Role } from '@msfa-models/role.model';

@Component({
  selector: 'msfa-sidebar',
  templateUrl: './sidebar.component.html',
  styleUrls: ['./sidebar.component.scss'],
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class SidebarComponent {
  @Input() userRoles: Role[];
  iconType = IconType;
  activeFeatures: Feature[] = environment.activeFeatures;

  get adminVisible(): boolean {
    return (
      this.activeFeatures.includes(Feature.ADMINISTRATION) &&
      this.userRoles?.some(role => role.type === RoleEnum.MSFA_AuthAdmin)
    );
  }
  get avropVisible(): boolean {
    return (
      this.activeFeatures.includes(Feature.AVROP) &&
      this.userRoles?.some(role => role.type === RoleEnum.MSFA_ReceiveDeltagare)
    );
  }
  get deltagareVisible(): boolean {
    return (
      this.activeFeatures.includes(Feature.DELTAGARE) &&
      this.userRoles?.some(role => role.type === RoleEnum.MSFA_ReportAndPlanning)
    );
  }
}
