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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user