import { Component, OnInit, ViewChild } from '@angular/core';
import { FormControl, FormGroup, Validators } from '@angular/forms';


@Component({
  selector: 'app-loan-add-new',
  templateUrl: './loan-add-new.component.html',
  styleUrls: ['./loan-add-new.component.scss']
})
export class LoanAddNewComponent implements OnInit {
  //popup
  public dialogOpened = false;
  public windowOpened = false;

  //test
  public somedata : string = "opened";


  //form access

  //@ViewChild('birthDate', {static: true}) birthDate: LoanEditComponent;

  constructor() { }

  ngOnInit(): void {
  }

  public close(component) {
    this.somedata = "" + Math.random();
    this[component + 'Opened'] = false;
  }

  public open(component) {
    //this.somedata = "" + Math.random();
    this[component + 'Opened'] = true;
  }

  public action(status) {
    console.log(`Dialog result: ${status}`);
    this.dialogOpened = false;
  }



  public min: Date = new Date(2015, 0, 1);
  public max: Date = new Date(2030, 4, 31);

  public registerForm: FormGroup = new FormGroup({
    transID: new FormControl(),
    submissionDate: new FormControl(new Date(2020, 0, 10)),
    clientNames : new FormControl([1]),
    brokers : new FormControl([2]),
    referals : new FormControl([3]),
    status: new FormControl(),
    lender: new FormControl(),
    limit: new FormControl(),
    settlementDate: new FormControl(new Date(2020, 0, 9)),
  });

  public submitForm(): void {
    this.registerForm.markAllAsTouched();
    //this.action('yes');
  }

  public clearForm(): void {
    this.registerForm.reset();
    //this.action('no');
  }

  public listClientNames: Array<{ text: string, value: number }> = [
    { text: 'John', value: 1 },
    { text: 'Steven', value: 2 },
    { text: 'William', value: 3 }
  ];

  public statis: { text: string, value: number } = { text: 'Female', value: 2 };


}
