import { useEffect, useState } from 'react' import { useApp } from '../context/AppContext.jsx' import { useApi } from '../hooks/useApi.js' export function Products() { const [products, setProducts] = useState([]) const [loading, setLoading] = useState(true) const { addToCart } = useApp() const { getProducts } = useApi() useEffect(() => { fetchProducts() }, []) const fetchProducts = async () => { try { const data = await getProducts() setProducts(data) } catch (error) { console.error('Error fetching products:', error) } finally { setLoading(false) } } if (loading) { return (
{product.description}
No products available