import React from 'react'; import { Store, Trash2, FileEdit, FileCheck, Printer } from 'lucide-react'; import { useCRM } from '../context/CRMContext'; import { OrderStatus } from '../types'; const Orders: React.FC = () => { const { orders, updateOrderStatus, resumeOrder, deleteOrder } = useCRM(); const handleDelete = async (id: string) => { if (window.confirm("Tem certeza que deseja excluir esse pedido?")) { await deleteOrder(id); } }; const handlePrint = (order: any) => { const printWindow = window.open('', '_blank'); if (printWindow) { printWindow.document.write(`
Relatório de Pedido
Data: ${new Date(order.date).toLocaleDateString()}
ID: #${order.id}
Status: ${order.status}
Fornecedor: ${order.supplierName}
| Produto | Qtd | Preço Unit. (USD) | Total (USD) | Total (BRL) |
|---|---|---|---|---|
| ${item.name} | ${item.quantity} | $ ${item.priceUSD.toFixed(2)} | $ ${(item.priceUSD * item.quantity).toFixed(2)} | R$ ${(item.priceBRL * item.quantity).toFixed(2)} |
Total USD: $ ${order.totalUSD.toFixed(2)}
Total BRL (Sem Taxas): R$ ${order.totalBRL.toFixed(2)}
Custo Final Estimado: R$ ${order.totalCostWithOverhead.toLocaleString('pt-BR')}
Lucro Estimado: R$ ${order.estimatedProfit.toLocaleString('pt-BR')}
Gestão de ciclo de vida e conciliação.
| ID / Data | Fornecedor | Compra (USD) | Custo BR (R$) | Delta ($) | Status | Ações |
|---|---|---|---|---|---|---|
|
{o.id.substring(0, 8)}... {new Date(o.date).toLocaleDateString()} |
|
US$ {o.totalUSD.toFixed(2)} | R$ {o.totalCostWithOverhead.toLocaleString('pt-BR')} | + {o.estimatedProfit.toLocaleString('pt-BR')} |
|
Pedido
{o.id.substring(0, 8)}...
{new Date(o.date).toLocaleDateString()}
Fornecedor
Total (BRL)
R$ {o.totalCostWithOverhead.toLocaleString('pt-BR')}