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

import { CourseService } from '../../../services/course.service';
import { InstructorService } from '../../../services/instructor.service';
import { SchoolService } from '../../../services/school.service';

import { InstructorData } from '../../../structures/instructor-data';
import { CourseData } from '../../../structures/course-data';
import { SchoolData } from '../../../structures/school-data';

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

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

  title: string = Globals.pages.accommondations.text;

  allCourses: CourseData[] | null = null;
  allInstructors: InstructorData[] | null = null;
  allSchools: SchoolData[] | null = null;

  constructor(private courseService: CourseService, private instructorService: InstructorService, private schoolService: SchoolService) { 
    this.courseService.courses$.subscribe((courses: CourseData[] | null) => {
      this.allCourses = courses;
    })
    this.courseService.actualizeActualYearCourses();

    this.instructorService.allInstructors$.subscribe((data: InstructorData[] | null) => {
      this.allInstructors = data;
    })
    this.instructorService.actualizeAllInstructors(); 

    this.schoolService.allSchools$.subscribe((data: SchoolData[] | null) => {
      this.allSchools = data;
    })
    this.schoolService.actualizeAllSchools();
  }

  ngOnInit(): void {
  }

}
