import { Component, OnInit } from '@angular/core';
import { CurrentWorkService } from '../current-work/current-work.service';
import { Work } from 'src/app/services/work/work';
import { Chapter } from 'src/app/services/chapter/chapter';
import { WorkReview } from 'src/app/services/review/work-review';
import { ReviewModalComponent } from '../../review-modal/review-modal.component';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';

@Component({
  selector: 'app-work-dashboard',
  templateUrl: './work-dashboard.component.html',
  styleUrls: ['./work-dashboard.component.css']
})
export class WorkDashboardComponent implements OnInit {
  work: Work;
  workChapters: Chapter[];
  workReviews: WorkReview[];

  openReview(review: WorkReview) {
    const activeModal = this.modalService.open(ReviewModalComponent, { size: 'lg', scrollable: true, centered: true });
    activeModal.componentInstance.review = review;
  }

  constructor(
    private currentWork: CurrentWorkService,
    private modalService: NgbModal,
  ) 


  ngOnInit() {
      this.currentWork.work
        .subscribe(work => this.work = work);
      this.currentWork.chapters
        .subscribe(chapters => this.workChapters = chapters);
      this.currentWork.reviews
        .subscribe(reviews => this.workReviews = reviews);
  }
}

{ }