import { Component, OnInit, ViewEncapsulation } from '@angular/core';
import { ActivatedRoute } from '@angular/router';

import { GameService } from 'app/modules/polyglot/api/services/game.service';
@Component({
  selector: 'main',
  templateUrl: './main.component.html',
  encapsulation: ViewEncapsulation.None,
})
export class GameMainComponent implements OnInit {
  /**
   * Constructor
   */
  constructor(
    private __activatedRoute: ActivatedRoute,
    private __gameService: GameService
  ) {}

  ngOnInit(): void {
    this.__activatedRoute.queryParams.subscribe((params) => {
      // console.log(params); // { orderby: "price" }
      // const vendorKey = params['vendor_key'];
      // const gameKey = params['game_key'];
      // let r = this.__gameService
      //   .getGameUrl(vendorKey, gameKey)
      //   .then((r) => {
      //     console.log('success', r.getUrl());
      //     window.location.href = r.getUrl();
      //   })
      //   .catch((e) => {
      //     console.log('fail', e);
      //   });
    });
  }
  /**
   * Track by function for ngFor loops
   *
   * @param index
   * @param item
   */
  trackByFn(index: number, item: any): any {
    return item.id || index;
  }
}
