feat: enhance vacation approval process by adding notification system for employees, including email alerts and in-app notifications; improve error handling and user feedback during vacation management

This commit is contained in:
2025-12-10 06:27:25 -03:00
parent 73da995109
commit d27c0b6f91
22 changed files with 1572 additions and 215 deletions

View File

@@ -859,7 +859,11 @@ export const marcarNotificacaoLida = mutation({
if (!usuarioAtual) throw new Error('Não autenticado');
const notificacao = await ctx.db.get(args.notificacaoId);
if (!notificacao) throw new Error('Notificação não encontrada');
// Se a notificação não existe (já foi deletada), retornar sucesso silenciosamente
// Isso evita erros quando múltiplas tentativas são feitas ou quando a notificação já foi removida
if (!notificacao) {
return true;
}
// SEGURANÇA: Verificar se a notificação pertence ao usuário atual
if (notificacao.usuarioId !== usuarioAtual._id) {
@@ -874,6 +878,11 @@ export const marcarNotificacaoLida = mutation({
}
}
// Se já está marcada como lida, retornar sucesso sem fazer nada
if (notificacao.lida) {
return true;
}
await ctx.db.patch(args.notificacaoId, { lida: true });
return true;
}