import { Component, Input } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';

@Component({
  selector: 'app-modal-add-actual',
  templateUrl: './modal-add-actual.component.html',
  styleUrls: ['./modal-add-actual.component.css']
})
export class ModalAddActualComponent {
  @Input() newAttribute: any = {};
  myForm: FormGroup;

  constructor(public activeModal: NgbActiveModal, private fb: FormBuilder) {
    this.createForm();
  }

  createForm() {
    this.myForm = this.fb.group({
      name: ['', Validators.required],
    });
  }

  addRow() {
    if (this.myForm.valid) {
      this.activeModal.close(this.myForm.value);
    }
  }
}
