import { Subscription } from 'rxjs';

import { Component, OnInit, OnDestroy } from '@angular/core';
import { ActivatedRoute, Router, Params } from '@angular/router';

import { LogService } from '@ucap/ng-logger';

import { QueryParams } from '../types/params.type';

@Component({
  selector: 'app-pages-group-sidenav',
  templateUrl: './sidenav.page.component.html',
  styleUrls: ['./sidenav.page.component.scss']
})
export class SidenavPageComponent implements OnInit, OnDestroy {
  private queryParamsSubscription: Subscription;

  constructor(
    private activatedRoute: ActivatedRoute,
    private router: Router,
    private logService: LogService
  ) {}

  ngOnInit(): void {
    this.queryParamsSubscription = this.activatedRoute.queryParams.subscribe(
      (params: Params) => {
        console.log('SidenavPageComponent', params[QueryParams.ID]);
      }
    );
  }

  ngOnDestroy(): void {
    if (!!this.queryParamsSubscription) {
      this.queryParamsSubscription.unsubscribe();
    }
  }
}
