feat: add functionality to manage employee status during point registration, preventing point logging for employees on vacation or leave; enhance UI alerts to inform users of their current status
This commit is contained in:
@@ -62,6 +62,12 @@
|
||||
funcionarioId && dataHoje ? { funcionarioId, data: dataHoje } : 'skip'
|
||||
);
|
||||
|
||||
// Query para obter status atual do funcionário (férias/licença)
|
||||
const funcionarioStatusQuery = useQuery(
|
||||
api.funcionarios.getCurrent,
|
||||
currentUser?.data ? {} : 'skip'
|
||||
);
|
||||
|
||||
// Estados
|
||||
let mostrandoWebcam = $state(false);
|
||||
let registrando = $state(false);
|
||||
@@ -86,6 +92,12 @@
|
||||
const registrosHoje = $derived(registrosHojeQuery?.data || []);
|
||||
const config = $derived(configQuery?.data);
|
||||
|
||||
// Status de férias/licença do funcionário
|
||||
const funcionarioStatus = $derived(funcionarioStatusQuery?.data);
|
||||
const statusFerias = $derived(funcionarioStatus?.statusFerias ?? 'ativo');
|
||||
const emFerias = $derived(statusFerias === 'em_ferias');
|
||||
const emLicenca = $derived(statusFerias === 'em_licenca');
|
||||
|
||||
const proximoTipo = $derived.by(() => {
|
||||
if (registrosHoje.length === 0) {
|
||||
return 'entrada';
|
||||
@@ -209,6 +221,16 @@
|
||||
return;
|
||||
}
|
||||
|
||||
// Verificar se funcionário está em férias ou licença
|
||||
if (emFerias || emLicenca) {
|
||||
mensagemErroModal = 'Registro de ponto não permitido';
|
||||
detalhesErroModal = emFerias
|
||||
? 'Seu status atual é "Em Férias". Durante o período de férias não é permitido registrar ponto.'
|
||||
: 'Seu status atual é "Em Licença". Durante o período de licença não é permitido registrar ponto.';
|
||||
mostrarModalErro = true;
|
||||
return;
|
||||
}
|
||||
|
||||
// Verificar permissões antes de registrar
|
||||
const permissoes = await verificarPermissoes();
|
||||
if (!permissoes.localizacao || !permissoes.webcam) {
|
||||
@@ -824,6 +846,8 @@
|
||||
!coletandoInfo &&
|
||||
config !== undefined &&
|
||||
!estaDispensado &&
|
||||
!emFerias &&
|
||||
!emLicenca &&
|
||||
temFuncionarioAssociado
|
||||
);
|
||||
});
|
||||
@@ -1051,6 +1075,25 @@
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<!-- Alerta de Status de Férias/Licença -->
|
||||
{#if temFuncionarioAssociado && (emFerias || emLicenca)}
|
||||
<div class="alert alert-info shadow-lg">
|
||||
<Info class="h-6 w-6 shrink-0 stroke-current" />
|
||||
<div>
|
||||
<h3 class="font-bold">Status do Funcionário</h3>
|
||||
<div class="text-sm">
|
||||
{#if emFerias}
|
||||
Seu status atual é <strong>Em Férias</strong>. Durante o período de férias não é permitido
|
||||
registrar ponto.
|
||||
{:else}
|
||||
Seu status atual é <strong>Em Licença</strong>. Durante o período de licença não é permitido
|
||||
registrar ponto.
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<!-- Card de Registro de Ponto Modernizado -->
|
||||
<div
|
||||
class="card from-base-100 via-base-100 to-primary/5 border-base-300 mx-auto max-w-2xl border bg-gradient-to-br shadow-2xl"
|
||||
@@ -1083,7 +1126,11 @@
|
||||
? 'Você não possui funcionário associado à sua conta'
|
||||
: estaDispensado
|
||||
? 'Você está dispensado de registrar ponto no momento'
|
||||
: ''}
|
||||
: emFerias
|
||||
? 'Você está em férias. Durante o período de férias não é permitido registrar ponto.'
|
||||
: emLicenca
|
||||
? 'Você está em licença. Durante o período de licença não é permitido registrar ponto.'
|
||||
: ''}
|
||||
>
|
||||
{#if registrando}
|
||||
<span class="loading loading-spinner loading-sm"></span>
|
||||
@@ -1098,6 +1145,12 @@
|
||||
{:else if estaDispensado}
|
||||
<XCircle class="h-5 w-5" />
|
||||
Registro Indisponível
|
||||
{:else if emFerias}
|
||||
<XCircle class="h-5 w-5" />
|
||||
Em Férias
|
||||
{:else if emLicenca}
|
||||
<XCircle class="h-5 w-5" />
|
||||
Em Licença
|
||||
{:else if proximoTipo === 'entrada' || proximoTipo === 'retorno_almoco'}
|
||||
<LogIn class="h-5 w-5" />
|
||||
Registrar Entrada
|
||||
|
||||
Reference in New Issue
Block a user