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

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

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

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

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