feat: add approval/rejection information and change history display in AprovarAusencias and AprovarFerias components for enhanced user feedback
This commit is contained in:
@@ -290,6 +290,20 @@ export const obterDetalhes = query({
|
||||
time = await ctx.db.get(membroTime.timeId);
|
||||
}
|
||||
|
||||
// Enriquecer histórico com nomes dos usuários
|
||||
let historicoComUsuarios = ferias.historicoAlteracoes;
|
||||
if (historicoComUsuarios && historicoComUsuarios.length > 0) {
|
||||
historicoComUsuarios = await Promise.all(
|
||||
historicoComUsuarios.map(async (hist) => {
|
||||
const usuario = await ctx.db.get(hist.usuarioId);
|
||||
return {
|
||||
...hist,
|
||||
usuarioNome: usuario?.nome || 'Usuário Desconhecido'
|
||||
};
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
...ferias,
|
||||
funcionario: funcionario
|
||||
@@ -299,7 +313,8 @@ export const obterDetalhes = query({
|
||||
}
|
||||
: null,
|
||||
gestor,
|
||||
time
|
||||
time,
|
||||
historicoAlteracoes: historicoComUsuarios
|
||||
};
|
||||
}
|
||||
});
|
||||
@@ -389,6 +404,10 @@ export const aprovar = mutation({
|
||||
|
||||
const funcionario = await ctx.db.get(registro.funcionarioId);
|
||||
|
||||
// Buscar nome do gestor para o histórico
|
||||
const gestorUsuario = await ctx.db.get(args.gestorId);
|
||||
const nomeGestor = gestorUsuario?.nome || 'Gestor';
|
||||
|
||||
// Atualizar o registro
|
||||
await ctx.db.patch(registro._id, {
|
||||
status: 'aprovado',
|
||||
@@ -399,7 +418,7 @@ export const aprovar = mutation({
|
||||
{
|
||||
data: Date.now(),
|
||||
usuarioId: args.gestorId,
|
||||
acao: 'Aprovado'
|
||||
acao: `Aprovado por ${nomeGestor}`
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user