Fix pre-servicios preview: clear store once, clean row HTML structure

- Move _rdaJsonStore={} reset to before both sections so ps-json-* keys
  are not wiped when pacientes section renders
- Replace divide-y wrapper divs with explicit border-b on each row,
  eliminating duplicate/misplaced dividers in the pre-servicios list

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Lizandro Guarnizo
2026-07-11 09:18:58 -05:00
co-authored by Claude Sonnet 4.6
parent c4c6a2cd35
commit c18da17317
+4 -4
View File
@@ -209,6 +209,7 @@ async function previewAutomation() {
if (!data.success) { showToast(data.message || 'Error al consultar', 'error'); return; } if (!data.success) { showToast(data.message || 'Error al consultar', 'error'); return; }
_previewData = data; _previewData = data;
_rdaJsonStore = {};
document.getElementById('cnt-pacientes').textContent = data.pacientes; document.getElementById('cnt-pacientes').textContent = data.pacientes;
document.getElementById('cnt-recepciones').textContent = data.recepciones; document.getElementById('cnt-recepciones').textContent = data.recepciones;
document.getElementById('cnt-examenes').textContent = data.examenes; document.getElementById('cnt-examenes').textContent = data.examenes;
@@ -222,8 +223,8 @@ async function previewAutomation() {
const key = `ps-json-${i}`; const key = `ps-json-${i}`;
_rdaJsonStore[key] = ps.json; _rdaJsonStore[key] = ps.json;
return ` return `
<div class="divide-y divide-orange-50"> <div>
<div class="flex items-center gap-3 px-4 py-2.5 hover:bg-orange-50 cursor-pointer select-none" <div class="flex items-center gap-3 px-4 py-2.5 hover:bg-orange-50 cursor-pointer select-none border-b border-orange-100"
onclick="togglePs('${key}', this)"> onclick="togglePs('${key}', this)">
<i class="fas fa-chevron-right text-orange-300 text-xs transition-transform duration-150" id="pschev-${i}"></i> <i class="fas fa-chevron-right text-orange-300 text-xs transition-transform duration-150" id="pschev-${i}"></i>
<span class="font-mono text-orange-700 font-medium w-32">${ps.factura}</span> <span class="font-mono text-orange-700 font-medium w-32">${ps.factura}</span>
@@ -231,7 +232,7 @@ async function previewAutomation() {
<span class="text-gray-600 flex-1 text-xs">Pac. ${ps.paciente}</span> <span class="text-gray-600 flex-1 text-xs">Pac. ${ps.paciente}</span>
<span class="text-xs text-orange-500">${ps.examenes} examen(es)</span> <span class="text-xs text-orange-500">${ps.examenes} examen(es)</span>
</div> </div>
<div id="${key}" class="hidden bg-gray-900 text-green-300 text-xs font-mono p-4 overflow-x-auto whitespace-pre"></div> <div id="${key}" class="hidden bg-gray-900 text-green-300 text-xs font-mono p-4 overflow-x-auto whitespace-pre border-b border-orange-100"></div>
</div>`; </div>`;
}).join(''); }).join('');
psSection.classList.remove('hidden'); psSection.classList.remove('hidden');
@@ -244,7 +245,6 @@ async function previewAutomation() {
table.innerHTML = '<div class="p-4 text-gray-400 text-center">No hay pacientes para esta fecha</div>'; table.innerHTML = '<div class="p-4 text-gray-400 text-center">No hay pacientes para esta fecha</div>';
showToast('No hay datos para esa fecha', 'warning'); showToast('No hay datos para esa fecha', 'warning');
} else { } else {
_rdaJsonStore = {};
table.innerHTML = data.pacientes_preview.map((p, i) => { table.innerHTML = data.pacientes_preview.map((p, i) => {
const rdaRows = p.rda.map((r, j) => { const rdaRows = p.rda.map((r, j) => {
const key = `rda-json-${i}-${j}`; const key = `rda-json-${i}-${j}`;