feat: product recipes
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
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
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { Products } from '../../types/services/product'
|
||||
import { Product, Products } from '../../types/services/product'
|
||||
import { api } from '../api'
|
||||
import { ProductRecipe } from '../../types/services/productRecipe'
|
||||
|
||||
interface ProductsQueryParams {
|
||||
page?: number
|
||||
@@ -39,7 +40,7 @@ export function useProducts(params: ProductsQueryParams = {}) {
|
||||
}
|
||||
|
||||
export function useProductById(id: string) {
|
||||
return useQuery({
|
||||
return useQuery<Product>({
|
||||
queryKey: ['product', id],
|
||||
queryFn: async () => {
|
||||
const res = await api.get(`/products/${id}`)
|
||||
|
||||
Reference in New Issue
Block a user