feat: enhance notification management with new clearing functionalities

- Added functionality to clear all notifications and clear unread notifications for improved user control.
- Updated NotificationBell component to support modal display for notifications, enhancing user experience.
- Refactored notification handling to separate read and unread notifications, providing clearer organization.
- Introduced new UI elements for managing notifications, including buttons for clearing notifications directly from the modal.
- Improved backend mutations to handle notification deletion securely, ensuring users can only delete their own notifications.
This commit is contained in:
2025-11-05 15:06:41 -03:00
parent 6166043735
commit 1b02ea7c22
3 changed files with 394 additions and 157 deletions

View File

@@ -208,6 +208,21 @@
templates.find((t) => t._id === templateId),
);
// Função para renderizar template com variáveis (similar à função do backend)
function renderizarTemplate(
template: string,
variaveis: Record<string, string>,
): string {
let resultado = template;
for (const [chave, valor] of Object.entries(variaveis)) {
const placeholder = `{{${chave}}}`;
resultado = resultado.replace(new RegExp(placeholder, "g"), valor);
}
return resultado;
}
// Função para mostrar mensagens
function mostrarMensagem(tipo: "success" | "error" | "info", texto: string) {
mensagem = { tipo, texto };
@@ -733,8 +748,11 @@
);
if (conversaId) {
const mensagem = usarTemplate
? templateSelecionado?.corpo || ""
const mensagem = usarTemplate && templateSelecionado
? renderizarTemplate(templateSelecionado.corpo, {
nome: destinatario.nome,
matricula: destinatario.matricula || "",
})
: mensagemPersonalizada;
if (agendadaPara) {
@@ -988,10 +1006,12 @@
);
if (conversaId) {
// Para templates, usar corpo direto (o backend já faz substituição via email)
// Para mensagem personalizada, usar diretamente
const mensagem = usarTemplate
? templateSelecionado?.corpo || ""
// Renderizar template com variáveis do destinatário
const mensagem = usarTemplate && templateSelecionado
? renderizarTemplate(templateSelecionado.corpo, {
nome: destinatario.nome,
matricula: destinatario.matricula || "",
})
: mensagemPersonalizada;
if (agendadaPara) {