import { Component, OnInit, Output, EventEmitter, ViewChild, Input, OnChanges, SimpleChanges, SimpleChange} from '@angular/core';
import { FinancingOptionsProperties } from '../../interfaces/financing-options-properties-interface';

@Component({
  selector: 'app-car-summary-header',
  templateUrl: './car-summary-header.component.html',
  styleUrls: ['./car-summary-header.component.scss']
})
export class CarSummaryHeaderComponent implements OnInit {

  @ViewChild('basicModal') modal;
  @ViewChild('mailModal') mailModal;
  @Output() public testDrive: EventEmitter<any> = new EventEmitter();
  @Output() public editInfo: EventEmitter<any> = new EventEmitter();
  @Output() public sendMail: EventEmitter<any> = new EventEmitter();
  @Output() public addToWishlist: EventEmitter<any> = new EventEmitter();
  @Output() public financeOptions: EventEmitter<any> = new EventEmitter();
  @Input() financingOptionsItems: FinancingOptionsProperties[];
  @Input() vehicleData;
  @Input() vehicleLabels;

  public vehicleHeaderData;
  public vehicleLabelsData;


  constructor() { }

  ngOnChanges(changes: SimpleChanges) {
    if (changes.vehicleLabels) {
      this.vehicleLabelsData = changes.vehicleLabels.currentValue;
    }
    if (changes.vehicleData) {
      this.vehicleHeaderData = changes.vehicleData.currentValue;
    }
  }

  ngOnInit() {
  }

  drive() {
    this.testDrive.emit('');
  }

  editInformation() {
    this.editInfo.emit('');
  }

  mailToSelf() {
    this.mailModal.show();
  }

  wishList() {
    this.addToWishlist.emit('');
  }

  financingOptions(e?: any) {
    this.modal.show();
  }

  closeDialog() {
    this.modal.nativeElement.style.display = `none`;
  }

}
