feat: add mutation to exclude absence requests and enhance point registration by blocking entries during approved absences
This commit is contained in:
@@ -605,6 +605,15 @@ export const registrarPonto = mutation({
|
||||
const dia = String(dataObj.getUTCDate()).padStart(2, '0');
|
||||
const data = `${ano}-${mes}-${dia}`;
|
||||
|
||||
// Bloquear registro de ponto quando houver ausência aprovada ativa na data
|
||||
const ausenciaInfo = await verificarAusenciaAprovada(ctx, usuario.funcionarioId, data);
|
||||
if (ausenciaInfo.temAusencia) {
|
||||
throw new Error(
|
||||
ausenciaInfo.motivo ||
|
||||
'Não é possível registrar ponto: existe uma ausência aprovada ativa para esta data.'
|
||||
);
|
||||
}
|
||||
|
||||
// Verificar se já existe registro no mesmo minuto
|
||||
const funcionarioId = usuario.funcionarioId; // Já verificado acima, não é undefined
|
||||
const registrosMinuto = await ctx.db
|
||||
|
||||
Reference in New Issue
Block a user