feat: enhance user management with matricula retrieval and validation
- Updated user-related queries and mutations to retrieve the matricula from associated funcionario records, improving data accuracy. - Refactored user creation and listing functionalities to ensure matricula is correctly handled and displayed. - Enhanced error handling and validation for user operations, ensuring a more robust user management experience. - Improved the overall structure of user-related code for better maintainability and clarity.
This commit is contained in:
@@ -88,9 +88,14 @@ export const listar = query({
|
||||
if (log.usuarioId) {
|
||||
const user = await ctx.db.get(log.usuarioId);
|
||||
if (user) {
|
||||
let matricula: string | undefined = undefined;
|
||||
if (user.funcionarioId) {
|
||||
const funcionario = await ctx.db.get(user.funcionarioId);
|
||||
matricula = funcionario?.matricula;
|
||||
}
|
||||
usuario = {
|
||||
_id: user._id,
|
||||
matricula: user.matricula,
|
||||
matricula: matricula || "",
|
||||
nome: user.nome,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user