import { ExternalPageService } from './../../shared/external-page.service';
import { AuthServiceService } from './../../shared/auth-service.service';
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';

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

  constructor(private authSer: AuthServiceService, 
    private externalService: ExternalPageService,
    private router: Router) { }
    
    currentDate: any = Date.now();//ararbic date 
    currentEnglishDate: any = Date.now(); //english date
    headerMenus = []; //header data 

  ngOnInit() {

    this.authSer.arabicTemplate = true;
    this.authSer.showDashboardHeader = false;
    this.authSer.setLocalLang(); //set languages icons
    this.currentDate = this.authSer.writeHijri(new Date(this.currentDate), 'ar', 'header');

    //get header data 
    this.externalService.getHeader().subscribe(
      (responce) => {
        console.log(responce);
        this.headerMenus = responce['parents'];
        console.log('menu data' , this.headerMenus);
      },
      (error) => {
        console.log(error);
      }
    );





  }


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

}
