import {Component, OnInit, ChangeDetectionStrategy, Input, OnChanges, ChangeDetectorRef, Output, EventEmitter} from '@angular/core';
import {BaseList} from '../../../../../core/base/base-list';
import {map, switchMap, tap} from 'rxjs/operators';
import {formatDate} from '@angular/common';
import {DialogComponent} from '../../dialog/dialog.component';
import {ActivatedRoute} from '@angular/router';
import {TestingControlsService} from '../../../../../core/service/testing-information/testing-controls.service';
import {MatDialog} from '@angular/material/dialog';
import {SweetalertService} from '../../../../../core/service/sweetalert/sweetalert';
import {TestingInformationService} from '../../../../../core/service/testing-information/testing-information.service';

@Component({
  selector: 'app-room-view-list',
  templateUrl: './room-view-list.component.html',
  styleUrls: ['./room-view-list.component.scss'],
  changeDetection: ChangeDetectionStrategy.OnPush
})
export class RoomViewListComponent extends BaseList implements OnInit, OnChanges{
  testingControlList: any = [];
  @Input() testingInformationList: any = [];
  @Input() testingInfoData:any;
  @Input() query:any;
  @Output() changeroom = new EventEmitter();

  reload: boolean;
  constructor(
    public activeRoute: ActivatedRoute,
    private testingControlSV: TestingControlsService,
    private cdr: ChangeDetectorRef,
    private dialog: MatDialog,
    private swSV: SweetalertService,
    private testingInfoSV: TestingInformationService
  ){
    super();
  }

  ngOnInit(): void {
    this.getEventPage().pipe(
      tap(x => this.onPaginatorPageChange.emit(x))
    ).subscribe();
  }

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

  changeRoom(data){
    this.changeroom.emit({data, TestInformation: this.testingInfoData});

  }

}
