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

export interface AlertSnackbarData {
  html: string;
  buttonText?: string;
}

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

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

  tempAgeLimits = [];

  constructor(
    public dialogRef: MatSnackBarRef<AlertSnackbarComponent>,
    @Inject(MAT_SNACK_BAR_DATA) public data: AlertSnackbarData
  ) {}

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

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