import { queryOptions } from '@tanstack/react-query';
import { getDocumentLibraries, getDocumentLibraryById } from './service';
import type { DocumentLibraryFilters } from './types';

export const documentLibraryKeys = {
  all: ['crm-document-library'] as const,
  lists: () => [...documentLibraryKeys.all, 'list'] as const,
  list: (filters: DocumentLibraryFilters) => [...documentLibraryKeys.lists(), filters] as const,
  details: () => [...documentLibraryKeys.all, 'detail'] as const,
  detail: (id: string) => [...documentLibraryKeys.details(), id] as const
};

export const documentLibrariesQueryOptions = (
  filters: DocumentLibraryFilters = {}
) =>
  queryOptions({
    queryKey: documentLibraryKeys.list(filters),
    queryFn: () => getDocumentLibraries(filters)
  });

export const documentLibraryByIdOptions = (id: string) =>
  queryOptions({
    queryKey: documentLibraryKeys.detail(id),
    queryFn: () => getDocumentLibraryById(id)
  });
