feat: agregar total al carrito

This commit is contained in:
Sofía Maturana 2026-04-08 13:48:11 -04:00
parent 2436eb3747
commit e82cd0d475

View file

@ -4,9 +4,20 @@ import { pizzaCart } from "./pizzas";
const Cart = () => {
const [cart, setCart] = useState(pizzaCart);
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">
{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>
<div className="flex gap-4">
<button
@ -40,6 +51,7 @@ const Cart = () => {
</div>
))}
</div>
</section>
);
};