import { keepPreviousData, useQuery } from '@tanstack/react-query'
import { getProductPrices } from '../api/getProductPrices'

export function useProductPrices(productId: number, page: number = 1, pageSize: number = 20) {
  return useQuery({
    queryKey: ['product-prices', productId, page, pageSize],
    queryFn: () => getProductPrices(productId, page, pageSize),
    enabled: productId > 0,
    staleTime: 30_000,
    placeholderData: keepPreviousData,
  })
}
