import {Component, Input, OnInit} from '@angular/core';
import {Router} from "@angular/router";
import {Header, Item} from "../../../utils/entities/sidebar";

@Component({
  selector: 'dashboard-sidebar',
  templateUrl: 'sideBar.component.html'
})
export class SideBarComponent implements OnInit {
  @Input() items: Item[] = [];
  // TODO remove it
  @Input() name = null;
  @Input() header: Header = null;
  @Input() showHeader: boolean = true;

  constructor(private router: Router) {
  }

  ngOnInit(): void {
  }

  private getCurrentRoute(): string {
    return this.router.url.split('?')[0];
  }

  isTheActiveMenu(route: string): boolean {
    return this.getCurrentRoute().indexOf(route) !== -1;
  }
}
