import {Component, OnInit, ChangeDetectionStrategy, Input, Output, EventEmitter, OnChanges} from '@angular/core';
import {BaseList} from '../../../../../../core/base/base-list';

@Component({
  selector: 'app-reject-exam-list',
  templateUrl: './reject-exam-list.component.html',
  styleUrls: ['./reject-exam-list.component.scss'],
  changeDetection: ChangeDetectionStrategy.OnPush
})
export class RejectExamListComponent  extends BaseList implements OnInit, OnChanges {
  @Input() subjectList: any = [];
  @Output() edit = new EventEmitter();
  @Output() view = new EventEmitter();
  @Output() expand = new EventEmitter();
  @Output() delete = new EventEmitter();
  @Output() close = new EventEmitter();
  column = ['1',
    'testing_information_code',
    'testing_information_name',
    'academic_semester_code',
    'academic_year_code',
    '10',
    'count_subject',
    'is_open',
    '7',
    '8',
    '9'
  ];
  reload: boolean;
  constructor(
  ) {
    super();
  }

  ngOnInit(): void {
    this.reload = false;
    setTimeout(() => {
      this.reload = true;
    }, 2000);
  }

  ngOnChanges(){
    // console.log(this.subjectList);
    this.subjectList = this.updateMatTable(this.subjectList ? this.subjectList : []);
    this.subjectList.data = this.subjectList.data
      .filter((x) => {
        return x.is_open != null;
    }).map((x) => {
        if (x.is_open === false){
          return x;
        }else {
          x.updated_by = ''
          x.updated_datetime = ''
          return x;
        }
    });
  }

  onEdit(id){
    this.edit.emit(id);
  }

  onClose(id){
    this.close.emit(id);
  }

}
