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:
@@ -7,6 +7,7 @@
|
||||
import TicketTimeline from "$lib/components/chamados/TicketTimeline.svelte";
|
||||
import { chamadosStore } from "$lib/stores/chamados";
|
||||
import { resolve } from "$app/paths";
|
||||
import { useConvexWithAuth } from "$lib/hooks/useConvexWithAuth";
|
||||
|
||||
type Ticket = Doc<"tickets">;
|
||||
type SlaConfig = Doc<"slaConfigs">;
|
||||
@@ -45,6 +46,11 @@
|
||||
carregarSlaConfigs();
|
||||
});
|
||||
|
||||
$effect(() => {
|
||||
// Garante que o cliente Convex use o token do usuário logado
|
||||
useConvexWithAuth();
|
||||
});
|
||||
|
||||
async function carregarSlaConfigs() {
|
||||
try {
|
||||
carregandoSla = true;
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
getStatusLabel,
|
||||
prazoRestante,
|
||||
} from "$lib/utils/chamados";
|
||||
import { useConvexWithAuth } from "$lib/hooks/useConvexWithAuth";
|
||||
|
||||
type Ticket = Doc<"tickets">;
|
||||
type Usuario = Doc<"usuarios">;
|
||||
@@ -60,6 +61,8 @@
|
||||
});
|
||||
|
||||
onMount(() => {
|
||||
// Configura token no cliente Convex
|
||||
useConvexWithAuth();
|
||||
if (slaConfigsQuery?.data && slaConfigsQuery.data.length > 0) {
|
||||
selecionarSla(slaConfigsQuery.data[0]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user