import { Component, OnInit } from '@angular/core';
import { MatTableDataSource } from '@angular/material/table';

@Component({
  selector: 'app-work-team',
  templateUrl: './work-team.component.html',
  styleUrls: ['./work-team.component.css']
})
export class WorkTeamComponent implements OnInit {

  public isLoading: boolean;
  public isLoadingForm: boolean;

  public btnSmall: boolean;
  public txtBuscador: string;
  public dataSource: MatTableDataSource<any>;

  constructor() { 
    this.btnSmall = false;
    this.txtBuscador = '';
    this.dataSource = new MatTableDataSource<any>();
    this.isLoading = false;
    this.isLoadingForm = false;
  }

  ngOnInit(): void {
  }

  public openDialog(typeForm: string, element?:any){

  }

      // Método de filtrado de datos
      public applyFilter(event: any, type: string):void {
        let filterValue:string;
        if (type == 'INP') {
          filterValue = (event.target as HTMLInputElement).value;
        }else{
          this.txtBuscador = event;
          filterValue = event;
        }
        this.dataSource.filter = filterValue.trim().toLowerCase();
        if (this.dataSource.paginator) {
          this.dataSource.paginator.firstPage();
        }
      }
  
    // Método para reajustar los botones según sus dimensiones
    public onResize(): void {
      this.btnSmall = window.innerWidth <= 1405;
    }
    
}
