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

@Injectable({
  providedIn: 'root'
})
export class NurseGuard 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 == 'nurse');
    }
    if (!can) {
      this.router.navigate(['login']);
      return false
    }
    return true;
  }

}
