import { Component, OnInit, ViewChild } from '@angular/core';
import { MatSidenav } from '@angular/material/sidenav';
import { USERInterface } from 'src/app/interfaces/user-interface';
import { ENCService } from 'src/app/services/enc/enc.service';
import { IAMService } from 'src/app/services/iam/iam.service';

@Component({
  selector: 'app-toolbar',
  templateUrl: './toolbar.component.html',
  styleUrls: ['./toolbar.component.css']
})
export class ToolbarComponent implements OnInit {


  usuario_session:USERInterface = JSON.parse(localStorage.getItem('TIMUSERENC')!);
  isLoggedIn:Boolean = false;
  razonSocial: string = "";
  empresa:string = "";

  sidenav!: MatSidenav;

  constructor(
    private _IAMService:IAMService,
    private _encService: ENCService,
  ) { 
    this.isLoggedIn = (localStorage.getItem('jwt') !== "");
    this.empresa = this._encService.desencriptar( this.usuario_session.RFCEMPRESA);
    this.razonSocial = this._encService.desencriptar(this.usuario_session.RAZONSOCIAL);
  }

  ngOnInit(): void {
  }

  logout() {
    this.isLoggedIn = false;
    this._IAMService.logout();
  }


}
