import { Component, OnInit } from '@angular/core';
import { ComponentBase } from '@core/base/common-base';
import { HomeService } from '@core/services/home.service';
import { Observable, takeUntil } from 'rxjs';
import { MEETING, USER_TASKS } from '../../core/models/home.model';

@Component({
  selector: 'app-dashboard',
  templateUrl: './dashboard.component.html',
  styleUrls: ['./dashboard.component.scss'],
})
export class DashboardComponent extends ComponentBase implements OnInit {
  meetingList: MEETING[] = [];
  userTasks: USER_TASKS[] = [];
  constructor(private readonly homeService: HomeService) {
    super();
  }

  ngOnInit(): void {
    this.getMeetings();
    this.getUserTaks();
  }

  getMeetings(): void {
    this.homeService
      .getMeetings()
      .pipe(takeUntil(this.destroy$))
      .subscribe((res) => {
        this.meetingList = res.result;
      });
  }

  getUserTaks(): void {
    this.homeService
      .getUserTasks()
      .pipe(takeUntil(this.destroy$))
      .subscribe((res) => {
        console.log(res);
        this.userTasks = res.result;
      });
  }
}
