import { useQuery } from '@tanstack/react-query';
import { verificationApi } from '../apis';
import { verificationKeys } from '../keys';
import { ADMIN_CASE_STALE_TIME } from '../constants';

/**
 * The full admin case for one nurse — steps + documents + credentials + the identity name for cross-check.
 * Keyed per `nurseVerificationId` and only enabled once one is selected (pass `null` from the queue until a
 * row is opened). Invalidated on every decide / approve / reject so the case reflects the new step states.
 */
export function useVerificationCase(nurseVerificationId: number | null) {
  return useQuery({
    queryKey: verificationKeys.adminCase(nurseVerificationId ?? -1),
    queryFn: () => verificationApi.getVerificationCase(nurseVerificationId as number),
    enabled: nurseVerificationId != null,
    staleTime: ADMIN_CASE_STALE_TIME,
  });
}
