From a2451baafc70cac562db6f2ef7957e022ed25d6f Mon Sep 17 00:00:00 2001 From: killer-cf Date: Wed, 12 Nov 2025 20:00:01 -0300 Subject: [PATCH] Use $app/paths resolve for internal URLs and clean code``` --- AGENTS.md | 23 +++++++++++ .../ti/usuarios/criar/+page.svelte | 38 +++++++------------ 2 files changed, 37 insertions(+), 24 deletions(-) create mode 100644 AGENTS.md diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..a6e66ff --- /dev/null +++ b/AGENTS.md @@ -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. diff --git a/apps/web/src/routes/(dashboard)/ti/usuarios/criar/+page.svelte b/apps/web/src/routes/(dashboard)/ti/usuarios/criar/+page.svelte index de91390..4b5bf41 100644 --- a/apps/web/src/routes/(dashboard)/ti/usuarios/criar/+page.svelte +++ b/apps/web/src/routes/(dashboard)/ti/usuarios/criar/+page.svelte @@ -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 @@

Cadastre um novo usuário no sistema

- + @@ -254,7 +244,7 @@ > {#if funcionarios?.data} - {#each funcionarios.data as func} + {#each funcionarios.data as func (func._id)} {/each} {/if} @@ -312,7 +302,7 @@ > {#if roles?.data && Array.isArray(roles.data)} - {#each roles.data as role} + {#each roles.data as role (role._id)} @@ -484,7 +474,7 @@
  • O usuário deverá alterar a senha no primeiro acesso
  • As credenciais devem ser repassadas manualmente (por enquanto)
  • - Configure o SMTP em Configurações de Email para envio automático
  • @@ -493,7 +483,7 @@
    - +