import { Component, OnInit, Input } from '@angular/core';
import { Router } from '@angular/router';
import { Utils } from 'app/utils';
import { TaModalServiceService, MODAL_CONTENT } from 'app/ta/ta-modal-service.service';
import { environment } from '../../../../environments/environment.dev';

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

  // TOOD: use the right model
  @Input() userData: any;

  // review what this does and calculate it here istead of passing from ta-profles
  @Input() showCandidateDetails: boolean;

  @Input() profilePic: string;

  get showApproveReject() {
    return this.userData.userInfoMstr.status == "ONBOARDED";
  }

  Initials(fullname) {
    return Utils.Initials(fullname);
  }
  imageUrl = environment.imageUrl;
  constructor(
    private modalService: TaModalServiceService,
    private router: Router,
  ) { }

  ngOnInit() {
    this.modalService.selectCandidate(this.userData.userInfoMstr.userInfoMstrId);
  }

  showRejectModal() {
    this.modalService.showModal(MODAL_CONTENT.REJECT);
  }

  showAproveModal() {
    this.modalService.showModal(MODAL_CONTENT.SELECT);
  }

  goToEdit() {
    this.router.navigate(['/ta', 'taEditProfile'], {
      queryParams: {
        uuid: this.userData.userInfoMstr.userInfoMstrId
      }
    });
  }
}
