import { Component, OnInit } from "@angular/core";
import { AuthService } from "../../../services/auth2.service";
import { Router } from "@angular/router";
import Swal from "sweetalert2";

declare const $: any;
declare interface RouteInfo {
  path: string;
  title: string;
  icon: string;
  class: string;
  allowed_roles?: any;
}
export const ROUTES: RouteInfo[] = [
  {
    path: "/dashboard",
    title: "Dashboard",
    icon: "dashboard",
    class: ""
  },
  {
    path: "/investment-proposals",
    title: "Propuestas de inversión",
    icon: "wb_incandescent",
    class: ""
    //allowed_roles: [2, 3]
  }
  /*
  {
    path: "/investments",
    title: "Inversiones",
    icon: "work",
    class: ""
    //allowed_roles: [2, 3]
  },
  {
    path: "/arbitrations",
    title: "Arbitrajes",
    icon: "flag",
    class: ""
    //allowed_roles: [2, 3]
  },
  {
    path: "/performances",
    title: "Rendimientos",
    icon: "playlist_add",
    class: ""
    //allowed_roles: [2, 3]
  },
  {
    path: "/users",
    title: "Usuarios",
    icon: "people",
    class: ""
    //allowed_roles: [2, 3]
  }*/
];

@Component({
  selector: "app-sidebar",
  templateUrl: "./sidebar.component.html",
  styleUrls: ["./sidebar.component.scss"]
})
export class SidebarComponent implements OnInit {
  menuItems: any[];
  adminMenuItems: any[];
  adminMenu: boolean = false;
  role_number: any;

  constructor(private auth: AuthService, private router: Router) {}

  ngOnInit() {
    this.menuItems = ROUTES.filter(menuItem => menuItem);
  }

  isMobileMenu() {
    if ($(window).width() > 991) {
      return false;
    }
    return true;
  }

  logout() {
    Swal.fire({});
    Swal.showLoading();

    this.auth.logout();

    //this.router.navigateByUrl("login");
  }
}
