import { Component, OnInit } from '@angular/core';

import { InstructorService } from '../../../services/instructor.service';

import { InstructorData } from '../../../structures/instructor-data';

import * as Globals from '../../../globals';

@Component({
  selector: 'app-all-instructors-page',
  templateUrl: './all-instructors-page.component.html',
  styleUrls: ['./all-instructors-page.component.scss']
})
export class AllInstructorsPageComponent implements OnInit {

  title = Globals.pages.instructors.text;

  allInstructors: InstructorData[] | null = null;

  constructor(private instructorService: InstructorService) { 
    this.instructorService.allInstructors$.subscribe((data: InstructorData[] | null) => {
      if(data != null) {
        this.allInstructors = data.filter(instructor => {
          return instructor.role != 'cekatel' && instructor.role != 'blokovany';
        });
      } else {
        []
      }
    })
    this.instructorService.actualizeAllInstructors();    
  }

  ngOnInit(): void {
  }

}
