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

import { Component, Input, OnChanges, SimpleChanges } from '@angular/core';
import { BreadcrumbsService } from '../../breadcrumbs.service';
import { SidebarNavItem } from '../bci-sidebar/sidebar-nav-item.model';

@Component({
  selector: 'bci-app',
  templateUrl: './bci-app.component.html',
  styleUrls: ['./bci-app.component.scss'],
})
export class BciAppComponent implements OnChanges {
  @Input() applicationTitle = '';
  @Input() applicationTitleLineTwo: string;
  @Input() sidebarLinks: SidebarNavItem[] = [];
  @Input() sidebarFooterLinks: SidebarNavItem[] = [];
  @Input() showSidebarFooterTime = false;

  public navigationItems = [];

  constructor(private breadcrumbsService: BreadcrumbsService) {}

  ngOnChanges(changes: SimpleChanges): void {
    if (changes.sidebarLinks || changes.sidebarFooterLinks) {
      this.navigationItems = [...this.sidebarLinks, ...this.sidebarFooterLinks];
      this.breadcrumbsService.setNavigationItems(this.navigationItems);
    }
  }
}
