Ajustes gerais - Etapa 1 #52
@@ -2,8 +2,13 @@ import { api } from "@sgse-app/backend/convex/_generated/api";
|
|||||||
import { createConvexHttpClient } from "@mmailaender/convex-better-auth-svelte/sveltekit";
|
import { createConvexHttpClient } from "@mmailaender/convex-better-auth-svelte/sveltekit";
|
||||||
|
|
||||||
export const load = async ({ locals }) => {
|
export const load = async ({ locals }) => {
|
||||||
const client = createConvexHttpClient({ token: locals.token });
|
try {
|
||||||
|
const client = createConvexHttpClient({ token: locals.token });
|
||||||
const currentUser = await client.query(api.auth.getCurrentUser, {});
|
const currentUser = await client.query(api.auth.getCurrentUser, {});
|
||||||
return { currentUser };
|
return { currentUser };
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Erro ao carregar usuário atual no layout do dashboard:", error);
|
||||||
|
// Evita quebrar toda a área logada em caso de falha transitória na API/auth
|
||||||
|
return { currentUser: null };
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1147,27 +1147,27 @@
|
|||||||
<div
|
<div
|
||||||
class="rounded-2xl bg-base-100/80 shadow-xl border border-base-200/60 p-6 lg:p-8 space-y-6 backdrop-blur"
|
class="rounded-2xl bg-base-100/80 shadow-xl border border-base-200/60 p-6 lg:p-8 space-y-6 backdrop-blur"
|
||||||
>
|
>
|
||||||
<!-- Header -->
|
<!-- Header -->
|
||||||
<div class="flex flex-col gap-4 lg:flex-row lg:items-center lg:justify-between">
|
<div class="flex flex-col gap-4 lg:flex-row lg:items-center lg:justify-between">
|
||||||
<div class="flex items-center gap-4">
|
<div class="flex items-center gap-4">
|
||||||
<div class="bg-gradient-to-br from-primary/15 via-info/10 to-secondary/10 rounded-2xl p-3">
|
<div class="bg-gradient-to-br from-primary/15 via-info/10 to-secondary/10 rounded-2xl p-3">
|
||||||
<svg
|
<svg
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
class="text-primary h-9 w-9"
|
class="text-primary h-9 w-9"
|
||||||
fill="none"
|
fill="none"
|
||||||
viewBox="0 0 24 24"
|
viewBox="0 0 24 24"
|
||||||
stroke="currentColor"
|
stroke="currentColor"
|
||||||
>
|
>
|
||||||
<path
|
<path
|
||||||
stroke-linecap="round"
|
stroke-linecap="round"
|
||||||
stroke-linejoin="round"
|
stroke-linejoin="round"
|
||||||
stroke-width="2"
|
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"
|
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>
|
</svg>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<h1 class="text-base-content text-3xl font-bold">Notificações e Mensagens</h1>
|
<h1 class="text-base-content text-3xl font-bold">Notificações e Mensagens</h1>
|
||||||
<p class="text-base-content/60 mt-1 text-sm lg:text-base">
|
<p class="text-base-content/60 mt-1 text-sm lg:text-base">
|
||||||
Envie avisos importantes por <span class="font-semibold">chat</span> e
|
Envie avisos importantes por <span class="font-semibold">chat</span> e
|
||||||
<span class="font-semibold">email HTML padronizado</span> para os usuários do SGSE.
|
<span class="font-semibold">email HTML padronizado</span> para os usuários do SGSE.
|
||||||
@@ -1186,11 +1186,11 @@
|
|||||||
<div class="text-base-content text-lg font-semibold">
|
<div class="text-base-content text-lg font-semibold">
|
||||||
{totalTemplates}
|
{totalTemplates}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- Mensagens de Feedback -->
|
<!-- Mensagens de Feedback -->
|
||||||
{#if mensagem}
|
{#if mensagem}
|
||||||
<div
|
<div
|
||||||
class="alert mb-6 shadow-lg"
|
class="alert mb-6 shadow-lg"
|
||||||
|
|||||||
@@ -96,193 +96,176 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="container mx-auto max-w-7xl px-4 py-6">
|
<div class="container mx-auto max-w-7xl px-4 py-8">
|
||||||
<!-- Header -->
|
<div
|
||||||
<div class="mb-6 flex items-center justify-between">
|
class="rounded-2xl bg-base-100/80 shadow-xl border border-base-200/60 p-6 lg:p-8 space-y-6 backdrop-blur"
|
||||||
<div class="flex items-center gap-4">
|
>
|
||||||
<div class="bg-info/10 rounded-xl p-3">
|
<!-- Header -->
|
||||||
<svg
|
<div class="flex flex-col gap-4 lg:flex-row lg:items-center lg:justify-between">
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
<div class="flex items-center gap-4">
|
||||||
class="text-info h-8 w-8"
|
<div class="bg-gradient-to-br from-info/15 via-primary/10 to-secondary/10 rounded-2xl p-3">
|
||||||
fill="none"
|
|
||||||
viewBox="0 0 24 24"
|
|
||||||
stroke="currentColor"
|
|
||||||
>
|
|
||||||
<path
|
|
||||||
stroke-linecap="round"
|
|
||||||
stroke-linejoin="round"
|
|
||||||
stroke-width="2"
|
|
||||||
d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<h1 class="text-base-content text-3xl font-bold">Gerenciar Templates</h1>
|
|
||||||
<p class="text-base-content/60 mt-1">Criar, editar e excluir templates de emails e mensagens</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<a href="/ti/notificacoes" 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="M10 19l-7-7m0 0l7-7m-7 7h18" />
|
|
||||||
</svg>
|
|
||||||
Voltar
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Mensagens de Feedback -->
|
|
||||||
{#if mensagem}
|
|
||||||
<div
|
|
||||||
class="alert mb-6 shadow-lg"
|
|
||||||
class:alert-success={mensagem.tipo === 'success'}
|
|
||||||
class:alert-error={mensagem.tipo === 'error'}
|
|
||||||
class:alert-info={mensagem.tipo === 'info'}
|
|
||||||
>
|
|
||||||
<span class="font-medium">{mensagem.texto}</span>
|
|
||||||
<button type="button" class="btn btn-sm btn-circle btn-ghost" onclick={() => (mensagem = null)}>
|
|
||||||
✕
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
{/if}
|
|
||||||
|
|
||||||
<!-- Filtros e Busca -->
|
|
||||||
<div class="card bg-base-100 mb-6 shadow-xl">
|
|
||||||
<div class="card-body">
|
|
||||||
<div class="grid grid-cols-1 gap-4 md:grid-cols-2">
|
|
||||||
<div class="form-control">
|
|
||||||
<label class="label">
|
|
||||||
<span class="label-text font-medium">Buscar</span>
|
|
||||||
</label>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
bind:value={buscaTexto}
|
|
||||||
placeholder="Buscar por nome, código ou título..."
|
|
||||||
class="input input-bordered"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div class="form-control">
|
|
||||||
<label class="label">
|
|
||||||
<span class="label-text font-medium">Categoria</span>
|
|
||||||
</label>
|
|
||||||
<select bind:value={filtroCategoria} class="select select-bordered">
|
|
||||||
<option value="todos">Todas</option>
|
|
||||||
<option value="email">Email</option>
|
|
||||||
<option value="chat">Chat</option>
|
|
||||||
<option value="ambos">Ambos</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Lista de Templates -->
|
|
||||||
<div class="card bg-base-100 shadow-xl">
|
|
||||||
<div class="card-body">
|
|
||||||
<div class="mb-4 flex items-center justify-between">
|
|
||||||
<h2 class="card-title">Templates ({templatesFiltrados.length})</h2>
|
|
||||||
<a href="/ti/notificacoes/templates/novo" class="btn btn-primary">
|
|
||||||
<svg
|
<svg
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
class="h-5 w-5"
|
class="text-info h-9 w-9"
|
||||||
fill="none"
|
fill="none"
|
||||||
viewBox="0 0 24 24"
|
viewBox="0 0 24 24"
|
||||||
stroke="currentColor"
|
stroke="currentColor"
|
||||||
>
|
>
|
||||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4" />
|
<path
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
stroke-width="2"
|
||||||
|
d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"
|
||||||
|
/>
|
||||||
</svg>
|
</svg>
|
||||||
Novo Template
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{#if templatesFiltrados.length === 0}
|
|
||||||
<div class="py-10 text-center">
|
|
||||||
<p class="text-base-content/60">Nenhum template encontrado.</p>
|
|
||||||
</div>
|
</div>
|
||||||
{:else}
|
<div>
|
||||||
<div class="overflow-x-auto">
|
<h1 class="text-base-content text-3xl font-bold">Gerenciar Templates</h1>
|
||||||
<table class="table-zebra table">
|
<p class="text-base-content/60 mt-1 text-sm lg:text-base">
|
||||||
<thead>
|
Crie, edite e organize templates de <span class="font-semibold">chat</span> (texto puro) e
|
||||||
<tr>
|
<span class="font-semibold">email HTML padronizado</span> usados em todas as notificações do SGSE.
|
||||||
<th>Código</th>
|
</p>
|
||||||
<th>Nome</th>
|
</div>
|
||||||
<th>Tipo</th>
|
</div>
|
||||||
<th>Categoria</th>
|
<a href="/ti/notificacoes" class="btn btn-outline gap-2">
|
||||||
<th>Variáveis</th>
|
<svg
|
||||||
<th>Ações</th>
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
</tr>
|
class="h-5 w-5"
|
||||||
</thead>
|
fill="none"
|
||||||
<tbody>
|
viewBox="0 0 24 24"
|
||||||
{#each templatesFiltrados as template (template._id)}
|
stroke="currentColor"
|
||||||
|
>
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 19l-7-7m0 0l7-7m-7 7h18" />
|
||||||
|
</svg>
|
||||||
|
Voltar para Notificações
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Mensagens de Feedback -->
|
||||||
|
{#if mensagem}
|
||||||
|
<div
|
||||||
|
class="alert shadow-lg"
|
||||||
|
class:alert-success={mensagem.tipo === 'success'}
|
||||||
|
class:alert-error={mensagem.tipo === 'error'}
|
||||||
|
class:alert-info={mensagem.tipo === 'info'}
|
||||||
|
>
|
||||||
|
<span class="font-medium">{mensagem.texto}</span>
|
||||||
|
<button type="button" class="btn btn-sm btn-circle btn-ghost" onclick={() => (mensagem = null)}>
|
||||||
|
✕
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
<!-- Filtros e Busca -->
|
||||||
|
<div class="card bg-base-100 shadow-sm border border-base-200">
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="grid grid-cols-1 gap-4 md:grid-cols-2">
|
||||||
|
<div class="form-control">
|
||||||
|
<label class="label">
|
||||||
|
<span class="label-text font-medium">Buscar</span>
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
bind:value={buscaTexto}
|
||||||
|
placeholder="Buscar por nome, código ou título..."
|
||||||
|
class="input input-bordered"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div class="form-control">
|
||||||
|
<label class="label">
|
||||||
|
<span class="label-text font-medium">Categoria</span>
|
||||||
|
</label>
|
||||||
|
<select bind:value={filtroCategoria} class="select select-bordered">
|
||||||
|
<option value="todos">Todas</option>
|
||||||
|
<option value="email">Email</option>
|
||||||
|
<option value="chat">Chat</option>
|
||||||
|
<option value="ambos">Ambos</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Lista de Templates -->
|
||||||
|
<div class="card bg-base-100 shadow-sm border border-base-200">
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="mb-4 flex items-center justify-between">
|
||||||
|
<h2 class="card-title">Templates ({templatesFiltrados.length})</h2>
|
||||||
|
<a href="/ti/notificacoes/templates/novo" class="btn btn-primary gap-2">
|
||||||
|
<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" />
|
||||||
|
</svg>
|
||||||
|
Novo Template
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{#if templatesFiltrados.length === 0}
|
||||||
|
<div class="py-10 text-center">
|
||||||
|
<p class="text-base-content/60">Nenhum template encontrado.</p>
|
||||||
|
</div>
|
||||||
|
{:else}
|
||||||
|
<div class="overflow-x-auto">
|
||||||
|
<table class="table-zebra table">
|
||||||
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<th>Código</th>
|
||||||
<code class="badge badge-ghost">{template.codigo}</code>
|
<th>Nome</th>
|
||||||
</td>
|
<th>Tipo</th>
|
||||||
<td>
|
<th>Categoria</th>
|
||||||
<div class="font-medium">{template.nome}</div>
|
<th>Variáveis</th>
|
||||||
<div class="text-sm text-base-content/60">{template.titulo}</div>
|
<th>Ações</th>
|
||||||
</td>
|
</tr>
|
||||||
<td>
|
</thead>
|
||||||
{#if template.tipo === 'sistema'}
|
<tbody>
|
||||||
<span class="badge badge-info">Sistema</span>
|
{#each templatesFiltrados as template (template._id)}
|
||||||
{:else}
|
<tr>
|
||||||
<span class="badge badge-success">Customizado</span>
|
<td>
|
||||||
{/if}
|
<code class="badge badge-ghost">{template.codigo}</code>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{#if template.categoria}
|
<div class="font-medium">{template.nome}</div>
|
||||||
<span class="badge badge-outline">{template.categoria}</span>
|
<div class="text-sm text-base-content/60">{template.titulo}</div>
|
||||||
{:else}
|
</td>
|
||||||
<span class="badge badge-ghost">-</span>
|
<td>
|
||||||
{/if}
|
{#if template.tipo === 'sistema'}
|
||||||
</td>
|
<span class="badge badge-info">Sistema</span>
|
||||||
<td>
|
{:else}
|
||||||
{#if template.variaveis && template.variaveis.length > 0}
|
<span class="badge badge-success">Customizado</span>
|
||||||
<div class="flex flex-wrap gap-1">
|
{/if}
|
||||||
{#each template.variaveis.slice(0, 3) as variavel}
|
</td>
|
||||||
<span class="badge badge-sm">{{variavel}}</span>
|
<td>
|
||||||
{/each}
|
{#if template.categoria}
|
||||||
{#if template.variaveis.length > 3}
|
<span class="badge badge-outline">{template.categoria}</span>
|
||||||
<span class="badge badge-sm">+{template.variaveis.length - 3}</span>
|
{:else}
|
||||||
{/if}
|
<span class="badge badge-ghost">-</span>
|
||||||
</div>
|
{/if}
|
||||||
{:else}
|
</td>
|
||||||
<span class="text-base-content/40">-</span>
|
<td>
|
||||||
{/if}
|
{#if template.variaveis && template.variaveis.length > 0}
|
||||||
</td>
|
<div class="flex flex-wrap gap-1">
|
||||||
<td>
|
{#each template.variaveis.slice(0, 3) as variavel}
|
||||||
<div class="flex gap-2">
|
<span class="badge badge-sm">{{variavel}}</span>
|
||||||
<a
|
{/each}
|
||||||
href="/ti/notificacoes/templates/{template._id}"
|
{#if template.variaveis.length > 3}
|
||||||
class="btn btn-sm btn-ghost"
|
<span class="badge badge-sm">+{template.variaveis.length - 3}</span>
|
||||||
title="Editar"
|
{/if}
|
||||||
>
|
</div>
|
||||||
<svg
|
{:else}
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
<span class="text-base-content/40">-</span>
|
||||||
class="h-4 w-4"
|
{/if}
|
||||||
fill="none"
|
</td>
|
||||||
viewBox="0 0 24 24"
|
<td>
|
||||||
stroke="currentColor"
|
<div class="flex gap-2">
|
||||||
>
|
<a
|
||||||
<path
|
href="/ti/notificacoes/templates/{template._id}"
|
||||||
stroke-linecap="round"
|
class="btn btn-sm btn-ghost"
|
||||||
stroke-linejoin="round"
|
title="Editar"
|
||||||
stroke-width="2"
|
|
||||||
d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
</a>
|
|
||||||
{#if template.tipo === 'customizado'}
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
class="btn btn-sm btn-ghost text-error"
|
|
||||||
onclick={() => excluirTemplate(template._id)}
|
|
||||||
disabled={processando}
|
|
||||||
title="Excluir"
|
|
||||||
>
|
>
|
||||||
<svg
|
<svg
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
@@ -295,19 +278,43 @@
|
|||||||
stroke-linecap="round"
|
stroke-linecap="round"
|
||||||
stroke-linejoin="round"
|
stroke-linejoin="round"
|
||||||
stroke-width="2"
|
stroke-width="2"
|
||||||
d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"
|
d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"
|
||||||
/>
|
/>
|
||||||
</svg>
|
</svg>
|
||||||
</button>
|
</a>
|
||||||
{/if}
|
{#if template.tipo === 'customizado'}
|
||||||
</div>
|
<button
|
||||||
</td>
|
type="button"
|
||||||
</tr>
|
class="btn btn-sm btn-ghost text-error"
|
||||||
{/each}
|
onclick={() => excluirTemplate(template._id)}
|
||||||
</tbody>
|
disabled={processando}
|
||||||
</table>
|
title="Excluir"
|
||||||
</div>
|
>
|
||||||
{/if}
|
<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="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{/each}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -110,63 +110,66 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="container mx-auto max-w-4xl px-4 py-6">
|
<div class="container mx-auto max-w-4xl px-4 py-8">
|
||||||
<div class="mb-6 flex items-center justify-between">
|
<div
|
||||||
<div class="flex items-center gap-4">
|
class="rounded-2xl bg-base-100/80 shadow-xl border border-base-200/60 p-6 lg:p-8 space-y-6 backdrop-blur"
|
||||||
<div class="bg-info/10 rounded-xl p-3">
|
>
|
||||||
<svg
|
<div class="mb-4 flex items-center justify-between">
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
<div class="flex items-center gap-4">
|
||||||
class="text-info h-8 w-8"
|
<div class="bg-gradient-to-br from-info/15 via-primary/10 to-secondary/10 rounded-2xl p-3">
|
||||||
fill="none"
|
<svg
|
||||||
viewBox="0 0 24 24"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
stroke="currentColor"
|
class="text-info h-9 w-9"
|
||||||
>
|
fill="none"
|
||||||
<path
|
viewBox="0 0 24 24"
|
||||||
stroke-linecap="round"
|
stroke="currentColor"
|
||||||
stroke-linejoin="round"
|
>
|
||||||
stroke-width="2"
|
<path
|
||||||
d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"
|
stroke-linecap="round"
|
||||||
/>
|
stroke-linejoin="round"
|
||||||
</svg>
|
stroke-width="2"
|
||||||
</div>
|
d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"
|
||||||
<div>
|
/>
|
||||||
<h1 class="text-base-content text-3xl font-bold">Editar Template</h1>
|
</svg>
|
||||||
<p class="text-base-content/60 mt-1">
|
</div>
|
||||||
Atualize as informações do template selecionado. Templates de sistema não podem ser
|
<div>
|
||||||
editados.
|
<h1 class="text-base-content text-3xl font-bold">Editar Template</h1>
|
||||||
</p>
|
<p class="text-base-content/60 mt-1 text-sm lg:text-base">
|
||||||
|
Ajuste o texto base usado em <span class="font-semibold">chat</span> e na versão HTML de
|
||||||
|
<span class="font-semibold">email</span>. Templates de sistema podem ter restrições de edição.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<a href={resolve('/ti/notificacoes/templates')} class="btn btn-outline"> Voltar </a>
|
||||||
</div>
|
</div>
|
||||||
<a href={resolve('/ti/notificacoes/templates')} class="btn btn-ghost"> Voltar </a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{#if !template}
|
{#if !template}
|
||||||
<div class="alert alert-error">
|
<div class="alert alert-error">
|
||||||
<span>Template não encontrado.</span>
|
<span>Template não encontrado.</span>
|
||||||
</div>
|
|
||||||
{:else}
|
|
||||||
{#if mensagem}
|
|
||||||
<div
|
|
||||||
class="alert mb-6 shadow-lg"
|
|
||||||
class:alert-success={mensagem.tipo === 'success'}
|
|
||||||
class:alert-error={mensagem.tipo === 'error'}
|
|
||||||
class:alert-info={mensagem.tipo === 'info'}
|
|
||||||
>
|
|
||||||
<span class="font-medium">{mensagem.texto}</span>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
class="btn btn-sm btn-circle btn-ghost"
|
|
||||||
onclick={() => {
|
|
||||||
mensagem = null;
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
✕
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{:else}
|
||||||
|
{#if mensagem}
|
||||||
|
<div
|
||||||
|
class="alert mb-4 shadow-lg"
|
||||||
|
class:alert-success={mensagem.tipo === 'success'}
|
||||||
|
class:alert-error={mensagem.tipo === 'error'}
|
||||||
|
class:alert-info={mensagem.tipo === 'info'}
|
||||||
|
>
|
||||||
|
<span class="font-medium">{mensagem.texto}</span>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="btn btn-sm btn-circle btn-ghost"
|
||||||
|
onclick={() => {
|
||||||
|
mensagem = null;
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
✕
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
<div class="card bg-base-100 shadow-xl">
|
<div class="card bg-base-100 shadow-sm border border-base-200">
|
||||||
<div class="card-body space-y-4">
|
<div class="card-body space-y-4">
|
||||||
<div class="grid grid-cols-1 gap-4 md:grid-cols-2">
|
<div class="grid grid-cols-1 gap-4 md:grid-cols-2">
|
||||||
<div class="form-control">
|
<div class="form-control">
|
||||||
<label class="label" for="nome">
|
<label class="label" for="nome">
|
||||||
@@ -277,6 +280,6 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
{/if}
|
||||||
{/if}
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -79,57 +79,61 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="container mx-auto max-w-4xl px-4 py-6">
|
<div class="container mx-auto max-w-4xl px-4 py-8">
|
||||||
<div class="mb-6 flex items-center justify-between">
|
<div
|
||||||
<div class="flex items-center gap-4">
|
class="rounded-2xl bg-base-100/80 shadow-xl border border-base-200/60 p-6 lg:p-8 space-y-6 backdrop-blur"
|
||||||
<div class="bg-info/10 rounded-xl p-3">
|
>
|
||||||
<svg
|
<div class="mb-4 flex items-center justify-between">
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
<div class="flex items-center gap-4">
|
||||||
class="text-info h-8 w-8"
|
<div class="bg-gradient-to-br from-info/15 via-primary/10 to-secondary/10 rounded-2xl p-3">
|
||||||
fill="none"
|
<svg
|
||||||
viewBox="0 0 24 24"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
stroke="currentColor"
|
class="text-info h-9 w-9"
|
||||||
>
|
fill="none"
|
||||||
<path
|
viewBox="0 0 24 24"
|
||||||
stroke-linecap="round"
|
stroke="currentColor"
|
||||||
stroke-linejoin="round"
|
>
|
||||||
stroke-width="2"
|
<path
|
||||||
d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"
|
stroke-linecap="round"
|
||||||
/>
|
stroke-linejoin="round"
|
||||||
</svg>
|
stroke-width="2"
|
||||||
</div>
|
d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"
|
||||||
<div>
|
/>
|
||||||
<h1 class="text-base-content text-3xl font-bold">Novo Template</h1>
|
</svg>
|
||||||
<p class="text-base-content/60 mt-1">
|
</div>
|
||||||
Crie um template de email ou mensagem para reutilizar no sistema.
|
<div>
|
||||||
</p>
|
<h1 class="text-base-content text-3xl font-bold">Novo Template</h1>
|
||||||
|
<p class="text-base-content/60 mt-1 text-sm lg:text-base">
|
||||||
|
Defina o texto base que será usado em <span class="font-semibold">chat</span> e na versão
|
||||||
|
HTML de <span class="font-semibold">email</span> com o estilo padrão do SGSE.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<a href={resolve('/ti/notificacoes/templates')} class="btn btn-outline"> Voltar </a>
|
||||||
</div>
|
</div>
|
||||||
<a href={resolve('/ti/notificacoes/templates')} class="btn btn-ghost"> Voltar </a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{#if mensagem}
|
{#if mensagem}
|
||||||
<div
|
<div
|
||||||
class="alert mb-6 shadow-lg"
|
class="alert mb-4 shadow-lg"
|
||||||
class:alert-success={mensagem.tipo === 'success'}
|
class:alert-success={mensagem.tipo === 'success'}
|
||||||
class:alert-error={mensagem.tipo === 'error'}
|
class:alert-error={mensagem.tipo === 'error'}
|
||||||
class:alert-info={mensagem.tipo === 'info'}
|
class:alert-info={mensagem.tipo === 'info'}
|
||||||
>
|
|
||||||
<span class="font-medium">{mensagem.texto}</span>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
class="btn btn-sm btn-circle btn-ghost"
|
|
||||||
onclick={() => {
|
|
||||||
mensagem = null;
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
✕
|
<span class="font-medium">{mensagem.texto}</span>
|
||||||
</button>
|
<button
|
||||||
</div>
|
type="button"
|
||||||
{/if}
|
class="btn btn-sm btn-circle btn-ghost"
|
||||||
|
onclick={() => {
|
||||||
|
mensagem = null;
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
✕
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
<div class="card bg-base-100 shadow-xl">
|
<div class="card bg-base-100 shadow-sm border border-base-200">
|
||||||
<div class="card-body space-y-4">
|
<div class="card-body space-y-4">
|
||||||
<div class="grid grid-cols-1 gap-4 md:grid-cols-2">
|
<div class="grid grid-cols-1 gap-4 md:grid-cols-2">
|
||||||
<div class="form-control">
|
<div class="form-control">
|
||||||
<label class="label" for="codigo">
|
<label class="label" for="codigo">
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { v } from 'convex/values';
|
import { v } from 'convex/values';
|
||||||
import { mutation, query, internalMutation } from './_generated/server';
|
import { mutation, query, internalMutation } from './_generated/server';
|
||||||
import { internal } from './_generated/api';
|
import { internal, api } from './_generated/api';
|
||||||
import { Id } from './_generated/dataModel';
|
import { Id } from './_generated/dataModel';
|
||||||
import type { QueryCtx } from './_generated/server';
|
import type { QueryCtx } from './_generated/server';
|
||||||
|
|
||||||
@@ -387,7 +387,9 @@ export const verificarAlertasInternal = internalMutation({
|
|||||||
threshold: alerta.threshold.toString()
|
threshold: alerta.threshold.toString()
|
||||||
};
|
};
|
||||||
|
|
||||||
await ctx.scheduler.runAfter(0, internal.email.enviarEmailComTemplate, {
|
// Importante: usar api.email.enviarEmailComTemplate (action pública),
|
||||||
|
// e não internal.email, para corresponder à tipagem gerada em ./_generated/api.
|
||||||
|
await ctx.scheduler.runAfter(0, api.email.enviarEmailComTemplate, {
|
||||||
destinatario: email,
|
destinatario: email,
|
||||||
destinatarioId: usuario._id,
|
destinatarioId: usuario._id,
|
||||||
templateCodigo: 'monitoramento_alerta_sistema',
|
templateCodigo: 'monitoramento_alerta_sistema',
|
||||||
|
|||||||
Reference in New Issue
Block a user