import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { EmployeeHttpService } from 'app/services/employee/employee-http.service';
import {MatDialog, MatDialogRef, MAT_DIALOG_DATA} from '@angular/material';
import { CreateEnvironmentComponent } from '../create-environment/create-environment.component';

@Component({
  selector: 'app-project-request-list',
  templateUrl: './project-request-list.component.html',
  styleUrls: ['./project-request-list.component.scss']
})
export class ProjectRequestListComponent implements OnInit {

  listTableHeader: string[];
  projectDetail;
  projectInfo;
  constructor(private employeeService: EmployeeHttpService, private dialog: MatDialog) { }
  @Input() projectListInfo;
  @Input() submitted;
  @Output() getAllProjectList = new EventEmitter();
  ngOnInit() {
    this.listTableHeader = ['Employee Name', 'Template', 'Project Name', 'Created On'];
    console.log('projectListInfo', this.projectListInfo);
  }

  openDialog(project) {
    const dialogRef = this.dialog.open(CreateEnvironmentComponent, {
    height: '530.98px',
    width: '650.53px',
    data: {project},
    });
    dialogRef.componentInstance.getAllProjects.subscribe(() => {
     this.getAllProjectList.emit();
    });
  }
  getProjectById(projectId) {
    this.employeeService.getProjectById(projectId).subscribe(resp => {
      console.log('resp', resp);
      this.openDialog(resp);
      }, err => {
      console.log('Error on gett all created repo');
      });
  }
}
