import { Component, ElementRef, ViewChild } from '@angular/core';
import { Router, RouterModule, RouterOutlet } from '@angular/router';
import { Authentication } from './services/Authentication';
import { CommonModule } from '@angular/common';

@Component({
  selector: 'app-root',
  imports: [RouterOutlet, CommonModule, RouterModule],
  templateUrl: './app.html',
  styleUrl: './app.css'
})
export class App {

  @ViewChild('homeLink') homeLink!: ElementRef<HTMLAnchorElement>;
  @ViewChild('jobsLink') jobLink!: ElementRef<HTMLAnchorElement>;
  @ViewChild('resumesLink') resumeLink!: ElementRef<HTMLAnchorElement>;

  constructor(public auth: Authentication, private router: Router){}

  ngAfterViewInit(){
    let ViewLinks = [ this.homeLink, this.resumeLink, this.jobLink ];
    ViewLinks.forEach(link => {
      if (new URL(link.nativeElement.href).pathname === new URL(window.location.href).pathname){
        link.nativeElement.classList.add("active");
      }
    });
  }

}
