From c40852703da9f1a8ea2dc935031c58a8fe807235 Mon Sep 17 00:00:00 2001 From: 2ManyProjects Date: Sat, 26 Apr 2025 13:22:29 -0500 Subject: [PATCH] fixed produc tloading --- frontend/src/pages/ProductDetailPage.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/pages/ProductDetailPage.jsx b/frontend/src/pages/ProductDetailPage.jsx index e070e5b..bddce37 100644 --- a/frontend/src/pages/ProductDetailPage.jsx +++ b/frontend/src/pages/ProductDetailPage.jsx @@ -42,7 +42,7 @@ const ProductDetailPage = () => { // Fetch product data const { data: products, isLoading, error } = useProduct(id); const addToCart = useAddToCart(); - let product = products[0] + let product = products?.length > 0 ? products[0] : null // Handle quantity changes const increaseQuantity = () => { if (product && quantity < product.stock_quantity) {