| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
1399e949 please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information. @microsoft-github-policy-service agree [company="{your company}"]
Contributor License Agreement Contribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
// src/pages/Checkout.js
import React from "react";
import { useCart } from "../store/cart";
export default function Checkout() {
const { cart, clearCart } = useCart();
const total = cart.reduce((acc, item) => acc + item.price, 0).toFixed(2);
const handleCheckout = () => {
alert("Pedido finalizado com sucesso!");
clearCart();
};
return (
Checkout
{cart.length === 0 ? (
Seu carrinho está vazio.
) : (
{cart.map((item, i) => (
{item.name}
R$ {item.price}
))}
Total: R$ {total}
Finalizar Pedido
)}
);
}