import {Component, OnInit, ChangeDetectionStrategy, ChangeDetectorRef} from '@angular/core';
import {Observable} from "rxjs";
import {TestingInformationService} from "../../../../../core/service/testing-information/testing-information.service";
import {Router} from "@angular/router";

@Component({
  selector: 'app-seat-change-test-information',
  templateUrl: './seat-change-test-information.container.html',
  styleUrls: ['./seat-change-test-information.container.scss'],
  changeDetection: ChangeDetectionStrategy.OnPush
})
export class SeatChangeTestInformationContainer implements OnInit {
  subjectList$ = new Observable();
  constructor(
    private testinforSV: TestingInformationService,
    private cdr: ChangeDetectorRef,
    private router: Router,
  ) { }

  ngOnInit(): void {
    this.subjectList$ = this.testinforSV.search(`?is_open=true`);
  }

  search(query){
    if(query) return this.subjectList$ = this.testinforSV.search(`?${query}`);
    if(!query) return this.subjectList$ = this.testinforSV.search(`?is_open=true`);
  }

  view(id){
    this.router.navigate(['seat-change/view', id]);
  }

}
