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

import { Component } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { LogoutComponent, SidebarNavItem } from '@bci-web-core/core';
import { CustomOverlayComponent } from './custom-overlay/custom-overlay.component';

@Component({
  selector: 'bci-side-navigation-demo',
  templateUrl: './side-navigation-demo.component.html',
  styleUrls: ['./side-navigation-demo.component.scss'],
})
export class SideNavigationDemoComponent {
  public extendedNavigation = false;

  sidebarLinks: SidebarNavItem[] = [];

  constructor(private router: Router, private route: ActivatedRoute) {
    const profileItem = new SidebarNavItem();
    profileItem.title = 'Maja Mustermann';
    profileItem.overlay = { component: CustomOverlayComponent, config: { userName: 'Maja Mustermann' } };
    profileItem.icon = 'Bosch-Ic-user';
    this.sidebarLinks.push(profileItem);

    const logoutItem = new SidebarNavItem();
    logoutItem.title = 'Logout';
    logoutItem.icon = 'Bosch-Ic-user';
    logoutItem.overlay = {
      component: LogoutComponent,
      config: {
        title: 'Do you want to logout?',
        // eslint-disable-next-line no-empty-function
        onLogout: () => {},
      },
    };
    this.sidebarLinks.push(logoutItem);
  }

  activateExtendedMode() {
    this.router.navigate(['./'], { relativeTo: this.route, queryParams: { extendedNavigation: true } });
  }

  deactivateExtendedMode() {
    this.router.navigate(['./'], { relativeTo: this.route, queryParams: { extendedNavigation: false } });
  }
}
