fixed edit product
This commit is contained in:
parent
bd0fcb4955
commit
a67b4f881f
2 changed files with 3 additions and 3 deletions
|
|
@ -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
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -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) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue