refactor: replace useMutation with useConvexClient for API calls in LGPD-related pages to streamline data handling and improve consistency across components

This commit is contained in:
2025-12-02 09:55:28 -03:00
parent e460b114ed
commit 0c507f41da
6 changed files with 25 additions and 26 deletions

View File

@@ -2,7 +2,7 @@
import { resolve } from '$app/paths';
import { page } from '$app/state';
import { Shield, CheckCircle, AlertCircle, FileText } from 'lucide-svelte';
import { useQuery, useMutation } from 'convex-svelte';
import { useQuery, useConvexClient } from 'convex-svelte';
import { api } from '@sgse-app/backend/convex/_generated/api';
let aceito = $state(false);
@@ -11,8 +11,8 @@
let sucesso = $state(false);
// Verificar se já aceitou o termo
const client = useConvexClient();
const consentimentoQuery = useQuery(api.lgpd.verificarConsentimento, { tipo: 'termo_uso' });
const registrarConsentimento = useMutation(api.lgpd.registrarConsentimento);
const jaAceitou = $derived(
consentimentoQuery?.data?.aceito === true &&
@@ -34,7 +34,7 @@
}
}
async function aceitarTermo() {
async function aceitarTermo() {
if (termoObrigatorio && !aceito) {
erro = 'Você precisa aceitar o termo para continuar';
return;
@@ -50,7 +50,7 @@
erro = null;
try {
await registrarConsentimento({
await client.mutation(api.lgpd.registrarConsentimento, {
tipo: 'termo_uso',
aceito: true,
versao: versaoTermoAtual