import { Component, OnInit } from '@angular/core';
import { NotificationService, NotificationType } from '@xdf/commons';
import { SharedFilterService } from 'projects/bytebot-html/src/app/services/shared-filters.service';
import { OperationalConsultationService } from '../../../../services/operational-consultation.service';
import { PetiFormatter } from '../summary-peti-widget/formatter/formatter';
import { MessageCountFormatter } from '../summary-peti-widget/formatter/message-count.formatter';
import { PetyWidgetModel } from '../summary-peti-widget/summary-peti-widget.component';

@Component({
  selector: 'byte-operative-dashboard',
  templateUrl: './operative-dashboard.component.html',
  styleUrls: ['./operative-dashboard.component.scss']
})
export class OperativeDashboardComponent implements OnInit {

  latestDate = new Date();
  existDateRange = false;
  isLoading = false;
  startDate: Date;
  endDate: Date;
  data: any;
  isDataLoaded = false;
  formatterNumber: PetiFormatter = new MessageCountFormatter();

  panelOptions = {
    elevation: false,
    title: {
      primary: 'dashboards.operative.message.customer.activity',
      secondary: ''
    }
  };

  optionsInactivitySesion = {
    width: 300,
    height: 60,
    fill: '#C8FEFF',
    stroke: '#23c6c8',
    strokeWidth: 1
  };

  totalSesionsOptions = {
    width: 300,
    height: 60,
    fill: '#CFECFF',
    stroke: '#1c84c6',
    strokeWidth: 1
  };

  totalReceivedOptions = {
    width: 300,
    height: 60,
    fill: '#D2EEE9',
    stroke: '#1ab394',
    strokeWidth: 1
  };

  totalSentOptions = {
    width: 300,
    height: 60,
    fill: '#FFD9DD',
    stroke: '#ed5565',
    strokeWidth: 1
  };

  constructor(
    protected operationalConsultationService: OperationalConsultationService,
    protected notificationService: NotificationService) { }

  ngOnInit() {

  }

  filter(filters) {
    this.isDataLoaded = false;
    this.isLoading = true;
    this.startDate = filters['startDateTime'];
    this.endDate = filters['endDateTime'];
    const channel = filters['channel'];
    this.operationalConsultationService.getSummary(this.startDate, this.endDate, channel).subscribe(response => {
      this.data = response;
      this.isLoading = false;
      this.isDataLoaded = true;
    }, err => {
      this.isLoading = false;
    });
  }

}
