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

@Component({
    selector: 'app-check-candidate-testing-list',
    templateUrl: './check-candidate-testing-list.component.html',
    styleUrls: ['./check-candidate-testing-list.component.scss'],
    changeDetection: ChangeDetectionStrategy.OnPush
})
export class CheckCandidateTestingListComponent extends BaseList implements OnInit, OnChanges {

    column = [
        '1',
        'testing_information_code',
        'testing_information_name',
        'total_register',
        'total_have_exam_total_register',
        'seat_create_total_seat',
        'academic_semester_code',
        'academic_year_code',
        'created_by',
        'created_datetime',
        '7'
    ];
    @Output() view = new EventEmitter();
    @Input() testingInformationList: any = [];
    reload: boolean;

    constructor() {
        super();
    }

    ngOnInit(): void {
        this.getEventPage().pipe(
            tap(x => this.onPaginatorPageChange.emit(x)),
            tap(x => {
                this.reload = false;
                setTimeout(() => {
                    this.reload = true;
                }, 2000);
            }),
        ).subscribe()
    }

    ngOnChanges() {
        this.testingInformationList = this.updatePagingMatabe(this.testingInformationList ? this.testingInformationList : []);
    }

    onView(id) {
        this.view.emit(id);
    }

}
