Actualizar index.html
This commit is contained in:
37
index.html
37
index.html
@@ -432,6 +432,22 @@
|
||||
let dateStr = q.created_at || q.date || "";
|
||||
if(dateStr && dateStr.includes('T')) dateStr = dateStr.split('T')[0].split('-').reverse().join('/');
|
||||
|
||||
// 🛑 LÓGICA STRIPE: Creamos el botón rápido si está firmado, la empresa tiene Stripe y NO está pagado
|
||||
let bSet = globalCompanyData?.billing_settings || {};
|
||||
if (typeof bSet === 'string') { try { bSet = JSON.parse(bSet); } catch(e) {} }
|
||||
const stripeEnabled = bSet.stripe_enabled && bSet.stripe_pk;
|
||||
|
||||
const isSigned = (q.status === 'accepted' || q.status === 'converted');
|
||||
let quickPayButton = '';
|
||||
|
||||
if (stripeEnabled && isSigned && q.status !== 'paid') {
|
||||
quickPayButton = `
|
||||
<button onclick="event.stopPropagation(); quickPayStripe(${q.id})" class="mt-4 w-full bg-indigo-600 text-white font-black py-3 rounded-xl flex items-center justify-center gap-2 uppercase tracking-widest text-[10px] shadow-md shadow-indigo-500/20 active:scale-95 transition-transform hover:bg-indigo-700">
|
||||
<i data-lucide="credit-card" class="w-4 h-4"></i> Pagar Ahora
|
||||
</button>
|
||||
`;
|
||||
}
|
||||
|
||||
// 🛑 FIX: Calcar los colores y estados del escritorio
|
||||
let statusBadge = "";
|
||||
if (!q.status || q.status === 'pending') {
|
||||
@@ -463,6 +479,7 @@
|
||||
<span class="text-[10px] font-bold text-slate-500 flex items-center gap-1"><i data-lucide="calendar" class="w-3 h-3"></i> ${dateStr}</span>
|
||||
<span class="text-lg font-black text-slate-800">${amountStr}€</span>
|
||||
</div>
|
||||
${quickPayButton}
|
||||
</div>`;
|
||||
});
|
||||
|
||||
@@ -693,6 +710,26 @@
|
||||
}
|
||||
}
|
||||
|
||||
// 💳 LANZAR PAGO RÁPIDO DESDE LA TARJETA EXTERNA
|
||||
async function quickPayStripe(id) {
|
||||
showToast("⏳ Redirigiendo a pasarela segura...");
|
||||
try {
|
||||
const res = await fetch(`${API_URL}/public/portal/${urlToken}/budget/${id}/checkout`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
});
|
||||
const data = await res.json();
|
||||
|
||||
if (data.ok && data.checkout_url) {
|
||||
window.location.href = data.checkout_url;
|
||||
} else {
|
||||
showToast(data.error || "❌ Error al iniciar el pago.");
|
||||
}
|
||||
} catch (e) {
|
||||
showToast("❌ Error de conexión con el banco.");
|
||||
}
|
||||
}
|
||||
|
||||
async function generatePDF(id) {
|
||||
const budget = currentQuotes.find(b => b.id === id);
|
||||
if(!budget) return showToast("❌ Error: Presupuesto no encontrado");
|
||||
|
||||
Reference in New Issue
Block a user