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

@Component({
  selector: 'app-notification-check-exam-list',
  templateUrl: './notification-check-exam-list.container.html',
  styleUrls: ['./notification-check-exam-list.container.scss'],
  changeDetection: ChangeDetectionStrategy.OnPush
})
export class NotificationCheckExamListContainer 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`);
  }

  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(['notification-check-exam/detail', id]);
  }

}
