feat: integrate point management features into the dashboard

- Added a new "Meu Ponto" section for users to register their work hours, breaks, and attendance.
- Introduced a "Controle de Ponto" category in the Recursos Humanos section for managing employee time records.
- Enhanced the backend schema to support point registration and configuration settings.
- Updated various components to improve UI consistency and user experience across the dashboard.
This commit is contained in:
2025-11-18 11:44:12 -03:00
parent 52123a33b3
commit f0c6e4468f
22 changed files with 3604 additions and 128 deletions

View File

@@ -0,0 +1,56 @@
import { api } from '@sgse-app/backend/convex/_generated/api';
import type { ConvexClient } from 'convex/browser';
/**
* Obtém tempo do servidor (sincronizado)
*/
export async function obterTempoServidor(client: ConvexClient): Promise<number> {
try {
// Tentar obter configuração e sincronizar se necessário
const config = await client.query(api.configuracaoRelogio.obterConfiguracao, {});
if (config.usarServidorExterno) {
try {
const resultado = await client.action(api.configuracaoRelogio.sincronizarTempo, {});
if (resultado.sucesso && resultado.timestamp) {
return resultado.timestamp;
}
} catch (error) {
console.warn('Erro ao sincronizar com servidor externo:', error);
if (config.fallbackParaPC) {
return Date.now();
}
throw error;
}
}
// Usar tempo do servidor Convex
const tempoServidor = await client.query(api.configuracaoRelogio.obterTempoServidor, {});
return tempoServidor.timestamp;
} catch (error) {
console.warn('Erro ao obter tempo do servidor, usando tempo local:', error);
return Date.now();
}
}
/**
* Obtém tempo do PC (fallback)
*/
export function obterTempoPC(): number {
return Date.now();
}
/**
* Calcula offset entre dois timestamps
*/
export function calcularOffset(timestampServidor: number, timestampLocal: number): number {
return timestampServidor - timestampLocal;
}
/**
* Aplica offset a um timestamp
*/
export function aplicarOffset(timestamp: number, offsetSegundos: number): number {
return timestamp + offsetSegundos * 1000;
}