import { Router } from '@angular/router';
import { InternalPageService } from './../../shared/internal-page.service';
import { UserService } from './../../shared/user.service';
import { AuthServiceService } from './../../shared/auth-service.service';
import { Component, OnInit } from '@angular/core';

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

  constructor(private authSer: AuthServiceService, 
    private userservice: UserService, 
    private internalService: InternalPageService, 
    private router: Router) { }
  


  ngOnInit() {


    this.authSer.arabicTemplate = true;
    this.authSer.arabicLanguage = true;
    this.authSer.englishLanguage = false;
    
    
    //this.spinner.show();
    this.authSer.showDashboardHeader = false;
    //console.log(this.checkTokenExpire);
      //get profile data
    this.userservice.getUserDataProfile();
    this.authSer.currentDate = this.authSer.writeHijri(new Date(this.authSer.currentDate), 'ar');
  }

  onLogin() {
    this.router.navigate(['/login']);
  }

  onGetProfile() {
    console.log('profile/'  + this.authSer.dataLoginUser['id']);
    this.router.navigate(['profile/'  + this.authSer.dataLoginUser['id']]);
  }

  //log out function
  onLogout() { 
    localStorage.clear();
    this.router.navigate(['login']);
  }

  onDashBoard() {
    this.router.navigate(['dashboard/' + this.authSer.dataLoginUser['id']]);
  }

  goToHome() {
    this.router.navigate(['InternalPage/home']);
  }


  

}
