import { Component, Inject, OnInit } from '@angular/core';
import { SliderData } from '../../../../../interfaces/slider.interface';
import { FormControl, FormGroup, Validators } from '@angular/forms';
import { MAT_DIALOG_DATA } from '@angular/material/dialog';
import { GetIssueTracking } from '../../../../../interfaces/acquisition-management/issue-tracking.interface';

@Component({
    selector: 'app-details-issue-tracking',
    templateUrl: './details-issue-tracking.component.html',
    styleUrl: './details-issue-tracking.component.css',
    standalone: false
})
export class DetailsIssueTrackingComponent implements OnInit {
  public arrImages: Array<SliderData>;
  public formGroup: FormGroup;
  
  constructor(@Inject(MAT_DIALOG_DATA) public objIssueTracking: GetIssueTracking) {
    this.formGroup = this.createFormGroup();
    this.arrImages = [];
  }

  ngOnInit(): void {
    this.objIssueTracking.EVIDENCIA.map((evidence:string) => {
      this.arrImages.push({
        image: evidence,
        width: '521px',
        height: '300px'
      });
    });
  }

  private createFormGroup() {
    return new FormGroup({
      TIPO: new FormControl(this.objIssueTracking.TIPO_PROBLEMA, Validators.required),
      DESCRIPCION: new FormControl(this.objIssueTracking.DESCRIPCION, Validators.required),
      RESULUCION: new FormControl(this.objIssueTracking.RESOLUCION, Validators.required),
    });
  }
}
