Files
cataRio/nuxt4/app/components/auth/BackendVerificationButton.vue
josedario87 599cb24f8d Fix: Resolver todos los errores de TypeScript
ERRORES RESUELTOS:

1. Colores de botones inválidos → colores válidos:
   - 'orange' → 'warning' (BackendVerificationButton)
   - 'purple' → 'primary' (FrontendVerificationButton)
   - 'red' → 'error' (CheckAuthentikAdminsButton)
   - 'blue' → 'info' (CheckGrupoPruebaButton)
   - 'green' → 'success' (CheckLvl0Button)
   - 'gray' → 'neutral' (CheckPublicAccessButton, UserMetadata)

2. Tipos no exportados en Nuxt UI v4:
   - Removidos imports: ButtonColor, ButtonVariant, ButtonSize
   - Reemplazados con tipos literales inline
   - Removido 'none' de variant (no válido en v4)

3. Subcategoria puede ser null:
   - FormularioMuestra: tipo cambiado a Exclude<Subcategoria, null>
   - sesion.vue: agregado ?? 'null' para key y guards para null

4. process.client no definido:
   - useCatacion.ts: process.client → import.meta.client (2 lugares)
   - Nuxt 4 usa import.meta.client en lugar de process.client

5. process.env en nuxt.config.ts:
   - Removido process.env.NUXT_PUBLIC_AUTHENTIK_URL
   - Nuxt runtimeConfig lee automáticamente de .env
   - Solo valor por defecto necesario

6. Propiedades no válidas en PWA manifest:
   - Removido: capture_links (no existe en ManifestOptions)
   - Removido: url_handlers (no existe en ManifestOptions)
   - Removido: handle_links (no existe en ManifestOptions)

7. Toast props no válidas:
   - Removido: timeout (no existe en Toast type)
   - BackendVerificationButton y FrontendVerificationButton

RESULTADO:
 npx nuxi typecheck pasa sin errores
 Solo warnings de @nuxt/content (no críticos)
2025-10-19 03:14:14 -06:00

82 lines
2.0 KiB
Vue

<template>
<UButton
color="warning"
size="lg"
variant="outline"
:loading="loading"
@click="handleClick"
class="verification-button"
>
<template #leading>
<UIcon name="i-heroicons-server" />
</template>
Verificación Backend
</UButton>
</template>
<script setup lang="ts">
const toast = useToast()
const loading = ref(false)
const handleClick = async () => {
loading.value = true
try {
// Consultar el endpoint que lee los headers del servidor
const response = await $fetch<{
authenticated: boolean
user?: {
username: string
groups: string[]
}
}>('/api/auth/status')
if (response.authenticated && response.user) {
const groupCount = response.user.groups.length
const groupList = response.user.groups.join(', ') || 'Ninguno'
toast.add({
title: 'Verificación Backend',
description: `Usuario: ${response.user.username}
Grupos (${groupCount}): ${groupList}`,
color: 'warning',
icon: 'i-heroicons-server-stack'
})
} else {
toast.add({
title: 'No Autenticado (Backend)',
description: 'No hay sesión activa en el servidor',
color: 'warning',
icon: 'i-heroicons-exclamation-triangle'
})
}
} catch (error) {
toast.add({
title: 'Error Backend',
description: 'No se pudo verificar en el servidor',
color: 'error',
icon: 'i-heroicons-x-circle'
})
console.error('Backend verification error:', error)
} finally {
loading.value = false
}
}
</script>
<style scoped>
.verification-button {
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
box-shadow: 0 4px 6px -1px rgba(249, 115, 22, 0.1), 0 2px 4px -1px rgba(249, 115, 22, 0.06);
}
.verification-button:hover {
transform: translateY(-2px) scale(1.02);
box-shadow: 0 10px 15px -3px rgba(249, 115, 22, 0.2), 0 4px 6px -2px rgba(249, 115, 22, 0.1);
}
.verification-button:active {
transform: translateY(0) scale(0.98);
}
</style>