import { Component, OnInit, Input } from '@angular/core';
import { Router } from '@angular/router';
import { environment } from '../../../../../environments/environment.dev';
@Component({
  selector: 'app-employee-assessment-course',
  templateUrl: './employee-assessment-course.component.html',
  styleUrls: ['./employee-assessment-course.component.scss']
})
export class EmployeeAssessmentCourseComponent implements OnInit {
  imagelink: string;
  @Input() Allcourserecords: any;

  constructor(private router: Router) { }

  ngOnInit() {
    this.imagelink = environment.imageUrl+'/assets/img/employee/newdashboard/';
    console.log(this.Allcourserecords);
  }

  getcolor(x, type) {
    const status = x.trim();
    let color = '';
    let img = '';
    switch (status) {
      case 'Overdue':
        color = '#F97787';
        img = 'Overdue';
        return type === 'color' ? color : img;
      // return color;
      case 'Open':
        color = '#68CBFF';
        img = 'To Do';
        return type === 'color' ? color : img;
      case 'In Progress':
        color = '#F8C580';
        img = 'In Progress';
        return type === 'color' ? color : img;
      case 'Under Review':
        color = '#9B9B9B';
        img = 'Under Review';
        return type === 'color' ? color : img;
      case 'Completed':
        color = '#15CC83';
        img = 'Done';
        return type === 'color' ? color : img;
      case 'Done':
        color = '#15CC83';
        img = 'Done';
        return type === 'color' ? color : img;
      default:
        color = '#000000';
        img = 'UR';
        return type === 'color' ? color : img;
    }
  }

  getcurrentstatus(x) {
    if (x === 'In Progress') {
      return 'In Progress';
    }


    if (x === 'Completed') {
      return 'Done';
    }

    if (x === 'Open') {
      return 'To Do';
    }


    if (x === 'Overdue') {
      return 'Overdue';
    }

  }

  gocoursePage(link): void {
    // this.router.navigate([]).then(result => { window.location.href = link; });
    this.router.navigate([]).then(result => { window.open(link, '_blank'); });
  }

  changeTimeformat(data) {
    if (data) {
      const duration = data.split(':')[1] + ' ' + data.split(':')[2];
      return duration;
    }
  }
}
