feat: product recipes

This commit is contained in:
ferdiansyah783
2025-08-11 13:48:24 +07:00
parent b648349ebd
commit c3780af341
13 changed files with 1162 additions and 420 deletions
+13
View File
@@ -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
}
})
}
+3 -2
View File
@@ -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}`)