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

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

  @Input() candidate:any;
  @Input() role:any;
  @Input() approval:string;
  @Output() candidateID = new EventEmitter<string>();
  @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() { }

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

  Selected(ID) {
    this.candidateID.emit(ID);
  }
  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)
  }



  coachAssign(ID){

    this.candidateID.emit(ID);
  }

  Intials(cString) {

    ///console.log(cString,'kkkkkkkkkkkkkkkkkkkk');

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

  }

}
