/*
 * Copyright (C) 2019 Robert Bosch GmbH Copyright (C) 2019 Robert Bosch Manufacturing Solutions GmbH, Germany. All rights reserved.
 */

import { Component } from '@angular/core';
import { MatDialogRef } from '@angular/material/dialog';

@Component({
  selector: 'bci-modal-window-demo-form-modal',
  templateUrl: './modal-window-demo-form-modal.component.html',
  styleUrls: ['./modal-window-demo-form-modal.component.scss'],
})
export class ModalWindowDemoFormModalComponent {
  public address = {
    street: 'DemoStrada',
    postcode: '70469',
    city: 'Stuttgart',
  };

  submitDisabled = false;

  constructor(private _matDialogRef: MatDialogRef<ModalWindowDemoFormModalComponent>) {}

  getSubmitDisabled(): void {
    this.submitDisabled = !this.address.city || !this.address.street || !this.address.postcode;
  }
  save(): void {
    if (this.submitDisabled) return;
    this._matDialogRef.close(this.address);
  }
  close(): void {
    this._matDialogRef.close();
  }
}
