feat: enhance LGPD compliance features by adding configurable data protection officer details, consent term settings, and improved error handling across various components
This commit is contained in:
@@ -1,6 +1,15 @@
|
||||
<script lang="ts">
|
||||
import { resolve } from '$app/paths';
|
||||
import { Shield, FileText, Mail, Phone, Calendar } from 'lucide-svelte';
|
||||
import { useQuery } from 'convex-svelte';
|
||||
import { api } from '@sgse-app/backend/convex/_generated/api';
|
||||
|
||||
const configLGPD = useQuery(api.lgpd.obterConfiguracaoLGPD, {});
|
||||
|
||||
const encarregadoNome = $derived(configLGPD?.data?.encarregadoNome || 'Encarregado de Proteção de Dados');
|
||||
const encarregadoEmail = $derived(configLGPD?.data?.encarregadoEmail || 'lgpd@esportes.pe.gov.br');
|
||||
const encarregadoTelefone = $derived(configLGPD?.data?.encarregadoTelefone || '(81) 3184-XXXX');
|
||||
const encarregadoHorario = $derived(configLGPD?.data?.encarregadoHorarioAtendimento || 'Segunda a Sexta, das 8h às 17h');
|
||||
</script>
|
||||
|
||||
<div class="container mx-auto px-4 py-8 max-w-4xl">
|
||||
@@ -360,31 +369,40 @@
|
||||
entre em contato com nosso Encarregado de Proteção de Dados:
|
||||
</p>
|
||||
<div class="bg-primary/5 p-6 rounded-lg space-y-3">
|
||||
{#if encarregadoNome && encarregadoNome !== 'Encarregado de Proteção de Dados'}
|
||||
<div class="flex items-center gap-3">
|
||||
<FileText class="h-5 w-5 text-primary" />
|
||||
<div>
|
||||
<p class="text-sm font-semibold">Nome</p>
|
||||
<p class="text-base-content/70">{encarregadoNome}</p>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
<div class="flex items-center gap-3">
|
||||
<Mail class="h-5 w-5 text-primary" />
|
||||
<div>
|
||||
<p class="text-sm font-semibold">E-mail</p>
|
||||
<p class="text-base-content/70">lgpd@esportes.pe.gov.br</p>
|
||||
<p class="text-base-content/70">{encarregadoEmail}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-center gap-3">
|
||||
<Phone class="h-5 w-5 text-primary" />
|
||||
<div>
|
||||
<p class="text-sm font-semibold">Telefone</p>
|
||||
<p class="text-base-content/70">(81) 3184-XXXX</p>
|
||||
<p class="text-base-content/70">{encarregadoTelefone}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-center gap-3">
|
||||
<FileText class="h-5 w-5 text-primary" />
|
||||
<div>
|
||||
<p class="text-sm font-semibold">Horário de Atendimento</p>
|
||||
<p class="text-base-content/70">Segunda a Sexta, das 8h às 17h</p>
|
||||
<p class="text-base-content/70">{encarregadoHorario}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="alert alert-info mt-4">
|
||||
<p class="text-sm">
|
||||
As solicitações serão respondidas em até 15 (quinze) dias, conforme previsto na
|
||||
As solicitações serão respondidas em até {configLGPD?.data?.prazoRespostaPadrao || 15} (quinze) dias, conforme previsto na
|
||||
LGPD.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@@ -115,8 +115,9 @@
|
||||
tipoSelecionado = null;
|
||||
dadosSolicitados = '';
|
||||
observacoes = '';
|
||||
} catch (error: any) {
|
||||
toast.error(error.message || 'Erro ao criar solicitação');
|
||||
} catch (error: unknown) {
|
||||
const message = error instanceof Error ? error.message : 'Erro ao criar solicitação';
|
||||
toast.error(message);
|
||||
} finally {
|
||||
carregando = false;
|
||||
}
|
||||
|
||||
@@ -14,15 +14,25 @@
|
||||
const registrarConsentimento = useMutation(api.lgpd.registrarConsentimento);
|
||||
|
||||
const jaAceitou = $derived(
|
||||
consentimentoQuery?.data?.aceito === true && consentimentoQuery?.data?.versao === '1.0'
|
||||
consentimentoQuery?.data?.aceito === true &&
|
||||
consentimentoQuery?.data?.versao === consentimentoQuery?.data?.versaoTermoAtual
|
||||
);
|
||||
|
||||
const termoObrigatorio = $derived(consentimentoQuery?.data?.termoObrigatorio ?? false);
|
||||
const versaoTermoAtual = $derived(consentimentoQuery?.data?.versaoTermoAtual ?? '1.0');
|
||||
|
||||
async function aceitarTermo() {
|
||||
if (!aceito) {
|
||||
if (termoObrigatorio && !aceito) {
|
||||
erro = 'Você precisa aceitar o termo para continuar';
|
||||
return;
|
||||
}
|
||||
|
||||
if (!aceito) {
|
||||
// Se não é obrigatório e não aceitou, apenas redireciona
|
||||
window.location.href = resolve('/');
|
||||
return;
|
||||
}
|
||||
|
||||
carregando = true;
|
||||
erro = null;
|
||||
|
||||
@@ -30,11 +40,11 @@
|
||||
await registrarConsentimento({
|
||||
tipo: 'termo_uso',
|
||||
aceito: true,
|
||||
versao: '1.0'
|
||||
versao: versaoTermoAtual
|
||||
});
|
||||
sucesso = true;
|
||||
} catch (e: any) {
|
||||
erro = e.message || 'Erro ao registrar consentimento';
|
||||
} catch (e: unknown) {
|
||||
erro = e instanceof Error ? e.message : 'Erro ao registrar consentimento';
|
||||
} finally {
|
||||
carregando = false;
|
||||
}
|
||||
@@ -68,7 +78,7 @@
|
||||
<CheckCircle class="h-16 w-16 text-success mx-auto mb-4" strokeWidth={2} />
|
||||
<h2 class="card-title text-2xl justify-center mb-4">Termo Já Aceito</h2>
|
||||
<p class="text-base-content/80 mb-6">
|
||||
Você já aceitou este termo de consentimento. Se desejar revogar seu consentimento ou
|
||||
Você já aceitou este termo de consentimento (versão {versaoTermoAtual}). Se desejar revogar seu consentimento ou
|
||||
gerenciar suas preferências de privacidade, acesse a página de privacidade.
|
||||
</p>
|
||||
<div class="flex flex-col sm:flex-row gap-4 justify-center">
|
||||
@@ -208,14 +218,24 @@
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div class="alert alert-warning mb-6">
|
||||
<AlertCircle class="h-5 w-5" />
|
||||
<p class="text-sm">
|
||||
<strong>Atenção:</strong> O aceite deste termo é obrigatório para utilização do
|
||||
sistema. Ao aceitar, você confirma que leu, compreendeu e concorda com todos os
|
||||
termos e condições estabelecidos.
|
||||
</p>
|
||||
</div>
|
||||
{#if termoObrigatorio}
|
||||
<div class="alert alert-warning mb-6">
|
||||
<AlertCircle class="h-5 w-5" />
|
||||
<p class="text-sm">
|
||||
<strong>Atenção:</strong> O aceite deste termo é obrigatório para utilização do
|
||||
sistema. Ao aceitar, você confirma que leu, compreendeu e concorda com todos os
|
||||
termos e condições estabelecidos.
|
||||
</p>
|
||||
</div>
|
||||
{:else}
|
||||
<div class="alert alert-info mb-6">
|
||||
<AlertCircle class="h-5 w-5" />
|
||||
<p class="text-sm">
|
||||
<strong>Informação:</strong> O aceite deste termo é opcional. Você pode aceitar
|
||||
voluntariamente ou continuar sem aceitar.
|
||||
</p>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -253,7 +273,7 @@
|
||||
<div class="flex flex-col sm:flex-row gap-4">
|
||||
<button
|
||||
onclick={aceitarTermo}
|
||||
disabled={!aceito || carregando}
|
||||
disabled={(termoObrigatorio && !aceito) || carregando}
|
||||
class="btn btn-primary btn-lg flex-1"
|
||||
>
|
||||
{#if carregando}
|
||||
|
||||
@@ -4,8 +4,15 @@
|
||||
import { api } from '@sgse-app/backend/convex/_generated/api';
|
||||
import { Shield, FileText, AlertTriangle, CheckCircle, Settings, Users } from 'lucide-svelte';
|
||||
import StatsCard from '$lib/components/ti/StatsCard.svelte';
|
||||
import { onMount } from 'svelte';
|
||||
|
||||
const estatisticas = useQuery(api.lgpd.obterEstatisticasLGPD, {});
|
||||
|
||||
onMount(() => {
|
||||
if (estatisticas?.error) {
|
||||
console.error('Erro ao carregar estatísticas LGPD:', estatisticas.error);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<div class="container mx-auto px-4 py-6 max-w-7xl">
|
||||
@@ -23,11 +30,20 @@
|
||||
</div>
|
||||
|
||||
<!-- Stats Cards -->
|
||||
{#if estatisticas}
|
||||
{#if estatisticas === undefined}
|
||||
<div class="flex justify-center items-center py-20">
|
||||
<span class="loading loading-spinner loading-lg text-primary"></span>
|
||||
</div>
|
||||
{:else if estatisticas?.error}
|
||||
<div class="alert alert-error mb-6">
|
||||
<AlertTriangle class="h-5 w-5" />
|
||||
<span>Erro ao carregar estatísticas: {estatisticas.error}</span>
|
||||
</div>
|
||||
{:else if estatisticas?.data}
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 mb-8">
|
||||
<StatsCard
|
||||
title="Solicitações Pendentes"
|
||||
value={estatisticas.solicitacoesPendentes}
|
||||
value={estatisticas.data.solicitacoesPendentes}
|
||||
description="Aguardando resposta"
|
||||
Icon={AlertTriangle}
|
||||
color="warning"
|
||||
@@ -35,7 +51,7 @@
|
||||
|
||||
<StatsCard
|
||||
title="Solicitações Vencendo"
|
||||
value={estatisticas.solicitacoesVencendo}
|
||||
value={estatisticas.data.solicitacoesVencendo}
|
||||
description="Prazo próximo"
|
||||
Icon={AlertTriangle}
|
||||
color="error"
|
||||
@@ -43,7 +59,7 @@
|
||||
|
||||
<StatsCard
|
||||
title="Total de Solicitações"
|
||||
value={estatisticas.totalSolicitacoes}
|
||||
value={estatisticas.data.totalSolicitacoes}
|
||||
description="Todas as solicitações"
|
||||
Icon={FileText}
|
||||
color="info"
|
||||
@@ -51,16 +67,12 @@
|
||||
|
||||
<StatsCard
|
||||
title="Consentimentos Ativos"
|
||||
value={estatisticas.consentimentosAtivos}
|
||||
value={estatisticas.data.consentimentosAtivos}
|
||||
description="Consentimentos válidos"
|
||||
Icon={CheckCircle}
|
||||
color="success"
|
||||
/>
|
||||
</div>
|
||||
{:else}
|
||||
<div class="flex justify-center items-center py-20">
|
||||
<span class="loading loading-spinner loading-lg text-primary"></span>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<!-- Ações Rápidas -->
|
||||
@@ -87,14 +99,14 @@
|
||||
</div>
|
||||
|
||||
<!-- Informações -->
|
||||
{#if estatisticas}
|
||||
{#if estatisticas?.data}
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
||||
<!-- Solicitações por Tipo -->
|
||||
<div class="card bg-base-100 shadow-xl">
|
||||
<div class="card-body">
|
||||
<h2 class="card-title text-xl mb-4">Solicitações por Tipo</h2>
|
||||
<div class="space-y-2">
|
||||
{#each Object.entries(estatisticas.solicitacoesPorTipo) as [tipo, quantidade]}
|
||||
{#each Object.entries(estatisticas.data.solicitacoesPorTipo) as [tipo, quantidade]}
|
||||
<div class="flex justify-between items-center p-2 bg-base-200 rounded">
|
||||
<span class="text-sm font-medium">{tipo}</span>
|
||||
<span class="badge badge-primary">{quantidade}</span>
|
||||
@@ -111,19 +123,19 @@
|
||||
<div class="space-y-3">
|
||||
<div class="flex justify-between">
|
||||
<span>Total de ROTs:</span>
|
||||
<span class="font-semibold">{estatisticas.totalROTs}</span>
|
||||
<span class="font-semibold">{estatisticas.data.totalROTs}</span>
|
||||
</div>
|
||||
<div class="flex justify-between">
|
||||
<span>ROTs Ativos:</span>
|
||||
<span class="font-semibold text-success">{estatisticas.rotsAtivos}</span>
|
||||
<span class="font-semibold text-success">{estatisticas.data.rotsAtivos}</span>
|
||||
</div>
|
||||
<div class="flex justify-between">
|
||||
<span>Total de Consentimentos:</span>
|
||||
<span class="font-semibold">{estatisticas.totalConsentimentos}</span>
|
||||
<span class="font-semibold">{estatisticas.data.totalConsentimentos}</span>
|
||||
</div>
|
||||
<div class="flex justify-between">
|
||||
<span>Consentimentos Ativos:</span>
|
||||
<span class="font-semibold text-success">{estatisticas.consentimentosAtivos}</span>
|
||||
<span class="font-semibold text-success">{estatisticas.data.consentimentosAtivos}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import { resolve } from '$app/paths';
|
||||
import { useQuery, useMutation } from 'convex-svelte';
|
||||
import { api } from '@sgse-app/backend/convex/_generated/api';
|
||||
import { Shield, Save, Mail, Phone, User, Calendar } from 'lucide-svelte';
|
||||
import { Shield, Save, Mail, Phone, User, Calendar, ToggleLeft, ToggleRight } from 'lucide-svelte';
|
||||
import { toast } from 'svelte-sonner';
|
||||
|
||||
const config = useQuery(api.lgpd.obterConfiguracaoLGPD, {});
|
||||
@@ -11,8 +11,11 @@
|
||||
let encarregadoNome = $state('');
|
||||
let encarregadoEmail = $state('');
|
||||
let encarregadoTelefone = $state('');
|
||||
let encarregadoHorarioAtendimento = $state('Segunda a Sexta, das 8h às 17h');
|
||||
let prazoRespostaPadrao = $state(15);
|
||||
let diasAlertaVencimento = $state(3);
|
||||
let termoObrigatorio = $state(false);
|
||||
let versaoTermoAtual = $state('1.0');
|
||||
let carregando = $state(false);
|
||||
|
||||
// Sincronizar com query
|
||||
@@ -21,8 +24,11 @@
|
||||
encarregadoNome = config.data.encarregadoNome || '';
|
||||
encarregadoEmail = config.data.encarregadoEmail || '';
|
||||
encarregadoTelefone = config.data.encarregadoTelefone || '';
|
||||
encarregadoHorarioAtendimento = config.data.encarregadoHorarioAtendimento || 'Segunda a Sexta, das 8h às 17h';
|
||||
prazoRespostaPadrao = config.data.prazoRespostaPadrao;
|
||||
diasAlertaVencimento = config.data.diasAlertaVencimento;
|
||||
termoObrigatorio = config.data.termoObrigatorio;
|
||||
versaoTermoAtual = config.data.versaoTermoAtual;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -34,13 +40,17 @@
|
||||
encarregadoNome: encarregadoNome || undefined,
|
||||
encarregadoEmail: encarregadoEmail || undefined,
|
||||
encarregadoTelefone: encarregadoTelefone || undefined,
|
||||
encarregadoHorarioAtendimento: encarregadoHorarioAtendimento || undefined,
|
||||
prazoRespostaPadrao,
|
||||
diasAlertaVencimento
|
||||
diasAlertaVencimento,
|
||||
termoObrigatorio,
|
||||
versaoTermoAtual: versaoTermoAtual || '1.0'
|
||||
});
|
||||
|
||||
toast.success('Configurações salvas com sucesso!');
|
||||
} catch (error: any) {
|
||||
toast.error(error.message || 'Erro ao salvar configurações');
|
||||
} catch (error: unknown) {
|
||||
const message = error instanceof Error ? error.message : 'Erro ao salvar configurações';
|
||||
toast.error(message);
|
||||
} finally {
|
||||
carregando = false;
|
||||
}
|
||||
@@ -120,6 +130,73 @@
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-control">
|
||||
<label class="label">
|
||||
<span class="label-text font-semibold">Horário de Atendimento</span>
|
||||
</label>
|
||||
<div class="relative">
|
||||
<Calendar class="absolute left-3 top-1/2 transform -translate-y-1/2 h-5 w-5 text-base-content/40" />
|
||||
<input
|
||||
type="text"
|
||||
bind:value={encarregadoHorarioAtendimento}
|
||||
placeholder="Segunda a Sexta, das 8h às 17h"
|
||||
class="input input-bordered w-full pl-10"
|
||||
/>
|
||||
</div>
|
||||
<label class="label">
|
||||
<span class="label-text-alt text-base-content/60">
|
||||
Horário de atendimento do Encarregado de Dados
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Configurações de Termo de Consentimento -->
|
||||
<div class="card bg-base-100 shadow-xl mb-6">
|
||||
<div class="card-body">
|
||||
<h2 class="card-title text-2xl mb-4">Termo de Consentimento</h2>
|
||||
<p class="text-base-content/60 mb-6">
|
||||
Configure se o termo de consentimento é obrigatório para acesso ao sistema.
|
||||
</p>
|
||||
|
||||
<div class="space-y-4">
|
||||
<div class="form-control">
|
||||
<label class="cursor-pointer label justify-start gap-4">
|
||||
<input
|
||||
type="checkbox"
|
||||
bind:checked={termoObrigatorio}
|
||||
class="checkbox checkbox-primary"
|
||||
/>
|
||||
<div>
|
||||
<span class="label-text font-semibold">Termo de Consentimento Obrigatório</span>
|
||||
<p class="text-sm text-base-content/60">
|
||||
Quando habilitado, os usuários precisam aceitar o termo de consentimento
|
||||
antes de acessar o sistema.
|
||||
</p>
|
||||
</div>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="form-control">
|
||||
<label class="label">
|
||||
<span class="label-text font-semibold">Versão Atual do Termo</span>
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
bind:value={versaoTermoAtual}
|
||||
placeholder="1.0"
|
||||
class="input input-bordered"
|
||||
/>
|
||||
<label class="label">
|
||||
<span class="label-text-alt text-base-content/60">
|
||||
Versão do termo de consentimento atual. Ao alterar, usuários precisarão aceitar
|
||||
novamente.
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -87,8 +87,9 @@
|
||||
compartilhamentoTerceiros = false;
|
||||
terceiros = [];
|
||||
descricao = '';
|
||||
} catch (error: any) {
|
||||
toast.error(error.message || 'Erro ao criar registro');
|
||||
} catch (error: unknown) {
|
||||
const message = error instanceof Error ? error.message : 'Erro ao criar registro';
|
||||
toast.error(message);
|
||||
} finally {
|
||||
carregando = false;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
import { resolve } from '$app/paths';
|
||||
import { useQuery, useMutation } from 'convex-svelte';
|
||||
import { api } from '@sgse-app/backend/convex/_generated/api';
|
||||
import type { Id } from '@sgse-app/backend/convex/_generated/dataModel';
|
||||
import {
|
||||
Shield,
|
||||
FileText,
|
||||
@@ -106,7 +107,7 @@
|
||||
|
||||
try {
|
||||
await responderSolicitacao({
|
||||
solicitacaoId: solicitacaoSelecionada as any,
|
||||
solicitacaoId: solicitacaoSelecionada as Id<'solicitacoesLGPD'>,
|
||||
resposta: resposta.trim(),
|
||||
status: statusResposta
|
||||
});
|
||||
@@ -114,8 +115,9 @@
|
||||
toast.success('Solicitação respondida com sucesso!');
|
||||
solicitacaoSelecionada = null;
|
||||
resposta = '';
|
||||
} catch (error: any) {
|
||||
toast.error(error.message || 'Erro ao responder solicitação');
|
||||
} catch (error: unknown) {
|
||||
const message = error instanceof Error ? error.message : 'Erro ao responder solicitação';
|
||||
toast.error(message);
|
||||
} finally {
|
||||
carregando = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user