import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
import { environment } from '../../../../environments/environment.dev';

@Component({
  selector: 'app-pgm-recommend-employee-card',
  templateUrl: './pgm-recommend-employee-card.component.html',
  styleUrls: ['./pgm-recommend-employee-card.component.scss']
})
export class PgmRecommendEmployeeCardComponent implements OnInit {

  @Input() candidate:any;
  @Input() role:any;
  @Input() approval:string;
  @Output() candidateID = new EventEmitter<string>();
  @Output() assignCoach = new EventEmitter<object>();
  @Output() scheduleId = new EventEmitter<string>();
  @Output() eventID = new EventEmitter<string>();
  @Output() approve = new EventEmitter<string>();
  @Output() reject = new EventEmitter<string>();
  assign = false;


  imageUrl: string = environment.imageUrl;
  constructor() {

    this.approval = 'hide'
  }

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

  Selected(ID) {
    this.candidateID.emit(ID);
  }

  coachAssigned(UID,CID) {
    this.assignCoach.emit({userId:UID,courseId:CID});
  }
  eventChange(ID) {
    this.eventID.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){

    this.approve.emit(id);
    console.log("confirm approve");
  }
  confirmReject(id){
    this.reject.emit(id)
  }

  Intials(cString) {
    if(cString) {
      return cString.replace(/\W*(\w)\w*/g, '$1').toUpperCase()
    }
  }



}








