import {Component} from "@angular/core";
import {AuthenticationMethodService, Session, UserService} from "@webbpm/base-package";
import {Observable} from "rxjs";
import {AsyncPipe} from "@angular/common";
import {SharedModule} from "shared";

@Component({
    selector: "[log-out]",
    templateUrl: "./log_out.html",
    imports: [SharedModule, AsyncPipe]
})
export class LogOutComponent {

  public currentSession: Observable<Session>;

  constructor(private userService: UserService,
              private authenticationMethodService: AuthenticationMethodService) {
    this.currentSession = userService.getCurrentSession();
  }

  public logout(): void {
    this.userService.logout();
  }

  public getCurrentUserName(): string {
    return this.userService.getCurrentUserName();
  }

  public getFullUserName(): string {
    return this.userService.getFullUserName();
  }

  public isLogoutButtonVisible(): boolean {
    return this.authenticationMethodService.isFormAuth();
  }

  public getOrgUnitName(): string {
    return this.userService.getOrgUnitName();
  }
}
