Use $app/paths resolve for internal URLs and clean code```

This commit is contained in:
2025-11-12 20:00:01 -03:00
parent 34e4835c81
commit a2451baafc
2 changed files with 37 additions and 24 deletions

23
AGENTS.md Normal file
View File

@@ -0,0 +1,23 @@
You are able to use the Svelte MCP server, where you have access to comprehensive Svelte 5 and SvelteKit documentation. Here's how to use the available tools effectively:
## Available MCP Tools:
### 1. list-sections
Use this FIRST to discover all available documentation sections. Returns a structured list with titles, use_cases, and paths.
When asked about Svelte or SvelteKit topics, ALWAYS use this tool at the start of the chat to find relevant sections.
### 2. get-documentation
Retrieves full documentation content for specific sections. Accepts single or multiple sections.
After calling the list-sections tool, you MUST analyze the returned documentation sections (especially the use_cases field) and then use the get-documentation tool to fetch ALL documentation sections that are relevant for the user's task.
### 3. svelte-autofixer
Analyzes Svelte code and returns issues and suggestions.
You MUST use this tool whenever writing Svelte code before sending it to the user. Keep calling it until no issues or suggestions are returned.
### 4. playground-link
Generates a Svelte Playground link with the provided code.
After completing the code, ask the user if they want a playground link. Only call this tool after user confirmation and NEVER if code was written to files in their project.

View File

@@ -2,6 +2,7 @@
import { useQuery, useConvexClient } from 'convex-svelte';
import { api } from '@sgse-app/backend/convex/_generated/api';
import { goto } from '$app/navigation';
import { resolve } from '$app/paths';
import type { Id } from '@sgse-app/backend/convex/_generated/dataModel';
import ProtectedRoute from '$lib/components/ProtectedRoute.svelte';
@@ -9,18 +10,6 @@
const roles = useQuery(api.roles.listar, {});
const funcionarios = useQuery(api.funcionarios.getAll, {});
// Debug - Remover após teste
$effect(() => {
console.log('=== DEBUG PERFIS ===');
console.log('roles:', roles);
console.log('roles?.data:', roles?.data);
console.log('É array?', Array.isArray(roles?.data));
if (roles?.data) {
console.log('Quantidade de perfis:', roles.data.length);
console.log('Perfis:', roles.data);
}
});
// Estados do formulário
let nome = $state('');
let email = $state('');
@@ -75,19 +64,20 @@
`Usuário criado! SENHA TEMPORÁRIA: ${senhaGerada} - Anote esta senha, ela não será exibida novamente!`
);
setTimeout(() => {
goto('/ti/usuarios');
goto(resolve('/ti/usuarios'));
}, 5000);
} else {
mostrarMensagem('success', 'Usuário criado com sucesso!');
setTimeout(() => {
goto('/ti/usuarios');
goto(resolve('/ti/usuarios'));
}, 2000);
}
} else {
mostrarMensagem('error', resultado.erro);
}
} catch (error: any) {
mostrarMensagem('error', error.message || 'Erro ao criar usuário');
} catch (error: unknown) {
const message = error instanceof Error ? error.message : String(error);
mostrarMensagem('error', message || 'Erro ao criar usuário');
} finally {
processando = false;
}
@@ -99,7 +89,7 @@
// Auto-completar ao selecionar funcionário
$effect(() => {
if (funcionarioId && funcionarios?.data) {
const funcSelecionado = funcionarios.data.find((f: any) => f._id === funcionarioId);
const funcSelecionado = funcionarios.data.find((f) => f._id === funcionarioId);
if (funcSelecionado) {
email = funcSelecionado.email || email;
nome = funcSelecionado.nome || nome;
@@ -154,7 +144,7 @@
<p class="text-base-content/60 mt-1">Cadastre um novo usuário no sistema</p>
</div>
</div>
<a href="/ti/usuarios" class="btn btn-outline btn-primary gap-2">
<a href={resolve('/ti/usuarios')} class="btn btn-outline btn-primary gap-2">
<svg
xmlns="http://www.w3.org/2000/svg"
class="h-5 w-5"
@@ -177,8 +167,8 @@
<!-- Breadcrumbs -->
<div class="breadcrumbs mb-6 text-sm">
<ul>
<li><a href="/ti/painel-administrativo">Dashboard TI</a></li>
<li><a href="/ti/usuarios">Usuários</a></li>
<li><a href={resolve('/ti/painel-administrativo')}>Dashboard TI</a></li>
<li><a href={resolve('/ti/usuarios')}>Usuários</a></li>
<li>Criar Usuário</li>
</ul>
</div>
@@ -254,7 +244,7 @@
>
<option value="">Selecione um funcionário para auto-completar dados</option>
{#if funcionarios?.data}
{#each funcionarios.data as func}
{#each funcionarios.data as func (func._id)}
<option value={func._id}>{func.nome} - Mat: {func.matricula}</option>
{/each}
{/if}
@@ -312,7 +302,7 @@
>
<option value="">Selecione um perfil</option>
{#if roles?.data && Array.isArray(roles.data)}
{#each roles.data as role}
{#each roles.data as role (role._id)}
<option value={role._id}>
{role.descricao} ({role.nome})
</option>
@@ -484,7 +474,7 @@
<li>O usuário deverá alterar a senha no primeiro acesso</li>
<li>As credenciais devem ser repassadas manualmente (por enquanto)</li>
<li>
Configure o SMTP em <a href="/ti/configuracoes-email" class="link"
Configure o SMTP em <a href={resolve('/ti/configuracoes-email')} class="link"
>Configurações de Email</a
> para envio automático
</li>
@@ -493,7 +483,7 @@
</div>
<div class="card-actions border-base-300 mt-8 justify-end border-t pt-6">
<a href="/ti/usuarios" class="btn gap-2" class:btn-disabled={processando}>
<a href={resolve('/ti/usuarios')} class="btn gap-2" class:btn-disabled={processando}>
<svg
xmlns="http://www.w3.org/2000/svg"
class="h-5 w-5"