Agregar botones de debug temporales para gestión de BD
All checks were successful
build-and-deploy / build-and-deploy (push) Successful in 16s

⚠️ CÓDIGO TEMPORAL - NO ELIMINAR SIN CONSULTAR ⚠️

Backend:
- POST /api/debug/reset-database - Borra todos los datos
- POST /api/debug/seed-database - Carga datos de ejemplo

Frontend:
- Card rojo con advertencias notorias
- Botones: 🗑️ BORRAR TODA LA BD y 🌱 CARGAR DATOS DE EJEMPLO
- Confirmación antes de resetear
- Estados de loading
- Alertas de éxito/error

Todos los archivos marcados con comentarios muy visibles:
⚠️⚠️⚠️ NO ELIMINAR SIN CONSULTAR A DARIO/DRAGANEL/NUCLEO000 ⚠️⚠️⚠️

Útil para desarrollo y debugging del sistema de trazabilidad.
This commit is contained in:
2025-11-21 19:43:04 -06:00
parent 0f8891f77d
commit 3a1c3fb7a2
3 changed files with 202 additions and 0 deletions

View File

@@ -37,6 +37,44 @@
</p>
</UCard>
<!-- BOTONES DE DEBUG - TEMPORALES -->
<!-- NO ELIMINAR SIN CONSULTAR A DARIO/DRAGANEL/NUCLEO000 -->
<UCard class="mb-4 border-2 border-red-500 bg-red-50 dark:bg-red-950">
<div class="flex items-center gap-2 mb-3">
<UIcon name="i-heroicons-exclamation-triangle" class="w-6 h-6 text-red-600" />
<h3 class="text-lg font-bold text-red-600">
DEBUG - BOTONES TEMPORALES
</h3>
</div>
<p class="text-sm text-red-700 dark:text-red-400 mb-3">
<strong>ADVERTENCIA:</strong> Estos botones modifican la base de datos directamente.
<br />
<strong>NO ELIMINAR</strong> este código sin consultar a Dario/Draganel/nucleo000.
</p>
<div class="flex gap-2 flex-wrap">
<UButton
@click="resetDatabase"
color="red"
variant="solid"
:loading="resettingDB"
>
🗑 BORRAR TODA LA BD
</UButton>
<UButton
@click="seedDatabase"
color="orange"
variant="solid"
:loading="seedingDB"
>
🌱 CARGAR DATOS DE EJEMPLO
</UButton>
</div>
<p class="text-xs text-red-600 dark:text-red-400 mt-2">
Resultados en consola (F12). Recarga la página después de usar estos botones.
</p>
</UCard>
<!-- FIN BOTONES DE DEBUG -->
<!-- Contenido principal -->
<div v-if="isAuthenticated">
<!-- Navegación por Tabs -->
@@ -189,6 +227,62 @@ const handleOperacionFormSuccess = () => {
// Las tablas se recargarán automáticamente
}
// ⚠️⚠️⚠️ FUNCIONES DE DEBUG - TEMPORALES ⚠️⚠️⚠️
// NO ELIMINAR SIN CONSULTAR A DARIO/DRAGANEL/NUCLEO000
const resettingDB = ref(false)
const seedingDB = ref(false)
const resetDatabase = async () => {
if (!confirm('⚠️ ADVERTENCIA: Esto BORRARÁ TODOS LOS DATOS de la base de datos.\n\n¿Estás seguro de continuar?')) {
return
}
console.log('🗑️ === RESETEANDO BASE DE DATOS ===')
resettingDB.value = true
try {
const response = await fetch('/api/debug/reset-database', {
method: 'POST',
})
const data = await response.json()
console.log('Status:', response.status)
console.log('Respuesta:', data)
if (data.success) {
alert('✅ Base de datos reseteada exitosamente.\n\nRecarga la página para ver los cambios.')
}
} catch (error) {
console.error('❌ Error:', error)
alert('❌ Error reseteando la base de datos. Ver consola.')
} finally {
resettingDB.value = false
}
}
const seedDatabase = async () => {
console.log('🌱 === CARGANDO DATOS DE EJEMPLO ===')
seedingDB.value = true
try {
const response = await fetch('/api/debug/seed-database', {
method: 'POST',
})
const data = await response.json()
console.log('Status:', response.status)
console.log('Respuesta:', data)
if (data.success) {
alert('✅ Datos de ejemplo cargados exitosamente.\n\nRecarga la página para ver los cambios.')
}
} catch (error) {
console.error('❌ Error:', error)
alert('❌ Error cargando datos. Ver consola.')
} finally {
seedingDB.value = false
}
}
// ⚠️⚠️⚠️ FIN FUNCIONES DE DEBUG ⚠️⚠️⚠️
// Funciones de prueba de API
const testGetLotes = async () => {
console.log('=== Probando GET /api/lotes ===')