Files
cataRio/nuxt4/app/components/auth/GroupCheckButton.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

111 lines
2.6 KiB
Vue

<template>
<UButton
:color="color"
:size="size"
:variant="variant"
:loading="loading"
@click="handleClick"
class="group-check-button"
>
<template #leading>
<UIcon :name="icon" />
</template>
<slot>{{ label }}</slot>
</UButton>
</template>
<script setup lang="ts">
interface Props {
groupName: string
label?: string
icon?: string
color?: 'primary' | 'secondary' | 'success' | 'info' | 'warning' | 'error' | 'neutral'
variant?: 'solid' | 'outline' | 'soft' | 'ghost' | 'link' | 'subtle'
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl'
verifyBackend?: boolean
}
const props = withDefaults(defineProps<Props>(), {
label: 'Verificar Grupo',
icon: 'i-heroicons-shield-check',
color: 'primary',
variant: 'soft',
size: 'lg',
verifyBackend: false
})
const { hasGroup, checkGroupBackend } = useAuthentik()
const toast = useToast()
const loading = ref(false)
const handleClick = async () => {
loading.value = true
try {
if (props.verifyBackend) {
// Verificación backend
const hasAccess = await checkGroupBackend(props.groupName)
if (hasAccess) {
toast.add({
title: 'Acceso Permitido (Backend)',
description: `Perteneces al grupo: ${props.groupName}`,
color: 'success',
icon: 'i-heroicons-check-circle'
})
} else {
toast.add({
title: 'Acceso Denegado (Backend)',
description: `No perteneces al grupo: ${props.groupName}`,
color: 'error',
icon: 'i-heroicons-x-circle'
})
}
} else {
// Verificación frontend
const hasAccess = hasGroup(props.groupName)
if (hasAccess) {
toast.add({
title: 'Acceso Permitido (Frontend)',
description: `Perteneces al grupo: ${props.groupName}`,
color: 'success',
icon: 'i-heroicons-check-circle'
})
} else {
toast.add({
title: 'Acceso Denegado (Frontend)',
description: `No perteneces al grupo: ${props.groupName}`,
color: 'error',
icon: 'i-heroicons-x-circle'
})
}
}
} catch (error) {
toast.add({
title: 'Error de Verificación',
description: 'No se pudo verificar el grupo',
color: 'error',
icon: 'i-heroicons-exclamation-triangle'
})
console.error('Group check error:', error)
} finally {
loading.value = false
}
}
</script>
<style scoped>
.group-check-button {
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.group-check-button:hover {
transform: translateY(-2px);
}
.group-check-button:active {
transform: translateY(0);
}
</style>