import { inject } from '@angular/core';
import { CanActivateFn, Router } from '@angular/router';
import { AuthService } from '../../services/auth/auth.service';

export const superAdminGuard: CanActivateFn = () => {
  const auth = inject(AuthService);
  const router = inject(Router);
  return (auth.currentUser?.roles ?? []).includes('super_admin')
    ? true
    : router.createUrlTree(['/dashboards/crm']);
};
