import { Component, OnInit, Input,Output, EventEmitter } from '@angular/core';
import {EmployeeCourseIdService} from 'app/coach/shared/service/employee-course-id.service';
import {coachEmployeeUpdateStatus} from 'app/models/coach-employee/udpateStatus';

@Component({
  selector: 'app-coach-employee-card',
  templateUrl: './coach-employee-card.component.html',
  styleUrls: ['./coach-employee-card.component.scss']

})
export class CoachEmployeeCardComponent implements OnInit {



  @Input() candidate:any;
  @Input() approval:string;
  @Output() candidateID = new EventEmitter<string>();
  @Output() scheduleId = new EventEmitter<string>();
  @Output() approve = new EventEmitter<string>();
  @Output() reject = new EventEmitter<string>();



  constructor(private employeeIdCourseService:EmployeeCourseIdService) { }

  ngOnInit() {
    console.log(this.approval);
    if(!this.approval){
      this.approval = 'hide';
    }
  }

  Selected(ID,courseID) {

    var obj = {
      userinfoMastrId: ID,
      courseId: courseID
    }

    this.employeeIdCourseService.setEmployeeIdCourse(obj);
    console.log("obj",obj);
    this.candidateID.emit(ID);
  }

  schedule(ID){
    this.scheduleId.emit(ID);
  }

  Approve(decision, status){
    console.log("status,status ",status);
    if( status == "METTL_REVIEW" && decision == "show"){

      console.log('METTL_REVIEW',decision);
      this.approval = decision;

    }
    else if (decision == 'hide'){
      this.approval = decision;
      console.log('METTL_REVIEW no hide');
    }


  }
  confirmApprove(id,courseId,updatedStatus){

    var obj ={
      userInfoMstrId : id,
      courseId : courseId,
      status : updatedStatus
    }


    this.employeeIdCourseService.setEmployeeApproveRejectData(obj);

    this.approve.emit(status);
    console.log("confirm approve");
  }


}
