import { Component, Inject } from '@angular/core';
import { FormControl, Validators } from '@angular/forms';
import { MAT_DIALOG_DATA } from '@angular/material/dialog';
import { AlertData } from '../../../../interfaces/alert.interface';

@Component({
    selector: 'app-alert',
    templateUrl: './alert.component.html',
    styleUrl: './alert.component.css',
    standalone: false
})
export class AlertComponent {
  public commentsControl: FormControl;
  public btnCancelar: string;
  public btnAceptar: string;
  
  constructor(@Inject(MAT_DIALOG_DATA) public data: AlertData) {
    this.commentsControl = new FormControl('');
    if(this.data.showComments != undefined){
      this.commentsControl.addValidators([Validators.required, Validators.minLength(15)]);
    }

    if (this.data.btnCancelar === undefined) {
      this.btnCancelar = 'Cancelar';
    } else {
      this.btnCancelar = this.data.btnCancelar;
    }

    if (this.data.btnAceptar === undefined) {
      this.btnAceptar = 'Aceptar';
    } else {
      this.btnAceptar = this.data.btnAceptar;
    }
  }
}
