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:
@@ -1,12 +1,12 @@
|
||||
<script lang="ts">
|
||||
import { resolve } from '$app/paths';
|
||||
import { useQuery, useMutation } from 'convex-svelte';
|
||||
import { useQuery, useConvexClient } from 'convex-svelte';
|
||||
import { api } from '@sgse-app/backend/convex/_generated/api';
|
||||
import { Shield, Save, Mail, Phone, User, Calendar, ToggleLeft, ToggleRight } from 'lucide-svelte';
|
||||
import { toast } from 'svelte-sonner';
|
||||
|
||||
const client = useConvexClient();
|
||||
const config = useQuery(api.lgpd.obterConfiguracaoLGPD, {});
|
||||
const atualizarConfig = useMutation(api.lgpd.atualizarConfiguracaoLGPD);
|
||||
|
||||
let encarregadoNome = $state('');
|
||||
let encarregadoEmail = $state('');
|
||||
@@ -36,7 +36,7 @@
|
||||
carregando = true;
|
||||
|
||||
try {
|
||||
await atualizarConfig({
|
||||
await client.mutation(api.lgpd.atualizarConfiguracaoLGPD, {
|
||||
encarregadoNome: encarregadoNome || undefined,
|
||||
encarregadoEmail: encarregadoEmail || undefined,
|
||||
encarregadoTelefone: encarregadoTelefone || undefined,
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
<script lang="ts">
|
||||
import { resolve } from '$app/paths';
|
||||
import { useQuery, useMutation } from 'convex-svelte';
|
||||
import { useQuery, useConvexClient } from 'convex-svelte';
|
||||
import { api } from '@sgse-app/backend/convex/_generated/api';
|
||||
import { Shield, FileText, Plus, CheckCircle, XCircle } from 'lucide-svelte';
|
||||
import { format } from 'date-fns';
|
||||
import { ptBR } from 'date-fns/locale';
|
||||
import { toast } from 'svelte-sonner';
|
||||
|
||||
const client = useConvexClient();
|
||||
const registros = useQuery(api.lgpd.listarRegistrosTratamento, { ativo: undefined });
|
||||
|
||||
let mostrarFormulario = $state(false);
|
||||
let mostrarFormulario = $state(false);
|
||||
let finalidade = $state('');
|
||||
let baseLegal = $state('');
|
||||
let categoriasDados = $state<string[]>([]);
|
||||
@@ -21,8 +22,6 @@
|
||||
let descricao = $state('');
|
||||
let carregando = $state(false);
|
||||
|
||||
const criarROT = useMutation(api.lgpd.criarRegistroTratamento);
|
||||
|
||||
const categoriasDadosDisponiveis = [
|
||||
'dados_identificacao',
|
||||
'dados_contato',
|
||||
@@ -63,7 +62,7 @@
|
||||
carregando = true;
|
||||
|
||||
try {
|
||||
await criarROT({
|
||||
await client.mutation(api.lgpd.criarRegistroTratamento, {
|
||||
finalidade: finalidade.trim(),
|
||||
baseLegal: baseLegal.trim(),
|
||||
categoriasDados,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { resolve } from '$app/paths';
|
||||
import { useQuery, useMutation } from 'convex-svelte';
|
||||
import { useQuery, useConvexClient } from 'convex-svelte';
|
||||
import { api } from '@sgse-app/backend/convex/_generated/api';
|
||||
import type { Id } from '@sgse-app/backend/convex/_generated/dataModel';
|
||||
import {
|
||||
@@ -31,11 +31,11 @@
|
||||
let tipoFiltro = $state<TipoFiltro>(null);
|
||||
let termoBusca = $state('');
|
||||
|
||||
const client = useConvexClient();
|
||||
const solicitacoes = useQuery(api.lgpd.listarSolicitacoes, {
|
||||
status: statusFiltro || undefined,
|
||||
tipo: tipoFiltro || undefined
|
||||
});
|
||||
const responderSolicitacao = useMutation(api.lgpd.responderSolicitacao);
|
||||
|
||||
let solicitacaoSelecionada = $state<string | null>(null);
|
||||
let resposta = $state('');
|
||||
@@ -106,7 +106,7 @@
|
||||
carregando = true;
|
||||
|
||||
try {
|
||||
await responderSolicitacao({
|
||||
await client.mutation(api.lgpd.responderSolicitacao, {
|
||||
solicitacaoId: solicitacaoSelecionada as Id<'solicitacoesLGPD'>,
|
||||
resposta: resposta.trim(),
|
||||
status: statusResposta
|
||||
|
||||
Reference in New Issue
Block a user