import { Component, OnInit, EventEmitter, Output, Input } from '@angular/core';
import { ModalService } from '@libs/ui';
import { Process } from '../../../../core/models/process.model';
import { Router } from '@angular/router';

@Component({
  selector: 'app-process-delete-dialog',
  templateUrl: './process-delete-dialog.component.html',
  styleUrls: ['./process-delete-dialog.component.scss'],
})
export class ProcessDeleteDialogComponent implements OnInit {
  id: string;
  @Output() deleted: EventEmitter<Process> = new EventEmitter();
  private _process: Process;
  @Input() set process(val: Process) {
    this._process = val;
    this.id = 'process-delete-modal-' + this.process.id;
  }
  get process(): Process {
    return this._process;
  }

  constructor(private modalService: ModalService, private router: Router) {}

  ngOnInit() {}

  openDialog() {
    this.modalService.open(this.id);
  }

  closeModal() {
    this.modalService.close(this.id);
  }

  delete() {
    this.deleted.emit(this.process);
  }
}
