import { ChangeDetectionStrategy, Component, inject } from '@angular/core';

import {
  ConfirmModalData,
  MODAL_DATA,
  ModalRef
} from '../../../core/services/modal.service';
import { ButtonComponent } from '../button/button.component';

@Component({
  selector: 'app-confirm-modal',
  imports: [ButtonComponent],
  templateUrl: './confirm-modal.component.html',
  styleUrl: './confirm-modal.component.scss',
  changeDetection: ChangeDetectionStrategy.OnPush
})
export class ConfirmModalComponent {
  protected readonly data = inject<ConfirmModalData>(MODAL_DATA);
  private readonly modalRef = inject<ModalRef<boolean>>(ModalRef);

  protected cancel(): void {
    this.modalRef.close(false);
  }

  protected confirm(): void {
    this.modalRef.close(true);
  }
}
