import { inject } from '@angular/core';
import { CanActivateFn } from '@angular/router';
import { AdminAuthService } from './admin-auth.service';

/** Guards `/admin/**` routes. Never shares state with the customer auth guard/service. */
export const adminAuthGuard: CanActivateFn = () => {
  const adminAuth = inject(AdminAuthService);

  if (adminAuth.isAuthenticated()) {
    return true;
  }

  adminAuth.requestLogin();
  return false;
};
