14 lines
433 B
TypeScript
14 lines
433 B
TypeScript
import { useQuery } from '@tanstack/react-query'
|
|
import { ProductRecipe } from '../../types/services/productRecipe'
|
|
import { api } from '../api'
|
|
|
|
export function useProductRecipesByProduct(productId: string) {
|
|
return useQuery<ProductRecipe[]>({
|
|
queryKey: ['product-recipes', productId],
|
|
queryFn: async () => {
|
|
const res = await api.get(`/product-recipes/product/${productId}`)
|
|
return res.data.data
|
|
}
|
|
})
|
|
}
|