import { Component, OnInit } from '@angular/core';
import { DomSanitizer, SafeUrl } from '@angular/platform-browser';
import { AuthService } from 'src/app/auth/services/auth.service';
import { ShoppingService } from 'src/app/services/shopping.service';

@Component({
  selector: 'app-header-admin',
  templateUrl: './header-admin.component.html',
  styleUrls: ['./header-admin.component.scss']
})
export class HeaderAdminComponent implements OnInit {
  public themeColor = 'inherit';
   /* Header */
   public userName: string;
   public storeName: string;
   public imageLogoBase64: SafeUrl;

  constructor(
    private authService: AuthService,
    private shoppingService: ShoppingService,
    private sanitizer: DomSanitizer
  ) { }

  ngOnInit(): void {
    this.userName  = this.authService.getUserName();
    this.storeName = this.authService.getStoreName();
    const sellerId = this.authService.getSeller();
    const rawImageLogoBase64 = `data:img/png;base64,[encoded data, 7756 characters]`;
    this.imageLogoBase64 = this.sanitizer.bypassSecurityTrustUrl(rawImageLogoBase64);
  }

  logout() {
    this.shoppingService.cancelShopping();
    this.authService.logout();
  }

}
