import { Component, EventEmitter, inject, Input, OnInit, Output } from '@angular/core';
import { ACCOUNT_PAGE, Globals, IAppPage, LOGIN_PAGE } from '../../../services/globals';
import { APPICON4NAVBAR_TOKEN, APPICON4TEST_TOKEN } from '../../../injection-tokens';
import { AuthorizeService } from '../../../services/authorize.service';
import { HenselTranslateService } from '../../../services/localization/hensel-translate.service';
import { ServerInfoService } from '../../../services/serverinfo.service';

@Component({
  selector: 'app-header',
  templateUrl: './header.component.html',
  styleUrls: ['./header.component.scss']
})

export class HeaderComponent implements OnInit {
  @Input() public title: string;
  @Output() public sidenavToggle = new EventEmitter();

  public pageLogin: IAppPage = LOGIN_PAGE;
  public pageAccount: IAppPage = ACCOUNT_PAGE;
  private cnst_AppIcon4Navbar = inject(APPICON4NAVBAR_TOKEN);
  private cnst_AppIcon4Test = inject(APPICON4TEST_TOKEN);
  public get navBarIconPath(): string {
    return this.serverInfoService.isLive() ? this.cnst_AppIcon4Navbar : this.cnst_AppIcon4Test;
  }

  constructor(
    public globals: Globals,
    public authService: AuthorizeService,
    public serverInfoService: ServerInfoService,
    public translate: HenselTranslateService,
  ) { }

  ngOnInit() {
  }

  public onToggleSidenav = () => {
    this.sidenavToggle.emit();
  }

  refreshPage() {
    window.location.reload();
  }

}
