feat: agregar total al carrito
This commit is contained in:
parent
2436eb3747
commit
e82cd0d475
1 changed files with 47 additions and 35 deletions
14
src/Cart.jsx
14
src/Cart.jsx
|
|
@ -4,9 +4,20 @@ import { pizzaCart } from "./pizzas";
|
||||||
const Cart = () => {
|
const Cart = () => {
|
||||||
const [cart, setCart] = useState(pizzaCart);
|
const [cart, setCart] = useState(pizzaCart);
|
||||||
return (
|
return (
|
||||||
|
<section id="cart">
|
||||||
|
<h1 className="text-4xl font-bold">Carrito</h1>
|
||||||
|
<p>
|
||||||
|
Total:
|
||||||
|
<strong>
|
||||||
|
{` $${cart.reduce((acc, it) => acc + it.price * it.count, 0).toLocaleString("es-CL")}`}
|
||||||
|
</strong>
|
||||||
|
</p>
|
||||||
<div id="cartContainer" className="flex gap-4 flex-col">
|
<div id="cartContainer" className="flex gap-4 flex-col">
|
||||||
{cart.map((pizza) => (
|
{cart.map((pizza) => (
|
||||||
<div className="border-3 border-lime-300 rounded-md p-2" key={pizza.id}>
|
<div
|
||||||
|
className="border-3 border-lime-300 rounded-md p-2"
|
||||||
|
key={pizza.id}
|
||||||
|
>
|
||||||
<h2>Pizza {pizza.name}</h2>
|
<h2>Pizza {pizza.name}</h2>
|
||||||
<div className="flex gap-4">
|
<div className="flex gap-4">
|
||||||
<button
|
<button
|
||||||
|
|
@ -40,6 +51,7 @@ const Cart = () => {
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
</section>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue