/* MIL GRAU RP — Checkout, PIX, Profile pages */
const { useState: uS2, useEffect: uE2, useMemo: uM2 } = React;
// ===== CHECKOUT =====
function CheckoutPage({ items, onNav, onPay, onAddItem }) {
const [pay, setPay] = uS2('pix');
const [terms, setTerms] = uS2(false);
const [coupon, setCoupon] = uS2('');
const [appliedCoupon, setAppliedCoupon] = uS2(null);
const [form, setForm] = uS2({ nome: '', email: '', cpf: '', tel: '', idCidade: '' });
const [discordLinked, setDiscordLinked] = uS2(false);
const subtotal = items.reduce((s, i) => s + i.price * i.qty, 0);
const discount = appliedCoupon ? subtotal * 0.1 : 0;
const total = subtotal - discount;
const applyCoupon = () => {
if (coupon.toUpperCase() === 'BEMVINDOMG') {
setAppliedCoupon('BEMVINDOMG');
} else {
setAppliedCoupon('invalid');
}
};
return (
Finalizar compra
{/* Discord */}
1 Sua conta
{discordLinked ? (
Diego Martins#4892
Conectado via Discord
) : (
)}
{/* Forma de pagamento */}
2 Forma de pagamento
setPay('pix')}>
PIX
Aprovação imediata
setPay('mp')}>
Mercado Pago
Cartão de crédito
setPay('pp')}>
PayPal
Internacional
{/* Dados pessoais */}
{/* Resumo */}
Resumo do pedido
{items.map(item => (
{item.name}
Qtd: {item.qty}
{window.MGRP_DATA.fmtBRL(item.price * item.qty)}
))}
CUPOM DE DESCONTO
setCoupon(e.target.value)} placeholder="Digite o cupom"/>
{appliedCoupon === 'BEMVINDOMG' && (
Cupom BEMVINDOMG aplicado: -10%
)}
{appliedCoupon === 'invalid' && (
Cupom inválido. Tente "BEMVINDOMG".
)}
Subtotal{window.MGRP_DATA.fmtBRL(subtotal)}
{discount > 0 &&
Desconto (10%)-{window.MGRP_DATA.fmtBRL(discount)}
}
Taxa de processamentoGrátis
Total{window.MGRP_DATA.fmtBRL(total)}
Adicione Cartão 100k
+ R$ 47,90 e leve dinheiro extra
Pagamento 100% seguro
);
}
// ===== PIX PAYMENT =====
function PixPage({ amount, onNav }) {
const [copied, setCopied] = uS2(false);
const code = '00020126360014BR.GOV.BCB.PIX0114+5511999990000520400005303986540' + (amount || 0).toFixed(2) + '5802BR5919MILGRAURP STORE LTDA6009SAO PAULO62070503***6304ABCD';
const copy = () => {
navigator.clipboard?.writeText(code);
setCopied(true);
setTimeout(() => setCopied(false), 2000);
};
return (
Concluir pagamento
Escaneie o QR Code ou copie o código PIX para pagar
{window.MGRP_DATA.fmtBRL(amount || 247.90)}
Aguardando pagamento... expira em 14:32
📱 Como pagar com PIX?
1
Abra o app do seu banco e acesse a área PIX.
2
Escolha "Pagar com QR Code" ou "PIX Copia e Cola" e cole o código.
3
Confirme o pagamento. Seu produto será liberado automaticamente em segundos.
);
}
// QR placeholder (SVG modules)
function QRPlaceholder() {
const size = 21;
const cells = [];
// pseudo-random pattern with finder squares
for (let y = 0; y < size; y++) {
for (let x = 0; x < size; x++) {
const isFinder = (x < 7 && y < 7) || (x >= size - 7 && y < 7) || (x < 7 && y >= size - 7);
let on = false;
if (isFinder) {
const fx = x < 7 ? x : x - (size - 7);
const fy = y < 7 ? y : y - (size - 7);
on = (fx === 0 || fx === 6 || fy === 0 || fy === 6 || (fx >= 2 && fx <= 4 && fy >= 2 && fy <= 4));
} else {
on = ((x * 31 + y * 17 + x * y) % 3 === 0);
}
if (on) cells.push();
}
}
return (
);
}
// ===== PROFILE =====
function ProfilePage({ onNav, products }) {
const [tab, setTab] = uS2('orders');
const orders = [
{ id: 'MG-2026-04829', date: '02 Mai 2026', status: 'Concluído', items: [products.find(p => p.id === 'passe-premium'), products.find(p => p.id === 'sistema-tvs')], total: 309.80 },
{ id: 'MG-2026-04612', date: '28 Abr 2026', status: 'Concluído', items: [products.find(p => p.id === 'cartao-100k')], total: 47.90 },
{ id: 'MG-2026-04501', date: '15 Abr 2026', status: 'Pendente', items: [products.find(p => p.id === 'passe-lendario')], total: 247.90 },
].filter(o => o.items.every(Boolean));
return (
Meu perfil
{tab === 'orders' && (
<>
Histórico de pedidos
{orders.length} pedidos
{orders.map(o => (
{o.items.map(it => (
{it.name}
x1
{window.MGRP_DATA.fmtBRL(it.price)}
))}
Total: {window.MGRP_DATA.fmtBRL(o.total)}
))}
>
)}
{tab === 'data' && (
Dados pessoais
)}
{tab === 'settings' && (
)}
);
}
window.CheckoutPage = CheckoutPage;
window.PixPage = PixPage;
window.ProfilePage = ProfilePage;