refactor: enhance chat components with type safety and response functionality
- Updated type definitions in ChatWindow and MessageList components for better type safety. - Improved MessageInput to handle message responses, including a preview feature for replying to messages. - Enhanced the chat message handling logic to support message references and improve user interaction. - Refactored notification utility functions to support push notifications and rate limiting for email sending. - Updated backend schema to accommodate new features related to message responses and notifications.
This commit is contained in:
@@ -1,69 +1,73 @@
|
||||
<script lang="ts">
|
||||
import { page } from "$app/state";
|
||||
import ActionGuard from "$lib/components/ActionGuard.svelte";
|
||||
import { Toaster } from "svelte-sonner";
|
||||
const { children } = $props();
|
||||
|
||||
// Resolver recurso/ação a partir da rota
|
||||
const routeAction = $derived.by(() => {
|
||||
const p = page.url.pathname;
|
||||
if (p === "/" || p === "/solicitar-acesso") return null;
|
||||
|
||||
// Funcionários
|
||||
if (p.startsWith("/recursos-humanos/funcionarios")) {
|
||||
if (p.includes("/cadastro"))
|
||||
return { recurso: "funcionarios", acao: "criar" };
|
||||
if (p.includes("/excluir"))
|
||||
return { recurso: "funcionarios", acao: "excluir" };
|
||||
if (p.includes("/editar") || p.includes("/funcionarioId"))
|
||||
return { recurso: "funcionarios", acao: "editar" };
|
||||
return { recurso: "funcionarios", acao: "listar" };
|
||||
}
|
||||
|
||||
// Símbolos
|
||||
if (p.startsWith("/recursos-humanos/simbolos")) {
|
||||
if (p.includes("/cadastro"))
|
||||
return { recurso: "simbolos", acao: "criar" };
|
||||
if (p.includes("/excluir"))
|
||||
return { recurso: "simbolos", acao: "excluir" };
|
||||
if (p.includes("/editar") || p.includes("/simboloId"))
|
||||
return { recurso: "simbolos", acao: "editar" };
|
||||
return { recurso: "simbolos", acao: "listar" };
|
||||
}
|
||||
|
||||
// Outras áreas (uso genérico: ver)
|
||||
if (p.startsWith("/financeiro"))
|
||||
return { recurso: "financeiro", acao: "ver" };
|
||||
if (p.startsWith("/controladoria"))
|
||||
return { recurso: "controladoria", acao: "ver" };
|
||||
if (p.startsWith("/licitacoes"))
|
||||
return { recurso: "licitacoes", acao: "ver" };
|
||||
if (p.startsWith("/compras")) return { recurso: "compras", acao: "ver" };
|
||||
if (p.startsWith("/juridico")) return { recurso: "juridico", acao: "ver" };
|
||||
if (p.startsWith("/comunicacao"))
|
||||
return { recurso: "comunicacao", acao: "ver" };
|
||||
if (p.startsWith("/programas-esportivos"))
|
||||
return { recurso: "programas_esportivos", acao: "ver" };
|
||||
if (p.startsWith("/secretaria-executiva"))
|
||||
return { recurso: "secretaria_executiva", acao: "ver" };
|
||||
if (p.startsWith("/gestao-pessoas"))
|
||||
return { recurso: "gestao_pessoas", acao: "ver" };
|
||||
|
||||
return null;
|
||||
});
|
||||
</script>
|
||||
|
||||
{#if routeAction}
|
||||
<ActionGuard recurso={routeAction.recurso} acao={routeAction.acao}>
|
||||
<main id="container-central" class="w-full max-w-none px-3 lg:px-4 py-4">
|
||||
{@render children()}
|
||||
</main>
|
||||
</ActionGuard>
|
||||
{:else}
|
||||
<main id="container-central" class="w-full max-w-none px-3 lg:px-4 py-4">
|
||||
{@render children()}
|
||||
</main>
|
||||
{/if}
|
||||
|
||||
<!-- Toast Notifications (Sonner) -->
|
||||
<Toaster position="top-right" richColors closeButton expand={true} />
|
||||
<script lang="ts">
|
||||
import { page } from "$app/state";
|
||||
import ActionGuard from "$lib/components/ActionGuard.svelte";
|
||||
import { Toaster } from "svelte-sonner";
|
||||
import PushNotificationManager from "$lib/components/PushNotificationManager.svelte";
|
||||
const { children } = $props();
|
||||
|
||||
// Resolver recurso/ação a partir da rota
|
||||
const routeAction = $derived.by(() => {
|
||||
const p = page.url.pathname;
|
||||
if (p === "/" || p === "/solicitar-acesso") return null;
|
||||
|
||||
// Funcionários
|
||||
if (p.startsWith("/recursos-humanos/funcionarios")) {
|
||||
if (p.includes("/cadastro"))
|
||||
return { recurso: "funcionarios", acao: "criar" };
|
||||
if (p.includes("/excluir"))
|
||||
return { recurso: "funcionarios", acao: "excluir" };
|
||||
if (p.includes("/editar") || p.includes("/funcionarioId"))
|
||||
return { recurso: "funcionarios", acao: "editar" };
|
||||
return { recurso: "funcionarios", acao: "listar" };
|
||||
}
|
||||
|
||||
// Símbolos
|
||||
if (p.startsWith("/recursos-humanos/simbolos")) {
|
||||
if (p.includes("/cadastro"))
|
||||
return { recurso: "simbolos", acao: "criar" };
|
||||
if (p.includes("/excluir"))
|
||||
return { recurso: "simbolos", acao: "excluir" };
|
||||
if (p.includes("/editar") || p.includes("/simboloId"))
|
||||
return { recurso: "simbolos", acao: "editar" };
|
||||
return { recurso: "simbolos", acao: "listar" };
|
||||
}
|
||||
|
||||
// Outras áreas (uso genérico: ver)
|
||||
if (p.startsWith("/financeiro"))
|
||||
return { recurso: "financeiro", acao: "ver" };
|
||||
if (p.startsWith("/controladoria"))
|
||||
return { recurso: "controladoria", acao: "ver" };
|
||||
if (p.startsWith("/licitacoes"))
|
||||
return { recurso: "licitacoes", acao: "ver" };
|
||||
if (p.startsWith("/compras")) return { recurso: "compras", acao: "ver" };
|
||||
if (p.startsWith("/juridico")) return { recurso: "juridico", acao: "ver" };
|
||||
if (p.startsWith("/comunicacao"))
|
||||
return { recurso: "comunicacao", acao: "ver" };
|
||||
if (p.startsWith("/programas-esportivos"))
|
||||
return { recurso: "programas_esportivos", acao: "ver" };
|
||||
if (p.startsWith("/secretaria-executiva"))
|
||||
return { recurso: "secretaria_executiva", acao: "ver" };
|
||||
if (p.startsWith("/gestao-pessoas"))
|
||||
return { recurso: "gestao_pessoas", acao: "ver" };
|
||||
|
||||
return null;
|
||||
});
|
||||
</script>
|
||||
|
||||
{#if routeAction}
|
||||
<ActionGuard recurso={routeAction.recurso} acao={routeAction.acao}>
|
||||
<main id="container-central" class="w-full max-w-none px-3 lg:px-4 py-4">
|
||||
{@render children()}
|
||||
</main>
|
||||
</ActionGuard>
|
||||
{:else}
|
||||
<main id="container-central" class="w-full max-w-none px-3 lg:px-4 py-4">
|
||||
{@render children()}
|
||||
</main>
|
||||
{/if}
|
||||
|
||||
<!-- Toast Notifications (Sonner) -->
|
||||
<Toaster position="top-right" richColors closeButton expand={true} />
|
||||
|
||||
<!-- Push Notification Manager (registra subscription automaticamente) -->
|
||||
<PushNotificationManager />
|
||||
|
||||
Reference in New Issue
Block a user