import {Component, OnInit, ChangeDetectionStrategy, Input, OnChanges} from '@angular/core';
import {BaseList} from '../../../../../core/base/base-list';
import {AppTokenService} from '../../../../../core/service/security/app-token.service';
import {TestingInformationService} from '../../../../../core/service/testing-information/testing-information.service';
import {tap} from 'rxjs/operators';
import {MatDialog} from '@angular/material/dialog';
import {ApproveDialogComponent} from '../../dialog/approve-dialog/approve-dialog.component';

@Component({
  selector: 'app-approve-examination-list',
  templateUrl: './approve-examination-list.component.html',
  styleUrls: ['./approve-examination-list.component.scss'],
  changeDetection: ChangeDetectionStrategy.OnPush
})
export class ApproveExaminationListComponent extends BaseList implements OnInit, OnChanges {
  @Input() subjectList: any = [];
  column = ['1', '2', '3', '4', '5', '6', '7'];
  constructor(
    private testingInformationSV: TestingInformationService,
    public dialog: MatDialog,
  ) {
    super();
  }

  ngOnInit(): void {
  }

  ngOnChanges(){
    this.subjectList = this.updateMatTable(this.subjectList ? this.subjectList : []);
  }

  approveDialog(TestInforuid){
    this.testingInformationSV.get(TestInforuid).pipe(
      tap(x => this.openDialog(TestInforuid, x)),
    ).subscribe();
  }

  openDialog(TestInforuid, data){
    const dialog = this.dialog.open(ApproveDialogComponent, {
      width: '50%',
      data: {
        TestInforuid,
        data : data,
      }
    });
  }

}
