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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user