Compare commits
1 commit
| Author | SHA1 | Date | |
|---|---|---|---|
| b57386f6f8 |
15 changed files with 821 additions and 1 deletions
|
|
@ -0,0 +1,163 @@
|
|||
'use client';
|
||||
|
||||
import { useEffect, useState, useCallback } from "react";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
|
||||
import Loading from "@/app/_components/loading/loading";
|
||||
import GTBDocumentoTipoTable from "../../_components/g_tb_documentotipo/GTBDocumentoTipoTable";
|
||||
import GTBDocumentoTipoForm from "../../_components/g_tb_documentotipo/GTBDocumentoTipoForm";
|
||||
|
||||
import { useGTBDocumentoTipoReadHook } from "../../_hooks/g_tb_documentotipo/useGTBDocumentoTipoReadHook";
|
||||
import { useGTBDocumentoTipoRemoveHook } from "../../_hooks/g_tb_documentotipo/useGTBDocumentoTipoRemoveHook";
|
||||
import { useGTBDocumentoTipoSaveHook } from "../../_hooks/g_tb_documentotipo/useGTBDocumentoTipoSaveHook";
|
||||
|
||||
import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog";
|
||||
import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDialog";
|
||||
|
||||
import GTBDocumentoTipoInterface from "../../_interfaces/GTBDocumentoTipoInterface";
|
||||
import Header from "@/app/_components/structure/Header";
|
||||
|
||||
export default function TTBAndamentoServico() {
|
||||
// Hooks para leitura e salvamento
|
||||
const { gTBDocumentoTipo, fetchGTBDocumentoTipo } = useGTBDocumentoTipoReadHook();
|
||||
const { saveGTBDocumentoTipo } = useGTBDocumentoTipoSaveHook();
|
||||
const { removeGTBDocumentoTipo } = useGTBDocumentoTipoRemoveHook();
|
||||
|
||||
// Estados
|
||||
const [selectedAndamento, setSelectedAndamento] = useState<GTBDocumentoTipoInterface | null>(null);
|
||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||
|
||||
// Estado para saber qual item será deletado
|
||||
const [itemToDelete, setItemToDelete] = useState<GTBDocumentoTipoInterface | null>(null);
|
||||
|
||||
/**
|
||||
* Hook do modal de confirmação
|
||||
*/
|
||||
const {
|
||||
isOpen: isConfirmOpen,
|
||||
openDialog: openConfirmDialog,
|
||||
handleConfirm,
|
||||
handleCancel,
|
||||
} = useConfirmDialog();
|
||||
|
||||
/**
|
||||
* Abre o formulário no modo de edição ou criação
|
||||
*/
|
||||
const handleOpenForm = useCallback((data: GTBDocumentoTipoInterface | null) => {
|
||||
setSelectedAndamento(data);
|
||||
setIsFormOpen(true);
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Fecha o formulário e limpa o andamento selecionado
|
||||
*/
|
||||
const handleCloseForm = useCallback(() => {
|
||||
setSelectedAndamento(null);
|
||||
setIsFormOpen(false);
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Salva os dados do formulário
|
||||
*/
|
||||
const handleSave = useCallback(async (formData: GTBDocumentoTipoInterface) => {
|
||||
|
||||
// Aguarda salvar o registro
|
||||
await saveGTBDocumentoTipo(formData);
|
||||
|
||||
// Atualiza a lista de dados
|
||||
fetchGTBDocumentoTipo();
|
||||
|
||||
}, [saveGTBDocumentoTipo, fetchGTBDocumentoTipo, handleCloseForm]);
|
||||
|
||||
/**
|
||||
* Quando o usuário clica em "remover" na tabela
|
||||
*/
|
||||
const handleConfirmDelete = useCallback((item: GTBDocumentoTipoInterface) => {
|
||||
|
||||
// Define o item atual para remoção
|
||||
setItemToDelete(item);
|
||||
|
||||
// Abre o modal de confirmação
|
||||
openConfirmDialog();
|
||||
|
||||
}, [openConfirmDialog]);
|
||||
|
||||
/**
|
||||
* Executa a exclusão de fato quando o usuário confirma
|
||||
*/
|
||||
const handleDelete = useCallback(async () => {
|
||||
|
||||
// Protege contra null
|
||||
if (!itemToDelete) return;
|
||||
|
||||
// Executa o Hook de remoção
|
||||
await removeGTBDocumentoTipo(itemToDelete);
|
||||
|
||||
// Atualiza a lista
|
||||
await fetchGTBDocumentoTipo();
|
||||
|
||||
// Limpa o item selecionado
|
||||
setItemToDelete(null);
|
||||
|
||||
// Fecha o modal
|
||||
handleCancel();
|
||||
|
||||
}, [itemToDelete, fetchGTBDocumentoTipo, handleCancel]);
|
||||
|
||||
/**
|
||||
* Busca inicial dos dados
|
||||
*/
|
||||
useEffect(() => {
|
||||
fetchGTBDocumentoTipo();
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Tela de loading enquanto carrega os dados
|
||||
*/
|
||||
if (!gTBDocumentoTipo) {
|
||||
return <Loading type={2} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
{/* Cabeçalho */}
|
||||
<Header
|
||||
title={"Tipos de Documentos"}
|
||||
description={"Gerenciamento de Tipo de Documentos"}
|
||||
buttonText={"Novo Tipo"}
|
||||
buttonAction={() => { handleOpenForm(null) }}
|
||||
/>
|
||||
|
||||
{/* Tabela de andamentos */}
|
||||
<Card>
|
||||
<CardContent>
|
||||
<GTBDocumentoTipoTable
|
||||
data={gTBDocumentoTipo}
|
||||
onEdit={handleOpenForm}
|
||||
onDelete={handleConfirmDelete}
|
||||
/>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Modal de confirmação */}
|
||||
<ConfirmDialog
|
||||
isOpen={isConfirmOpen}
|
||||
title="Confirmar exclusão"
|
||||
description="Atenção"
|
||||
message={`Deseja realmente excluir o tipo de documento "${itemToDelete?.descricao}"?`}
|
||||
confirmText="Sim, excluir"
|
||||
cancelText="Cancelar"
|
||||
onConfirm={handleDelete}
|
||||
onCancel={handleCancel}
|
||||
/>
|
||||
|
||||
{/* Formulário de criação/edição */}
|
||||
<GTBDocumentoTipoForm
|
||||
isOpen={isFormOpen}
|
||||
data={selectedAndamento}
|
||||
onClose={handleCloseForm}
|
||||
onSave={handleSave}
|
||||
/>
|
||||
</div>
|
||||
); 4
|
||||
}
|
||||
|
|
@ -0,0 +1,133 @@
|
|||
'use client';
|
||||
|
||||
import z from "zod";
|
||||
import { useEffect } from "react";
|
||||
import { useForm, Controller } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Checkbox } from "@/components/ui/checkbox";
|
||||
import {
|
||||
Dialog,
|
||||
DialogClose,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle
|
||||
} from "@/components/ui/dialog";
|
||||
import {
|
||||
Form,
|
||||
FormControl,
|
||||
FormField,
|
||||
FormItem,
|
||||
FormLabel,
|
||||
FormMessage
|
||||
} from "@/components/ui/form";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
|
||||
import { GTBDocumentoTipoSchema } from "../../_schemas/GTBDocumentoTipoSchema";
|
||||
|
||||
type FormValues = z.infer<typeof GTBDocumentoTipoSchema>;
|
||||
|
||||
interface GTBDocumentoTipoFormProps {
|
||||
isOpen: boolean;
|
||||
data: FormValues | null;
|
||||
onClose: (item: null, isFormStatus: boolean) => void;
|
||||
onSave: (data: FormValues) => void;
|
||||
}
|
||||
|
||||
export default function GTBProfissaoForm({ isOpen, data, onClose, onSave }: GTBDocumentoTipoFormProps) {
|
||||
// Inicializa o react-hook-form com schema zod
|
||||
const form = useForm<FormValues>({
|
||||
resolver: zodResolver(GTBDocumentoTipoSchema),
|
||||
defaultValues: {
|
||||
tb_documentotipo_id: 0,
|
||||
descricao: '',
|
||||
texto: '',
|
||||
situacao: '',
|
||||
possui_numeracao: '',
|
||||
orgao_padrao: '',
|
||||
descricao_simplificada: '',
|
||||
tipo: '',
|
||||
descricao_sinter: '',
|
||||
},
|
||||
});
|
||||
|
||||
// Atualiza o formulário quando recebe dados para edição
|
||||
useEffect(() => {
|
||||
if (data) form.reset(data);
|
||||
}, [data, form]);
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
open={isOpen}
|
||||
onOpenChange={(open) => {
|
||||
if (!open) onClose(null, false);
|
||||
}}
|
||||
>
|
||||
<DialogContent className="sm:max-w-[425px]">
|
||||
|
||||
<DialogHeader>
|
||||
<DialogTitle>
|
||||
Profissões
|
||||
</DialogTitle>
|
||||
<DialogDescription>
|
||||
Controle de profissões
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
|
||||
<Form {...form}>
|
||||
<form onSubmit={form.handleSubmit(onSave)} className="space-y-6">
|
||||
|
||||
{/* Descrição */}
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="descricao"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Descrição</FormLabel>
|
||||
<FormControl>
|
||||
<Input type="text" {...field} placeholder="Digite a descrição" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
{/* Situação */}
|
||||
<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>
|
||||
)}
|
||||
/>
|
||||
|
||||
{/* Rodapé do Dialog */}
|
||||
<DialogFooter className="mt-4">
|
||||
<DialogClose asChild>
|
||||
<Button variant="outline" type="button" onClick={() => onClose(null, false)} className="cursor-pointer">
|
||||
Cancelar
|
||||
</Button>
|
||||
</DialogClose>
|
||||
<Button type="submit" className="cursor-pointer">
|
||||
Salvar
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
|
||||
{/* Campo oculto */}
|
||||
<input type="hidden" {...form.register("tb_documentotipo_id")} />
|
||||
</form>
|
||||
</Form>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,127 @@
|
|||
'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 GTBDocumentoTipoInterface from "../../_interfaces/GTBDocumentoTipoInterface";
|
||||
|
||||
interface GTBDocumentoTipoTableProps {
|
||||
data: GTBDocumentoTipoInterface[];
|
||||
onEdit: (item: GTBDocumentoTipoInterface, isEditingFormStatus: boolean) => void;
|
||||
onDelete: (item: GTBDocumentoTipoInterface, isEditingFormStatus: boolean) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renderiza o badge de situação
|
||||
*/
|
||||
function StatusBadge({ situacao }: { situacao: string }) {
|
||||
const isActive = situacao === "A";
|
||||
|
||||
const baseClasses =
|
||||
"text-xs font-medium px-2.5 py-0.5 rounded-sm me-2";
|
||||
|
||||
const activeClasses =
|
||||
"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-300";
|
||||
|
||||
const inactiveClasses =
|
||||
"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300";
|
||||
|
||||
return (
|
||||
<span className={`${baseClasses} ${isActive ? activeClasses : inactiveClasses}`}>
|
||||
{isActive ? "Ativo" : "Inativo"}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
export default function GTBProfissaoTable({
|
||||
data,
|
||||
onEdit,
|
||||
onDelete
|
||||
}: GTBDocumentoTipoTableProps) {
|
||||
return (
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>#</TableHead>
|
||||
<TableHead>Situação</TableHead>
|
||||
<TableHead>CBO</TableHead>
|
||||
<TableHead>Descrição</TableHead>
|
||||
<TableHead className="text-right">Ações</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
|
||||
<TableBody>
|
||||
{data.map((item) => (
|
||||
<TableRow
|
||||
key={item.tb_documentotipo_id}
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<TableCell className="font-medium">
|
||||
{item.tb_documentotipo_id}
|
||||
</TableCell>
|
||||
|
||||
<TableCell>
|
||||
<StatusBadge situacao={item.situacao} />
|
||||
</TableCell>
|
||||
|
||||
<TableCell>
|
||||
{item.descricao}
|
||||
</TableCell>
|
||||
|
||||
<TableCell className="text-right">
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<EllipsisIcon />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
|
||||
<DropdownMenuContent side="left" align="start">
|
||||
<DropdownMenuGroup>
|
||||
<DropdownMenuItem
|
||||
className="cursor-pointer"
|
||||
onSelect={() => onEdit(item, true)}
|
||||
>
|
||||
<PencilIcon className="mr-2 h-4 w-4" />
|
||||
Editar
|
||||
</DropdownMenuItem>
|
||||
|
||||
<DropdownMenuSeparator />
|
||||
|
||||
<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>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,252 @@
|
|||
export default async function GTBDocumentoTipoIndexData() {
|
||||
|
||||
return Promise.resolve({
|
||||
statu: 200,
|
||||
message: 'Sucesso',
|
||||
data: [
|
||||
{
|
||||
tb_documentotipo_id: 1.00,
|
||||
descricao: 'identidade',
|
||||
texto: null,
|
||||
situacao: 'A',
|
||||
possui_numeracao: null,
|
||||
orgao_padrao: null,
|
||||
descricao_simplificada: 'RG',
|
||||
tipo: null,
|
||||
descricao_sinter: null
|
||||
},
|
||||
{
|
||||
tb_documentotipo_id: 3.00,
|
||||
descricao: 'CNH',
|
||||
texto: null,
|
||||
situacao: 'A',
|
||||
possui_numeracao: null,
|
||||
orgao_padrao: 'CNH',
|
||||
descricao_simplificada: 'CNH',
|
||||
tipo: null,
|
||||
descricao_sinter: null
|
||||
},
|
||||
{
|
||||
tb_documentotipo_id: 4.00,
|
||||
descricao: 'CARTEIRA SINDI. TRABALHADORES',
|
||||
texto: null,
|
||||
situacao: 'A',
|
||||
possui_numeracao: null,
|
||||
orgao_padrao: '-',
|
||||
descricao_simplificada: 'TRAB',
|
||||
tipo: null,
|
||||
descricao_sinter: null
|
||||
},
|
||||
{
|
||||
tb_documentotipo_id: 5.00,
|
||||
descricao: 'Certidão de Nascimento nº',
|
||||
texto: null,
|
||||
situacao: 'A',
|
||||
possui_numeracao: null,
|
||||
orgao_padrao: null,
|
||||
descricao_simplificada: 'NAS',
|
||||
tipo: null,
|
||||
descricao_sinter: null
|
||||
},
|
||||
{
|
||||
tb_documentotipo_id: 7.00,
|
||||
descricao: 'CARTEIRA FUNCIONAL',
|
||||
texto: null,
|
||||
situacao: 'A',
|
||||
possui_numeracao: null,
|
||||
orgao_padrao: null,
|
||||
descricao_simplificada: 'CAR.FUNC.',
|
||||
tipo: null,
|
||||
descricao_sinter: null
|
||||
},
|
||||
{
|
||||
tb_documentotipo_id: 8.00,
|
||||
descricao: 'IDENTIDADE DE ESTRANGEIRO',
|
||||
texto: null,
|
||||
situacao: 'A',
|
||||
possui_numeracao: null,
|
||||
orgao_padrao: null,
|
||||
descricao_simplificada: 'IDENTIDADE',
|
||||
tipo: null,
|
||||
descricao_sinter: null
|
||||
},
|
||||
{
|
||||
tb_documentotipo_id: 9.00,
|
||||
descricao: 'CERTIDAO DE NASCIMENTO',
|
||||
texto: null,
|
||||
situacao: 'A',
|
||||
possui_numeracao: null,
|
||||
orgao_padrao: null,
|
||||
descricao_simplificada: 'C. NASCIME',
|
||||
tipo: null,
|
||||
descricao_sinter: null
|
||||
},
|
||||
{
|
||||
tb_documentotipo_id: 10.00,
|
||||
descricao: 'PASSAPORTE',
|
||||
texto: null,
|
||||
situacao: 'A',
|
||||
possui_numeracao: null,
|
||||
orgao_padrao: null,
|
||||
descricao_simplificada: 'PASSAPORTE',
|
||||
tipo: null,
|
||||
descricao_sinter: null
|
||||
},
|
||||
{
|
||||
tb_documentotipo_id: 11.00,
|
||||
descricao: 'RESERVISTA',
|
||||
texto: null,
|
||||
situacao: 'A',
|
||||
possui_numeracao: null,
|
||||
orgao_padrao: null,
|
||||
descricao_simplificada: '123456',
|
||||
tipo: null,
|
||||
descricao_sinter: null
|
||||
},
|
||||
{
|
||||
tb_documentotipo_id: 13.00,
|
||||
descricao: 'CARTEIRA EXERCITO BRASILEIRO',
|
||||
texto: null,
|
||||
situacao: 'A',
|
||||
possui_numeracao: null,
|
||||
orgao_padrao: null,
|
||||
descricao_simplificada: '123456',
|
||||
tipo: null,
|
||||
descricao_sinter: null
|
||||
},
|
||||
{
|
||||
tb_documentotipo_id: 12.00,
|
||||
descricao: 'CARTEIRA MILITAR',
|
||||
texto: null,
|
||||
situacao: 'A',
|
||||
possui_numeracao: null,
|
||||
orgao_padrao: null,
|
||||
descricao_simplificada: '123456',
|
||||
tipo: null,
|
||||
descricao_sinter: null
|
||||
},
|
||||
{
|
||||
tb_documentotipo_id: 14.00,
|
||||
descricao: 'PASSE DO IDOSO',
|
||||
texto: null,
|
||||
situacao: 'A',
|
||||
possui_numeracao: null,
|
||||
orgao_padrao: null,
|
||||
descricao_simplificada: '123456',
|
||||
tipo: null,
|
||||
descricao_sinter: null
|
||||
},
|
||||
{
|
||||
tb_documentotipo_id: 15.00,
|
||||
descricao: 'SIND. TRABALHADORES - CUT',
|
||||
texto: null,
|
||||
situacao: 'A',
|
||||
possui_numeracao: null,
|
||||
orgao_padrao: null,
|
||||
descricao_simplificada: 'CARTEIRA',
|
||||
tipo: null,
|
||||
descricao_sinter: null
|
||||
},
|
||||
{
|
||||
tb_documentotipo_id: 16.00,
|
||||
descricao: 'CARTEIRA DE TRABALHO',
|
||||
texto: null,
|
||||
situacao: 'A',
|
||||
possui_numeracao: null,
|
||||
orgao_padrao: null,
|
||||
descricao_simplificada: '123456',
|
||||
tipo: null,
|
||||
descricao_sinter: null
|
||||
},
|
||||
{
|
||||
tb_documentotipo_id: 17.00,
|
||||
descricao: 'CARTEIRA DO ESTUDANTE',
|
||||
texto: null,
|
||||
situacao: 'A',
|
||||
possui_numeracao: null,
|
||||
orgao_padrao: null,
|
||||
descricao_simplificada: '123456',
|
||||
tipo: null,
|
||||
descricao_sinter: null
|
||||
},
|
||||
{
|
||||
tb_documentotipo_id: 18.00,
|
||||
descricao: 'CARTEIRA PROFISSIONAL',
|
||||
texto: null,
|
||||
situacao: 'A',
|
||||
possui_numeracao: null,
|
||||
orgao_padrao: null,
|
||||
descricao_simplificada: '123456',
|
||||
tipo: null,
|
||||
descricao_sinter: null
|
||||
},
|
||||
{
|
||||
tb_documentotipo_id: 19.00,
|
||||
descricao: 'CÉDULA DE IDENTIDADE',
|
||||
texto: null,
|
||||
situacao: 'A',
|
||||
possui_numeracao: null,
|
||||
orgao_padrao: null,
|
||||
descricao_simplificada: 'C.I.',
|
||||
tipo: null,
|
||||
descricao_sinter: null
|
||||
},
|
||||
{
|
||||
tb_documentotipo_id: 20.00,
|
||||
descricao: 'CERTIDÃO DE CASAMENTO',
|
||||
texto: null,
|
||||
situacao: 'A',
|
||||
possui_numeracao: null,
|
||||
orgao_padrao: '-',
|
||||
descricao_simplificada: 'CC',
|
||||
tipo: null,
|
||||
descricao_sinter: null
|
||||
},
|
||||
{
|
||||
tb_documentotipo_id: 21.00,
|
||||
descricao: 'E-TÍTULO',
|
||||
texto: null,
|
||||
situacao: 'A',
|
||||
possui_numeracao: null,
|
||||
orgao_padrao: null,
|
||||
descricao_simplificada: 'E-TÍTULO',
|
||||
tipo: null,
|
||||
descricao_sinter: null
|
||||
},
|
||||
{
|
||||
tb_documentotipo_id: 22.00,
|
||||
descricao: 'NÃO INFORMADO',
|
||||
texto: null,
|
||||
situacao: 'A',
|
||||
possui_numeracao: null,
|
||||
orgao_padrao: null,
|
||||
descricao_simplificada: 'NINF',
|
||||
tipo: null,
|
||||
descricao_sinter: null
|
||||
},
|
||||
{
|
||||
tb_documentotipo_id: 23.00,
|
||||
descricao: 'NÃO INFORMADO',
|
||||
texto: null,
|
||||
situacao: 'A',
|
||||
possui_numeracao: null,
|
||||
orgao_padrao: null,
|
||||
descricao_simplificada: 'NÃO',
|
||||
tipo: null,
|
||||
descricao_sinter: null
|
||||
},
|
||||
{
|
||||
tb_documentotipo_id: 24.00,
|
||||
descricao: 'CARTEIRA DE IDENTIDADE',
|
||||
texto: null,
|
||||
situacao: 'A',
|
||||
possui_numeracao: null,
|
||||
orgao_padrao: null,
|
||||
descricao_simplificada: 'CARTEIRA',
|
||||
tipo: null,
|
||||
descricao_sinter: null
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
export default async function GTBDocumentoTipoRemoveData() {
|
||||
|
||||
return Promise.resolve({
|
||||
status: 200,
|
||||
message: 'Sucesso'
|
||||
});
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
export default async function GTBDocumentoTipoSaveData() {
|
||||
|
||||
return Promise.resolve({
|
||||
status: 201,
|
||||
message: 'Sucesso'
|
||||
});
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
import { useResponse } from "@/app/_response/ResponseContext"
|
||||
import { useState } from "react";
|
||||
import GTBDocumentoTIpoInterface from "../../_interfaces/GTBDocumentoTipoInterface";
|
||||
import GTBDocumenTipoIndexService from "../../_services/g_tb_documento/GTBDocumentoTipoIndexService";
|
||||
|
||||
export const useGTBDocumentoTipoReadHook = () => {
|
||||
|
||||
const { setResponse } = useResponse();
|
||||
const [gTBDocumentoTipo, setGTBDocumentoTipo] = useState<GTBDocumentoTIpoInterface[]>([]);
|
||||
|
||||
const fetchGTBDocumentoTipo = async () => {
|
||||
|
||||
const response = await GTBDocumenTipoIndexService();
|
||||
|
||||
setGTBDocumentoTipo(response.data);
|
||||
|
||||
setResponse(response);
|
||||
|
||||
}
|
||||
|
||||
return { gTBDocumentoTipo, fetchGTBDocumentoTipo }
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
import { useResponse } from "@/app/_response/ResponseContext"
|
||||
import GTBDocumentoTIpoInterface from "../../_interfaces/GTBDocumentoTipoInterface";
|
||||
import GTBDocumentoTipoRemoveService from "../../_services/g_tb_documento/GTBDocumentoTipoRemoveService";
|
||||
|
||||
export const useGTBDocumentoTipoRemoveHook = () => {
|
||||
|
||||
const { setResponse } = useResponse();
|
||||
|
||||
const removeGTBDocumentoTipo = async (data: GTBDocumentoTIpoInterface) => {
|
||||
|
||||
const response = await GTBDocumentoTipoRemoveService(data);
|
||||
|
||||
setResponse(response);
|
||||
|
||||
}
|
||||
|
||||
return { removeGTBDocumentoTipo }
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
import { useResponse } from "@/app/_response/ResponseContext"
|
||||
import { useState } from "react";
|
||||
import GTBDocumentoTIpoInterface from "../../_interfaces/GTBDocumentoTipoInterface";
|
||||
import GTBDocumentoTipoSaveService from "../../_services/g_tb_documento/GTBDocumentoTipoSaveService";
|
||||
|
||||
export const useGTBDocumentoTipoSaveHook = () => {
|
||||
|
||||
const { setResponse } = useResponse();
|
||||
const [gTBDocumentoTipo, setGTBDocumentoTipo] = useState<GTBDocumentoTIpoInterface | null>(null);
|
||||
// controla se o formulário está aberto ou fechado
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
|
||||
const saveGTBDocumentoTipo = async (data: GTBDocumentoTIpoInterface) => {
|
||||
|
||||
const response = await GTBDocumentoTipoSaveService(data);
|
||||
|
||||
setGTBDocumentoTipo(response.data);
|
||||
|
||||
setResponse(response);
|
||||
|
||||
// Fecha o formulário automaticamente após salvar
|
||||
setIsOpen(false);
|
||||
|
||||
// Retorna os dados imediatamente
|
||||
return response;
|
||||
|
||||
}
|
||||
|
||||
return { gTBDocumentoTipo, saveGTBDocumentoTipo }
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
|
||||
export default interface GTBDocumentoTIpoInterface {
|
||||
tb_documentotipo_id?: number,
|
||||
descricao: string,
|
||||
texto: string,
|
||||
situacao: string,
|
||||
possui_numeracao: string,
|
||||
orgao_padrao: string,
|
||||
descricao_simplificada: string,
|
||||
tipo: string,
|
||||
descricao_sinter: string,
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
import z from "zod";
|
||||
|
||||
export const GTBDocumentoTipoSchema = z.object({
|
||||
tb_documentotipo_id: z.number().optional(),
|
||||
descricao: z.string(),
|
||||
texto: z.string(),
|
||||
situacao: z.string(),
|
||||
possui_numeracao: z.string(),
|
||||
orgao_padrao: z.string(),
|
||||
descricao_simplificada: z.string(),
|
||||
tipo: z.string(),
|
||||
descricao_sinter: z.string(),
|
||||
});
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
import GTBDocumentoTipoIndexData from "../../_data/GTBDocumentoTipo/GTBDocumentoTipoIndexData";
|
||||
|
||||
export default async function GTBDocumenTipoIndexService() {
|
||||
|
||||
const response = GTBDocumentoTipoIndexData();
|
||||
|
||||
return response;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
import GTBDocumentoTipoIndexData from "../../_data/GTBDocumentoTipo/GTBDocumentoTipoIndexData";
|
||||
|
||||
export default async function GTBDocumentoTipoRemoveService() {
|
||||
|
||||
const response = GTBDocumentoTipoIndexData();
|
||||
|
||||
return response;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
import GTBDocumentoTipoIndexData from "../../_data/GTBDocumentoTipo/GTBDocumentoTipoIndexData";
|
||||
|
||||
export default async function GTBDocumentoTipoSaveService() {
|
||||
|
||||
const response = GTBDocumentoTipoIndexData();
|
||||
|
||||
return response;
|
||||
|
||||
}
|
||||
|
|
@ -100,7 +100,11 @@ const data = {
|
|||
{
|
||||
title: "Regimes/Comunhão",
|
||||
url: "/cadastros/regime-comunhao/",
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "Documentos/Tipos",
|
||||
url: "/cadastros/documento-tipo/",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue