import { Injectable } from '@angular/core';
import { CanActivate, Router } from '@angular/router';

@Injectable({
  providedIn: 'root'
})
export class RealtimeBroadcastGuard implements CanActivate  {
  constructor(public router: Router) { }

  canActivate(): boolean {
    const menus = JSON.parse(localStorage.getItem('menu'));
    let can = false;
    if (menus) {
      can = menus.some(e => e.link == 'realtimeBroadcast');
    }
    if (!can) {
      this.router.navigate(['login']);
      return false
    }
    return true;
  }
}
