import { Component, Input } from '@angular/core';
import { DetailsService } from 'src/services/details/details.service';

@Component({
  selector: 'app-skill-details',
  templateUrl: './skill-details.component.html',
  styleUrl: './skill-details.component.scss',
})
export class SkillDetailsComponent {
  @Input() skillName: string = '';
  @Input() skillModifier: string = '';
  @Input() advantage: 'none' | 'advantage' | 'disadvantage' = 'none';

  public showButtonsContainer: boolean = false;

  public constructor(public detailsAccessor: DetailsService) {}

  public showButtons(): void {
    this.showButtonsContainer = true;
  }

  public close(result: string): void {
    if (result === 'update') {
      this.detailsAccessor.closePanel(result, {
        advantage: this.advantage,
      });
    } else if (result === 'cancel') {
      this.detailsAccessor.closePanel(result);
    }
  }
}
