import {Component, OnInit, ChangeDetectionStrategy, Input, OnChanges} from '@angular/core';
import {PeriodicElement} from '../../../../../manage-test-center/presenter/manage-test-center-table/manage-test-center-table.component';
import {DialogComponent} from '../../../../daily-summary/presenter/dialog/dialog.component';
import {filter, switchMap} from 'rxjs/operators';
import {SelectionModel} from '@angular/cdk/collections';
import {DailyRegisterPaymentService} from '../../../../../../core/service/report/daily-register/daily-register-payment.service';
import {MatDialog} from '@angular/material/dialog';
import {DailyRegisterPaymentTotalService} from '../../../../../../core/service/report/daily-register/daily-register-payment-total.service';
import {PeriodRegisterPaymentService} from '../../../../../../core/service/report/period-register/period-register-payment.service';
import {BaseList} from '../../../../../../core/base/base-list';

@Component({
  selector: 'app-daily-summary-ttb-list',
  templateUrl: './daily-summary-ttb-list.component.html',
  styleUrls: ['./daily-summary-ttb-list.component.scss'],
  changeDetection: ChangeDetectionStrategy.OnPush
})
export class DailySummaryTtbListComponent extends BaseList  implements OnInit , OnChanges {
  column = ['1','2','3','4','5','6']
  @Input() dailySummary:any = [];
  @Input() dailySummaryTable:any = [];
  selection = new SelectionModel<PeriodicElement>(true, []);

  constructor(
    private dailyRegisterPaymentSV: DailyRegisterPaymentService,
    private dialog: MatDialog,
    private dailyRegisterPaymentTotalSV: DailyRegisterPaymentTotalService,
    private periodRegisterPaymentSV: PeriodRegisterPaymentService
  ) {
    super();
  }

  ngOnInit(): void {

  }

  ngOnChanges() {
    console.log(this.dailySummary);
    if (this.dailySummary != null){
      const tableFake = [];
      tableFake.push(this.dailySummary.response.data[0])
      this.dailySummaryTable = this.updateMatTable(tableFake);
    }

  }

  total(){
    // const total = this.dailySummary.data.reduce((prev,cur) => {
    //   return prev + +cur.testing_fee
    // },0)
    // return total
  }

}
