Correcion con vite, borrar los print y mejorar la barra de manuales

This commit is contained in:
2026-05-07 11:41:44 -05:00
parent d325218d27
commit beaf9b2f8e
5 changed files with 32 additions and 304 deletions

View File

@@ -33,6 +33,8 @@
let isLoading = $state(false);
let isCreating = $state(false);
let searchTerm = $state('');
let hasError = $state(false);
let isLoaded = $state(false);
const isAdmin = $derived($currentUser?.roles?.includes('admin') || false);
const currentPath = $derived(page.url.pathname + page.url.search);
@@ -155,8 +157,11 @@
async function loadArticles() {
isLoading = true;
try {
hasError = false;
articles = await helpApi.listArticles();
isLoaded = true;
} catch (e) {
hasError = true;
toast.error('Error al cargar artículos de ayuda');
} finally {
isLoading = false;
@@ -222,9 +227,14 @@
}
$effect(() => {
if (helpStore.isOpen && articles.length === 0 && !isLoading) {
if (helpStore.isOpen && !isLoaded && !isLoading && !hasError) {
loadArticles();
}
// Reset error when drawer closes to allow retry next time it opens
if (!helpStore.isOpen) {
hasError = false;
}
});
function renderMarkdown(content: string) {
@@ -336,10 +346,20 @@
<BookOpen size={24} class="text-muted-foreground/40" />
</div>
<div class="space-y-1">
<p class="text-sm font-medium">Biblioteca vacía</p>
<p class="text-xs text-muted-foreground">No hay artículos registrados en el sistema aún.</p>
<p class="text-sm font-medium">
{hasError ? 'Error de conexión' : 'Biblioteca vacía'}
</p>
<p class="text-xs text-muted-foreground">
{hasError
? 'No pudimos conectar con el servidor de ayuda.'
: 'No hay artículos registrados para esta sección aún.'}
</p>
</div>
{#if isAdmin}
{#if hasError}
<Button variant="outline" size="sm" onclick={loadArticles} class="mt-2 h-8">
Reintentar
</Button>
{:else if isAdmin}
<Button variant="outline" size="sm" onclick={startCreate} class="mt-2 h-8">
<Plus size={14} class="mr-1" /> Crear primero
</Button>