-
Notifications
You must be signed in to change notification settings - Fork 154
Expand file tree
/
Copy pathProducts.jsx
More file actions
38 lines (33 loc) · 958 Bytes
/
Products.jsx
File metadata and controls
38 lines (33 loc) · 958 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { useEffect, useState } from 'react';
import { useNavigate } from 'react-router-dom';
import ProductCard from '../Components/ProductCard';
import { getAllCocktails } from '../api';
const Products = () => {
const [products, setProducts] = useState([]);
const navigate = useNavigate();
useEffect(() => {
const fetchProducts = async () => {
const { cocktails } = await getAllCocktails();
setProducts(cocktails);
};
fetchProducts();
}, []);
return (
<div className="container">
<button className="btn" onClick={() => navigate(-1)}>
Go Back
</button>
<div className="title">
<h1>CockTails</h1>
</div>
<div className="cocktails-container">
{products.map((product) => (
<div key={product.id} className="cocktail-card">
<ProductCard product={product} />
</div>
))}
</div>
</div>
);
};
export default Products;