fix(Build): ajuste nos crud de andamento e tipo de reconhecimento para realizar a build da versão
This commit is contained in:
parent
bdf982fe38
commit
477c1cd22a
9 changed files with 37 additions and 23 deletions
|
|
@ -91,6 +91,9 @@ export default function TTBAndamentoServico() {
|
|||
*/
|
||||
const handleDelete = useCallback(async () => {
|
||||
|
||||
// Protege contra null
|
||||
if (!itemToDelete) return;
|
||||
|
||||
// Executa o Hook de remoção
|
||||
await deleteTTBAndamentoServico(itemToDelete);
|
||||
|
||||
|
|
@ -168,5 +171,5 @@ export default function TTBAndamentoServico() {
|
|||
onSave={handleSave}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
);4
|
||||
}
|
||||
|
|
@ -6,8 +6,8 @@ import { Card, CardContent } from "@/components/ui/card";
|
|||
import { PlusIcon } from "lucide-react";
|
||||
|
||||
import Loading from "@/app/_components/loading/loading";
|
||||
import TTBAndamentoServicoTable from "../../_components/t_tb_reconhecimentotipo/TTBReconhecimentoTipoTable";
|
||||
import TTBAndamentoServicoForm from "../../_components/t_tb_reconhecimentotipo/TTBReconhecimentoTipoForm";
|
||||
import TTBReconhecimentoTipoTable from "../../_components/t_tb_reconhecimentotipo/TTBReconhecimentoTipoTable";
|
||||
import TTBReconhecimentoTipoForm from "../../_components/t_tb_reconhecimentotipo/TTBReconhecimentoTipoForm";
|
||||
|
||||
import { useTTBReconhecimentoTipoReadHook } from "../../_hooks/t_tb_reconhecimentotipo/useTTBReconhecimentoTipoReadHook";
|
||||
import { useTTBReconhecimentoTipoSaveHook } from "../../_hooks/t_tb_reconhecimentotipo/useTTBReconhecimentoTipoSaveHook";
|
||||
|
|
@ -17,7 +17,6 @@ import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog";
|
|||
import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDialog";
|
||||
|
||||
import TTBReconhecimentoTipoInterface from "../../_interfaces/TTBReconhecimentoTipoInterface";
|
||||
import TTBReconhecimentoTipoFormProps from "../../_components/t_tb_reconhecimentotipo/TTBReconhecimentoTipoForm";
|
||||
|
||||
export default function TTBAndamentoServico() {
|
||||
|
||||
|
|
@ -93,6 +92,9 @@ export default function TTBAndamentoServico() {
|
|||
*/
|
||||
const handleDelete = useCallback(async () => {
|
||||
|
||||
// Protege contra null
|
||||
if (!itemToDelete) return;
|
||||
|
||||
// Executa o Hook de remoção
|
||||
await deleteTTBReconhecimentoTipo(itemToDelete);
|
||||
|
||||
|
|
@ -142,7 +144,7 @@ export default function TTBAndamentoServico() {
|
|||
{/* Tabela de andamentos */}
|
||||
<Card>
|
||||
<CardContent>
|
||||
<TTBAndamentoServicoTable
|
||||
<TTBReconhecimentoTipoTable
|
||||
data={tTBReconhecimentosTipos}
|
||||
onEdit={handleOpenForm}
|
||||
onDelete={handleConfirmDelete}
|
||||
|
|
@ -163,7 +165,7 @@ export default function TTBAndamentoServico() {
|
|||
/>
|
||||
|
||||
{/* Formulário de criação/edição */}
|
||||
<TTBReconhecimentoTipoFormProps
|
||||
<TTBReconhecimentoTipoForm
|
||||
isOpen={isFormOpen}
|
||||
data={selectedReconhecimentoTipo}
|
||||
onClose={handleCloseForm}
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ export default function TTBAndamentoServicoForm({ isOpen, data, onClose, onSave
|
|||
resolver: zodResolver(TTBAndamentoServicoSchema),
|
||||
defaultValues: {
|
||||
descricao: "",
|
||||
tipo: "",
|
||||
tipo: tipoEnum.OUTROS,
|
||||
situacao: "A",
|
||||
usa_email: "I",
|
||||
tb_andamentoservico_id: 0,
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import { Input } from "@/components/ui/input";
|
|||
import { Label } from "@/components/ui/label";
|
||||
|
||||
import { TTBReconhecimentoTipoSchema } from "../../_schemas/TTBReconhecimentoTipoSchema";
|
||||
import { situacaoEnum } from "../../_interfaces/TTBReconhecimentoTipoInterface";
|
||||
|
||||
type FormValues = z.infer<typeof TTBReconhecimentoTipoSchema>;
|
||||
|
||||
|
|
@ -38,14 +39,14 @@ interface TTBReconhecimentoTipoFormProps {
|
|||
onSave: (data: FormValues) => void;
|
||||
}
|
||||
|
||||
export default function TTBReconhecimentoTipoFormProps({ isOpen, data, onClose, onSave }: TTBReconhecimentoTipoFormProps) {
|
||||
export default function TTBReconhecimentoTipoForm({ isOpen, data, 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: "A",
|
||||
situacao: situacaoEnum.ATIVO,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ export const useTTBReconhecimentoTipoReadHook = () => {
|
|||
|
||||
const { setResponse } = useResponse();
|
||||
|
||||
const [tTBReconhecimentosTipos, setReconhecimenntosTipos] = useState<ITTTBReconhecimentoTipo>();
|
||||
const [tTBReconhecimentosTipos, setReconhecimenntosTipos] = useState<ITTTBReconhecimentoTipo[]>([]);
|
||||
|
||||
const fetchTTBReconhecimentosTipos = async () => {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
export default interface TTBAndamentoServicoInteface {
|
||||
tb_andamentoservico_id: number,
|
||||
descricao: null | string,
|
||||
situacao: null | string,
|
||||
tipo: null | tipoEnum,
|
||||
tb_andamentoservico_id?: number,
|
||||
descricao: string,
|
||||
situacao: string,
|
||||
tipo: tipoEnum,
|
||||
usa_email: string
|
||||
}
|
||||
|
||||
export enum tipoEnum {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,12 @@
|
|||
export default interface TTBReconhecimentoTipoInterface{
|
||||
tb_reconhecimentotipo_id: number,
|
||||
export default interface TTBReconhecimentoTipoInterface {
|
||||
tb_reconhecimentotipo_id?: number,
|
||||
descricao: string,
|
||||
situacao: string,
|
||||
situacao: situacaoEnum,
|
||||
}
|
||||
|
||||
export enum situacaoEnum {
|
||||
|
||||
ATIVO = 'A',
|
||||
INATIVO = 'I',
|
||||
|
||||
}
|
||||
|
|
@ -1,11 +1,12 @@
|
|||
import { z } from 'zod';
|
||||
import { tipoEnum } from '../_interfaces/TTBAndamentoServicoInterface';
|
||||
|
||||
export const TTBAndamentoServicoSchema = z.object({
|
||||
|
||||
tb_andamentoservico_id: z.number().optional(),
|
||||
descricao: z.string().min(1, "Descrição Obrigatória"),
|
||||
situacao: z.string().min(1, "Situação Obrigatória"),
|
||||
tipo: z.string().min(1, "Tipo Obrigatória"),
|
||||
tipo: z.nativeEnum(tipoEnum, { message: "Tipo inválido" }),
|
||||
usa_email: z.string().min(1, "Email Obrigatória"),
|
||||
|
||||
});
|
||||
|
|
@ -1,9 +1,8 @@
|
|||
import { z } from 'zod';
|
||||
import { situacaoEnum } from '../_interfaces/TTBReconhecimentoTipoInterface';
|
||||
|
||||
export const TTBReconhecimentoTipoSchema = z.object({
|
||||
tb_reconhecimentotipo_id: z.number(),
|
||||
descricao: z.string().min(1),
|
||||
situacao: z.enum(["A", "I"], {
|
||||
errorMap: () => ({ message: "Situação deve ser 'A' ou 'I'" })
|
||||
}),
|
||||
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" }),
|
||||
});
|
||||
Loading…
Add table
Reference in a new issue