fixed edit product

This commit is contained in:
2ManyProjects 2025-04-25 22:49:09 -05:00
parent bd0fcb4955
commit a67b4f881f
2 changed files with 3 additions and 3 deletions

View file

@ -90,7 +90,7 @@ const ProductEditPage = () => {
queryKey: ['product', id], queryKey: ['product', id],
queryFn: async () => { queryFn: async () => {
const response = await apiClient.get(`/products/${id}`); const response = await apiClient.get(`/products/${id}`);
return response.data; return response.data[0];
}, },
enabled: !isNewProduct enabled: !isNewProduct
}); });

View file

@ -40,9 +40,9 @@ const ProductDetailPage = () => {
const [selectedImage, setSelectedImage] = useState(0); const [selectedImage, setSelectedImage] = useState(0);
// Fetch product data // Fetch product data
const { data: product, isLoading, error } = useProduct(id); const { data: products, isLoading, error } = useProduct(id);
const addToCart = useAddToCart(); const addToCart = useAddToCart();
let product = products[0]
// Handle quantity changes // Handle quantity changes
const increaseQuantity = () => { const increaseQuantity = () => {
if (product && quantity < product.stock_quantity) { if (product && quantity < product.stock_quantity) {