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 { RouletteCouponDataSource } from './roulette-coupon.data-source';
import { RouletteCouponService } from 'src/modules/special/roulette-coupon/service/roulette-coupon.service';

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

  dataSource: RouletteCouponDataSource = new RouletteCouponDataSource(
    this.rouletteCouponService
  );

  public inputChange$: Subject<string> = new Subject<string>();
  // 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 {}
}
