feat: enhance employee leave report generation by adding gestor information retrieval and improving filtering capabilities across components
This commit is contained in:
@@ -90,14 +90,33 @@ export const listarTodas = query({
|
||||
.first();
|
||||
|
||||
let time = null;
|
||||
let gestor = null;
|
||||
if (membroTime) {
|
||||
time = await ctx.db.get(membroTime.timeId);
|
||||
// Buscar gestor do time
|
||||
if (time?.gestorId) {
|
||||
const gestorUsuario = await ctx.db.get(time.gestorId);
|
||||
if (gestorUsuario) {
|
||||
// Buscar funcionário do gestor para obter o nome
|
||||
const gestorFuncionario = await ctx.db
|
||||
.query("funcionarios")
|
||||
.withIndex("by_usuario", (q) => q.eq("usuarioId", time.gestorId))
|
||||
.first();
|
||||
if (gestorFuncionario) {
|
||||
gestor = {
|
||||
_id: gestorUsuario._id,
|
||||
nome: gestorFuncionario.nome,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
...ferias,
|
||||
funcionario,
|
||||
time,
|
||||
gestor,
|
||||
};
|
||||
})
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user