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-create-exam-setup-period-by-subject',
  templateUrl: './create-exam-setup-period-by-subject.container.html',
  styleUrls: ['./create-exam-setup-period-by-subject.container.scss'],
  changeDetection: ChangeDetectionStrategy.OnPush
})
export class CreateExamSetupPeriodBySubjectContainer implements OnInit {
  subjectList$ = new Observable();

  constructor(
    private router: Router,
    private TestinforSV: TestingInformationService,
    private cdr: ChangeDetectorRef,
    private swSV: SweetalertService
  ) { }

  ngOnInit(): void {
    this.subjectList$ = this.TestinforSV.getMaintrueANDOpenNull();
  }

  edit(id){
    this.router.navigate(['special-period/view', id]);
  }

  search(query){
    if(query) return this.subjectList$ = this.TestinforSV.search(`?${query}`);
    if(!query) return this.subjectList$ = this.TestinforSV.getMaintrueANDOpenNull();
  }

}
