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

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

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

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

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

}
