import { Component, OnInit, ChangeDetectionStrategy, Input, OnChanges } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { tap } from 'rxjs/operators';
import { BaseList } from 'src/app/core/base/base-list';
import { CheckAvailableSeatService } from 'src/app/core/service/testing-register/check-available-seat.service';
import { ChangeDialogComponent } from '../../dialog/change-dialog/change-dialog/change-dialog.component';
import { ReasonDialogComponent } from '../../dialog/reason-dialog/reason-dialog/reason-dialog.component';

@Component({
  selector: 'wait-list',
  templateUrl: './wait-list.component.html',
  styleUrls: ['./wait-list.component.scss'],
  changeDetection: ChangeDetectionStrategy.OnPush
})
export class WaitListComponent extends BaseList implements OnInit,OnChanges {
  @Input() waitList: any = [];
  list = [1,2,3]
  column = ['1','2','3','4','5','6','7','8','9','10']
  constructor(
    private dialog: MatDialog,
    private checkAvalSeatSV: CheckAvailableSeatService
  ) {
    super()
   }

  ngOnInit(): void {
  }

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

  checkAvailable(x){
    console.log(x)
    // this.checkAvalSeatSV.add(x).pipe(
    //   tap(x => console.log(x))
    // ).subscribe()
    const dialogRef = this.dialog.open(ChangeDialogComponent, {
      width: '500px',
      data: x,
    });
  }

  reason(x){
    const dialogRef = this.dialog.open(ReasonDialogComponent, {
      width: '90vh',
      data: x,
    });
  }

}
