import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core';
import { ConfirmDialog } from '@msfa-enums/confirm-dialog.enum';

@Component({
  selector: 'msfa-confirm-dialog',
  templateUrl: './confirm-dialog.component.html',
  styleUrls: ['./confirm-dialog.component.scss'],
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ConfirmDialogComponent {
  @Input() dialogOpen: boolean;
  @Input() dialogTitle = 'Bekräfta';
  @Input() ariaLabel = 'Bekräfta för att gå vidare';
  @Input() primaryButtonText = 'Skicka';
  @Input() secondaryButtonText = 'Avbryt';
  @Output() confirmDialogChanged = new EventEmitter<ConfirmDialog>();

  closeDialog(confirmed: boolean): void {
    this.dialogOpen = false;
    this.confirmDialogChanged.emit(confirmed ? ConfirmDialog.ACCEPTED : ConfirmDialog.DISMISSED);
  }
}
