From 12a2c62af859a88bab55fc61a3ac03e9ebb14261 Mon Sep 17 00:00:00 2001 From: keven Date: Tue, 9 Sep 2025 15:15:23 -0300 Subject: [PATCH 01/10] [MVPTN-1] feat(Listagem): implementa a listagem de tipos de reconhecimento, atualmente usando dados 'mockados' --- .../reconhecimentos/page.tsx | 91 +++++++++++++++++++ .../TTBReconhecimentoTipoIndexData.ts | 25 +++++ .../useTTBReconhecimentoTipoReadHooks.ts | 26 ++++++ .../_interfaces/ITTTBReconhecimentoTipo.ts | 5 + .../_schemas/TTTBReconhecimentoTipo.ts | 7 ++ src/components/app-sidebar.tsx | 14 +-- 6 files changed, 157 insertions(+), 11 deletions(-) create mode 100644 src/app/(protected)/(cadastros)/cadastros/(t_tb_reconhecimentotipo)/reconhecimentos/page.tsx create mode 100644 src/app/(protected)/(cadastros)/cadastros/_data/TTBReconhecimentoTipo/TTBReconhecimentoTipoIndexData.ts create mode 100644 src/app/(protected)/(cadastros)/cadastros/_hooks/useTTBReconhecimentoTipoReadHooks.ts create mode 100644 src/app/(protected)/(cadastros)/cadastros/_interfaces/ITTTBReconhecimentoTipo.ts create mode 100644 src/app/(protected)/(cadastros)/cadastros/_schemas/TTTBReconhecimentoTipo.ts diff --git a/src/app/(protected)/(cadastros)/cadastros/(t_tb_reconhecimentotipo)/reconhecimentos/page.tsx b/src/app/(protected)/(cadastros)/cadastros/(t_tb_reconhecimentotipo)/reconhecimentos/page.tsx new file mode 100644 index 0000000..1147a6b --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/(t_tb_reconhecimentotipo)/reconhecimentos/page.tsx @@ -0,0 +1,91 @@ +'use client' + +import { Card, CardContent } from "@/components/ui/card"; +import { + Table, + TableBody, + TableCaption, + TableCell, + TableHead, + TableHeader, + TableRow, +} from "@/components/ui/table" +import { useTTBReconhecimentoTipoReadHooks } from "../../_hooks/useTTBReconhecimentoTipoReadHooks"; +import { useEffect } from "react"; +import ITTTBReconhecimentoTipo from '../../_interfaces/ITTTBReconhecimentoTipo' +import Loading from "@/app/_components/loading/loading"; +import { Button } from "@/components/ui/button"; +import Link from "next/link"; + +export default function TTBReconhecimentoTipoPage() { + + const { reconhecimentosTipos, fetchReconhecimentosTipos } = useTTBReconhecimentoTipoReadHooks(); + + useEffect(() => { + fetchReconhecimentosTipos(); + }, []); + + if (!reconhecimentosTipos) return + + return ( + +
+ +
+
+
+ Tipos de Reconhecimentos +
+
+ Gerenciamento de tipos de reconhecimentos +
+
+
+ +
+
+ + + + + + + # + + + Descrição + + + Situação + + Amount + + + + {reconhecimentosTipos.map((reconhecimentosTipos: ITTTBReconhecimentoTipo) => ( + + + {reconhecimentosTipos.tb_reconhecimentotipo_id} + + + {reconhecimentosTipos.descricao} + + + {reconhecimentosTipos.tb_reconhecimentotipo_id} + + $250.00 + + ))} + +
+
+
+
+ + ); + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_data/TTBReconhecimentoTipo/TTBReconhecimentoTipoIndexData.ts b/src/app/(protected)/(cadastros)/cadastros/_data/TTBReconhecimentoTipo/TTBReconhecimentoTipoIndexData.ts new file mode 100644 index 0000000..869a90a --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_data/TTBReconhecimentoTipo/TTBReconhecimentoTipoIndexData.ts @@ -0,0 +1,25 @@ +'use server' + +import API from "@/services/api/Api" +import { Methods } from "@/services/api/enums/ApiMethodEnum"; + +export default async function TTBReconhecimentoTipoIndexData() { + + // const api = new API(); + + // const response = await api.send({ + // 'method': Methods.GET, + // 'endpoint': `cadastros/reconhecimentos` + // }); + + // return response; + + return Promise.resolve({ + data: [ + { tb_reconhecimentotipo_id: 1, descricao: 'SEMELHANÇA', situacao: 'A' }, + { tb_reconhecimentotipo_id: 2, descricao: 'VERDADEIRO', situacao: 'A' }, + { tb_reconhecimentotipo_id: 3, descricao: 'ABONO', situacao: 'A' } + ] + }); + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_hooks/useTTBReconhecimentoTipoReadHooks.ts b/src/app/(protected)/(cadastros)/cadastros/_hooks/useTTBReconhecimentoTipoReadHooks.ts new file mode 100644 index 0000000..e626769 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_hooks/useTTBReconhecimentoTipoReadHooks.ts @@ -0,0 +1,26 @@ +'use client' + +import ITTTBReconhecimentoTipo from '../_interfaces/ITTTBReconhecimentoTipo' +import { useResponse } from "@/app/_response/ResponseContext" +import { useState } from "react"; +import TTBReconhecimentoTipoIndexData from '../_data/TTBReconhecimentoTipo/TTBReconhecimentoTipoIndexData'; + +export const useTTBReconhecimentoTipoReadHooks = () => { + + const { setResponse } = useResponse(); + + const [reconhecimentosTipos, setReconhecimenntosTipos] = useState(); + + const fetchReconhecimentosTipos = async () => { + + const response = await TTBReconhecimentoTipoIndexData(); + + setReconhecimenntosTipos(response.data); + + setResponse(response); + + } + + return { reconhecimentosTipos, fetchReconhecimentosTipos } + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_interfaces/ITTTBReconhecimentoTipo.ts b/src/app/(protected)/(cadastros)/cadastros/_interfaces/ITTTBReconhecimentoTipo.ts new file mode 100644 index 0000000..d0f4dda --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_interfaces/ITTTBReconhecimentoTipo.ts @@ -0,0 +1,5 @@ +export default interface ITTTBReconhecimentoTipo{ + tb_reconhecimentotipo_id: number, + descricao: string, + situacao: string, +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_schemas/TTTBReconhecimentoTipo.ts b/src/app/(protected)/(cadastros)/cadastros/_schemas/TTTBReconhecimentoTipo.ts new file mode 100644 index 0000000..18d493e --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_schemas/TTTBReconhecimentoTipo.ts @@ -0,0 +1,7 @@ +import { z } from 'zod'; + +export const TTBReconhecimentoTipoSchema = z.object({ + tb_reconhecimentotipo_id: z.number(), + descricao: z.string().min(1), + situacao: z.string().min(1), +}); \ No newline at end of file diff --git a/src/components/app-sidebar.tsx b/src/components/app-sidebar.tsx index 0e30057..0f56829 100644 --- a/src/components/app-sidebar.tsx +++ b/src/components/app-sidebar.tsx @@ -64,21 +64,13 @@ const data = { ], }, { - title: "Models", + title: "Cadastros", url: "#", icon: Bot, items: [ { - title: "Genesis", - url: "#", - }, - { - title: "Explorer", - url: "#", - }, - { - title: "Quantum", - url: "#", + title: "Reconhecimentos", + url: "/cadastros/reconhecimentos/", }, ], }, From 02ae936c879c49c8f1334765db35d345c2f27ab3 Mon Sep 17 00:00:00 2001 From: keven Date: Wed, 10 Sep 2025 16:59:00 -0300 Subject: [PATCH 02/10] =?UTF-8?q?[MVPTN]=20feat(dialog):=20Implementado=20?= =?UTF-8?q?formul=C3=A1rio=20em=20dialog=20e=20confirma=C3=A7=C3=A3o=20de?= =?UTF-8?q?=20exclus=C3=A3o=20de=20registro?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 75 +++++ package.json | 2 + .../reconhecimentos/page.tsx | 276 +++++++++++++++--- .../TTBReconhecimentoTipoSaveData.ts | 14 + .../useTTBReconhecimentoTipoReadHooks.ts | 8 +- .../useTTBReconhecimentoTipoSaveHooks.ts | 29 ++ .../_schemas/TTTBReconhecimentoTipo.ts | 4 +- src/components/ui/alert-dialog.tsx | 157 ++++++++++ src/components/ui/checkbox.tsx | 32 ++ src/components/ui/dialog.tsx | 143 +++++++++ 10 files changed, 699 insertions(+), 41 deletions(-) create mode 100644 src/app/(protected)/(cadastros)/cadastros/_data/TTBReconhecimentoTipo/TTBReconhecimentoTipoSaveData.ts create mode 100644 src/app/(protected)/(cadastros)/cadastros/_hooks/useTTBReconhecimentoTipoSaveHooks.ts create mode 100644 src/components/ui/alert-dialog.tsx create mode 100644 src/components/ui/checkbox.tsx create mode 100644 src/components/ui/dialog.tsx diff --git a/package-lock.json b/package-lock.json index 0f7ae39..10555ab 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,9 @@ "version": "0.1.0", "dependencies": { "@hookform/resolvers": "^5.2.1", + "@radix-ui/react-alert-dialog": "^1.1.15", "@radix-ui/react-avatar": "^1.1.10", + "@radix-ui/react-checkbox": "^1.3.3", "@radix-ui/react-collapsible": "^1.1.12", "@radix-ui/react-dialog": "^1.1.15", "@radix-ui/react-dropdown-menu": "^2.1.16", @@ -736,6 +738,34 @@ "integrity": "sha512-JTF99U/6XIjCBo0wqkU5sK10glYe27MRRsfwoiq5zzOEZLHU3A3KCMa5X/azekYRCJ0HlwI0crAXS/5dEHTzDg==", "license": "MIT" }, + "node_modules/@radix-ui/react-alert-dialog": { + "version": "1.1.15", + "resolved": "https://registry.npmjs.org/@radix-ui/react-alert-dialog/-/react-alert-dialog-1.1.15.tgz", + "integrity": "sha512-oTVLkEw5GpdRe29BqJ0LSDFWI3qu0vR1M0mUkOQWDIUnY/QIkLpgDMWuKxP94c2NAC2LGcgVhG1ImF3jkZ5wXw==", + "license": "MIT", + "dependencies": { + "@radix-ui/primitive": "1.1.3", + "@radix-ui/react-compose-refs": "1.1.2", + "@radix-ui/react-context": "1.1.2", + "@radix-ui/react-dialog": "1.1.15", + "@radix-ui/react-primitive": "2.1.3", + "@radix-ui/react-slot": "1.2.3" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, "node_modules/@radix-ui/react-arrow": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/@radix-ui/react-arrow/-/react-arrow-1.1.7.tgz", @@ -786,6 +816,36 @@ } } }, + "node_modules/@radix-ui/react-checkbox": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/@radix-ui/react-checkbox/-/react-checkbox-1.3.3.tgz", + "integrity": "sha512-wBbpv+NQftHDdG86Qc0pIyXk5IR3tM8Vd0nWLKDcX8nNn4nXFOFwsKuqw2okA/1D/mpaAkmuyndrPJTYDNZtFw==", + "license": "MIT", + "dependencies": { + "@radix-ui/primitive": "1.1.3", + "@radix-ui/react-compose-refs": "1.1.2", + "@radix-ui/react-context": "1.1.2", + "@radix-ui/react-presence": "1.1.5", + "@radix-ui/react-primitive": "2.1.3", + "@radix-ui/react-use-controllable-state": "1.2.2", + "@radix-ui/react-use-previous": "1.1.1", + "@radix-ui/react-use-size": "1.1.1" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, "node_modules/@radix-ui/react-collapsible": { "version": "1.1.12", "resolved": "https://registry.npmjs.org/@radix-ui/react-collapsible/-/react-collapsible-1.1.12.tgz", @@ -1412,6 +1472,21 @@ } } }, + "node_modules/@radix-ui/react-use-previous": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@radix-ui/react-use-previous/-/react-use-previous-1.1.1.tgz", + "integrity": "sha512-2dHfToCj/pzca2Ck724OZ5L0EVrr3eHRNsG/b3xQJLA2hZpVCS99bLAX+hm1IHXDEnzU6by5z/5MIY794/a8NQ==", + "license": "MIT", + "peerDependencies": { + "@types/react": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, "node_modules/@radix-ui/react-use-rect": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/@radix-ui/react-use-rect/-/react-use-rect-1.1.1.tgz", diff --git a/package.json b/package.json index 9ab3d66..22ea23d 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,9 @@ }, "dependencies": { "@hookform/resolvers": "^5.2.1", + "@radix-ui/react-alert-dialog": "^1.1.15", "@radix-ui/react-avatar": "^1.1.10", + "@radix-ui/react-checkbox": "^1.3.3", "@radix-ui/react-collapsible": "^1.1.12", "@radix-ui/react-dialog": "^1.1.15", "@radix-ui/react-dropdown-menu": "^2.1.16", diff --git a/src/app/(protected)/(cadastros)/cadastros/(t_tb_reconhecimentotipo)/reconhecimentos/page.tsx b/src/app/(protected)/(cadastros)/cadastros/(t_tb_reconhecimentotipo)/reconhecimentos/page.tsx index 1147a6b..c944264 100644 --- a/src/app/(protected)/(cadastros)/cadastros/(t_tb_reconhecimentotipo)/reconhecimentos/page.tsx +++ b/src/app/(protected)/(cadastros)/cadastros/(t_tb_reconhecimentotipo)/reconhecimentos/page.tsx @@ -1,37 +1,123 @@ 'use client' -import { Card, CardContent } from "@/components/ui/card"; +import { + AlertDialog, + AlertDialogAction, + AlertDialogCancel, + AlertDialogContent, + AlertDialogDescription, + AlertDialogFooter, + AlertDialogHeader, + AlertDialogTitle, + AlertDialogTrigger, +} from "@/components/ui/alert-dialog" + +import { + Dialog, + DialogClose, + DialogContent, + DialogDescription, + DialogFooter, + DialogHeader, + DialogTitle, + DialogTrigger, +} from "@/components/ui/dialog" + +import { Input } from "@/components/ui/input" +import { Card, CardContent } from "@/components/ui/card" import { Table, TableBody, - TableCaption, TableCell, TableHead, TableHeader, TableRow, } from "@/components/ui/table" -import { useTTBReconhecimentoTipoReadHooks } from "../../_hooks/useTTBReconhecimentoTipoReadHooks"; -import { useEffect } from "react"; -import ITTTBReconhecimentoTipo from '../../_interfaces/ITTTBReconhecimentoTipo' -import Loading from "@/app/_components/loading/loading"; -import { Button } from "@/components/ui/button"; -import Link from "next/link"; +import { useTTBReconhecimentoTipoReadHooks } from "../../_hooks/useTTBReconhecimentoTipoReadHooks" +import { useEffect, useState } from "react" +import ITTTBReconhecimentoTipo from "../../_interfaces/ITTTBReconhecimentoTipo" +import Loading from "@/app/_components/loading/loading" +import { Button } from "@/components/ui/button" +import { useTTBReconhecimentoTipoSaveHooks } from "../../_hooks/useTTBReconhecimentoTipoSaveHooks" +import { Controller, useForm } from "react-hook-form" +import { + Form, + FormControl, + FormField, + FormItem, + FormLabel, + FormMessage, +} from "@/components/ui/form" +import { zodResolver } from "@hookform/resolvers/zod" +import { TTBReconhecimentoTipoSchema } from "../../_schemas/TTTBReconhecimentoTipo" +import z from "zod" +import { Label } from "@/components/ui/label" +import { Checkbox } from "@/components/ui/checkbox" +import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuTrigger } from "@/components/ui/dropdown-menu" +import { DropdownMenuLabel } from "@radix-ui/react-dropdown-menu" +import { EllipsisIcon, PencilIcon, PlusIcon, Trash2 } from "lucide-react" + +type FormValues = z.infer export default function TTBReconhecimentoTipoPage() { + const { reconhecimentosTipos, fetchReconhecimentosTipos, addReconhecimentoTipo } = useTTBReconhecimentoTipoReadHooks() + const { reconhecimentoTipo, saveReconhecimentoTipo } = useTTBReconhecimentoTipoSaveHooks() - const { reconhecimentosTipos, fetchReconhecimentosTipos } = useTTBReconhecimentoTipoReadHooks(); + const [dialogOpen, setDialogOpen] = useState(false); + const [editingItem, setEditingItem] = useState(null); + + const [alertDialogOpen, setAlertDialogOpen] = useState(false); + const [item, setItem] = useState(null); useEffect(() => { - fetchReconhecimentosTipos(); - }, []); + fetchReconhecimentosTipos() + }, []) + + const form = useForm({ + resolver: zodResolver(TTBReconhecimentoTipoSchema), + defaultValues: { + tb_reconhecimentotipo_id: 0, + descricao: "", + situacao: "I", + }, + }) + + async function onSubmit(values: FormValues) { + const saved = await saveReconhecimentoTipo(values); // aguarda o retorno + addReconhecimentoTipo(saved); // adiciona diretamente na lista + + // reinicia o formulário para o estado original + form.reset(); + } + + async function openForm(values: FormValues) { + setEditingItem(values); // guarda os valores do item + setDialogOpen(true); // abre o Dialog + form.reset({ + tb_reconhecimentotipo_id: values.tb_reconhecimentotipo_id, + descricao: values.descricao, + situacao: values.situacao, + }); + + } + + async function handlingConfirmation(visibility : boolean, item: null|any) { + setAlertDialogOpen(visibility); + setItem(item); + } + + const emptyForm: FormValues = { + tb_reconhecimentotipo_id: 0, + descricao: "", + situacao: "I", // padrão Inativo + }; if (!reconhecimentosTipos) return return (
- -
+
Tipos de Reconhecimentos @@ -40,14 +126,14 @@ export default function TTBReconhecimentoTipoPage() { Gerenciamento de tipos de reconhecimentos
+
-
+ @@ -56,36 +142,148 @@ export default function TTBReconhecimentoTipoPage() { # - - Descrição - Situação - Amount + + Descrição + + + - {reconhecimentosTipos.map((reconhecimentosTipos: ITTTBReconhecimentoTipo) => ( - - - {reconhecimentosTipos.tb_reconhecimentotipo_id} - - - {reconhecimentosTipos.descricao} - - - {reconhecimentosTipos.tb_reconhecimentotipo_id} - - $250.00 - - ))} + {reconhecimentosTipos.map( + (item: ITTTBReconhecimentoTipo) => ( + + + {item.tb_reconhecimentotipo_id} + + + {item.situacao === 'A' ? ( + + Ativo + + ) : ( + + Inativo + + )} + + + {item.descricao} + + + + + + + + + openForm(item)}> + Editar + + + handlingConfirmation(true, item)}> + Remover + + + + + + + ) + )}
+ + + {/* Formulário dentro do Dialog */} +
+ + + + + + Tipos de Reconhecimentos + + Tipos de reconhecimentos são usados na tela de balcão + + + ( + + Descrição + + + + + + )} + /> +
+ ( + field.onChange(checked ? "A" : "I")} + /> + )} + /> + +
+ + + + + + + + + +
+ + +
+ + + + + + #{item?.tb_reconhecimentotipo_id} - {item?.descricao} + + + Esta ação não pode ser desfeita. Isso excluirá permanentemente o registro e seus dados dos nossos servidores. + + + + handlingConfirmation(false, null)} className="cursor-pointer"> + Cancelar + + + Continuar + + + + +
- - ); - -} \ No newline at end of file + ) +} diff --git a/src/app/(protected)/(cadastros)/cadastros/_data/TTBReconhecimentoTipo/TTBReconhecimentoTipoSaveData.ts b/src/app/(protected)/(cadastros)/cadastros/_data/TTBReconhecimentoTipo/TTBReconhecimentoTipoSaveData.ts new file mode 100644 index 0000000..daf5964 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_data/TTBReconhecimentoTipo/TTBReconhecimentoTipoSaveData.ts @@ -0,0 +1,14 @@ +import { faker } from "@faker-js/faker" + +export default async function TTBReconhecimentoTipoSaveData(reconhecimentoTipo: any) { + + return Promise.resolve({ + message: 'Dados salvos com sucesso', + data: { + tb_reconhecimentotipo_id: faker.number.int({ min: 1, max: 1000 }), + descricao: reconhecimentoTipo.tb_reconhecimentotipo_id + reconhecimentoTipo.descricao, + situacao: reconhecimentoTipo.situacao + }, + }); + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_hooks/useTTBReconhecimentoTipoReadHooks.ts b/src/app/(protected)/(cadastros)/cadastros/_hooks/useTTBReconhecimentoTipoReadHooks.ts index e626769..fb01797 100644 --- a/src/app/(protected)/(cadastros)/cadastros/_hooks/useTTBReconhecimentoTipoReadHooks.ts +++ b/src/app/(protected)/(cadastros)/cadastros/_hooks/useTTBReconhecimentoTipoReadHooks.ts @@ -21,6 +21,12 @@ export const useTTBReconhecimentoTipoReadHooks = () => { } - return { reconhecimentosTipos, fetchReconhecimentosTipos } + function addReconhecimentoTipo(reconhecimentoTipo: ITTTBReconhecimentoTipo) { + + setReconhecimenntosTipos(prev => [...(prev || []), reconhecimentoTipo]); + + } + + return { reconhecimentosTipos, fetchReconhecimentosTipos, addReconhecimentoTipo } } \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_hooks/useTTBReconhecimentoTipoSaveHooks.ts b/src/app/(protected)/(cadastros)/cadastros/_hooks/useTTBReconhecimentoTipoSaveHooks.ts new file mode 100644 index 0000000..8605a63 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_hooks/useTTBReconhecimentoTipoSaveHooks.ts @@ -0,0 +1,29 @@ +'use client' + +import { useResponse } from "@/app/_response/ResponseContext" +import { useState } from "react"; +import ITTTBReconhecimentoTipo from '../_interfaces/ITTTBReconhecimentoTipo' +import TTBReconhecimentoTipoSaveData from "../_data/TTBReconhecimentoTipo/TTBReconhecimentoTipoSaveData"; + +export const useTTBReconhecimentoTipoSaveHooks = () => { + + const { setResponse } = useResponse(); + + const [reconhecimentoTipo, setReconhcimentoTipo] = useState(); + + const saveReconhecimentoTipo = async (reconhecimentoTipo: ITTTBReconhecimentoTipo) => { + + const response = await TTBReconhecimentoTipoSaveData(reconhecimentoTipo); + + setReconhcimentoTipo(response.data); + + setResponse(response); + + // Retorna os valores de forma imediata + return response.data; + + } + + return { reconhecimentoTipo, saveReconhecimentoTipo } + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_schemas/TTTBReconhecimentoTipo.ts b/src/app/(protected)/(cadastros)/cadastros/_schemas/TTTBReconhecimentoTipo.ts index 18d493e..c8e73dc 100644 --- a/src/app/(protected)/(cadastros)/cadastros/_schemas/TTTBReconhecimentoTipo.ts +++ b/src/app/(protected)/(cadastros)/cadastros/_schemas/TTTBReconhecimentoTipo.ts @@ -3,5 +3,7 @@ import { z } from 'zod'; export const TTBReconhecimentoTipoSchema = z.object({ tb_reconhecimentotipo_id: z.number(), descricao: z.string().min(1), - situacao: z.string().min(1), + situacao: z.enum(["A", "I"], { + errorMap: () => ({ message: "Situação deve ser 'A' ou 'I'" }) + }), }); \ No newline at end of file diff --git a/src/components/ui/alert-dialog.tsx b/src/components/ui/alert-dialog.tsx new file mode 100644 index 0000000..0863e40 --- /dev/null +++ b/src/components/ui/alert-dialog.tsx @@ -0,0 +1,157 @@ +"use client" + +import * as React from "react" +import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog" + +import { cn } from "@/lib/utils" +import { buttonVariants } from "@/components/ui/button" + +function AlertDialog({ + ...props +}: React.ComponentProps) { + return +} + +function AlertDialogTrigger({ + ...props +}: React.ComponentProps) { + return ( + + ) +} + +function AlertDialogPortal({ + ...props +}: React.ComponentProps) { + return ( + + ) +} + +function AlertDialogOverlay({ + className, + ...props +}: React.ComponentProps) { + return ( + + ) +} + +function AlertDialogContent({ + className, + ...props +}: React.ComponentProps) { + return ( + + + + + ) +} + +function AlertDialogHeader({ + className, + ...props +}: React.ComponentProps<"div">) { + return ( +
+ ) +} + +function AlertDialogFooter({ + className, + ...props +}: React.ComponentProps<"div">) { + return ( +
+ ) +} + +function AlertDialogTitle({ + className, + ...props +}: React.ComponentProps) { + return ( + + ) +} + +function AlertDialogDescription({ + className, + ...props +}: React.ComponentProps) { + return ( + + ) +} + +function AlertDialogAction({ + className, + ...props +}: React.ComponentProps) { + return ( + + ) +} + +function AlertDialogCancel({ + className, + ...props +}: React.ComponentProps) { + return ( + + ) +} + +export { + AlertDialog, + AlertDialogPortal, + AlertDialogOverlay, + AlertDialogTrigger, + AlertDialogContent, + AlertDialogHeader, + AlertDialogFooter, + AlertDialogTitle, + AlertDialogDescription, + AlertDialogAction, + AlertDialogCancel, +} diff --git a/src/components/ui/checkbox.tsx b/src/components/ui/checkbox.tsx new file mode 100644 index 0000000..fa0e4b5 --- /dev/null +++ b/src/components/ui/checkbox.tsx @@ -0,0 +1,32 @@ +"use client" + +import * as React from "react" +import * as CheckboxPrimitive from "@radix-ui/react-checkbox" +import { CheckIcon } from "lucide-react" + +import { cn } from "@/lib/utils" + +function Checkbox({ + className, + ...props +}: React.ComponentProps) { + return ( + + + + + + ) +} + +export { Checkbox } diff --git a/src/components/ui/dialog.tsx b/src/components/ui/dialog.tsx new file mode 100644 index 0000000..d9ccec9 --- /dev/null +++ b/src/components/ui/dialog.tsx @@ -0,0 +1,143 @@ +"use client" + +import * as React from "react" +import * as DialogPrimitive from "@radix-ui/react-dialog" +import { XIcon } from "lucide-react" + +import { cn } from "@/lib/utils" + +function Dialog({ + ...props +}: React.ComponentProps) { + return +} + +function DialogTrigger({ + ...props +}: React.ComponentProps) { + return +} + +function DialogPortal({ + ...props +}: React.ComponentProps) { + return +} + +function DialogClose({ + ...props +}: React.ComponentProps) { + return +} + +function DialogOverlay({ + className, + ...props +}: React.ComponentProps) { + return ( + + ) +} + +function DialogContent({ + className, + children, + showCloseButton = true, + ...props +}: React.ComponentProps & { + showCloseButton?: boolean +}) { + return ( + + + + {children} + {showCloseButton && ( + + + Close + + )} + + + ) +} + +function DialogHeader({ className, ...props }: React.ComponentProps<"div">) { + return ( +
+ ) +} + +function DialogFooter({ className, ...props }: React.ComponentProps<"div">) { + return ( +
+ ) +} + +function DialogTitle({ + className, + ...props +}: React.ComponentProps) { + return ( + + ) +} + +function DialogDescription({ + className, + ...props +}: React.ComponentProps) { + return ( + + ) +} + +export { + Dialog, + DialogClose, + DialogContent, + DialogDescription, + DialogFooter, + DialogHeader, + DialogOverlay, + DialogPortal, + DialogTitle, + DialogTrigger, +} From 11aff8e15a3155f190a0913af518243bacf51658 Mon Sep 17 00:00:00 2001 From: keven Date: Thu, 11 Sep 2025 17:13:55 -0300 Subject: [PATCH 03/10] [MVPTN-2] feat(CRUD): CRUD com Mock para gerenciar a tabela t_tb_andamentoservico --- package-lock.json | 88 ++++++++ package.json | 2 + .../andamentos/page.tsx | 93 ++++++++ .../TTBAndamentoServicoAlert.tsx | 38 ++++ .../TTBAndamentoServicoForm.tsx | 150 +++++++++++++ .../TTBAndamentoServicoTable.tsx | 79 +++++++ .../TTBAndamentoServicoIndexData.ts | 132 ++++++++++++ .../TTBAndamentoServicoSaveData.ts | 16 ++ .../useTTBAndamentoServicoReadHook.ts | 33 +++ .../useTTBAndamentoServicoSaveHook.ts | 29 +++ .../TTBAndamentoServicoInterface.ts | 15 ++ .../cadastros/_schemas/TTBAndamentoServico.ts | 11 + src/app/globals.css | 200 ++++++++++++------ src/components/app-sidebar.tsx | 4 + src/components/ui/popover.tsx | 48 +++++ src/components/ui/select.tsx | 185 ++++++++++++++++ 16 files changed, 1057 insertions(+), 66 deletions(-) create mode 100644 src/app/(protected)/(cadastros)/cadastros/(t_tb_andamentoservico)/andamentos/page.tsx create mode 100644 src/app/(protected)/(cadastros)/cadastros/_components/t_tb_andamentoservico/TTBAndamentoServicoAlert.tsx create mode 100644 src/app/(protected)/(cadastros)/cadastros/_components/t_tb_andamentoservico/TTBAndamentoServicoForm.tsx create mode 100644 src/app/(protected)/(cadastros)/cadastros/_components/t_tb_andamentoservico/TTBAndamentoServicoTable.tsx create mode 100644 src/app/(protected)/(cadastros)/cadastros/_data/TTBAndamentoServico/TTBAndamentoServicoIndexData.ts create mode 100644 src/app/(protected)/(cadastros)/cadastros/_data/TTBAndamentoServico/TTBAndamentoServicoSaveData.ts create mode 100644 src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_andamentoservico/useTTBAndamentoServicoReadHook.ts create mode 100644 src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_andamentoservico/useTTBAndamentoServicoSaveHook.ts create mode 100644 src/app/(protected)/(cadastros)/cadastros/_interfaces/TTBAndamentoServicoInterface.ts create mode 100644 src/app/(protected)/(cadastros)/cadastros/_schemas/TTBAndamentoServico.ts create mode 100644 src/components/ui/popover.tsx create mode 100644 src/components/ui/select.tsx diff --git a/package-lock.json b/package-lock.json index 10555ab..db55039 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,6 +16,8 @@ "@radix-ui/react-dialog": "^1.1.15", "@radix-ui/react-dropdown-menu": "^2.1.16", "@radix-ui/react-label": "^2.1.7", + "@radix-ui/react-popover": "^1.1.15", + "@radix-ui/react-select": "^2.2.6", "@radix-ui/react-separator": "^1.1.7", "@radix-ui/react-slot": "^1.2.3", "@radix-ui/react-tooltip": "^1.2.8", @@ -732,6 +734,12 @@ "node": ">= 10" } }, + "node_modules/@radix-ui/number": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@radix-ui/number/-/number-1.1.1.tgz", + "integrity": "sha512-MkKCwxlXTgz6CFoJx3pCwn07GKp36+aZyu/u2Ln2VrA5DcdyCZkASEDBTd8x5whTQQL5CiYf4prXKLcgQdv29g==", + "license": "MIT" + }, "node_modules/@radix-ui/primitive": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/@radix-ui/primitive/-/primitive-1.1.3.tgz", @@ -1160,6 +1168,43 @@ } } }, + "node_modules/@radix-ui/react-popover": { + "version": "1.1.15", + "resolved": "https://registry.npmjs.org/@radix-ui/react-popover/-/react-popover-1.1.15.tgz", + "integrity": "sha512-kr0X2+6Yy/vJzLYJUPCZEc8SfQcf+1COFoAqauJm74umQhta9M7lNJHP7QQS3vkvcGLQUbWpMzwrXYwrYztHKA==", + "license": "MIT", + "dependencies": { + "@radix-ui/primitive": "1.1.3", + "@radix-ui/react-compose-refs": "1.1.2", + "@radix-ui/react-context": "1.1.2", + "@radix-ui/react-dismissable-layer": "1.1.11", + "@radix-ui/react-focus-guards": "1.1.3", + "@radix-ui/react-focus-scope": "1.1.7", + "@radix-ui/react-id": "1.1.1", + "@radix-ui/react-popper": "1.2.8", + "@radix-ui/react-portal": "1.1.9", + "@radix-ui/react-presence": "1.1.5", + "@radix-ui/react-primitive": "2.1.3", + "@radix-ui/react-slot": "1.2.3", + "@radix-ui/react-use-controllable-state": "1.2.2", + "aria-hidden": "^1.2.4", + "react-remove-scroll": "^2.6.3" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, "node_modules/@radix-ui/react-popper": { "version": "1.2.8", "resolved": "https://registry.npmjs.org/@radix-ui/react-popper/-/react-popper-1.2.8.tgz", @@ -1294,6 +1339,49 @@ } } }, + "node_modules/@radix-ui/react-select": { + "version": "2.2.6", + "resolved": "https://registry.npmjs.org/@radix-ui/react-select/-/react-select-2.2.6.tgz", + "integrity": "sha512-I30RydO+bnn2PQztvo25tswPH+wFBjehVGtmagkU78yMdwTwVf12wnAOF+AeP8S2N8xD+5UPbGhkUfPyvT+mwQ==", + "license": "MIT", + "dependencies": { + "@radix-ui/number": "1.1.1", + "@radix-ui/primitive": "1.1.3", + "@radix-ui/react-collection": "1.1.7", + "@radix-ui/react-compose-refs": "1.1.2", + "@radix-ui/react-context": "1.1.2", + "@radix-ui/react-direction": "1.1.1", + "@radix-ui/react-dismissable-layer": "1.1.11", + "@radix-ui/react-focus-guards": "1.1.3", + "@radix-ui/react-focus-scope": "1.1.7", + "@radix-ui/react-id": "1.1.1", + "@radix-ui/react-popper": "1.2.8", + "@radix-ui/react-portal": "1.1.9", + "@radix-ui/react-primitive": "2.1.3", + "@radix-ui/react-slot": "1.2.3", + "@radix-ui/react-use-callback-ref": "1.1.1", + "@radix-ui/react-use-controllable-state": "1.2.2", + "@radix-ui/react-use-layout-effect": "1.1.1", + "@radix-ui/react-use-previous": "1.1.1", + "@radix-ui/react-visually-hidden": "1.2.3", + "aria-hidden": "^1.2.4", + "react-remove-scroll": "^2.6.3" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, "node_modules/@radix-ui/react-separator": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/@radix-ui/react-separator/-/react-separator-1.1.7.tgz", diff --git a/package.json b/package.json index 22ea23d..7d867a7 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,8 @@ "@radix-ui/react-dialog": "^1.1.15", "@radix-ui/react-dropdown-menu": "^2.1.16", "@radix-ui/react-label": "^2.1.7", + "@radix-ui/react-popover": "^1.1.15", + "@radix-ui/react-select": "^2.2.6", "@radix-ui/react-separator": "^1.1.7", "@radix-ui/react-slot": "^1.2.3", "@radix-ui/react-tooltip": "^1.2.8", diff --git a/src/app/(protected)/(cadastros)/cadastros/(t_tb_andamentoservico)/andamentos/page.tsx b/src/app/(protected)/(cadastros)/cadastros/(t_tb_andamentoservico)/andamentos/page.tsx new file mode 100644 index 0000000..8249c7b --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/(t_tb_andamentoservico)/andamentos/page.tsx @@ -0,0 +1,93 @@ +'use client' + +import { Button } from "@/components/ui/button"; +import { Card, CardContent } from "@/components/ui/card"; +import { useEffect, useState } from "react"; +import { useTTBAndamentoServicoReadHook } from "../../_hooks/t_tb_andamentoservico/useTTBAndamentoServicoReadHook"; +import Loading from "@/app/_components/loading/loading"; +import TTBAndamentoServicoInteface, { tipoEnum } from "../../_interfaces/TTBAndamentoServicoInterface"; +import { TTBAndamentoServicoSchema } from "../../_schemas/TTBAndamentoServico"; +import z from "zod"; +import { useTTBAndamentoServicoSaveHook } from "../../_hooks/t_tb_andamentoservico/useTTBAndamentoServicoSaveHook"; +import TTBAndamentoServicoTable from "../../_components/t_tb_andamentoservico/TTBAndamentoServicoTable"; +import TTBAndamentoServicoForm from "../../_components/t_tb_andamentoservico/TTBAndamentoServicoForm"; +import TTBAndamentoServicoAlert from "../../_components/t_tb_andamentoservico/TTBAndamentoServicoAlert"; +import { PlusIcon } from "lucide-react"; + +type FormValues = z.infer + +export default function TTBAndamentoServico() { + + const { tTBAndamentosServicos, fetchTTBAndamentoServico, addTTBAndamentoServico } = useTTBAndamentoServicoReadHook(); + const { tTBAndamentoServico, saveTTBAndamentoServico } = useTTBAndamentoServicoSaveHook(); + + const [dialogOpen, setDialogOpen] = useState(false); + const [alertDialogOpen, setAlertDialogOpen] = useState(false); + const [item, setItem] = useState(null); + + const [formOpen, setFormOpen] = useState(false); + const [editingItem, setEditingItem] = useState(null); + + const [deleteOpen, setDeleteOpen] = useState(false) + const [deleteItem, setDeleteItem] = useState(null) + + const emptyForm: FormValues = { + tb_andamentoservico_id: 0, + descricao: "", + situacao: "I", + tipo: "", + usa_email: "", + }; + + useEffect(() => { + fetchTTBAndamentoServico(); + }, []); + + const handleSave = async (values: FormValues) => { + const saved = await saveTTBAndamentoServico(values); + addTTBAndamentoServico(saved); + setFormOpen(false); + } + + if (!tTBAndamentosServicos) return ; + return ( +
+
+
+
+ Andamentos +
+
+ Gerenciamento de tipos de reconhecimentos +
+
+
+ +
+
+ + + { setEditingItem(item); setFormOpen(true) }} + onDelete={(item) => { setDeleteItem(item); setDeleteOpen(true) }} + /> + + + setFormOpen(false)} + initialData={editingItem || emptyForm} + onSave={handleSave} + /> + < TTBAndamentoServicoAlert + isOpen={deleteOpen} + item={deleteItem} + onClose={() => setDeleteOpen(false)} + onConfirm={() => { setDeleteOpen(false) }} + /> +
+ ); +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_components/t_tb_andamentoservico/TTBAndamentoServicoAlert.tsx b/src/app/(protected)/(cadastros)/cadastros/_components/t_tb_andamentoservico/TTBAndamentoServicoAlert.tsx new file mode 100644 index 0000000..1fc1667 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_components/t_tb_andamentoservico/TTBAndamentoServicoAlert.tsx @@ -0,0 +1,38 @@ +'use client' + +import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle } from "@/components/ui/alert-dialog"; +import TTBAndamentoServicoInteface from "../../_interfaces/TTBAndamentoServicoInterface"; + +interface Props { + isOpen: boolean, + item?: TTBAndamentoServicoInteface | null, + onClose: () => void + onConfirm: () => void +} + +export default function TTBAndamentoServicoAlert({ isOpen, item, onClose, onConfirm }: Props) { + return ( +
+ + + + + #{item?.tb_andamentoservico_id} - {item?.descricao} + + + Esta ação não pode ser desfeita. Isso excluirá permanentemente o registro e seus dados dos nossos servidores. + + + + + Cancelar + + + Continuar + + + + +
+ ); +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_components/t_tb_andamentoservico/TTBAndamentoServicoForm.tsx b/src/app/(protected)/(cadastros)/cadastros/_components/t_tb_andamentoservico/TTBAndamentoServicoForm.tsx new file mode 100644 index 0000000..e2599d5 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_components/t_tb_andamentoservico/TTBAndamentoServicoForm.tsx @@ -0,0 +1,150 @@ +'use client' + +import z from "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 { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"; +import { Controller, useForm } from "react-hook-form"; +import { TTBAndamentoServicoSchema } from "../../_schemas/TTBAndamentoServico"; +import { tipoEnum } from "../../_interfaces/TTBAndamentoServicoInterface"; + +type FormValues = z.infer + +interface Props { + isOpen: boolean + onClose: () => void + initialData?: FormValues + onSave: (data: FormValues) => void +} + +export default function TTBAndamentoServicoForm({ isOpen, onClose, initialData, onSave }: Props) { + + const form = useForm({ + resolver: undefined, + defaultValues: initialData || { tb_andamentoservico_id: 0, descricao: "", situacao: "I" } + }) + + const tipoOptions = Object.values(tipoEnum).map((value) => ({ + value, + // Aqui você pode personalizar o label como quiser + label: + value === "C" ? "Cancelado" : + value === "E" ? "Estornado" : + value === "PT" ? "Protocolado" : + value === "PD" ? "Pedido" : + value === "NC" ? "Não Consta" : + "Outros" + })); + + return ( +
+ +
+ + + + + + Andamentos + + Controle de andamentos de atos + + + ( + + + Descrição + + + + + + + )} + /> + ( + + + Tipo + + + + + )} + /> +
+ ( + field.onChange(checked ? "A" : "I")} + /> + )} + /> + +
+
+ ( + field.onChange(checked ? "A" : "I")} + /> + )} + /> + +
+ + + + + + + + + +
+ + +
+
+ ); +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_components/t_tb_andamentoservico/TTBAndamentoServicoTable.tsx b/src/app/(protected)/(cadastros)/cadastros/_components/t_tb_andamentoservico/TTBAndamentoServicoTable.tsx new file mode 100644 index 0000000..9183f05 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_components/t_tb_andamentoservico/TTBAndamentoServicoTable.tsx @@ -0,0 +1,79 @@ +'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 TTBAndamentoServicoInteface from "../../_interfaces/TTBAndamentoServicoInterface"; + +interface Props { + data: TTBAndamentoServicoInteface[] + onEdit: (item: TTBAndamentoServicoInteface) => void + onDelete: (item: TTBAndamentoServicoInteface) => void +} + +export default function TTBAndamentoServicoTable({ data, onEdit, onDelete }: Props) { + return ( + + + + + # + + + Situação + + + Descrição + + + + + + {data.map( + (item: TTBAndamentoServicoInteface) => ( + + + {item.tb_andamentoservico_id} + + + {item.situacao === 'A' ? ( + + Ativo + + ) : ( + + Inativo + + )} + + + {item.descricao} + + + + + + + + + onEdit(item)}> + Editar + + + onDelete(item)}> + Remover + + + + + + + ) + )} + +
+ ); +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_data/TTBAndamentoServico/TTBAndamentoServicoIndexData.ts b/src/app/(protected)/(cadastros)/cadastros/_data/TTBAndamentoServico/TTBAndamentoServicoIndexData.ts new file mode 100644 index 0000000..b91bb11 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_data/TTBAndamentoServico/TTBAndamentoServicoIndexData.ts @@ -0,0 +1,132 @@ +export default async function TTBAndamentoServicoIndexData() { + return Promise.resolve({ + data: [ + { + tb_andamentoservico_id: 1, + descricao: "Recepção 1", + status: "A", + tipo: "G" + }, + { + tb_andamentoservico_id: 2, + descricao: "Aguardando assinatura da Imobiliária", + status: "A", + tipo: "G" + }, + { + tb_andamentoservico_id: 3, + descricao: "Esc. Impugnada (Falta Itbi, cert. ou documentos)", + status: "A", + tipo: "G" + }, + { + tb_andamentoservico_id: 4, + descricao: "Aguardando Certtb_andamentoservico_idão de Registro", + status: "A", + tipo: "G" + }, + { + tb_andamentoservico_id: 5, + descricao: "Conferencia", + status: "A", + tipo: "G" + }, + { + tb_andamentoservico_id: 16, + descricao: "Mapa", + status: "A", + tipo: "G" + }, + { + tb_andamentoservico_id: 6, + descricao: "Entregue", + status: "A", + tipo: "G" + }, + { + tb_andamentoservico_id: 18, + descricao: "PROTOCOLADO", + status: "A", + tipo: "G" + }, + { + tb_andamentoservico_id: 7, + descricao: "Protocolo", + status: "A", + tipo: "G" + }, + { + tb_andamentoservico_id: 8, + descricao: "Cadastro", + status: "A", + tipo: "G" + }, + { + tb_andamentoservico_id: 9, + descricao: "Registro/Espelho", + status: "A", + tipo: "G" + }, + { + tb_andamentoservico_id: 10, + descricao: "Corrigtb_andamentoservico_ido Pronto", + status: "A", + tipo: "G" + }, + { + tb_andamentoservico_id: 11, + descricao: "Aguardando Cliente", + status: "A", + tipo: "G" + }, + { + tb_andamentoservico_id: 12, + descricao: "Cancelado a pedtb_andamentoservico_ido da parte", + status: "A", + tipo: "C" + }, + { + tb_andamentoservico_id: 13, + descricao: "Cancelado por determinação judicial", + status: "A", + tipo: "C" + }, + { + tb_andamentoservico_id: 14, + descricao: "Capas e Indicador", + status: "A", + tipo: "G" + }, + { + tb_andamentoservico_id: 15, + descricao: "Falta assinatura", + status: "A", + tipo: "G" + }, + { + tb_andamentoservico_id: 17, + descricao: "Impugnado", + status: "A", + tipo: "G" + }, + { + tb_andamentoservico_id: 19, + descricao: "Entregre/sem registro", + status: "A", + tipo: "C" + }, + { + tb_andamentoservico_id: 20, + descricao: "Corrigtb_andamentoservico_ido sem Registro", + status: "A", + tipo: "C" + }, + { + tb_andamentoservico_id: 21, + descricao: "Cancelamento de ofício", + status: "A", + tipo: "C" + } + ] + }); +} diff --git a/src/app/(protected)/(cadastros)/cadastros/_data/TTBAndamentoServico/TTBAndamentoServicoSaveData.ts b/src/app/(protected)/(cadastros)/cadastros/_data/TTBAndamentoServico/TTBAndamentoServicoSaveData.ts new file mode 100644 index 0000000..ab8035d --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_data/TTBAndamentoServico/TTBAndamentoServicoSaveData.ts @@ -0,0 +1,16 @@ +import { faker } from "@faker-js/faker"; + +export default async function name(andamentoServico: any) { + + return Promise.resolve({ + message: 'Dados salvos com sucesso', + data: { + tb_reconhecimentotipo_id: faker.number.int({ min: 1, max: 1000 }), + descricao: andamentoServico.tb_reconhecimentotipo_id + andamentoServico.descricao, + situacao: andamentoServico.situacao, + tipo: andamentoServico.tipo, + usa_email: andamentoServico.usa_email, + }, + }); + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_andamentoservico/useTTBAndamentoServicoReadHook.ts b/src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_andamentoservico/useTTBAndamentoServicoReadHook.ts new file mode 100644 index 0000000..df69730 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_andamentoservico/useTTBAndamentoServicoReadHook.ts @@ -0,0 +1,33 @@ +'use client' + +import { useResponse } from "@/app/_response/ResponseContext" +import { useState } from "react"; +import TTBAndamentoServicoInteface from "../../_interfaces/TTBAndamentoServicoInterface"; +import TTBAndamentoServicoIndexData from "../../_data/TTBAndamentoServico/TTBAndamentoServicoIndexData"; + +export const useTTBAndamentoServicoReadHook = () => { + + const { setResponse } = useResponse(); + + const [tTBAndamentosServicos, setTTBAndamentosServicos] = useState(null); + + const fetchTTBAndamentoServico = async () => { + + const response = await TTBAndamentoServicoIndexData(); + + setTTBAndamentosServicos(response.data); + + // Define os dados do componente de resposta (toast, modal, etc) + setResponse(response); + + } + + function addTTBAndamentoServico(tTTBAndamentoServico: TTBAndamentoServicoInteface) { + + setTTBAndamentosServicos(prev => [...(prev || []), tTTBAndamentoServico]); + + } + + return { tTBAndamentosServicos, fetchTTBAndamentoServico, addTTBAndamentoServico } + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_andamentoservico/useTTBAndamentoServicoSaveHook.ts b/src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_andamentoservico/useTTBAndamentoServicoSaveHook.ts new file mode 100644 index 0000000..b854b0a --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_andamentoservico/useTTBAndamentoServicoSaveHook.ts @@ -0,0 +1,29 @@ +'use client' + +import { useResponse } from "@/app/_response/ResponseContext" +import { use, useState } from "react"; +import TTBAndamentoServicoInteface from "../../_interfaces/TTBAndamentoServicoInterface"; +import TTBReconhecimentoTipoSaveData from "../../_data/TTBReconhecimentoTipo/TTBReconhecimentoTipoSaveData"; + +export const useTTBAndamentoServicoSaveHook = () => { + + const { setResponse } = useResponse(); + + const [tTBAndamentoServico, setTTBAndamentoServico] = useState(); + + const saveTTBAndamentoServico = async (form: TTBAndamentoServicoInteface) => { + + const response = await TTBReconhecimentoTipoSaveData(form); + + setTTBAndamentoServico(response.data); + + setResponse(response); + + // Retorna os valores de forma imediata + return response.data; + + } + + return { tTBAndamentoServico, saveTTBAndamentoServico } + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_interfaces/TTBAndamentoServicoInterface.ts b/src/app/(protected)/(cadastros)/cadastros/_interfaces/TTBAndamentoServicoInterface.ts new file mode 100644 index 0000000..5322010 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_interfaces/TTBAndamentoServicoInterface.ts @@ -0,0 +1,15 @@ +export default interface TTBAndamentoServicoInteface { + tb_andamentoservico_id: number, + descricao: null | string, + situacao: null | string, + tipo: null | tipoEnum, +} + +export enum tipoEnum { + CANCELADO = "C", + ESTORNADO = "E", + PROTOCOLADO = "PT", + PEDIDO = "PD", + NAO_CONSTA = "NC", + OUTROS = "O", +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_schemas/TTBAndamentoServico.ts b/src/app/(protected)/(cadastros)/cadastros/_schemas/TTBAndamentoServico.ts new file mode 100644 index 0000000..af713ff --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_schemas/TTBAndamentoServico.ts @@ -0,0 +1,11 @@ +import { z } from 'zod'; + +export const TTBAndamentoServicoSchema = z.object({ + + tb_andamentoservico_id: z.number(), + descricao: z.string(), + situacao: z.string(), + tipo: z.string(), + usa_email: z.string() + +}); \ No newline at end of file diff --git a/src/app/globals.css b/src/app/globals.css index 7be488e..2b6326b 100644 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -6,8 +6,8 @@ @theme inline { --color-background: var(--background); --color-foreground: var(--foreground); - --font-sans: var(--font-geist-sans); - --font-mono: var(--font-geist-mono); + --font-sans: Inter, sans-serif; + --font-mono: JetBrains Mono, monospace; --color-sidebar-ring: var(--sidebar-ring); --color-sidebar-border: var(--sidebar-border); --color-sidebar-accent-foreground: var(--sidebar-accent-foreground); @@ -41,75 +41,142 @@ --radius-md: calc(var(--radius) - 2px); --radius-lg: var(--radius); --radius-xl: calc(var(--radius) + 4px); + --font-serif: Source Serif 4, serif; + --radius: 0.375rem; + --tracking-tighter: calc(var(--tracking-normal) - 0.05em); + --tracking-tight: calc(var(--tracking-normal) - 0.025em); + --tracking-wide: calc(var(--tracking-normal) + 0.025em); + --tracking-wider: calc(var(--tracking-normal) + 0.05em); + --tracking-widest: calc(var(--tracking-normal) + 0.1em); + --tracking-normal: var(--tracking-normal); + --shadow-2xl: var(--shadow-2xl); + --shadow-xl: var(--shadow-xl); + --shadow-lg: var(--shadow-lg); + --shadow-md: var(--shadow-md); + --shadow: var(--shadow); + --shadow-sm: var(--shadow-sm); + --shadow-xs: var(--shadow-xs); + --shadow-2xs: var(--shadow-2xs); + --spacing: var(--spacing); + --letter-spacing: var(--letter-spacing); + --shadow-offset-y: var(--shadow-offset-y); + --shadow-offset-x: var(--shadow-offset-x); + --shadow-spread: var(--shadow-spread); + --shadow-blur: var(--shadow-blur); + --shadow-opacity: var(--shadow-opacity); + --color-shadow-color: var(--shadow-color); + --color-destructive-foreground: var(--destructive-foreground); } :root { - --radius: 0.625rem; - --background: oklch(1 0 0); - --foreground: oklch(0.145 0 0); - --card: oklch(1 0 0); - --card-foreground: oklch(0.145 0 0); - --popover: oklch(1 0 0); - --popover-foreground: oklch(0.145 0 0); - --primary: oklch(0.205 0 0); - --primary-foreground: oklch(0.985 0 0); - --secondary: oklch(0.97 0 0); - --secondary-foreground: oklch(0.205 0 0); - --muted: oklch(0.97 0 0); - --muted-foreground: oklch(0.556 0 0); - --accent: oklch(0.97 0 0); - --accent-foreground: oklch(0.205 0 0); - --destructive: oklch(0.577 0.245 27.325); - --border: oklch(0.922 0 0); - --input: oklch(0.922 0 0); - --ring: oklch(0.708 0 0); - --chart-1: oklch(0.646 0.222 41.116); - --chart-2: oklch(0.6 0.118 184.704); - --chart-3: oklch(0.398 0.07 227.392); - --chart-4: oklch(0.828 0.189 84.429); - --chart-5: oklch(0.769 0.188 70.08); - --sidebar: oklch(0.985 0 0); - --sidebar-foreground: oklch(0.145 0 0); - --sidebar-primary: oklch(0.205 0 0); - --sidebar-primary-foreground: oklch(0.985 0 0); - --sidebar-accent: oklch(0.97 0 0); - --sidebar-accent-foreground: oklch(0.205 0 0); - --sidebar-border: oklch(0.922 0 0); - --sidebar-ring: oklch(0.708 0 0); + --radius: 0.375rem; + --background: oklch(1.0000 0 0); + --foreground: oklch(0.2686 0 0); + --card: oklch(1.0000 0 0); + --card-foreground: oklch(0.2686 0 0); + --popover: oklch(1.0000 0 0); + --popover-foreground: oklch(0.2686 0 0); + --primary: oklch(0.7686 0.1647 70.0804); + --primary-foreground: oklch(0 0 0); + --secondary: oklch(0.9670 0.0029 264.5419); + --secondary-foreground: oklch(0.4461 0.0263 256.8018); + --muted: oklch(0.9846 0.0017 247.8389); + --muted-foreground: oklch(0.5510 0.0234 264.3637); + --accent: oklch(0.9869 0.0214 95.2774); + --accent-foreground: oklch(0.4732 0.1247 46.2007); + --destructive: oklch(0.6368 0.2078 25.3313); + --border: oklch(0.9276 0.0058 264.5313); + --input: oklch(0.9276 0.0058 264.5313); + --ring: oklch(0.7686 0.1647 70.0804); + --chart-1: oklch(0.7686 0.1647 70.0804); + --chart-2: oklch(0.6658 0.1574 58.3183); + --chart-3: oklch(0.5553 0.1455 48.9975); + --chart-4: oklch(0.4732 0.1247 46.2007); + --chart-5: oklch(0.4137 0.1054 45.9038); + --sidebar: oklch(0.9846 0.0017 247.8389); + --sidebar-foreground: oklch(0.2686 0 0); + --sidebar-primary: oklch(0.7686 0.1647 70.0804); + --sidebar-primary-foreground: oklch(1.0000 0 0); + --sidebar-accent: oklch(0.9869 0.0214 95.2774); + --sidebar-accent-foreground: oklch(0.4732 0.1247 46.2007); + --sidebar-border: oklch(0.9276 0.0058 264.5313); + --sidebar-ring: oklch(0.7686 0.1647 70.0804); + --destructive-foreground: oklch(1.0000 0 0); + --font-sans: Inter, sans-serif; + --font-serif: Source Serif 4, serif; + --font-mono: JetBrains Mono, monospace; + --shadow-color: hsl(0 0% 0%); + --shadow-opacity: 0.1; + --shadow-blur: 8px; + --shadow-spread: -1px; + --shadow-offset-x: 0px; + --shadow-offset-y: 4px; + --letter-spacing: 0em; + --spacing: 0.25rem; + --shadow-2xs: 0px 4px 8px -1px hsl(0 0% 0% / 0.05); + --shadow-xs: 0px 4px 8px -1px hsl(0 0% 0% / 0.05); + --shadow-sm: 0px 4px 8px -1px hsl(0 0% 0% / 0.10), 0px 1px 2px -2px hsl(0 0% 0% / 0.10); + --shadow: 0px 4px 8px -1px hsl(0 0% 0% / 0.10), 0px 1px 2px -2px hsl(0 0% 0% / 0.10); + --shadow-md: 0px 4px 8px -1px hsl(0 0% 0% / 0.10), 0px 2px 4px -2px hsl(0 0% 0% / 0.10); + --shadow-lg: 0px 4px 8px -1px hsl(0 0% 0% / 0.10), 0px 4px 6px -2px hsl(0 0% 0% / 0.10); + --shadow-xl: 0px 4px 8px -1px hsl(0 0% 0% / 0.10), 0px 8px 10px -2px hsl(0 0% 0% / 0.10); + --shadow-2xl: 0px 4px 8px -1px hsl(0 0% 0% / 0.25); + --tracking-normal: 0em; } .dark { - --background: oklch(0.145 0 0); - --foreground: oklch(0.985 0 0); - --card: oklch(0.205 0 0); - --card-foreground: oklch(0.985 0 0); - --popover: oklch(0.205 0 0); - --popover-foreground: oklch(0.985 0 0); - --primary: oklch(0.922 0 0); - --primary-foreground: oklch(0.205 0 0); - --secondary: oklch(0.269 0 0); - --secondary-foreground: oklch(0.985 0 0); - --muted: oklch(0.269 0 0); - --muted-foreground: oklch(0.708 0 0); - --accent: oklch(0.269 0 0); - --accent-foreground: oklch(0.985 0 0); - --destructive: oklch(0.704 0.191 22.216); - --border: oklch(1 0 0 / 10%); - --input: oklch(1 0 0 / 15%); - --ring: oklch(0.556 0 0); - --chart-1: oklch(0.488 0.243 264.376); - --chart-2: oklch(0.696 0.17 162.48); - --chart-3: oklch(0.769 0.188 70.08); - --chart-4: oklch(0.627 0.265 303.9); - --chart-5: oklch(0.645 0.246 16.439); - --sidebar: oklch(0.205 0 0); - --sidebar-foreground: oklch(0.985 0 0); - --sidebar-primary: oklch(0.488 0.243 264.376); - --sidebar-primary-foreground: oklch(0.985 0 0); - --sidebar-accent: oklch(0.269 0 0); - --sidebar-accent-foreground: oklch(0.985 0 0); - --sidebar-border: oklch(1 0 0 / 10%); - --sidebar-ring: oklch(0.556 0 0); + --background: oklch(0.2046 0 0); + --foreground: oklch(0.9219 0 0); + --card: oklch(0.2686 0 0); + --card-foreground: oklch(0.9219 0 0); + --popover: oklch(0.2686 0 0); + --popover-foreground: oklch(0.9219 0 0); + --primary: oklch(0.7686 0.1647 70.0804); + --primary-foreground: oklch(0 0 0); + --secondary: oklch(0.2686 0 0); + --secondary-foreground: oklch(0.9219 0 0); + --muted: oklch(0.2686 0 0); + --muted-foreground: oklch(0.7155 0 0); + --accent: oklch(0.4732 0.1247 46.2007); + --accent-foreground: oklch(0.9243 0.1151 95.7459); + --destructive: oklch(0.6368 0.2078 25.3313); + --border: oklch(0.3715 0 0); + --input: oklch(0.3715 0 0); + --ring: oklch(0.7686 0.1647 70.0804); + --chart-1: oklch(0.8369 0.1644 84.4286); + --chart-2: oklch(0.6658 0.1574 58.3183); + --chart-3: oklch(0.4732 0.1247 46.2007); + --chart-4: oklch(0.5553 0.1455 48.9975); + --chart-5: oklch(0.4732 0.1247 46.2007); + --sidebar: oklch(0.1684 0 0); + --sidebar-foreground: oklch(0.9219 0 0); + --sidebar-primary: oklch(0.7686 0.1647 70.0804); + --sidebar-primary-foreground: oklch(1.0000 0 0); + --sidebar-accent: oklch(0.4732 0.1247 46.2007); + --sidebar-accent-foreground: oklch(0.9243 0.1151 95.7459); + --sidebar-border: oklch(0.3715 0 0); + --sidebar-ring: oklch(0.7686 0.1647 70.0804); + --destructive-foreground: oklch(1.0000 0 0); + --radius: 0.375rem; + --font-sans: Inter, sans-serif; + --font-serif: Source Serif 4, serif; + --font-mono: JetBrains Mono, monospace; + --shadow-color: hsl(0 0% 0%); + --shadow-opacity: 0.1; + --shadow-blur: 8px; + --shadow-spread: -1px; + --shadow-offset-x: 0px; + --shadow-offset-y: 4px; + --letter-spacing: 0em; + --spacing: 0.25rem; + --shadow-2xs: 0px 4px 8px -1px hsl(0 0% 0% / 0.05); + --shadow-xs: 0px 4px 8px -1px hsl(0 0% 0% / 0.05); + --shadow-sm: 0px 4px 8px -1px hsl(0 0% 0% / 0.10), 0px 1px 2px -2px hsl(0 0% 0% / 0.10); + --shadow: 0px 4px 8px -1px hsl(0 0% 0% / 0.10), 0px 1px 2px -2px hsl(0 0% 0% / 0.10); + --shadow-md: 0px 4px 8px -1px hsl(0 0% 0% / 0.10), 0px 2px 4px -2px hsl(0 0% 0% / 0.10); + --shadow-lg: 0px 4px 8px -1px hsl(0 0% 0% / 0.10), 0px 4px 6px -2px hsl(0 0% 0% / 0.10); + --shadow-xl: 0px 4px 8px -1px hsl(0 0% 0% / 0.10), 0px 8px 10px -2px hsl(0 0% 0% / 0.10); + --shadow-2xl: 0px 4px 8px -1px hsl(0 0% 0% / 0.25); } @layer base { @@ -118,8 +185,9 @@ } body { @apply bg-background text-foreground; + letter-spacing: var(--tracking-normal); } .bg-brand{ background-color: #1A292F; } -} +} \ No newline at end of file diff --git a/src/components/app-sidebar.tsx b/src/components/app-sidebar.tsx index 0f56829..0460464 100644 --- a/src/components/app-sidebar.tsx +++ b/src/components/app-sidebar.tsx @@ -72,6 +72,10 @@ const data = { title: "Reconhecimentos", url: "/cadastros/reconhecimentos/", }, + { + title: "Andamentos", + url: "/cadastros/andamentos/", + }, ], }, { diff --git a/src/components/ui/popover.tsx b/src/components/ui/popover.tsx new file mode 100644 index 0000000..01e468b --- /dev/null +++ b/src/components/ui/popover.tsx @@ -0,0 +1,48 @@ +"use client" + +import * as React from "react" +import * as PopoverPrimitive from "@radix-ui/react-popover" + +import { cn } from "@/lib/utils" + +function Popover({ + ...props +}: React.ComponentProps) { + return +} + +function PopoverTrigger({ + ...props +}: React.ComponentProps) { + return +} + +function PopoverContent({ + className, + align = "center", + sideOffset = 4, + ...props +}: React.ComponentProps) { + return ( + + + + ) +} + +function PopoverAnchor({ + ...props +}: React.ComponentProps) { + return +} + +export { Popover, PopoverTrigger, PopoverContent, PopoverAnchor } diff --git a/src/components/ui/select.tsx b/src/components/ui/select.tsx new file mode 100644 index 0000000..dcbbc0c --- /dev/null +++ b/src/components/ui/select.tsx @@ -0,0 +1,185 @@ +"use client" + +import * as React from "react" +import * as SelectPrimitive from "@radix-ui/react-select" +import { CheckIcon, ChevronDownIcon, ChevronUpIcon } from "lucide-react" + +import { cn } from "@/lib/utils" + +function Select({ + ...props +}: React.ComponentProps) { + return +} + +function SelectGroup({ + ...props +}: React.ComponentProps) { + return +} + +function SelectValue({ + ...props +}: React.ComponentProps) { + return +} + +function SelectTrigger({ + className, + size = "default", + children, + ...props +}: React.ComponentProps & { + size?: "sm" | "default" +}) { + return ( + + {children} + + + + + ) +} + +function SelectContent({ + className, + children, + position = "popper", + ...props +}: React.ComponentProps) { + return ( + + + + + {children} + + + + + ) +} + +function SelectLabel({ + className, + ...props +}: React.ComponentProps) { + return ( + + ) +} + +function SelectItem({ + className, + children, + ...props +}: React.ComponentProps) { + return ( + + + + + + + {children} + + ) +} + +function SelectSeparator({ + className, + ...props +}: React.ComponentProps) { + return ( + + ) +} + +function SelectScrollUpButton({ + className, + ...props +}: React.ComponentProps) { + return ( + + + + ) +} + +function SelectScrollDownButton({ + className, + ...props +}: React.ComponentProps) { + return ( + + + + ) +} + +export { + Select, + SelectContent, + SelectGroup, + SelectItem, + SelectLabel, + SelectScrollDownButton, + SelectScrollUpButton, + SelectSeparator, + SelectTrigger, + SelectValue, +} From 3355c98164cb427b5aebf460cf11a1c9ac96e837 Mon Sep 17 00:00:00 2001 From: keven Date: Fri, 12 Sep 2025 10:31:16 -0300 Subject: [PATCH 04/10] =?UTF-8?q?[MVPTN-2]=20feat(CRUD):=20Atualiza=C3=A7?= =?UTF-8?q?=C3=A3o=20no=20crud=20de=20gerenciamento=20de=20andamentos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cadastros/(t_tb_andamentoservico)/andamentos/page.tsx | 2 +- .../(t_tb_reconhecimentotipo)/reconhecimentos/page.tsx | 8 ++++---- .../t_tb_andamentoservico/TTBAndamentoServicoForm.tsx | 6 ++++-- .../useTTBReconhecimentoTipoReadHooks.ts | 4 ++-- .../useTTBReconhecimentoTipoSaveHooks.ts | 4 ++-- ...hecimentoTipo.ts => TTBReconhecimentoTipoInterface.ts} | 2 +- ...TBAndamentoServico.ts => TTBAndamentoServicoSchema.ts} | 0 ...conhecimentoTipo.ts => TTBReconhecimentoTipoSchema.ts} | 0 8 files changed, 14 insertions(+), 12 deletions(-) rename src/app/(protected)/(cadastros)/cadastros/_hooks/{ => t_tb_reocnhecimentotipo}/useTTBReconhecimentoTipoReadHooks.ts (79%) rename src/app/(protected)/(cadastros)/cadastros/_hooks/{ => t_tb_reocnhecimentotipo}/useTTBReconhecimentoTipoSaveHooks.ts (78%) rename src/app/(protected)/(cadastros)/cadastros/_interfaces/{ITTTBReconhecimentoTipo.ts => TTBReconhecimentoTipoInterface.ts} (59%) rename src/app/(protected)/(cadastros)/cadastros/_schemas/{TTBAndamentoServico.ts => TTBAndamentoServicoSchema.ts} (100%) rename src/app/(protected)/(cadastros)/cadastros/_schemas/{TTTBReconhecimentoTipo.ts => TTBReconhecimentoTipoSchema.ts} (100%) diff --git a/src/app/(protected)/(cadastros)/cadastros/(t_tb_andamentoservico)/andamentos/page.tsx b/src/app/(protected)/(cadastros)/cadastros/(t_tb_andamentoservico)/andamentos/page.tsx index 8249c7b..0338ae2 100644 --- a/src/app/(protected)/(cadastros)/cadastros/(t_tb_andamentoservico)/andamentos/page.tsx +++ b/src/app/(protected)/(cadastros)/cadastros/(t_tb_andamentoservico)/andamentos/page.tsx @@ -6,7 +6,7 @@ import { useEffect, useState } from "react"; import { useTTBAndamentoServicoReadHook } from "../../_hooks/t_tb_andamentoservico/useTTBAndamentoServicoReadHook"; import Loading from "@/app/_components/loading/loading"; import TTBAndamentoServicoInteface, { tipoEnum } from "../../_interfaces/TTBAndamentoServicoInterface"; -import { TTBAndamentoServicoSchema } from "../../_schemas/TTBAndamentoServico"; +import { TTBAndamentoServicoSchema } from "../../_schemas/TTBAndamentoServicoSchema"; import z from "zod"; import { useTTBAndamentoServicoSaveHook } from "../../_hooks/t_tb_andamentoservico/useTTBAndamentoServicoSaveHook"; import TTBAndamentoServicoTable from "../../_components/t_tb_andamentoservico/TTBAndamentoServicoTable"; diff --git a/src/app/(protected)/(cadastros)/cadastros/(t_tb_reconhecimentotipo)/reconhecimentos/page.tsx b/src/app/(protected)/(cadastros)/cadastros/(t_tb_reconhecimentotipo)/reconhecimentos/page.tsx index c944264..ac533b6 100644 --- a/src/app/(protected)/(cadastros)/cadastros/(t_tb_reconhecimentotipo)/reconhecimentos/page.tsx +++ b/src/app/(protected)/(cadastros)/cadastros/(t_tb_reconhecimentotipo)/reconhecimentos/page.tsx @@ -33,12 +33,12 @@ import { TableHeader, TableRow, } from "@/components/ui/table" -import { useTTBReconhecimentoTipoReadHooks } from "../../_hooks/useTTBReconhecimentoTipoReadHooks" +import { useTTBReconhecimentoTipoReadHooks } from "../../_hooks/t_tb_reocnhecimentotipo/useTTBReconhecimentoTipoReadHooks" import { useEffect, useState } from "react" -import ITTTBReconhecimentoTipo from "../../_interfaces/ITTTBReconhecimentoTipo" +import ITTTBReconhecimentoTipo from "../../_interfaces/TTBReconhecimentoTipoInterface" import Loading from "@/app/_components/loading/loading" import { Button } from "@/components/ui/button" -import { useTTBReconhecimentoTipoSaveHooks } from "../../_hooks/useTTBReconhecimentoTipoSaveHooks" +import { useTTBReconhecimentoTipoSaveHooks } from "../../_hooks/t_tb_reocnhecimentotipo/useTTBReconhecimentoTipoSaveHooks" import { Controller, useForm } from "react-hook-form" import { Form, @@ -49,7 +49,7 @@ import { FormMessage, } from "@/components/ui/form" import { zodResolver } from "@hookform/resolvers/zod" -import { TTBReconhecimentoTipoSchema } from "../../_schemas/TTTBReconhecimentoTipo" +import { TTBReconhecimentoTipoSchema } from "../../_schemas/TTBReconhecimentoTipoSchema" import z from "zod" import { Label } from "@/components/ui/label" import { Checkbox } from "@/components/ui/checkbox" diff --git a/src/app/(protected)/(cadastros)/cadastros/_components/t_tb_andamentoservico/TTBAndamentoServicoForm.tsx b/src/app/(protected)/(cadastros)/cadastros/_components/t_tb_andamentoservico/TTBAndamentoServicoForm.tsx index e2599d5..dbb519f 100644 --- a/src/app/(protected)/(cadastros)/cadastros/_components/t_tb_andamentoservico/TTBAndamentoServicoForm.tsx +++ b/src/app/(protected)/(cadastros)/cadastros/_components/t_tb_andamentoservico/TTBAndamentoServicoForm.tsx @@ -9,7 +9,7 @@ import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"; import { Controller, useForm } from "react-hook-form"; -import { TTBAndamentoServicoSchema } from "../../_schemas/TTBAndamentoServico"; +import { TTBAndamentoServicoSchema } from "../../_schemas/TTBAndamentoServicoSchema"; import { tipoEnum } from "../../_interfaces/TTBAndamentoServicoInterface"; type FormValues = z.infer @@ -52,7 +52,9 @@ export default function TTBAndamentoServicoForm({ isOpen, onClose, initialData,
- Andamentos + + Andamentos + Controle de andamentos de atos diff --git a/src/app/(protected)/(cadastros)/cadastros/_hooks/useTTBReconhecimentoTipoReadHooks.ts b/src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_reocnhecimentotipo/useTTBReconhecimentoTipoReadHooks.ts similarity index 79% rename from src/app/(protected)/(cadastros)/cadastros/_hooks/useTTBReconhecimentoTipoReadHooks.ts rename to src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_reocnhecimentotipo/useTTBReconhecimentoTipoReadHooks.ts index fb01797..39c2686 100644 --- a/src/app/(protected)/(cadastros)/cadastros/_hooks/useTTBReconhecimentoTipoReadHooks.ts +++ b/src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_reocnhecimentotipo/useTTBReconhecimentoTipoReadHooks.ts @@ -1,9 +1,9 @@ 'use client' -import ITTTBReconhecimentoTipo from '../_interfaces/ITTTBReconhecimentoTipo' +import ITTTBReconhecimentoTipo from '../../_interfaces/TTBReconhecimentoTipoInterface' import { useResponse } from "@/app/_response/ResponseContext" import { useState } from "react"; -import TTBReconhecimentoTipoIndexData from '../_data/TTBReconhecimentoTipo/TTBReconhecimentoTipoIndexData'; +import TTBReconhecimentoTipoIndexData from '../../_data/TTBReconhecimentoTipo/TTBReconhecimentoTipoIndexData'; export const useTTBReconhecimentoTipoReadHooks = () => { diff --git a/src/app/(protected)/(cadastros)/cadastros/_hooks/useTTBReconhecimentoTipoSaveHooks.ts b/src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_reocnhecimentotipo/useTTBReconhecimentoTipoSaveHooks.ts similarity index 78% rename from src/app/(protected)/(cadastros)/cadastros/_hooks/useTTBReconhecimentoTipoSaveHooks.ts rename to src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_reocnhecimentotipo/useTTBReconhecimentoTipoSaveHooks.ts index 8605a63..820b846 100644 --- a/src/app/(protected)/(cadastros)/cadastros/_hooks/useTTBReconhecimentoTipoSaveHooks.ts +++ b/src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_reocnhecimentotipo/useTTBReconhecimentoTipoSaveHooks.ts @@ -2,8 +2,8 @@ import { useResponse } from "@/app/_response/ResponseContext" import { useState } from "react"; -import ITTTBReconhecimentoTipo from '../_interfaces/ITTTBReconhecimentoTipo' -import TTBReconhecimentoTipoSaveData from "../_data/TTBReconhecimentoTipo/TTBReconhecimentoTipoSaveData"; +import ITTTBReconhecimentoTipo from '../../_interfaces/TTBReconhecimentoTipoInterface' +import TTBReconhecimentoTipoSaveData from "../../_data/TTBReconhecimentoTipo/TTBReconhecimentoTipoSaveData"; export const useTTBReconhecimentoTipoSaveHooks = () => { diff --git a/src/app/(protected)/(cadastros)/cadastros/_interfaces/ITTTBReconhecimentoTipo.ts b/src/app/(protected)/(cadastros)/cadastros/_interfaces/TTBReconhecimentoTipoInterface.ts similarity index 59% rename from src/app/(protected)/(cadastros)/cadastros/_interfaces/ITTTBReconhecimentoTipo.ts rename to src/app/(protected)/(cadastros)/cadastros/_interfaces/TTBReconhecimentoTipoInterface.ts index d0f4dda..8eef0fe 100644 --- a/src/app/(protected)/(cadastros)/cadastros/_interfaces/ITTTBReconhecimentoTipo.ts +++ b/src/app/(protected)/(cadastros)/cadastros/_interfaces/TTBReconhecimentoTipoInterface.ts @@ -1,4 +1,4 @@ -export default interface ITTTBReconhecimentoTipo{ +export default interface TTBReconhecimentoTipoInterface{ tb_reconhecimentotipo_id: number, descricao: string, situacao: string, diff --git a/src/app/(protected)/(cadastros)/cadastros/_schemas/TTBAndamentoServico.ts b/src/app/(protected)/(cadastros)/cadastros/_schemas/TTBAndamentoServicoSchema.ts similarity index 100% rename from src/app/(protected)/(cadastros)/cadastros/_schemas/TTBAndamentoServico.ts rename to src/app/(protected)/(cadastros)/cadastros/_schemas/TTBAndamentoServicoSchema.ts diff --git a/src/app/(protected)/(cadastros)/cadastros/_schemas/TTTBReconhecimentoTipo.ts b/src/app/(protected)/(cadastros)/cadastros/_schemas/TTBReconhecimentoTipoSchema.ts similarity index 100% rename from src/app/(protected)/(cadastros)/cadastros/_schemas/TTTBReconhecimentoTipo.ts rename to src/app/(protected)/(cadastros)/cadastros/_schemas/TTBReconhecimentoTipoSchema.ts From 46918249a20e3cf150e889aee9cee702c2548789 Mon Sep 17 00:00:00 2001 From: keven Date: Fri, 12 Sep 2025 11:32:34 -0300 Subject: [PATCH 05/10] =?UTF-8?q?[MVPTN-1]=20feat(Componentes):=20Separado?= =?UTF-8?q?=20a=20p=C3=A1gina=20em=20componentes=20que=20compo=C3=AAm=20a?= =?UTF-8?q?=20p=C3=A1gina?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../reconhecimentos/page.tsx | 150 ------------------ .../TTBReconhecimentoTipoAlert.tsx | 28 ++++ .../TTBReconhecimentoTipoForm.tsx | 74 +++++++++ .../TTBReconhecimentoTipoTable.tsx | 85 ++++++++++ 4 files changed, 187 insertions(+), 150 deletions(-) create mode 100644 src/app/(protected)/(cadastros)/cadastros/_components/t_tb_reconhecimentotipo/TTBReconhecimentoTipoAlert.tsx create mode 100644 src/app/(protected)/(cadastros)/cadastros/_components/t_tb_reconhecimentotipo/TTBReconhecimentoTipoForm.tsx create mode 100644 src/app/(protected)/(cadastros)/cadastros/_components/t_tb_reconhecimentotipo/TTBReconhecimentoTipoTable.tsx diff --git a/src/app/(protected)/(cadastros)/cadastros/(t_tb_reconhecimentotipo)/reconhecimentos/page.tsx b/src/app/(protected)/(cadastros)/cadastros/(t_tb_reconhecimentotipo)/reconhecimentos/page.tsx index ac533b6..4bab9e4 100644 --- a/src/app/(protected)/(cadastros)/cadastros/(t_tb_reconhecimentotipo)/reconhecimentos/page.tsx +++ b/src/app/(protected)/(cadastros)/cadastros/(t_tb_reconhecimentotipo)/reconhecimentos/page.tsx @@ -134,156 +134,6 @@ export default function TTBReconhecimentoTipoPage() {
- - - - - - - # - - - Situação - - - Descrição - - - - - - - {reconhecimentosTipos.map( - (item: ITTTBReconhecimentoTipo) => ( - - - {item.tb_reconhecimentotipo_id} - - - {item.situacao === 'A' ? ( - - Ativo - - ) : ( - - Inativo - - )} - - - {item.descricao} - - - - - - - - - openForm(item)}> - Editar - - - handlingConfirmation(true, item)}> - Remover - - - - - - - ) - )} - -
-
-
- - - {/* Formulário dentro do Dialog */} - - - - - - - Tipos de Reconhecimentos - - Tipos de reconhecimentos são usados na tela de balcão - - - ( - - Descrição - - - - - - )} - /> -
- ( - field.onChange(checked ? "A" : "I")} - /> - )} - /> - -
- - - - - - - - - -
- - -
- - - - - - #{item?.tb_reconhecimentotipo_id} - {item?.descricao} - - - Esta ação não pode ser desfeita. Isso excluirá permanentemente o registro e seus dados dos nossos servidores. - - - - handlingConfirmation(false, null)} className="cursor-pointer"> - Cancelar - - - Continuar - - - - -
) } diff --git a/src/app/(protected)/(cadastros)/cadastros/_components/t_tb_reconhecimentotipo/TTBReconhecimentoTipoAlert.tsx b/src/app/(protected)/(cadastros)/cadastros/_components/t_tb_reconhecimentotipo/TTBReconhecimentoTipoAlert.tsx new file mode 100644 index 0000000..a95e312 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_components/t_tb_reconhecimentotipo/TTBReconhecimentoTipoAlert.tsx @@ -0,0 +1,28 @@ +import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle } from "@/components/ui/alert-dialog"; + +export default function TTBReconhecimentoTipoAlert() { + + return ( + + + + + #{item?.tb_reconhecimentotipo_id} - {item?.descricao} + + + Esta ação não pode ser desfeita. Isso excluirá permanentemente o registro e seus dados dos nossos servidores. + + + + handlingConfirmation(false, null)} className="cursor-pointer"> + Cancelar + + + Continuar + + + + + ); + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_components/t_tb_reconhecimentotipo/TTBReconhecimentoTipoForm.tsx b/src/app/(protected)/(cadastros)/cadastros/_components/t_tb_reconhecimentotipo/TTBReconhecimentoTipoForm.tsx new file mode 100644 index 0000000..ffa8e5e --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_components/t_tb_reconhecimentotipo/TTBReconhecimentoTipoForm.tsx @@ -0,0 +1,74 @@ +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 { FormControl, FormField, FormItem, FormLabel, FormMessage } from "@/components/ui/form"; +import { Label } from "@/components/ui/label"; +import { Controller, Form } from "react-hook-form"; + +export default function TTBReconhecimentoTipoForm() { + + return ( + + {/* Formulário dentro do Dialog */} +
+ + + + + + Tipos de Reconhecimentos + + Tipos de reconhecimentos são usados na tela de balcão + + + ( + + Descrição + + + + + + )} + /> +
+ ( + field.onChange(checked ? "A" : "I")} + /> + )} + /> + +
+ + + + + + + + + +
+ + +
+ ); + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_components/t_tb_reconhecimentotipo/TTBReconhecimentoTipoTable.tsx b/src/app/(protected)/(cadastros)/cadastros/_components/t_tb_reconhecimentotipo/TTBReconhecimentoTipoTable.tsx new file mode 100644 index 0000000..72ce875 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_components/t_tb_reconhecimentotipo/TTBReconhecimentoTipoTable.tsx @@ -0,0 +1,85 @@ +import { Button } from "@/components/ui/button"; +import { Card, CardContent } from "@/components/ui/card"; +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, Trash2 } from "lucide-react"; +import TTBReconhecimentoTipoInterface from "../../_interfaces/TTBReconhecimentoTipoInterface"; + +interface Props { + data: TTBReconhecimentoTipoInterface, + onEdit: (item: TTBReconhecimentoTipoInterface) => void, + onDelete: (item: TTBReconhecimentoTipoInterface) => void, +} + +export default function TTBReconhecimentoTipoTable() { + + return ( + + + + + + + # + + + Situação + + + Descrição + + + + + + + {reconhecimentosTipos.map( + (item: ITTTBReconhecimentoTipo) => ( + + + {item.tb_reconhecimentotipo_id} + + + {item.situacao === 'A' ? ( + + Ativo + + ) : ( + + Inativo + + )} + + + {item.descricao} + + + + + + + + + openForm(item)}> + Editar + + + handlingConfirmation(true, item)}> + Remover + + + + + + + ) + )} + +
+
+
+ ); + +} \ No newline at end of file From 0407483d2300523ff2fec06568ec4e75e6d12e2b Mon Sep 17 00:00:00 2001 From: keven Date: Sat, 13 Sep 2025 13:14:00 -0300 Subject: [PATCH 06/10] =?UTF-8?q?[MVPTN-2]=20refacto(AndamentoServico):=20?= =?UTF-8?q?Refaz=20o=20CRUD=20de=20AndamentoServico=20implementando=20comp?= =?UTF-8?q?oneiza=C3=A7=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 24 ++ package.json | 2 + src/actions/json/Json.ts | 16 +- .../andamentos/page.tsx | 174 +++++++---- .../TTBAndamentoServicoAlert.tsx | 38 --- .../TTBAndamentoServicoForm.tsx | 273 ++++++++++-------- .../TTBAndamentoServicoTable.tsx | 169 +++++++---- .../TTBAndamentoServicoIndexData.ts | 145 +--------- .../TTBAndamentoServicoSaveData.ts | 25 +- .../useTTBAndamentoServicoReadHook.ts | 1 + .../useTTBAndamentoServicoSaveHook.ts | 8 +- .../confirm_dialog/ConfirmDialog.tsx | 83 ++++++ .../confirm_dialog/useConfirmDialog.ts | 51 ++++ src/config/app.json | 2 +- src/services/api/Api.ts | 5 +- 15 files changed, 580 insertions(+), 436 deletions(-) delete mode 100644 src/app/(protected)/(cadastros)/cadastros/_components/t_tb_andamentoservico/TTBAndamentoServicoAlert.tsx create mode 100644 src/app/_components/confirm_dialog/ConfirmDialog.tsx create mode 100644 src/app/_components/confirm_dialog/useConfirmDialog.ts diff --git a/package-lock.json b/package-lock.json index db55039..9e77c45 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,6 +8,7 @@ "name": "app", "version": "0.1.0", "dependencies": { + "@faker-js/faker": "^10.0.0", "@hookform/resolvers": "^5.2.1", "@radix-ui/react-alert-dialog": "^1.1.15", "@radix-ui/react-avatar": "^1.1.10", @@ -24,6 +25,7 @@ "class-variance-authority": "^0.7.1", "clsx": "^2.1.1", "cookies-next": "^6.1.0", + "faker-js": "^1.0.0", "jsonwebtoken": "^9.0.2", "lucide-react": "^0.540.0", "next": "15.4.6", @@ -69,6 +71,22 @@ "tslib": "^2.4.0" } }, + "node_modules/@faker-js/faker": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/@faker-js/faker/-/faker-10.0.0.tgz", + "integrity": "sha512-UollFEUkVXutsaP+Vndjxar40Gs5JL2HeLcl8xO1QAjJgOdhc3OmBFWyEylS+RddWaaBiAzH+5/17PLQJwDiLw==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/fakerjs" + } + ], + "license": "MIT", + "engines": { + "node": "^20.19.0 || ^22.13.0 || ^23.5.0 || >=24.0.0", + "npm": ">=10" + } + }, "node_modules/@floating-ui/core": { "version": "1.7.3", "resolved": "https://registry.npmjs.org/@floating-ui/core/-/core-1.7.3.tgz", @@ -2167,6 +2185,12 @@ "node": ">=10.13.0" } }, + "node_modules/faker-js": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/faker-js/-/faker-js-1.0.0.tgz", + "integrity": "sha512-kaToadbN63LWhHjl69pqG+YHlxAK0aZAPhQDUpVP7v7+RG//ZpK0OzXjCwaAQq98awOii0WSHxtJmIz0X7/UqQ==", + "license": "ISC" + }, "node_modules/get-nonce": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/get-nonce/-/get-nonce-1.0.1.tgz", diff --git a/package.json b/package.json index 7d867a7..0111c7f 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "lint": "next lint" }, "dependencies": { + "@faker-js/faker": "^10.0.0", "@hookform/resolvers": "^5.2.1", "@radix-ui/react-alert-dialog": "^1.1.15", "@radix-ui/react-avatar": "^1.1.10", @@ -25,6 +26,7 @@ "class-variance-authority": "^0.7.1", "clsx": "^2.1.1", "cookies-next": "^6.1.0", + "faker-js": "^1.0.0", "jsonwebtoken": "^9.0.2", "lucide-react": "^0.540.0", "next": "15.4.6", diff --git a/src/actions/json/Json.ts b/src/actions/json/Json.ts index 92a1a18..b075b64 100644 --- a/src/actions/json/Json.ts +++ b/src/actions/json/Json.ts @@ -1,16 +1,6 @@ +import appConfig from '../../config/app.json'; export default class Json { - - static execute(path: string) { - - return { - "state": "go", - "api": { - "url": "http://localhost:8000/", - "prefix": "api/v1", - "content_type": "application/json" - } - } - + static execute() { + return appConfig; } - } \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/(t_tb_andamentoservico)/andamentos/page.tsx b/src/app/(protected)/(cadastros)/cadastros/(t_tb_andamentoservico)/andamentos/page.tsx index 0338ae2..7fe708a 100644 --- a/src/app/(protected)/(cadastros)/cadastros/(t_tb_andamentoservico)/andamentos/page.tsx +++ b/src/app/(protected)/(cadastros)/cadastros/(t_tb_andamentoservico)/andamentos/page.tsx @@ -1,92 +1,154 @@ -'use client' +'use client'; +import { useEffect, useState, useCallback } from "react"; import { Button } from "@/components/ui/button"; import { Card, CardContent } from "@/components/ui/card"; -import { useEffect, useState } from "react"; -import { useTTBAndamentoServicoReadHook } from "../../_hooks/t_tb_andamentoservico/useTTBAndamentoServicoReadHook"; -import Loading from "@/app/_components/loading/loading"; -import TTBAndamentoServicoInteface, { tipoEnum } from "../../_interfaces/TTBAndamentoServicoInterface"; -import { TTBAndamentoServicoSchema } from "../../_schemas/TTBAndamentoServicoSchema"; -import z from "zod"; -import { useTTBAndamentoServicoSaveHook } from "../../_hooks/t_tb_andamentoservico/useTTBAndamentoServicoSaveHook"; -import TTBAndamentoServicoTable from "../../_components/t_tb_andamentoservico/TTBAndamentoServicoTable"; -import TTBAndamentoServicoForm from "../../_components/t_tb_andamentoservico/TTBAndamentoServicoForm"; -import TTBAndamentoServicoAlert from "../../_components/t_tb_andamentoservico/TTBAndamentoServicoAlert"; import { PlusIcon } from "lucide-react"; -type FormValues = z.infer +import Loading from "@/app/_components/loading/loading"; +import TTBAndamentoServicoTable from "../../_components/t_tb_andamentoservico/TTBAndamentoServicoTable"; +import TTBAndamentoServicoForm from "../../_components/t_tb_andamentoservico/TTBAndamentoServicoForm"; + +import { useTTBAndamentoServicoReadHook } from "../../_hooks/t_tb_andamentoservico/useTTBAndamentoServicoReadHook"; +import { useTTBAndamentoServicoSaveHook } from "../../_hooks/t_tb_andamentoservico/useTTBAndamentoServicoSaveHook"; + +import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog"; +import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDialog"; + +import TTBAndamentoServicoInterface from "../../_interfaces/TTBAndamentoServicoInterface"; export default function TTBAndamentoServico() { + // Hooks para leitura e salvamento + const { tTBAndamentosServicos, fetchTTBAndamentoServico } = useTTBAndamentoServicoReadHook(); + const { saveTTBAndamentoServico } = useTTBAndamentoServicoSaveHook(); - const { tTBAndamentosServicos, fetchTTBAndamentoServico, addTTBAndamentoServico } = useTTBAndamentoServicoReadHook(); - const { tTBAndamentoServico, saveTTBAndamentoServico } = useTTBAndamentoServicoSaveHook(); + // Estados + const [selectedAndamento, setSelectedAndamento] = useState(null); + const [isFormOpen, setIsFormOpen] = useState(false); - const [dialogOpen, setDialogOpen] = useState(false); - const [alertDialogOpen, setAlertDialogOpen] = useState(false); - const [item, setItem] = useState(null); + // Estado para saber qual item será deletado + const [itemToDelete, setItemToDelete] = useState(null); - const [formOpen, setFormOpen] = useState(false); - const [editingItem, setEditingItem] = useState(null); + /** + * Hook do modal de confirmação + */ + const { + isOpen: isConfirmOpen, + openDialog: openConfirmDialog, + handleConfirm, + handleCancel, + } = useConfirmDialog(); - const [deleteOpen, setDeleteOpen] = useState(false) - const [deleteItem, setDeleteItem] = useState(null) + /** + * Abre o formulário no modo de edição ou criação + */ + const handleOpenForm = useCallback((data: TTBAndamentoServicoInterface | null) => { + setSelectedAndamento(data); + setIsFormOpen(true); + }, []); - const emptyForm: FormValues = { - tb_andamentoservico_id: 0, - descricao: "", - situacao: "I", - tipo: "", - usa_email: "", - }; + /** + * 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: TTBAndamentoServicoInterface) => { + await saveTTBAndamentoServico(formData); + handleCloseForm(); + fetchTTBAndamentoServico(); // Atualiza a lista após salvar + }, + [saveTTBAndamentoServico, fetchTTBAndamentoServico, handleCloseForm] + ); + + /** + * Quando o usuário clica em "remover" na tabela + */ + const handleConfirmDelete = useCallback((item: TTBAndamentoServicoInterface) => { + setItemToDelete(item); + openConfirmDialog(); // Abre o modal de confirmação + }, [openConfirmDialog]); + + /** + * Executa a exclusão de fato quando o usuário confirma + */ + const handleDelete = useCallback(() => { + if (!itemToDelete) return; + console.log("Deletando andamento:", itemToDelete); + + // TODO: Implementar lógica de exclusão na API + fetchTTBAndamentoServico(); // Atualiza a lista + setItemToDelete(null); // Limpa o item selecionado + handleCancel(); // Fecha o modal + }, [itemToDelete, fetchTTBAndamentoServico, handleCancel]); + + /** + * Busca inicial dos dados + */ useEffect(() => { fetchTTBAndamentoServico(); }, []); - const handleSave = async (values: FormValues) => { - const saved = await saveTTBAndamentoServico(values); - addTTBAndamentoServico(saved); - setFormOpen(false); + /** + * Tela de loading enquanto carrega os dados + */ + if (!tTBAndamentosServicos) { + return ; } - if (!tTBAndamentosServicos) return ; return (
-
-
-
+ {/* Cabeçalho */} +
+
+

Andamentos -

-
+ +

Gerenciamento de tipos de reconhecimentos -

-
-
- +

+
+ + {/* Tabela de andamentos */} { setEditingItem(item); setFormOpen(true) }} - onDelete={(item) => { setDeleteItem(item); setDeleteOpen(true) }} + onEdit={handleOpenForm} + onDelete={handleConfirmDelete} /> - setFormOpen(false)} - initialData={editingItem || emptyForm} - onSave={handleSave} + + {/* Modal de confirmação */} + - < TTBAndamentoServicoAlert - isOpen={deleteOpen} - item={deleteItem} - onClose={() => setDeleteOpen(false)} - onConfirm={() => { setDeleteOpen(false) }} + + {/* Formulário de criação/edição */} +
); diff --git a/src/app/(protected)/(cadastros)/cadastros/_components/t_tb_andamentoservico/TTBAndamentoServicoAlert.tsx b/src/app/(protected)/(cadastros)/cadastros/_components/t_tb_andamentoservico/TTBAndamentoServicoAlert.tsx deleted file mode 100644 index 1fc1667..0000000 --- a/src/app/(protected)/(cadastros)/cadastros/_components/t_tb_andamentoservico/TTBAndamentoServicoAlert.tsx +++ /dev/null @@ -1,38 +0,0 @@ -'use client' - -import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle } from "@/components/ui/alert-dialog"; -import TTBAndamentoServicoInteface from "../../_interfaces/TTBAndamentoServicoInterface"; - -interface Props { - isOpen: boolean, - item?: TTBAndamentoServicoInteface | null, - onClose: () => void - onConfirm: () => void -} - -export default function TTBAndamentoServicoAlert({ isOpen, item, onClose, onConfirm }: Props) { - return ( -
- - - - - #{item?.tb_andamentoservico_id} - {item?.descricao} - - - Esta ação não pode ser desfeita. Isso excluirá permanentemente o registro e seus dados dos nossos servidores. - - - - - Cancelar - - - Continuar - - - - -
- ); -} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_components/t_tb_andamentoservico/TTBAndamentoServicoForm.tsx b/src/app/(protected)/(cadastros)/cadastros/_components/t_tb_andamentoservico/TTBAndamentoServicoForm.tsx index dbb519f..bd85c25 100644 --- a/src/app/(protected)/(cadastros)/cadastros/_components/t_tb_andamentoservico/TTBAndamentoServicoForm.tsx +++ b/src/app/(protected)/(cadastros)/cadastros/_components/t_tb_andamentoservico/TTBAndamentoServicoForm.tsx @@ -1,36 +1,67 @@ -'use client' +'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 { + 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 { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"; -import { Controller, useForm } from "react-hook-form"; +import { + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue +} from "@/components/ui/select"; + import { TTBAndamentoServicoSchema } from "../../_schemas/TTBAndamentoServicoSchema"; import { tipoEnum } from "../../_interfaces/TTBAndamentoServicoInterface"; -type FormValues = z.infer +type FormValues = z.infer; interface Props { - isOpen: boolean - onClose: () => void - initialData?: FormValues - onSave: (data: FormValues) => void + isOpen: boolean; + data: FormValues | null; + onClose: (item: null, isFormStatus: boolean) => void; + onSave: (data: FormValues) => void; } -export default function TTBAndamentoServicoForm({ isOpen, onClose, initialData, onSave }: Props) { - +export default function TTBAndamentoServicoForm({ isOpen, data, onClose, onSave }: Props) { + // Inicializa o react-hook-form com schema zod const form = useForm({ - resolver: undefined, - defaultValues: initialData || { tb_andamentoservico_id: 0, descricao: "", situacao: "I" } - }) + resolver: zodResolver(TTBAndamentoServicoSchema), + defaultValues: { + descricao: "", + tipo: "", + situacao: "A", + usa_email: "I", + tb_andamentoservico_id: undefined, + }, + }); + // Opções do Select mapeadas a partir do enum const tipoOptions = Object.values(tipoEnum).map((value) => ({ value, - // Aqui você pode personalizar o label como quiser label: value === "C" ? "Cancelado" : value === "E" ? "Estornado" : @@ -40,113 +71,117 @@ export default function TTBAndamentoServicoForm({ isOpen, onClose, initialData, "Outros" })); + // Atualiza o formulário quando recebe dados para edição + useEffect(() => { + if (data) form.reset(data); + }, [data, form]); + return ( -
- + { + if (!open) onClose(null, false); + }} + > + + + + Andamentos + + + Controle de andamentos de atos + + +
- - - - - - - Andamentos - - - Controle de andamentos de atos - - - ( - - - Descrição - - - - - - - )} + + + {/* Descrição */} + ( + + Descrição + + + + + + )} + /> + + {/* Tipo */} + ( + + Tipo + + + + )} + /> + + {/* Situação */} + ( +
+ field.onChange(checked ? "A" : "I")} /> - ( - - - Tipo - - - - - )} + +
+ )} + /> + + {/* Usar e-mail */} + ( +
+ field.onChange(checked ? "A" : "I")} /> -
- ( - field.onChange(checked ? "A" : "I")} - /> - )} - /> - -
-
- ( - field.onChange(checked ? "A" : "I")} - /> - )} - /> - -
- - - - - - - - - - + +
+ )} + /> + + {/* Rodapé do Dialog */} + + + + + + + + {/* Campo oculto */} + -
-
+ + ); -} \ No newline at end of file +} diff --git a/src/app/(protected)/(cadastros)/cadastros/_components/t_tb_andamentoservico/TTBAndamentoServicoTable.tsx b/src/app/(protected)/(cadastros)/cadastros/_components/t_tb_andamentoservico/TTBAndamentoServicoTable.tsx index 9183f05..1eada8f 100644 --- a/src/app/(protected)/(cadastros)/cadastros/_components/t_tb_andamentoservico/TTBAndamentoServicoTable.tsx +++ b/src/app/(protected)/(cadastros)/cadastros/_components/t_tb_andamentoservico/TTBAndamentoServicoTable.tsx @@ -1,79 +1,124 @@ -'use client' +'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 { + 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 TTBAndamentoServicoInteface from "../../_interfaces/TTBAndamentoServicoInterface"; -interface Props { - data: TTBAndamentoServicoInteface[] - onEdit: (item: TTBAndamentoServicoInteface) => void - onDelete: (item: TTBAndamentoServicoInteface) => void +interface TTBAndamentoServicoTableProps { + data: TTBAndamentoServicoInteface[]; + onEdit: (item: TTBAndamentoServicoInteface, isEditingFormStatus: boolean) => void; + onDelete: (item: TTBAndamentoServicoInteface, isEditingFormStatus: boolean) => void; } -export default function TTBAndamentoServicoTable({ data, onEdit, onDelete }: Props) { +/** + * 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 ( + + {isActive ? "Ativo" : "Inativo"} + + ); +} + +export default function TTBAndamentoServicoTable({ + data, + onEdit, + onDelete +}: TTBAndamentoServicoTableProps) { return ( - - # - - - Situação - - - Descrição - - + # + Situação + Descrição + Ações + - {data.map( - (item: TTBAndamentoServicoInteface) => ( - - - {item.tb_andamentoservico_id} - - - {item.situacao === 'A' ? ( - - Ativo - - ) : ( - - Inativo - - )} - - - {item.descricao} - - - - - - - - - onEdit(item)}> - Editar - - - onDelete(item)}> - Remover - - - - - - - ) - )} + {data.map((item) => ( + + + {item.tb_andamentoservico_id} + + + + + + + {item.descricao} + + + + + + + + + + onEdit(item, true)} + > + + Editar + + + + + onDelete(item, true)} + > + + Remover + + + + + + + ))}
); -} \ No newline at end of file +} diff --git a/src/app/(protected)/(cadastros)/cadastros/_data/TTBAndamentoServico/TTBAndamentoServicoIndexData.ts b/src/app/(protected)/(cadastros)/cadastros/_data/TTBAndamentoServico/TTBAndamentoServicoIndexData.ts index b91bb11..3865338 100644 --- a/src/app/(protected)/(cadastros)/cadastros/_data/TTBAndamentoServico/TTBAndamentoServicoIndexData.ts +++ b/src/app/(protected)/(cadastros)/cadastros/_data/TTBAndamentoServico/TTBAndamentoServicoIndexData.ts @@ -1,132 +1,17 @@ +'use server' + +import API from "@/services/api/Api"; +import { Methods } from "@/services/api/enums/ApiMethodEnum"; + export default async function TTBAndamentoServicoIndexData() { - return Promise.resolve({ - data: [ - { - tb_andamentoservico_id: 1, - descricao: "Recepção 1", - status: "A", - tipo: "G" - }, - { - tb_andamentoservico_id: 2, - descricao: "Aguardando assinatura da Imobiliária", - status: "A", - tipo: "G" - }, - { - tb_andamentoservico_id: 3, - descricao: "Esc. Impugnada (Falta Itbi, cert. ou documentos)", - status: "A", - tipo: "G" - }, - { - tb_andamentoservico_id: 4, - descricao: "Aguardando Certtb_andamentoservico_idão de Registro", - status: "A", - tipo: "G" - }, - { - tb_andamentoservico_id: 5, - descricao: "Conferencia", - status: "A", - tipo: "G" - }, - { - tb_andamentoservico_id: 16, - descricao: "Mapa", - status: "A", - tipo: "G" - }, - { - tb_andamentoservico_id: 6, - descricao: "Entregue", - status: "A", - tipo: "G" - }, - { - tb_andamentoservico_id: 18, - descricao: "PROTOCOLADO", - status: "A", - tipo: "G" - }, - { - tb_andamentoservico_id: 7, - descricao: "Protocolo", - status: "A", - tipo: "G" - }, - { - tb_andamentoservico_id: 8, - descricao: "Cadastro", - status: "A", - tipo: "G" - }, - { - tb_andamentoservico_id: 9, - descricao: "Registro/Espelho", - status: "A", - tipo: "G" - }, - { - tb_andamentoservico_id: 10, - descricao: "Corrigtb_andamentoservico_ido Pronto", - status: "A", - tipo: "G" - }, - { - tb_andamentoservico_id: 11, - descricao: "Aguardando Cliente", - status: "A", - tipo: "G" - }, - { - tb_andamentoservico_id: 12, - descricao: "Cancelado a pedtb_andamentoservico_ido da parte", - status: "A", - tipo: "C" - }, - { - tb_andamentoservico_id: 13, - descricao: "Cancelado por determinação judicial", - status: "A", - tipo: "C" - }, - { - tb_andamentoservico_id: 14, - descricao: "Capas e Indicador", - status: "A", - tipo: "G" - }, - { - tb_andamentoservico_id: 15, - descricao: "Falta assinatura", - status: "A", - tipo: "G" - }, - { - tb_andamentoservico_id: 17, - descricao: "Impugnado", - status: "A", - tipo: "G" - }, - { - tb_andamentoservico_id: 19, - descricao: "Entregre/sem registro", - status: "A", - tipo: "C" - }, - { - tb_andamentoservico_id: 20, - descricao: "Corrigtb_andamentoservico_ido sem Registro", - status: "A", - tipo: "C" - }, - { - tb_andamentoservico_id: 21, - descricao: "Cancelamento de ofício", - status: "A", - tipo: "C" - } - ] + + const api = new API(); + + const response = await api.send({ + 'method': Methods.GET, + 'endpoint': `administrativo/t_tb_andamentoservico/` }); -} + + return response; + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_data/TTBAndamentoServico/TTBAndamentoServicoSaveData.ts b/src/app/(protected)/(cadastros)/cadastros/_data/TTBAndamentoServico/TTBAndamentoServicoSaveData.ts index ab8035d..fdc5943 100644 --- a/src/app/(protected)/(cadastros)/cadastros/_data/TTBAndamentoServico/TTBAndamentoServicoSaveData.ts +++ b/src/app/(protected)/(cadastros)/cadastros/_data/TTBAndamentoServico/TTBAndamentoServicoSaveData.ts @@ -1,16 +1,19 @@ -import { faker } from "@faker-js/faker"; +'use server' -export default async function name(andamentoServico: any) { +import API from "@/services/api/Api"; +import TTBAndamentoServicoInteface from "../../_interfaces/TTBAndamentoServicoInterface"; +import { Methods } from "@/services/api/enums/ApiMethodEnum"; - return Promise.resolve({ - message: 'Dados salvos com sucesso', - data: { - tb_reconhecimentotipo_id: faker.number.int({ min: 1, max: 1000 }), - descricao: andamentoServico.tb_reconhecimentotipo_id + andamentoServico.descricao, - situacao: andamentoServico.situacao, - tipo: andamentoServico.tipo, - usa_email: andamentoServico.usa_email, - }, +export default async function TTBAndamentoServicoSaveData(andamentoServico: TTBAndamentoServicoInteface) { + + const api = new API(); + + const response = await api.send({ + method: Methods.POST, + endpoint: `administrativo/t_tb_andamentoservico/`, + body: andamentoServico }); + return response; + } \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_andamentoservico/useTTBAndamentoServicoReadHook.ts b/src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_andamentoservico/useTTBAndamentoServicoReadHook.ts index df69730..a1b0ac1 100644 --- a/src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_andamentoservico/useTTBAndamentoServicoReadHook.ts +++ b/src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_andamentoservico/useTTBAndamentoServicoReadHook.ts @@ -15,6 +15,7 @@ export const useTTBAndamentoServicoReadHook = () => { const response = await TTBAndamentoServicoIndexData(); + // Armazena os dados consultados setTTBAndamentosServicos(response.data); // Define os dados do componente de resposta (toast, modal, etc) diff --git a/src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_andamentoservico/useTTBAndamentoServicoSaveHook.ts b/src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_andamentoservico/useTTBAndamentoServicoSaveHook.ts index b854b0a..18f6c0d 100644 --- a/src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_andamentoservico/useTTBAndamentoServicoSaveHook.ts +++ b/src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_andamentoservico/useTTBAndamentoServicoSaveHook.ts @@ -1,9 +1,9 @@ 'use client' import { useResponse } from "@/app/_response/ResponseContext" -import { use, useState } from "react"; +import { useState } from "react"; import TTBAndamentoServicoInteface from "../../_interfaces/TTBAndamentoServicoInterface"; -import TTBReconhecimentoTipoSaveData from "../../_data/TTBReconhecimentoTipo/TTBReconhecimentoTipoSaveData"; +import TTBAndamentoServicoSaveData from "../../_data/TTBAndamentoServico/TTBAndamentoServicoSaveData"; export const useTTBAndamentoServicoSaveHook = () => { @@ -13,10 +13,12 @@ export const useTTBAndamentoServicoSaveHook = () => { const saveTTBAndamentoServico = async (form: TTBAndamentoServicoInteface) => { - const response = await TTBReconhecimentoTipoSaveData(form); + const response = await TTBAndamentoServicoSaveData(form); + // Armazena os dados da repsota setTTBAndamentoServico(response.data); + // Define os dados da respota(toast, modal, etc) setResponse(response); // Retorna os valores de forma imediata diff --git a/src/app/_components/confirm_dialog/ConfirmDialog.tsx b/src/app/_components/confirm_dialog/ConfirmDialog.tsx new file mode 100644 index 0000000..f72a3eb --- /dev/null +++ b/src/app/_components/confirm_dialog/ConfirmDialog.tsx @@ -0,0 +1,83 @@ +'use client'; + +import React from 'react'; + +// Shadcn UI components +import { + AlertDialog, + AlertDialogCancel, + AlertDialogContent, + AlertDialogDescription, + AlertDialogFooter, + AlertDialogHeader, + AlertDialogTitle, + AlertDialogAction, +} from '@/components/ui/alert-dialog'; + +interface AlertProps { + /** Controla a abertura do modal */ + isOpen: boolean; + + /** Título principal do alerta */ + title: string; + + /** Descrição adicional do alerta */ + description?: string; + + /** Mensagem do corpo do alerta */ + message: string; + + /** Texto do botão de confirmação */ + confirmText?: string; + + /** Texto do botão de cancelamento */ + cancelText?: string; + + /** Função executada ao confirmar */ + onConfirm: () => void; + + /** Função executada ao cancelar */ + onCancel: () => void; +} + +/** + * Componente de alerta genérico e reutilizável. + * Baseado no Radix e Shadcn UI, com suporte a título, descrição, + * mensagem e botões de ação customizáveis. + */ +export default function ConfirmDialog({ + isOpen, + title, + description, + message, + confirmText = 'Confirmar', + cancelText = 'Cancelar', + onConfirm, + onCancel, +}: AlertProps) { + return ( + + + + {title} + {description && ( + {description} + )} + + +
+ {message} +
+ + + + {cancelText} + + + {confirmText} + + +
+
+ ); +} diff --git a/src/app/_components/confirm_dialog/useConfirmDialog.ts b/src/app/_components/confirm_dialog/useConfirmDialog.ts new file mode 100644 index 0000000..55afbc6 --- /dev/null +++ b/src/app/_components/confirm_dialog/useConfirmDialog.ts @@ -0,0 +1,51 @@ +// Importa os hooks useCallback e useState do React +import { useCallback, useState } from "react"; + +// Define a interface para opções do hook +// Permite que o usuário passe callbacks opcionais para confirmação e cancelamento +interface UseConfirmDialogOptions { + onConfirm?: () => void; // Função chamada quando o usuário confirma a ação + onCancel?: () => void; // Função chamada quando o usuário cancela a ação +} + +// Declara o hook customizado useConfirmDialog +// Recebe um objeto de opções que contém os callbacks onConfirm e onCancel +export function useConfirmDialog({ onConfirm, onCancel }: UseConfirmDialogOptions = {}) { + // Estado interno que controla se o diálogo de confirmação está aberto + const [isOpen, setIsOpen] = useState(false); + + // Função para abrir o diálogo + // useCallback memoriza a função para que não seja recriada em cada renderização + const openDialog = useCallback(() => setIsOpen(true), []); + + // Função para fechar o diálogo + const closeDialog = useCallback(() => setIsOpen(false), []); + + // Função chamada quando o usuário confirma a ação + // Executa o callback onConfirm, se fornecido, e fecha o diálogo + const handleConfirm = useCallback(() => { + onConfirm?.(); // Chama onConfirm somente se ele existir + closeDialog(); // Fecha o diálogo após a confirmação + }, [onConfirm, closeDialog]); + + // Função chamada quando o usuário cancela a ação + // Executa o callback onCancel, se fornecido, e fecha o diálogo + const handleCancel = useCallback(() => { + onCancel?.(); // Chama onCancel somente se ele existir + closeDialog(); // Fecha o diálogo após o cancelamento + }, [onCancel, closeDialog]); + + // Retorna os valores e funções que serão usados pelo componente + // isOpen -> estado do modal + // openDialog -> função para abrir o modal + // closeDialog -> função para fechar o modal + // handleConfirm -> função para confirmar a ação + // handleCancel -> função para cancelar a ação + return { + isOpen, + openDialog, + closeDialog, + handleConfirm, + handleCancel, + }; +} diff --git a/src/config/app.json b/src/config/app.json index 64ba493..d38e8d3 100644 --- a/src/config/app.json +++ b/src/config/app.json @@ -1,7 +1,7 @@ { "state": "go", "api": { - "url": "http://localhost:3000/", + "url": "http://localhost:8000/", "prefix": "api/v1/", "content_type": "application/json" } diff --git a/src/services/api/Api.ts b/src/services/api/Api.ts index 75e6173..dfa75f1 100644 --- a/src/services/api/Api.ts +++ b/src/services/api/Api.ts @@ -1,6 +1,5 @@ import Json from '@/actions/json/Json'; import ApiInterface from './interfaces/ApiInterface'; -import Response from '@/services/response/Response'; import TokenGet from '@/actions/token/TokenGet'; import ApiSchema from '@/services/api/schemas/ApiSchema'; @@ -17,7 +16,7 @@ export default class API { this.ApiSchema = new ApiSchema(); // Obtem as configurações da aplicação - this.config = Json.execute('config/app.json'); + this.config = Json.execute(); } @@ -46,7 +45,7 @@ export default class API { const filteredBody = _data.body ? Object.fromEntries(Object.entries(_data.body).filter(([_, v]) => v != null && v !== "")) : null; // Realiza a requisição - const response = await fetch(`${this.ApiSchema.url}${this.ApiSchema.prefix}/${this.ApiSchema.endpoint}`, { + const response = await fetch(`${this.ApiSchema.url}${this.ApiSchema.prefix}${this.ApiSchema.endpoint}`, { method: _data.method, headers: { "Accept": `${this.ApiSchema.contentType}`, From 44d20d6f81c08d93f1063113471b9e231609d4ce Mon Sep 17 00:00:00 2001 From: keven Date: Sun, 14 Sep 2025 10:49:05 -0300 Subject: [PATCH 07/10] =?UTF-8?q?[MVPTN-2]=20feat(CRUD):=20Finaliza=C3=A7?= =?UTF-8?q?=C3=A3o=20de=20a=C3=A7=C3=B5es=20do=20CRUD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../andamentos/page.tsx | 49 +++++++++++++------ .../TTBAndamentoServicoForm.tsx | 8 +-- .../TTBAndamentoServicoRemoveData.ts | 18 +++++++ .../TTBAndamentoServicoSaveData.ts | 8 +-- .../useTTBAndamentoServicoDeleteHook.ts | 24 +++++++++ .../useTTBAndamentoServicoSaveHook.ts | 4 +- .../_schemas/TTBAndamentoServicoSchema.ts | 10 ++-- 7 files changed, 91 insertions(+), 30 deletions(-) create mode 100644 src/app/(protected)/(cadastros)/cadastros/_data/TTBAndamentoServico/TTBAndamentoServicoRemoveData.ts create mode 100644 src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_andamentoservico/useTTBAndamentoServicoDeleteHook.ts diff --git a/src/app/(protected)/(cadastros)/cadastros/(t_tb_andamentoservico)/andamentos/page.tsx b/src/app/(protected)/(cadastros)/cadastros/(t_tb_andamentoservico)/andamentos/page.tsx index 7fe708a..2f9fb14 100644 --- a/src/app/(protected)/(cadastros)/cadastros/(t_tb_andamentoservico)/andamentos/page.tsx +++ b/src/app/(protected)/(cadastros)/cadastros/(t_tb_andamentoservico)/andamentos/page.tsx @@ -16,11 +16,13 @@ import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog"; import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDialog"; import TTBAndamentoServicoInterface from "../../_interfaces/TTBAndamentoServicoInterface"; +import { useTTBAndamentoServicoDeleteHook } from "../../_hooks/t_tb_andamentoservico/useTTBAndamentoServicoDeleteHook"; export default function TTBAndamentoServico() { // Hooks para leitura e salvamento const { tTBAndamentosServicos, fetchTTBAndamentoServico } = useTTBAndamentoServicoReadHook(); const { saveTTBAndamentoServico } = useTTBAndamentoServicoSaveHook(); + const { deleteTTBAndamentoServico } = useTTBAndamentoServicoDeleteHook(); // Estados const [selectedAndamento, setSelectedAndamento] = useState(null); @@ -58,34 +60,49 @@ export default function TTBAndamentoServico() { /** * Salva os dados do formulário */ - const handleSave = useCallback( - async (formData: TTBAndamentoServicoInterface) => { - await saveTTBAndamentoServico(formData); - handleCloseForm(); - fetchTTBAndamentoServico(); // Atualiza a lista após salvar - }, - [saveTTBAndamentoServico, fetchTTBAndamentoServico, handleCloseForm] - ); + const handleSave = useCallback(async (formData: TTBAndamentoServicoInterface) => { + + // Aguarda salvar o registro + await saveTTBAndamentoServico(formData); + + // Encerra o fomulário + handleCloseForm(); + + // Atualiza a lista de dados + fetchTTBAndamentoServico(); + + }, [saveTTBAndamentoServico, fetchTTBAndamentoServico, handleCloseForm]); /** * Quando o usuário clica em "remover" na tabela */ const handleConfirmDelete = useCallback((item: TTBAndamentoServicoInterface) => { + + // Define o item atual para remoção setItemToDelete(item); - openConfirmDialog(); // Abre o modal de confirmação + + // Abre o modal de confirmação + openConfirmDialog(); + }, [openConfirmDialog]); /** * Executa a exclusão de fato quando o usuário confirma */ - const handleDelete = useCallback(() => { - if (!itemToDelete) return; - console.log("Deletando andamento:", itemToDelete); + const handleDelete = useCallback(async () => { + + // Executa o Hook de remoção + await deleteTTBAndamentoServico(itemToDelete); + + // Atualiza a lista + await fetchTTBAndamentoServico(); + + // Limpa o item selecionado + setItemToDelete(null); + + // Fecha o modal + handleCancel(); - // TODO: Implementar lógica de exclusão na API - fetchTTBAndamentoServico(); // Atualiza a lista - setItemToDelete(null); // Limpa o item selecionado - handleCancel(); // Fecha o modal }, [itemToDelete, fetchTTBAndamentoServico, handleCancel]); /** diff --git a/src/app/(protected)/(cadastros)/cadastros/_components/t_tb_andamentoservico/TTBAndamentoServicoForm.tsx b/src/app/(protected)/(cadastros)/cadastros/_components/t_tb_andamentoservico/TTBAndamentoServicoForm.tsx index bd85c25..f93cd52 100644 --- a/src/app/(protected)/(cadastros)/cadastros/_components/t_tb_andamentoservico/TTBAndamentoServicoForm.tsx +++ b/src/app/(protected)/(cadastros)/cadastros/_components/t_tb_andamentoservico/TTBAndamentoServicoForm.tsx @@ -55,7 +55,7 @@ export default function TTBAndamentoServicoForm({ isOpen, data, onClose, onSave tipo: "", situacao: "A", usa_email: "I", - tb_andamentoservico_id: undefined, + tb_andamentoservico_id: 0, }, }); @@ -170,11 +170,13 @@ export default function TTBAndamentoServicoForm({ isOpen, data, onClose, onSave {/* Rodapé do Dialog */} - - + {/* Campo oculto */} diff --git a/src/app/(protected)/(cadastros)/cadastros/_data/TTBAndamentoServico/TTBAndamentoServicoRemoveData.ts b/src/app/(protected)/(cadastros)/cadastros/_data/TTBAndamentoServico/TTBAndamentoServicoRemoveData.ts new file mode 100644 index 0000000..5ad8fc9 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_data/TTBAndamentoServico/TTBAndamentoServicoRemoveData.ts @@ -0,0 +1,18 @@ +'use server' + +import API from "@/services/api/Api"; +import TTBAndamentoServicoInteface from "../../_interfaces/TTBAndamentoServicoInterface"; +import { Methods } from "@/services/api/enums/ApiMethodEnum"; + +export default async function TTBAndamentoServicoRemoveData(tTBAndamentoServico: TTBAndamentoServicoInteface) { + + const api = new API(); + + const response = await api.send({ + method: Methods.DELETE, + endpoint: `administrativo/t_tb_andamentoservico/${tTBAndamentoServico.tb_andamentoservico_id}` + }); + + return response; + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_data/TTBAndamentoServico/TTBAndamentoServicoSaveData.ts b/src/app/(protected)/(cadastros)/cadastros/_data/TTBAndamentoServico/TTBAndamentoServicoSaveData.ts index fdc5943..c8ebd33 100644 --- a/src/app/(protected)/(cadastros)/cadastros/_data/TTBAndamentoServico/TTBAndamentoServicoSaveData.ts +++ b/src/app/(protected)/(cadastros)/cadastros/_data/TTBAndamentoServico/TTBAndamentoServicoSaveData.ts @@ -4,14 +4,14 @@ import API from "@/services/api/Api"; import TTBAndamentoServicoInteface from "../../_interfaces/TTBAndamentoServicoInterface"; import { Methods } from "@/services/api/enums/ApiMethodEnum"; -export default async function TTBAndamentoServicoSaveData(andamentoServico: TTBAndamentoServicoInteface) { +export default async function TTBAndamentoServicoSaveData(data: TTBAndamentoServicoInteface) { const api = new API(); const response = await api.send({ - method: Methods.POST, - endpoint: `administrativo/t_tb_andamentoservico/`, - body: andamentoServico + method: data.tb_andamentoservico_id ? Methods.PUT : Methods.POST, + endpoint: `administrativo/t_tb_andamentoservico/${data.tb_andamentoservico_id ? data.tb_andamentoservico_id : ''}`, + body: data }); return response; diff --git a/src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_andamentoservico/useTTBAndamentoServicoDeleteHook.ts b/src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_andamentoservico/useTTBAndamentoServicoDeleteHook.ts new file mode 100644 index 0000000..c3407ee --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_andamentoservico/useTTBAndamentoServicoDeleteHook.ts @@ -0,0 +1,24 @@ +import { useResponse } from "@/app/_response/ResponseContext" +import { useState } from "react"; +import TTBAndamentoServicoInteface from "../../_interfaces/TTBAndamentoServicoInterface"; +import TTBAndamentoServicoRemoveData from "../../_data/TTBAndamentoServico/TTBAndamentoServicoRemoveData"; + +export const useTTBAndamentoServicoDeleteHook = () => { + + const { setResponse } = useResponse(); + + const [tTBAndamentoServico, setTTBAndamentoServico] = useState(); + + const deleteTTBAndamentoServico = async (data: TTBAndamentoServicoInteface) => { + + const response = await TTBAndamentoServicoRemoveData(data); + + setTTBAndamentoServico(data); + + setResponse(response); + + } + + return { tTBAndamentoServico, deleteTTBAndamentoServico } + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_andamentoservico/useTTBAndamentoServicoSaveHook.ts b/src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_andamentoservico/useTTBAndamentoServicoSaveHook.ts index 18f6c0d..c5c1c37 100644 --- a/src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_andamentoservico/useTTBAndamentoServicoSaveHook.ts +++ b/src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_andamentoservico/useTTBAndamentoServicoSaveHook.ts @@ -11,9 +11,9 @@ export const useTTBAndamentoServicoSaveHook = () => { const [tTBAndamentoServico, setTTBAndamentoServico] = useState(); - const saveTTBAndamentoServico = async (form: TTBAndamentoServicoInteface) => { + const saveTTBAndamentoServico = async (data: TTBAndamentoServicoInteface) => { - const response = await TTBAndamentoServicoSaveData(form); + const response = await TTBAndamentoServicoSaveData(data); // Armazena os dados da repsota setTTBAndamentoServico(response.data); diff --git a/src/app/(protected)/(cadastros)/cadastros/_schemas/TTBAndamentoServicoSchema.ts b/src/app/(protected)/(cadastros)/cadastros/_schemas/TTBAndamentoServicoSchema.ts index af713ff..7a326bc 100644 --- a/src/app/(protected)/(cadastros)/cadastros/_schemas/TTBAndamentoServicoSchema.ts +++ b/src/app/(protected)/(cadastros)/cadastros/_schemas/TTBAndamentoServicoSchema.ts @@ -2,10 +2,10 @@ import { z } from 'zod'; export const TTBAndamentoServicoSchema = z.object({ - tb_andamentoservico_id: z.number(), - descricao: z.string(), - situacao: z.string(), - tipo: z.string(), - usa_email: z.string() + 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"), + usa_email: z.string().min(1, "Email Obrigatória"), }); \ No newline at end of file From bdf982fe38efbbc77c29a324ee81304dd143dcc9 Mon Sep 17 00:00:00 2001 From: keven Date: Sun, 14 Sep 2025 11:33:44 -0300 Subject: [PATCH 08/10] =?UTF-8?q?[MVPTN-1]=20feat(CRUD):=20Finaliza=C3=A7?= =?UTF-8?q?=C3=A3o=20do=20CRUD=20de=20cadastro=20de=20Tipos=20de=20Reconhe?= =?UTF-8?q?cimentos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../reconhecimentos/page.tsx | 275 ++++++++++-------- .../TTBReconhecimentoTipoAlert.tsx | 28 -- .../TTBReconhecimentoTipoForm.tsx | 178 ++++++++---- .../TTBReconhecimentoTipoTable.tsx | 191 +++++++----- .../TTBReconhecimentoTipoDeleteData.ts | 16 + .../TTBReconhecimentoTipoIndexData.ts | 20 +- .../TTBReconhecimentoTipoSaveData.ts | 21 +- .../useTTBReconhecimentoTipoDeleteHook.ts | 19 ++ .../useTTBReconhecimentoTipoReadHook.ts} | 14 +- .../useTTBReconhecimentoTipoSaveHook.ts} | 10 +- 10 files changed, 447 insertions(+), 325 deletions(-) delete mode 100644 src/app/(protected)/(cadastros)/cadastros/_components/t_tb_reconhecimentotipo/TTBReconhecimentoTipoAlert.tsx create mode 100644 src/app/(protected)/(cadastros)/cadastros/_data/TTBReconhecimentoTipo/TTBReconhecimentoTipoDeleteData.ts create mode 100644 src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_reconhecimentotipo/useTTBReconhecimentoTipoDeleteHook.ts rename src/app/(protected)/(cadastros)/cadastros/_hooks/{t_tb_reocnhecimentotipo/useTTBReconhecimentoTipoReadHooks.ts => t_tb_reconhecimentotipo/useTTBReconhecimentoTipoReadHook.ts} (52%) rename src/app/(protected)/(cadastros)/cadastros/_hooks/{t_tb_reocnhecimentotipo/useTTBReconhecimentoTipoSaveHooks.ts => t_tb_reconhecimentotipo/useTTBReconhecimentoTipoSaveHook.ts} (60%) diff --git a/src/app/(protected)/(cadastros)/cadastros/(t_tb_reconhecimentotipo)/reconhecimentos/page.tsx b/src/app/(protected)/(cadastros)/cadastros/(t_tb_reconhecimentotipo)/reconhecimentos/page.tsx index 4bab9e4..d24425b 100644 --- a/src/app/(protected)/(cadastros)/cadastros/(t_tb_reconhecimentotipo)/reconhecimentos/page.tsx +++ b/src/app/(protected)/(cadastros)/cadastros/(t_tb_reconhecimentotipo)/reconhecimentos/page.tsx @@ -1,139 +1,174 @@ -'use client' +'use client'; -import { - AlertDialog, - AlertDialogAction, - AlertDialogCancel, - AlertDialogContent, - AlertDialogDescription, - AlertDialogFooter, - AlertDialogHeader, - AlertDialogTitle, - AlertDialogTrigger, -} from "@/components/ui/alert-dialog" +import { useEffect, useState, useCallback } from "react"; +import { Button } from "@/components/ui/button"; +import { Card, CardContent } from "@/components/ui/card"; +import { PlusIcon } from "lucide-react"; -import { - Dialog, - DialogClose, - DialogContent, - DialogDescription, - DialogFooter, - DialogHeader, - DialogTitle, - DialogTrigger, -} from "@/components/ui/dialog" +import Loading from "@/app/_components/loading/loading"; +import TTBAndamentoServicoTable from "../../_components/t_tb_reconhecimentotipo/TTBReconhecimentoTipoTable"; +import TTBAndamentoServicoForm from "../../_components/t_tb_reconhecimentotipo/TTBReconhecimentoTipoForm"; -import { Input } from "@/components/ui/input" -import { Card, CardContent } from "@/components/ui/card" -import { - Table, - TableBody, - TableCell, - TableHead, - TableHeader, - TableRow, -} from "@/components/ui/table" -import { useTTBReconhecimentoTipoReadHooks } from "../../_hooks/t_tb_reocnhecimentotipo/useTTBReconhecimentoTipoReadHooks" -import { useEffect, useState } from "react" -import ITTTBReconhecimentoTipo from "../../_interfaces/TTBReconhecimentoTipoInterface" -import Loading from "@/app/_components/loading/loading" -import { Button } from "@/components/ui/button" -import { useTTBReconhecimentoTipoSaveHooks } from "../../_hooks/t_tb_reocnhecimentotipo/useTTBReconhecimentoTipoSaveHooks" -import { Controller, useForm } from "react-hook-form" -import { - Form, - FormControl, - FormField, - FormItem, - FormLabel, - FormMessage, -} from "@/components/ui/form" -import { zodResolver } from "@hookform/resolvers/zod" -import { TTBReconhecimentoTipoSchema } from "../../_schemas/TTBReconhecimentoTipoSchema" -import z from "zod" -import { Label } from "@/components/ui/label" -import { Checkbox } from "@/components/ui/checkbox" -import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuTrigger } from "@/components/ui/dropdown-menu" -import { DropdownMenuLabel } from "@radix-ui/react-dropdown-menu" -import { EllipsisIcon, PencilIcon, PlusIcon, Trash2 } from "lucide-react" +import { useTTBReconhecimentoTipoReadHook } from "../../_hooks/t_tb_reconhecimentotipo/useTTBReconhecimentoTipoReadHook"; +import { useTTBReconhecimentoTipoSaveHook } from "../../_hooks/t_tb_reconhecimentotipo/useTTBReconhecimentoTipoSaveHook"; +import { useTTBReconhecimentoTipoDeleteHook } from "../../_hooks/t_tb_reconhecimentotipo/useTTBReconhecimentoTipoDeleteHook"; -type FormValues = z.infer +import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog"; +import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDialog"; -export default function TTBReconhecimentoTipoPage() { - const { reconhecimentosTipos, fetchReconhecimentosTipos, addReconhecimentoTipo } = useTTBReconhecimentoTipoReadHooks() - const { reconhecimentoTipo, saveReconhecimentoTipo } = useTTBReconhecimentoTipoSaveHooks() +import TTBReconhecimentoTipoInterface from "../../_interfaces/TTBReconhecimentoTipoInterface"; +import TTBReconhecimentoTipoFormProps from "../../_components/t_tb_reconhecimentotipo/TTBReconhecimentoTipoForm"; - const [dialogOpen, setDialogOpen] = useState(false); - const [editingItem, setEditingItem] = useState(null); +export default function TTBAndamentoServico() { - const [alertDialogOpen, setAlertDialogOpen] = useState(false); - const [item, setItem] = useState(null); + // Hooks para leitura e salvamento + const { tTBReconhecimentosTipos, fetchTTBReconhecimentosTipos } = useTTBReconhecimentoTipoReadHook(); + const { saveTTBReconhecimentoTipo } = useTTBReconhecimentoTipoSaveHook(); + const { deleteTTBReconhecimentoTipo } = useTTBReconhecimentoTipoDeleteHook(); + // Estados + const [selectedReconhecimentoTipo, setReconhecimentoTipo] = useState(null); + const [isFormOpen, setIsFormOpen] = useState(false); + + // Estado para saber qual item será deletado + const [itemToDelete, setItemToDelete] = useState(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: TTBReconhecimentoTipoInterface | null) => { + setReconhecimentoTipo(data); + setIsFormOpen(true); + }, []); + + /** + * Fecha o formulário e limpa o andamento selecionado + */ + const handleCloseForm = useCallback(() => { + setReconhecimentoTipo(null); + setIsFormOpen(false); + }, []); + + /** + * Salva os dados do formulário + */ + const handleSave = useCallback(async (formData: TTBReconhecimentoTipoInterface) => { + + // Aguarda salvar o registro + await saveTTBReconhecimentoTipo(formData); + + // Encerra o fomulário + handleCloseForm(); + + // Atualiza a lista de dados + fetchTTBReconhecimentosTipos(); + + }, [saveTTBReconhecimentoTipo, fetchTTBReconhecimentosTipos, handleCloseForm]); + + /** + * Quando o usuário clica em "remover" na tabela + */ + const handleConfirmDelete = useCallback((item: TTBReconhecimentoTipoInterface) => { + + // 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 () => { + + // Executa o Hook de remoção + await deleteTTBReconhecimentoTipo(itemToDelete); + + // Atualiza a lista + await fetchTTBReconhecimentosTipos(); + + // Limpa o item selecionado + setItemToDelete(null); + + // Fecha o modal + handleCancel(); + + }, [itemToDelete, fetchTTBReconhecimentosTipos, handleCancel]); + + /** + * Busca inicial dos dados + */ useEffect(() => { - fetchReconhecimentosTipos() - }, []) + fetchTTBReconhecimentosTipos(); + }, []); - const form = useForm({ - resolver: zodResolver(TTBReconhecimentoTipoSchema), - defaultValues: { - tb_reconhecimentotipo_id: 0, - descricao: "", - situacao: "I", - }, - }) - - async function onSubmit(values: FormValues) { - const saved = await saveReconhecimentoTipo(values); // aguarda o retorno - addReconhecimentoTipo(saved); // adiciona diretamente na lista - - // reinicia o formulário para o estado original - form.reset(); + /** + * Tela de loading enquanto carrega os dados + */ + if (!tTBReconhecimentosTipos) { + return ; } - async function openForm(values: FormValues) { - setEditingItem(values); // guarda os valores do item - setDialogOpen(true); // abre o Dialog - form.reset({ - tb_reconhecimentotipo_id: values.tb_reconhecimentotipo_id, - descricao: values.descricao, - situacao: values.situacao, - }); - - } - - async function handlingConfirmation(visibility : boolean, item: null|any) { - setAlertDialogOpen(visibility); - setItem(item); - } - - const emptyForm: FormValues = { - tb_reconhecimentotipo_id: 0, - descricao: "", - situacao: "I", // padrão Inativo - }; - - if (!reconhecimentosTipos) return - return ( -
-
-
-
- Tipos de Reconhecimentos -
-
+ {/* Cabeçalho */} +
+
+

+ Reconhecimentos +

+

Gerenciamento de tipos de reconhecimentos -

-
- -
- +

+
+ {/* Tabela de andamentos */} + + + + + + + {/* Modal de confirmação */} + + + {/* Formulário de criação/edição */} +
- ) -} + ); +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_components/t_tb_reconhecimentotipo/TTBReconhecimentoTipoAlert.tsx b/src/app/(protected)/(cadastros)/cadastros/_components/t_tb_reconhecimentotipo/TTBReconhecimentoTipoAlert.tsx deleted file mode 100644 index a95e312..0000000 --- a/src/app/(protected)/(cadastros)/cadastros/_components/t_tb_reconhecimentotipo/TTBReconhecimentoTipoAlert.tsx +++ /dev/null @@ -1,28 +0,0 @@ -import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle } from "@/components/ui/alert-dialog"; - -export default function TTBReconhecimentoTipoAlert() { - - return ( - - - - - #{item?.tb_reconhecimentotipo_id} - {item?.descricao} - - - Esta ação não pode ser desfeita. Isso excluirá permanentemente o registro e seus dados dos nossos servidores. - - - - handlingConfirmation(false, null)} className="cursor-pointer"> - Cancelar - - - Continuar - - - - - ); - -} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_components/t_tb_reconhecimentotipo/TTBReconhecimentoTipoForm.tsx b/src/app/(protected)/(cadastros)/cadastros/_components/t_tb_reconhecimentotipo/TTBReconhecimentoTipoForm.tsx index ffa8e5e..3eb8bf6 100644 --- a/src/app/(protected)/(cadastros)/cadastros/_components/t_tb_reconhecimentotipo/TTBReconhecimentoTipoForm.tsx +++ b/src/app/(protected)/(cadastros)/cadastros/_components/t_tb_reconhecimentotipo/TTBReconhecimentoTipoForm.tsx @@ -1,74 +1,126 @@ +'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 { FormControl, FormField, FormItem, FormLabel, FormMessage } from "@/components/ui/form"; +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 { Controller, Form } from "react-hook-form"; -export default function TTBReconhecimentoTipoForm() { +import { TTBReconhecimentoTipoSchema } from "../../_schemas/TTBReconhecimentoTipoSchema"; + +type FormValues = z.infer; + +interface TTBReconhecimentoTipoFormProps { + isOpen: boolean; + data: FormValues | null; + onClose: (item: null, isFormStatus: boolean) => void; + onSave: (data: FormValues) => void; +} + +export default function TTBReconhecimentoTipoFormProps({ isOpen, data, onClose, onSave }: TTBReconhecimentoTipoFormProps) { + // Inicializa o react-hook-form com schema zod + const form = useForm({ + resolver: zodResolver(TTBReconhecimentoTipoSchema), + defaultValues: { + tb_reconhecimentotipo_id: 0, + descricao: "", + situacao: "A", + }, + }); + + // Atualiza o formulário quando recebe dados para edição + useEffect(() => { + if (data) form.reset(data); + }, [data, form]); return ( - - {/* Formulário dentro do Dialog */} -
- - - - - - Tipos de Reconhecimentos - - Tipos de reconhecimentos são usados na tela de balcão - - - ( - - Descrição - - - - - - )} - /> + { + if (!open) onClose(null, false); + }} + > + + + + Reconhecimentos + + + Tipos de Reconhecimentos + + + + + + + {/* Descrição */} + ( + + Descrição + + + + + + )} + /> + + {/* Situação */} + (
- ( - field.onChange(checked ? "A" : "I")} - /> - )} + field.onChange(checked ? "A" : "I")} /> - +
- - - - - - - - - -
- - + )} + /> + + {/* Rodapé do Dialog */} + + + + + + + + {/* Campo oculto */} + + + +
); - -} \ No newline at end of file +} diff --git a/src/app/(protected)/(cadastros)/cadastros/_components/t_tb_reconhecimentotipo/TTBReconhecimentoTipoTable.tsx b/src/app/(protected)/(cadastros)/cadastros/_components/t_tb_reconhecimentotipo/TTBReconhecimentoTipoTable.tsx index 72ce875..d8e1087 100644 --- a/src/app/(protected)/(cadastros)/cadastros/_components/t_tb_reconhecimentotipo/TTBReconhecimentoTipoTable.tsx +++ b/src/app/(protected)/(cadastros)/cadastros/_components/t_tb_reconhecimentotipo/TTBReconhecimentoTipoTable.tsx @@ -1,85 +1,124 @@ +'use client'; + import { Button } from "@/components/ui/button"; -import { Card, CardContent } from "@/components/ui/card"; -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, Trash2 } from "lucide-react"; +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 TTBReconhecimentoTipoInterface from "../../_interfaces/TTBReconhecimentoTipoInterface"; -interface Props { - data: TTBReconhecimentoTipoInterface, - onEdit: (item: TTBReconhecimentoTipoInterface) => void, - onDelete: (item: TTBReconhecimentoTipoInterface) => void, +interface TTBReconhecimentoTipoTableProps { + data: TTBReconhecimentoTipoInterface[]; + onEdit: (item: TTBReconhecimentoTipoInterface, isEditingFormStatus: boolean) => void; + onDelete: (item: TTBReconhecimentoTipoInterface, isEditingFormStatus: boolean) => void; } -export default function TTBReconhecimentoTipoTable() { +/** + * 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 ( - - - - - - - # - - - Situação - - - Descrição - - - - - - - {reconhecimentosTipos.map( - (item: ITTTBReconhecimentoTipo) => ( - - - {item.tb_reconhecimentotipo_id} - - - {item.situacao === 'A' ? ( - - Ativo - - ) : ( - - Inativo - - )} - - - {item.descricao} - - - - - - - - - openForm(item)}> - Editar - - - handlingConfirmation(true, item)}> - Remover - - - - - - - ) - )} - -
-
-
+ + {isActive ? "Ativo" : "Inativo"} + ); +} -} \ No newline at end of file +export default function TTBReconhecimentoTipoTable({ + data, + onEdit, + onDelete +}: TTBReconhecimentoTipoTableProps) { + return ( + + + + # + Situação + Descrição + Ações + + + + + {data.map((item) => ( + + + {item.tb_reconhecimentotipo_id} + + + + + + + {item.descricao} + + + + + + + + + + onEdit(item, true)} + > + + Editar + + + + + onDelete(item, true)} + > + + Remover + + + + + + + ))} + +
+ ); +} diff --git a/src/app/(protected)/(cadastros)/cadastros/_data/TTBReconhecimentoTipo/TTBReconhecimentoTipoDeleteData.ts b/src/app/(protected)/(cadastros)/cadastros/_data/TTBReconhecimentoTipo/TTBReconhecimentoTipoDeleteData.ts new file mode 100644 index 0000000..5f279f9 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_data/TTBReconhecimentoTipo/TTBReconhecimentoTipoDeleteData.ts @@ -0,0 +1,16 @@ +import API from "@/services/api/Api"; +import TTBReconhecimentoTipoInterface from "../../_interfaces/TTBReconhecimentoTipoInterface"; +import { Methods } from "@/services/api/enums/ApiMethodEnum"; + +export default async function TTBReconhecimentoTipoDeleteData(data: TTBReconhecimentoTipoInterface) { + + const api = new API(); + + const response = await api.send({ + method: Methods.DELETE, + endpoint: `administrativo/t_tb_reconhecimentotipo/${data.tb_reconhecimentotipo_id}` + }); + + return response; + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_data/TTBReconhecimentoTipo/TTBReconhecimentoTipoIndexData.ts b/src/app/(protected)/(cadastros)/cadastros/_data/TTBReconhecimentoTipo/TTBReconhecimentoTipoIndexData.ts index 869a90a..7d7995e 100644 --- a/src/app/(protected)/(cadastros)/cadastros/_data/TTBReconhecimentoTipo/TTBReconhecimentoTipoIndexData.ts +++ b/src/app/(protected)/(cadastros)/cadastros/_data/TTBReconhecimentoTipo/TTBReconhecimentoTipoIndexData.ts @@ -5,21 +5,13 @@ import { Methods } from "@/services/api/enums/ApiMethodEnum"; export default async function TTBReconhecimentoTipoIndexData() { - // const api = new API(); + const api = new API(); - // const response = await api.send({ - // 'method': Methods.GET, - // 'endpoint': `cadastros/reconhecimentos` - // }); - - // return response; - - return Promise.resolve({ - data: [ - { tb_reconhecimentotipo_id: 1, descricao: 'SEMELHANÇA', situacao: 'A' }, - { tb_reconhecimentotipo_id: 2, descricao: 'VERDADEIRO', situacao: 'A' }, - { tb_reconhecimentotipo_id: 3, descricao: 'ABONO', situacao: 'A' } - ] + const response = await api.send({ + method: Methods.GET, + endpoint: `administrativo/t_tb_reconhecimentotipo` }); + return response; + } \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_data/TTBReconhecimentoTipo/TTBReconhecimentoTipoSaveData.ts b/src/app/(protected)/(cadastros)/cadastros/_data/TTBReconhecimentoTipo/TTBReconhecimentoTipoSaveData.ts index daf5964..e045e65 100644 --- a/src/app/(protected)/(cadastros)/cadastros/_data/TTBReconhecimentoTipo/TTBReconhecimentoTipoSaveData.ts +++ b/src/app/(protected)/(cadastros)/cadastros/_data/TTBReconhecimentoTipo/TTBReconhecimentoTipoSaveData.ts @@ -1,14 +1,17 @@ -import { faker } from "@faker-js/faker" +import API from "@/services/api/Api"; +import { Methods } from "@/services/api/enums/ApiMethodEnum"; +import TTBReconhecimentoTipoInterface from "../../_interfaces/TTBReconhecimentoTipoInterface"; -export default async function TTBReconhecimentoTipoSaveData(reconhecimentoTipo: any) { +export default async function TTBReconhecimentoTipoSaveData(data: TTBReconhecimentoTipoInterface) { - return Promise.resolve({ - message: 'Dados salvos com sucesso', - data: { - tb_reconhecimentotipo_id: faker.number.int({ min: 1, max: 1000 }), - descricao: reconhecimentoTipo.tb_reconhecimentotipo_id + reconhecimentoTipo.descricao, - situacao: reconhecimentoTipo.situacao - }, + const api = new API(); + + const response = await api.send({ + method: data.tb_reconhecimentotipo_id ? Methods.PUT : Methods.POST, + endpoint: `administrativo/t_tb_reconhecimentotipo/${data.tb_reconhecimentotipo_id ? data.tb_reconhecimentotipo_id : ''}`, + body: data }); + return response; + } \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_reconhecimentotipo/useTTBReconhecimentoTipoDeleteHook.ts b/src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_reconhecimentotipo/useTTBReconhecimentoTipoDeleteHook.ts new file mode 100644 index 0000000..eb926e7 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_reconhecimentotipo/useTTBReconhecimentoTipoDeleteHook.ts @@ -0,0 +1,19 @@ +import { useResponse } from "@/app/_response/ResponseContext" +import TTBReconhecimentoTipoInterface from "../../_interfaces/TTBReconhecimentoTipoInterface"; +import TTBReconhecimentoTipoDeleteData from "../../_data/TTBReconhecimentoTipo/TTBReconhecimentoTipoDeleteData"; + +export const useTTBReconhecimentoTipoDeleteHook = () => { + + const { setResponse } = useResponse(); + + const deleteTTBReconhecimentoTipo = async (data: TTBReconhecimentoTipoInterface) => { + + const response = await TTBReconhecimentoTipoDeleteData(data); + + setResponse(response); + + } + + return { deleteTTBReconhecimentoTipo } + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_reocnhecimentotipo/useTTBReconhecimentoTipoReadHooks.ts b/src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_reconhecimentotipo/useTTBReconhecimentoTipoReadHook.ts similarity index 52% rename from src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_reocnhecimentotipo/useTTBReconhecimentoTipoReadHooks.ts rename to src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_reconhecimentotipo/useTTBReconhecimentoTipoReadHook.ts index 39c2686..3f62408 100644 --- a/src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_reocnhecimentotipo/useTTBReconhecimentoTipoReadHooks.ts +++ b/src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_reconhecimentotipo/useTTBReconhecimentoTipoReadHook.ts @@ -5,13 +5,13 @@ import { useResponse } from "@/app/_response/ResponseContext" import { useState } from "react"; import TTBReconhecimentoTipoIndexData from '../../_data/TTBReconhecimentoTipo/TTBReconhecimentoTipoIndexData'; -export const useTTBReconhecimentoTipoReadHooks = () => { +export const useTTBReconhecimentoTipoReadHook = () => { const { setResponse } = useResponse(); - const [reconhecimentosTipos, setReconhecimenntosTipos] = useState(); + const [tTBReconhecimentosTipos, setReconhecimenntosTipos] = useState(); - const fetchReconhecimentosTipos = async () => { + const fetchTTBReconhecimentosTipos = async () => { const response = await TTBReconhecimentoTipoIndexData(); @@ -21,12 +21,6 @@ export const useTTBReconhecimentoTipoReadHooks = () => { } - function addReconhecimentoTipo(reconhecimentoTipo: ITTTBReconhecimentoTipo) { - - setReconhecimenntosTipos(prev => [...(prev || []), reconhecimentoTipo]); - - } - - return { reconhecimentosTipos, fetchReconhecimentosTipos, addReconhecimentoTipo } + return { tTBReconhecimentosTipos, fetchTTBReconhecimentosTipos } } \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_reocnhecimentotipo/useTTBReconhecimentoTipoSaveHooks.ts b/src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_reconhecimentotipo/useTTBReconhecimentoTipoSaveHook.ts similarity index 60% rename from src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_reocnhecimentotipo/useTTBReconhecimentoTipoSaveHooks.ts rename to src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_reconhecimentotipo/useTTBReconhecimentoTipoSaveHook.ts index 820b846..48c60dd 100644 --- a/src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_reocnhecimentotipo/useTTBReconhecimentoTipoSaveHooks.ts +++ b/src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_reconhecimentotipo/useTTBReconhecimentoTipoSaveHook.ts @@ -5,17 +5,17 @@ import { useState } from "react"; import ITTTBReconhecimentoTipo from '../../_interfaces/TTBReconhecimentoTipoInterface' import TTBReconhecimentoTipoSaveData from "../../_data/TTBReconhecimentoTipo/TTBReconhecimentoTipoSaveData"; -export const useTTBReconhecimentoTipoSaveHooks = () => { +export const useTTBReconhecimentoTipoSaveHook = () => { const { setResponse } = useResponse(); - const [reconhecimentoTipo, setReconhcimentoTipo] = useState(); + const [tTBReconhecimentoTipo, setTTBReconhcimentoTipo] = useState(); - const saveReconhecimentoTipo = async (reconhecimentoTipo: ITTTBReconhecimentoTipo) => { + const saveTTBReconhecimentoTipo = async (reconhecimentoTipo: ITTTBReconhecimentoTipo) => { const response = await TTBReconhecimentoTipoSaveData(reconhecimentoTipo); - setReconhcimentoTipo(response.data); + saveTTBReconhecimentoTipo(response.data); setResponse(response); @@ -24,6 +24,6 @@ export const useTTBReconhecimentoTipoSaveHooks = () => { } - return { reconhecimentoTipo, saveReconhecimentoTipo } + return { tTBReconhecimentoTipo, saveTTBReconhecimentoTipo } } \ No newline at end of file From 477c1cd22a568e9db214b48102cbe12ef2004d06 Mon Sep 17 00:00:00 2001 From: keven Date: Sun, 14 Sep 2025 12:29:19 -0300 Subject: [PATCH 09/10] =?UTF-8?q?fix(Build):=20ajuste=20nos=20crud=20de=20?= =?UTF-8?q?andamento=20e=20tipo=20de=20reconhecimento=20para=20realizar=20?= =?UTF-8?q?a=20build=20da=20vers=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../(t_tb_andamentoservico)/andamentos/page.tsx | 5 ++++- .../reconhecimentos/page.tsx | 12 +++++++----- .../TTBAndamentoServicoForm.tsx | 2 +- .../TTBReconhecimentoTipoForm.tsx | 5 +++-- .../useTTBReconhecimentoTipoReadHook.ts | 2 +- .../_interfaces/TTBAndamentoServicoInterface.ts | 9 +++++---- .../_interfaces/TTBReconhecimentoTipoInterface.ts | 13 ++++++++++--- .../cadastros/_schemas/TTBAndamentoServicoSchema.ts | 3 ++- .../_schemas/TTBReconhecimentoTipoSchema.ts | 9 ++++----- 9 files changed, 37 insertions(+), 23 deletions(-) diff --git a/src/app/(protected)/(cadastros)/cadastros/(t_tb_andamentoservico)/andamentos/page.tsx b/src/app/(protected)/(cadastros)/cadastros/(t_tb_andamentoservico)/andamentos/page.tsx index 2f9fb14..a11eecb 100644 --- a/src/app/(protected)/(cadastros)/cadastros/(t_tb_andamentoservico)/andamentos/page.tsx +++ b/src/app/(protected)/(cadastros)/cadastros/(t_tb_andamentoservico)/andamentos/page.tsx @@ -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} />
- ); + );4 } \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/(t_tb_reconhecimentotipo)/reconhecimentos/page.tsx b/src/app/(protected)/(cadastros)/cadastros/(t_tb_reconhecimentotipo)/reconhecimentos/page.tsx index d24425b..2372e32 100644 --- a/src/app/(protected)/(cadastros)/cadastros/(t_tb_reconhecimentotipo)/reconhecimentos/page.tsx +++ b/src/app/(protected)/(cadastros)/cadastros/(t_tb_reconhecimentotipo)/reconhecimentos/page.tsx @@ -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 */} - {/* Formulário de criação/edição */} - ; @@ -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({ resolver: zodResolver(TTBReconhecimentoTipoSchema), defaultValues: { tb_reconhecimentotipo_id: 0, descricao: "", - situacao: "A", + situacao: situacaoEnum.ATIVO, }, }); diff --git a/src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_reconhecimentotipo/useTTBReconhecimentoTipoReadHook.ts b/src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_reconhecimentotipo/useTTBReconhecimentoTipoReadHook.ts index 3f62408..5817953 100644 --- a/src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_reconhecimentotipo/useTTBReconhecimentoTipoReadHook.ts +++ b/src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_reconhecimentotipo/useTTBReconhecimentoTipoReadHook.ts @@ -9,7 +9,7 @@ export const useTTBReconhecimentoTipoReadHook = () => { const { setResponse } = useResponse(); - const [tTBReconhecimentosTipos, setReconhecimenntosTipos] = useState(); + const [tTBReconhecimentosTipos, setReconhecimenntosTipos] = useState([]); const fetchTTBReconhecimentosTipos = async () => { diff --git a/src/app/(protected)/(cadastros)/cadastros/_interfaces/TTBAndamentoServicoInterface.ts b/src/app/(protected)/(cadastros)/cadastros/_interfaces/TTBAndamentoServicoInterface.ts index 5322010..26ad9e2 100644 --- a/src/app/(protected)/(cadastros)/cadastros/_interfaces/TTBAndamentoServicoInterface.ts +++ b/src/app/(protected)/(cadastros)/cadastros/_interfaces/TTBAndamentoServicoInterface.ts @@ -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 { diff --git a/src/app/(protected)/(cadastros)/cadastros/_interfaces/TTBReconhecimentoTipoInterface.ts b/src/app/(protected)/(cadastros)/cadastros/_interfaces/TTBReconhecimentoTipoInterface.ts index 8eef0fe..46daae9 100644 --- a/src/app/(protected)/(cadastros)/cadastros/_interfaces/TTBReconhecimentoTipoInterface.ts +++ b/src/app/(protected)/(cadastros)/cadastros/_interfaces/TTBReconhecimentoTipoInterface.ts @@ -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', + } \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_schemas/TTBAndamentoServicoSchema.ts b/src/app/(protected)/(cadastros)/cadastros/_schemas/TTBAndamentoServicoSchema.ts index 7a326bc..4677fdf 100644 --- a/src/app/(protected)/(cadastros)/cadastros/_schemas/TTBAndamentoServicoSchema.ts +++ b/src/app/(protected)/(cadastros)/cadastros/_schemas/TTBAndamentoServicoSchema.ts @@ -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"), }); \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_schemas/TTBReconhecimentoTipoSchema.ts b/src/app/(protected)/(cadastros)/cadastros/_schemas/TTBReconhecimentoTipoSchema.ts index c8e73dc..f9c8f27 100644 --- a/src/app/(protected)/(cadastros)/cadastros/_schemas/TTBReconhecimentoTipoSchema.ts +++ b/src/app/(protected)/(cadastros)/cadastros/_schemas/TTBReconhecimentoTipoSchema.ts @@ -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" }), }); \ No newline at end of file From 2256dd367fc8284fa868029c8f725ff54bb08fd4 Mon Sep 17 00:00:00 2001 From: keven Date: Mon, 15 Sep 2025 08:55:42 -0300 Subject: [PATCH 10/10] =?UTF-8?q?refactor(API):=20Ajusta=20os=20endpoints?= =?UTF-8?q?=20para=20consultar=20o=20usu=C3=A1rio?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../usuarios/[id]/detalhes/page.tsx | 2 +- .../(g_usuario)/usuarios/formulario/page.tsx | 6 +- .../(g_usuario)/usuarios/page.tsx | 2 +- .../_data/g_usuario/GUsuarioDeleteData.ts | 2 +- .../_data/g_usuario/GUsuarioIndexData.ts | 2 +- .../_data/g_usuario/GUsuarioLoginData.ts | 2 +- .../_data/g_usuario/GUsuarioReadData.ts | 2 +- .../_data/g_usuario/GUsuarioSaveData.ts | 2 +- .../_hooks/g_usuario/useGUsuarioIndexHook.ts | 2 +- .../_hooks/g_usuario/useGUsuarioReadHooks.ts | 2 +- .../_hooks/g_usuario/useGUsuarioSaveHook.ts | 2 +- .../{IGUsuario.ts => GUsuarioInterface.ts} | 2 +- .../_schemas/GUsuarioSchema.ts | 2 +- .../_services/g_usuario/GUsuarioIndex.ts | 2 +- .../_services/g_usuario/GUsuarioLogin.ts | 1 - .../andamentos/page.tsx | 25 ++---- .../reconhecimentos/page.tsx | 23 ++--- .../(protected)/(servicos)/servicos/page.tsx | 88 +++++++++++++++++++ .../confirm_dialog/ConfirmDialog.tsx | 2 - src/app/_components/structure/Header.tsx | 33 +++++++ src/components/app-sidebar.tsx | 13 +++ 21 files changed, 165 insertions(+), 52 deletions(-) rename src/app/(protected)/(administrativo)/_interfaces/{IGUsuario.ts => GUsuarioInterface.ts} (96%) create mode 100644 src/app/(protected)/(servicos)/servicos/page.tsx create mode 100644 src/app/_components/structure/Header.tsx diff --git a/src/app/(protected)/(administrativo)/(g_usuario)/usuarios/[id]/detalhes/page.tsx b/src/app/(protected)/(administrativo)/(g_usuario)/usuarios/[id]/detalhes/page.tsx index f48c529..42f4757 100644 --- a/src/app/(protected)/(administrativo)/(g_usuario)/usuarios/[id]/detalhes/page.tsx +++ b/src/app/(protected)/(administrativo)/(g_usuario)/usuarios/[id]/detalhes/page.tsx @@ -8,7 +8,7 @@ import { CardContent } from "@/components/ui/card"; import { useGUsuarioReadHooks } from "@/app/(protected)/(administrativo)/_hooks/g_usuario/useGUsuarioReadHooks"; -import Usuario from "@/app/(protected)/(administrativo)/_interfaces/IGUsuario"; +import Usuario from "@/app/(protected)/(administrativo)/_interfaces/GUsuarioInterface"; import Loading from "@/app/_components/loading/loading"; export default function UsuarioDetalhes() { diff --git a/src/app/(protected)/(administrativo)/(g_usuario)/usuarios/formulario/page.tsx b/src/app/(protected)/(administrativo)/(g_usuario)/usuarios/formulario/page.tsx index f4d153a..16c0a87 100644 --- a/src/app/(protected)/(administrativo)/(g_usuario)/usuarios/formulario/page.tsx +++ b/src/app/(protected)/(administrativo)/(g_usuario)/usuarios/formulario/page.tsx @@ -4,7 +4,7 @@ import { zodResolver } from "@hookform/resolvers/zod" import { useForm } from "react-hook-form" import { z } from "zod" import { Input } from "@/components/ui/input" -import { UsuarioFormSchema } from "../../../_schemas/GUsuarioSchema" +import { GUsuarioSchema } from "../../../_schemas/GUsuarioSchema" import { Button @@ -26,14 +26,14 @@ import { import { useGUsuarioSaveHook } from "../../../_hooks/g_usuario/useGUsuarioSaveHook" -type FormValues = z.infer +type FormValues = z.infer export default function UsuarioFormularioPage() { const { usuario, saveUsuario } = useGUsuarioSaveHook(); const form = useForm({ - resolver: zodResolver(UsuarioFormSchema), + resolver: zodResolver(GUsuarioSchema), defaultValues: { login: '', nome_completo: '', diff --git a/src/app/(protected)/(administrativo)/(g_usuario)/usuarios/page.tsx b/src/app/(protected)/(administrativo)/(g_usuario)/usuarios/page.tsx index 77e4dc5..37344b1 100644 --- a/src/app/(protected)/(administrativo)/(g_usuario)/usuarios/page.tsx +++ b/src/app/(protected)/(administrativo)/(g_usuario)/usuarios/page.tsx @@ -14,7 +14,7 @@ import { TableRow, } from "@/components/ui/table" -import Usuario from "../../_interfaces/IGUsuario"; +import Usuario from "../../_interfaces/GUsuarioInterface"; import { Button } from "@/components/ui/button"; import Link from "next/link"; import { useGUsuarioIndexHook } from "../../_hooks/g_usuario/useGUsuarioIndexHook"; diff --git a/src/app/(protected)/(administrativo)/_data/g_usuario/GUsuarioDeleteData.ts b/src/app/(protected)/(administrativo)/_data/g_usuario/GUsuarioDeleteData.ts index 3313c91..1d1d6ba 100644 --- a/src/app/(protected)/(administrativo)/_data/g_usuario/GUsuarioDeleteData.ts +++ b/src/app/(protected)/(administrativo)/_data/g_usuario/GUsuarioDeleteData.ts @@ -9,7 +9,7 @@ export default async function GUsuarioDeleteData(usuarioId: number) { const response = await api.send({ 'method': Methods.DELETE, - 'endpoint': `administrativo/usuarios/${usuarioId}` + 'endpoint': `administrativo/g_usuario/${usuarioId}` }); return response; diff --git a/src/app/(protected)/(administrativo)/_data/g_usuario/GUsuarioIndexData.ts b/src/app/(protected)/(administrativo)/_data/g_usuario/GUsuarioIndexData.ts index 8b6f66f..aaf6075 100644 --- a/src/app/(protected)/(administrativo)/_data/g_usuario/GUsuarioIndexData.ts +++ b/src/app/(protected)/(administrativo)/_data/g_usuario/GUsuarioIndexData.ts @@ -9,7 +9,7 @@ export default async function GUsuarioIndexData() { const response = await api.send({ 'method': Methods.GET, - 'endpoint': `administrativo/usuarios/` + 'endpoint': `administrativo/g_usuario/` }); return response; diff --git a/src/app/(protected)/(administrativo)/_data/g_usuario/GUsuarioLoginData.ts b/src/app/(protected)/(administrativo)/_data/g_usuario/GUsuarioLoginData.ts index 5602616..c6f7c46 100644 --- a/src/app/(protected)/(administrativo)/_data/g_usuario/GUsuarioLoginData.ts +++ b/src/app/(protected)/(administrativo)/_data/g_usuario/GUsuarioLoginData.ts @@ -10,7 +10,7 @@ export default async function GUsuarioLoginData(form: any) { // Realiza o envio dos dados const response = await api.send({ method: Methods.POST, - endpoint: `administrativo/usuarios/login`, + endpoint: `administrativo/g_usuario/authenticate`, body: form }); diff --git a/src/app/(protected)/(administrativo)/_data/g_usuario/GUsuarioReadData.ts b/src/app/(protected)/(administrativo)/_data/g_usuario/GUsuarioReadData.ts index 872c948..afe73b3 100644 --- a/src/app/(protected)/(administrativo)/_data/g_usuario/GUsuarioReadData.ts +++ b/src/app/(protected)/(administrativo)/_data/g_usuario/GUsuarioReadData.ts @@ -9,7 +9,7 @@ export default async function GUsuarioReadData(usuarioId: number) { const response = await api.send({ 'method': Methods.GET, - 'endpoint': `administrativo/usuarios/${usuarioId}` + 'endpoint': `administrativo/g_usuario/${usuarioId}` }); return response diff --git a/src/app/(protected)/(administrativo)/_data/g_usuario/GUsuarioSaveData.ts b/src/app/(protected)/(administrativo)/_data/g_usuario/GUsuarioSaveData.ts index 2ee92e2..e6ce62c 100644 --- a/src/app/(protected)/(administrativo)/_data/g_usuario/GUsuarioSaveData.ts +++ b/src/app/(protected)/(administrativo)/_data/g_usuario/GUsuarioSaveData.ts @@ -9,7 +9,7 @@ export default async function GUsuarioSaveData(form: any) { const response = await api.send({ 'method': Methods.POST, - 'endpoint': `administrativo/usuarios/`, + 'endpoint': `administrativo/g_usuario/`, 'body': form }); diff --git a/src/app/(protected)/(administrativo)/_hooks/g_usuario/useGUsuarioIndexHook.ts b/src/app/(protected)/(administrativo)/_hooks/g_usuario/useGUsuarioIndexHook.ts index ce65a48..93ca26d 100644 --- a/src/app/(protected)/(administrativo)/_hooks/g_usuario/useGUsuarioIndexHook.ts +++ b/src/app/(protected)/(administrativo)/_hooks/g_usuario/useGUsuarioIndexHook.ts @@ -1,7 +1,7 @@ 'use client' import { useState } from "react" -import Usuario from "../../_interfaces/IGUsuario" +import Usuario from "../../_interfaces/GUsuarioInterface" import GUsuarioIndex from "../../_services/g_usuario/GUsuarioIndex"; import { useResponse } from "@/app/_response/ResponseContext"; diff --git a/src/app/(protected)/(administrativo)/_hooks/g_usuario/useGUsuarioReadHooks.ts b/src/app/(protected)/(administrativo)/_hooks/g_usuario/useGUsuarioReadHooks.ts index 3283fa1..da75695 100644 --- a/src/app/(protected)/(administrativo)/_hooks/g_usuario/useGUsuarioReadHooks.ts +++ b/src/app/(protected)/(administrativo)/_hooks/g_usuario/useGUsuarioReadHooks.ts @@ -1,7 +1,7 @@ 'use client' import { useState } from "react" -import Usuario from "../../_interfaces/IGUsuario" +import Usuario from "../../_interfaces/GUsuarioInterface" import GUsuarioRead from "../../_services/g_usuario/GUsuarioRead"; import { useResponse } from "@/app/_response/ResponseContext"; diff --git a/src/app/(protected)/(administrativo)/_hooks/g_usuario/useGUsuarioSaveHook.ts b/src/app/(protected)/(administrativo)/_hooks/g_usuario/useGUsuarioSaveHook.ts index c6d1144..6519021 100644 --- a/src/app/(protected)/(administrativo)/_hooks/g_usuario/useGUsuarioSaveHook.ts +++ b/src/app/(protected)/(administrativo)/_hooks/g_usuario/useGUsuarioSaveHook.ts @@ -1,7 +1,7 @@ 'use client' import { useState } from "react" -import Usuario from "../../_interfaces/IGUsuario" +import Usuario from "../../_interfaces/GUsuarioInterface" import GUsuarioSave from "../../_services/g_usuario/GUsuarioSave"; import { useResponse } from "@/app/_response/ResponseContext"; diff --git a/src/app/(protected)/(administrativo)/_interfaces/IGUsuario.ts b/src/app/(protected)/(administrativo)/_interfaces/GUsuarioInterface.ts similarity index 96% rename from src/app/(protected)/(administrativo)/_interfaces/IGUsuario.ts rename to src/app/(protected)/(administrativo)/_interfaces/GUsuarioInterface.ts index bb299b4..13af8c1 100644 --- a/src/app/(protected)/(administrativo)/_interfaces/IGUsuario.ts +++ b/src/app/(protected)/(administrativo)/_interfaces/GUsuarioInterface.ts @@ -1,4 +1,4 @@ -export default interface Usuario { +export default interface GUsuario { usuario_id: number, trocarsenha: string, login: string, diff --git a/src/app/(protected)/(administrativo)/_schemas/GUsuarioSchema.ts b/src/app/(protected)/(administrativo)/_schemas/GUsuarioSchema.ts index c6b8831..c3942c2 100644 --- a/src/app/(protected)/(administrativo)/_schemas/GUsuarioSchema.ts +++ b/src/app/(protected)/(administrativo)/_schemas/GUsuarioSchema.ts @@ -1,6 +1,6 @@ import { z } from "zod"; -export const UsuarioFormSchema = z.object({ +export const GUsuarioSchema = z.object({ trocarsenha: z.string().optional(), login: z.string().optional(), senha: z.string().optional(), diff --git a/src/app/(protected)/(administrativo)/_services/g_usuario/GUsuarioIndex.ts b/src/app/(protected)/(administrativo)/_services/g_usuario/GUsuarioIndex.ts index 7447a94..b105740 100644 --- a/src/app/(protected)/(administrativo)/_services/g_usuario/GUsuarioIndex.ts +++ b/src/app/(protected)/(administrativo)/_services/g_usuario/GUsuarioIndex.ts @@ -8,4 +8,4 @@ export default async function GUsuarioIndex() { return response; -} \ No newline at end of file +} \ No newline at end of file diff --git a/src/app/(protected)/(administrativo)/_services/g_usuario/GUsuarioLogin.ts b/src/app/(protected)/(administrativo)/_services/g_usuario/GUsuarioLogin.ts index b2f5926..2699a22 100644 --- a/src/app/(protected)/(administrativo)/_services/g_usuario/GUsuarioLogin.ts +++ b/src/app/(protected)/(administrativo)/_services/g_usuario/GUsuarioLogin.ts @@ -6,7 +6,6 @@ import { import GUsuarioLoginData from "../../_data/g_usuario/GUsuarioLoginData" import { redirect } from "next/navigation"; -import empty from "@/actions/validations/empty"; export default async function GUsuarioLoginService(form: any) { diff --git a/src/app/(protected)/(cadastros)/cadastros/(t_tb_andamentoservico)/andamentos/page.tsx b/src/app/(protected)/(cadastros)/cadastros/(t_tb_andamentoservico)/andamentos/page.tsx index a11eecb..9d80a98 100644 --- a/src/app/(protected)/(cadastros)/cadastros/(t_tb_andamentoservico)/andamentos/page.tsx +++ b/src/app/(protected)/(cadastros)/cadastros/(t_tb_andamentoservico)/andamentos/page.tsx @@ -1,9 +1,7 @@ 'use client'; import { useEffect, useState, useCallback } from "react"; -import { Button } from "@/components/ui/button"; 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_andamentoservico/TTBAndamentoServicoTable"; @@ -17,6 +15,7 @@ import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDia import TTBAndamentoServicoInterface from "../../_interfaces/TTBAndamentoServicoInterface"; import { useTTBAndamentoServicoDeleteHook } from "../../_hooks/t_tb_andamentoservico/useTTBAndamentoServicoDeleteHook"; +import Header from "@/app/_components/structure/Header"; export default function TTBAndamentoServico() { // Hooks para leitura e salvamento @@ -125,20 +124,12 @@ export default function TTBAndamentoServico() { return (
{/* Cabeçalho */} -
-
-

- Andamentos -

-

- Gerenciamento de tipos de reconhecimentos -

-
- -
+
{ handleOpenForm(null) }} + /> {/* Tabela de andamentos */} @@ -171,5 +162,5 @@ export default function TTBAndamentoServico() { onSave={handleSave} />
- );4 + ); 4 } \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/(t_tb_reconhecimentotipo)/reconhecimentos/page.tsx b/src/app/(protected)/(cadastros)/cadastros/(t_tb_reconhecimentotipo)/reconhecimentos/page.tsx index 2372e32..6f66b36 100644 --- a/src/app/(protected)/(cadastros)/cadastros/(t_tb_reconhecimentotipo)/reconhecimentos/page.tsx +++ b/src/app/(protected)/(cadastros)/cadastros/(t_tb_reconhecimentotipo)/reconhecimentos/page.tsx @@ -1,11 +1,10 @@ 'use client'; import { useEffect, useState, useCallback } from "react"; -import { Button } from "@/components/ui/button"; import { Card, CardContent } from "@/components/ui/card"; -import { PlusIcon } from "lucide-react"; import Loading from "@/app/_components/loading/loading"; +import Header from "@/app/_components/structure/Header"; import TTBReconhecimentoTipoTable from "../../_components/t_tb_reconhecimentotipo/TTBReconhecimentoTipoTable"; import TTBReconhecimentoTipoForm from "../../_components/t_tb_reconhecimentotipo/TTBReconhecimentoTipoForm"; @@ -126,20 +125,12 @@ export default function TTBAndamentoServico() { return (
{/* Cabeçalho */} -
-
-

- Reconhecimentos -

-

- Gerenciamento de tipos de reconhecimentos -

-
- -
+
{ handleOpenForm(null) }} + /> {/* Tabela de andamentos */} diff --git a/src/app/(protected)/(servicos)/servicos/page.tsx b/src/app/(protected)/(servicos)/servicos/page.tsx new file mode 100644 index 0000000..ebfcd9d --- /dev/null +++ b/src/app/(protected)/(servicos)/servicos/page.tsx @@ -0,0 +1,88 @@ +'use client' + +import { Card, CardAction, CardContent, CardDescription, CardTitle } from "@/components/ui/card" +import { BabyIcon, CrossIcon, FileCheckIcon, FileTextIcon, GavelIcon, GlobeIcon, HeartIcon, PenIcon, ScrollIcon, UsersIcon } from "lucide-react"; + +const services = [ + { + title: 'Registro de Nascimento', + description: 'Emissão e registro de certidões de nascimento, garantindo a cidadania e identidade legal do recém-nascido.', + icon: BabyIcon + }, + { + title: 'Registro de Casamento', + description: 'Processo completo para habilitação, registro e emissão da certidão de casamento.', + icon: HeartIcon + }, + { + title: 'Registro de Óbito', + description: 'Lavratura do registro de óbito e emissão da certidão correspondente para fins legais.', + icon: CrossIcon + }, + { + title: 'Reconhecimento de Firma', + description: 'Autenticação da assinatura de documentos, garantindo sua validade jurídica.', + icon: PenIcon + }, + { + title: 'Autenticação de Documentos', + description: 'Confirmação de que cópias estão de acordo com o documento original apresentado.', + icon: FileCheckIcon + }, + { + title: 'Procurações', + description: 'Elaboração e registro de procurações públicas para representação legal de pessoas físicas ou jurídicas.', + icon: ScrollIcon + }, + { + title: 'Testamentos', + description: 'Lavratura e registro de testamentos públicos com segurança jurídica.', + icon: GavelIcon + }, + { + title: 'Divórcio Extrajudicial', + description: 'Formalização do divórcio por via administrativa, de forma rápida e sem processo judicial.', + icon: UsersIcon + }, + { + title: 'Apostilamento de Documentos', + description: 'Apostilamento conforme a Convenção da Haia para validade internacional de documentos.', + icon: GlobeIcon + }, + { + title: 'Certidões e Segunda Via', + description: 'Emissão de segundas vias e certidões de nascimento, casamento e óbito.', + icon: FileTextIcon + } +]; + +export default function ServicosPage() { + return ( +
+
+

Bem-vindo(a)!

+

+ Olá, Keven! É um prazer ter você conosco. +

+
+
+ {services.map((item: any, index) => ( + + +
+ +
+ + + {item.title} + + + {item.description} + +
+
+ ))} +
+
+ ) +} \ No newline at end of file diff --git a/src/app/_components/confirm_dialog/ConfirmDialog.tsx b/src/app/_components/confirm_dialog/ConfirmDialog.tsx index f72a3eb..e24cfd3 100644 --- a/src/app/_components/confirm_dialog/ConfirmDialog.tsx +++ b/src/app/_components/confirm_dialog/ConfirmDialog.tsx @@ -64,11 +64,9 @@ export default function ConfirmDialog({ {description} )} -
{message}
- {cancelText} diff --git a/src/app/_components/structure/Header.tsx b/src/app/_components/structure/Header.tsx new file mode 100644 index 0000000..c8c02e6 --- /dev/null +++ b/src/app/_components/structure/Header.tsx @@ -0,0 +1,33 @@ +import { Button } from "@/components/ui/button"; +import { PlusIcon } from "lucide-react"; + +interface HeaderProps { + + title: string, + description: string, + buttonText: string, + buttonAction: (...args: any[]) => void; +}; + +export default function Header({ title, description, buttonText, buttonAction }: HeaderProps) { + + return ( +
+
+
+

+ {title} +

+

+ {description} +

+
+ +
+
+ ); + +} \ No newline at end of file diff --git a/src/components/app-sidebar.tsx b/src/components/app-sidebar.tsx index 0460464..a037aff 100644 --- a/src/components/app-sidebar.tsx +++ b/src/components/app-sidebar.tsx @@ -8,6 +8,7 @@ import { Command, Frame, GalleryVerticalEnd, + House, Map, PieChart, Settings2, @@ -51,6 +52,18 @@ const data = { }, ], navMain: [ + { + title: "Início", + url: "#", + icon: House, + isActive: false, + items: [ + { + title: "Serviços", + url: "/servicos/", + }, + ], + }, { title: "Administrativo", url: "#",