/* ============================================================ checkout.jsx — Create Checkout + Products CRUD + Order Bumps CRUD ============================================================ */ // ============================================================ // Create Checkout — main builder for a payment link // ============================================================ function CreateCheckout(){ const { products, bumps, pushToast, setModal, setRoute } = useApp(); const [name, setName] = React.useState(products[1].name); const [desc, setDesc] = React.useState(products[1].desc); const [price, setPrice] = React.useState(products[1].price); const [installments, setInstallments] = React.useState(12); const [allowPix, setAllowPix] = React.useState(true); const [allowCard, setAllowCard] = React.useState(true); const [allowStripe, setAllowStripe] = React.useState(false); const [gateway, setGateway] = React.useState("mp"); // mp | stripe — qual gateway processa const [customerName, setCustomerName] = React.useState(""); const [customerEmail, setCustomerEmail] = React.useState(""); const [customerPhone, setCustomerPhone] = React.useState(""); const [postUrl, setPostUrl] = React.useState("https://blackx.holdingcriativa.com.br/obrigado"); const [status, setStatus] = React.useState("ativo"); const [dueDate, setDueDate] = React.useState(() => { const d = new Date(); d.setDate(d.getDate() + 7); return d.toISOString().slice(0, 10); }); // Order bumps selected (with active state, separate from the catalog "active" flag) const [bumpsOn, setBumpsOn] = React.useState( bumps.filter(b => b.active).slice(0, 2).map(b => b.id) ); // Generated link state const [generated, setGenerated] = React.useState(null); const [generating, setGenerating] = React.useState(false); const total = price + bumps.filter(b => bumpsOn.includes(b.id)).reduce((a, b) => a + b.price, 0); const generate = () => { if (!name.trim() || price <= 0) { pushToast("Preencha nome e valor.", "warn"); return; } setGenerating(true); setGenerated(null); setTimeout(() => { setGenerating(false); const slug = name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)/g, "").slice(0, 32); const id = uid(); setGenerated({ url: `https://pagblackx.holdingcriativa.com.br/c/${slug}-${id}`, id, slug, }); pushToast("Link de pagamento gerado."); }, 900); }; const copyLink = async () => { if (!generated) return; try { await navigator.clipboard.writeText(generated.url); pushToast("Link copiado."); } catch { pushToast("Não foi possível copiar.", "bad"); } }; const sendWA = () => { if (!generated) return; const msg = encodeURIComponent(`Olá! Segue o link de pagamento da BlackX:\n${generated.url}`); pushToast("Mensagem preparada no WhatsApp."); window.open(`https://wa.me/?text=${msg}`, "_blank"); }; const previewCustomer = () => { if (!generated) return setRoute("/pay/preview"); setRoute("/pay/preview"); }; return ( setRoute("/dashboard")}>Cancelar}>
Novo

Monte uma cobrança em segundos.

Defina o produto, parcelamento e order bumps. Em seguida, gere o link, copie ou envie pelo WhatsApp.

{/* LEFT: builder form */}

Produto

O que está sendo vendido
setName(e.target.value)} />