import {Component, OnInit} from '@angular/core';
import { CommonModule, DatePipe, ViewportScroller } from '@angular/common';
import { RouterOutlet, NavigationEnd, Router, RouterLink, RouterLinkActive  } from '@angular/router';
import { RequestComponent } from './request/request.component';
import {GoogleAnalyticsService} from "./_services/googleAnalytics.service";
import {environment} from "../environments/environment";

@Component({
  selector: 'app-root',
  standalone: true,
  imports: [CommonModule, RouterOutlet, RouterLink, RouterLinkActive, DatePipe, RequestComponent],
  templateUrl: './app.component.html',
  styleUrl: './app.component.scss'
})
export class AppComponent implements OnInit{

  title = 'NIR';
  dateNow?: Date;
  navShow = false;

  ngOnInit(){
    this.dateNow = new Date;
    if (environment.production) {
      this.googleAnalyticsService.initialize();
    }
  }

  constructor(
    readonly router: Router,
    readonly viewportScroller: ViewportScroller,
    private readonly googleAnalyticsService: GoogleAnalyticsService
  ) {

    router.events.subscribe((event) => {
        if (event instanceof NavigationEnd) this.viewportScroller.scrollToPosition([0, 0]);
      });

  }
}
