import {
  Component,
  OnInit,
  OnDestroy,
  ViewEncapsulation,
  AfterViewInit,
  ViewChild,
  ElementRef
} from '@angular/core';
import { FormGroup, FormBuilder, FormArray } from '@angular/forms';
import { fuseAnimations } from 'src/@fuse/animations';
import { Subject } from 'rxjs';
import { FixBonusDataSource } from './fix-bonus.data-source';
import { FixBonusService } from 'src/modules/special/fix-bonus/service/fix-bonus.service';

@Component({
  selector: 'app-fix-bonus',
  templateUrl: './fix-bonus.component.html',
  styleUrls: ['./fix-bonus.component.scss'],
  encapsulation: ViewEncapsulation.None,
  animations: fuseAnimations
})
export class FixBonusComponent implements OnInit, OnDestroy, AfterViewInit {
  displayedColumns = [
    'gameType',
    'gameDescription',
    'userDescription',
    'odds',
    'folder',
    'allow'
  ];
  constructor(
    private fb: FormBuilder,
    private fixBonusService: FixBonusService
  ) {
    this._unsubscribeAll = new Subject();
  }

  dataSource: FixBonusDataSource = new FixBonusDataSource(this.fixBonusService);

  public inputChange$: Subject<string> = new Subject<string>();
  public ClickedRowIndex: number = -1;
  // public ClickedRow: cObject; currentRow: cObject;

  public mtformgroup: FormGroup;
  public mtformarray: FormArray;

  @ViewChild('filter', { static: true })
  filter: ElementRef;

  // Private
  private _unsubscribeAll: Subject<any>;

  ngOnInit() {
    this.mtformarray = this.fb.array([]);
    this.mtformgroup = this.fb.group({ formarray: this.mtformarray });
    this.dataSource.formg = this.mtformgroup;
  }

  /**
   * On destroy
   */
  ngOnDestroy(): void {
    // Unsubscribe from all subscriptions
    this._unsubscribeAll.next();
    this._unsubscribeAll.complete();
  }

  ngAfterViewInit(): void {}

  fixBonusfoUpdate(): void {}
}
