import { Component, OnInit, OnDestroy, ChangeDetectionStrategy } from '@angular/core';
import { Subject } from 'rxjs';
import { Router } from '@angular/router';
import { DateAdapter } from '../../components/calendar/providers';
import { TaskCalendarFacade } from 'apps/sales/src/app/store/branch';

@Component({
  selector: 'app-calendar-view',
  templateUrl: 'calendar-view.component.html',
  styleUrls: ['calendar-view.component.scss'],
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class CalendarViewComponent implements OnInit, OnDestroy {
  currentDate = this.dateAdapter.getDate(new Date());

  updateSubject = new Subject();

  constructor(private router: Router, private dateAdapter: DateAdapter, public store: TaskCalendarFacade) {}

  ngOnInit() {
    this.store.getTasks();
  }

  ngOnDestroy() {
    this.updateSubject.complete();
  }

  navigateToTasks() {
    // TODO breadcrumbs to store, current route
    this.router.navigate(['task-calendar', 'tasks']);
  }

  openDetails(itemId: number) {
    // open modal dialog
  }
}
