feat: enhance vacation management system with new employee association functionality, improved email notification handling, and comprehensive documentation; update dependencies and UI components for better user experience
This commit is contained in:
@@ -204,6 +204,39 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Card Notificações e Mensagens -->
|
||||
<div class="card bg-base-100 shadow-xl hover:shadow-2xl transition-shadow">
|
||||
<div class="card-body">
|
||||
<div class="flex items-center gap-4 mb-4">
|
||||
<div class="p-3 bg-info/20 rounded-lg">
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
class="h-8 w-8 text-info"
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
stroke="currentColor"
|
||||
>
|
||||
<path
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
stroke-width="2"
|
||||
d="M15 17h5l-1.405-1.405A2.032 2.032 0 0118 14.158V11a6.002 6.002 0 00-4-5.659V5a2 2 0 10-4 0v.341C7.67 6.165 6 8.388 6 11v3.159c0 .538-.214 1.055-.595 1.436L4 17h5m6 0v1a3 3 0 11-6 0v-1m6 0H9"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
<h2 class="card-title text-xl">Notificações e Mensagens</h2>
|
||||
</div>
|
||||
<p class="text-base-content/70 mb-4">
|
||||
Envie notificações para usuários do sistema via chat ou email. Configure templates de mensagens reutilizáveis.
|
||||
</p>
|
||||
<div class="card-actions justify-end">
|
||||
<a href="/ti/notificacoes" class="btn btn-info">
|
||||
Acessar Painel
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Card Documentação -->
|
||||
<div class="card bg-base-100 shadow-xl hover:shadow-2xl transition-shadow">
|
||||
<div class="card-body">
|
||||
@@ -230,7 +263,7 @@
|
||||
Manuais, guias e documentação técnica do sistema para usuários e administradores.
|
||||
</p>
|
||||
<div class="card-actions justify-end">
|
||||
<button class="btn btn-primary" disabled>
|
||||
<button type="button" class="btn btn-primary" disabled>
|
||||
Em breve
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
let abaAtiva = $state<"atividades" | "logins">("atividades");
|
||||
let limite = $state(50);
|
||||
|
||||
// Queries
|
||||
const atividades = useQuery(api.logsAtividades.listarAtividades, { limite });
|
||||
const logins = useQuery(api.logsLogin.listarTodosLogins, { limite });
|
||||
// Queries com $derived para garantir reatividade
|
||||
const atividades = $derived(useQuery(api.logsAtividades.listarAtividades, { limite }));
|
||||
const logins = $derived(useQuery(api.logsLogin.listarTodosLogins, { limite }));
|
||||
|
||||
function formatarData(timestamp: number) {
|
||||
return new Date(timestamp).toLocaleString('pt-BR', {
|
||||
|
||||
@@ -187,42 +187,45 @@
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<!-- Servidor -->
|
||||
<div class="form-control md:col-span-1">
|
||||
<label class="label">
|
||||
<label class="label" for="smtp-servidor">
|
||||
<span class="label-text font-medium">Servidor SMTP *</span>
|
||||
</label>
|
||||
<input
|
||||
id="smtp-servidor"
|
||||
type="text"
|
||||
bind:value={servidor}
|
||||
placeholder="smtp.exemplo.com"
|
||||
class="input input-bordered"
|
||||
/>
|
||||
<label class="label">
|
||||
<div class="label">
|
||||
<span class="label-text-alt">Ex: smtp.gmail.com, smtp.office365.com</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Porta -->
|
||||
<div class="form-control">
|
||||
<label class="label">
|
||||
<label class="label" for="smtp-porta">
|
||||
<span class="label-text font-medium">Porta *</span>
|
||||
</label>
|
||||
<input
|
||||
id="smtp-porta"
|
||||
type="number"
|
||||
bind:value={porta}
|
||||
placeholder="587"
|
||||
class="input input-bordered"
|
||||
/>
|
||||
<label class="label">
|
||||
<div class="label">
|
||||
<span class="label-text-alt">Comum: 587 (TLS), 465 (SSL), 25</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Usuário -->
|
||||
<div class="form-control">
|
||||
<label class="label">
|
||||
<label class="label" for="smtp-usuario">
|
||||
<span class="label-text font-medium">Usuário/Email *</span>
|
||||
</label>
|
||||
<input
|
||||
id="smtp-usuario"
|
||||
type="text"
|
||||
bind:value={usuario}
|
||||
placeholder="usuario@exemplo.com"
|
||||
@@ -232,16 +235,17 @@
|
||||
|
||||
<!-- Senha -->
|
||||
<div class="form-control">
|
||||
<label class="label">
|
||||
<label class="label" for="smtp-senha">
|
||||
<span class="label-text font-medium">Senha *</span>
|
||||
</label>
|
||||
<input
|
||||
id="smtp-senha"
|
||||
type="password"
|
||||
bind:value={senha}
|
||||
placeholder="••••••••"
|
||||
class="input input-bordered"
|
||||
/>
|
||||
<label class="label">
|
||||
<div class="label">
|
||||
<span class="label-text-alt text-warning">
|
||||
{#if configAtual?.data?.ativo}
|
||||
Deixe em branco para manter a senha atual
|
||||
@@ -249,15 +253,16 @@
|
||||
Digite a senha da conta de email
|
||||
{/if}
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Email Remetente -->
|
||||
<div class="form-control">
|
||||
<label class="label">
|
||||
<label class="label" for="smtp-email-remetente">
|
||||
<span class="label-text font-medium">Email Remetente *</span>
|
||||
</label>
|
||||
<input
|
||||
id="smtp-email-remetente"
|
||||
type="email"
|
||||
bind:value={emailRemetente}
|
||||
placeholder="noreply@sgse.pe.gov.br"
|
||||
@@ -267,10 +272,11 @@
|
||||
|
||||
<!-- Nome Remetente -->
|
||||
<div class="form-control">
|
||||
<label class="label">
|
||||
<label class="label" for="smtp-nome-remetente">
|
||||
<span class="label-text font-medium">Nome Remetente *</span>
|
||||
</label>
|
||||
<input
|
||||
id="smtp-nome-remetente"
|
||||
type="text"
|
||||
bind:value={nomeRemetente}
|
||||
placeholder="SGSE - Sistema de Gestão"
|
||||
|
||||
@@ -35,23 +35,97 @@
|
||||
|
||||
processando = true;
|
||||
try {
|
||||
// TODO: Implementar envio de notificação
|
||||
console.log("Enviar notificação", {
|
||||
destinatarioId,
|
||||
canal,
|
||||
templateId: usarTemplate ? templateId : undefined,
|
||||
mensagem: !usarTemplate ? mensagemPersonalizada : undefined
|
||||
});
|
||||
const destinatario = usuarios?.data?.find(u => u._id === destinatarioId);
|
||||
|
||||
alert("Notificação enviada com sucesso!");
|
||||
if (!destinatario) {
|
||||
alert("Destinatário não encontrado");
|
||||
return;
|
||||
}
|
||||
|
||||
let resultadoChat = null;
|
||||
let resultadoEmail = null;
|
||||
|
||||
// ENVIAR PARA CHAT
|
||||
if (canal === "chat" || canal === "ambos") {
|
||||
const conversaResult = await client.mutation(
|
||||
api.chat.criarOuBuscarConversaIndividual,
|
||||
{ outroUsuarioId: destinatarioId as any }
|
||||
);
|
||||
|
||||
if (conversaResult.conversaId) {
|
||||
const mensagem = usarTemplate
|
||||
? templateSelecionado?.corpo || ""
|
||||
: mensagemPersonalizada;
|
||||
|
||||
resultadoChat = await client.mutation(api.chat.enviarMensagem, {
|
||||
conversaId: conversaResult.conversaId,
|
||||
conteudo: mensagem,
|
||||
tipo: "texto", // Tipo de mensagem
|
||||
permitirNotificacaoParaSiMesmo: true, // ✅ Permite notificação para si mesmo via painel admin
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// ENVIAR PARA EMAIL
|
||||
if (canal === "email" || canal === "ambos") {
|
||||
if (!destinatario.email) {
|
||||
alert("Destinatário não possui email cadastrado");
|
||||
processando = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (usarTemplate && templateId) {
|
||||
// Usar template
|
||||
const template = templateSelecionado;
|
||||
if (template) {
|
||||
resultadoEmail = await client.mutation(api.email.enviarEmailComTemplate, {
|
||||
destinatario: destinatario.email,
|
||||
destinatarioId: destinatario._id as any,
|
||||
templateCodigo: template.codigo,
|
||||
variaveis: {
|
||||
nome: destinatario.nome,
|
||||
matricula: destinatario.matricula,
|
||||
},
|
||||
enviadoPorId: destinatario._id as any, // TODO: Pegar usuário logado
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// Mensagem personalizada
|
||||
resultadoEmail = await client.mutation(api.email.enfileirarEmail, {
|
||||
destinatario: destinatario.email,
|
||||
destinatarioId: destinatario._id as any,
|
||||
assunto: "Notificação do Sistema",
|
||||
corpo: mensagemPersonalizada,
|
||||
enviadoPorId: destinatario._id as any, // TODO: Pegar usuário logado
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Feedback de sucesso
|
||||
let mensagem = "Notificação enviada com sucesso!";
|
||||
if (canal === "ambos") {
|
||||
if (resultadoChat && resultadoEmail) {
|
||||
mensagem = "✅ Notificação enviada para Chat e Email!";
|
||||
} else if (resultadoChat) {
|
||||
mensagem = "✅ Notificação enviada para Chat. Email falhou.";
|
||||
} else if (resultadoEmail) {
|
||||
mensagem = "✅ Notificação enviada para Email. Chat falhou.";
|
||||
}
|
||||
} else if (canal === "chat" && resultadoChat) {
|
||||
mensagem = "✅ Mensagem enviada no Chat!";
|
||||
} else if (canal === "email" && resultadoEmail) {
|
||||
mensagem = "✅ Email enfileirado para envio!";
|
||||
}
|
||||
|
||||
alert(mensagem);
|
||||
|
||||
// Limpar form
|
||||
destinatarioId = "";
|
||||
templateId = "";
|
||||
mensagemPersonalizada = "";
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
console.error("Erro ao enviar notificação:", error);
|
||||
alert("Erro ao enviar notificação");
|
||||
alert("Erro ao enviar notificação: " + (error.message || "Erro desconhecido"));
|
||||
} finally {
|
||||
processando = false;
|
||||
}
|
||||
@@ -82,10 +156,10 @@
|
||||
|
||||
<!-- Destinatário -->
|
||||
<div class="form-control mb-4">
|
||||
<label class="label">
|
||||
<label class="label" for="destinatario-select">
|
||||
<span class="label-text font-medium">Destinatário *</span>
|
||||
</label>
|
||||
<select bind:value={destinatarioId} class="select select-bordered">
|
||||
<select id="destinatario-select" bind:value={destinatarioId} class="select select-bordered">
|
||||
<option value="">Selecione um usuário</option>
|
||||
{#if usuarios?.data}
|
||||
{#each usuarios.data as usuario}
|
||||
@@ -99,9 +173,9 @@
|
||||
|
||||
<!-- Canal -->
|
||||
<div class="form-control mb-4">
|
||||
<label class="label">
|
||||
<div class="label">
|
||||
<span class="label-text font-medium">Canal de Envio *</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="flex gap-4">
|
||||
<label class="label cursor-pointer">
|
||||
<input
|
||||
@@ -135,9 +209,9 @@
|
||||
|
||||
<!-- Tipo de Mensagem -->
|
||||
<div class="form-control mb-4">
|
||||
<label class="label">
|
||||
<div class="label">
|
||||
<span class="label-text font-medium">Tipo de Mensagem</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="flex gap-4">
|
||||
<label class="label cursor-pointer">
|
||||
<input
|
||||
@@ -163,10 +237,10 @@
|
||||
{#if usarTemplate}
|
||||
<!-- Template -->
|
||||
<div class="form-control mb-4">
|
||||
<label class="label">
|
||||
<label class="label" for="template-select">
|
||||
<span class="label-text font-medium">Template *</span>
|
||||
</label>
|
||||
<select bind:value={templateId} class="select select-bordered">
|
||||
<select id="template-select" bind:value={templateId} class="select select-bordered">
|
||||
<option value="">Selecione um template</option>
|
||||
{#if templates?.data}
|
||||
{#each templates.data as template}
|
||||
@@ -192,10 +266,11 @@
|
||||
{:else}
|
||||
<!-- Mensagem Personalizada -->
|
||||
<div class="form-control mb-4">
|
||||
<label class="label">
|
||||
<label class="label" for="mensagem-textarea">
|
||||
<span class="label-text font-medium">Mensagem *</span>
|
||||
</label>
|
||||
<textarea
|
||||
id="mensagem-textarea"
|
||||
bind:value={mensagemPersonalizada}
|
||||
class="textarea textarea-bordered h-32"
|
||||
placeholder="Digite sua mensagem personalizada..."
|
||||
@@ -267,14 +342,15 @@
|
||||
</div>
|
||||
{#if template.tipo !== "sistema"}
|
||||
<div class="dropdown dropdown-end">
|
||||
<label tabindex="0" class="btn btn-ghost btn-xs">
|
||||
<button type="button" tabindex="0" class="btn btn-ghost btn-xs" aria-label="Opções do template">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 5v.01M12 12v.01M12 19v.01M12 6a1 1 0 110-2 1 1 0 010 2zm0 7a1 1 0 110-2 1 1 0 010 2zm0 7a1 1 0 110-2 1 1 0 010 2z" />
|
||||
</svg>
|
||||
</label>
|
||||
</button>
|
||||
<!-- svelte-ignore a11y_no_noninteractive_tabindex -->
|
||||
<ul tabindex="0" class="dropdown-content menu p-2 shadow bg-base-100 rounded-box w-32">
|
||||
<li><button>Editar</button></li>
|
||||
<li><button class="text-error">Excluir</button></li>
|
||||
<li><button type="button">Editar</button></li>
|
||||
<li><button type="button" class="text-error">Excluir</button></li>
|
||||
</ul>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
@@ -83,7 +83,7 @@
|
||||
<div class="card bg-base-100 shadow-xl mb-8">
|
||||
<div class="card-body">
|
||||
<h2 class="card-title text-2xl mb-4">Ações Rápidas</h2>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4">
|
||||
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
|
||||
<a href="/ti/usuarios" class="btn btn-primary">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4" />
|
||||
@@ -104,13 +104,6 @@
|
||||
</svg>
|
||||
Ver Logs
|
||||
</a>
|
||||
|
||||
<a href="/ti/notificacoes" class="btn btn-info">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 17h5l-1.405-1.405A2.032 2.032 0 0118 14.158V11a6.002 6.002 0 00-4-5.659V5a2 2 0 10-4 0v.341C7.67 6.165 6 8.388 6 11v3.159c0 .538-.214 1.055-.595 1.436L4 17h5m6 0v1a3 3 0 11-6 0v-1m6 0H9" />
|
||||
</svg>
|
||||
Enviar Notificação
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -412,8 +412,10 @@
|
||||
<td>
|
||||
<div class="flex gap-2 justify-end">
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-sm btn-info btn-square tooltip"
|
||||
data-tip="Ver Detalhes"
|
||||
aria-label="Ver Detalhes"
|
||||
onclick={() => abrirDetalhes(perfil)}
|
||||
disabled={processando}
|
||||
>
|
||||
@@ -439,8 +441,10 @@
|
||||
</svg>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-sm btn-warning btn-square tooltip"
|
||||
data-tip="Editar"
|
||||
aria-label="Editar"
|
||||
onclick={() => abrirEditar(perfil)}
|
||||
disabled={processando}
|
||||
>
|
||||
@@ -460,8 +464,10 @@
|
||||
</svg>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-sm btn-success btn-square tooltip"
|
||||
data-tip="Clonar"
|
||||
aria-label="Clonar"
|
||||
onclick={() => clonarPerfil(perfil)}
|
||||
disabled={processando}
|
||||
>
|
||||
@@ -481,8 +487,10 @@
|
||||
</svg>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-sm btn-error btn-square tooltip"
|
||||
data-tip={perfil.numeroUsuarios > 0 ? "Não pode excluir - Perfil em uso" : "Excluir"}
|
||||
aria-label="Excluir"
|
||||
onclick={() => abrirModalExcluir(perfil)}
|
||||
disabled={processando || perfil.numeroUsuarios > 0}
|
||||
>
|
||||
@@ -921,10 +929,10 @@
|
||||
<span>Esta ação não pode ser desfeita!</span>
|
||||
</div>
|
||||
<div class="modal-action">
|
||||
<button class="btn btn-ghost" onclick={fecharModalExcluir} disabled={processando}>
|
||||
<button type="button" class="btn btn-ghost" onclick={fecharModalExcluir} disabled={processando}>
|
||||
Cancelar
|
||||
</button>
|
||||
<button class="btn btn-error" onclick={confirmarExclusao} disabled={processando}>
|
||||
<button type="button" class="btn btn-error" onclick={confirmarExclusao} disabled={processando}>
|
||||
{#if processando}
|
||||
<span class="loading loading-spinner loading-sm"></span>
|
||||
{/if}
|
||||
|
||||
@@ -14,9 +14,18 @@
|
||||
let filtroStatus = $state<"todos" | "ativo" | "bloqueado" | "inativo">("todos");
|
||||
let usuarioSelecionado = $state<any>(null);
|
||||
let modalAberto = $state(false);
|
||||
let modalAcao = $state<"bloquear" | "desbloquear" | "reset">("bloquear");
|
||||
let modalAcao = $state<"bloquear" | "desbloquear" | "reset" | "associar">("bloquear");
|
||||
let motivo = $state("");
|
||||
let processando = $state(false);
|
||||
|
||||
// Modal de associar funcionário
|
||||
let modalAssociarAberto = $state(false);
|
||||
let usuarioParaAssociar = $state<any>(null);
|
||||
let funcionarioSelecionadoId = $state<string>("");
|
||||
let buscaFuncionario = $state("");
|
||||
|
||||
// Query de funcionários
|
||||
const funcionarios = useQuery(api.funcionarios.list, {});
|
||||
|
||||
// Usuários filtrados
|
||||
const usuariosFiltrados = $derived.by(() => {
|
||||
@@ -36,6 +45,21 @@
|
||||
return matchNome && matchStatus;
|
||||
});
|
||||
});
|
||||
|
||||
// Funcionários filtrados (sem associação ou disponíveis)
|
||||
const funcionariosFiltrados = $derived.by(() => {
|
||||
if (!funcionarios?.data || !Array.isArray(funcionarios.data)) return [];
|
||||
|
||||
return funcionarios.data.filter(f => {
|
||||
// Filtro por busca
|
||||
const matchBusca = !buscaFuncionario ||
|
||||
f.nome.toLowerCase().includes(buscaFuncionario.toLowerCase()) ||
|
||||
f.cpf?.includes(buscaFuncionario) ||
|
||||
f.matricula?.includes(buscaFuncionario);
|
||||
|
||||
return matchBusca;
|
||||
}).sort((a, b) => a.nome.localeCompare(b.nome));
|
||||
});
|
||||
|
||||
const stats = $derived.by(() => {
|
||||
if (!usuarios?.data || !Array.isArray(usuarios.data)) return null;
|
||||
@@ -59,6 +83,59 @@
|
||||
usuarioSelecionado = null;
|
||||
motivo = "";
|
||||
}
|
||||
|
||||
function abrirModalAssociar(usuario: any) {
|
||||
usuarioParaAssociar = usuario;
|
||||
funcionarioSelecionadoId = usuario.funcionarioId || "";
|
||||
buscaFuncionario = "";
|
||||
modalAssociarAberto = true;
|
||||
}
|
||||
|
||||
function fecharModalAssociar() {
|
||||
modalAssociarAberto = false;
|
||||
usuarioParaAssociar = null;
|
||||
funcionarioSelecionadoId = "";
|
||||
buscaFuncionario = "";
|
||||
}
|
||||
|
||||
async function associarFuncionario() {
|
||||
if (!usuarioParaAssociar || !funcionarioSelecionadoId) return;
|
||||
|
||||
processando = true;
|
||||
try {
|
||||
await client.mutation(api.usuarios.associarFuncionario, {
|
||||
usuarioId: usuarioParaAssociar._id as Id<"usuarios">,
|
||||
funcionarioId: funcionarioSelecionadoId as Id<"funcionarios">
|
||||
});
|
||||
|
||||
alert("Funcionário associado com sucesso!");
|
||||
fecharModalAssociar();
|
||||
} catch (error: any) {
|
||||
alert("Erro ao associar funcionário: " + error.message);
|
||||
} finally {
|
||||
processando = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function desassociarFuncionario() {
|
||||
if (!usuarioParaAssociar) return;
|
||||
|
||||
if (!confirm("Deseja realmente desassociar o funcionário deste usuário?")) return;
|
||||
|
||||
processando = true;
|
||||
try {
|
||||
await client.mutation(api.usuarios.desassociarFuncionario, {
|
||||
usuarioId: usuarioParaAssociar._id as Id<"usuarios">
|
||||
});
|
||||
|
||||
alert("Funcionário desassociado com sucesso!");
|
||||
fecharModalAssociar();
|
||||
} catch (error: any) {
|
||||
alert("Erro ao desassociar funcionário: " + error.message);
|
||||
} finally {
|
||||
processando = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function executarAcao() {
|
||||
if (!usuarioSelecionado) return;
|
||||
@@ -140,10 +217,11 @@
|
||||
<div class="card-body">
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div class="form-control">
|
||||
<label class="label">
|
||||
<label class="label" for="buscar-usuario-input">
|
||||
<span class="label-text">Buscar por nome, matrícula ou email</span>
|
||||
</label>
|
||||
<input
|
||||
id="buscar-usuario-input"
|
||||
type="text"
|
||||
bind:value={filtroNome}
|
||||
placeholder="Digite para buscar..."
|
||||
@@ -152,10 +230,10 @@
|
||||
</div>
|
||||
|
||||
<div class="form-control">
|
||||
<label class="label">
|
||||
<label class="label" for="filtro-status-select">
|
||||
<span class="label-text">Filtrar por status</span>
|
||||
</label>
|
||||
<select bind:value={filtroStatus} class="select select-bordered">
|
||||
<select id="filtro-status-select" bind:value={filtroStatus} class="select select-bordered">
|
||||
<option value="todos">Todos</option>
|
||||
<option value="ativo">Ativos</option>
|
||||
<option value="bloqueado">Bloqueados</option>
|
||||
@@ -180,6 +258,7 @@
|
||||
<th>Matrícula</th>
|
||||
<th>Nome</th>
|
||||
<th>Email</th>
|
||||
<th>Funcionário</th>
|
||||
<th>Status</th>
|
||||
<th>Ações</th>
|
||||
</tr>
|
||||
@@ -190,11 +269,40 @@
|
||||
<td class="font-mono">{usuario.matricula}</td>
|
||||
<td>{usuario.nome}</td>
|
||||
<td>{usuario.email || "-"}</td>
|
||||
<td>
|
||||
{#if usuario.funcionarioId}
|
||||
<div class="badge badge-success gap-2">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="h-3 w-3" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7" />
|
||||
</svg>
|
||||
Associado
|
||||
</div>
|
||||
{:else}
|
||||
<div class="badge badge-warning gap-2">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="h-3 w-3" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" />
|
||||
</svg>
|
||||
Não associado
|
||||
</div>
|
||||
{/if}
|
||||
</td>
|
||||
<td>
|
||||
<UserStatusBadge ativo={usuario.ativo} bloqueado={usuario.bloqueado} />
|
||||
</td>
|
||||
<td>
|
||||
<div class="flex gap-2">
|
||||
<div class="flex gap-2 flex-wrap">
|
||||
<!-- Botão Associar Funcionário -->
|
||||
<button
|
||||
class="btn btn-sm btn-info"
|
||||
onclick={() => abrirModalAssociar(usuario)}
|
||||
title={usuario.funcionarioId ? "Alterar funcionário associado" : "Associar funcionário"}
|
||||
>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z" />
|
||||
</svg>
|
||||
{usuario.funcionarioId ? "Alterar" : "Associar"}
|
||||
</button>
|
||||
|
||||
{#if usuario.bloqueado}
|
||||
<button
|
||||
class="btn btn-sm btn-success"
|
||||
@@ -261,10 +369,11 @@
|
||||
|
||||
{#if modalAcao === "bloquear"}
|
||||
<div class="form-control mb-4">
|
||||
<label class="label">
|
||||
<label class="label" for="motivo-bloqueio-textarea">
|
||||
<span class="label-text">Motivo do bloqueio *</span>
|
||||
</label>
|
||||
<textarea
|
||||
id="motivo-bloqueio-textarea"
|
||||
bind:value={motivo}
|
||||
class="textarea textarea-bordered"
|
||||
placeholder="Digite o motivo..."
|
||||
@@ -302,7 +411,126 @@
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
||||
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||
<div class="modal-backdrop" onclick={fecharModal}></div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<!-- Modal Associar Funcionário -->
|
||||
{#if modalAssociarAberto && usuarioParaAssociar}
|
||||
<div class="modal modal-open">
|
||||
<div class="modal-box max-w-2xl">
|
||||
<h3 class="font-bold text-lg mb-4">
|
||||
Associar Funcionário ao Usuário
|
||||
</h3>
|
||||
|
||||
<div class="mb-6">
|
||||
<p class="text-base-content/80 mb-2">
|
||||
<strong>Usuário:</strong> {usuarioParaAssociar.nome} ({usuarioParaAssociar.matricula})
|
||||
</p>
|
||||
|
||||
{#if usuarioParaAssociar.funcionarioId}
|
||||
<div class="alert alert-info">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" class="stroke-current shrink-0 w-6 h-6">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path>
|
||||
</svg>
|
||||
<span>Este usuário já possui um funcionário associado. Você pode alterá-lo ou desassociá-lo.</span>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<!-- Busca de Funcionários -->
|
||||
<div class="form-control mb-4">
|
||||
<label for="busca-funcionario" class="label">
|
||||
<span class="label-text">Buscar Funcionário</span>
|
||||
</label>
|
||||
<input
|
||||
id="busca-funcionario"
|
||||
type="text"
|
||||
bind:value={buscaFuncionario}
|
||||
placeholder="Digite nome, CPF ou matrícula..."
|
||||
class="input input-bordered"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- Lista de Funcionários -->
|
||||
<div class="form-control mb-6">
|
||||
<div class="label">
|
||||
<span class="label-text">Selecione o Funcionário *</span>
|
||||
</div>
|
||||
|
||||
<div class="border rounded-lg max-h-96 overflow-y-auto">
|
||||
{#if funcionariosFiltrados.length === 0}
|
||||
<div class="p-4 text-center text-base-content/60">
|
||||
{buscaFuncionario ? "Nenhum funcionário encontrado com esse critério" : "Carregando funcionários..."}
|
||||
</div>
|
||||
{:else}
|
||||
{#each funcionariosFiltrados as func}
|
||||
<label class="flex items-center gap-3 p-3 hover:bg-base-200 cursor-pointer border-b last:border-b-0">
|
||||
<input
|
||||
type="radio"
|
||||
name="funcionario"
|
||||
value={func._id}
|
||||
bind:group={funcionarioSelecionadoId}
|
||||
class="radio radio-primary"
|
||||
/>
|
||||
<div class="flex-1">
|
||||
<div class="font-semibold">{func.nome}</div>
|
||||
<div class="text-sm text-base-content/70">
|
||||
CPF: {func.cpf || "N/A"}
|
||||
{#if func.matricula}
|
||||
| Matrícula: {func.matricula}
|
||||
{/if}
|
||||
</div>
|
||||
{#if func.descricaoCargo}
|
||||
<div class="text-xs text-base-content/60">{func.descricaoCargo}</div>
|
||||
{/if}
|
||||
</div>
|
||||
</label>
|
||||
{/each}
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Ações -->
|
||||
<div class="modal-action">
|
||||
<button
|
||||
class="btn btn-ghost"
|
||||
onclick={fecharModalAssociar}
|
||||
disabled={processando}
|
||||
>
|
||||
Cancelar
|
||||
</button>
|
||||
|
||||
{#if usuarioParaAssociar.funcionarioId}
|
||||
<button
|
||||
class="btn btn-error"
|
||||
onclick={desassociarFuncionario}
|
||||
disabled={processando}
|
||||
>
|
||||
{#if processando}
|
||||
<span class="loading loading-spinner loading-sm"></span>
|
||||
{/if}
|
||||
Desassociar
|
||||
</button>
|
||||
{/if}
|
||||
|
||||
<button
|
||||
class="btn btn-primary"
|
||||
onclick={associarFuncionario}
|
||||
disabled={processando || !funcionarioSelecionadoId}
|
||||
>
|
||||
{#if processando}
|
||||
<span class="loading loading-spinner loading-sm"></span>
|
||||
{/if}
|
||||
{usuarioParaAssociar.funcionarioId ? "Alterar" : "Associar"}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
||||
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||
<div class="modal-backdrop" onclick={fecharModalAssociar}></div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user