import { Component, OnInit } from "@angular/core";
import { CommonService } from "src/app/hmg-common/services/common/common.service";
import { TranslatorService } from "src/app/hmg-common/services/translator/translator.service";
import { AuthenticationService } from "src/app/hmg-common/services/authentication/authentication.service";
import { AuthenticatedUser } from "src/app/hmg-common/services/authentication/models/authenticated-user";
@Component({
  selector: "app-home",
  templateUrl: "./home.component.html",
  styleUrls: ["./home.component.scss"]
})
export class HomeComponent implements OnInit {
  personalInfo: any;
  imageSrc: string = "../assets/imgs/profile.png";
  constructor(
    public ts: TranslatorService,
    public cs: CommonService,
    public authService: AuthenticationService
  ) {}

  ngOnInit() {
    this.getProfile();
  }
  getProfile() {
    this.authService
      .loadAuthenticatedUser()
      .subscribe((user: AuthenticatedUser) => {
        if (user) {
          this.personalInfo = user;
          this.imageSrc = user.EMPLOYEE_IMAGE
            ? "data:image/png;base64," + user.EMPLOYEE_IMAGE
            : this.imageSrc;
          console.log(user);
        } else {
          console.log(user);
        }
      });
  }
}
