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