import React from "react"; import { OrderItem } from "../../types"; interface CheckoutProductsTableProps { cart: OrderItem[]; onEdit?: (item: OrderItem) => void; onDiscount?: (item: OrderItem) => void; onRemove?: (item: OrderItem) => void; } const CheckoutProductsTable: React.FC = ({ cart, onEdit, onDiscount, onRemove, }) => { // Renderizar badge de condição const renderConditionBadge = (item: OrderItem) => { if (item.discount && item.discount > 0) { return ( Em promoção ); } return null; }; // Renderizar badge de tipo de entrega const renderDeliveryTypeBadge = (item: OrderItem) => { if (item.deliveryType === "RI") { return ( Retira imediata ); } if (item.deliveryType === "EN") { return ( Entrega ); } if (item.deliveryType === "RP") { return ( Retira posterior ); } if (item.deliveryType === "EF") { return ( Encomenda ); } return null; }; return (
{/* Cards View - Mobile/Tablet */}
{cart.length === 0 ? (
Nenhum item adicionado ao pedido.
) : (
{cart.map((item, idx) => (
{/* Header do Card */}
#{idx + 1} Cód: {item.code} {renderConditionBadge(item)}

{item.name}

{/* Informações do Produto */}
Marca: {item.mark || "-"}
Desconto: {item.discount ? `${item.discount.toFixed(2)}%` : "0,00%"}
F.Retira: {item.stockStore ? `Loja ${item.stockStore}` : "-"}
Tipo de entrega: {renderDeliveryTypeBadge(item)}
{/* Valores */}
Preço unitário: R$ {item.price.toFixed(2)}
Quantidade: {item.quantity.toFixed(2)}
Valor total: R$ {(item.price * item.quantity).toFixed(2)}
{/* Ações */}
))}
)}
{/* Table View - Desktop */}
{cart.length === 0 ? ( ) : ( cart.map((item, idx) => ( )) )}
Seq Código Produto Condição Marca Descon F.Retira Tipo de entre. Preço Qtde Valor total Ações
Nenhum item adicionado ao pedido.
{idx + 1} {item.code} {item.name} {item.discount && item.discount > 0 && ( Em promoção )} {item.mark || "-"} {item.discount ? `${item.discount.toFixed(2)}%` : "0,00%"} {item.stockStore ? `Loja ${item.stockStore}` : "-"} {item.deliveryType === "RI" && ( Retira imediata )} {item.deliveryType === "EN" && ( Entrega )} {item.deliveryType === "RP" && ( Retira posterior )} {item.deliveryType === "EF" && ( Encomenda )} R$ {item.price.toFixed(2)} {item.quantity.toFixed(2)} R$ {(item.price * item.quantity).toFixed(2)}
); }; export default CheckoutProductsTable;