import { Subscription } from 'rxjs';

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

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

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

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

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

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

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