feat: update email handling and user management logic

- Added logic to update user email if it differs from the existing record when updating a funcionario.
- Refactored email sending action to improve code readability and maintainability, including consistent formatting and error handling.
- Enhanced logging for email configuration and sending processes to provide clearer feedback during operations.
This commit is contained in:
2025-11-05 15:05:54 -03:00
parent d0bcef4d40
commit fe83a3d371
2 changed files with 50 additions and 18 deletions

View File

@@ -371,6 +371,17 @@ export const update = mutation({
}
}
const usuarioExists = await ctx.db
.query("usuarios")
.withIndex("by_funcionarioId", (q) => q.eq("funcionarioId", args.id))
.unique();
if (usuarioExists && usuarioExists.email !== args.email) {
await ctx.db.patch(usuarioExists._id, {
email: args.email,
});
}
const { id, ...updateData } = args;
await ctx.db.patch(id, updateData);
return null;