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 { IInputDataUpload } from '../input-data-upload.model';
import { InputDataUploadService } from '../service/input-data-upload.service';

export const IMPORT_EVENT = 'IMPORT_EVENT';

@Component({
  standalone: true,
  templateUrl: './input-data-upload-import-dialog.component.html',
  imports: [SharedModule, FormsModule],
})
export class InputDataUploadImportDialogComponent {
  inputDataUpload?: IInputDataUpload;

  protected inputDataUploadService = inject(InputDataUploadService);
  protected activeModal = inject(NgbActiveModal);

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

  confirmImport(id: number): void {
	if (this.inputDataUpload) {
	  this.inputDataUploadService.doLoad(this.inputDataUpload.id).subscribe(() => {
		this.activeModal.close(IMPORT_EVENT);
	  });
	}
  }
}
