feat(TServicoPedido): Implementa a solicitação de certidão na tela de pedido

This commit is contained in:
Keven 2025-12-18 16:11:53 -03:00
parent b5ea5a75a8
commit fd79837fdc
17 changed files with 410 additions and 116 deletions

View file

@ -21,11 +21,11 @@ import {
FormMessage,
} from '@/components/ui/form';
import { Input } from '@/components/ui/input';
import { useGGramaticaFormHook } from '@/packages/administrativo/hooks/GGramatica/useGGramaticaFormHook';
import { GGramaticaFormInterface } from '@/packages/administrativo/interfaces/GGramatica/GGramaticaFormInterface';
import { ResetFormIfData } from '@/shared/actions/form/ResetFormIfData';
import LoadingButton from '@/shared/components/loadingButton/LoadingButton';
import { useGGramaticaFormHook } from '@/packages/administrativo/hooks/GGramatica/useGGramaticaFormHook';
import { GGramaticaFormInterface } from '@/packages/administrativo/interfaces/GGramatica/GGramaticaFormInterface';
/**
* Formulário de cadastro/edição de Natureza

View file

@ -1,4 +1,4 @@
import { WebcamIcon } from 'lucide-react';
import { FileSpreadsheetIcon, WebcamIcon } from 'lucide-react';
import { memo, useCallback, useState } from 'react';
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
@ -13,6 +13,7 @@ import {
} from '@/components/ui/item';
import TPessoaTableFormSubviewInterface from '@/packages/administrativo/interfaces/TPessoa/TPessoaTableFormSubviewInterface';
import TPessoaCartaoForm from '@/packages/servicos/components/TPessoaCartao/TPessoaCartaoForm';
import { FormatDateTime } from '@/shared/actions/dateTime/FormatDateTime';
import GetNameInitials from '@/shared/actions/text/GetNameInitials';
import BiometriaButton from '@/shared/components/biometria/BiometriaButton';
import WebCamDialog from '@/shared/components/webcam/WebCamDialog';
@ -80,47 +81,19 @@ function TPessoaTableFormSubview({
</ItemActions>
</Item>
)}
{data.servico.tipo_item == 'C' && (
{data.ato && (
<Item variant="outline">
<ItemMedia>
<Avatar className="size-10">
<AvatarImage src={``} />
<AvatarFallback>{GetNameInitials(data.pessoa?.nome)}</AvatarFallback>
</Avatar>
<FileSpreadsheetIcon className="size-5" />
</ItemMedia>
<ItemContent>
<ItemTitle>
{data.pessoa?.cpf_cnpj} - {data.pessoa?.nome}
Ato de Origem
</ItemTitle>
<ItemDescription>{data.pessoa?.email || 'Email não informado'}</ItemDescription>
{params
.filter((param) => Number(param.valor) === data?.servico?.servico_tipo_id)
.map((param) => (
<TPessoaCartaoForm form={form} index={item_index} key={param.config_id} />
))}
<ItemDescription>
<b>Pedido:</b> {data.ato.ato_id}, <b>Protocolo:</b> {data.ato.protocolo}, <b>Livro:</b> {data.ato.livro}, <b>Lavratura:</b> {FormatDateTime(data.ato.data_lavratura)}, <b>Folhas</b>: {data.ato.folha_inicial} a {data.ato.folha_final}
</ItemDescription>
</ItemContent>
<ItemActions>
{data?.servico?.requer_biometria === 'S' && (
<BiometriaButton
status={statusBiometria}
onCaptureSuccess={handleCaptureSuccess}
/>
)}
{data?.servico?.requer_biometria && (
<Button
type="button"
size="icon-lg"
variant="outline"
className="cursor-pointer rounded-full"
aria-label="Capturar imagem"
onClick={() => {
setIsWebCamOpenDialog(true);
}}
>
<WebcamIcon />
</Button>
)}
</ItemActions>
</Item>
)}
{isWebCamOpenDialog && (

View file

@ -1,3 +1,4 @@
import { FormatDateTime } from "@/shared/actions/dateTime/FormatDateTime";
export default function TServicoPedidoItemLocalPrepare(data, response) {
@ -15,19 +16,27 @@ export default function TServicoPedidoItemLocalPrepare(data, response) {
fundesp: response.data.valor_fundos ?? 0,
taxa_judiciaria: response.data.taxa_judiciaria ?? 0,
valor_iss: response.data.valor_iss ?? 0,
pessoa_id: data?.pessoa?.pessoa_id ?? null,
};
if (data?.pessoa?.pessoa_id) {
if (data?.pessoa) {
item.pessoa_id = data?.pessoa?.pessoa_id;
item.subview = {
servico: data.servico_tipo,
pessoa: data.pessoa,
};
}
if (data.servico_tipo.tipo_item === 'C') {
if (data?.ato) {
if (data?.ato?.ato_id) {
item.certidao_ato_id = data?.ato?.ato_id;
}
if (!data?.ato?.ato_id) {
item.certidao_ato_antigo = data?.ato?.certidao_ato_antigo;
}
item.desc_complementar = `Prt: ${data?.ato?.protocolo ?? '---'}, Lv: ${data?.ato?.livro ?? '---'}, Lav: ${data?.ato?.data_lavratura ? FormatDateTime(data?.ato?.data_lavratura) : '---'}, Fls: ${data?.ato?.folha_inicial ?? '---'} a ${data?.ato?.folha_final ?? '---'}`
item.subview = {
servico: data.servico_tipo,
ato: data.ato,
};
}

View file

@ -43,7 +43,7 @@ export function TAtoTableFormColumnsDialog(
enableSorting: false,
},
// CPF
// Protocolo
{
accessorKey: 'protocolo',
header: ({ column }) => (
@ -73,6 +73,21 @@ export function TAtoTableFormColumnsDialog(
enableSorting: true,
},
// Livro
{
accessorKey: 'numero_livro',
header: ({ column }) => (
<Button
variant="ghost"
onClick={() => column.toggleSorting(column.getIsSorted() === 'asc')}
>
Livro <ArrowUpDownIcon className="ml-1 h-4 w-4 cursor-pointer" />
</Button>
),
cell: ({ row }) => Number(row.getValue('numero_livro')),
enableSorting: true,
},
// Folha Inicial
{
accessorKey: 'folha_inicial',

View file

@ -3,24 +3,29 @@
import { useEffect, useState } from 'react';
import { Button } from '@/components/ui/button';
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
import {
Dialog,
DialogClose,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
DialogTitle
} from '@/components/ui/dialog';
import { FormControl, FormField, FormItem, FormLabel, FormMessage } from '@/components/ui/form';
import { Input } from '@/components/ui/input';
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
import TPessoaInterface from '@/packages/administrativo/interfaces/TPessoa/TPessoaInterface';
import { useTAtoIndexHook } from '@/packages/servicos/hooks/TAto/useTAtoIndexHook';
import { useTServicoItemPedidoCertidaoFormHook } from '@/packages/servicos/hooks/TServicoItemPedido/useTServicoItemPedidoCertidaoFormHook';
import TAtoTableFormInterface from '@/packages/servicos/interfaces/TAto/TAtoTableFormInterface';
import { FormatDateForm } from '@/shared/actions/dateTime/FormatDateForm';
import ConfirmacaoSelect from '@/shared/components/confirmacao/ConfirmacaoSelect';
import { DataTable } from '@/shared/components/dataTable/DataTable';
import LoadingButton from '@/shared/components/loadingButton/LoadingButton';
import { TAtoTableFormColumnsDialog } from './TAtoTableFormColumnsDialog';
export default function TAtoTableFormDialog({
isOpen,
onClose,
@ -28,14 +33,11 @@ export default function TAtoTableFormDialog({
buttonIsLoading,
}: TAtoTableFormInterface) {
const formCertidao = useTServicoItemPedidoCertidaoFormHook({});
const { tAto, fetchTAto } = useTAtoIndexHook();
const [atos, setAtos] = useState<any>();
const [selectedTPessoa, setSelectedTPessoa] = useState<TPessoaInterface | null>(null);
// Executa o Hook de Acordo com o tipo de pessoa informado
const loadData = async () => {
await fetchTAto();
};
const [selectedAto, setSelectedAto] = useState<TPessoaInterface | null>(null);
// Atualiza a variavel de pessoa quando tiver alteração na variavel de pessoas fisicas
useEffect(() => {
@ -45,10 +47,10 @@ export default function TAtoTableFormDialog({
// Executa o hook correspondente ao tipo de pessoa, sempre que o tipo pessoa mudar
useEffect(() => {
// Dispara o carregamento de informações
loadData();
fetchTAto()
}, []);
const columns = TAtoTableFormColumnsDialog(setSelectedTPessoa);
const columns = TAtoTableFormColumnsDialog(setSelectedAto);
return (
<Dialog
@ -59,40 +61,192 @@ export default function TAtoTableFormDialog({
>
<DialogContent className="max-h-[70vh] w-full max-w-full overflow-auto p-6 sm:max-w-4xl md:max-w-6xl lg:max-w-6xl">
<DialogHeader>
<DialogTitle>Atos</DialogTitle>
<DialogDescription>Busque o Ato desejado</DialogDescription>
<DialogTitle>
Atos
</DialogTitle>
<DialogDescription>
Busque o Ato desejado
</DialogDescription>
</DialogHeader>
<div className="max-h-[50vh] overflow-y-auto">
<DataTable
data={atos}
columns={columns}
filterColumn="nome_completo"
filterPlaceholder="Buscar por nome ou email..."
/>
</div>
{/* Rodapé do Dialog */}
<DialogFooter className="mt-4">
<DialogClose asChild>
<Button
variant="outline"
type="button"
onClick={() => onClose(null, false)}
className="cursor-pointer"
>
Cancelar
</Button>
</DialogClose>
<LoadingButton
text="Selecionar"
textLoading="Aguarde..."
loading={buttonIsLoading}
type="button"
onClick={() => {
onSave(selectedTPessoa);
onClose(null, false);
}}
/>
</DialogFooter>
<Tabs defaultValue="account">
<TabsList>
<TabsTrigger value="account">
Atos do Sistemas
</TabsTrigger>
<TabsTrigger value="password">
Transcrever
</TabsTrigger>
</TabsList>
<TabsContent value="account">
<div className="max-h-[50vh] overflow-y-auto">
<DataTable
data={atos}
columns={columns}
filterColumn="protocolo"
filterPlaceholder="Buscar por nome ou email..."
/>
{/* Rodapé do Dialog */}
<div className="mt-6 flex items-center justify-end gap-3">
<DialogClose asChild>
<Button
variant="outline"
type="button"
onClick={() => onClose(null, false)}
className="cursor-pointer"
>
Cancelar
</Button>
</DialogClose>
<LoadingButton
text="Selecionar"
textLoading="Aguarde..."
loading={buttonIsLoading}
type="button"
onClick={() => {
onSave(selectedAto);
onClose(null, false);
}}
/>
</div>
</div>
</TabsContent>
<TabsContent value="password">
<Card>
<CardHeader>
<CardTitle>
Dados do Ato
</CardTitle>
</CardHeader>
<CardContent>
<div className="grid grid-cols-12 gap-4">
<div className="col-span-12 md:col-span-2">
<FormField
control={formCertidao.control}
name="protocolo"
render={({ field }) => (
<FormItem>
<FormLabel className="font-semibold">Protocolo</FormLabel>
<FormControl>
<Input {...field} type="text" />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
</div>
<div className="col-span-12 md:col-span-2">
<FormField
control={formCertidao.control}
name="livro"
render={({ field }) => (
<FormItem>
<FormLabel className="font-semibold">livro</FormLabel>
<FormControl>
<Input {...field} type="text" />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
</div>
<div className="col-span-12 md:col-span-2">
<FormField
control={formCertidao.control}
name="folha_inicial"
render={({ field }) => (
<FormItem>
<FormLabel className="font-semibold">
Fl. Inicial
</FormLabel>
<FormControl>
<Input {...field} type="text" />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
</div>
<div className="col-span-12 md:col-span-2">
<FormField
control={formCertidao.control}
name="folha_final"
render={({ field }) => (
<FormItem>
<FormLabel className="font-semibold">
Fl. Final
</FormLabel>
<FormControl>
<Input {...field} type="text" />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
</div>
<div className="col-span-12 md:col-span-2">
<FormField
control={formCertidao.control}
name="data_lavratura"
render={({ field }) => (
<FormItem>
<FormLabel className="font-semibold">Lavratura</FormLabel>
<FormControl>
<Input
{...field}
type="text"
value={FormatDateForm(field.value)}
maxLength={14}
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
</div>
<div className="col-span-12 md:col-span-2">
<FormField
control={formCertidao.control}
name="frente_verso"
render={({ field }) => (
<FormItem>
<FormLabel className="font-semibold">Frente/Verso</FormLabel>
<FormControl>
<ConfirmacaoSelect field={field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
{/* Rodapé do Dialog */}
<div className="mt-6 flex items-center justify-end gap-3">
<DialogClose asChild>
<Button
variant="outline"
type="button"
onClick={() => onClose(null, false)}
className="cursor-pointer"
>
Cancelar
</Button>
</DialogClose>
<LoadingButton
text="Salvar"
textLoading="Aguarde..."
loading={buttonIsLoading}
type="button"
onClick={() => {
onSave(formCertidao.getValues());
onClose(null, false);
}}
/>
</div>
</div>
</div>
</CardContent>
</Card>
</TabsContent>
</Tabs>
</DialogContent>
</Dialog>
);

View file

@ -21,6 +21,7 @@ import GEmolumentoServicoSelect from '@/packages/administrativo/components/GEmol
import GUsuarioSelect from '@/packages/administrativo/components/GUsuario/GUsuarioSelect';
import TPessoaTableFormDialog from '@/packages/administrativo/components/TPessoa/TPessoaTableFormDialog';
import TServicoTipoSelect from '@/packages/administrativo/components/TServicoTipo/TServicoTipoSelect';
import TAtoTableFormDialog from '@/packages/servicos/components/TAto/TAtoTableFormDialog';
import { TServicoItemPedidoFormTable } from '@/packages/servicos/components/TServicoItemPedido/TServicoItemPedidoFormTable';
import useTServicoPedidoFormControllerHook from '@/packages/servicos/hooks/TServicoPedido/useTServicoPedidoFormControllerHook';
import { TServicoPedidoFormInterface } from '@/packages/servicos/interfaces/TServicoPedido/TServicoPedidoFormInterface';
@ -34,7 +35,6 @@ import {
} from '@/shared/components/step/stepNavigator';
import TipoPagamentoSelect from '@/shared/components/tipoPagamento/TipoPagamentoSelect';
import TAtoTableFormDialog from '../TAto/TAtoTableFormDialog';
export default function TServicoPedidoForm({ servico_pedido_id }: TServicoPedidoFormInterface) {
@ -84,7 +84,6 @@ export default function TServicoPedidoForm({ servico_pedido_id }: TServicoPedido
<h4 className="text-3xl">Pedido</h4>
</CardTitle>
</CardHeader>
<CardContent className="space-y-4">
<div className="grid grid-cols-12 gap-4">
{/* Escrevente */}
@ -241,7 +240,6 @@ export default function TServicoPedidoForm({ servico_pedido_id }: TServicoPedido
</div>
</CardContent>
</Card>
{/* Seção 3 */}
<Card role="presentation" id="selectPayment" className="scroll-mt-6">
<CardHeader>
@ -445,7 +443,7 @@ export default function TServicoPedidoForm({ servico_pedido_id }: TServicoPedido
<TAtoTableFormDialog
isOpen={tServicoPedidoController.isAtoFormOpen}
onClose={tServicoPedidoController.handleCloseAtoForm}
onSave={tServicoPedidoController.handleAddItemWithPessoa}
onSave={tServicoPedidoController.handleAddItemWithAto}
buttonIsLoading={tServicoPedidoController.isSaving}
/>
)}

View file

@ -1,13 +1,14 @@
import TServicoPedidoInterface from '@/packages/servicos/interfaces/TServicoPedido/TServicoPedidoInterface';
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';
import TServicoPedidoInterface from '../../interfaces/TServicoPedido/TServicoPedidoInterface';
async function executeTServicoPedidoSaveData(
data: TServicoPedidoInterface,
): Promise<ApiResponseInterface> {
// Verifica se existe ID para decidir se é atualização (PUT) ou criação (POST)
const isUpdate = Boolean(data.servico_pedido_id);
@ -18,7 +19,7 @@ async function executeTServicoPedidoSaveData(
return api.send({
method: isUpdate ? Methods.PUT : Methods.POST, // PUT se atualizar, POST se criar
endpoint: `servicos/pedidos/t_servico_pedido/${data.servico_pedido_id || ''}`, // endpoint dinâmico
body: data, // payload enviado para a API
body: data,
});
}

View file

@ -0,0 +1,21 @@
import { zodResolver } from '@hookform/resolvers/zod';
import { useForm } from 'react-hook-form';
import { TServicoPedidoItemCertidaoFormValues, TServicoPedidoItemCertidaoSchema } from '@/packages/servicos/schemas/TServicoItemPedido/TServicoItemPedidoCertidaoSchema';
export function useTServicoItemPedidoCertidaoFormHook(defaults?: Partial<TServicoPedidoItemCertidaoFormValues>) {
return useForm<TServicoPedidoItemCertidaoFormValues>({
resolver: zodResolver(TServicoPedidoItemCertidaoSchema),
defaultValues: {
certidao_ato_antigo: 'S',
livro: '',
protocolo: '',
folha_inicial: 0,
folha_final: 0,
frente_verso: '',
data_lavratura: '',
...defaults,
},
});
}

View file

@ -4,7 +4,7 @@ import { useForm } from 'react-hook-form';
import {
TServicoItemPedidoFormValues,
TServicoItemPedidoSchema,
} from '../../schemas/TServicoItemPedido/TServicoItemPedidoSchema';
} from '@/packages/servicos/schemas/TServicoItemPedido/TServicoItemPedidoSchema';
export function useTServicoItemPedidoFormHook(defaults?: Partial<TServicoItemPedidoFormValues>) {
return useForm<TServicoItemPedidoFormValues>({

View file

@ -11,12 +11,14 @@ import { useTServicoPedidoFormHook } from '@/packages/servicos/hooks/TServicoPed
import { useTServicoPedidoLoadParamsHook } from '@/packages/servicos/hooks/TServicoPedido/useTServicoPedidoLoadParamsHook';
import { useTServicoPedidoSaveHook } from '@/packages/servicos/hooks/TServicoPedido/useTServicoPedidoSaveHook';
import { useTServicoPedidoShowHook } from '@/packages/servicos/hooks/TServicoPedido/useTServicoPedidoShowHook';
import TAtoInterface from '@/packages/servicos/interfaces/TAto/TAtoInterface';
import TServicoPedidoInterface from '@/packages/servicos/interfaces/TServicoPedido/TServicoPedidoInterface';
import { TServicoPedidoFormValues } from '@/packages/servicos/schemas/TServicoPedido/TServicoPedidoFormSchema';
import { useResponse } from '@/shared/components/response/ResponseContext';
import { StepNavigatorRef } from '@/shared/components/step/stepNavigator';
import { SituacoesEnum } from '@/shared/enums/SituacoesEnum';
export default function useTServicoPedidoFormControllerHook(servico_pedido_id?: number) {
const router = useRouter();
@ -135,7 +137,20 @@ export default function useTServicoPedidoFormControllerHook(servico_pedido_id?:
const handleAddItemWithPessoa = useCallback(
async (selectedTPessoa: TPessoaInterface) => {
handleAddItem(selectedTPessoa)
const data = {
type: 1,
data: selectedTPessoa
}
handleAddItem(data)
}, [selectedEmolumento, selectedServicoTipo]);
const handleAddItemWithAto = useCallback(
async (selectedAto: TAtoInterface) => {
const data = {
type: 2,
data: selectedAto
}
handleAddItem(data)
}, [selectedEmolumento, selectedServicoTipo]);
// Controla o formulário de cancelamento de pedido
@ -163,7 +178,7 @@ export default function useTServicoPedidoFormControllerHook(servico_pedido_id?:
}, []);
// Controle de itens
const handleAddItem = useCallback(async (selectedTPessoa?: TPessoaInterface) => {
const handleAddItem = useCallback(async (selectedData?) => {
setIsAdding(true);
@ -173,9 +188,14 @@ export default function useTServicoPedidoFormControllerHook(servico_pedido_id?:
emolumento: selectedEmolumento,
};
// Se existir pessoa, adiciona ao payload
if (selectedTPessoa) {
payload.pessoa = selectedTPessoa;
// Verifica se o dado é do tipo pessoa
if (selectedData?.type === 1) {
payload.pessoa = selectedData.data;
}
// Verifica se o dado é do tipo ato
if (selectedData?.type === 2) {
payload.ato = selectedData.data;
}
// Obtem o resultado da adição do item
@ -368,6 +388,7 @@ export default function useTServicoPedidoFormControllerHook(servico_pedido_id?:
handleClosePessoaForm,
handleCloseAtoForm,
handleAddItemWithPessoa,
handleAddItemWithAto,
handleOpenSaveConfirm,
handleChangeQtd
};

View file

@ -15,6 +15,7 @@ export const useTServicoPedidoSaveHook = () => {
const [isOpen, setIsOpen] = useState(false);
const saveTServicoPedido = async (data: TServicoPedidoInterface) => {
const response = await TServicoPedidoSaveService(data);
// Armazena os dados da resposta

View file

@ -0,0 +1,85 @@
import z from "zod";
export const TAtoSchema = z.object({
ato_id: z.string().optional(),
ato_tipo_id: z.string().optional(),
escrevente_ato_id: z.string().optional(),
escrevente_assina_id: z.string().optional(),
livro_andamento_id: z.string().optional(),
data_abertura: z.string().optional(),
data_lavratura: z.string().optional(),
usuario_id: z.string().optional(),
protocolo: z.string().optional(),
alienacao_data: z.string().optional(),
qualificacao_imovel_id: z.string().optional(),
folha_inicial: z.string().optional(),
folha_final: z.string().optional(),
folha_total: z.string().optional(),
alienacao_forma: z.string().optional(),
grs_numero: z.string().optional(),
texto: z.string().optional(),
texto_finalizacao: z.string().optional(),
natureza_id: z.string().optional(),
valor_pagamento: z.string().optional(),
situacao_ato: z.string().optional(),
texto_imovel_geral: z.string().optional(),
texto_assinatura: z.string().optional(),
cancelado_data: z.string().optional(),
cancelado_motivo: z.string().optional(),
cancelado_observacao: z.string().optional(),
cancelado_usuario_id: z.string().optional(),
data_cancelamento: z.string().optional(),
alienacao_datalavratura: z.string().optional(),
ato_antigo: z.string().optional(),
folha_letra: z.string().optional(),
qtd_imovel: z.string().optional(),
minuta_protegida: z.string().optional(),
havido_marcacao_id: z.string().optional(),
observacao: z.string().optional(),
selo_livro_id: z.string().optional(),
usar_tabela_auxiliar: z.string().optional(),
ato_antigo_ocorrencia: z.string().optional(),
fonte_tamanho: z.string().optional(),
selo_recuo: z.string().optional(),
ato_antigo_protocolo: z.string().optional(),
ato_anterior_origem: z.string().optional(),
ato_anterior_livro: z.string().optional(),
ato_anterior_finicial: z.string().optional(),
ato_anterior_tb_cartorio_id: z.string().optional(),
ato_anterior_outorgante: z.string().optional(),
ato_anterior_observacao: z.string().optional(),
ato_anterior_ato_id: z.string().optional(),
ato_anterior_data: z.string().optional(),
ato_anterior_anotacao_adicional: z.string().optional(),
ato_anterior_ato_tipo_id: z.string().optional(),
ato_anterior_valor_documento: z.string().optional(),
cadastrar_imovel: z.string().optional(),
filho_maior_qtd: z.string().optional(),
filho_maior_descricao: z.string().optional(),
filho_menor_qtd: z.string().optional(),
filho_menor_descricao: z.string().optional(),
casamento_data: z.string().optional(),
casamento_tb_regime_id: z.string().optional(),
ato_anterior_ffinal: z.string().optional(),
resp_filhos_maiores: z.string().optional(),
resp_filhos_menores: z.string().optional(),
censec_naturezalitigio_id: z.string().optional(),
censec_acordo: z.string().optional(),
nlote: z.string().optional(),
especie_pagamento: z.string().optional(),
fora_cartorio: z.string().optional(),
nfse_id: z.string().optional(),
acao: z.string().optional(),
data_protocolo: z.string().optional(),
frente_verso: z.string().optional(),
chave_importacao: z.string().optional(),
lavratura_online: z.string().optional(),
data_prevista_entrega: z.string().optional(),
usuario_id_lavratura: z.string().optional(),
ativo: z.string().optional(),
convalidacao: z.string().optional(),
lado_folha_fim: z.string().optional(),
ato_oneroso: z.string().optional(),
mne: z.string().optional(),
eh_restrito: z.string().optional(),
})

View file

@ -0,0 +1,15 @@
import z from 'zod';
export const TServicoPedidoItemCertidaoSchema = z.object({
certidao_ato_antigo: z.string().optional(),
ato_id: z.number().optional(),
livro: z.string().optional(),
protocolo: z.string().optional(),
folha_inicial: z.number().optional(),
folha_final: z.number().optional(),
frente_verso: z.string().optional(),
data_lavratura: z.string().optional()
})
export type TServicoPedidoItemCertidaoFormValues = z.infer<typeof TServicoPedidoItemCertidaoSchema>;

View file

@ -69,5 +69,4 @@ export const TServicoItemPedidoSchema = z.object({
cartao_data: z.string().optional(),
cartao_selar: z.string().optional(),
});
export type TServicoItemPedidoFormValues = z.infer<typeof TServicoItemPedidoSchema>;
export type TServicoItemPedidoFormValues = z.infer<typeof TServicoItemPedidoSchema>;

View file

@ -2,34 +2,20 @@ import z from 'zod';
export const TServicoPedidoFormSchema = z.object({
servico_pedido_id: z.number().optional(),
escrevente_id: z.number().int().positive('Escrevente é obrigatório.'),
apresentante: z.string().min(1, 'Apresentante é obrigatório.'),
cpfcnpj_apresentante: z.string().min(1, 'CPF/CNPJ do apresentante é obrigatório.'),
selo_pessoa_nome: z.string().min(1, 'Nome da pessoa do selo é obrigatório.'),
selo_pessoa_cpfcnpj: z.string().min(1, 'CPF/CNPJ da pessoa do selo é obrigatório.'),
servico_tipo: z.any().refine((v) => !!v, 'Selecione um serviço.'),
emolumento: z.any().refine((v) => !!v, 'Selecione um emolumento.'),
itens: z.array(z.any()).min(1, 'Adicione ao menos um item ao pedido.'),
pagador_nome: z.string().min(1, 'Nome do requerente é obrigatório.'),
pagador_cpfcnpj: z.string().min(1, 'CPF/CNPJ do requerente é obrigatório.'),
valor_pedido: z.number().nonnegative('Valor do pedido inválido.'),
valor_pago: z.number().nonnegative('Valor pago inválido.'),
tipo_pagamento: z.any().refine((v) => !!v, 'Selecione a forma de pagamento.'),
situacao: z.string().min(1, 'Campo situação deve ser informado'),
itens: z.array(z.any()).min(1, 'Adicione ao menos um item ao pedido.'),
});
export type TServicoPedidoFormValues = z.infer<typeof TServicoPedidoFormSchema>;

View file

@ -1,7 +1,7 @@
import { TServicoPedidoSaveData } from '@/packages/servicos/data/TServicoPedido/TServicoPedidoSaveData';
import TServicoPedidoInterface from '@/packages/servicos/interfaces/TServicoPedido/TServicoPedidoInterface';
import { withClientErrorHandler } from '@/shared/actions/withClientErrorHandler/withClientErrorHandler';
import { TServicoPedidoSaveData } from '../../data/TServicoPedido/TServicoPedidoSaveData';
import TServicoPedidoInterface from '../../interfaces/TServicoPedido/TServicoPedidoInterface';
async function executeTServicoPedidoSaveService(data: TServicoPedidoInterface) {
const response = await TServicoPedidoSaveData(data);

View file

@ -0,0 +1,16 @@
/**
* Remove caracteres não numéricos (Auxiliar)
* Se você tiver essa função exportada em outro lugar, pode importar.
*/
function unmask(value: string): string {
return value.replace(/\D/g, '');
}
export function FormatDateForm(value: string = ''): string {
const digits = unmask(value);
return digits
.slice(0, 8) // Limita a 8 dígitos (ddmmyyyy)
.replace(/^(\d{2})(\d)/, '$1/$2') // Coloca a primeira barra após o dia
.replace(/^(\d{2})\/(\d{2})(\d)/, '$1/$2/$3'); // Coloca a segunda barra após o mês
}