refactor: enhance role management UI and integrate profile management features
- Introduced a modal for managing user profiles, allowing for the creation and editing of profiles with improved state management. - Updated the role filtering logic to enhance type safety and readability. - Refactored UI components for better user experience, including improved button states and loading indicators. - Removed outdated code related to permissions and streamlined the overall structure for maintainability.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { v } from "convex/values";
|
||||
import { mutation, query } from "./_generated/server";
|
||||
import { Id } from "./_generated/dataModel";
|
||||
|
||||
// Mutation para fazer upload de arquivo e obter o storage ID
|
||||
export const generateUploadUrl = mutation({
|
||||
@@ -72,9 +73,70 @@ export const getDocumentosUrls = query({
|
||||
throw new Error("Funcionário não encontrado");
|
||||
}
|
||||
|
||||
// Gerar URLs para todos os documentos
|
||||
const urls: Record<string, string | null> = {};
|
||||
const campos = [
|
||||
// Tipo exato do retorno para alinhar com o validator
|
||||
type DocumentUrls = {
|
||||
certidaoAntecedentesPF: string | null;
|
||||
certidaoAntecedentesJFPE: string | null;
|
||||
certidaoAntecedentesSDS: string | null;
|
||||
certidaoAntecedentesTJPE: string | null;
|
||||
certidaoImprobidade: string | null;
|
||||
rgFrente: string | null;
|
||||
rgVerso: string | null;
|
||||
cpfFrente: string | null;
|
||||
cpfVerso: string | null;
|
||||
situacaoCadastralCPF: string | null;
|
||||
tituloEleitorFrente: string | null;
|
||||
tituloEleitorVerso: string | null;
|
||||
comprovanteVotacao: string | null;
|
||||
carteiraProfissionalFrente: string | null;
|
||||
carteiraProfissionalVerso: string | null;
|
||||
comprovantePIS: string | null;
|
||||
certidaoRegistroCivil: string | null;
|
||||
certidaoNascimentoDependentes: string | null;
|
||||
cpfDependentes: string | null;
|
||||
reservistaDoc: string | null;
|
||||
comprovanteEscolaridade: string | null;
|
||||
comprovanteResidencia: string | null;
|
||||
comprovanteContaBradesco: string | null;
|
||||
declaracaoAcumulacaoCargo: string | null;
|
||||
declaracaoDependentesIR: string | null;
|
||||
declaracaoIdoneidade: string | null;
|
||||
termoNepotismo: string | null;
|
||||
termoOpcaoRemuneracao: string | null;
|
||||
};
|
||||
|
||||
const urls: DocumentUrls = {
|
||||
certidaoAntecedentesPF: null,
|
||||
certidaoAntecedentesJFPE: null,
|
||||
certidaoAntecedentesSDS: null,
|
||||
certidaoAntecedentesTJPE: null,
|
||||
certidaoImprobidade: null,
|
||||
rgFrente: null,
|
||||
rgVerso: null,
|
||||
cpfFrente: null,
|
||||
cpfVerso: null,
|
||||
situacaoCadastralCPF: null,
|
||||
tituloEleitorFrente: null,
|
||||
tituloEleitorVerso: null,
|
||||
comprovanteVotacao: null,
|
||||
carteiraProfissionalFrente: null,
|
||||
carteiraProfissionalVerso: null,
|
||||
comprovantePIS: null,
|
||||
certidaoRegistroCivil: null,
|
||||
certidaoNascimentoDependentes: null,
|
||||
cpfDependentes: null,
|
||||
reservistaDoc: null,
|
||||
comprovanteEscolaridade: null,
|
||||
comprovanteResidencia: null,
|
||||
comprovanteContaBradesco: null,
|
||||
declaracaoAcumulacaoCargo: null,
|
||||
declaracaoDependentesIR: null,
|
||||
declaracaoIdoneidade: null,
|
||||
termoNepotismo: null,
|
||||
termoOpcaoRemuneracao: null,
|
||||
};
|
||||
|
||||
const campos: Array<keyof DocumentUrls> = [
|
||||
"certidaoAntecedentesPF",
|
||||
"certidaoAntecedentesJFPE",
|
||||
"certidaoAntecedentesSDS",
|
||||
@@ -106,7 +168,9 @@ export const getDocumentosUrls = query({
|
||||
];
|
||||
|
||||
for (const campo of campos) {
|
||||
const storageId = funcionario[campo as keyof typeof funcionario] as Id<"_storage"> | undefined;
|
||||
const storageId = (funcionario as Record<string, unknown>)[campo as string] as
|
||||
| Id<"_storage">
|
||||
| undefined;
|
||||
if (storageId) {
|
||||
urls[campo] = await ctx.storage.getUrl(storageId);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user