feat(sinpe): filtro de rechazados reparado con purga de caché, nuevo spinner celeste sin barra ni timer, sondeo de hasta 2 min con timeout asistido
This commit is contained in:
+27
-3
@@ -4636,7 +4636,7 @@ body.dark-mode .parent-subview-back-btn:hover {
|
||||
position: absolute;
|
||||
inset: -6px;
|
||||
border-radius: 50%;
|
||||
border: 3px solid #86efac;
|
||||
border: 3px solid #38bdf8;
|
||||
opacity: 0.8;
|
||||
animation: sinpePulseRing 2s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
|
||||
}
|
||||
@@ -4660,8 +4660,14 @@ body.dark-mode .parent-subview-back-btn:hover {
|
||||
}
|
||||
|
||||
.sinpe-icon-badge.loading {
|
||||
background: #f0fdf4;
|
||||
border: 2px solid #86efac;
|
||||
background: #f0f9ff;
|
||||
border: 2px solid #38bdf8;
|
||||
}
|
||||
|
||||
.sinpe-icon-badge.timeout {
|
||||
background: #f0f9ff;
|
||||
border: 2.5px solid #38bdf8;
|
||||
animation: sinpePopIn 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
|
||||
}
|
||||
|
||||
.sinpe-icon-badge.success {
|
||||
@@ -4786,6 +4792,24 @@ body.dark-mode .parent-subview-back-btn:hover {
|
||||
box-shadow: 0 4px 14px rgba(220, 38, 38, 0.35);
|
||||
}
|
||||
|
||||
.btn-sinpe-sky {
|
||||
background: linear-gradient(135deg, #0284c7, #0369a1);
|
||||
color: white;
|
||||
box-shadow: 0 4px 14px rgba(2, 132, 199, 0.35);
|
||||
}
|
||||
|
||||
.btn-sinpe-subtle {
|
||||
background: #f1f5f9;
|
||||
color: #334155;
|
||||
border: 1.5px solid #cbd5e1;
|
||||
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
|
||||
}
|
||||
|
||||
.btn-sinpe-subtle:hover {
|
||||
background: #e2e8f0;
|
||||
color: #0f172a;
|
||||
}
|
||||
|
||||
body.dark-mode .modal-sinpe-card {
|
||||
background: #0f172a !important;
|
||||
color: #f8fafc !important;
|
||||
|
||||
+52
-19
@@ -12,7 +12,7 @@
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
|
||||
<meta name="apple-mobile-web-app-title" content="SiboPay">
|
||||
<meta name="mobile-web-app-capable" content="yes">
|
||||
<link rel="stylesheet" href="/css/styles.css?v=10.1">
|
||||
<link rel="stylesheet" href="/css/styles.css?v=10.4">
|
||||
<style>
|
||||
/* Transiciones suaves */
|
||||
.fade-enter { animation: fadeIn 0.2s ease-in-out; }
|
||||
@@ -2440,31 +2440,27 @@
|
||||
<div class="modal-qr-card modal-sinpe-card" onclick="event.stopPropagation()">
|
||||
<button type="button" class="modal-sinpe-close-btn" id="modalSinpeBtnCloseX" onclick="closeSinpeModal()" style="display: none;" title="Cerrar">✕</button>
|
||||
|
||||
<!-- 1. ESTADO: CARGANDO / VALIDANDO SINPE (10-20s con barra y animación) -->
|
||||
<!-- 1. ESTADO: CARGANDO / VALIDANDO SINPE (Hasta 2 minutos con mensajes sutiles) -->
|
||||
<div id="modalSinpeStateLoading" style="display: none;">
|
||||
<div class="sinpe-spinner-container">
|
||||
<div class="sinpe-pulse-ring"></div>
|
||||
<div class="sinpe-icon-badge loading">
|
||||
<svg class="sinpe-spin-svg" width="38" height="38" viewBox="0 0 24 24" fill="none">
|
||||
<circle cx="12" cy="12" r="10" stroke="#dcfce7" stroke-width="3"/>
|
||||
<path d="M12 2a10 10 0 0 1 10 10" stroke="#16a34a" stroke-width="3" stroke-linecap="round"/>
|
||||
<circle cx="12" cy="12" r="10" stroke="#e0f2fe" stroke-width="3"/>
|
||||
<path d="M12 2a10 10 0 0 1 10 10" stroke="#0284c7" stroke-width="3" stroke-linecap="round"/>
|
||||
</svg>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h3 style="margin: 14px 0 4px 0; font-size: 1.25rem; font-weight: 900; color: var(--text-main);">Validando SINPE</h3>
|
||||
<p id="modalSinpeLoadingSubtext" style="font-size: 0.85rem; color: #64748b; margin: 0 0 14px 0; line-height: 1.35;">
|
||||
Consultando confirmación bancaria en tiempo real...
|
||||
<p id="modalSinpeLoadingSubtext" style="font-size: 0.85rem; color: #64748b; margin: 0 0 10px 0; line-height: 1.35;">
|
||||
Validando comprobante con el banco. Esto podría tardar hasta 1 minuto...
|
||||
</p>
|
||||
|
||||
<!-- Barra de Progreso y Cuenta Regresiva de 18s -->
|
||||
<div class="sinpe-progress-track">
|
||||
<div class="sinpe-progress-bar" id="modalSinpeProgressBar"></div>
|
||||
</div>
|
||||
|
||||
<div style="display: flex; justify-content: space-between; align-items: center; margin-top: 6px; font-size: 0.72rem; color: #64748b; font-weight: 700;">
|
||||
<span id="modalSinpeStepText">Buscando comprobante bancario...</span>
|
||||
<span id="modalSinpeTimerText" style="color: #16a34a; font-weight: 900; font-family: monospace; font-size: 0.82rem;">18s</span>
|
||||
<!-- Subtítulos sutiles que rotan -->
|
||||
<div style="text-align: center; margin: 0 0 14px 0; font-size: 0.78rem; color: #0284c7; font-weight: 800; min-height: 20px; display: flex; align-items: center; justify-content: center; gap: 6px;">
|
||||
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" class="sinpe-spin-svg"><path d="M21 12a9 9 0 1 1-6.219-8.56"/></svg>
|
||||
<span id="modalSinpeStepText">Consultando confirmación bancaria en tiempo real...</span>
|
||||
</div>
|
||||
|
||||
<!-- Resumen de la Operación -->
|
||||
@@ -2475,16 +2471,53 @@
|
||||
</div>
|
||||
<div class="sinpe-info-row">
|
||||
<span>Monto a validar:</span>
|
||||
<strong id="modalSinpeSummaryMonto" style="color: #16a34a; font-size: 0.96rem;">₡0</strong>
|
||||
<strong id="modalSinpeSummaryMonto" style="color: #0284c7; font-size: 0.96rem;">₡0</strong>
|
||||
</div>
|
||||
<div class="sinpe-info-row">
|
||||
<span>Código de detalle:</span>
|
||||
<strong id="modalSinpeSummaryCodigo" style="font-family: monospace; letter-spacing: 0.5px; color: #15803d;">-</strong>
|
||||
<strong id="modalSinpeSummaryCodigo" style="font-family: monospace; letter-spacing: 0.5px; color: #0369a1;">-</strong>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="font-size: 0.73rem; color: #64748b; margin-top: 14px; line-height: 1.4; background: #f8fafc; padding: 9px 12px; border-radius: 10px; border: 1px solid #e2e8f0; text-align: left;">
|
||||
<span style="font-weight: 800; color: #334155;">⏳ Espere un momento, por favor:</span> Los bancos emiten el comprobante digital entre 10 y 20 segundos después de realizar el envío.
|
||||
<div style="font-size: 0.73rem; color: #64748b; margin-top: 14px; line-height: 1.4; background: #f0f9ff; border: 1px solid #bae6fd; padding: 9px 12px; border-radius: 10px; text-align: left;">
|
||||
<span style="font-weight: 800; color: #0284c7;">⏳ Espere un momento, por favor:</span> Esto podría tardar hasta 1 minuto mientras el banco emite el comprobante digital. No cierre esta pantalla.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ESTADO: TIEMPO DE ESPERA AGOTADO (2 minutos sin confirmación bancaria) -->
|
||||
<div id="modalSinpeStateTimeout" style="display: none;">
|
||||
<div class="sinpe-icon-badge timeout">
|
||||
<svg width="38" height="38" viewBox="0 0 24 24" fill="none" stroke="#0284c7" stroke-width="2.3" stroke-linecap="round" stroke-linejoin="round">
|
||||
<circle cx="12" cy="12" r="10"/>
|
||||
<polyline points="12 6 12 12 16 14"/>
|
||||
</svg>
|
||||
</div>
|
||||
|
||||
<h3 style="margin: 14px 0 4px 0; font-size: 1.25rem; font-weight: 900; color: var(--text-main);">El banco aún no confirma</h3>
|
||||
<p style="font-size: 0.84rem; color: #64748b; margin: 0 0 14px 0; line-height: 1.45;">
|
||||
No hemos recibido el correo de confirmación de tu banco todavía. Puedes seguir esperando 1 minuto más o enviarla para que el comercio la revise manualmente.
|
||||
</p>
|
||||
|
||||
<div class="sinpe-info-summary" style="margin-bottom: 16px;">
|
||||
<div class="sinpe-info-row">
|
||||
<span>Monto reportado:</span>
|
||||
<strong id="modalSinpeTimeoutMonto" style="color: #0284c7; font-size: 0.96rem;">₡0</strong>
|
||||
</div>
|
||||
<div class="sinpe-info-row">
|
||||
<span>Código de detalle:</span>
|
||||
<strong id="modalSinpeTimeoutCodigo" style="font-family: monospace;">-</strong>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="display: flex; flex-direction: column; gap: 8px;">
|
||||
<button type="button" class="btn-sinpe-action btn-sinpe-sky" onclick="retrySinpeWaitMore()">
|
||||
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.3" stroke-linecap="round" stroke-linejoin="round"><path d="M21.5 2v6h-6M21.34 15.57a10 10 0 1 1-.57-8.38l5.67-5.67"/></svg>
|
||||
<span>Seguir esperando 1 minuto más</span>
|
||||
</button>
|
||||
<button type="button" class="btn-sinpe-action btn-sinpe-subtle" onclick="confirmSinpeSendManualReview()">
|
||||
<svg width="17" height="17" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.3" stroke-linecap="round" stroke-linejoin="round"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/><line x1="16" y1="13" x2="8" y2="13"/><line x1="16" y1="17" x2="8" y2="17"/></svg>
|
||||
<span>Enviar a revisión manual</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -2606,6 +2639,6 @@
|
||||
<script src="/js/sounds.js?v=9.6"></script>
|
||||
<script src="/js/jsQR.js"></script>
|
||||
<script src="/js/food-icons.js?v=1.1"></script>
|
||||
<script src="/js/app.js?v=10.3"></script>
|
||||
<script src="/js/app.js?v=10.4"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+234
-59
@@ -2812,6 +2812,8 @@ function fallbackCopyText(text, cb) {
|
||||
let sinpeProgressInterval = null;
|
||||
let sinpeIsPolling = false;
|
||||
|
||||
let currentSinpePollingData = null;
|
||||
|
||||
function showSinpeModal(state, data = {}) {
|
||||
const modal = document.getElementById('modalSinpeValidacion');
|
||||
if (!modal) return;
|
||||
@@ -2820,12 +2822,14 @@ function showSinpeModal(state, data = {}) {
|
||||
const stateSuccess = document.getElementById('modalSinpeStateSuccess');
|
||||
const statePending = document.getElementById('modalSinpeStatePending');
|
||||
const stateError = document.getElementById('modalSinpeStateError');
|
||||
const stateTimeout = document.getElementById('modalSinpeStateTimeout');
|
||||
const btnCloseX = document.getElementById('modalSinpeBtnCloseX');
|
||||
|
||||
if (stateLoading) stateLoading.style.display = 'none';
|
||||
if (stateSuccess) stateSuccess.style.display = 'none';
|
||||
if (statePending) statePending.style.display = 'none';
|
||||
if (stateError) stateError.style.display = 'none';
|
||||
if (stateTimeout) stateTimeout.style.display = 'none';
|
||||
|
||||
if (state === 'loading') {
|
||||
if (stateLoading) stateLoading.style.display = 'block';
|
||||
@@ -2834,15 +2838,18 @@ function showSinpeModal(state, data = {}) {
|
||||
const sumMonto = document.getElementById('modalSinpeSummaryMonto');
|
||||
const sumCod = document.getElementById('modalSinpeSummaryCodigo');
|
||||
const stepText = document.getElementById('modalSinpeStepText');
|
||||
const timerText = document.getElementById('modalSinpeTimerText');
|
||||
const bar = document.getElementById('modalSinpeProgressBar');
|
||||
|
||||
if (sumChild) sumChild.textContent = data.studentName || '-';
|
||||
if (sumMonto) sumMonto.textContent = `₡${(data.monto || 0).toLocaleString('es-CR')}`;
|
||||
if (sumCod) sumCod.textContent = data.codigo || '-';
|
||||
if (stepText) stepText.textContent = 'Buscando comprobante bancario...';
|
||||
if (timerText) timerText.textContent = '18s';
|
||||
if (bar) bar.style.width = '0%';
|
||||
if (stepText) stepText.textContent = 'Consultando confirmación bancaria en tiempo real...';
|
||||
} else if (state === 'timeout') {
|
||||
if (stateTimeout) stateTimeout.style.display = 'block';
|
||||
if (btnCloseX) btnCloseX.style.display = 'flex';
|
||||
const tMonto = document.getElementById('modalSinpeTimeoutMonto');
|
||||
const tCod = document.getElementById('modalSinpeTimeoutCodigo');
|
||||
if (tMonto) tMonto.textContent = `₡${(data.monto || 0).toLocaleString('es-CR')}`;
|
||||
if (tCod) tCod.textContent = data.codigo || '-';
|
||||
} else if (state === 'success') {
|
||||
if (stateSuccess) stateSuccess.style.display = 'block';
|
||||
if (btnCloseX) btnCloseX.style.display = 'flex';
|
||||
@@ -2925,21 +2932,34 @@ async function executeParentSinpeRecharge() {
|
||||
`;
|
||||
}
|
||||
|
||||
// Abrir modal con estado LOADING (sin alertas intrusivas)
|
||||
currentSinpePollingData = {
|
||||
studentId: currentParentChild.id,
|
||||
studentName: currentParentChild.nombre_completo,
|
||||
monto,
|
||||
codigo,
|
||||
comprobante
|
||||
};
|
||||
|
||||
// Abrir modal con estado LOADING (sin barra ni contador de segundos)
|
||||
showSinpeModal('loading', {
|
||||
studentName: currentParentChild.nombre_completo,
|
||||
monto: monto,
|
||||
codigo: codigo
|
||||
});
|
||||
|
||||
const totalDurationMs = 18000; // 18 segundos de sondeo visual
|
||||
const pollIntervalMs = 3000; // Consulta cada 3 segundos
|
||||
const maxIntentos = 40; // 40 intentos * 3s = 120 segundos (2 minutos)
|
||||
const startTime = Date.now();
|
||||
sinpeIsPolling = true;
|
||||
|
||||
const bar = document.getElementById('modalSinpeProgressBar');
|
||||
const timerText = document.getElementById('modalSinpeTimerText');
|
||||
const stepText = document.getElementById('modalSinpeStepText');
|
||||
const rotatingSubtitles = [
|
||||
'Consultando confirmación bancaria en tiempo real...',
|
||||
'Sondeando comprobante con el banco...',
|
||||
'Esto podría tardar hasta 1 minuto, por favor espere...',
|
||||
'Verificando transferencias SINPE entrantes...',
|
||||
'Sincronizando estado digital del banco...'
|
||||
];
|
||||
|
||||
clearInterval(sinpeProgressInterval);
|
||||
sinpeProgressInterval = setInterval(() => {
|
||||
@@ -2948,29 +2968,15 @@ async function executeParentSinpeRecharge() {
|
||||
return;
|
||||
}
|
||||
const elapsed = Date.now() - startTime;
|
||||
const progress = Math.min(100, Math.round((elapsed / totalDurationMs) * 100));
|
||||
const remainingSecs = Math.max(0, Math.ceil((totalDurationMs - elapsed) / 1000));
|
||||
|
||||
if (bar) bar.style.width = `${progress}%`;
|
||||
if (timerText) timerText.textContent = `${remainingSecs}s`;
|
||||
|
||||
if (stepText) {
|
||||
if (elapsed < 4500) {
|
||||
stepText.textContent = 'Buscando comprobante bancario...';
|
||||
} else if (elapsed < 9000) {
|
||||
stepText.textContent = 'Sondeando transferencias SINPE entrantes...';
|
||||
} else if (elapsed < 13500) {
|
||||
stepText.textContent = 'Esperando confirmación digital del banco...';
|
||||
} else {
|
||||
stepText.textContent = 'Verificación bancaria final...';
|
||||
const stepIdx = Math.floor(elapsed / 5000) % rotatingSubtitles.length;
|
||||
if (stepText && stepText.textContent !== rotatingSubtitles[stepIdx]) {
|
||||
stepText.textContent = rotatingSubtitles[stepIdx];
|
||||
}
|
||||
}
|
||||
}, 100);
|
||||
}, 1000);
|
||||
|
||||
try {
|
||||
let verifiedData = null;
|
||||
let definitiveError = null;
|
||||
const maxIntentos = 6;
|
||||
|
||||
for (let intento = 1; intento <= maxIntentos; intento++) {
|
||||
if (!sinpeIsPolling) break;
|
||||
@@ -3057,39 +3063,15 @@ async function executeParentSinpeRecharge() {
|
||||
}
|
||||
|
||||
// ============================================
|
||||
// CASO 3: BANCO AÚN NO RESPONDIÓ (REGISTRO AUTOMÁTICO PARA REVISIÓN)
|
||||
// CASO 3: BANCO AÚN NO RESPONDIÓ TRAS 2 MINUTOS -> MODAL TIMEOUT
|
||||
// ============================================
|
||||
if (window.sounds) window.sounds.playTap();
|
||||
|
||||
try {
|
||||
await fetch('/api/sinpe/solicitar', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
estudiante_id: currentParentChild.id,
|
||||
padre_usuario_id: currentUser ? currentUser.id : null,
|
||||
monto,
|
||||
comprobante: comprobante || `SINPE-${codigo}`,
|
||||
codigo_detalle: codigo,
|
||||
notas: `Portal de Padres - Código: ${codigo}`
|
||||
})
|
||||
});
|
||||
} catch (solErr) {
|
||||
console.warn('Error al registrar solicitud:', solErr);
|
||||
}
|
||||
|
||||
if (inputMonto) inputMonto.value = '';
|
||||
if (inputComp) inputComp.value = '';
|
||||
|
||||
showSinpeModal('pending', {
|
||||
showSinpeModal('timeout', {
|
||||
studentName: currentParentChild.nombre_completo,
|
||||
monto: monto,
|
||||
codigo: codigo
|
||||
});
|
||||
|
||||
await loadParentSinpeRequests(currentParentChild.id);
|
||||
obtenerNuevoCodigoSinpe();
|
||||
|
||||
} catch (err) {
|
||||
sinpeIsPolling = false;
|
||||
clearInterval(sinpeProgressInterval);
|
||||
@@ -3109,6 +3091,181 @@ async function executeParentSinpeRecharge() {
|
||||
}
|
||||
}
|
||||
|
||||
async function retrySinpeWaitMore() {
|
||||
if (!currentSinpePollingData) return;
|
||||
const { studentId, studentName, monto, codigo, comprobante } = currentSinpePollingData;
|
||||
|
||||
showSinpeModal('loading', {
|
||||
studentName: studentName || (currentParentChild ? currentParentChild.nombre_completo : ''),
|
||||
monto,
|
||||
codigo
|
||||
});
|
||||
|
||||
const pollIntervalMs = 3000;
|
||||
const maxIntentos = 20; // 20 * 3s = 60s (1 minuto más)
|
||||
const startTime = Date.now();
|
||||
sinpeIsPolling = true;
|
||||
|
||||
const stepText = document.getElementById('modalSinpeStepText');
|
||||
const rotatingSubtitles = [
|
||||
'Buscando comprobante bancario...',
|
||||
'Consultando transferencias recientes...',
|
||||
'Esto podría tardar unos momentos más...',
|
||||
'Verificando confirmación digital...'
|
||||
];
|
||||
|
||||
clearInterval(sinpeProgressInterval);
|
||||
sinpeProgressInterval = setInterval(() => {
|
||||
if (!sinpeIsPolling) {
|
||||
clearInterval(sinpeProgressInterval);
|
||||
return;
|
||||
}
|
||||
const elapsed = Date.now() - startTime;
|
||||
const stepIdx = Math.floor(elapsed / 5000) % rotatingSubtitles.length;
|
||||
if (stepText && stepText.textContent !== rotatingSubtitles[stepIdx]) {
|
||||
stepText.textContent = rotatingSubtitles[stepIdx];
|
||||
}
|
||||
}, 1000);
|
||||
|
||||
try {
|
||||
let verifiedData = null;
|
||||
let definitiveError = null;
|
||||
|
||||
for (let intento = 1; intento <= maxIntentos; intento++) {
|
||||
if (!sinpeIsPolling) break;
|
||||
|
||||
try {
|
||||
const res = await fetch('/api/sinpe/validar', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
estudiante_id: studentId,
|
||||
padre_usuario_id: currentUser ? currentUser.id : null,
|
||||
monto,
|
||||
codigo,
|
||||
comprobante: comprobante || null
|
||||
})
|
||||
});
|
||||
|
||||
const data = await res.json();
|
||||
if (data.verificado && data.success) {
|
||||
verifiedData = data;
|
||||
break;
|
||||
}
|
||||
if (data.error && !data.retry) {
|
||||
definitiveError = data;
|
||||
break;
|
||||
}
|
||||
} catch (pollErr) {
|
||||
console.warn(`[SINPE Retry Polling intento ${intento}]`, pollErr);
|
||||
}
|
||||
|
||||
if (intento < maxIntentos && sinpeIsPolling) {
|
||||
await new Promise(r => setTimeout(r, pollIntervalMs));
|
||||
}
|
||||
}
|
||||
|
||||
sinpeIsPolling = false;
|
||||
clearInterval(sinpeProgressInterval);
|
||||
|
||||
if (verifiedData && verifiedData.verificado) {
|
||||
if (window.sounds) window.sounds.playCoin();
|
||||
const nuevoSaldo = typeof verifiedData.saldo_nuevo === 'number'
|
||||
? verifiedData.saldo_nuevo
|
||||
: ((currentParentChild ? currentParentChild.saldo_colones : 0) + monto);
|
||||
|
||||
if (currentParentChild) {
|
||||
currentParentChild.saldo_colones = nuevoSaldo;
|
||||
renderActiveChildDetails(currentParentChild);
|
||||
}
|
||||
|
||||
const inputMonto = document.getElementById('inputParentSinpeMonto');
|
||||
const inputComp = document.getElementById('inputParentSinpeComprobante');
|
||||
if (inputMonto) inputMonto.value = '';
|
||||
if (inputComp) inputComp.value = '';
|
||||
|
||||
showSinpeModal('success', {
|
||||
studentName: studentName || (currentParentChild ? currentParentChild.nombre_completo : ''),
|
||||
monto,
|
||||
banco: verifiedData.banco || 'Bancario',
|
||||
comprobante: verifiedData.comprobante || verifiedData.codigo || codigo,
|
||||
codigo,
|
||||
nuevoSaldo
|
||||
});
|
||||
|
||||
if (currentParentChild) {
|
||||
await loadParentSinpeRequests(currentParentChild.id);
|
||||
}
|
||||
obtenerNuevoCodigoSinpe();
|
||||
return;
|
||||
}
|
||||
|
||||
if (definitiveError) {
|
||||
if (window.sounds) window.sounds.playError();
|
||||
showSinpeModal('error', {
|
||||
title: 'Comprobante no válido',
|
||||
message: definitiveError.message || definitiveError.error || 'El comprobante ya fue utilizado o los datos no corresponden a la transferencia.'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// Si después del minuto adicional aún no llega, pasamos a confirmación para revisión manual
|
||||
await confirmSinpeSendManualReview();
|
||||
|
||||
} catch (err) {
|
||||
sinpeIsPolling = false;
|
||||
clearInterval(sinpeProgressInterval);
|
||||
if (window.sounds) window.sounds.playError();
|
||||
showSinpeModal('error', {
|
||||
title: 'Error de conexión',
|
||||
message: `No se pudo conectar con el servidor: ${err.message}`
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async function confirmSinpeSendManualReview() {
|
||||
if (!currentSinpePollingData) return;
|
||||
const { studentId, studentName, monto, codigo, comprobante } = currentSinpePollingData;
|
||||
|
||||
sinpeIsPolling = false;
|
||||
clearInterval(sinpeProgressInterval);
|
||||
|
||||
if (window.sounds) window.sounds.playTap();
|
||||
|
||||
try {
|
||||
await fetch('/api/sinpe/solicitar', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
estudiante_id: studentId,
|
||||
padre_usuario_id: currentUser ? currentUser.id : null,
|
||||
monto,
|
||||
comprobante: comprobante || `SINPE-${codigo}`,
|
||||
codigo_detalle: codigo,
|
||||
notas: `Portal de Padres - Código: ${codigo}`
|
||||
})
|
||||
});
|
||||
} catch (solErr) {
|
||||
console.warn('Error al registrar solicitud:', solErr);
|
||||
}
|
||||
|
||||
const inputMonto = document.getElementById('inputParentSinpeMonto');
|
||||
const inputComp = document.getElementById('inputParentSinpeComprobante');
|
||||
if (inputMonto) inputMonto.value = '';
|
||||
if (inputComp) inputComp.value = '';
|
||||
|
||||
showSinpeModal('pending', {
|
||||
studentName: studentName || (currentParentChild ? currentParentChild.nombre_completo : ''),
|
||||
monto,
|
||||
codigo
|
||||
});
|
||||
|
||||
if (currentParentChild) {
|
||||
await loadParentSinpeRequests(currentParentChild.id);
|
||||
}
|
||||
obtenerNuevoCodigoSinpe();
|
||||
}
|
||||
|
||||
async function loadParentSinpeRequests(studentId) {
|
||||
const box = document.getElementById('parentSinpePendingBox');
|
||||
const list = document.getElementById('parentSinpePendingList');
|
||||
@@ -5002,21 +5159,28 @@ function setMovFilter(filter) {
|
||||
|
||||
[btnAll, btnRecargas, btnCobros, btnRechazados].forEach(b => {
|
||||
if (!b) return;
|
||||
b.classList.remove('active');
|
||||
b.style.background = 'transparent';
|
||||
b.style.color = '#64748b';
|
||||
b.style.boxShadow = 'none';
|
||||
b.style.fontWeight = '700';
|
||||
});
|
||||
|
||||
const activeBtn = filter === 'recargas' ? btnRecargas : (filter === 'cobros' ? btnCobros : (filter === 'rechazados' ? btnRechazados : btnAll));
|
||||
const isRechazadosTab = filter === 'rechazados' || filter === 'rechazado';
|
||||
const activeBtn = filter === 'recargas' ? btnRecargas : (filter === 'cobros' ? btnCobros : (isRechazadosTab ? btnRechazados : btnAll));
|
||||
if (activeBtn) {
|
||||
activeBtn.classList.add('active');
|
||||
activeBtn.style.background = '#ffffff';
|
||||
activeBtn.style.color = filter === 'rechazados' ? '#e11d48' : '#0284c7';
|
||||
activeBtn.style.color = isRechazadosTab ? '#e11d48' : '#0284c7';
|
||||
activeBtn.style.boxShadow = '0 1px 3px rgba(0,0,0,0.08)';
|
||||
activeBtn.style.fontWeight = '800';
|
||||
}
|
||||
|
||||
if (!adminMovimientosData || adminMovimientosData.length === 0) {
|
||||
loadAdminMovimientos();
|
||||
} else {
|
||||
renderAdminMovimientos();
|
||||
}
|
||||
if (window.sounds) window.sounds.playTap();
|
||||
}
|
||||
|
||||
@@ -5037,7 +5201,7 @@ function renderAdminMovimientos() {
|
||||
if (m.monto_colones <= 0 || m.tipo === 'compra_mostrador' || m.tipo === 'preorden' || m.tipo === 'sinpe_rechazado' || m.tipo === 'recarga_rechazada') return false;
|
||||
} else if (currentMovFilter === 'cobros') {
|
||||
if (m.monto_colones >= 0 && (m.tipo === 'recarga_manual' || m.tipo === 'recarga_sinpe' || m.tipo === 'sinpe_rechazado' || m.tipo === 'recarga_rechazada')) return false;
|
||||
} else if (currentMovFilter === 'rechazados') {
|
||||
} else if (currentMovFilter === 'rechazados' || currentMovFilter === 'rechazado') {
|
||||
if (m.tipo !== 'sinpe_rechazado' && m.tipo !== 'recarga_rechazada') return false;
|
||||
}
|
||||
|
||||
@@ -5054,11 +5218,22 @@ function renderAdminMovimientos() {
|
||||
});
|
||||
|
||||
if (filtered.length === 0) {
|
||||
const isRechazados = currentMovFilter === 'rechazados' || currentMovFilter === 'rechazado';
|
||||
container.innerHTML = `
|
||||
<div style="text-align: center; color: var(--text-muted); padding: 35px 20px; background: #f8fafc; border-radius: 14px; border: 1.5px dashed var(--border);">
|
||||
<div style="display: flex; justify-content: center; margin-bottom: 8px;"><svg width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" style="opacity: 0.4;"><circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/></svg></div>
|
||||
<p style="margin: 8px 0 2px 0; font-weight: 800; font-size: 0.95rem; color: var(--text-main);">No se encontraron movimientos</p>
|
||||
<span style="font-size: 0.78rem; color: var(--text-muted);">No hay registros que coincidan con el filtro o búsqueda actual.</span>
|
||||
<div style="display: flex; justify-content: center; margin-bottom: 8px;">
|
||||
<svg width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="${isRechazados ? '#e11d48' : 'currentColor'}" stroke-width="2" style="opacity: ${isRechazados ? '0.7' : '0.4'};">
|
||||
${isRechazados
|
||||
? '<circle cx="12" cy="12" r="10"/><line x1="15" y1="9" x2="9" y2="15"/><line x1="9" y1="9" x2="15" y2="15"/>'
|
||||
: '<circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/>'}
|
||||
</svg>
|
||||
</div>
|
||||
<p style="margin: 8px 0 2px 0; font-weight: 800; font-size: 0.95rem; color: var(--text-main);">
|
||||
${isRechazados ? 'No hay transferencias SINPE rechazadas' : 'No se encontraron movimientos'}
|
||||
</p>
|
||||
<span style="font-size: 0.78rem; color: var(--text-muted);">
|
||||
${isRechazados ? 'Todas las transferencias registradas han sido procesadas con éxito o están pendientes de revisión.' : 'No hay registros que coincidan con el filtro o búsqueda actual.'}
|
||||
</span>
|
||||
</div>
|
||||
`;
|
||||
return;
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
// RecreoPay PWA Service Worker v8.5 - Soporte Web Push VAPID en Segundo Plano
|
||||
const CACHE_NAME = 'recreopay-v8.5';
|
||||
// RecreoPay PWA Service Worker v8.6 - Soporte Web Push VAPID en Segundo Plano
|
||||
const CACHE_NAME = 'recreopay-v8.6';
|
||||
const STATIC_ASSETS = [
|
||||
'/',
|
||||
'/index.html',
|
||||
|
||||
Reference in New Issue
Block a user