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

import { Component } from '@angular/core';
import { BannerButton, NotificationBannerService, NotificationService, NotificationTypes } from '@bci-web-core/core';

@Component({
  selector: 'bci-notification-banner-demo',
  templateUrl: './notification-banner-demo.component.html',
  styleUrls: ['./notification-banner-demo.component.scss'],
})
export class NotificationBannerDemoComponent {
  description = 'Banner has been displayed.';
  buttonLabel = '';
  link = '';
  showDismissButton = true;
  notificationType: NotificationTypes = NotificationTypes.Success;
  NotificationTypes = NotificationTypes;

  constructor(
    private notificationBannerService: NotificationBannerService,
    private notificationService: NotificationService
  ) {}

  openNotificationBanner(): void {
    const buttons: BannerButton[] = [];
    if (this.buttonLabel) {
      buttons.push({
        text: this.buttonLabel,
        link: this.link,
        clickHandler: () => this.notificationService.success(`you clicked the ${this.buttonLabel} button`),
      });
    }
    this.notificationBannerService.showBanner(this.description, this.notificationType, buttons, this.showDismissButton);
  }
}
