import { Component, Inject, OnInit } from '@angular/core';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
import { MatTableDataSource } from '@angular/material/table';
import { ContactData } from 'src/app/interfaces/acquisition-management/provider.interface';
import { ResourcesService } from 'src/app/services/resources/resources.service';

@Component({
  selector: 'app-contact-provider',
  templateUrl: './contact-provider.component.html',
  styleUrls: ['./contact-provider.component.css']
})
export class ContactProviderComponent implements OnInit {
  public displayedColumns: string[] = [
    'NOMBRE_CONTACTO',
    'TIPO_CONTACTO',
    'DIRECCION',
    'CORREO1',
    'TELEFONO1',
    'ACCIONES',
  ];
  public isLoading: boolean;
  public dataSource: MatTableDataSource<ContactData>;

  constructor(
    @Inject(MAT_DIALOG_DATA) public dataContact: Array<ContactData>,
    private _dialogRef: MatDialogRef<any>,
    public resourcesService: ResourcesService,
  ) {
    this.dataSource = new MatTableDataSource(this.dataContact);
    this.isLoading = false;
  }

  ngOnInit(): void {
  }

  public openDialog(element:ContactData) {
    this._dialogRef.close(element);
  }

  public generateDirection(direction: string) {
    return this.resourcesService.resizeText(direction, 37);
  }

}
