import { Component, OnInit, OnChanges, Input, Output, EventEmitter } from '@angular/core';
import { Course, UserCourseMappingExtended, CourseCardType, CourseStatus } from 'app/models/capability-transformation/course-list.model';
import { CapabilityTransformationHttpService } from 'app/services/capability-transformation/capability-transformation-http.service';

@Component({
  selector: 'app-employee-dashboard-home-ctcontent',
  templateUrl: './employee-dashboard-home-ctcontent.component.html',
  styleUrls: ['./employee-dashboard-home-ctcontent.component.scss']
})
export class EmployeeDashboardHomeCTContentComponent implements OnInit, OnChanges {
  // This workaround was set to fix the warning/Input bug from angular-cli
  // @Input() coursesLists: UserCourseMappingExtended;
  @Input() coursesLists? = <UserCourseMappingExtended>null;
  @Input() role?: any;
  @Output() updateCourseEvent = new EventEmitter<{ course: Course, type: CourseCardType, courseStatus: string, assessmentPage: any }>();
  @Output() assessmentEvent = new EventEmitter<string>();

  courseListNames: string[] = [];

  constructor() {}

  ngOnInit() {
    this.courseListNames = Object.keys(this.coursesLists);
  }
  ngOnChanges() {
    this.ngOnInit();
  }

  updateCourse(assessmentPage: any, course: Course, type: CourseCardType, courseStatus: CourseStatus) {
    this.updateCourseEvent.emit({ course: course, type: type, courseStatus: courseStatus, assessmentPage: assessmentPage });
  }

  gotoAssessmentEvent(evnt){
    this.assessmentEvent.emit(evnt)
  }
}
