import { Component, OnInit, Output, EventEmitter } from '@angular/core';
import { Router } from '@angular/router';
import { ApiService } from '@shared/services/api.service';

@Component({
  selector: 'app-dashboard-user-count',
  templateUrl: './dashboard-user-count.component.html',
  styleUrls: ['./dashboard-user-count.component.sass']
})
export class DashboardUserCountComponent {

  public userCounts: any;
  @Output() onApiSuccess: EventEmitter<any> = new EventEmitter;

  constructor(private Router: Router, public _apiCallService: ApiService) {
    this.getUserCount();
  }

  getUserCount() {
    this._apiCallService.getUserCount()
      .subscribe((response: any) => {
        this.userCounts = response.data.gender_count;
      }, (error: any) => {
      })
  }

  navigateToUserCategories() {
    // this.Router.navigate(['/user-categories/users']);
    if (this.Router.url.includes('dashboard')) {
      this.Router.navigate([`dashboard/users`]);
    } else {
      this.Router.navigate([`users`]);
    }
  }

}