import {
  Component,
  OnInit,
  Inject,
  ViewChild,
  ElementRef
} from '@angular/core';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';

export interface AlertDialogData {
  title: string;
  message?: string;
  html?: string;
}

// tslint:disable-next-line: no-empty-interface
export interface AlertDialogResult {}

@Component({
  selector: 'ucap-ui-alert-dialog',
  templateUrl: './alert.dialog.component.html',
  styleUrls: ['./alert.dialog.component.scss']
})
export class AlertDialogComponent implements OnInit {
  @ViewChild('messageContainer', { static: true })
  messageContainer: ElementRef;

  tempAgeLimits = [];

  constructor(
    public dialogRef: MatDialogRef<AlertDialogComponent, AlertDialogResult>,
    @Inject(MAT_DIALOG_DATA) public data: AlertDialogData
  ) {}

  ngOnInit(): void {
    if (!!this.data.html) {
      this.messageContainer.nativeElement.innerHTML = this.data.html;
    }
  }

  onClickConfirm(): void {
    this.dialogRef.close({});
  }
}
