import { Component, Inject } from '@angular/core';
import { ComponentInformationCheckbox, ComponentInformationInput, ComponentInformationRadio, ComponentInformationSelect, ComponentInformationTextarea, DataFormComponents } from '../../../interfaces/forms-management/form-management.interface';
import { MAT_DIALOG_DATA } from '@angular/material/dialog';

@Component({
  selector: 'app-example-component',
  standalone: false,
  templateUrl: './example-component.component.html',
  styleUrl: './example-component.component.css'
})
export class ExampleComponentComponent {

  public componentInput: ComponentInformationInput;
  public componentSelect: ComponentInformationSelect;
  public componentTextarea: ComponentInformationTextarea;
  public componentCheckbox: ComponentInformationCheckbox;
  public componentRadio: ComponentInformationRadio;

  constructor(
    @Inject(MAT_DIALOG_DATA) public typeComponent: DataFormComponents,
  ) {

    if(typeComponent.TYPE_COMPONENT === 'INPUT') {
      this.componentInput = typeComponent.COMPONENT as ComponentInformationInput;
    } else {
      this.componentInput = {} as ComponentInformationInput;
    }

    if(typeComponent.TYPE_COMPONENT === 'SELECT') {
      this.componentSelect = typeComponent.COMPONENT as ComponentInformationSelect;
    } else {
      this.componentSelect = {} as ComponentInformationSelect;
    }

    if(typeComponent.TYPE_COMPONENT === 'TEXTAREA') {
      this.componentTextarea = typeComponent.COMPONENT as ComponentInformationTextarea;
    } else {
      this.componentTextarea = {} as ComponentInformationTextarea;
    }
    
    if(typeComponent.TYPE_COMPONENT === 'CHECKBOX') {
      this.componentCheckbox = typeComponent.COMPONENT as ComponentInformationCheckbox;
    } else {
      this.componentCheckbox = {} as ComponentInformationCheckbox;
    }
    
    if(typeComponent.TYPE_COMPONENT === 'RADIO') {
      this.componentRadio = typeComponent.COMPONENT as ComponentInformationRadio;
    } else {
      this.componentRadio = {} as ComponentInformationRadio;
    }

  }
}
