fix(Deploy): Ajustes para build de versão
This commit is contained in:
parent
e98a293286
commit
f9df3cd8a3
130 changed files with 1124 additions and 1627 deletions
8
package-lock.json
generated
8
package-lock.json
generated
|
|
@ -33,7 +33,7 @@
|
|||
"clsx": "^2.1.1",
|
||||
"cmdk": "^1.1.1",
|
||||
"cookies-next": "^6.1.0",
|
||||
"date-fns": "^4.1.0",
|
||||
"date-fns": "^3.6.0",
|
||||
"faker-js": "^1.0.0",
|
||||
"framer-motion": "^12.23.24",
|
||||
"input-otp": "^1.4.2",
|
||||
|
|
@ -4459,9 +4459,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/date-fns": {
|
||||
"version": "4.1.0",
|
||||
"resolved": "https://registry.npmjs.org/date-fns/-/date-fns-4.1.0.tgz",
|
||||
"integrity": "sha512-Ukq0owbQXxa/U3EGtsdVBkR1w7KOQ5gIBqdH2hkvknzZPYvBxb/aa6E8L7tmjFtkwZBu3UXBbjIgPo/Ez4xaNg==",
|
||||
"version": "3.6.0",
|
||||
"resolved": "https://registry.npmjs.org/date-fns/-/date-fns-3.6.0.tgz",
|
||||
"integrity": "sha512-fRHTG8g/Gif+kSh50gaGEdToemgfj74aRX3swtiouboip5JDLAyDE9F11nHMIcvOaXeOC6D7SpNhi7uFyB7Uww==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@
|
|||
"clsx": "^2.1.1",
|
||||
"cmdk": "^1.1.1",
|
||||
"cookies-next": "^6.1.0",
|
||||
"date-fns": "^4.1.0",
|
||||
"date-fns": "^3.6.0",
|
||||
"faker-js": "^1.0.0",
|
||||
"framer-motion": "^12.23.24",
|
||||
"input-otp": "^1.4.2",
|
||||
|
|
|
|||
|
|
@ -1,50 +0,0 @@
|
|||
'use client';
|
||||
|
||||
import { useEffect } from 'react';
|
||||
import { useParams } from 'next/navigation';
|
||||
|
||||
import { Card, CardContent } from '@/components/ui/card';
|
||||
import { useGUsuarioReadHooks } from '@/packages/administrativo/hooks/GUsuario/useGUsuarioReadHooks';
|
||||
import Usuario from '@/packages/administrativo/interfaces/GUsuario/GUsuarioInterface';
|
||||
import Loading from '@/shared/components/loading/loading';
|
||||
|
||||
export default function UsuarioDetalhes() {
|
||||
const params = useParams();
|
||||
|
||||
const { usuario, fetchUsuario } = useGUsuarioReadHooks();
|
||||
|
||||
useEffect(() => {
|
||||
if (params.id) {
|
||||
fetchUsuario({ usuario_id: Number(params.id) } as Usuario);
|
||||
}
|
||||
}, []);
|
||||
|
||||
if (!usuario) return <Loading type={1} />;
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Card>
|
||||
<CardContent>
|
||||
<div className="mb-4 grid grid-cols-4 gap-4">
|
||||
<div>
|
||||
<div className="text-2xl font-semibold">Nome</div>
|
||||
<div className="text-xl">{usuario?.nome_completo}</div>
|
||||
</div>
|
||||
<div>
|
||||
<div className="text-2xl font-semibold">CPF</div>
|
||||
<div className="text-xl">{usuario?.cpf}</div>
|
||||
</div>
|
||||
<div>
|
||||
<div className="text-2xl font-semibold">Função</div>
|
||||
<div className="text-xl">{usuario?.funcao}</div>
|
||||
</div>
|
||||
<div>
|
||||
<div className="text-2xl font-semibold">Email</div>
|
||||
<div className="text-xl">{usuario?.email}</div>
|
||||
</div>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,126 +0,0 @@
|
|||
'use client';
|
||||
|
||||
import { zodResolver } from '@hookform/resolvers/zod';
|
||||
import { useForm } from 'react-hook-form';
|
||||
import { z } from 'zod';
|
||||
|
||||
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Card, CardContent } from '@/components/ui/card';
|
||||
import {
|
||||
Form,
|
||||
FormControl,
|
||||
FormField,
|
||||
FormItem,
|
||||
FormLabel,
|
||||
FormMessage,
|
||||
} from '@/components/ui/form';
|
||||
import { Input } from '@/components/ui/input';
|
||||
|
||||
import { useGUsuarioSaveHook } from '../../../../../../packages/administrativo/hooks/GUsuario/useGUsuarioSaveHook';
|
||||
import { GUsuarioSchema } from '../../../../../../packages/administrativo/schemas/GUsuario/GUsuarioSchema';
|
||||
|
||||
type FormValues = z.infer<typeof GUsuarioSchema>;
|
||||
|
||||
export default function UsuarioFormularioPage() {
|
||||
const { usuario, saveUsuario } = useGUsuarioSaveHook();
|
||||
|
||||
const form = useForm<FormValues>({
|
||||
resolver: zodResolver(GUsuarioSchema),
|
||||
defaultValues: {
|
||||
login: '',
|
||||
nome_completo: '',
|
||||
funcao: '',
|
||||
email: '',
|
||||
cpf: '',
|
||||
},
|
||||
});
|
||||
|
||||
async function onSubmit(values: FormValues) {
|
||||
saveUsuario(values);
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Card>
|
||||
<CardContent>
|
||||
<Form {...form}>
|
||||
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-8">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="login"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Login</FormLabel>
|
||||
<FormControl>
|
||||
<Input {...field} />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="nome_completo"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Nome Completo</FormLabel>
|
||||
<FormControl>
|
||||
<Input {...field} />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="funcao"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Função</FormLabel>
|
||||
<FormControl>
|
||||
<Input {...field} />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="email"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Email</FormLabel>
|
||||
<FormControl>
|
||||
<Input {...field} />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="cpf"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Cpf</FormLabel>
|
||||
<FormControl>
|
||||
<Input {...field} />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
<Button type="submit">Salvar</Button>
|
||||
</form>
|
||||
</Form>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,85 +0,0 @@
|
|||
'use client';
|
||||
|
||||
import Link from 'next/link';
|
||||
import { useEffect } from 'react';
|
||||
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Card, CardContent } from '@/components/ui/card';
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableHead,
|
||||
TableHeader,
|
||||
TableRow,
|
||||
} from '@/components/ui/table';
|
||||
import Loading from '@/shared/components/loading/loading';
|
||||
|
||||
import { useGUsuarioIndexHook } from '../../../../../packages/administrativo/hooks/GUsuario/useGUsuarioIndexHook';
|
||||
import Usuario from '../../../../../packages/administrativo/interfaces/GUsuario/GUsuarioInterface';
|
||||
|
||||
|
||||
|
||||
|
||||
export default function UsuarioPage() {
|
||||
const { usuarios, fetchUsuarios } = useGUsuarioIndexHook();
|
||||
|
||||
useEffect(() => {
|
||||
fetchUsuarios();
|
||||
}, []);
|
||||
|
||||
if (!usuarios) return <Loading type={2} />;
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Card>
|
||||
<CardContent>
|
||||
<div className="grid grid-cols-2">
|
||||
<div className="text-2xl font-semibold">Usuarios</div>
|
||||
<div className="text-right">
|
||||
<Button asChild>
|
||||
<Link href="/usuarios/formulario">+ Usuário</Link>
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead className="text-center">#</TableHead>
|
||||
<TableHead>Situação</TableHead>
|
||||
<TableHead>CPF</TableHead>
|
||||
<TableHead>Login / Sigla / Nome</TableHead>
|
||||
<TableHead>Função</TableHead>
|
||||
<TableHead></TableHead>
|
||||
<TableHead></TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{usuarios.map((usuario: Usuario) => (
|
||||
<TableRow key={usuario.usuario_id} className="cursor-pointer">
|
||||
<TableCell className="text-center">{usuario.usuario_id}</TableCell>
|
||||
<TableCell className="font-medium">{usuario.situacao}</TableCell>
|
||||
<TableCell className="font-medium">{usuario.cpf}</TableCell>
|
||||
<TableCell>
|
||||
<div className="text-xs font-semibold">
|
||||
{usuario.login} - {usuario.sigla}
|
||||
</div>
|
||||
<div className="text-base">{usuario.nome_completo}</div>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<div className="text-base">{usuario.funcao}</div>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<Button asChild>
|
||||
<Link href={`/usuarios/${usuario.usuario_id}/detalhes`}>Detalhes</Link>
|
||||
</Button>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
import TServicoTipoIndex from "@/packages/administrativo/components/TServicoTipo/TServicoTipoIndex";
|
||||
|
||||
export default function TServicoTipoPage() {
|
||||
|
||||
return (
|
||||
<TServicoTipoIndex />
|
||||
);
|
||||
|
||||
}
|
||||
|
|
@ -1,101 +0,0 @@
|
|||
'use client';
|
||||
|
||||
import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuGroup,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger,
|
||||
} from '@/components/ui/dropdown-menu';
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableHead,
|
||||
TableHeader,
|
||||
TableRow,
|
||||
} from '@/components/ui/table';
|
||||
|
||||
import { EllipsisIcon, PencilIcon, Trash2Icon } from 'lucide-react';
|
||||
import TServicoTipoInterface from '../../_interfaces/TServicoTipoInterface'; // Import alterado
|
||||
|
||||
// Tipagem das props do componente da tabela
|
||||
interface TServicoTipoTableProps {
|
||||
// Nome da interface alterado
|
||||
data: TServicoTipoInterface[]; // lista de tipos de serviço
|
||||
onEdit: (item: TServicoTipoInterface, isEditingFormStatus: boolean) => void; // callback para edição
|
||||
onDelete: (item: TServicoTipoInterface, isEditingFormStatus: boolean) => void; // callback para exclusão
|
||||
}
|
||||
|
||||
/**
|
||||
* Componente principal da tabela de Tipos de Serviço
|
||||
*/
|
||||
export default function TServicoTipoTable({ data, onEdit, onDelete }: TServicoTipoTableProps) {
|
||||
return (
|
||||
<Table className="w-full table-fixed">
|
||||
{/* Cabeçalho da tabela */}
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead className="w-15 font-bold">#</TableHead>
|
||||
{/* As colunas IBGE e UF foram removidas */}
|
||||
<TableHead className="font-bold">Descrição</TableHead>
|
||||
<TableHead className="text-right"></TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
|
||||
{/* Corpo da tabela */}
|
||||
<TableBody>
|
||||
{data.map((item) => (
|
||||
// Assumindo que o ID do Tipo de Serviço é 'servico_tipo_id'
|
||||
<TableRow key={item.servico_tipo_id} className="cursor-pointer">
|
||||
{/* ID do Tipo de Serviço */}
|
||||
<TableCell>{item.servico_tipo_id}</TableCell>
|
||||
|
||||
{/* Nome/descrição do Tipo de Serviço (descricao) */}
|
||||
<TableCell>{item.descricao}</TableCell>
|
||||
{/* As células de IBGE e UF foram removidas */}
|
||||
|
||||
{/* Ações (menu dropdown) */}
|
||||
<TableCell className="text-right">
|
||||
<DropdownMenu>
|
||||
{/* Botão de disparo do menu */}
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button variant="outline" size="icon" className="cursor-pointer">
|
||||
<EllipsisIcon />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
|
||||
{/* Conteúdo do menu */}
|
||||
<DropdownMenuContent side="left" align="start">
|
||||
<DropdownMenuGroup>
|
||||
{/* Opção editar */}
|
||||
<DropdownMenuItem
|
||||
className="cursor-pointer"
|
||||
onSelect={() => onEdit(item, true)}
|
||||
>
|
||||
<PencilIcon className="mr-2 h-4 w-4" />
|
||||
Editar
|
||||
</DropdownMenuItem>
|
||||
|
||||
<DropdownMenuSeparator />
|
||||
|
||||
{/* Opção remover */}
|
||||
<DropdownMenuItem
|
||||
className="cursor-pointer"
|
||||
onSelect={() => onDelete(item, true)}
|
||||
>
|
||||
<Trash2Icon className="mr-2 h-4 w-4" />
|
||||
Remover
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuGroup>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
// Importa o utilitário responsável por tratar erros de forma padronizada no cliente
|
||||
import { withClientErrorHandler } from '@/shared/actions/withClientErrorHandler/withClientErrorHandler';
|
||||
|
||||
// Importa a classe de serviço que gerencia requisições HTTP para a API
|
||||
import API from '@/shared/services/api/Api';
|
||||
|
||||
// Importa o enum que define os métodos HTTP disponíveis (GET, POST, PUT, DELETE, etc.)
|
||||
import { Methods } from '@/shared/services/api/enums/ApiMethodEnum';
|
||||
|
||||
import { GEmolumentoReadInterface } from '../../_interfaces/GEmolumentoReadInterface';
|
||||
|
||||
// Função assíncrona responsável por executar a requisição para listar os tipos de marcação
|
||||
async function executeGEmolumentoIndexData(data: GEmolumentoReadInterface) {
|
||||
|
||||
// Cria uma nova instância da classe API para enviar a requisição
|
||||
const api = new API();
|
||||
|
||||
// Envia uma requisição GET para o endpoint 'administrativo/g_marcacao_tipo/'
|
||||
return await api.send({
|
||||
method: Methods.GET,
|
||||
endpoint: `administrativo/g_emolumento/sistema/${data.sistema_id}?${new URLSearchParams(data.urlParams).toString()}`,
|
||||
});
|
||||
}
|
||||
|
||||
// Exporta a função encapsulada pelo handler de erro, garantindo tratamento uniforme em caso de falhas
|
||||
export const GEmolumentoIndexData = withClientErrorHandler(executeGEmolumentoIndexData);
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
// Importa o utilitário responsável por tratar erros de forma padronizada no cliente
|
||||
import { withClientErrorHandler } from '@/shared/actions/withClientErrorHandler/withClientErrorHandler';
|
||||
|
||||
// Importa a classe de serviço que gerencia requisições HTTP para a API
|
||||
import API from '@/shared/services/api/Api';
|
||||
|
||||
// Importa o enum que define os métodos HTTP disponíveis (GET, POST, PUT, DELETE, etc.)
|
||||
import { Methods } from '@/shared/services/api/enums/ApiMethodEnum';
|
||||
import { TTBReconhecimentoTipoReadInterface } from '../../_interfaces/TTBReconhecimentoTipoReadInterface';
|
||||
|
||||
// Função assíncrona responsável por executar a requisição para listar os tipos de marcação
|
||||
async function executeTTBReconhecimentoTipoIndexData(data: TTBReconhecimentoTipoReadInterface) {
|
||||
// Cria uma nova instância da classe API para enviar a requisição
|
||||
const api = new API();
|
||||
|
||||
// Concatena o endpoint com a query string (caso existam parâmetros)
|
||||
const endpoint = `administrativo/t_tb_reconhecimentotipo/`;
|
||||
|
||||
// Envia uma requisição GET para o endpoint 'administrativo/g_marcacao_tipo/'
|
||||
return await api.send({
|
||||
method: Methods.GET,
|
||||
endpoint: endpoint,
|
||||
});
|
||||
}
|
||||
|
||||
// Exporta a função encapsulada pelo handler de erro, garantindo tratamento uniforme em caso de falhas
|
||||
export const TTBReconhecimentoTipoIndexData = withClientErrorHandler(
|
||||
executeTTBReconhecimentoTipoIndexData,
|
||||
);
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
// Importa o hook responsável por gerenciar e exibir respostas globais (sucesso, erro, etc.)
|
||||
import { useMemo, useState } from 'react';
|
||||
|
||||
import { useResponse } from '@/shared/components/response/ResponseContext';
|
||||
|
||||
// Importa hooks do React para gerenciamento de estado e memorização de valores
|
||||
|
||||
// Importa a interface que define a estrutura dos dados de "GEmolumento"
|
||||
import { GEmolumentoInterface } from '../../_interfaces/GEmolumentoInterface';
|
||||
import { GEmolumentoReadInterface } from '../../_interfaces/GEmolumentoReadInterface';
|
||||
|
||||
// Importa o serviço responsável por buscar os dados de "GEmolumento" na API
|
||||
import { GEmolumentoIndexService } from '../../_services/g_emolumento/GEmolumentoIndexService';
|
||||
|
||||
// Hook personalizado para leitura (consulta) dos emolumentos
|
||||
export const useGEmolumentoReadHook = () => {
|
||||
// Obtém a função que atualiza a resposta global do sistema
|
||||
const { setResponse } = useResponse();
|
||||
|
||||
// Define o estado local que armazenará a lista de emolumentos
|
||||
const [gEmolumento, setGEmolumento] = useState<GEmolumentoInterface[]>([]);
|
||||
|
||||
// Função responsável por buscar os dados da API e atualizar o estado
|
||||
const fetchGEmolumento = async (data: GEmolumentoReadInterface) => {
|
||||
// Executa o serviço que faz a requisição à API
|
||||
const response = await GEmolumentoIndexService(data);
|
||||
|
||||
// Atualiza o estado local com os dados retornados
|
||||
setGEmolumento(response.data);
|
||||
|
||||
// Atualiza o contexto global de resposta (ex: para exibir alertas ou mensagens)
|
||||
setResponse(response);
|
||||
};
|
||||
|
||||
// Retorna os dados e a função de busca, memorizando o valor para evitar recriações desnecessárias
|
||||
return useMemo(() => ({ gEmolumento, fetchGEmolumento }), [gEmolumento, fetchGEmolumento]);
|
||||
};
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
// Importa o hook responsável por gerenciar e exibir respostas globais (sucesso, erro, etc.)
|
||||
import { useResponse } from '@/shared/components/response/ResponseContext';
|
||||
|
||||
// Importa hooks do React para gerenciamento de estado e memorização de valores
|
||||
import { useMemo, useState } from 'react';
|
||||
|
||||
// Importa a interface que define a estrutura dos dados de "TTBReconhecimentoTipo"
|
||||
import { TTBReconhecimentoTipoReadInterface } from '../../_interfaces/TTBReconhecimentoTipoReadInterface';
|
||||
import { TTBReconhecimentoTipoInterface } from '../../_interfaces/TTBReconhecimentoTipoInterface';
|
||||
|
||||
// Importa o serviço responsável por buscar os dados de "TTBReconhecimentoTipo" na API
|
||||
import { TTBReconhecimentoTipoIndexService } from '../../_services/t_tb_reconhecimentotipo/TTBReconhecimentoTipoIndexService';
|
||||
|
||||
// Hook personalizado para leitura (consulta) dos tipos de marcação
|
||||
export const useTTBReconhecimentoTipoReadHook = () => {
|
||||
// Obtém a função que atualiza a resposta global do sistema
|
||||
const { setResponse } = useResponse();
|
||||
|
||||
// Define o estado local que armazenará a lista de tipos de marcação
|
||||
const [tTBReconhecimentoTipo, setTTBReconhecimentoTipo] = useState<
|
||||
TTBReconhecimentoTipoInterface[]
|
||||
>([]);
|
||||
|
||||
// Função responsável por buscar os dados da API e atualizar o estado
|
||||
const fetchTTBReconhecimentoTipo = async (data: TTBReconhecimentoTipoReadInterface) => {
|
||||
// Executa o serviço que faz a requisição à API
|
||||
const response = await TTBReconhecimentoTipoIndexService(data);
|
||||
|
||||
// Atualiza o estado local com os dados retornados
|
||||
setTTBReconhecimentoTipo(response.data);
|
||||
|
||||
// Atualiza o contexto global de resposta (ex: para exibir alertas ou mensagens)
|
||||
setResponse(response);
|
||||
};
|
||||
|
||||
// Retorna os dados e a função de busca, memorizando o valor para evitar recriações desnecessárias
|
||||
return useMemo(
|
||||
() => ({ tTBReconhecimentoTipo, fetchTTBReconhecimentoTipo }),
|
||||
[tTBReconhecimentoTipo, fetchTTBReconhecimentoTipo],
|
||||
);
|
||||
};
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
// Interface que representa a tabela G_EMOLUMENTO
|
||||
export interface GEmolumentoInterface {
|
||||
emolumento_id?: number; // NUMERIC(10,2) - Chave primária
|
||||
descricao?: string; // VARCHAR(260)
|
||||
tipo?: string; // VARCHAR(1)
|
||||
sistema_id?: number; // NUMERIC(10,2)
|
||||
selo_grupo_id?: number; // NUMERIC(10,2)
|
||||
reg_averb?: string; // VARCHAR(1)
|
||||
pre_definido?: string; // VARCHAR(1)
|
||||
situacao?: string; // VARCHAR(1)
|
||||
situacao_ri?: string; // VARCHAR(1)
|
||||
com_reducao?: string; // VARCHAR(1)
|
||||
motivo_reducao?: string; // VARCHAR(120)
|
||||
valor_maximo_certidao?: number; // NUMERIC(14,3)
|
||||
tipo_objetivo?: string; // VARCHAR(3)
|
||||
modelo_tag?: string; // VARCHAR(3)
|
||||
codigo_nota_id?: number; // NUMERIC(10,2)
|
||||
convenio_codhab?: string; // VARCHAR(1)
|
||||
item_df?: string; // VARCHAR(10)
|
||||
}
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
// Interface que representa a tabela G_EMOLUMENTO_ITEM (inferido)
|
||||
export interface GEmolumentoItemInterface {
|
||||
valor_emolumento?: number; // NUMERIC(14,3)
|
||||
emolumento_item_id: number; // NUMERIC(10,2) NOT NULL - Chave primária (assumida)
|
||||
emolumento_id?: number; // NUMERIC(10,2)
|
||||
valor_inicio?: number; // NUMERIC(14,3)
|
||||
valor_fim?: number; // NUMERIC(14,3)
|
||||
valor_taxa_judiciaria?: number; // NUMERIC(14,3)
|
||||
emolumento_periodo_id?: number; // NUMERIC(10,2)
|
||||
codigo?: number; // NUMERIC(10,2)
|
||||
pagina_extra?: number; // NUMERIC(10,2)
|
||||
valor_pagina_extra?: number; // NUMERIC(14,3)
|
||||
valor_outra_taxa1?: number; // NUMERIC(14,3)
|
||||
codigo_selo?: string; // VARCHAR(30)
|
||||
valor_fundo_ri?: number; // NUMERIC(14,3)
|
||||
codigo_tabela?: string; // VARCHAR(30)
|
||||
selo_grupo_id?: number; // NUMERIC(10,2)
|
||||
codigo_km?: string; // VARCHAR(30)
|
||||
emolumento_acresce?: number; // NUMERIC(14,3)
|
||||
taxa_acresce?: number; // NUMERIC(14,3)
|
||||
funcivil_acresce?: number; // NUMERIC(14,3)
|
||||
valor_fracao?: number; // NUMERIC(14,3)
|
||||
valor_por_excedente_emol?: number; // NUMERIC(14,3)
|
||||
valor_por_excedente_tj?: number; // NUMERIC(14,3)
|
||||
valor_por_excedente_fundo?: number; // NUMERIC(14,3)
|
||||
valor_limite_excedente_emol?: number; // NUMERIC(14,3)
|
||||
valor_limite_excedente_tj?: number; // NUMERIC(14,3)
|
||||
valor_limite_excedente_fundo?: number; // NUMERIC(14,3)
|
||||
fundo_selo?: number; // NUMERIC(14,3)
|
||||
distribuicao?: number; // NUMERIC(14,3)
|
||||
vrc_ext?: number; // NUMERIC(10,2) - Renomeado de VRCEXT para vrc_ext (convenção)
|
||||
}
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
export default interface TServicoTipoInterface {
|
||||
servico_tipo_id?: number; // SERVICO_TIPO_ID NUMERIC(10,2) NOT NULL (PK)
|
||||
descricao: string; // DESCRICAO VARCHAR(60)
|
||||
valor?: number; // VALOR NUMERIC(14,3)
|
||||
tipo_item?: string;
|
||||
requer_autorizacao?: string; // REQUER_AUTORIZACAO VARCHAR(1)
|
||||
requer_biometria?: string; // REQUER_BIOMETRIA VARCHAR(1)
|
||||
tipo_pessoa?: string; // TIPO_PESSOA VARCHAR(1)
|
||||
tb_reconhecimentotipo_id?: number; // TB_RECONHECIMENTOTIPO_ID NUMERIC(10,2) (FK)
|
||||
requer_abonador?: string; // REQUER_ABONADOR VARCHAR(1)
|
||||
situacao?: string; // SITUACAO VARCHAR(1)
|
||||
requer_cpf?: string; // REQUER_CPF VARCHAR(1)
|
||||
servico_padrao?: string; // SERVICO_PADRAO VARCHAR(1)
|
||||
maximo_pessoa?: number; // MAXIMO_PESSOA NUMERIC(10,2)
|
||||
alterar_valor?: string; // ALTERAR_VALOR VARCHAR(1)
|
||||
servico_caixa_id?: number; // SERVICO_CAIXA_ID NUMERIC(10,2)
|
||||
caixa_servico_id?: number; // LIBERAR_DESCONTO VARCHAR(1)
|
||||
valor_fixo?: string; // VALOR_FIXO VARCHAR(1)
|
||||
emolumento_id?: number; // EMOLUMENTO_ID NUMERIC(10,2) (FK)
|
||||
emolumento_obrigatorio?: number; // EMOLUMENTO_OBRIGATORIO NUMERIC(10,2) (FK)
|
||||
ato_praticado?: string; // ATO_PRATICADO VARCHAR(1)
|
||||
selar?: string; // SELAR VARCHAR(1)
|
||||
frenteverso?: string; // FRENTEVERSO VARCHAR(1)
|
||||
etiqueta_unica?: string; // ETIQUETA_UNICA VARCHAR(1)
|
||||
transferencia_veiculo?: string; // TRANSFERENCIA_VEICULO VARCHAR(1)
|
||||
usar_a4?: string; // USAR_A4 VARCHAR(1)
|
||||
averbacao?: string; // AVERBACAO VARCHAR(1)
|
||||
}
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
// Interface que representa a tabela T_TB_RECONHECIMENTOTIPO
|
||||
export interface TTbReconhecimentoTipoInterface {
|
||||
tb_reconhecimentotipo_id: number; // NUMERIC(10,2) NOT NULL - Chave primária
|
||||
descricao?: string; // VARCHAR(30)
|
||||
situacao?: string; // VARCHAR(1)
|
||||
}
|
||||
|
|
@ -1,78 +0,0 @@
|
|||
import z from 'zod';
|
||||
|
||||
/**
|
||||
* Tipos utilitários para campos simples
|
||||
*/
|
||||
const SN = z.enum(['S', 'N']).default('N'); // Campos do tipo Sim/Não
|
||||
const AI = z.enum(['A', 'I']).default('A'); // Situação Ativo/Inativo
|
||||
const OneCharString = z.string().max(1, 'Deve ter no máximo 1 caractere').optional();
|
||||
const RequiredString = z.string().min(1, 'O campo é obrigatório');
|
||||
const OptionalNumber = z.number().optional();
|
||||
const RequiredNumber = z.number();
|
||||
|
||||
/**
|
||||
* Schema principal baseado na DDL e adaptado ao formulário React
|
||||
*/
|
||||
export const TServicoTipoSchema = z.object({
|
||||
// Identificador
|
||||
servico_tipo_id: RequiredNumber.describe('ID do Tipo de Serviço').optional(),
|
||||
|
||||
// Campos principais
|
||||
descricao: z.string().max(60, 'A descrição deve ter no máximo 60 caracteres').optional(),
|
||||
categoria: z.string().optional(),
|
||||
|
||||
// Controle de flags (S/N)
|
||||
frenteverso: SN.optional(),
|
||||
averbacao: SN.optional(),
|
||||
transferencia_veiculo: SN.optional(),
|
||||
usar_a4: SN.optional(),
|
||||
etiqueta_unica: SN.optional(),
|
||||
selar: SN.optional(),
|
||||
servico_padrao: SN.optional(),
|
||||
// lancar_taxa: SN.optional(),
|
||||
// lancar_fundesp: SN.optional(),
|
||||
// liberar_desconto: SN.optional(),
|
||||
// fundesp_automatica: SN.optional(),
|
||||
// lancar_valor_documento: SN.optional(),
|
||||
valor_fixo: SN.optional(),
|
||||
ato_praticado: SN.optional(),
|
||||
// apresentante_selo: SN.optional(),
|
||||
// renovacao_cartao: SN.optional(),
|
||||
|
||||
// Situação
|
||||
situacao: AI,
|
||||
|
||||
// Campos numéricos
|
||||
valor: OptionalNumber,
|
||||
maximo_pessoa: OptionalNumber,
|
||||
servico_caixa_id: OptionalNumber,
|
||||
emolumento_id: z.number().nullable(),
|
||||
emolumento_obrigatorio: z.number().nullable(),
|
||||
|
||||
// Relacionamentos e permissões
|
||||
tipo_item: OneCharString,
|
||||
requer_autorizacao: OneCharString,
|
||||
requer_biometria: OneCharString,
|
||||
tipo_pessoa: OneCharString,
|
||||
tb_reconhecimentotipo_id: OptionalNumber,
|
||||
// tipo_permissao_cpf: OneCharString,
|
||||
requer_abonador: OneCharString,
|
||||
// requer_representante: OneCharString,
|
||||
requer_cpf: OneCharString,
|
||||
// alterar_valor: OneCharString,
|
||||
// pagina_acrescida: OneCharString,
|
||||
|
||||
// Campos auxiliares usados apenas no formulário (não persistidos)
|
||||
valor_emolumento: z.number().optional(),
|
||||
valor_taxa_judiciaria: z.number().optional(),
|
||||
fundesp_valor: z.number().optional(),
|
||||
valor_total: z.number().optional(),
|
||||
etiquetas_carimbos: z.any().optional(),
|
||||
emolumento: z.any().optional(),
|
||||
emolumento_auxiliar: z.any().optional(),
|
||||
});
|
||||
|
||||
/**
|
||||
* Tipo inferido do schema — usado diretamente no useForm
|
||||
*/
|
||||
export type TServicoTipoFormValues = z.infer<typeof TServicoTipoSchema>;
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
// Importa o utilitário responsável por lidar com erros de forma padronizada no cliente
|
||||
import { withClientErrorHandler } from '@/shared/actions/withClientErrorHandler/withClientErrorHandler';
|
||||
|
||||
// Importa a função que realiza a requisição de listagem dos tipos de marcação
|
||||
import { GEmolumentoIndexData } from '../../_data/GEmolumento/GEmolumentoIndexData';
|
||||
import { GEmolumentoReadInterface } from '../../_interfaces/GEmolumentoReadInterface';
|
||||
|
||||
// Função assíncrona responsável por executar o serviço de listagem de tipos de marcação
|
||||
async function executeGEmolumentoIndexService(data: GEmolumentoReadInterface) {
|
||||
|
||||
// Chama a função que realiza a requisição à API e aguarda a resposta
|
||||
const response = await GEmolumentoIndexData(data);
|
||||
|
||||
// Retorna a resposta obtida da requisição
|
||||
return response;
|
||||
}
|
||||
|
||||
// Exporta o serviço encapsulado pelo handler de erro, garantindo tratamento uniforme em caso de falhas
|
||||
export const GEmolumentoIndexService = withClientErrorHandler(executeGEmolumentoIndexService);
|
||||
|
|
@ -171,8 +171,8 @@ const data = {
|
|||
url: '/administrativo/centrais/censec/naturezas-litigios',
|
||||
},
|
||||
{
|
||||
title: 'Serviços/Tipos',
|
||||
url: '/cadastros/servicos-tipo/',
|
||||
title: 'Tipos/Serviços',
|
||||
url: '/administrativo/tipos-servicos',
|
||||
},
|
||||
{
|
||||
title: 'Atos/Partes Tipos',
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
'use client';
|
||||
|
||||
import React from 'react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
Command,
|
||||
|
|
@ -13,10 +12,11 @@ import {
|
|||
import { FormControl } from '@/components/ui/form';
|
||||
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { CheckIcon, ChevronsUpDownIcon } from 'lucide-react';
|
||||
import { CCaixaServicoReadInterface } from '@/packages/administrativo/hooks/CCaixaServico/CCaixaServicoReadInterface';
|
||||
import { useCCaixaServicoReadHook } from '@/packages/administrativo/interfaces/CCaixaServico/useCCaixaServicoReadHook';
|
||||
import GetCapitalize from '@/shared/actions/text/GetCapitalize';
|
||||
import { useCCaixaServicoReadHook } from '@/app/(protected)/(cadastros)/cadastros/_hooks/c_caixa_servico/useCCaixaServicoReadHook';
|
||||
import { CCaixaServicoReadInterface } from '@/app/(protected)/(cadastros)/cadastros/_interfaces/CCaixaServicoReadInterface';
|
||||
import { CheckIcon, ChevronsUpDownIcon } from 'lucide-react';
|
||||
import React from 'react';
|
||||
|
||||
export default function CCaixaServicoSelect({ sistema_id, field }: any) {
|
||||
const cCaixaServicoReadParams: CCaixaServicoReadInterface = { sistema_id };
|
||||
|
|
|
|||
|
|
@ -115,7 +115,10 @@ export default function GCalculoForm({
|
|||
render={({ field }) => (
|
||||
<FormItem className="col-span-1 sm:col-span-2">
|
||||
<FormLabel>Emolumento</FormLabel>
|
||||
<GEmolumentoSelect field={field} />
|
||||
<GEmolumentoSelect
|
||||
field={field}
|
||||
sistema_id={2}
|
||||
/>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
|
|
|
|||
|
|
@ -5,12 +5,12 @@ import { DataTable } from '@/shared/components/dataTable/DataTable';
|
|||
|
||||
import GCalculoColumns from './GCalculoColumns';
|
||||
|
||||
/**
|
||||
* Componente principal da tabela de Naturezas
|
||||
*/
|
||||
export default function GCalculoTable({ data, onEdit, onDelete }: GCalculoTableInterface) {
|
||||
|
||||
const columns = GCalculoColumns(onEdit, onDelete);
|
||||
|
||||
return (
|
||||
|
||||
<div>
|
||||
<DataTable
|
||||
data={data}
|
||||
|
|
@ -19,5 +19,6 @@ export default function GCalculoTable({ data, onEdit, onDelete }: GCalculoTableI
|
|||
filterPlaceholder="Buscar por apresentante da natureza..."
|
||||
/>
|
||||
</div>
|
||||
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,22 +3,6 @@
|
|||
import { CheckIcon, ChevronsUpDownIcon } from 'lucide-react';
|
||||
import React from 'react';
|
||||
|
||||
import { useGEmolumentoReadHook } from '@/app/(protected)/(cadastros)/cadastros/_hooks/g_emolumento/useGEmolumentoReadHook';
|
||||
import { GEmolumentoReadInterface } from '@/app/(protected)/(cadastros)/cadastros/_interfaces/GEmolumentoReadInterface';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
Command,
|
||||
CommandEmpty,
|
||||
CommandGroup,
|
||||
CommandInput,
|
||||
CommandItem,
|
||||
CommandList,
|
||||
|
||||
import { CheckIcon, ChevronsUpDownIcon } from 'lucide-react';
|
||||
import React from 'react';
|
||||
|
||||
import { useGEmolumentoReadHook } from '@/app/(protected)/(cadastros)/cadastros/_hooks/g_emolumento/useGEmolumentoReadHook';
|
||||
import { GEmolumentoReadInterface } from '@/app/(protected)/(cadastros)/cadastros/_interfaces/GEmolumentoReadInterface';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
Command,
|
||||
|
|
@ -31,6 +15,8 @@ import {
|
|||
import { FormControl } from '@/components/ui/form';
|
||||
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { useGEmolumentoReadHook } from '@/packages/administrativo/hooks/GEmolumento/useGEmolumentoReadHook';
|
||||
import { GEmolumentoReadInterface } from '@/packages/administrativo/interfaces/GEmolumento/GEmolumentoReadInterface';
|
||||
import GetCapitalize from '@/shared/actions/text/GetCapitalize';
|
||||
|
||||
// Tipagem das props do componente
|
||||
|
|
@ -142,7 +128,7 @@ export default function GEmolumentoSelect({
|
|||
if (onSelectChange)
|
||||
onSelectChange({
|
||||
key: Number(item.emolumento_id),
|
||||
value: item.descricao,
|
||||
value: item.descricao ?? '',
|
||||
});
|
||||
|
||||
// Fecha o popover
|
||||
|
|
@ -168,28 +154,4 @@ export default function GEmolumentoSelect({
|
|||
</PopoverContent>
|
||||
</Popover>
|
||||
);
|
||||
// Fecha o popover
|
||||
setOpen(false);
|
||||
}}
|
||||
>
|
||||
{/* Ícone de seleção (check) */ }
|
||||
< CheckIcon
|
||||
className = {
|
||||
cn(
|
||||
'mr-2 h-4 w-4',
|
||||
String(field.value?.key ?? field.value) === String(item.emolumento_id)
|
||||
? 'opacity-100'
|
||||
: 'opacity-0',
|
||||
)}
|
||||
/>
|
||||
{/* Nome formatado do emolumento */ }
|
||||
{ GetCapitalize(item.descricao) }
|
||||
</CommandItem >
|
||||
))}
|
||||
</CommandGroup >
|
||||
</CommandList >
|
||||
</Command >
|
||||
</PopoverContent >
|
||||
</Popover >
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@
|
|||
import { CheckIcon, ChevronsUpDownIcon } from 'lucide-react';
|
||||
import { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
|
||||
import { useGEmolumentoReadHook } from '@/app/(protected)/(cadastros)/cadastros/_hooks/g_emolumento/useGEmolumentoReadHook';
|
||||
import { GEmolumentoReadInterface } from '@/app/(protected)/(cadastros)/cadastros/_interfaces/GEmolumentoReadInterface';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
Command,
|
||||
|
|
@ -17,6 +15,8 @@ import {
|
|||
import { FormControl } from '@/components/ui/form';
|
||||
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { useGEmolumentoReadHook } from '@/packages/administrativo/hooks/GEmolumento/useGEmolumentoReadHook';
|
||||
import { GEmolumentoReadInterface } from '@/packages/administrativo/interfaces/GEmolumento/GEmolumentoReadInterface';
|
||||
import GetCapitalize from '@/shared/actions/text/GetCapitalize';
|
||||
|
||||
// Tipagem das props do componente
|
||||
|
|
|
|||
|
|
@ -30,10 +30,6 @@ import LoadingButton from '@/shared/components/loadingButton/LoadingButton';
|
|||
import { useGEmolumentoItemFormHook } from '../../hooks/GEmolumentoItem/useGEmolumentoItemFormHook';
|
||||
import { GEmolumentoItemFormInterface } from '../../interfaces/GEmolumentoItem/GEmolumentoItemFormInterface';
|
||||
|
||||
/**
|
||||
* Formulário de cadastro/edição de Natureza
|
||||
* Baseado nos campos da tabela G_NATUREZA
|
||||
*/
|
||||
export default function GEmolumentoItemForm({
|
||||
isOpen,
|
||||
data,
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ export default function GGramaticaForm({
|
|||
onSave,
|
||||
buttonIsLoading,
|
||||
}: GGramaticaFormInterface) {
|
||||
|
||||
const form = useGGramaticaFormHook({});
|
||||
|
||||
// Atualiza o formulário quando recebe dados para edição
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
'use client';
|
||||
|
||||
import React from 'react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
Command,
|
||||
|
|
@ -13,10 +12,11 @@ import {
|
|||
import { FormControl } from '@/components/ui/form';
|
||||
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { CheckIcon, ChevronsUpDownIcon } from 'lucide-react';
|
||||
import { useGMarcacaoTipoReadHook } from '@/packages/administrativo/hooks/GMarcacaoTipo/useGMarcacaoTipoReadHook';
|
||||
import { GMarcacaoTipoReadInterface } from '@/packages/administrativo/interfaces/GMarcacaoTipo/GMarcacaoTipoReadInterface';
|
||||
import GetCapitalize from '@/shared/actions/text/GetCapitalize';
|
||||
import { useGMarcacaoTipoReadHook } from '@/app/(protected)/(cadastros)/cadastros/_hooks/g_marcacao_tipo/useGMarcacaoTipoReadHook';
|
||||
import { GMarcacaoTipoReadInterface } from '@/app/(protected)/(cadastros)/cadastros/_interfaces/GMarcacaoTipoReadInterface';
|
||||
import { CheckIcon, ChevronsUpDownIcon } from 'lucide-react';
|
||||
import React from 'react';
|
||||
|
||||
export default function GMarcacaoTipoSelect({ grupo, sistema_id, situacao, field }: any) {
|
||||
const gMarcacaoTipoReadParams: GMarcacaoTipoReadInterface = { grupo, sistema_id, situacao };
|
||||
|
|
|
|||
|
|
@ -1,21 +1,20 @@
|
|||
'use client';
|
||||
|
||||
import { useEffect, useState, useCallback } from 'react';
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
|
||||
import { Card, CardContent } from '@/components/ui/card';
|
||||
import { useGMedidaTipoReadHook } from '@/packages/administrativo/hooks/GMedidaTipo/useGMedidaTipoReadHook';
|
||||
import { useGMedidaTipoRemoveHook } from '@/packages/administrativo/hooks/GMedidaTipo/useGMedidaTipoRemoveHook';
|
||||
import { useGMedidaTipoSaveHook } from '@/packages/administrativo/hooks/GMedidaTipo/useGMedidaTipoSaveHook';
|
||||
import { GMedidaTipoInterface } from '@/packages/administrativo/interfaces/GMedidaTipo/GMedidaTipoInterface';
|
||||
import ConfirmDialog from '@/shared/components/confirmDialog/ConfirmDialog';
|
||||
import { useConfirmDialog } from '@/shared/components/confirmDialog/useConfirmDialog';
|
||||
import Loading from '@/shared/components/loading/loading';
|
||||
import { useResponse } from '@/shared/components/response/ResponseContext';
|
||||
import Header from '@/shared/components/structure/Header';
|
||||
import { SituacoesEnum } from '@/shared/enums/SituacoesEnum';
|
||||
|
||||
import GMedidaTipoForm from './GMedidaTipoForm';
|
||||
import GMedidaTipoTable from './GMedidaTipoTable';
|
||||
import { useGMedidaTipoReadHook } from '../../hooks/GMedidaTipo/useGMedidaTipoReadHook';
|
||||
import { useGMedidaTipoRemoveHook } from '../../hooks/GMedidaTipo/useGMedidaTipoRemoveHook';
|
||||
import { useGMedidaTipoSaveHook } from '../../hooks/GMedidaTipo/useGMedidaTipoSaveHook';
|
||||
import { GMedidaTipoInterface } from '../../interfaces/GMedidaTipo/GMedidaTipoInterface';
|
||||
|
||||
const initialMedidaTipo: GMedidaTipoInterface = {
|
||||
medida_tipo_id: 0,
|
||||
|
|
@ -109,8 +108,8 @@ export default function GMedidaTipoIndex() {
|
|||
title={'Tipos de Medida'}
|
||||
description={'Gerenciamento de tipos de medida'}
|
||||
buttonText={'Novo Tipo de Medida'}
|
||||
buttonAction={(data) => {
|
||||
handleOpenForm((data = initialMedidaTipo));
|
||||
buttonAction={() => {
|
||||
handleOpenForm(null);
|
||||
}}
|
||||
/>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
'use client';
|
||||
|
||||
import { useEffect, useState, useCallback } from 'react';
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
|
||||
import { Card, CardContent } from '@/components/ui/card';
|
||||
import { useGTBBairroReadHook } from '@/packages/administrativo/hooks/GTBBairro/useGTBBairroReadHook';
|
||||
|
|
@ -13,9 +13,9 @@ import { useResponse } from '@/shared/components/response/ResponseContext';
|
|||
import Header from '@/shared/components/structure/Header';
|
||||
import { SituacoesEnum } from '@/shared/enums/SituacoesEnum';
|
||||
|
||||
import { GTBBairroInterface } from '../../interfaces/GTBBairro/GTBBairroInterface';
|
||||
import GTBBairroForm from './GTBBairroForm';
|
||||
import GTBBairroTable from './GTBBairroTable';
|
||||
import { GTBBairroInterface } from '../../interfaces/GTBBairro/GTBBairroInterface';
|
||||
|
||||
const initialBairro: GTBBairroInterface = {
|
||||
sistema_id: null,
|
||||
|
|
@ -123,8 +123,8 @@ export default function GTBBairroIndex() {
|
|||
title={'Bairros'}
|
||||
description={'Gerenciamento de Bairros'}
|
||||
buttonText={'Novo Bairro'}
|
||||
buttonAction={(data) => {
|
||||
handleOpenForm((data = initialBairro));
|
||||
buttonAction={() => {
|
||||
handleOpenForm(null);
|
||||
}}
|
||||
/>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
'use client';
|
||||
|
||||
import { useEffect, useState, useCallback } from 'react';
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
|
||||
import { Card, CardContent } from '@/components/ui/card';
|
||||
import ConfirmDialog from '@/shared/components/confirmDialog/ConfirmDialog';
|
||||
|
|
@ -9,12 +9,12 @@ import Loading from '@/shared/components/loading/loading';
|
|||
import { useResponse } from '@/shared/components/response/ResponseContext';
|
||||
import Header from '@/shared/components/structure/Header';
|
||||
|
||||
import GTBEstadoCivilForm from './GTBEstadoCivilForm';
|
||||
import GTBEstadoCivilTable from './GTBEstadoCivilTable';
|
||||
import { useGTBEstadoCivilReadHook } from '../../hooks/GTBEstadoCivil/useGTBEstadoCivilReadHook';
|
||||
import { useGTBEstadoCivilRemoveHook } from '../../hooks/GTBEstadoCivil/useGTBEstadoCivilRemoveHook';
|
||||
import { useGTBEstadoCivilSaveHook } from '../../hooks/GTBEstadoCivil/useGTBEstadoCivilSaveHook';
|
||||
import { GTBEstadoCivilInterface } from '../../interfaces/GTBEstadoCivil/GTBEstadoCivilInterface';
|
||||
import GTBEstadoCivilForm from './GTBEstadoCivilForm';
|
||||
import GTBEstadoCivilTable from './GTBEstadoCivilTable';
|
||||
|
||||
const initalEstadoCivil: GTBEstadoCivilInterface = {
|
||||
tb_estadocivil_id: 0,
|
||||
|
|
@ -109,8 +109,8 @@ export default function GTBEstadoCivilIndex() {
|
|||
title={'Estados Civis'}
|
||||
description={'Gerenciamento de Estados Civis'}
|
||||
buttonText={'Novo Estado Civil'}
|
||||
buttonAction={(data) => {
|
||||
handleOpenForm((data = initalEstadoCivil));
|
||||
buttonAction={() => {
|
||||
handleOpenForm(null);
|
||||
}}
|
||||
/>
|
||||
|
||||
|
|
|
|||
|
|
@ -16,10 +16,10 @@ import { FormControl } from '@/components/ui/form';
|
|||
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { useGUsuarioIndexHook } from '@/packages/administrativo/hooks/GUsuario/useGUsuarioIndexHook';
|
||||
import GUsuarioIndexInterface from '@/packages/administrativo/interfaces/GUsuario/GUsuarioIndexInterface';
|
||||
import GUsuarioSelectInterface from '@/packages/administrativo/interfaces/GUsuario/GUsuarioSelectInterface';
|
||||
import GetCapitalize from '@/shared/actions/text/GetCapitalize';
|
||||
|
||||
import GUsuarioIndexInterface from '../../interfaces/GUsuario/GusuarioIndexInterface';
|
||||
|
||||
export default function GUsuarioSelect({ field }: GUsuarioSelectInterface) {
|
||||
const [open, setOpen] = useState(false);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
'use client';
|
||||
|
||||
import { useEffect, useState, useCallback } from 'react';
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
|
||||
import { Card, CardContent } from '@/components/ui/card';
|
||||
import { useTCensecNaturezaLitigioReadHook } from '@/packages/administrativo/hooks/TCensecNaturezaLitigio/useTCensecNaturezaLitigioReadHook';
|
||||
|
|
@ -13,9 +13,9 @@ import { useResponse } from '@/shared/components/response/ResponseContext';
|
|||
import Header from '@/shared/components/structure/Header';
|
||||
import { SituacoesEnum } from '@/shared/enums/SituacoesEnum';
|
||||
|
||||
import { TCensecNaturezaLitigioInterface } from '../../interfaces/TCensecNaturezaLitigio/TCensecNaturezaLitigioInterface';
|
||||
import TCensecNaturezaLitigioForm from './TCensecNaturezaLitigioForm';
|
||||
import TCensecNaturezaLitigioTable from './TCensecNaturezaLitigioTable';
|
||||
import { TCensecNaturezaLitigioInterface } from '../../interfaces/TCensecNaturezaLitigio/TCensecNaturezaLitigioInterface';
|
||||
|
||||
const initialCensecNaturezaLitigio: TCensecNaturezaLitigioInterface = {
|
||||
censec_naturezalitigio_id: 0,
|
||||
|
|
@ -112,7 +112,9 @@ export default function TCensecNaturezaLitigioIndex() {
|
|||
title={'Natureza do Litígio'}
|
||||
description={'Gerenciamento de Naturezas do Litígio'}
|
||||
buttonText={'Nova Natureza'}
|
||||
buttonAction={(data) => handleOpenForm((data = initialCensecNaturezaLitigio))}
|
||||
buttonAction={() => {
|
||||
handleOpenForm(null);
|
||||
}}
|
||||
/>
|
||||
|
||||
{/* Tabela */}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
'use client';
|
||||
|
||||
import { useEffect, useState, useCallback } from 'react';
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
|
||||
import { Card, CardContent } from '@/components/ui/card';
|
||||
import ConfirmDialog from '@/shared/components/confirmDialog/ConfirmDialog';
|
||||
|
|
@ -9,13 +9,13 @@ import Loading from '@/shared/components/loading/loading';
|
|||
import Header from '@/shared/components/structure/Header';
|
||||
import { SituacoesEnum } from '@/shared/enums/SituacoesEnum';
|
||||
|
||||
import TCensecTipoAtoForm from './TCensecTipoAtoForm';
|
||||
import TCensecTipoAtoTable from './TCensecTipoAtoTable';
|
||||
import { useTCensecReadHook } from '../../hooks/TCensec/useTCensecReadHook';
|
||||
import { useTCensecTipoAtoReadHook } from '../../hooks/TCensecTipoAto/useTCensecTipoAtoReadHook';
|
||||
import { useTCensecTipoAtoRemoveHook } from '../../hooks/TCensecTipoAto/useTCensecTipoAtoRemoveHook';
|
||||
import { useTCensecTipoAtoSaveHook } from '../../hooks/TCensecTipoAto/useTCensecTipoAtoSaveHook';
|
||||
import { TCensecTipoAtoInterface } from '../../interfaces/TCensecTipoAto/TCensecTipoAtoInterface';
|
||||
import TCensecTipoAtoForm from './TCensecTipoAtoForm';
|
||||
import TCensecTipoAtoTable from './TCensecTipoAtoTable';
|
||||
|
||||
// Estado inicial para criação
|
||||
const initialTCensecTipoAto: TCensecTipoAtoInterface = {
|
||||
|
|
@ -106,8 +106,8 @@ export default function TCensecTipoAtoIndex() {
|
|||
title="Tipos de Ato CENSEC"
|
||||
description="Gerenciamento de Tipos de Ato vinculados ao CENSEC"
|
||||
buttonText="Novo Tipo de Ato"
|
||||
buttonAction={(data) => {
|
||||
handleOpenForm((data = initialTCensecTipoAto));
|
||||
buttonAction={() => {
|
||||
handleOpenForm(null);
|
||||
}}
|
||||
/>
|
||||
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ export function TPessoaTableFormColumnsDialog(setSelectedTPessoa: React.Dispatch
|
|||
<div>
|
||||
<div className="font-semibold text-gray-900 capitalize">{pessoa.nome || '-'}</div>
|
||||
<div className="text-sm text-gray-500">
|
||||
{empty(pessoa.email) ? 'Email não informado' : pessoa.email}
|
||||
{empty(pessoa?.email) ? 'Email não informado' : pessoa?.email}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -40,17 +40,15 @@ function TPessoaTableFormSubview({
|
|||
|
||||
}, [])
|
||||
|
||||
// Define a classe do botão de biometria com base no status, sem estado extra
|
||||
const biometriaButtonClass = useMemo(() => {
|
||||
switch (1) {
|
||||
const status = 1 as number; // força tipo number
|
||||
|
||||
switch (status) {
|
||||
case 0:
|
||||
// Amarelo (aviso)
|
||||
return 'bg-amber-100 text-amber-700 border border-amber-300 hover:bg-amber-200 hover:text-amber-800';
|
||||
case 1:
|
||||
// Verde discreto
|
||||
return 'bg-green-100 text-green-700 border border-green-300 hover:bg-green-200 hover:text-green-800';
|
||||
case 2:
|
||||
// Vermelho (erro)
|
||||
return 'bg-red-100 text-red-700 border border-red-300 hover:bg-red-200 hover:text-red-800';
|
||||
default:
|
||||
return '';
|
||||
|
|
|
|||
|
|
@ -0,0 +1,73 @@
|
|||
import { ColumnDef } from '@tanstack/react-table';
|
||||
import { EllipsisIcon, PencilIcon, Trash2Icon } from 'lucide-react';
|
||||
|
||||
import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuGroup,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger,
|
||||
} from '@/components/ui/dropdown-menu';
|
||||
import TServicoTipoInterface from '@/packages/administrativo/interfaces/TServicoTipo/TServicoTipoInterface';
|
||||
import GetCapitalize from '@/shared/actions/text/GetCapitalize';
|
||||
import { SortableHeader } from '@/shared/components/dataTable/SortableHeader';
|
||||
|
||||
|
||||
export default function TServicoTipoColumns(
|
||||
onEdit: (item: TServicoTipoInterface, isEditingFormStatus: boolean) => void,
|
||||
onDelete: (item: TServicoTipoInterface, isEditingFormStatus: boolean) => void,
|
||||
): ColumnDef<TServicoTipoInterface>[] {
|
||||
return [
|
||||
// ID
|
||||
{
|
||||
accessorKey: 'servico_tipo_id',
|
||||
header: ({ column }) => SortableHeader('ID', column),
|
||||
cell: ({ row }) => Number(row.getValue('servico_tipo_id')),
|
||||
enableSorting: true,
|
||||
},
|
||||
|
||||
// Descrição
|
||||
{
|
||||
accessorKey: 'descricao',
|
||||
header: ({ column }) => SortableHeader('Descrição', column),
|
||||
cell: ({ row }) => GetCapitalize(String(row.getValue('descricao') || '')),
|
||||
},
|
||||
|
||||
// Ações
|
||||
{
|
||||
id: 'actions',
|
||||
header: 'Ações',
|
||||
cell: ({ row }) => {
|
||||
const data = row.original;
|
||||
return (
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button variant="ghost" size="icon">
|
||||
<EllipsisIcon />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent side="left" align="start">
|
||||
<DropdownMenuGroup>
|
||||
<DropdownMenuItem onSelect={() => onEdit(data, true)}>
|
||||
<PencilIcon className="mr-2 h-4 w-4" />
|
||||
Editar
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuSeparator />
|
||||
<DropdownMenuItem
|
||||
onSelect={() => onDelete(data, true)}
|
||||
>
|
||||
<Trash2Icon className="mr-2 h-4 w-4" />
|
||||
Remover
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuGroup>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
);
|
||||
},
|
||||
enableSorting: false,
|
||||
enableHiding: false,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
|
@ -1,5 +1,8 @@
|
|||
'use client';
|
||||
|
||||
import { CirclePlus, DollarSign, Settings, SquarePen, Trash } from 'lucide-react';
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Checkbox } from '@/components/ui/checkbox';
|
||||
import {
|
||||
|
|
@ -20,11 +23,6 @@ import {
|
|||
FormMessage,
|
||||
} from '@/components/ui/form';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem
|
||||
} from '@/components/ui/select';
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
|
|
@ -34,151 +32,94 @@ import {
|
|||
TableRow,
|
||||
} from '@/components/ui/table';
|
||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
|
||||
import { zodResolver } from '@hookform/resolvers/zod';
|
||||
import { CirclePlus, DollarSign, Settings, SquarePen, Trash } from 'lucide-react';
|
||||
import React, { useState } from 'react';
|
||||
import { useForm } from 'react-hook-form';
|
||||
|
||||
import { useGEmolumentoItemReadHook } from '@/app/(protected)/(cadastros)/cadastros/_hooks/g_emolumento_item/useGEmolumentoItemReadHook';
|
||||
import { useTServicoEtiquetaReadHook } from '@/app/(protected)/(cadastros)/cadastros/_hooks/t_servico_etiqueta/useTServicoEtiquetaReadHook';
|
||||
import { useTServicoEtiquetaRemoveHook } from '@/app/(protected)/(cadastros)/cadastros/_hooks/t_servico_etiqueta/useTServicoEtiquetaRemoveHook';
|
||||
import { useTServicoEtiquetaSaveHook } from '@/app/(protected)/(cadastros)/cadastros/_hooks/t_servico_etiqueta/useTServicoEtiquetaSaveHook';
|
||||
import { GEmolumentoItemReadInterface } from '@/app/(protected)/(cadastros)/cadastros/_interfaces/GEmolumentoItemReadInterface';
|
||||
import CCaixaServicoSelect from '@/packages/administrativo/components/CCaixaServico/CCaixaServicoSelect';
|
||||
import GEmolumentoSelect from '@/packages/administrativo/components/GEmolumento/GEmolumentoSelect';
|
||||
import GMarcacaoTipoSelect from '@/packages/administrativo/components/GMarcacaoTipo/GMarcacaoTipoSelect';
|
||||
import TTBReconhecimentoTipoSelect from '@/packages/administrativo/components/TTBReconhecimentoTipo/TTBReconhecimentoTipoSelect';
|
||||
import { TServicoTipoSaveData } from '@/packages/administrativo/data/TServicoTipo/TServicoTipoSaveData';
|
||||
import { useGEmolumentoItemReadHook } from '@/packages/administrativo/hooks/GEmolumentoItem/useGEmolumentoItemReadHook';
|
||||
import { useTServicoEtiquetaReadHook } from '@/packages/administrativo/hooks/TServicoEtiqueta/useTServicoEtiquetaReadHook';
|
||||
import { useTServicoEtiquetaRemoveHook } from '@/packages/administrativo/hooks/TServicoEtiqueta/useTServicoEtiquetaRemoveHook';
|
||||
import { useTServicoEtiquetaSaveHook } from '@/packages/administrativo/hooks/TServicoEtiqueta/useTServicoEtiquetaSaveHook';
|
||||
import { useTServicoTipoFormHook } from '@/packages/administrativo/hooks/TServicoTipo/useTServicoTipoFormHook';
|
||||
import { GEmolumentoItemReadInterface } from '@/packages/administrativo/interfaces/GEmolumentoItem/GEmolumentoItemReadInterface';
|
||||
import TServicoTipoFormInterface from '@/packages/administrativo/interfaces/TServicoTipo/TServicoTipoFormInterface';
|
||||
import { TServicoTipoFormValues } from '@/packages/administrativo/schemas/TServicoTipo/TServicoTipoSchema';
|
||||
import CategoriaServicoSelect from '@/shared/components/categoriaServicoSelect/CategoriaServicoSelect';
|
||||
import { ConfirmacaoCheckBox } from '@/shared/components/confirmacao/ConfirmacaoCheckBox';
|
||||
import ConfirmacaoSelect from '@/shared/components/confirmacao/ConfirmacaoSelect';
|
||||
import { TipoPessoaSelect } from '@/shared/components/tipoPessoa/tipoPessoaSelect';
|
||||
import { useEffect } from 'react';
|
||||
import { TServicoTipoSaveData } from '../../../../../../packages/administrativo/data/TServicoTipo/TServicoTipoSaveData';
|
||||
import { TServicoTipoFormValues, TServicoTipoSchema } from '../../_schemas/TServicoTipoSchema';
|
||||
|
||||
// Propriedades esperadas pelo componente
|
||||
interface Props {
|
||||
isOpen: boolean;
|
||||
data: TServicoTipoFormValues | null;
|
||||
onClose: (item: null, isFormStatus: boolean) => void;
|
||||
onSave: (data: TServicoTipoFormValues) => void;
|
||||
}
|
||||
import { ConfirmacaoEnum } from '@/shared/enums/ConfirmacaoEnum';
|
||||
import { SituacoesEnum } from '@/shared/enums/SituacoesEnum';
|
||||
|
||||
// Componente principal do formulário
|
||||
export default function TServicoTipoForm({ isOpen, data, onClose, onSave }: Props) {
|
||||
// Inicializa o react-hook-form com validação via Zod
|
||||
const form = useForm<TServicoTipoFormValues>({
|
||||
resolver: zodResolver(TServicoTipoSchema),
|
||||
defaultValues: {
|
||||
servico_tipo_id: 0,
|
||||
emolumento_id: 0,
|
||||
emolumento_obrigatorio: 0,
|
||||
descricao: '',
|
||||
maximo_pessoa: 0,
|
||||
tipo_item: '',
|
||||
frenteverso: 'N',
|
||||
averbacao: 'N',
|
||||
transferencia_veiculo: 'N',
|
||||
usar_a4: 'N',
|
||||
etiqueta_unica: 'N',
|
||||
situacao: 'A',
|
||||
selar: 'N',
|
||||
valor_emolumento: 0,
|
||||
valor_taxa_judiciaria: 0,
|
||||
fundesp_valor: 0,
|
||||
valor_total: 0,
|
||||
tipo_pessoa: 'F', // ou "J"
|
||||
} as unknown as TServicoTipoFormValues,
|
||||
});
|
||||
export default function TServicoTipoForm({
|
||||
isOpen,
|
||||
data,
|
||||
onClose,
|
||||
onSave,
|
||||
}: TServicoTipoFormInterface) {
|
||||
const form = useTServicoTipoFormHook({});
|
||||
|
||||
// Carrega o ID caso esteja informado no form
|
||||
const servico_tipo_id = form.getValues('servico_tipo_id') || 0;
|
||||
|
||||
// Hook responsável por buscar emolumentos no backend
|
||||
const { tServicoEtiqueta, fetchTServicoEtiqueta } = useTServicoEtiquetaReadHook();
|
||||
|
||||
// Hook responsável em salvar o a etiqueta selecionada
|
||||
const { tServicoEtiquetaSave, fetchTServicoEtiquetaSave } = useTServicoEtiquetaSaveHook();
|
||||
|
||||
// Hook responsável em excluir a etiqueta selecionada
|
||||
const { fetchTServicoEtiquetaSave } = useTServicoEtiquetaSaveHook();
|
||||
const { fetchTServicoEtiquetaRemove } = useTServicoEtiquetaRemoveHook();
|
||||
|
||||
// Estado para gerenciar os itens da tabela de etiquetas/carimbos
|
||||
const [itensTabela, setItensTabela] = useState<
|
||||
{ servico_etiqueta_id: string | number; descricao: string }[]
|
||||
>([]);
|
||||
|
||||
// Carrega os dados de emolumentos apenas uma vez ao montar o componente
|
||||
React.useEffect(() => {
|
||||
// Função para consumir o endpoint da api
|
||||
// Carrega etiquetas quando o form tem ID
|
||||
useEffect(() => {
|
||||
const loadData = async () => {
|
||||
// Verifica se o ID do serviço tipo foi informado
|
||||
if (servico_tipo_id > 0) {
|
||||
// Consumo o endpoint da api
|
||||
await fetchTServicoEtiqueta({ servico_tipo_id });
|
||||
}
|
||||
};
|
||||
|
||||
// Chama a função para consumir o endpoint da api
|
||||
loadData();
|
||||
}, [servico_tipo_id]);
|
||||
|
||||
// Atualiza itensTabela sempre que tServicoEtiqueta for carregado
|
||||
React.useEffect(() => {
|
||||
// Verifica se a consulta retornou os dados como objeto
|
||||
// Atualiza a tabela quando muda o hook
|
||||
useEffect(() => {
|
||||
if (Array.isArray(tServicoEtiqueta) && tServicoEtiqueta.length > 0) {
|
||||
// Lista os itens
|
||||
const mapped = tServicoEtiqueta.map((item) => ({
|
||||
servico_etiqueta_id: Number(item.servico_etiqueta_id ?? 0),
|
||||
descricao: String(item.descricao ?? 'Sem descrição'),
|
||||
}));
|
||||
|
||||
setItensTabela(mapped);
|
||||
} else {
|
||||
setItensTabela([]);
|
||||
}
|
||||
}, [tServicoEtiqueta]);
|
||||
|
||||
// Função para adicionar um novo item à tabela Etiquetas/Carimbos
|
||||
const handleAddEtiquetaCarimbo = async () => {
|
||||
// Captura o valor selecionado do formulário
|
||||
const valorSelecionado = form.getValues('etiquetas_carimbos');
|
||||
|
||||
// Se não houver valor selecionado, não faz nada
|
||||
if (!valorSelecionado) return;
|
||||
|
||||
// Verifica se o item já se encontra na tabela
|
||||
const alreadyExists = itensTabela.some(
|
||||
(p) => String(p.descricao).trim() === String(valorSelecionado.value).trim(),
|
||||
(p) => String(p.descricao).trim() === String(valorSelecionado).trim(),
|
||||
);
|
||||
|
||||
// Caso o item já esteja na tabela, para o procedimento
|
||||
if (alreadyExists) {
|
||||
return;
|
||||
}
|
||||
if (alreadyExists) return;
|
||||
|
||||
// --- Envio opcional para API ---
|
||||
try {
|
||||
// Verifica se o ID do serviço tipo foi informado
|
||||
if (servico_tipo_id > 0) {
|
||||
// Monta o objeto do item selecionado
|
||||
const data = {
|
||||
etiqueta_modelo_id: valorSelecionado.key,
|
||||
const dataToSave = {
|
||||
etiqueta_modelo_id: 0, // não há ID, pois o valor é string
|
||||
servico_tipo_id: servico_tipo_id,
|
||||
};
|
||||
|
||||
// Consumo o endpoint da api
|
||||
const response = await fetchTServicoEtiquetaSave(data);
|
||||
const response = await fetchTServicoEtiquetaSave(dataToSave);
|
||||
|
||||
// Verifica se tServicoEtiquetaSave é um objeto válido (não null e não array)
|
||||
if (response && typeof response === 'object' && !Array.isArray(response)) {
|
||||
// Monta o objeto com um único item para a tabela
|
||||
const item = {
|
||||
servico_etiqueta_id: Number(response.servico_etiqueta_id) ?? 0,
|
||||
descricao: String(valorSelecionado.value) ?? 'Sem descrição',
|
||||
descricao: String(valorSelecionado) ?? 'Sem descrição',
|
||||
};
|
||||
|
||||
// Adiciona o item na tabela
|
||||
setItensTabela((prev) => {
|
||||
const idAtual = String(response.servico_etiqueta_id ?? '');
|
||||
const exists = prev.some((p) => String(p.servico_etiqueta_id ?? '') === idAtual);
|
||||
|
|
@ -186,110 +127,80 @@ export default function TServicoTipoForm({ isOpen, data, onClose, onSave }: Prop
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Se ocorrer erros, informo
|
||||
} catch (error) {
|
||||
console.log('Erro ao enviar o serviço para a API: ' + error);
|
||||
}
|
||||
};
|
||||
|
||||
// Função para remover um item da tabela
|
||||
// Remove item da tabela
|
||||
const handleRemoveItem = async (servico_etiqueta_id: number) => {
|
||||
try {
|
||||
// Verifica se o ID da etiqueta tipo foi informado
|
||||
if (servico_etiqueta_id > 0) {
|
||||
// Monta o objeto do item selecionado
|
||||
const data = {
|
||||
servico_etiqueta_id: servico_etiqueta_id,
|
||||
};
|
||||
|
||||
// Consumo o endpoint da api
|
||||
const data = { servico_etiqueta_id };
|
||||
await fetchTServicoEtiquetaRemove(data);
|
||||
}
|
||||
|
||||
// Atualiza a tabela no form
|
||||
setItensTabela((prev) =>
|
||||
prev.filter((p) => Number(p.servico_etiqueta_id) !== servico_etiqueta_id),
|
||||
);
|
||||
|
||||
// Se ocorrer erros, informo
|
||||
} catch (error) {
|
||||
console.log('Erro ao enviar o serviço para a API: ' + error);
|
||||
}
|
||||
};
|
||||
|
||||
// Parâmetros para o hook de leitura de emolumento_item
|
||||
// Inicializa com valores padrão (0) para evitar uso de propriedades não declaradas.
|
||||
const gEmolumentoItemReadParams: GEmolumentoItemReadInterface = { emolumento_id: 0, valor: 0 };
|
||||
|
||||
// Estados locais
|
||||
const [open, setOpen] = React.useState(false);
|
||||
const [isLoading, setIsLoading] = React.useState(false);
|
||||
const [open, setOpen] = useState(false);
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
|
||||
// Hook que realiza a leitura do emolumento_item
|
||||
const { gGEmolumentoItem, fetchGEmolumentoItem } = useGEmolumentoItemReadHook();
|
||||
|
||||
// Busca os dados ao montar o componente (somente se houver ID válido)
|
||||
React.useEffect(() => {
|
||||
// Busca emolumento item
|
||||
useEffect(() => {
|
||||
const loadData = async () => {
|
||||
// Validação: só executa se houver emolumento_id informado e válido
|
||||
if (
|
||||
!gEmolumentoItemReadParams?.emolumento_id || // se não existir o campo
|
||||
isNaN(Number(gEmolumentoItemReadParams.emolumento_id)) || // se não for número
|
||||
Number(gEmolumentoItemReadParams.emolumento_id) <= 0 // se for zero ou negativo
|
||||
!gEmolumentoItemReadParams?.emolumento_id ||
|
||||
isNaN(Number(gEmolumentoItemReadParams.emolumento_id)) ||
|
||||
Number(gEmolumentoItemReadParams.emolumento_id) <= 0
|
||||
) {
|
||||
return; // encerra sem executar a busca
|
||||
return;
|
||||
}
|
||||
|
||||
// Executa a busca apenas se ainda não houver dados carregados
|
||||
if (!gGEmolumentoItem.length) {
|
||||
setIsLoading(true);
|
||||
await fetchGEmolumentoItem(gEmolumentoItemReadParams);
|
||||
setIsLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
loadData();
|
||||
}, [gEmolumentoItemReadParams.emolumento_id]);
|
||||
|
||||
// Captura o ID do serviço para uso local
|
||||
const servicoTipoId = Number(form.watch('servico_tipo_id') || data?.servico_tipo_id || 0);
|
||||
|
||||
// Função chamada ao clicar em "Salvar"
|
||||
const handleSave = async (formData: TServicoTipoFormValues) => {
|
||||
try {
|
||||
// Se o form não trouxe o ID, tenta puxar de `data`
|
||||
const servico_tipo_id =
|
||||
formData.servico_tipo_id || data?.servico_tipo_id || form.getValues('servico_tipo_id') || 0;
|
||||
|
||||
// Atualiza o valor dentro do formData
|
||||
formData.servico_tipo_id = Number(servico_tipo_id);
|
||||
|
||||
// Intercepta e trata o valor de emolumento_id
|
||||
const emolumentoId = Number(formData.emolumento_id ?? 0);
|
||||
formData.emolumento_id = emolumentoId === 0 ? null : emolumentoId;
|
||||
|
||||
// Intercepta e trata o valor de emolumento_obrigatorio
|
||||
const emolumentoObrigatorio = Number(formData.emolumento_obrigatorio ?? 0);
|
||||
formData.emolumento_obrigatorio = emolumentoObrigatorio === 0 ? null : emolumentoObrigatorio;
|
||||
|
||||
// Detecta automaticamente se é edição
|
||||
const isEditing = !!formData.servico_tipo_id && Number(formData.servico_tipo_id) > 0;
|
||||
|
||||
// Envia os dados para o módulo com o método correto
|
||||
const response = await TServicoTipoSaveData({
|
||||
...formData,
|
||||
metodo: isEditing ? 'PUT' : 'POST', // 💡 Definição explícita do método
|
||||
metodo: isEditing ? 'PUT' : 'POST',
|
||||
});
|
||||
|
||||
// Atualiza o formulário apenas se o retorno for válido
|
||||
if (response?.data?.servico_tipo_id) {
|
||||
const novoId = response.data.servico_tipo_id;
|
||||
form.setValue('servico_tipo_id', novoId); // mantém o ID atualizado
|
||||
|
||||
// Merge dos dados para preservar valores locais
|
||||
form.setValue('servico_tipo_id', novoId);
|
||||
form.reset({ ...form.getValues(), ...response.data });
|
||||
|
||||
console.log(`Serviço ${isEditing ? 'atualizado' : 'criado'} com sucesso (ID: ${novoId})`);
|
||||
} else {
|
||||
console.log('Erro ao salvar o tipo de serviço.');
|
||||
|
|
@ -299,17 +210,12 @@ export default function TServicoTipoForm({ isOpen, data, onClose, onSave }: Prop
|
|||
}
|
||||
};
|
||||
|
||||
// Carrega os dados apenas quando o modal
|
||||
// abrir e houver um registro para editar
|
||||
// Carrega dados ao abrir o modal
|
||||
useEffect(() => {
|
||||
// Remove as etiquetas selecionadas
|
||||
setItensTabela([]);
|
||||
|
||||
if (isOpen && data && Number(data.servico_tipo_id ?? 0) > 0) {
|
||||
/** Carrega os dados no formulário */
|
||||
form.reset(data); // edição
|
||||
form.reset(data);
|
||||
} else if (isOpen && !data) {
|
||||
/** Reseta os campos do formulário */
|
||||
form.reset({
|
||||
servico_tipo_id: 0,
|
||||
emolumento_id: 0,
|
||||
|
|
@ -317,13 +223,13 @@ export default function TServicoTipoForm({ isOpen, data, onClose, onSave }: Prop
|
|||
descricao: '',
|
||||
maximo_pessoa: 0,
|
||||
tipo_item: '',
|
||||
frenteverso: 'N',
|
||||
averbacao: 'N',
|
||||
transferencia_veiculo: 'N',
|
||||
usar_a4: 'N',
|
||||
etiqueta_unica: 'N',
|
||||
situacao: 'A',
|
||||
selar: 'N',
|
||||
frenteverso: ConfirmacaoEnum.N,
|
||||
averbacao: ConfirmacaoEnum.N,
|
||||
transferencia_veiculo: ConfirmacaoEnum.N,
|
||||
usar_a4: ConfirmacaoEnum.N,
|
||||
etiqueta_unica: ConfirmacaoEnum.N,
|
||||
situacao: SituacoesEnum.A,
|
||||
selar: ConfirmacaoEnum.N,
|
||||
valor_emolumento: 0,
|
||||
valor_taxa_judiciaria: 0,
|
||||
fundesp_valor: 0,
|
||||
|
|
@ -496,8 +402,10 @@ export default function TServicoTipoForm({ isOpen, data, onClose, onSave }: Prop
|
|||
<FormControl>
|
||||
<Checkbox
|
||||
className="cursor-pointer"
|
||||
checked={field.value === 'S'} // marca quando o valor for "S"
|
||||
onCheckedChange={(checked) => field.onChange(checked ? 'S' : 'N')} // grava "S" ou "N"
|
||||
checked={field.value === ConfirmacaoEnum.S}
|
||||
onCheckedChange={(checked) =>
|
||||
field.onChange(checked ? ConfirmacaoEnum.S : ConfirmacaoEnum.N)
|
||||
}
|
||||
disabled={!isEnabled}
|
||||
/>
|
||||
</FormControl>
|
||||
|
|
@ -516,9 +424,7 @@ export default function TServicoTipoForm({ isOpen, data, onClose, onSave }: Prop
|
|||
control={form.control}
|
||||
name="situacao"
|
||||
render={({ field }) => {
|
||||
// Considera "A" ou vazio como marcado
|
||||
const isChecked = field.value === 'A' || !field.value;
|
||||
|
||||
const isChecked = field.value === SituacoesEnum.A || !field.value;
|
||||
return (
|
||||
<FormItem className="flex flex-row items-center space-y-0 space-x-3">
|
||||
<FormControl>
|
||||
|
|
@ -526,11 +432,15 @@ export default function TServicoTipoForm({ isOpen, data, onClose, onSave }: Prop
|
|||
className="cursor-pointer"
|
||||
checked={isChecked}
|
||||
onCheckedChange={(checked) => {
|
||||
field.onChange(checked ? 'A' : 'I'); // grava "A" ou "I" no form
|
||||
field.onChange(
|
||||
checked ? SituacoesEnum.A : SituacoesEnum.I
|
||||
);
|
||||
}}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormLabel className="cursor-pointer font-normal">Ativo</FormLabel>
|
||||
<FormLabel className="cursor-pointer font-normal">
|
||||
Ativo
|
||||
</FormLabel>
|
||||
</FormItem>
|
||||
);
|
||||
}}
|
||||
|
|
@ -602,19 +512,9 @@ export default function TServicoTipoForm({ isOpen, data, onClose, onSave }: Prop
|
|||
render={({ field }) => (
|
||||
<FormItem className="w-full">
|
||||
<FormLabel>Biometria</FormLabel>
|
||||
<Select value={field.value} onValueChange={field.onChange}>
|
||||
<FormControl>
|
||||
<ConfirmacaoSelect field={field} />
|
||||
</FormControl>
|
||||
<SelectContent>
|
||||
<SelectItem value="S" className="cursor-pointer">
|
||||
Sim
|
||||
</SelectItem>
|
||||
<SelectItem value="N" className="cursor-pointer">
|
||||
Não
|
||||
</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<FormControl>
|
||||
<ConfirmacaoSelect field={field} />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
|
|
@ -629,19 +529,9 @@ export default function TServicoTipoForm({ isOpen, data, onClose, onSave }: Prop
|
|||
render={({ field }) => (
|
||||
<FormItem className="w-full">
|
||||
<FormLabel>CPF/CNPJ</FormLabel>
|
||||
<Select value={field.value} onValueChange={field.onChange}>
|
||||
<FormControl>
|
||||
<ConfirmacaoSelect field={field} />
|
||||
</FormControl>
|
||||
<SelectContent>
|
||||
<SelectItem value="S" className="cursor-pointer">
|
||||
Sim
|
||||
</SelectItem>
|
||||
<SelectItem value="N" className="cursor-pointer">
|
||||
Não
|
||||
</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<FormControl>
|
||||
<ConfirmacaoSelect field={field} />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
|
|
@ -656,19 +546,9 @@ export default function TServicoTipoForm({ isOpen, data, onClose, onSave }: Prop
|
|||
render={({ field }) => (
|
||||
<FormItem className="w-full">
|
||||
<FormLabel>Autorização</FormLabel>
|
||||
<Select value={field.value} onValueChange={field.onChange}>
|
||||
<FormControl>
|
||||
<ConfirmacaoSelect field={field} />
|
||||
</FormControl>
|
||||
<SelectContent>
|
||||
<SelectItem value="S" className="cursor-pointer">
|
||||
Sim
|
||||
</SelectItem>
|
||||
<SelectItem value="N" className="cursor-pointer">
|
||||
Não
|
||||
</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<FormControl>
|
||||
<ConfirmacaoSelect field={field} />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
|
|
@ -683,19 +563,9 @@ export default function TServicoTipoForm({ isOpen, data, onClose, onSave }: Prop
|
|||
render={({ field }) => (
|
||||
<FormItem className="w-full">
|
||||
<FormLabel>Abonador</FormLabel>
|
||||
<Select value={field.value} onValueChange={field.onChange}>
|
||||
<FormControl>
|
||||
<ConfirmacaoSelect field={field} />
|
||||
</FormControl>
|
||||
<SelectContent>
|
||||
<SelectItem value="S" className="cursor-pointer">
|
||||
Sim
|
||||
</SelectItem>
|
||||
<SelectItem value="N" className="cursor-pointer">
|
||||
Não
|
||||
</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<FormControl>
|
||||
<ConfirmacaoSelect field={field} />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
|
|
@ -759,7 +629,7 @@ export default function TServicoTipoForm({ isOpen, data, onClose, onSave }: Prop
|
|||
variant="outline"
|
||||
className="w-full cursor-pointer"
|
||||
type="button"
|
||||
onClick={() => handleRemoveItem(item.servico_etiqueta_id)}
|
||||
onClick={() => handleRemoveItem(Number(item.servico_etiqueta_id))}
|
||||
>
|
||||
<Trash /> Remover
|
||||
</Button>
|
||||
|
|
@ -789,19 +659,9 @@ export default function TServicoTipoForm({ isOpen, data, onClose, onSave }: Prop
|
|||
render={({ field }) => (
|
||||
<FormItem className="w-full">
|
||||
<FormLabel>Selar</FormLabel>
|
||||
<Select value={field.value} onValueChange={field.onChange}>
|
||||
<FormControl>
|
||||
<ConfirmacaoSelect field={field} />
|
||||
</FormControl>
|
||||
<SelectContent>
|
||||
<SelectItem value="S" className="cursor-pointer">
|
||||
Sim
|
||||
</SelectItem>
|
||||
<SelectItem value="N" className="cursor-pointer">
|
||||
Não
|
||||
</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<FormControl>
|
||||
<ConfirmacaoSelect field={field} />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
|
|
@ -1,29 +1,24 @@
|
|||
'use client';
|
||||
|
||||
import { Card, CardContent } from '@/components/ui/card';
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
|
||||
import Loading from '@/shared/components/loading/loading';
|
||||
|
||||
// Componentes específicos para TServicoTipo
|
||||
import TServicoTipoForm from '../../_components/t_servico_tipo/TServicoTipoForm';
|
||||
import TServicoTipoTable from '../../_components/t_servico_tipo/TServicoTipoTable';
|
||||
|
||||
// Hooks específicos para TServicoTipo
|
||||
import { useTServicoTipoEditHook } from '../../../../../../packages/administrativo/hooks/TServicoTipo/useTServicoTipoEditHook';
|
||||
import { useTServicoTipoReadHook } from '../../../../../../packages/administrativo/hooks/TServicoTipo/useTServicoTipoReadHook';
|
||||
import { useTServicoTipoRemoveHook } from '../../../../../../packages/administrativo/hooks/TServicoTipo/useTServicoTipoRemoveHook';
|
||||
import { useTServicoTipoSaveHook } from '../../../../../../packages/administrativo/hooks/TServicoTipo/useTServicoTipoSaveHook';
|
||||
|
||||
import { Card, CardContent } from '@/components/ui/card';
|
||||
import { useTServicoTipoEditHook } from '@/packages/administrativo/hooks/TServicoTipo/useTServicoTipoEditHook';
|
||||
import { useTServicoTipoReadHook } from '@/packages/administrativo/hooks/TServicoTipo/useTServicoTipoReadHook';
|
||||
import { useTServicoTipoRemoveHook } from '@/packages/administrativo/hooks/TServicoTipo/useTServicoTipoRemoveHook';
|
||||
import { useTServicoTipoSaveHook } from '@/packages/administrativo/hooks/TServicoTipo/useTServicoTipoSaveHook';
|
||||
import TServicoTipoInterface from '@/packages/administrativo/interfaces/TServicoTipo/TServicoTipoInterface';
|
||||
import ConfirmDialog from '@/shared/components/confirmDialog/ConfirmDialog';
|
||||
import { useConfirmDialog } from '@/shared/components/confirmDialog/useConfirmDialog';
|
||||
|
||||
// Interface específica para TServicoTipo
|
||||
import Loading from '@/shared/components/loading/loading';
|
||||
import Header from '@/shared/components/structure/Header';
|
||||
import TServicoTipoInterface from '../../_interfaces/TServicoTipoInterface';
|
||||
|
||||
export default function TServicoTipoPage() {
|
||||
// Hooks para leitura, salvamento e remoção
|
||||
import TServicoTipoForm from './TServicoTipoForm';
|
||||
import TServicoTipoTable from './TServicoTipoTable';
|
||||
|
||||
|
||||
export default function TServicoTipoIndex() {
|
||||
|
||||
const { tServicoTipo, fetchTServicoTipo } = useTServicoTipoReadHook();
|
||||
const { saveTServicoTipo } = useTServicoTipoSaveHook();
|
||||
const { removeTServicoTipo } = useTServicoTipoRemoveHook();
|
||||
|
|
@ -33,9 +28,8 @@ export default function TServicoTipoPage() {
|
|||
const [selectedServicoTipo, setSelectedServicoTipo] = useState<TServicoTipoInterface | null>(
|
||||
null,
|
||||
);
|
||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||
|
||||
// Estado para saber qual item será deletado
|
||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||
const [itemToDelete, setItemToDelete] = useState<TServicoTipoInterface | null>(null);
|
||||
|
||||
/**
|
||||
|
|
@ -95,6 +89,7 @@ export default function TServicoTipoPage() {
|
|||
|
||||
// Atualiza a lista de dados
|
||||
fetchTServicoTipo();
|
||||
|
||||
},
|
||||
[saveTServicoTipo, fetchTServicoTipo],
|
||||
);
|
||||
|
|
@ -144,7 +139,9 @@ export default function TServicoTipoPage() {
|
|||
* Tela de loading enquanto carrega os dados
|
||||
*/
|
||||
if (!tServicoTipo) {
|
||||
|
||||
return <Loading type={2} />;
|
||||
|
||||
}
|
||||
|
||||
return (
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
'use client';
|
||||
|
||||
import { CheckIcon, ChevronsUpDownIcon } from 'lucide-react';
|
||||
import { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
|
||||
import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
|
|
@ -16,30 +16,46 @@ import { FormControl } from '@/components/ui/form';
|
|||
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { useTServicoTipoReadHook } from '@/packages/administrativo/hooks/TServicoTipo/useTServicoTipoReadHook';
|
||||
import TServicoTipoIndexInteface from '@/packages/administrativo/interfaces/TServicoTipo/TServicoTipoIndexInteface';
|
||||
import TServicoTipoSelectInterface from '@/packages/administrativo/interfaces/TServicoTipo/TServicoTipoSelectInterface';
|
||||
import GetCapitalize from '@/shared/actions/text/GetCapitalize';
|
||||
import { ConfirmacaoEnum } from '@/shared/enums/ConfirmacaoEnum';
|
||||
|
||||
import TServicoTipoIndexInteface from '../../interfaces/TServicoTipo/TServicoTipoIndexInteface';
|
||||
/**
|
||||
* Estrutura mínima esperada de um tipo de serviço
|
||||
*/
|
||||
interface TServicoTipoItem {
|
||||
servico_tipo_id?: number;
|
||||
descricao?: string;
|
||||
tipo_item?: string;
|
||||
tipo_pessoa?: string;
|
||||
requer_biometria?: ConfirmacaoEnum;
|
||||
requer_cpf?: ConfirmacaoEnum;
|
||||
servico_caixa_id?: number;
|
||||
selar?: ConfirmacaoEnum;
|
||||
}
|
||||
|
||||
/**
|
||||
* Componente de seleção de Tipos de Serviço.
|
||||
* Compatível com react-hook-form e schemas com objetos completos.
|
||||
*/
|
||||
export default function TServicoTipoSelect({ field }: TServicoTipoSelectInterface) {
|
||||
const [open, setOpen] = useState(false);
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const { tServicoTipo = [], fetchTServicoTipo } = useTServicoTipoReadHook();
|
||||
|
||||
/**
|
||||
* Efeito para buscar os dados apenas uma vez.
|
||||
* Busca inicial de dados
|
||||
*/
|
||||
const loadData = useCallback(async () => {
|
||||
|
||||
const TServicoTipoIndex: TServicoTipoIndexInteface = {
|
||||
urlParams: {
|
||||
situacao: 'A'
|
||||
}
|
||||
}
|
||||
|
||||
if (tServicoTipo.length) return;
|
||||
|
||||
const params: TServicoTipoIndexInteface = {
|
||||
urlParams: { situacao: 'A' },
|
||||
};
|
||||
|
||||
setIsLoading(true);
|
||||
await fetchTServicoTipo(TServicoTipoIndex);
|
||||
await fetchTServicoTipo(params);
|
||||
setIsLoading(false);
|
||||
}, [tServicoTipo.length, fetchTServicoTipo]);
|
||||
|
||||
|
|
@ -48,40 +64,44 @@ export default function TServicoTipoSelect({ field }: TServicoTipoSelectInterfac
|
|||
}, [loadData]);
|
||||
|
||||
/**
|
||||
* Item selecionado (comparando por ID)
|
||||
*/
|
||||
const selected = useMemo(
|
||||
() =>
|
||||
tServicoTipo.find(
|
||||
(item) => String(item.servico_tipo_id) === String(field?.value?.servico_tipo_id ?? ''),
|
||||
),
|
||||
[tServicoTipo, field?.value],
|
||||
);
|
||||
|
||||
/**
|
||||
* Manipulador de seleção
|
||||
* Manipula a seleção de um item
|
||||
*/
|
||||
const handleSelect = useCallback(
|
||||
(item: any) => {
|
||||
(item: TServicoTipoItem) => {
|
||||
if (!field?.onChange) return;
|
||||
|
||||
const selectedValue = {
|
||||
servico_tipo_id: Number(item.servico_tipo_id),
|
||||
descricao: item.descricao,
|
||||
tipo_item: item.tipo_item,
|
||||
tipo_pessoa: item.tipo_pessoa,
|
||||
requer_biometria: item.requer_biometria,
|
||||
requer_cpf: item.requer_cpf,
|
||||
servico_caixa_id: item.servico_caixa_id,
|
||||
selar: item.selar,
|
||||
const selected: TServicoTipoItem = {
|
||||
servico_tipo_id: Number(item.servico_tipo_id ?? 0),
|
||||
descricao: String(item.descricao ?? ''),
|
||||
tipo_item: String(item.tipo_item ?? ''),
|
||||
tipo_pessoa: String(item.tipo_pessoa ?? ''),
|
||||
requer_biometria: (item.requer_biometria as ConfirmacaoEnum) ?? ConfirmacaoEnum.N,
|
||||
requer_cpf: (item.requer_cpf as ConfirmacaoEnum) ?? ConfirmacaoEnum.N,
|
||||
servico_caixa_id: Number(item.servico_caixa_id ?? 0),
|
||||
selar: (item.selar as ConfirmacaoEnum) ?? ConfirmacaoEnum.N,
|
||||
};
|
||||
|
||||
field.onChange(selectedValue);
|
||||
field.onChange(selected);
|
||||
setOpen(false);
|
||||
},
|
||||
[field],
|
||||
);
|
||||
|
||||
/**
|
||||
* Determina o valor exibido no botão principal
|
||||
*/
|
||||
const value = field?.value as TServicoTipoItem | undefined;
|
||||
|
||||
const selectedLabel =
|
||||
value?.descricao && typeof value.descricao === 'string'
|
||||
? GetCapitalize(value.descricao)
|
||||
: 'Selecione...';
|
||||
|
||||
const selectedId =
|
||||
typeof value?.servico_tipo_id === 'number'
|
||||
? String(value.servico_tipo_id)
|
||||
: '';
|
||||
|
||||
return (
|
||||
<Popover open={open} onOpenChange={setOpen}>
|
||||
<PopoverTrigger asChild>
|
||||
|
|
@ -93,11 +113,7 @@ export default function TServicoTipoSelect({ field }: TServicoTipoSelectInterfac
|
|||
disabled={isLoading}
|
||||
className="justify-between"
|
||||
>
|
||||
{isLoading
|
||||
? 'Carregando...'
|
||||
: field.value?.descricao
|
||||
? GetCapitalize(field.value.descricao)
|
||||
: 'Selecione...'}
|
||||
{isLoading ? 'Carregando...' : selectedLabel}
|
||||
<ChevronsUpDownIcon className="ml-2 h-4 w-4 shrink-0 opacity-50" />
|
||||
</Button>
|
||||
</FormControl>
|
||||
|
|
@ -111,24 +127,26 @@ export default function TServicoTipoSelect({ field }: TServicoTipoSelectInterfac
|
|||
{isLoading ? 'Carregando...' : 'Nenhum resultado encontrado.'}
|
||||
</CommandEmpty>
|
||||
<CommandGroup>
|
||||
{tServicoTipo.map((item) => (
|
||||
<CommandItem
|
||||
key={item.servico_tipo_id}
|
||||
value={item.descricao?.toLowerCase() ?? ''}
|
||||
onSelect={() => handleSelect(item)}
|
||||
>
|
||||
<CheckIcon
|
||||
className={cn(
|
||||
'mr-2 h-4 w-4',
|
||||
String(field?.value?.servico_tipo_id ?? '') ===
|
||||
String(item.servico_tipo_id)
|
||||
? 'opacity-100'
|
||||
: 'opacity-0',
|
||||
)}
|
||||
/>
|
||||
{GetCapitalize(item.descricao ?? '')}
|
||||
</CommandItem>
|
||||
))}
|
||||
{tServicoTipo.map((item) => {
|
||||
const itemId = String(item.servico_tipo_id ?? '');
|
||||
const isSelected = selectedId === itemId;
|
||||
|
||||
return (
|
||||
<CommandItem
|
||||
key={itemId}
|
||||
value={item.descricao?.toLowerCase() ?? ''}
|
||||
onSelect={() => handleSelect(item)}
|
||||
>
|
||||
<CheckIcon
|
||||
className={cn(
|
||||
'mr-2 h-4 w-4',
|
||||
isSelected ? 'opacity-100' : 'opacity-0',
|
||||
)}
|
||||
/>
|
||||
{GetCapitalize(item.descricao ?? '')}
|
||||
</CommandItem>
|
||||
);
|
||||
})}
|
||||
</CommandGroup>
|
||||
</CommandList>
|
||||
</Command>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
'use client';
|
||||
|
||||
import TServicoTipoTableInterface from '@/packages/administrativo/interfaces/TServicoTipo/TServicoTipoTableInterface';
|
||||
import { DataTable } from '@/shared/components/dataTable/DataTable';
|
||||
|
||||
import TServicoTipoColumns from './TServicoTipoColumns';
|
||||
|
||||
|
||||
/**
|
||||
* Componente principal da tabela de Naturezas
|
||||
*/
|
||||
export default function TServicoTipoTable({ data, onEdit, onDelete }: TServicoTipoTableInterface) {
|
||||
const columns = TServicoTipoColumns(onEdit, onDelete);
|
||||
return (
|
||||
<div>
|
||||
<DataTable
|
||||
data={data}
|
||||
columns={columns}
|
||||
filterColumn="descricao"
|
||||
filterPlaceholder="Buscar por descrição da natureza..."
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
import { zodResolver } from '@hookform/resolvers/zod';
|
||||
import { useEffect } from 'react';
|
||||
import { useForm, Controller } from 'react-hook-form';
|
||||
import { Controller, useForm } from 'react-hook-form';
|
||||
import z from 'zod';
|
||||
|
||||
import { Button } from '@/components/ui/button';
|
||||
|
|
@ -26,9 +26,8 @@ import {
|
|||
} from '@/components/ui/form';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Label } from '@/components/ui/label';
|
||||
|
||||
import { situacaoEnum } from '../../interfaces/TTBREconhecimentoTipo/TTBReconhecimentoTipoInterface';
|
||||
import { TTBReconhecimentoTipoSchema } from '../../schemas/TTBReconhecimentoTipo/TTBReconhecimentoTipoSchema';
|
||||
import { TTBReconhecimentoTipoSchema } from '@/packages/administrativo/schemas/TTBReconhecimentoTipo/TTBReconhecimentoTipoSchema';
|
||||
import { SituacoesEnum } from '@/shared/enums/SituacoesEnum';
|
||||
|
||||
type FormValues = z.infer<typeof TTBReconhecimentoTipoSchema>;
|
||||
|
||||
|
|
@ -45,17 +44,15 @@ export default function TTBReconhecimentoTipoForm({
|
|||
onClose,
|
||||
onSave,
|
||||
}: TTBReconhecimentoTipoFormProps) {
|
||||
// Inicializa o react-hook-form com schema zod
|
||||
const form = useForm<FormValues>({
|
||||
resolver: zodResolver(TTBReconhecimentoTipoSchema),
|
||||
defaultValues: {
|
||||
tb_reconhecimentotipo_id: 0,
|
||||
descricao: '',
|
||||
situacao: situacaoEnum.ATIVO,
|
||||
situacao: SituacoesEnum.A,
|
||||
},
|
||||
});
|
||||
|
||||
// Atualiza o formulário quando recebe dados para edição
|
||||
useEffect(() => {
|
||||
if (data) form.reset(data);
|
||||
}, [data, form]);
|
||||
|
|
@ -75,7 +72,7 @@ export default function TTBReconhecimentoTipoForm({
|
|||
|
||||
<Form {...form}>
|
||||
<form onSubmit={form.handleSubmit(onSave)} className="space-y-6">
|
||||
{/* Descrição */}
|
||||
{/* Campo: Descrição */}
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="descricao"
|
||||
|
|
@ -90,22 +87,30 @@ export default function TTBReconhecimentoTipoForm({
|
|||
)}
|
||||
/>
|
||||
|
||||
{/* Situação */}
|
||||
{/* Campo: Situação (checkbox com enum) */}
|
||||
<Controller
|
||||
name="situacao"
|
||||
control={form.control}
|
||||
render={({ field }) => (
|
||||
<div className="flex items-center space-x-2">
|
||||
<Checkbox
|
||||
checked={field.value === 'A'}
|
||||
onCheckedChange={(checked) => field.onChange(checked ? 'A' : 'I')}
|
||||
/>
|
||||
<Label>Ativo</Label>
|
||||
</div>
|
||||
)}
|
||||
render={({ field }) => {
|
||||
const isAtivo = field.value === SituacoesEnum.A;
|
||||
|
||||
return (
|
||||
<div className="flex items-center space-x-2">
|
||||
<Checkbox
|
||||
checked={isAtivo}
|
||||
onCheckedChange={(checked) =>
|
||||
field.onChange(
|
||||
checked ? SituacoesEnum.A : SituacoesEnum.I,
|
||||
)
|
||||
}
|
||||
/>
|
||||
<Label>Ativo</Label>
|
||||
</div>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
|
||||
{/* Rodapé do Dialog */}
|
||||
{/* Rodapé */}
|
||||
<DialogFooter className="mt-4">
|
||||
<DialogClose asChild>
|
||||
<Button
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
'use client';
|
||||
|
||||
import { useEffect, useState, useCallback } from 'react';
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
|
||||
import { Card, CardContent } from '@/components/ui/card';
|
||||
import { useTTBReconhecimentoTipoDeleteHook } from '@/packages/administrativo/hooks/TTBReconhecimentoTipo/useTTBReconhecimentoTipoDeleteHook';
|
||||
import { useTTBReconhecimentoTipoReadHook } from '@/packages/administrativo/hooks/TTBReconhecimentoTipo/useTTBReconhecimentoTipoReadHook';
|
||||
import { useTTBReconhecimentoTipoSaveHook } from '@/packages/administrativo/hooks/TTBReconhecimentoTipo/useTTBReconhecimentoTipoSaveHook';
|
||||
import TTBReconhecimentoTipoInterface from '@/packages/administrativo/interfaces/TTBREconhecimentoTipo/TTBReconhecimentoTipoInterface';
|
||||
import ConfirmDialog from '@/shared/components/confirmDialog/ConfirmDialog';
|
||||
import { useConfirmDialog } from '@/shared/components/confirmDialog/useConfirmDialog';
|
||||
import Loading from '@/shared/components/loading/loading';
|
||||
|
|
@ -13,12 +14,10 @@ import Header from '@/shared/components/structure/Header';
|
|||
|
||||
import TTBReconhecimentoTipoForm from './TTBReconhecimentoTipoForm';
|
||||
import TTBReconhecimentoTipoTable from './TTBReconhecimentoTipoTable';
|
||||
import TTBReconhecimentoTipoInterface from '../../interfaces/TTBREconhecimentoTipo/TTBReconhecimentoTipoInterface';
|
||||
|
||||
export default function TTBReconhecimentoTipoIndex() {
|
||||
// Hooks para leitura e salvamento
|
||||
const { tTBReconhecimentosTipos, fetchTTBReconhecimentosTipos } =
|
||||
useTTBReconhecimentoTipoReadHook();
|
||||
const { tTBReconhecimentoTipo, fetchTTBReconhecimentoTipo } = useTTBReconhecimentoTipoReadHook();
|
||||
const { saveTTBReconhecimentoTipo } = useTTBReconhecimentoTipoSaveHook();
|
||||
const { deleteTTBReconhecimentoTipo } = useTTBReconhecimentoTipoDeleteHook();
|
||||
|
||||
|
|
@ -36,7 +35,6 @@ export default function TTBReconhecimentoTipoIndex() {
|
|||
const {
|
||||
isOpen: isConfirmOpen,
|
||||
openDialog: openConfirmDialog,
|
||||
handleConfirm,
|
||||
handleCancel,
|
||||
} = useConfirmDialog();
|
||||
|
||||
|
|
@ -65,9 +63,9 @@ export default function TTBReconhecimentoTipoIndex() {
|
|||
await saveTTBReconhecimentoTipo(formData);
|
||||
|
||||
// Atualiza a lista de dados
|
||||
fetchTTBReconhecimentosTipos();
|
||||
fetchTTBReconhecimentoTipo();
|
||||
},
|
||||
[saveTTBReconhecimentoTipo, fetchTTBReconhecimentosTipos],
|
||||
[saveTTBReconhecimentoTipo, fetchTTBReconhecimentoTipo],
|
||||
);
|
||||
|
||||
/**
|
||||
|
|
@ -95,26 +93,26 @@ export default function TTBReconhecimentoTipoIndex() {
|
|||
await deleteTTBReconhecimentoTipo(itemToDelete);
|
||||
|
||||
// Atualiza a lista
|
||||
await fetchTTBReconhecimentosTipos();
|
||||
await fetchTTBReconhecimentoTipo();
|
||||
|
||||
// Limpa o item selecionado
|
||||
setItemToDelete(null);
|
||||
|
||||
// Fecha o modal
|
||||
handleCancel();
|
||||
}, [itemToDelete, fetchTTBReconhecimentosTipos, handleCancel]);
|
||||
}, [itemToDelete, fetchTTBReconhecimentoTipo, handleCancel]);
|
||||
|
||||
/**
|
||||
* Busca inicial dos dados
|
||||
*/
|
||||
useEffect(() => {
|
||||
fetchTTBReconhecimentosTipos();
|
||||
fetchTTBReconhecimentoTipo();
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Tela de loading enquanto carrega os dados
|
||||
*/
|
||||
if (!tTBReconhecimentosTipos) {
|
||||
if (!tTBReconhecimentoTipo) {
|
||||
return <Loading type={2} />;
|
||||
}
|
||||
|
||||
|
|
@ -134,7 +132,7 @@ export default function TTBReconhecimentoTipoIndex() {
|
|||
<Card>
|
||||
<CardContent>
|
||||
<TTBReconhecimentoTipoTable
|
||||
data={tTBReconhecimentosTipos}
|
||||
data={tTBReconhecimentoTipo}
|
||||
onEdit={handleOpenForm}
|
||||
onDelete={handleConfirmDelete}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
'use client';
|
||||
|
||||
import React from 'react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
Command,
|
||||
|
|
@ -13,10 +12,10 @@ import {
|
|||
import { FormControl } from '@/components/ui/form';
|
||||
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { CheckIcon, ChevronsUpDownIcon } from 'lucide-react';
|
||||
import { useTTBReconhecimentoTipoReadHook } from '@/packages/administrativo/hooks/TTBReconhecimentoTipo/useTTBReconhecimentoTipoReadHook';
|
||||
import GetCapitalize from '@/shared/actions/text/GetCapitalize';
|
||||
import { useTTBReconhecimentoTipoReadHook } from '@/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_reconhecimentotipo/useTTBReconhecimentoTipoReadHook';
|
||||
import { TTBREconhecimentoTipoReadInterface } from '@/app/(protected)/(cadastros)/cadastros/_interfaces/TTBREconhecimentoTipoReadInterface';
|
||||
import { CheckIcon, ChevronsUpDownIcon } from 'lucide-react';
|
||||
import React from 'react';
|
||||
|
||||
export default function TTBReconhecimentoTipoSelect({ field }: any) {
|
||||
const [open, setOpen] = React.useState(false);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,8 @@ import API from '@/shared/services/api/Api';
|
|||
|
||||
// Importa o enum que define os métodos HTTP disponíveis (GET, POST, PUT, DELETE, etc.)
|
||||
import { Methods } from '@/shared/services/api/enums/ApiMethodEnum';
|
||||
import { CCaixaServicoReadInterface } from '../../_interfaces/CCaixaServicoReadInterface';
|
||||
|
||||
import { CCaixaServicoReadInterface } from '../../hooks/CCaixaServico/CCaixaServicoReadInterface';
|
||||
|
||||
// Função assíncrona responsável por executar a requisição para listar os tipos de marcação
|
||||
async function executeCCaixaServicoIndexData(data: CCaixaServicoReadInterface) {
|
||||
|
|
@ -21,6 +22,7 @@ async function executeCCaixaServicoIndexData(data: CCaixaServicoReadInterface) {
|
|||
method: Methods.GET,
|
||||
endpoint: endpoint,
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// Exporta a função encapsulada pelo handler de erro, garantindo tratamento uniforme em caso de falhas
|
||||
|
|
@ -1,15 +1,19 @@
|
|||
// src/packages/administrativo/data/GEmolumento/GEmolumentoIndexData.ts
|
||||
import { GEmolumentoReadInterface } from '@/packages/administrativo/interfaces/GEmolumento/GEmolumentoReadInterface';
|
||||
import { withClientErrorHandler } from '@/shared/actions/withClientErrorHandler/withClientErrorHandler';
|
||||
import API from '@/shared/services/api/Api';
|
||||
import { Methods } from '@/shared/services/api/enums/ApiMethodEnum';
|
||||
import ApiResponseInterface from '@/shared/services/api/interfaces/ApiResponseInterface';
|
||||
|
||||
async function executeGEmolumentoIndexData(): Promise<ApiResponseInterface> {
|
||||
async function executeGEmolumentoIndexData(data?: GEmolumentoReadInterface) {
|
||||
|
||||
const api = new API();
|
||||
|
||||
return api.send({
|
||||
const queryString = data?.urlParams ? new URLSearchParams(data.urlParams as Record<string, string>).toString() : '';
|
||||
|
||||
return await api.send({
|
||||
method: Methods.GET,
|
||||
endpoint: `administrativo/g_emolumento/`,
|
||||
endpoint: `administrativo/g_emolumento/sistema/${data?.sistema_id}${queryString ? `?${queryString}` : ''}`,
|
||||
});
|
||||
}
|
||||
|
||||
export const GEmolumentoIndexData = withClientErrorHandler(executeGEmolumentoIndexData);
|
||||
export const GEmolumentoIndexData = withClientErrorHandler(executeGEmolumentoIndexData);
|
||||
|
|
@ -6,7 +6,8 @@ import API from '@/shared/services/api/Api';
|
|||
|
||||
// Importa o enum que define os métodos HTTP disponíveis (GET, POST, PUT, DELETE, etc.)
|
||||
import { Methods } from '@/shared/services/api/enums/ApiMethodEnum';
|
||||
import { GEmolumentoItemReadInterface } from '../../_interfaces/GEmolumentoItemReadInterface';
|
||||
|
||||
import { GEmolumentoItemReadInterface } from '../../interfaces/GEmolumentoItem/GEmolumentoItemReadInterface';
|
||||
|
||||
// Função assíncrona responsável por executar a requisição para listar os tipos de marcação
|
||||
async function executeGEmolumentoItemValorData(data: GEmolumentoItemReadInterface) {
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
// Importa o utilitário responsável por tratar erros de forma padronizada no cliente
|
||||
import { buildQueryString } from '@/shared/actions/api/buildQueryString';
|
||||
import { withClientErrorHandler } from '@/shared/actions/withClientErrorHandler/withClientErrorHandler';
|
||||
|
||||
// Importa a classe de serviço que gerencia requisições HTTP para a API
|
||||
|
|
@ -6,10 +7,10 @@ import API from '@/shared/services/api/Api';
|
|||
|
||||
// Importa o enum que define os métodos HTTP disponíveis (GET, POST, PUT, DELETE, etc.)
|
||||
import { Methods } from '@/shared/services/api/enums/ApiMethodEnum';
|
||||
import { GMarcacaoTipoReadInterface } from '../../_interfaces/GMarcacaoTipoReadInterface';
|
||||
|
||||
import { GMarcacaoTipoReadInterface } from '../../interfaces/GMarcacaoTipo/GMarcacaoTipoReadInterface';
|
||||
|
||||
// Importa a função genérica que monta a query string dinamicamente
|
||||
import { buildQueryString } from '@/shared/actions/api/buildQueryString';
|
||||
|
||||
// Função assíncrona responsável por executar a requisição para listar os tipos de marcação
|
||||
async function executeGMarcacaoTipoIndexData(data: GMarcacaoTipoReadInterface) {
|
||||
|
|
@ -1,19 +1,17 @@
|
|||
'use server';
|
||||
|
||||
import GUsuarioIndexInterface from '@/packages/administrativo/interfaces/GUsuario/GUsuarioIndexInterface';
|
||||
import API from '@/shared/services/api/Api';
|
||||
import { Methods } from '@/shared/services/api/enums/ApiMethodEnum';
|
||||
|
||||
import GUsuarioIndexInterface from '../../interfaces/GUsuario/GusuarioIndexInterface';
|
||||
export default async function GUsuarioIndexData(data?: GUsuarioIndexInterface) {
|
||||
|
||||
export default async function GUsuarioIndexData(data: GUsuarioIndexInterface) {
|
||||
const api = new API();
|
||||
|
||||
const response = await api.send({
|
||||
method: Methods.GET,
|
||||
endpoint: `administrativo/g_usuario?${new URLSearchParams(data.urlParams).toString()}`,
|
||||
endpoint: `administrativo/g_usuario?${new URLSearchParams(data?.urlParams).toString()}`,
|
||||
});
|
||||
|
||||
console.log(response)
|
||||
|
||||
return response;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import API from '@/shared/services/api/Api'; //
|
|||
import { Methods } from '@/shared/services/api/enums/ApiMethodEnum'; //
|
||||
|
||||
// Importa a interface tipada que define a estrutura dos dados do tipo de serviço
|
||||
import { TServicoEtiquetaInterface } from '../../_interfaces/TServicoEtiquetaInterface';
|
||||
import { TServicoEtiquetaInterface } from '../../interfaces/TServicoEtiqueta/TServicoEtiquetaInterface';
|
||||
|
||||
// Importa função que encapsula chamadas assíncronas e trata erros automaticamente
|
||||
import { withClientErrorHandler } from '@/shared/actions/withClientErrorHandler/withClientErrorHandler'; //
|
||||
|
|
@ -5,7 +5,7 @@ import API from '@/shared/services/api/Api'; //
|
|||
import { Methods } from '@/shared/services/api/enums/ApiMethodEnum'; //
|
||||
|
||||
// Importa a interface tipada que define a estrutura dos dados do tipo de serviço
|
||||
import { TServicoEtiquetaInterface } from '../../_interfaces/TServicoEtiquetaInterface'; // Alterado de GCidadeInterface
|
||||
import { TServicoEtiquetaInterface } from '../../interfaces/TServicoEtiqueta/TServicoEtiquetaInterface'; // Alterado de GCidadeInterface
|
||||
|
||||
// Importa função que encapsula chamadas assíncronas e trata erros automaticamente
|
||||
import { withClientErrorHandler } from '@/shared/actions/withClientErrorHandler/withClientErrorHandler'; //
|
||||
|
|
@ -1,17 +1,17 @@
|
|||
// Importa o serviço de API que será utilizado para realizar requisições HTTP
|
||||
import { withClientErrorHandler } from '@/shared/actions/withClientErrorHandler/withClientErrorHandler'; //
|
||||
import API from '@/shared/services/api/Api'; //
|
||||
|
||||
// Importa o esquema de validação de dados para tipos de serviço
|
||||
import { TServicoEtiquetaFormValues } from '../../_schemas/TServicoEtiquetaSchema';
|
||||
|
||||
// Importa o enum que contém os métodos HTTP disponíveis (GET, POST, PUT, DELETE)
|
||||
import { Methods } from '@/shared/services/api/enums/ApiMethodEnum'; //
|
||||
|
||||
import { TServicoEtiquetaFormValues } from '../../schemas/TServicoEtiqueta/TServicoEtiquetaSchema';
|
||||
|
||||
// Importa o enum que contém os métodos HTTP disponíveis (GET, POST, PUT, DELETE)
|
||||
|
||||
// Importa a interface tipada que define a estrutura dos dados do tipo de serviço
|
||||
import { TServicoEtiquetaInterface } from '../../_interfaces/TServicoEtiquetaInterface'; // Interface alterada
|
||||
|
||||
// Importa função que encapsula chamadas assíncronas e trata erros automaticamente
|
||||
import { withClientErrorHandler } from '@/shared/actions/withClientErrorHandler/withClientErrorHandler'; //
|
||||
|
||||
// Função assíncrona que implementa a lógica de salvar (criar/atualizar) um tipo de serviço
|
||||
async function executeTServicoEtiquetaSaveData(data: TServicoEtiquetaFormValues) {
|
||||
|
|
@ -5,7 +5,7 @@ import API from '@/shared/services/api/Api'; //
|
|||
import { Methods } from '@/shared/services/api/enums/ApiMethodEnum'; //
|
||||
|
||||
// Importa a interface tipada que define a estrutura dos dados do tipo de serviço
|
||||
import TServicoTipoInterface from '../../../../app/(protected)/(cadastros)/cadastros/_interfaces/TServicoTipoInterface'; // Alterado de GCidadeInterface
|
||||
import TServicoTipoInterface from '../../interfaces/TServicoTipo/TServicoTipoInterface'; // Alterado de GCidadeInterface
|
||||
|
||||
// Importa função que encapsula chamadas assíncronas e trata erros automaticamente
|
||||
import { withClientErrorHandler } from '@/shared/actions/withClientErrorHandler/withClientErrorHandler'; //
|
||||
|
|
|
|||
|
|
@ -1,25 +1,18 @@
|
|||
// Importa o serviço de API que será utilizado para realizar requisições HTTP
|
||||
import TServicoTipoIndexInteface from '@/packages/administrativo/interfaces/TServicoTipo/TServicoTipoIndexInteface';
|
||||
import { withClientErrorHandler } from '@/shared/actions/withClientErrorHandler/withClientErrorHandler';
|
||||
import API from '@/shared/services/api/Api';
|
||||
import { Methods } from '@/shared/services/api/enums/ApiMethodEnum';
|
||||
|
||||
// Importa o enum que contém os métodos HTTP disponíveis (GET, POST, PUT, DELETE)
|
||||
import { Methods } from '@/shared/services/api/enums/ApiMethodEnum'; //
|
||||
|
||||
import TServicoTipoIndexInteface from '../../interfaces/TServicoTipo/TServicoTipoIndexInteface';
|
||||
|
||||
// Importa função que encapsula chamadas assíncronas e trata erros automaticamente
|
||||
async function executeTServicoTipoIndexData(data?: TServicoTipoIndexInteface) {
|
||||
|
||||
// Função assíncrona que implementa a lógica de buscar todos os tipos de serviço (GET)
|
||||
async function executeTServicoTipoIndexData(data: TServicoTipoIndexInteface) {
|
||||
// Instancia o cliente da API para enviar a requisição
|
||||
const api = new API(); //
|
||||
const api = new API();
|
||||
|
||||
// Executa a requisição para a API com o método apropriado e o endpoint da tabela t_servico_tipo
|
||||
return await api.send({
|
||||
method: Methods.GET, // GET listar todos os itens
|
||||
endpoint: `administrativo/t_servico_tipo/?${new URLSearchParams(data.urlParams).toString()}`,
|
||||
method: Methods.GET,
|
||||
endpoint: `administrativo/t_servico_tipo/?${new URLSearchParams(data?.urlParams).toString()}`,
|
||||
});
|
||||
}
|
||||
|
||||
// Exporta a função de listar tipos de serviço já encapsulada com tratamento de erros
|
||||
export const TServicoTipoIndexData = withClientErrorHandler(executeTServicoTipoIndexData);
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import API from '@/shared/services/api/Api'; //
|
|||
import { Methods } from '@/shared/services/api/enums/ApiMethodEnum'; //
|
||||
|
||||
// Importa a interface tipada que define a estrutura dos dados do tipo de serviço
|
||||
import TServicoTipoInterface from '../../../../app/(protected)/(cadastros)/cadastros/_interfaces/TServicoTipoInterface'; // Alterado de GCidadeInterface
|
||||
import TServicoTipoInterface from '../../interfaces/TServicoTipo/TServicoTipoInterface'; // Alterado de GCidadeInterface
|
||||
|
||||
// Importa função que encapsula chamadas assíncronas e trata erros automaticamente
|
||||
import { withClientErrorHandler } from '@/shared/actions/withClientErrorHandler/withClientErrorHandler'; //
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
import API from '@/shared/services/api/Api'; //
|
||||
|
||||
// Importa o esquema de validação de dados para tipos de serviço
|
||||
import { TServicoTipoFormValues } from '../../../../app/(protected)/(cadastros)/cadastros/_schemas/TServicoTipoSchema';
|
||||
import { TServicoTipoFormValues } from '../../schemas/TServicoTipo/TServicoTipoSchema';
|
||||
|
||||
// Importa o enum que contém os métodos HTTP disponíveis (GET, POST, PUT, DELETE)
|
||||
import { Methods } from '@/shared/services/api/enums/ApiMethodEnum'; //
|
||||
|
|
|
|||
|
|
@ -1,15 +1,22 @@
|
|||
'use server';
|
||||
|
||||
import { TTBReconhecimentoTipoReadInterface } from '@/packages/administrativo/interfaces/TTBREconhecimentoTipo/TTBReconhecimentoTipoReadInterface';
|
||||
import { withClientErrorHandler } from '@/shared/actions/withClientErrorHandler/withClientErrorHandler';
|
||||
import API from '@/shared/services/api/Api';
|
||||
import { Methods } from '@/shared/services/api/enums/ApiMethodEnum';
|
||||
|
||||
export default async function TTBReconhecimentoTipoIndexData() {
|
||||
|
||||
// Função assíncrona responsável por executar a requisição para listar os tipos de marcação
|
||||
async function executeTTBReconhecimentoTipoIndexData(data?: TTBReconhecimentoTipoReadInterface) {
|
||||
// Cria uma nova instância da classe API para enviar a requisição
|
||||
const api = new API();
|
||||
|
||||
const response = await api.send({
|
||||
// Envia uma requisição GET para o endpoint 'administrativo/g_marcacao_tipo/'
|
||||
return await api.send({
|
||||
method: Methods.GET,
|
||||
endpoint: `administrativo/t_tb_reconhecimentotipo`,
|
||||
endpoint: `administrativo/t_tb_reconhecimentotipo/${new URLSearchParams(data?.urlParams).toString()}`
|
||||
});
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
// Exporta a função encapsulada pelo handler de erro, garantindo tratamento uniforme em caso de falhas
|
||||
export const TTBReconhecimentoTipoIndexData = withClientErrorHandler(
|
||||
executeTTBReconhecimentoTipoIndexData,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
'use server';
|
||||
|
||||
import API from '@/shared/services/api/Api';
|
||||
import { Methods } from '@/shared/services/api/enums/ApiMethodEnum';
|
||||
|
||||
export default async function TTBReconhecimentoTipoIndexData() {
|
||||
const api = new API();
|
||||
|
||||
const response = await api.send({
|
||||
method: Methods.GET,
|
||||
endpoint: `administrativo/t_tb_reconhecimentotipo`,
|
||||
});
|
||||
|
||||
return response;
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
import { useMemo, useState } from 'react';
|
||||
|
||||
import GEmolumentoInterface from '@/packages/administrativo/interfaces/GEmolumento/GEmolumentoInterface';
|
||||
import { GEmolumentoReadInterface } from '@/packages/administrativo/interfaces/GEmolumento/GEmolumentoReadInterface';
|
||||
import { GEmolumentoIndexService } from '@/packages/administrativo/services/GEmolumento/GEmolumentoIndexService';
|
||||
import { useResponse } from '@/shared/components/response/ResponseContext';
|
||||
|
||||
export const useGEmolumentoReadHook = () => {
|
||||
|
||||
const { setResponse } = useResponse();
|
||||
|
||||
const [gEmolumento, setGEmolumento] = useState<GEmolumentoInterface[]>([]);
|
||||
|
||||
const fetchGEmolumento = async (data?: GEmolumentoReadInterface) => {
|
||||
|
||||
const response = await GEmolumentoIndexService(data as any);
|
||||
|
||||
setGEmolumento(response.data);
|
||||
|
||||
setResponse(response);
|
||||
};
|
||||
|
||||
return useMemo(() => ({ gEmolumento, fetchGEmolumento }), [gEmolumento, fetchGEmolumento]);
|
||||
};
|
||||
|
|
@ -1,17 +1,11 @@
|
|||
// Importa o hook responsável por gerenciar e exibir respostas globais (sucesso, erro, etc.)
|
||||
import { useMemo, useState } from 'react';
|
||||
|
||||
import GEmolumentoItemInterface from '@/packages/administrativo/interfaces/GEmolumentoItem/GEmolumentoItemInterface';
|
||||
import { GEmolumentoItemReadInterface } from '@/packages/administrativo/interfaces/GEmolumentoItem/GEmolumentoItemReadInterface';
|
||||
import { GEmolumentoItemValorService } from '@/packages/administrativo/services/GEmolumentoItem/GEmolumentoItemValorService';
|
||||
import { useResponse } from '@/shared/components/response/ResponseContext';
|
||||
|
||||
// Importa hooks do React para gerenciamento de estado e memorização de valores
|
||||
|
||||
// Importa a interface que define a estrutura dos dados de "gEmolumentoItem"
|
||||
import { GEmolumentoItemInterface } from '../../_interfaces/GEmolumentoItemInterface';
|
||||
import { GEmolumentoItemReadInterface } from '../../_interfaces/GEmolumentoItemReadInterface';
|
||||
|
||||
// Importa o serviço responsável por buscar os dados de "GEmolumentoItem" na API
|
||||
import { GEmolumentoItemValorService } from '../../_services/g_emolumento_item/GEmolumentoItemValorService';
|
||||
|
||||
// Hook personalizado para leitura (consulta) dos emolumentos
|
||||
export const useGEmolumentoItemReadHook = () => {
|
||||
const { setResponse } = useResponse();
|
||||
|
|
@ -1,15 +1,16 @@
|
|||
// Importa o hook responsável por gerenciar e exibir respostas globais (sucesso, erro, etc.)
|
||||
import { useMemo, useState } from 'react';
|
||||
|
||||
import { useResponse } from '@/shared/components/response/ResponseContext';
|
||||
|
||||
// Importa hooks do React para gerenciamento de estado e memorização de valores
|
||||
import { useMemo, useState } from 'react';
|
||||
|
||||
// Importa a interface que define a estrutura dos dados de "GMarcacaoTipo"
|
||||
import { GMarcacaoTipoReadInterface } from '../../_interfaces/GMarcacaoTipoReadInterface';
|
||||
import { GMarcacaoTipoInterface } from '../../_interfaces/GMarcacaoTipoInterface';
|
||||
import { GMarcacaoTipoInterface } from '../../interfaces/GMarcacaoTipo/GMarcacaoTipoInterface';
|
||||
import { GMarcacaoTipoReadInterface } from '../../interfaces/GMarcacaoTipo/GMarcacaoTipoReadInterface';
|
||||
|
||||
// Importa o serviço responsável por buscar os dados de "GMarcacaoTipo" na API
|
||||
import { GMarcacaoTipoIndexService } from '../../_services/g_marcacao_tipo/GMarcacaoTipoIndexService';
|
||||
import { GMarcacaoTipoIndexService } from '../../services/GMarcacaoTipo/GMarcacaoTipoIndexService';
|
||||
|
||||
// Hook personalizado para leitura (consulta) dos tipos de marcação
|
||||
export const useGMarcacaoTipoReadHook = () => {
|
||||
|
|
@ -5,7 +5,7 @@ import { useState } from 'react';
|
|||
import Usuario from '@/packages/administrativo/interfaces/GUsuario/GUsuarioInterface';
|
||||
import { useResponse } from '@/shared/components/response/ResponseContext';
|
||||
|
||||
import GUsuarioIndexInterface from '../../interfaces/GUsuario/GusuarioIndexInterface';
|
||||
import GUsuarioIndexInterface from '../../interfaces/GUsuario/GUsuarioIndexInterface';
|
||||
import GUsuarioIndex from '../../services/GUsuario/GUsuarioIndex';
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,15 @@
|
|||
// Importa o hook responsável por gerenciar e exibir respostas globais (sucesso, erro, etc.)
|
||||
import { useCallback, useState } from 'react';
|
||||
|
||||
import { useResponse } from '@/shared/components/response/ResponseContext';
|
||||
|
||||
// Importa hooks do React para gerenciamento de estado e memorização de valores
|
||||
import { useCallback, useState } from 'react';
|
||||
|
||||
// Importa a interface que define a estrutura dos dados de "TServicoEtiqueta"
|
||||
import { TServicoEtiquetaInterface } from '../../_interfaces/TServicoEtiquetaInterface';
|
||||
import { TServicoEtiquetaInterface } from '../../interfaces/TServicoEtiqueta/TServicoEtiquetaInterface';
|
||||
|
||||
// Importa o serviço responsável por buscar os dados de "TServicoEtiqueta" na API
|
||||
import { TServicoEtiquetaServicoIdService } from '../../_services/t_servico_etiqueta/TServicoEtiquetaServicoIdService';
|
||||
import { TServicoEtiquetaServicoIdService } from '../../services/TServicoEtiqueta/TServicoEtiquetaServicoIdService';
|
||||
|
||||
// Hook personalizado para leitura (consulta) dos tipos de marcação
|
||||
export const useTServicoEtiquetaReadHook = () => {
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
import { useResponse } from '@/shared/components/response/ResponseContext'; // Contexto global para gerenciar respostas da API
|
||||
|
||||
// Interface tipada do tipo de serviço
|
||||
import { TServicoEtiquetaInterface } from '../../_interfaces/TServicoEtiquetaInterface';
|
||||
import { TServicoEtiquetaInterface } from '../../interfaces/TServicoEtiqueta/TServicoEtiquetaInterface';
|
||||
|
||||
// Função que remove o tipo de serviço via API
|
||||
import { TServicoEtiquetaRemoveData } from '../../_data/TServicoEtiqueta/TServicoEtiquetaRemoveData';
|
||||
import { TServicoEtiquetaRemoveData } from '../../data/TServicoEtiqueta/TServicoEtiquetaRemoveData';
|
||||
|
||||
// Hook customizado para remoção de tipos de serviço
|
||||
export const useTServicoEtiquetaRemoveHook = () => {
|
||||
|
|
@ -1,11 +1,12 @@
|
|||
import { useState } from 'react';
|
||||
|
||||
import { useResponse } from '@/shared/components/response/ResponseContext';
|
||||
|
||||
// Interface tipada do serviço etiqueta
|
||||
import { TServicoEtiquetaInterface } from '../../_interfaces/TServicoEtiquetaInterface';
|
||||
import { TServicoEtiquetaInterface } from '../../interfaces/TServicoEtiqueta/TServicoEtiquetaInterface';
|
||||
|
||||
// Serviço que salva os dados do serviço etiqueta
|
||||
import { TServicoEtiquetaSaveService } from '../../_services/t_servico_etiqueta/TServicoEtiquetaSaveService';
|
||||
import { TServicoEtiquetaSaveService } from '../../services/TServicoEtiqueta/TServicoEtiquetaSaveService';
|
||||
|
||||
export const useTServicoEtiquetaSaveHook = () => {
|
||||
const { setResponse } = useResponse();
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
import { useResponse } from '@/shared/components/response/ResponseContext'; // Contexto global para gerenciar respostas da API
|
||||
|
||||
// Interface tipada do tipo de serviço
|
||||
import TServicoTipoInterface from '../../../../app/(protected)/(cadastros)/cadastros/_interfaces/TServicoTipoInterface';
|
||||
import TServicoTipoInterface from '../../interfaces/TServicoTipo/TServicoTipoInterface';
|
||||
|
||||
// Função que Edit o tipo de serviço via API
|
||||
import { TServicoTipoEditData } from '../../data/TServicoTipo/TServicoTipoEditData';
|
||||
|
|
|
|||
|
|
@ -0,0 +1,26 @@
|
|||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { useForm } from "react-hook-form";
|
||||
|
||||
import { TServicoTipoFormValues, TServicoTipoSchema } from "@/packages/administrativo/schemas/TServicoTipo/TServicoTipoSchema";
|
||||
import { ConfirmacaoEnum } from "@/shared/enums/ConfirmacaoEnum";
|
||||
import { SituacoesEnum } from "@/shared/enums/SituacoesEnum";
|
||||
|
||||
export function useTServicoTipoFormHook(defaults?: Partial<TServicoTipoFormValues>) {
|
||||
return useForm<TServicoTipoFormValues>({
|
||||
resolver: zodResolver(TServicoTipoSchema),
|
||||
defaultValues: {
|
||||
situacao: SituacoesEnum.A,
|
||||
frenteverso: ConfirmacaoEnum.N,
|
||||
averbacao: ConfirmacaoEnum.N,
|
||||
transferencia_veiculo: ConfirmacaoEnum.N,
|
||||
usar_a4: ConfirmacaoEnum.N,
|
||||
etiqueta_unica: ConfirmacaoEnum.N,
|
||||
selar: ConfirmacaoEnum.N,
|
||||
valor_emolumento: 0,
|
||||
valor_taxa_judiciaria: 0,
|
||||
fundesp_valor: 0,
|
||||
valor_total: 0,
|
||||
...defaults
|
||||
},
|
||||
});
|
||||
}
|
||||
|
|
@ -3,8 +3,8 @@ import { useState } from 'react';
|
|||
import { useResponse } from '@/shared/components/response/ResponseContext'; // Contexto global para gerenciar respostas da API
|
||||
|
||||
// Serviço que busca a lista de tipos de serviço (TServicoTipoIndexService)
|
||||
import TServicoTipoInterface from '../../../../app/(protected)/(cadastros)/cadastros/_interfaces/TServicoTipoInterface';
|
||||
import TServicoTipoIndexInteface from '../../interfaces/TServicoTipo/TServicoTipoIndexInteface';
|
||||
import TServicoTipoInterface from '../../interfaces/TServicoTipo/TServicoTipoInterface';
|
||||
import { TServicoTipoIndexService } from '../../services/TServicoTipo/TServicoTipoIndexService';
|
||||
|
||||
// Interface tipada do tipo de serviço
|
||||
|
|
@ -19,7 +19,7 @@ export const useTServicoTipoReadHook = () => {
|
|||
const [tServicoTipo, setTServicoTipo] = useState<TServicoTipoInterface[]>([]);
|
||||
|
||||
// Função assíncrona que busca os dados dos tipos de serviço
|
||||
const fetchTServicoTipo = async (data: TServicoTipoIndexInteface) => {
|
||||
const fetchTServicoTipo = async (data?: TServicoTipoIndexInteface) => {
|
||||
// Chama o serviço responsável por consultar a API
|
||||
const response = await TServicoTipoIndexService(data);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { useResponse } from '@/shared/components/response/ResponseContext'; // Contexto global para gerenciar respostas da API
|
||||
|
||||
// Interface tipada do tipo de serviço
|
||||
import TServicoTipoInterface from '../../../../app/(protected)/(cadastros)/cadastros/_interfaces/TServicoTipoInterface';
|
||||
import TServicoTipoInterface from '../../interfaces/TServicoTipo/TServicoTipoInterface';
|
||||
|
||||
// Função que remove o tipo de serviço via API
|
||||
import { TServicoTipoRemoveData } from '../../data/TServicoTipo/TServicoTipoRemoveData';
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { useResponse } from '@/shared/components/response/ResponseContext';
|
|||
import { useState } from 'react';
|
||||
|
||||
// Interface tipada do tipo de serviço
|
||||
import TServicoTipoInterface from '../../../../app/(protected)/(cadastros)/cadastros/_interfaces/TServicoTipoInterface';
|
||||
import TServicoTipoInterface from '../../interfaces/TServicoTipo/TServicoTipoInterface';
|
||||
|
||||
// Serviço que salva os dados do tipo de serviço
|
||||
import { TServicoTipoSaveService } from '../../services/TServicoTipo/TServicoTipoSaveService';
|
||||
|
|
|
|||
|
|
@ -1,25 +1,42 @@
|
|||
'use client';
|
||||
// Importa o hook responsável por gerenciar e exibir respostas globais (sucesso, erro, etc.)
|
||||
import { useMemo, useState } from 'react';
|
||||
|
||||
import { useState } from 'react';
|
||||
|
||||
import TTBReconhecimentoTipoIndexData from '@/packages/administrativo/data/TTBReconhecimentoTipo/TTBReconhecimentoTipoIndexData';
|
||||
import ITTTBReconhecimentoTipo from '@/packages/administrativo/interfaces/TTBREconhecimentoTipo/TTBReconhecimentoTipoInterface';
|
||||
// Importa hooks do React para gerenciamento de estado e memorização de valores
|
||||
|
||||
// Importa a interface que define a estrutura dos dados de "TTBReconhecimentoTipo"
|
||||
import TTBReconhecimentoTipoInterface from '@/packages/administrativo/interfaces/TTBREconhecimentoTipo/TTBReconhecimentoTipoInterface';
|
||||
import { TTBReconhecimentoTipoReadInterface } from '@/packages/administrativo/interfaces/TTBREconhecimentoTipo/TTBReconhecimentoTipoReadInterface';
|
||||
import { TTBReconhecimentoTipoIndexService } from '@/packages/administrativo/services/TTBReconhecimentoTipo/TTBReconhecimentoTipoIndexService';
|
||||
import { useResponse } from '@/shared/components/response/ResponseContext';
|
||||
|
||||
// Importa o serviço responsável por buscar os dados de "TTBReconhecimentoTipo" na API
|
||||
|
||||
// Hook personalizado para leitura (consulta) dos tipos de marcação
|
||||
export const useTTBReconhecimentoTipoReadHook = () => {
|
||||
// Obtém a função que atualiza a resposta global do sistema
|
||||
const { setResponse } = useResponse();
|
||||
|
||||
const [tTBReconhecimentosTipos, setReconhecimenntosTipos] = useState<ITTTBReconhecimentoTipo[]>(
|
||||
[],
|
||||
);
|
||||
// Define o estado local que armazenará a lista de tipos de marcação
|
||||
const [tTBReconhecimentoTipo, setTTBReconhecimentoTipo] = useState<
|
||||
TTBReconhecimentoTipoInterface[]
|
||||
>([]);
|
||||
|
||||
const fetchTTBReconhecimentosTipos = async () => {
|
||||
const response = await TTBReconhecimentoTipoIndexData();
|
||||
// Função responsável por buscar os dados da API e atualizar o estado
|
||||
const fetchTTBReconhecimentoTipo = async (data?: TTBReconhecimentoTipoReadInterface) => {
|
||||
// Executa o serviço que faz a requisição à API
|
||||
const response = await TTBReconhecimentoTipoIndexService(data);
|
||||
|
||||
setReconhecimenntosTipos(response.data);
|
||||
// Atualiza o estado local com os dados retornados
|
||||
setTTBReconhecimentoTipo(response.data);
|
||||
|
||||
// Atualiza o contexto global de resposta (ex: para exibir alertas ou mensagens)
|
||||
setResponse(response);
|
||||
};
|
||||
|
||||
return { tTBReconhecimentosTipos, fetchTTBReconhecimentosTipos };
|
||||
// Retorna os dados e a função de busca, memorizando o valor para evitar recriações desnecessárias
|
||||
return useMemo(
|
||||
() => ({ tTBReconhecimentoTipo, fetchTTBReconhecimentoTipo }),
|
||||
[tTBReconhecimentoTipo, fetchTTBReconhecimentoTipo],
|
||||
);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,15 +1,16 @@
|
|||
// Importa o hook responsável por gerenciar e exibir respostas globais (sucesso, erro, etc.)
|
||||
import { useMemo, useState } from 'react';
|
||||
|
||||
import { useResponse } from '@/shared/components/response/ResponseContext';
|
||||
|
||||
// Importa hooks do React para gerenciamento de estado e memorização de valores
|
||||
import { useMemo, useState } from 'react';
|
||||
|
||||
// Importa a interface que define a estrutura dos dados de "CCaixaServico"
|
||||
import { CCaixaServicoReadInterface } from '../../_interfaces/CCaixaServicoReadInterface';
|
||||
import { CCaixaServicoInterface } from '../../hooks/CCaixaServico/CCaixaServicoInterface';
|
||||
import { CCaixaServicoReadInterface } from '../../hooks/CCaixaServico/CCaixaServicoReadInterface';
|
||||
|
||||
// Importa o serviço responsável por buscar os dados de "CCaixaServico" na API
|
||||
import { CCaixaServicoIndexService } from '../../_services/c_caixa_servico/CCaixaServicoIndexService';
|
||||
import { CCaixaServicoInterface } from '../../_interfaces/CCaixaServicoInterface';
|
||||
import { CCaixaServicoIndexService } from '../../services/CCaixaServico/CCaixaServicoIndexService';
|
||||
|
||||
// Hook personalizado para leitura (consulta) dos tipos de marcação
|
||||
export const useCCaixaServicoReadHook = () => {
|
||||
|
|
@ -1,19 +1,20 @@
|
|||
// Interface que representa a tabela G_EMOLUMENTO
|
||||
export default interface GEmolumentoInterface {
|
||||
emolumento_id?: number;
|
||||
descricao?: string;
|
||||
tipo?: string;
|
||||
sistema_id?: number;
|
||||
selo_grupo_id?: number;
|
||||
reg_averb?: string;
|
||||
pre_definido?: string;
|
||||
situacao?: string;
|
||||
situacao_ri?: string;
|
||||
com_reducao?: string;
|
||||
motivo_reducao?: string;
|
||||
valor_maximo_certidao?: number;
|
||||
tipo_objetivo?: string;
|
||||
modelo_tag?: string;
|
||||
codigo_nota_id?: number;
|
||||
convenio_codhab?: string;
|
||||
item_df?: string;
|
||||
}
|
||||
emolumento_id?: number; // NUMERIC(10,2) - Chave primária
|
||||
descricao?: string; // VARCHAR(260)
|
||||
tipo?: string; // VARCHAR(1)
|
||||
sistema_id?: number; // NUMERIC(10,2)
|
||||
selo_grupo_id?: number; // NUMERIC(10,2)
|
||||
reg_averb?: string; // VARCHAR(1)
|
||||
pre_definido?: string; // VARCHAR(1)
|
||||
situacao?: string; // VARCHAR(1)
|
||||
situacao_ri?: string; // VARCHAR(1)
|
||||
com_reducao?: string; // VARCHAR(1)
|
||||
motivo_reducao?: string; // VARCHAR(120)
|
||||
valor_maximo_certidao?: number; // NUMERIC(14,3)
|
||||
tipo_objetivo?: string; // VARCHAR(3)
|
||||
modelo_tag?: string; // VARCHAR(3)
|
||||
codigo_nota_id?: number; // NUMERIC(10,2)
|
||||
convenio_codhab?: string; // VARCHAR(1)
|
||||
item_df?: string; // VARCHAR(10)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
export interface GEmolumentoReadInterface {
|
||||
sistema_id?: number;
|
||||
urlParams?: object
|
||||
urlParams?: Record<string, string>;
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
export default interface GEmolumentoItemIndexInterface {
|
||||
emolumento_id: number;
|
||||
emolumento_periodo_id?: number;
|
||||
urlParams?: object
|
||||
}
|
||||
|
|
@ -1,31 +1,38 @@
|
|||
// Interface que representa a tabela G_EMOLUMENTO_ITEM
|
||||
export default interface GEmolumentoItemInterface {
|
||||
valor_emolumento?: number,
|
||||
emolumento_item_id?: number,
|
||||
emolumento_id?: number,
|
||||
valor_inicio?: number,
|
||||
valor_fim?: number,
|
||||
valor_taxa_judiciaria?: number,
|
||||
emolumento_periodo_id?: number,
|
||||
codigo?: number,
|
||||
pagina_extra?: number,
|
||||
valor_pagina_extra?: number,
|
||||
valor_outra_taxa1?: number,
|
||||
codigo_selo?: string,
|
||||
valor_fundo_ri?: number,
|
||||
codigo_tabela?: string,
|
||||
selo_grupo_id?: number,
|
||||
codigo_km?: string,
|
||||
emolumento_acresce?: number,
|
||||
taxa_acresce?: number,
|
||||
funcivil_acresce?: number,
|
||||
valor_fracao?: number,
|
||||
valor_por_excedente_emol?: number,
|
||||
valor_por_excedente_tj?: number,
|
||||
valor_por_excedente_fundo?: number,
|
||||
valor_limite_excedente_emol?: number,
|
||||
valor_limite_excedente_tj?: number,
|
||||
valor_limite_excedente_fundo?: number,
|
||||
fundo_selo?: number,
|
||||
distribuicao?: number,
|
||||
vrcext?: number,
|
||||
emolumento_item_id?: number; // PK (opcional em criação)
|
||||
emolumento_id?: number;
|
||||
emolumento_periodo_id?: number;
|
||||
selo_grupo_id?: number;
|
||||
|
||||
codigo?: number;
|
||||
codigo_tabela?: string;
|
||||
codigo_selo?: string;
|
||||
codigo_km?: string;
|
||||
|
||||
valor_emolumento?: number;
|
||||
valor_inicio?: number;
|
||||
valor_fim?: number;
|
||||
valor_taxa_judiciaria?: number;
|
||||
valor_fundo_ri?: number;
|
||||
valor_outra_taxa1?: number;
|
||||
valor_pagina_extra?: number;
|
||||
pagina_extra?: number;
|
||||
|
||||
emolumento_acresce?: number;
|
||||
taxa_acresce?: number;
|
||||
funcivil_acresce?: number;
|
||||
|
||||
valor_fracao?: number;
|
||||
valor_por_excedente_emol?: number;
|
||||
valor_por_excedente_tj?: number;
|
||||
valor_por_excedente_fundo?: number;
|
||||
|
||||
valor_limite_excedente_emol?: number;
|
||||
valor_limite_excedente_tj?: number;
|
||||
valor_limite_excedente_fundo?: number;
|
||||
|
||||
fundo_selo?: number;
|
||||
distribuicao?: number;
|
||||
vrc_ext?: number; // nome coerente com convenção snake_case da base
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { GGramaticaFormValues } from '../../schemas/GGramatica/GGramaticaSchema';
|
||||
import { GGramaticaFormValues } from '@/packages/administrativo/schemas/GGramatica/GGramaticaSchema';
|
||||
|
||||
export interface GGramaticaFormInterface {
|
||||
isOpen: boolean;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
export default interface GUsuarioIndexInterface {
|
||||
urlParams: object
|
||||
urlParams?: Record<string, string>;
|
||||
}
|
||||
|
|
@ -28,4 +28,5 @@ export default interface TPessoaInterface {
|
|||
unidade?: string;
|
||||
numero_end?: string;
|
||||
foto?: string;
|
||||
email?: string;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,8 @@
|
|||
import { TServicoTipoFormValues } from "@/packages/administrativo/schemas/TServicoTipo/TServicoTipoSchema";
|
||||
|
||||
export default interface TServicoTipoFormInterface {
|
||||
isOpen: boolean;
|
||||
data: TServicoTipoFormValues | null;
|
||||
onClose: (item: null, isFormStatus: boolean) => void;
|
||||
onSave: (data: TServicoTipoFormValues) => void;
|
||||
}
|
||||
|
|
@ -1,3 +1,3 @@
|
|||
export default interface TServicoTipoIndexInteface {
|
||||
urlParams: object
|
||||
urlParams?: Record<string, string>;
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
import { ConfirmacaoEnum } from "@/shared/enums/ConfirmacaoEnum";
|
||||
import { SituacoesEnum } from "@/shared/enums/SituacoesEnum";
|
||||
|
||||
export default interface TServicoTipoInterface {
|
||||
servico_tipo_id?: number;
|
||||
descricao?: string;
|
||||
categoria?: string;
|
||||
|
||||
// Controle de flags (S/N)
|
||||
frenteverso?: ConfirmacaoEnum;
|
||||
averbacao?: ConfirmacaoEnum;
|
||||
transferencia_veiculo?: ConfirmacaoEnum;
|
||||
usar_a4?: ConfirmacaoEnum;
|
||||
etiqueta_unica?: ConfirmacaoEnum;
|
||||
selar?: ConfirmacaoEnum;
|
||||
servico_padrao?: ConfirmacaoEnum;
|
||||
valor_fixo?: ConfirmacaoEnum;
|
||||
ato_praticado?: ConfirmacaoEnum;
|
||||
|
||||
// Situação (A/I)
|
||||
situacao?: SituacoesEnum; // 🔹 Tornado opcional para alinhar ao schema
|
||||
|
||||
// Campos numéricos
|
||||
valor?: number;
|
||||
maximo_pessoa?: number;
|
||||
servico_caixa_id?: number;
|
||||
emolumento_id?: number | null;
|
||||
emolumento_obrigatorio?: number | null;
|
||||
|
||||
// Relacionamentos e permissões
|
||||
tipo_item?: string;
|
||||
requer_autorizacao?: ConfirmacaoEnum;
|
||||
requer_biometria?: ConfirmacaoEnum;
|
||||
tipo_pessoa?: string;
|
||||
tb_reconhecimentotipo_id?: number;
|
||||
requer_abonador?: ConfirmacaoEnum;
|
||||
requer_cpf?: ConfirmacaoEnum;
|
||||
|
||||
// Campos auxiliares
|
||||
valor_emolumento?: number;
|
||||
valor_taxa_judiciaria?: number;
|
||||
fundesp_valor?: number;
|
||||
valor_total?: number;
|
||||
etiquetas_carimbos?: string;
|
||||
emolumento?: string;
|
||||
emolumento_auxiliar?: string;
|
||||
}
|
||||
|
|
@ -1,6 +1,11 @@
|
|||
import { ControllerRenderProps } from "react-hook-form";
|
||||
|
||||
import { TServicoPedidoFormValues } from "@/packages/servicos/schemas/TServicoPedido/TServicoPedidoFormSchema";
|
||||
|
||||
/**
|
||||
* Interface para o componente TServicoTipoSelect.
|
||||
* Compatível com formulários que usam TServicoPedidoFormValues.
|
||||
*/
|
||||
export default interface TServicoTipoSelectInterface {
|
||||
field?: {
|
||||
value?: number | string;
|
||||
onChange?: (value: string | number) => void;
|
||||
};
|
||||
field: ControllerRenderProps<TServicoPedidoFormValues, "servico_tipo">;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,7 @@
|
|||
import TServicoTipoInterface from "./TServicoTipoInterface";
|
||||
|
||||
export default interface TServicoTipoTableInterface {
|
||||
data?: TServicoTipoInterface[];
|
||||
onEdit: (item: TServicoTipoInterface, isEditingFormStatus: boolean) => void;
|
||||
onDelete: (item: TServicoTipoInterface, isEditingFormStatus: boolean) => void;
|
||||
}
|
||||
|
|
@ -1,10 +1,7 @@
|
|||
import { SituacoesEnum } from "@/shared/enums/SituacoesEnum";
|
||||
|
||||
export default interface TTBReconhecimentoTipoInterface {
|
||||
tb_reconhecimentotipo_id?: number;
|
||||
descricao: string;
|
||||
situacao: situacaoEnum;
|
||||
}
|
||||
|
||||
export enum situacaoEnum {
|
||||
ATIVO = 'A',
|
||||
INATIVO = 'I',
|
||||
situacao: SituacoesEnum;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
export interface TTBReconhecimentoTipoReadInterface {
|
||||
tb_reconhecimentotipo_id?: number;
|
||||
descricao?: string;
|
||||
urlParams?: Record<string, string>;
|
||||
}
|
||||
|
|
@ -35,7 +35,7 @@ export const GEmolumentoItemSchema = z.object({
|
|||
|
||||
fundo_selo: z.coerce.number().min(0).optional(),
|
||||
distribuicao: z.coerce.number().min(0).optional(),
|
||||
vrcext: z.coerce.number().min(0).optional(),
|
||||
vrc_ext: z.coerce.number().min(0).optional(), // corrigido: mesmo nome da interface
|
||||
});
|
||||
|
||||
export type GEmolumentoItemFormValues = z.infer<typeof GEmolumentoItemSchema>;
|
||||
export type GEmolumentoItemFormValues = z.infer<typeof GEmolumentoItemSchema>;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,57 @@
|
|||
import { z } from "zod";
|
||||
|
||||
import { ConfirmacaoEnum } from "@/shared/enums/ConfirmacaoEnum";
|
||||
import { SituacoesEnum } from "@/shared/enums/SituacoesEnum";
|
||||
|
||||
// Tipos auxiliares
|
||||
const OneCharString = z.string().max(1).optional();
|
||||
const OptionalNumber = z.number().optional();
|
||||
|
||||
const ConfirmacaoEnumSchema = z.nativeEnum(ConfirmacaoEnum);
|
||||
const SituacoesEnumSchema = z.nativeEnum(SituacoesEnum);
|
||||
|
||||
const OptionalConfirmacaoEnum = ConfirmacaoEnumSchema.optional();
|
||||
const OptionalSituacoesEnum = SituacoesEnumSchema.optional();
|
||||
|
||||
export const TServicoTipoSchema = z.object({
|
||||
servico_tipo_id: OptionalNumber,
|
||||
descricao: z.string().max(60).optional(),
|
||||
categoria: z.string().optional(),
|
||||
|
||||
frenteverso: OptionalConfirmacaoEnum,
|
||||
averbacao: OptionalConfirmacaoEnum,
|
||||
transferencia_veiculo: OptionalConfirmacaoEnum,
|
||||
usar_a4: OptionalConfirmacaoEnum,
|
||||
etiqueta_unica: OptionalConfirmacaoEnum,
|
||||
selar: OptionalConfirmacaoEnum,
|
||||
servico_padrao: OptionalConfirmacaoEnum,
|
||||
valor_fixo: OptionalConfirmacaoEnum,
|
||||
ato_praticado: OptionalConfirmacaoEnum,
|
||||
|
||||
situacao: OptionalSituacoesEnum,
|
||||
|
||||
valor: OptionalNumber,
|
||||
maximo_pessoa: OptionalNumber,
|
||||
servico_caixa_id: OptionalNumber,
|
||||
emolumento_id: z.number().nullable().optional(),
|
||||
emolumento_obrigatorio: z.number().nullable().optional(),
|
||||
|
||||
tipo_item: OneCharString,
|
||||
requer_autorizacao: OptionalConfirmacaoEnum,
|
||||
requer_biometria: OptionalConfirmacaoEnum,
|
||||
tipo_pessoa: OneCharString,
|
||||
tb_reconhecimentotipo_id: OptionalNumber,
|
||||
requer_abonador: OptionalConfirmacaoEnum,
|
||||
requer_cpf: OptionalConfirmacaoEnum,
|
||||
|
||||
valor_emolumento: OptionalNumber,
|
||||
valor_taxa_judiciaria: OptionalNumber,
|
||||
fundesp_valor: OptionalNumber,
|
||||
valor_total: OptionalNumber,
|
||||
|
||||
etiquetas_carimbos: z.string().optional(),
|
||||
emolumento: z.string().optional(),
|
||||
emolumento_auxiliar: z.string().optional(),
|
||||
});
|
||||
|
||||
export type TServicoTipoFormValues = z.infer<typeof TServicoTipoSchema>;
|
||||
|
|
@ -1,9 +1,11 @@
|
|||
import { z } from 'zod';
|
||||
|
||||
import { situacaoEnum } from '../../interfaces/TTBREconhecimentoTipo/TTBReconhecimentoTipoInterface';
|
||||
import { SituacoesEnum } from '@/shared/enums/SituacoesEnum';
|
||||
|
||||
export const TTBReconhecimentoTipoSchema = z.object({
|
||||
tb_reconhecimentotipo_id: z.number().optional(),
|
||||
descricao: z.string().min(1, 'Campo descrição deve ser preenchido'),
|
||||
situacao: z.nativeEnum(situacaoEnum, { message: 'Tipo inválido' }),
|
||||
situacao: z.nativeEnum(SituacoesEnum, { message: 'Tipo inválido' }),
|
||||
});
|
||||
|
||||
export type TTBReconhecimentoTipoFormValues = z.infer<typeof TTBReconhecimentoTipoSchema>;
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
import { withClientErrorHandler } from '@/shared/actions/withClientErrorHandler/withClientErrorHandler';
|
||||
|
||||
// Importa a função que realiza a requisição de listagem dos tipos de marcação
|
||||
import { CCaixaServicoIndexData } from '../../_data/CCaixaServico/CCaixaServicoIndexData';
|
||||
import { CCaixaServicoReadInterface } from '../../_interfaces/CCaixaServicoReadInterface';
|
||||
import { CCaixaServicoIndexData } from '../../data/CCaixaServico/CCaixaServicoIndexData';
|
||||
import { CCaixaServicoReadInterface } from '../../hooks/CCaixaServico/CCaixaServicoReadInterface';
|
||||
|
||||
// Função assíncrona responsável por executar o serviço de listagem de tipos de marcação
|
||||
async function executeCCaixaServicoIndexService(data: CCaixaServicoReadInterface) {
|
||||
|
|
@ -1,11 +1,18 @@
|
|||
// Importa o utilitário responsável por lidar com erros de forma padronizada no cliente
|
||||
import { GEmolumentoIndexData } from '@/packages/administrativo/data/GEmolumento/GEmolumentoIndexData';
|
||||
import { GEmolumentoReadInterface } from '@/packages/administrativo/interfaces/GEmolumento/GEmolumentoReadInterface';
|
||||
import { withClientErrorHandler } from '@/shared/actions/withClientErrorHandler/withClientErrorHandler';
|
||||
|
||||
import { GEmolumentoIndexData } from '../../data/GEmolumento/GEmolumentoIndexData';
|
||||
|
||||
export default async function executeGEmolumentoIndexService() {
|
||||
const response = await GEmolumentoIndexData();
|
||||
// Função assíncrona responsável por executar o serviço de listagem de tipos de marcação
|
||||
async function executeGEmolumentoIndexService(data?: GEmolumentoReadInterface) {
|
||||
|
||||
// Chama a função que realiza a requisição à API e aguarda a resposta
|
||||
const response = await GEmolumentoIndexData(data);
|
||||
|
||||
// Retorna a resposta obtida da requisição
|
||||
return response;
|
||||
}
|
||||
|
||||
// Exporta o serviço encapsulado pelo handler de erro, garantindo tratamento uniforme em caso de falhas
|
||||
export const GEmolumentoIndexService = withClientErrorHandler(executeGEmolumentoIndexService);
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
import { withClientErrorHandler } from '@/shared/actions/withClientErrorHandler/withClientErrorHandler';
|
||||
|
||||
// Importa a função que realiza a requisição de listagem dos tipos de marcação
|
||||
import { GEmolumentoItemValorData } from '../../_data/GEmolumentoItem/GEmolumentoItemValorData';
|
||||
import { GEmolumentoItemReadInterface } from '../../_interfaces/GEmolumentoItemReadInterface';
|
||||
import { GEmolumentoItemValorData } from '../../data/GEmolumentoItem/GEmolumentoItemValorData';
|
||||
import { GEmolumentoItemReadInterface } from '../../interfaces/GEmolumentoItem/GEmolumentoItemReadInterface';
|
||||
|
||||
// Função assíncrona responsável por executar o serviço de listagem de tipos de marcação
|
||||
async function executeGEmolumentoItemValorService(data: GEmolumentoItemReadInterface) {
|
||||
|
|
@ -2,8 +2,8 @@
|
|||
import { withClientErrorHandler } from '@/shared/actions/withClientErrorHandler/withClientErrorHandler';
|
||||
|
||||
// Importa a função que realiza a requisição de listagem dos tipos de marcação
|
||||
import { GMarcacaoTipoIndexData } from '../../_data/GMarcacaoTipo/GMarcacaoTipoIndexData';
|
||||
import { GMarcacaoTipoReadInterface } from '../../_interfaces/GMarcacaoTipoReadInterface';
|
||||
import { GMarcacaoTipoIndexData } from '../../data/GMarcacaoTipo/GMarcacaoTipoIndexData';
|
||||
import { GMarcacaoTipoReadInterface } from '../../interfaces/GMarcacaoTipo/GMarcacaoTipoReadInterface';
|
||||
|
||||
// Função assíncrona responsável por executar o serviço de listagem de tipos de marcação
|
||||
async function executeGMarcacaoTipoIndexService(data: GMarcacaoTipoReadInterface) {
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
'use server';
|
||||
|
||||
import GUsuarioIndexData from '../../data/GUsuario/GUsuarioIndexData';
|
||||
import GUsuarioIndexInterface from '../../interfaces/GUsuario/GusuarioIndexInterface';
|
||||
import GUsuarioIndexInterface from '../../interfaces/GUsuario/GUsuarioIndexInterface';
|
||||
|
||||
export default async function GUsuarioIndex(data: GUsuarioIndexInterface) {
|
||||
const response = await GUsuarioIndexData(data);
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue