import { Injectable } from '@angular/core';
import { MatSnackBar } from '@angular/material/snack-bar';

@Injectable({
  providedIn: 'root'
})
export class NotifierService {

  constructor(private snackBar: MatSnackBar) { }

  // Method to display a notification message with a button
  showNotification(displayMessage: string, button: string) {
    // Opens a snack bar with the provided message and button text
    this.snackBar.open(displayMessage, button, {
      // Duration for which the notification is displayed (in milliseconds)
      duration: 7000,
      // Horizontal position of the notification on the screen
      horizontalPosition: 'center',
    });
  }

  // Method to display a notification message without a button
  showInformation(displayMessage: string) {
    this.snackBar.open(displayMessage, undefined, {
      duration: 7000,
      horizontalPosition: 'center',

    });
  }
  //Close Snackbar
  dismissNotification() {
    if (this.snackBar) {
      this.snackBar.dismiss();
    }
  }
}
