import { useQuery } from '@tanstack/react-query';
import { searchMessages } from '../service/SearchService';
import { SearchQueryDto } from '../types/SearchTypes';

export const useSearchMessages = (query: SearchQueryDto) => {
    return useQuery({
        queryKey: ['search-messages', query],
        queryFn: () => searchMessages(query),
        staleTime: 5 * 60 * 1000, // 5 minutes
        enabled: !!query.q, // Only run query if search term exists
    });
}; 