import { Component, inject } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';

import SharedModule from 'app/shared/shared.module';
import { ITEM_DELETED_EVENT } from 'app/config/navigation.constants';
import { IOrganizationType } from '../organization-type.model';
import { OrganizationTypeService } from '../service/organization-type.service';

@Component({
  standalone: true,
  templateUrl: './organization-type-delete-dialog.component.html',
  imports: [SharedModule, FormsModule],
})
export class OrganizationTypeDeleteDialogComponent {
  organizationType?: IOrganizationType;

  protected organizationTypeService = inject(OrganizationTypeService);
  protected activeModal = inject(NgbActiveModal);

  cancel(): void {
    this.activeModal.dismiss();
  }

  confirmDelete(id: number): void {
    this.organizationTypeService.delete(id).subscribe(() => {
      this.activeModal.close(ITEM_DELETED_EVENT);
    });
  }
}
