feat: integrate Convex authentication across ticket management routes

- Added useConvexWithAuth hook to ensure authenticated access for ticket-related pages.
- Updated the perfil and central-chamados routes to include the authentication setup.
- Enhanced user navigation by adding a new "Meus Chamados" tab in the perfil page for better access to ticket management.
This commit is contained in:
2025-11-16 14:19:01 -03:00
parent 118051ad56
commit 24b8eb6a14
4 changed files with 38 additions and 0 deletions

View File

@@ -1,6 +1,7 @@
<script lang="ts">
import { useConvexClient, useQuery } from 'convex-svelte';
import { api } from '@sgse-app/backend/convex/_generated/api';
import { resolve } from '$app/paths';
import AprovarFerias from '$lib/components/AprovarFerias.svelte';
import WizardSolicitacaoFerias from '$lib/components/ferias/WizardSolicitacaoFerias.svelte';
import WizardSolicitacaoAusencia from '$lib/components/ausencias/WizardSolicitacaoAusencia.svelte';
@@ -603,6 +604,29 @@ const meusTimesGestor = $derived(timesSubordinados);
Minhas Ausências
</button>
<a
role="tab"
href={resolve('/perfil/chamados')}
class="tab tab-lg font-semibold transition-all duration-300 hover:bg-base-100"
aria-label="Meus Chamados"
>
<svg
xmlns="http://www.w3.org/2000/svg"
class="mr-2 h-5 w-5"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
stroke-width="2"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M3 7h18M3 12h12M3 17h18"
/>
</svg>
Meus Chamados
</a>
{#if ehGestor}
<button
type="button"

View File

@@ -14,6 +14,7 @@ import { chamadosStore } from "$lib/stores/chamados";
prazoRestante,
} from "$lib/utils/chamados";
import { resolve } from "$app/paths";
import { useConvexWithAuth } from "$lib/hooks/useConvexWithAuth";
type Ticket = Doc<"tickets">;
@@ -45,6 +46,10 @@ const ticketsFiltrados = $derived(
onMount(() => {
carregarChamados();
});
$effect(() => {
// Configura o token de autenticação no cliente Convex
useConvexWithAuth();
});
async function carregarChamados() {
try {