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

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

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

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

  tempAgeLimits = [];

  constructor(
    public dialogRef: MatDialogRef<NoticeDialogComponent, NoticeDialogResult>,
    @Inject(MAT_DIALOG_DATA) public data: NoticeDialogData
  ) {}

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

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