/**
* usePageAnalyses Hook
*
* TanStack Query hook for fetching page analyses for a tenant.
* Provides automatic caching, request deduplication, and background refetching.
*
* @layer Presentation
*/
import { useQuery } from '@tanstack/react-query';
import { queryKeys } from '@/lib/query-keys';
import { infoCenterApi } from '@/infrastructure/http/api/info-center';
import type { PageAnalysis } from '@/domain/entities/PageAnalysis';
import type { ReliabilityStatus } from '@archer/domain';
/**
* usePageAnalyses Hook Options
*/
export interface UsePageAnalysesOptions {
/**
* Tenant ID to fetch analyses for
*/
tenantId?: string;
/**
* Number of items to skip (pagination)
* @default 0
*/
skip?: number;
/**
* Maximum number of items to return
* @default 100
*/
limit?: number;
/**
* Filter by reliability status
*/
reliabilityStatus?: ReliabilityStatus;
/**
* Enable/disable the query
* @default true (when tenantId is provided)
*/
enabled?: boolean;
}
/**
* usePageAnalyses Hook Return Type
*/
export interface UsePageAnalysesReturn {
/**
* Page analyses array
*/
analyses: PageAnalysis[];
/**
* Loading state
*/
isLoading: boolean;
/**
* Error state
*/
error: Error | null;
/**
* Total count of analyses (from pagination metadata)
*/
total: number;
/**
* Whether there are more analyses to load
*/
hasMore: boolean;
/**
* Refetch function
*/
refetch: () => void;
}
/**
* Fetch page analyses for a tenant
*
* Uses TanStack Query for automatic caching, request deduplication,
* and background refetching.
*
* @param options - Query options
* @returns Page analyses with loading/error states
*
* @example
* ```tsx
* function AnalysesList() {
* const { analyses, isLoading, error } = usePageAnalyses({
* tenantId: 'tenant-123',
* limit: 100,
* });
*
* if (isLoading) return