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

@Component({
  selector: 'app-save-throw-details',
  templateUrl: './save-throw-details.component.html',
  styleUrl: './save-throw-details.component.scss',
})
export class SaveThrowDetailsComponent {
  @Input() attributeName: string = '';
  @Input() saveModifier: string = '';
  @Input() advantage: 'none' | 'advantage' | 'disadvantage' = 'none';

  public showButtonsContainer: boolean = false;

  constructor(
    public translate: TranslateService,
    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);
    }
  }
}
