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

@Component({
  selector: 'msfa-sidebar',
  templateUrl: './sidebar.component.html',
  styleUrls: ['./sidebar.component.scss'],
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class SidebarComponent {
  @Input() userRoles: Role[];
  UiIconType = UiIconType;
  UiIconSize = UiIconSize;
  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 || role.type === RoleEnum.MSFA_ReceiveDeltagare
      )
    );
  }
  get exportsVisible(): boolean {
    return (
      this.activeFeatures.includes(Feature.EXPORTS) &&
      this.userRoles?.some(role => role.type === RoleEnum.MSFA_ReceiveDeltagare)
    );
  }
}
