import { Highlightable } from '@angular/cdk/a11y';
import { Component, ElementRef, EventEmitter, HostBinding, Input, Output } from '@angular/core';
import { BranchDTO } from '@swagger/checkout';

@Component({
  selector: 'ui-branch-dropdown-item',
  templateUrl: 'branch-dropdown-item.component.html',
  styleUrls: ['branch-dropdown-item.component.scss'],
})
export class UiBranchDropdownItemComponent implements Highlightable {
  @Input() branch: BranchDTO;

  @Output() click = new EventEmitter<BranchDTO>();

  @Input()
  isSelected: boolean;

  isActive = false;

  @Input()
  @HostBinding('disabled')
  disabled?: boolean;

  constructor(private element: ElementRef) {}

  setActiveStyles(): void {
    this.isActive = true;
  }

  setInactiveStyles(): void {
    this.isActive = false;
  }

  scrollIntoView() {
    this.element?.nativeElement?.scrollIntoView();
  }
}
