format(Prettier): Configuração e Execução do prettier como formatador de código
This commit is contained in:
parent
b91ce54475
commit
8579387c53
301 changed files with 7911 additions and 9093 deletions
33
.eslintrc.json
Normal file
33
.eslintrc.json
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
// .eslintrc.json
|
||||
{
|
||||
"extends": [
|
||||
// 1. Configurações base do Next/React
|
||||
"next/core-web-vitals",
|
||||
// 2. Regras para ordenar e gerenciar importações
|
||||
"plugin:import/recommended",
|
||||
// 3. DESATIVA as regras do ESLint que conflitam com o Prettier (DEVE SER O ÚLTIMO)
|
||||
"prettier"
|
||||
],
|
||||
"plugins": ["import"],
|
||||
"rules": {
|
||||
/* --- Qualidade do Código (Next.js/React) --- */
|
||||
// Essa regra (já incluída no Next.js, mas bom reforçar) é a que remove imports não usados
|
||||
"no-unused-vars": "error",
|
||||
"react/jsx-uses-vars": "error",
|
||||
/* --- Ordem e Remoção de Importações (eslint-plugin-import) --- */
|
||||
// Configura a regra para a ordem das importações (groups/grupos)
|
||||
"import/order": [
|
||||
"error",
|
||||
{
|
||||
"groups": ["builtin", "external", "internal", "parent", "sibling", "index"],
|
||||
"newlines-between": "always",
|
||||
"alphabetize": {
|
||||
"order": "asc",
|
||||
"caseInsensitive": true
|
||||
}
|
||||
}
|
||||
],
|
||||
// Garante que o Next.js reconheça imports (como 'next/image', 'next/link')
|
||||
"import/no-unresolved": "error"
|
||||
}
|
||||
}
|
||||
9
.prettierrc
Normal file
9
.prettierrc
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"semi": true,
|
||||
"trailingComma": "all",
|
||||
"singleQuote": true,
|
||||
"printWidth": 100,
|
||||
"tabWidth": 2,
|
||||
"arrowParens": "always",
|
||||
"plugins": ["prettier-plugin-tailwindcss"]
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
import next from "eslint-config-next";
|
||||
import importPlugin from "eslint-plugin-import";
|
||||
import next from 'eslint-config-next';
|
||||
import importPlugin from 'eslint-plugin-import';
|
||||
|
||||
export default [
|
||||
next,
|
||||
|
|
@ -8,21 +8,16 @@ export default [
|
|||
import: importPlugin,
|
||||
},
|
||||
rules: {
|
||||
"import/order": [
|
||||
"error",
|
||||
'import/order': [
|
||||
'error',
|
||||
{
|
||||
groups: [
|
||||
"builtin",
|
||||
"external",
|
||||
"internal",
|
||||
["parent", "sibling", "index"],
|
||||
],
|
||||
"newlines-between": "always",
|
||||
alphabetize: { order: "asc", caseInsensitive: true },
|
||||
groups: ['builtin', 'external', 'internal', ['parent', 'sibling', 'index']],
|
||||
'newlines-between': 'always',
|
||||
alphabetize: { order: 'asc', caseInsensitive: true },
|
||||
},
|
||||
],
|
||||
semi: ["error", "always"],
|
||||
quotes: ["error", "double"],
|
||||
semi: ['error', 'always'],
|
||||
quotes: ['error', 'double'],
|
||||
},
|
||||
},
|
||||
];
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import type { NextConfig } from "next";
|
||||
import type { NextConfig } from 'next';
|
||||
|
||||
const nextConfig: NextConfig = {
|
||||
// Isso gera um diretório otimizado que inclui tudo o que a aplicação precisa para rodar
|
||||
output: "standalone",
|
||||
output: 'standalone',
|
||||
};
|
||||
|
||||
export default nextConfig;
|
||||
|
|
|
|||
|
|
@ -7,7 +7,9 @@
|
|||
"dev": "next dev --turbopack",
|
||||
"build": "next build",
|
||||
"start": "next start",
|
||||
"lint": "next lint"
|
||||
"lint": "next lint",
|
||||
"lint:fix": "npm run lint -- --fix",
|
||||
"format": "prettier --write . --ignore-path .gitignore"
|
||||
},
|
||||
"dependencies": {
|
||||
"@faker-js/faker": "^10.0.0",
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
const config = {
|
||||
plugins: ["@tailwindcss/postcss"],
|
||||
plugins: ['@tailwindcss/postcss'],
|
||||
};
|
||||
|
||||
export default config;
|
||||
|
|
|
|||
|
|
@ -5,10 +5,10 @@
|
|||
* @returns CNPJ formatado ou string parcial se incompleto
|
||||
*/
|
||||
export function FormatCNPJ(value: string | number): string {
|
||||
if (!value) return "";
|
||||
if (!value) return '';
|
||||
|
||||
// Converte para string e remove tudo que não seja número
|
||||
const digits = String(value).replace(/\D/g, "");
|
||||
const digits = String(value).replace(/\D/g, '');
|
||||
|
||||
// Garante que tenha no máximo 14 dígitos
|
||||
const cleanValue = digits.slice(0, 14);
|
||||
|
|
@ -16,8 +16,5 @@ export function FormatCNPJ(value: string | number): string {
|
|||
// Retorna parcialmente formatado se ainda não tiver 14 dígitos
|
||||
if (cleanValue.length < 14) return cleanValue;
|
||||
|
||||
return cleanValue.replace(
|
||||
/(\d{2})(\d{3})(\d{3})(\d{4})(\d{2})/,
|
||||
"$1.$2.$3/$4-$5",
|
||||
);
|
||||
return cleanValue.replace(/(\d{2})(\d{3})(\d{3})(\d{4})(\d{2})/, '$1.$2.$3/$4-$5');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,10 +5,10 @@
|
|||
* @returns CPF formatado ou string vazia se inválido
|
||||
*/
|
||||
export function FormatCPF(value: string | number): string {
|
||||
if (!value) return "";
|
||||
if (!value) return '';
|
||||
|
||||
// Converte para string e remove tudo que não seja número
|
||||
const digits = String(value).replace(/\D/g, "");
|
||||
const digits = String(value).replace(/\D/g, '');
|
||||
|
||||
// Garante que tenha no máximo 11 dígitos
|
||||
const cleanValue = digits.slice(0, 11);
|
||||
|
|
@ -16,5 +16,5 @@ export function FormatCPF(value: string | number): string {
|
|||
// Retorna formatado ou vazio se não tiver tamanho suficiente
|
||||
if (cleanValue.length !== 11) return cleanValue;
|
||||
|
||||
return cleanValue.replace(/(\d{3})(\d{3})(\d{3})(\d{2})/, "$1.$2.$3-$4");
|
||||
return cleanValue.replace(/(\d{3})(\d{3})(\d{3})(\d{2})/, '$1.$2.$3-$4');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
"use server";
|
||||
'use server';
|
||||
|
||||
import { cookies } from "next/headers";
|
||||
import { cookies } from 'next/headers';
|
||||
|
||||
/**
|
||||
* Função para obter tokens do lado servidorde acordo com o nome informado
|
||||
|
|
|
|||
|
|
@ -9,21 +9,19 @@
|
|||
* @param value - Data ou hora em string, Date ou timestamp
|
||||
* @returns Data formatada no padrão DD/MM/YYYY HH:mm ou parcial
|
||||
*/
|
||||
export function FormatDateTime(
|
||||
value: string | Date | number | null | undefined,
|
||||
): string {
|
||||
if (!value) return "-";
|
||||
export function FormatDateTime(value: string | Date | number | null | undefined): string {
|
||||
if (!value) return '-';
|
||||
|
||||
let date: Date;
|
||||
|
||||
// Converte entrada para Date
|
||||
if (value instanceof Date) {
|
||||
date = value;
|
||||
} else if (typeof value === "number") {
|
||||
} else if (typeof value === 'number') {
|
||||
date = new Date(value);
|
||||
} else if (typeof value === "string") {
|
||||
} else if (typeof value === 'string') {
|
||||
// Remove caracteres extras e tenta criar Date
|
||||
const cleanValue = value.trim().replace(/[^0-9]/g, "");
|
||||
const cleanValue = value.trim().replace(/[^0-9]/g, '');
|
||||
|
||||
if (cleanValue.length === 8) {
|
||||
// DDMMYYYY
|
||||
|
|
@ -34,22 +32,22 @@ export function FormatDateTime(
|
|||
} else {
|
||||
// Tenta parse padrão
|
||||
const parsed = new Date(value);
|
||||
if (isNaN(parsed.getTime())) return "-";
|
||||
if (isNaN(parsed.getTime())) return '-';
|
||||
date = parsed;
|
||||
}
|
||||
} else {
|
||||
return "-";
|
||||
return '-';
|
||||
}
|
||||
|
||||
// Extrai partes da data
|
||||
const day = date.getDate().toString().padStart(2, "0");
|
||||
const month = (date.getMonth() + 1).toString().padStart(2, "0");
|
||||
const day = date.getDate().toString().padStart(2, '0');
|
||||
const month = (date.getMonth() + 1).toString().padStart(2, '0');
|
||||
const year = date.getFullYear();
|
||||
const hours = date.getHours().toString().padStart(2, "0");
|
||||
const minutes = date.getMinutes().toString().padStart(2, "0");
|
||||
const hours = date.getHours().toString().padStart(2, '0');
|
||||
const minutes = date.getMinutes().toString().padStart(2, '0');
|
||||
|
||||
// Monta string parcialmente, dependendo da hora estar disponível
|
||||
const hasTime = !(hours === "00" && minutes === "00");
|
||||
const hasTime = !(hours === '00' && minutes === '00');
|
||||
|
||||
return `${day}/${month}/${year}${hasTime ? ` ${hours}:${minutes}` : ""}`;
|
||||
return `${day}/${month}/${year}${hasTime ? ` ${hours}:${minutes}` : ''}`;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import appConfig from "../../config/app.json";
|
||||
import appConfig from '../../config/app.json';
|
||||
export default class Json {
|
||||
static execute() {
|
||||
return appConfig;
|
||||
|
|
|
|||
|
|
@ -10,13 +10,13 @@
|
|||
* @returns Telefone formatado ou "-" se vazio
|
||||
*/
|
||||
export function FormatPhone(value: string | number): string {
|
||||
if (!value) return "-";
|
||||
if (!value) return '-';
|
||||
|
||||
// Converte para string e remove tudo que não for número
|
||||
const digits = String(value).replace(/\D/g, "");
|
||||
const digits = String(value).replace(/\D/g, '');
|
||||
|
||||
// Se não tiver nada após limpar, retorna "-"
|
||||
if (digits.length === 0) return "-";
|
||||
if (digits.length === 0) return '-';
|
||||
|
||||
// Garante no máximo 11 dígitos
|
||||
const cleanValue = digits.slice(0, 11);
|
||||
|
|
@ -26,7 +26,7 @@ export function FormatPhone(value: string | number): string {
|
|||
// -------------------------------
|
||||
if (cleanValue.length <= 8) {
|
||||
// Até 8 dígitos → formato parcial
|
||||
return cleanValue.replace(/(\d{4})(\d{0,4})/, "$1-$2").replace(/-$/, "");
|
||||
return cleanValue.replace(/(\d{4})(\d{0,4})/, '$1-$2').replace(/-$/, '');
|
||||
}
|
||||
|
||||
// -------------------------------
|
||||
|
|
@ -34,16 +34,12 @@ export function FormatPhone(value: string | number): string {
|
|||
// -------------------------------
|
||||
if (cleanValue.length === 9 || cleanValue.length === 10) {
|
||||
// DDD + telefone de 8 dígitos
|
||||
return cleanValue
|
||||
.replace(/^(\d{2})(\d{4})(\d{0,4})$/, "($1) $2-$3")
|
||||
.replace(/-$/, "");
|
||||
return cleanValue.replace(/^(\d{2})(\d{4})(\d{0,4})$/, '($1) $2-$3').replace(/-$/, '');
|
||||
}
|
||||
|
||||
if (cleanValue.length === 11) {
|
||||
// DDD + telefone de 9 dígitos
|
||||
return cleanValue
|
||||
.replace(/^(\d{2})(\d{5})(\d{0,4})$/, "($1) $2-$3")
|
||||
.replace(/-$/, "");
|
||||
return cleanValue.replace(/^(\d{2})(\d{5})(\d{0,4})$/, '($1) $2-$3').replace(/-$/, '');
|
||||
}
|
||||
|
||||
// Caso genérico, se não cair em nenhuma regra
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
* @returns String com a primeira letra em maiúscula
|
||||
*/
|
||||
export default function GetCapitalize(text: string): string {
|
||||
if (!text) return "";
|
||||
if (!text) return '';
|
||||
|
||||
return text.charAt(0).toUpperCase() + text.slice(1).toLowerCase();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
export default function GetNameInitials(data?: string): string {
|
||||
if (!data) return "";
|
||||
if (!data) return '';
|
||||
|
||||
// Remove espaços extras no início e no fim e divide em palavras
|
||||
const palavras = data.trim().split(/\s+/);
|
||||
|
||||
if (palavras.length === 0) return "";
|
||||
if (palavras.length === 0) return '';
|
||||
|
||||
if (palavras.length === 1) {
|
||||
// Apenas uma palavra → retorna as duas primeiras letras
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
export default function GetSigla(data: string): string {
|
||||
if (!data) return "";
|
||||
if (!data) return '';
|
||||
|
||||
// Remove espaços extras no início e no fim e divide em palavras
|
||||
const palavras = data.trim().split(/\s+/);
|
||||
|
|
@ -10,5 +10,5 @@ export default function GetSigla(data: string): string {
|
|||
}
|
||||
|
||||
// Duas ou mais palavras → retorna a primeira letra de cada
|
||||
return palavras.map((palavra) => palavra.charAt(0).toUpperCase()).join("");
|
||||
return palavras.map((palavra) => palavra.charAt(0).toUpperCase()).join('');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
"use server";
|
||||
'use server';
|
||||
|
||||
import { cookies } from "next/headers";
|
||||
import { cookies } from 'next/headers';
|
||||
|
||||
export default async function TokenGet() {
|
||||
const cookieStore = await cookies();
|
||||
const token = cookieStore.get("access_token");
|
||||
const token = cookieStore.get('access_token');
|
||||
return token?.value;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,5 +5,5 @@
|
|||
* @returns true se estiver vazio, null ou undefined
|
||||
*/
|
||||
export default function empty(data: unknown): boolean {
|
||||
return data == null || data === "" || data === false;
|
||||
return data == null || data === '' || data === false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,10 @@
|
|||
import withClientErrorHandlerInterface from "./withClientErrorHandlerInterface";
|
||||
import withClientErrorHandlerInterface from './withClientErrorHandlerInterface';
|
||||
|
||||
/**
|
||||
* Códigos de erro que começam com 6, são do front entd, na ordem do alfabeto o F de frontend é a sexta letra
|
||||
*/
|
||||
export function withClientErrorHandler<
|
||||
T extends (...args: any[]) => Promise<any>,
|
||||
>(action: T) {
|
||||
return async (
|
||||
...args: Parameters<T>
|
||||
): Promise<withClientErrorHandlerInterface> => {
|
||||
export function withClientErrorHandler<T extends (...args: any[]) => Promise<any>>(action: T) {
|
||||
return async (...args: Parameters<T>): Promise<withClientErrorHandlerInterface> => {
|
||||
try {
|
||||
// Executa a função definida
|
||||
const data = await action(...args);
|
||||
|
|
@ -19,7 +15,7 @@ export function withClientErrorHandler<
|
|||
// Retorna o erro de execuçãformatado
|
||||
return {
|
||||
status: 600,
|
||||
message: error?.message || "Erro interno do servidor",
|
||||
message: error?.message || 'Erro interno do servidor',
|
||||
data: error,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
"use client";
|
||||
'use client';
|
||||
|
||||
import { useEffect } from "react";
|
||||
import { useParams } from "next/navigation";
|
||||
import { useEffect } from 'react';
|
||||
import { useParams } from 'next/navigation';
|
||||
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
import { useGUsuarioReadHooks } from "@/app/(protected)/(administrativo)/_hooks/g_usuario/useGUsuarioReadHooks";
|
||||
import Usuario from "@/app/(protected)/(administrativo)/_interfaces/GUsuarioInterface";
|
||||
import Loading from "@/app/_components/loading/loading";
|
||||
import { Card, CardContent } from '@/components/ui/card';
|
||||
import { useGUsuarioReadHooks } from '@/app/(protected)/(administrativo)/_hooks/g_usuario/useGUsuarioReadHooks';
|
||||
import Usuario from '@/app/(protected)/(administrativo)/_interfaces/GUsuarioInterface';
|
||||
import Loading from '@/app/_components/loading/loading';
|
||||
|
||||
export default function UsuarioDetalhes() {
|
||||
const params = useParams();
|
||||
|
|
@ -17,7 +17,7 @@ export default function UsuarioDetalhes() {
|
|||
if (params.id) {
|
||||
fetchUsuario({ usuario_id: Number(params.id) } as Usuario);
|
||||
}
|
||||
console.log("pagina", usuario);
|
||||
console.log('pagina', usuario);
|
||||
}, []);
|
||||
|
||||
if (!usuario) return <Loading type={1} />;
|
||||
|
|
@ -26,7 +26,7 @@ export default function UsuarioDetalhes() {
|
|||
<div>
|
||||
<Card>
|
||||
<CardContent>
|
||||
<div className="mb-4 grid gap-4 grid-cols-4">
|
||||
<div className="mb-4 grid grid-cols-4 gap-4">
|
||||
<div>
|
||||
<div className="text-2xl font-semibold">Nome</div>
|
||||
<div className="text-xl">{usuario?.nome_completo}</div>
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
"use client";
|
||||
'use client';
|
||||
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { z } from "zod";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { GUsuarioSchema } from "../../../_schemas/GUsuarioSchema";
|
||||
import { zodResolver } from '@hookform/resolvers/zod';
|
||||
import { useForm } from 'react-hook-form';
|
||||
import { z } from 'zod';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { GUsuarioSchema } from '../../../_schemas/GUsuarioSchema';
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Button } from '@/components/ui/button';
|
||||
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
import { Card, CardContent } from '@/components/ui/card';
|
||||
|
||||
import {
|
||||
Form,
|
||||
|
|
@ -17,9 +17,9 @@ import {
|
|||
FormItem,
|
||||
FormLabel,
|
||||
FormMessage,
|
||||
} from "@/components/ui/form";
|
||||
} from '@/components/ui/form';
|
||||
|
||||
import { useGUsuarioSaveHook } from "../../../_hooks/g_usuario/useGUsuarioSaveHook";
|
||||
import { useGUsuarioSaveHook } from '../../../_hooks/g_usuario/useGUsuarioSaveHook';
|
||||
|
||||
type FormValues = z.infer<typeof GUsuarioSchema>;
|
||||
|
||||
|
|
@ -29,11 +29,11 @@ export default function UsuarioFormularioPage() {
|
|||
const form = useForm<FormValues>({
|
||||
resolver: zodResolver(GUsuarioSchema),
|
||||
defaultValues: {
|
||||
login: "",
|
||||
nome_completo: "",
|
||||
funcao: "",
|
||||
email: "",
|
||||
cpf: "",
|
||||
login: '',
|
||||
nome_completo: '',
|
||||
funcao: '',
|
||||
email: '',
|
||||
cpf: '',
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
"use client";
|
||||
'use client';
|
||||
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
import { Card, CardContent } from '@/components/ui/card';
|
||||
|
||||
import {
|
||||
Table,
|
||||
|
|
@ -9,14 +9,14 @@ import {
|
|||
TableHead,
|
||||
TableHeader,
|
||||
TableRow,
|
||||
} from "@/components/ui/table";
|
||||
} from '@/components/ui/table';
|
||||
|
||||
import Usuario from "../../_interfaces/GUsuarioInterface";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import Link from "next/link";
|
||||
import { useGUsuarioIndexHook } from "../../_hooks/g_usuario/useGUsuarioIndexHook";
|
||||
import { useEffect } from "react";
|
||||
import Loading from "@/app/_components/loading/loading";
|
||||
import Usuario from '../../_interfaces/GUsuarioInterface';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import Link from 'next/link';
|
||||
import { useGUsuarioIndexHook } from '../../_hooks/g_usuario/useGUsuarioIndexHook';
|
||||
import { useEffect } from 'react';
|
||||
import Loading from '@/app/_components/loading/loading';
|
||||
|
||||
export default function UsuarioPage() {
|
||||
const { usuarios, fetchUsuarios } = useGUsuarioIndexHook();
|
||||
|
|
@ -54,15 +54,11 @@ export default function UsuarioPage() {
|
|||
<TableBody>
|
||||
{usuarios.map((usuario: Usuario) => (
|
||||
<TableRow key={usuario.usuario_id} className="cursor-pointer">
|
||||
<TableCell className="text-center">
|
||||
{usuario.usuario_id}
|
||||
</TableCell>
|
||||
<TableCell className="font-medium">
|
||||
{usuario.situacao}
|
||||
</TableCell>
|
||||
<TableCell className="text-center">{usuario.usuario_id}</TableCell>
|
||||
<TableCell className="font-medium">{usuario.situacao}</TableCell>
|
||||
<TableCell className="font-medium">{usuario.cpf}</TableCell>
|
||||
<TableCell>
|
||||
<div className="font-semibold text-xs">
|
||||
<div className="text-xs font-semibold">
|
||||
{usuario.login} - {usuario.sigla}
|
||||
</div>
|
||||
<div className="text-base">{usuario.nome_completo}</div>
|
||||
|
|
@ -72,9 +68,7 @@ export default function UsuarioPage() {
|
|||
</TableCell>
|
||||
<TableCell>
|
||||
<Button asChild>
|
||||
<Link href={`/usuarios/${usuario.usuario_id}/detalhes`}>
|
||||
Detalhes
|
||||
</Link>
|
||||
<Link href={`/usuarios/${usuario.usuario_id}/detalhes`}>Detalhes</Link>
|
||||
</Button>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
"use server";
|
||||
'use server';
|
||||
|
||||
import API from "@/services/api/Api";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
import API from '@/services/api/Api';
|
||||
import { Methods } from '@/services/api/enums/ApiMethodEnum';
|
||||
|
||||
export default async function GUsuarioDeleteData(usuarioId: number) {
|
||||
const api = new API();
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
"use server";
|
||||
'use server';
|
||||
|
||||
import API from "@/services/api/Api";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
import API from '@/services/api/Api';
|
||||
import { Methods } from '@/services/api/enums/ApiMethodEnum';
|
||||
|
||||
export default async function GUsuarioIndexData() {
|
||||
const api = new API();
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
"use server";
|
||||
'use server';
|
||||
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
import API from "@/services/api/Api";
|
||||
import { Methods } from '@/services/api/enums/ApiMethodEnum';
|
||||
import API from '@/services/api/Api';
|
||||
|
||||
export default async function GUsuarioLoginData(form: any) {
|
||||
const api = new API();
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
"use server";
|
||||
'use server';
|
||||
|
||||
import API from "@/services/api/Api";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
import API from '@/services/api/Api';
|
||||
import { Methods } from '@/services/api/enums/ApiMethodEnum';
|
||||
|
||||
export default async function GUsuarioReadData(usuarioId: number) {
|
||||
const api = new API();
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
"use server";
|
||||
'use server';
|
||||
|
||||
import API from "@/services/api/Api";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
import API from '@/services/api/Api';
|
||||
import { Methods } from '@/services/api/enums/ApiMethodEnum';
|
||||
|
||||
export default async function GUsuarioSaveData(form: any) {
|
||||
const api = new API();
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
"use client";
|
||||
'use client';
|
||||
|
||||
import { useState } from "react";
|
||||
import Usuario from "../../_interfaces/GUsuarioInterface";
|
||||
import GUsuarioIndex from "../../_services/g_usuario/GUsuarioIndex";
|
||||
import { useResponse } from "@/app/_response/ResponseContext";
|
||||
import { useState } from 'react';
|
||||
import Usuario from '../../_interfaces/GUsuarioInterface';
|
||||
import GUsuarioIndex from '../../_services/g_usuario/GUsuarioIndex';
|
||||
import { useResponse } from '@/app/_response/ResponseContext';
|
||||
|
||||
export const useGUsuarioIndexHook = () => {
|
||||
const { setResponse } = useResponse();
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
"use client";
|
||||
'use client';
|
||||
|
||||
import GUsuarioLogoutService from "../../_services/g_usuario/GUsuarioLogoutService";
|
||||
import GUsuarioLogoutService from '../../_services/g_usuario/GUsuarioLogoutService';
|
||||
|
||||
export const useGUsuarioLogoutHook = () => {
|
||||
const logoutUsuario = async () => {
|
||||
await GUsuarioLogoutService("access_token");
|
||||
await GUsuarioLogoutService('access_token');
|
||||
};
|
||||
|
||||
return { logoutUsuario };
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
"use client";
|
||||
'use client';
|
||||
|
||||
import { useState } from "react";
|
||||
import Usuario from "../../_interfaces/GUsuarioInterface";
|
||||
import GUsuarioRead from "../../_services/g_usuario/GUsuarioRead";
|
||||
import { useResponse } from "@/app/_response/ResponseContext";
|
||||
import { useState } from 'react';
|
||||
import Usuario from '../../_interfaces/GUsuarioInterface';
|
||||
import GUsuarioRead from '../../_services/g_usuario/GUsuarioRead';
|
||||
import { useResponse } from '@/app/_response/ResponseContext';
|
||||
|
||||
export const useGUsuarioReadHooks = () => {
|
||||
const { setResponse } = useResponse();
|
||||
|
|
@ -12,7 +12,7 @@ export const useGUsuarioReadHooks = () => {
|
|||
|
||||
const fetchUsuario = async (Usuario: Usuario) => {
|
||||
const response = await GUsuarioRead(Usuario.usuario_id);
|
||||
console.log("hook", response.data);
|
||||
console.log('hook', response.data);
|
||||
|
||||
setUsuario(response.data);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
"use client";
|
||||
'use client';
|
||||
|
||||
import { useState } from "react";
|
||||
import Usuario from "../../_interfaces/GUsuarioInterface";
|
||||
import GUsuarioSave from "../../_services/g_usuario/GUsuarioSave";
|
||||
import { useResponse } from "@/app/_response/ResponseContext";
|
||||
import { useState } from 'react';
|
||||
import Usuario from '../../_interfaces/GUsuarioInterface';
|
||||
import GUsuarioSave from '../../_services/g_usuario/GUsuarioSave';
|
||||
import { useResponse } from '@/app/_response/ResponseContext';
|
||||
|
||||
export const useGUsuarioSaveHook = () => {
|
||||
const { setResponse } = useResponse();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { z } from "zod";
|
||||
import { z } from 'zod';
|
||||
|
||||
export const GUsuarioLoginSchema = z.object({
|
||||
login: z.string().min(1, "O campo deve ser preenchido"),
|
||||
senha_api: z.string().min(1, "O campo deve ser preenchido"),
|
||||
login: z.string().min(1, 'O campo deve ser preenchido'),
|
||||
senha_api: z.string().min(1, 'O campo deve ser preenchido'),
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { z } from "zod";
|
||||
import { z } from 'zod';
|
||||
|
||||
export const GUsuarioSchema = z.object({
|
||||
trocarsenha: z.string().optional(),
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
"use server";
|
||||
'use server';
|
||||
|
||||
import GUsuarioIndexData from "../../_data/g_usuario/GUsuarioIndexData";
|
||||
import GUsuarioIndexData from '../../_data/g_usuario/GUsuarioIndexData';
|
||||
|
||||
export default async function GUsuarioIndex() {
|
||||
const response = await GUsuarioIndexData();
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
"use server";
|
||||
'use server';
|
||||
|
||||
import { cookies } from "next/headers";
|
||||
import { cookies } from 'next/headers';
|
||||
|
||||
import GUsuarioLoginData from "../../_data/g_usuario/GUsuarioLoginData";
|
||||
import { redirect } from "next/navigation";
|
||||
import GUsuarioLoginData from '../../_data/g_usuario/GUsuarioLoginData';
|
||||
import { redirect } from 'next/navigation';
|
||||
|
||||
export default async function GUsuarioLoginService(form: any) {
|
||||
// Obtem a resposta da requisição
|
||||
|
|
@ -13,7 +13,7 @@ export default async function GUsuarioLoginService(form: any) {
|
|||
if (response.data.usuario_id <= 0) {
|
||||
return {
|
||||
code: 404,
|
||||
message: "Não foi localizado o usuário",
|
||||
message: 'Não foi localizado o usuário',
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -21,14 +21,14 @@ export default async function GUsuarioLoginService(form: any) {
|
|||
const cookieStore = await cookies();
|
||||
|
||||
// Cria um novo cookie
|
||||
cookieStore.set("access_token", response.data.token, {
|
||||
cookieStore.set('access_token', response.data.token, {
|
||||
httpOnly: true,
|
||||
secure: process.env.NODE_ENV === "production",
|
||||
sameSite: "strict",
|
||||
path: "/",
|
||||
secure: process.env.NODE_ENV === 'production',
|
||||
sameSite: 'strict',
|
||||
path: '/',
|
||||
maxAge: 60 * 60 * 24,
|
||||
});
|
||||
|
||||
// Redireciona para a págian desejada
|
||||
redirect("/servicos");
|
||||
redirect('/servicos');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
"use server";
|
||||
'use server';
|
||||
|
||||
import { cookies } from "next/headers";
|
||||
import { cookies } from 'next/headers';
|
||||
|
||||
import { redirect } from "next/navigation";
|
||||
import { redirect } from 'next/navigation';
|
||||
|
||||
export default async function GUsuarioLogoutService(token: string) {
|
||||
const cookieStore = await cookies();
|
||||
cookieStore.set(token, "", {
|
||||
cookieStore.set(token, '', {
|
||||
expires: new Date(0),
|
||||
path: "/",
|
||||
path: '/',
|
||||
});
|
||||
|
||||
redirect("/login");
|
||||
redirect('/login');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,19 +1,19 @@
|
|||
"use server";
|
||||
'use server';
|
||||
|
||||
import GUsuarioReadData from "../../_data/g_usuario/GUsuarioReadData";
|
||||
import GUsuarioReadData from '../../_data/g_usuario/GUsuarioReadData';
|
||||
|
||||
export default async function GUsuarioRead(usuarioId: number) {
|
||||
// Verifica se o id informado é válido
|
||||
if (usuarioId <= 0) {
|
||||
return {
|
||||
code: 400,
|
||||
message: "Usuário informado inválido",
|
||||
message: 'Usuário informado inválido',
|
||||
};
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await GUsuarioReadData(usuarioId);
|
||||
console.log("service", response);
|
||||
console.log('service', response);
|
||||
return response;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
"use server";
|
||||
'use server';
|
||||
|
||||
import GUsuarioSaveData from "../../_data/g_usuario/GUsuarioSaveData";
|
||||
import GUsuarioSaveData from '../../_data/g_usuario/GUsuarioSaveData';
|
||||
|
||||
export default async function GUsuarioSave(form: any) {
|
||||
return await GUsuarioSaveData(form);
|
||||
|
|
|
|||
|
|
@ -1,21 +1,21 @@
|
|||
"use client";
|
||||
'use client';
|
||||
|
||||
import { useEffect, useState, useCallback } from "react";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
import { useEffect, useState, useCallback } from 'react';
|
||||
import { Card, CardContent } from '@/components/ui/card';
|
||||
|
||||
import Loading from "@/app/_components/loading/loading";
|
||||
import GCidadeTable from "../../_components/g_cidade/GCidadeTable";
|
||||
import GCidadeForm from "../../_components/g_cidade/GCidadeForm";
|
||||
import Loading from '@/app/_components/loading/loading';
|
||||
import GCidadeTable from '../../_components/g_cidade/GCidadeTable';
|
||||
import GCidadeForm from '../../_components/g_cidade/GCidadeForm';
|
||||
|
||||
import { useGCidadeReadHook } from "../../_hooks/g_cidade/useGCidadeReadHook";
|
||||
import { useGCidadeSaveHook } from "../../_hooks/g_cidade/useGCidadeSaveHook";
|
||||
import { useGCidadeRemoveHook } from "../../_hooks/g_cidade/useGCidadeRemoveHook";
|
||||
import { useGCidadeReadHook } from '../../_hooks/g_cidade/useGCidadeReadHook';
|
||||
import { useGCidadeSaveHook } from '../../_hooks/g_cidade/useGCidadeSaveHook';
|
||||
import { useGCidadeRemoveHook } from '../../_hooks/g_cidade/useGCidadeRemoveHook';
|
||||
|
||||
import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog";
|
||||
import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDialog";
|
||||
import ConfirmDialog from '@/app/_components/confirm_dialog/ConfirmDialog';
|
||||
import { useConfirmDialog } from '@/app/_components/confirm_dialog/useConfirmDialog';
|
||||
|
||||
import GCidadeInterface from "../../_interfaces/GCidadeInterface";
|
||||
import Header from "@/app/_components/structure/Header";
|
||||
import GCidadeInterface from '../../_interfaces/GCidadeInterface';
|
||||
import Header from '@/app/_components/structure/Header';
|
||||
|
||||
export default function GCidadePage() {
|
||||
// Hooks para leitura e salvamento
|
||||
|
|
@ -24,15 +24,11 @@ export default function GCidadePage() {
|
|||
const { removeGCidade } = useGCidadeRemoveHook();
|
||||
|
||||
// Estados
|
||||
const [selectedCidade, setSelectedCidade] = useState<GCidadeInterface | null>(
|
||||
null,
|
||||
);
|
||||
const [selectedCidade, setSelectedCidade] = useState<GCidadeInterface | null>(null);
|
||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||
|
||||
// Estado para saber qual item será deletado
|
||||
const [itemToDelete, setItemToDelete] = useState<GCidadeInterface | null>(
|
||||
null,
|
||||
);
|
||||
const [itemToDelete, setItemToDelete] = useState<GCidadeInterface | null>(null);
|
||||
|
||||
/**
|
||||
* Hook do modal de confirmação
|
||||
|
|
@ -126,9 +122,9 @@ export default function GCidadePage() {
|
|||
<div>
|
||||
{/* Cabeçalho */}
|
||||
<Header
|
||||
title={"Cidades"}
|
||||
description={"Gerenciamento de Cidades"}
|
||||
buttonText={"Nova Cidade"}
|
||||
title={'Cidades'}
|
||||
description={'Gerenciamento de Cidades'}
|
||||
buttonText={'Nova Cidade'}
|
||||
buttonAction={() => {
|
||||
handleOpenForm(null);
|
||||
}}
|
||||
|
|
@ -137,11 +133,7 @@ export default function GCidadePage() {
|
|||
{/* Tabela de andamentos */}
|
||||
<Card>
|
||||
<CardContent>
|
||||
<GCidadeTable
|
||||
data={gCidade}
|
||||
onEdit={handleOpenForm}
|
||||
onDelete={handleConfirmDelete}
|
||||
/>
|
||||
<GCidadeTable data={gCidade} onEdit={handleOpenForm} onDelete={handleConfirmDelete} />
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,27 +1,27 @@
|
|||
"use client";
|
||||
'use client';
|
||||
|
||||
import { useEffect, useState, useCallback } from "react";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDialog";
|
||||
import { useResponse } from "@/app/_response/ResponseContext";
|
||||
import { useEffect, useState, useCallback } from 'react';
|
||||
import { Card, CardContent } from '@/components/ui/card';
|
||||
import { useConfirmDialog } from '@/app/_components/confirm_dialog/useConfirmDialog';
|
||||
import { useResponse } from '@/app/_response/ResponseContext';
|
||||
|
||||
import Header from "@/app/_components/structure/Header";
|
||||
import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog";
|
||||
import Loading from "@/app/_components/loading/loading";
|
||||
import GMedidaTipoTable from "../../_components/g_medidatipo/GMedidaTipoTable";
|
||||
import GMedidaTipoForm from "../../_components/g_medidatipo/GMedidaTipoForm";
|
||||
import Header from '@/app/_components/structure/Header';
|
||||
import ConfirmDialog from '@/app/_components/confirm_dialog/ConfirmDialog';
|
||||
import Loading from '@/app/_components/loading/loading';
|
||||
import GMedidaTipoTable from '../../_components/g_medidatipo/GMedidaTipoTable';
|
||||
import GMedidaTipoForm from '../../_components/g_medidatipo/GMedidaTipoForm';
|
||||
|
||||
import { useGMedidaTipoReadHook } from "../../_hooks/g_medidatipo/useGMedidaTipoReadHook";
|
||||
import { useGMedidaTipoSaveHook } from "../../_hooks/g_medidatipo/useGMedidaTipoSaveHook";
|
||||
import { useGMedidaTipoRemoveHook } from "../../_hooks/g_medidatipo/useGMedidaTipoRemoveHook";
|
||||
import { useGMedidaTipoReadHook } from '../../_hooks/g_medidatipo/useGMedidaTipoReadHook';
|
||||
import { useGMedidaTipoSaveHook } from '../../_hooks/g_medidatipo/useGMedidaTipoSaveHook';
|
||||
import { useGMedidaTipoRemoveHook } from '../../_hooks/g_medidatipo/useGMedidaTipoRemoveHook';
|
||||
|
||||
import { GMedidaTipoInterface } from "../../_interfaces/GMedidaTipoInterface";
|
||||
import { SituacoesEnum } from "@/enums/SituacoesEnum";
|
||||
import { GMedidaTipoInterface } from '../../_interfaces/GMedidaTipoInterface';
|
||||
import { SituacoesEnum } from '@/enums/SituacoesEnum';
|
||||
|
||||
const initialMedidaTipo: GMedidaTipoInterface = {
|
||||
medida_tipo_id: 0,
|
||||
sigla: "",
|
||||
descricao: "",
|
||||
sigla: '',
|
||||
descricao: '',
|
||||
};
|
||||
|
||||
export default function GMedidaTipoPage() {
|
||||
|
|
@ -37,19 +37,12 @@ export default function GMedidaTipoPage() {
|
|||
const { removeGMedidaTipo } = useGMedidaTipoRemoveHook();
|
||||
|
||||
// Estado para controlar o formulário e o item selecionado
|
||||
const [selectedMedidaTipo, setSelectedMedidaTipo] =
|
||||
useState<GMedidaTipoInterface | null>(null);
|
||||
const [selectedMedidaTipo, setSelectedMedidaTipo] = useState<GMedidaTipoInterface | null>(null);
|
||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||
const [itemToDelete, setItemToDelete] = useState<GMedidaTipoInterface | null>(
|
||||
null,
|
||||
);
|
||||
const [itemToDelete, setItemToDelete] = useState<GMedidaTipoInterface | null>(null);
|
||||
|
||||
// Hook para o modal de confirmação
|
||||
const {
|
||||
isOpen: isConfirmOpen,
|
||||
openDialog: openConfirmDialog,
|
||||
handleCancel,
|
||||
} = useConfirmDialog();
|
||||
const { isOpen: isConfirmOpen, openDialog: openConfirmDialog, handleCancel } = useConfirmDialog();
|
||||
|
||||
// Ações do formulário
|
||||
const handleOpenForm = useCallback((data: GMedidaTipoInterface | null) => {
|
||||
|
|
@ -90,7 +83,7 @@ export default function GMedidaTipoPage() {
|
|||
// Define os dados da resposta visual
|
||||
setResponse({
|
||||
status: 400,
|
||||
message: "Não foi informado um registro para exclusão",
|
||||
message: 'Não foi informado um registro para exclusão',
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
|
@ -114,9 +107,9 @@ export default function GMedidaTipoPage() {
|
|||
<div>
|
||||
{/* Cabeçalho */}
|
||||
<Header
|
||||
title={"Tipos de Medida"}
|
||||
description={"Gerenciamento de tipos de medida"}
|
||||
buttonText={"Novo Tipo de Medida"}
|
||||
title={'Tipos de Medida'}
|
||||
description={'Gerenciamento de tipos de medida'}
|
||||
buttonText={'Novo Tipo de Medida'}
|
||||
buttonAction={(data) => {
|
||||
handleOpenForm((data = initialMedidaTipo));
|
||||
}}
|
||||
|
|
|
|||
|
|
@ -1,27 +1,27 @@
|
|||
"use client";
|
||||
'use client';
|
||||
|
||||
import { useEffect, useState, useCallback } from "react";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDialog";
|
||||
import { useResponse } from "@/app/_response/ResponseContext";
|
||||
import { useEffect, useState, useCallback } from 'react';
|
||||
import { Card, CardContent } from '@/components/ui/card';
|
||||
import { useConfirmDialog } from '@/app/_components/confirm_dialog/useConfirmDialog';
|
||||
import { useResponse } from '@/app/_response/ResponseContext';
|
||||
|
||||
import Header from "@/app/_components/structure/Header";
|
||||
import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog";
|
||||
import Loading from "@/app/_components/loading/loading";
|
||||
import GTBBairroTable from "../../_components/g_tb_bairro/GTBBairroTable";
|
||||
import GTBBairroForm from "../../_components/g_tb_bairro/GTBBairroForm";
|
||||
import Header from '@/app/_components/structure/Header';
|
||||
import ConfirmDialog from '@/app/_components/confirm_dialog/ConfirmDialog';
|
||||
import Loading from '@/app/_components/loading/loading';
|
||||
import GTBBairroTable from '../../_components/g_tb_bairro/GTBBairroTable';
|
||||
import GTBBairroForm from '../../_components/g_tb_bairro/GTBBairroForm';
|
||||
|
||||
import { useGTBBairroReadHook } from "../../_hooks/g_tb_bairro/useGTBBairroReadHook";
|
||||
import { useGTBBairroSaveHook } from "../../_hooks/g_tb_bairro/useGTBBairroSaveHook";
|
||||
import { useGTBBairroRemoveHook } from "../../_hooks/g_tb_bairro/useGTBBairroRemoveHook";
|
||||
import { useGTBBairroReadHook } from '../../_hooks/g_tb_bairro/useGTBBairroReadHook';
|
||||
import { useGTBBairroSaveHook } from '../../_hooks/g_tb_bairro/useGTBBairroSaveHook';
|
||||
import { useGTBBairroRemoveHook } from '../../_hooks/g_tb_bairro/useGTBBairroRemoveHook';
|
||||
|
||||
import { GTBBairroInterface } from "../../_interfaces/GTBBairroInterface";
|
||||
import { SituacoesEnum } from "@/enums/SituacoesEnum";
|
||||
import { GTBBairroInterface } from '../../_interfaces/GTBBairroInterface';
|
||||
import { SituacoesEnum } from '@/enums/SituacoesEnum';
|
||||
|
||||
const initialBairro: GTBBairroInterface = {
|
||||
sistema_id: null,
|
||||
tb_bairro_id: 0,
|
||||
descricao: "",
|
||||
descricao: '',
|
||||
situacao: SituacoesEnum.A,
|
||||
};
|
||||
|
||||
|
|
@ -40,16 +40,10 @@ export default function GTBBairroPage() {
|
|||
// Estado para controlar o formulário e item selecionado
|
||||
const [selectedBairro, setBairro] = useState<GTBBairroInterface | null>(null);
|
||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||
const [itemToDelete, setItemToDelete] = useState<GTBBairroInterface | null>(
|
||||
null,
|
||||
);
|
||||
const [itemToDelete, setItemToDelete] = useState<GTBBairroInterface | null>(null);
|
||||
|
||||
// Hook para o modal de confirmação
|
||||
const {
|
||||
isOpen: isConfirmOpen,
|
||||
openDialog: openConfirmDialog,
|
||||
handleCancel,
|
||||
} = useConfirmDialog();
|
||||
const { isOpen: isConfirmOpen, openDialog: openConfirmDialog, handleCancel } = useConfirmDialog();
|
||||
|
||||
// Ações do formulário
|
||||
const handleOpenForm = useCallback((data: GTBBairroInterface | null) => {
|
||||
|
|
@ -94,7 +88,7 @@ export default function GTBBairroPage() {
|
|||
// Define os dados da resposta visual
|
||||
setResponse({
|
||||
status: 400,
|
||||
message: "Não foi informado um registro para exclusão",
|
||||
message: 'Não foi informado um registro para exclusão',
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
|
@ -127,9 +121,9 @@ export default function GTBBairroPage() {
|
|||
<div>
|
||||
{/* Cabeçalho */}
|
||||
<Header
|
||||
title={"Bairros"}
|
||||
description={"Gerenciamento de Bairros"}
|
||||
buttonText={"Novo Bairro"}
|
||||
title={'Bairros'}
|
||||
description={'Gerenciamento de Bairros'}
|
||||
buttonText={'Novo Bairro'}
|
||||
buttonAction={(data) => {
|
||||
handleOpenForm((data = initialBairro));
|
||||
}}
|
||||
|
|
@ -138,11 +132,7 @@ export default function GTBBairroPage() {
|
|||
{/* Tabela de Bairros */}
|
||||
<Card>
|
||||
<CardContent>
|
||||
<GTBBairroTable
|
||||
data={gTBBairro}
|
||||
onEdit={handleOpenForm}
|
||||
onDelete={handleConfirmDelete}
|
||||
/>
|
||||
<GTBBairroTable data={gTBBairro} onEdit={handleOpenForm} onDelete={handleConfirmDelete} />
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,27 +1,27 @@
|
|||
"use client";
|
||||
'use client';
|
||||
|
||||
import { useEffect, useState, useCallback } from "react";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDialog";
|
||||
import { useEffect, useState, useCallback } from 'react';
|
||||
import { Card, CardContent } from '@/components/ui/card';
|
||||
import { useConfirmDialog } from '@/app/_components/confirm_dialog/useConfirmDialog';
|
||||
|
||||
import Header from "@/app/_components/structure/Header";
|
||||
import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog";
|
||||
import Loading from "@/app/_components/loading/loading";
|
||||
import GTBEstadoCivilTable from "../../_components/g_tb_estadocivil/GTBEstadoCivilTable";
|
||||
import GTBEstadoCivilForm from "../../_components/g_tb_estadocivil/GTBEstadoCivilForm";
|
||||
import Header from '@/app/_components/structure/Header';
|
||||
import ConfirmDialog from '@/app/_components/confirm_dialog/ConfirmDialog';
|
||||
import Loading from '@/app/_components/loading/loading';
|
||||
import GTBEstadoCivilTable from '../../_components/g_tb_estadocivil/GTBEstadoCivilTable';
|
||||
import GTBEstadoCivilForm from '../../_components/g_tb_estadocivil/GTBEstadoCivilForm';
|
||||
|
||||
import { useGTBEstadoCivilReadHook } from "../../_hooks/g_tb_estadocivil/useGTBEstadoCivilReadHook";
|
||||
import { useGTBEstadoCivilSaveHook } from "../../_hooks/g_tb_estadocivil/useGTBEstadoCivilSaveHook";
|
||||
import { useGTBEstadoCivilRemoveHook } from "../../_hooks/g_tb_estadocivil/useGTBEstadoCivilRemoveHook";
|
||||
import { useGTBEstadoCivilReadHook } from '../../_hooks/g_tb_estadocivil/useGTBEstadoCivilReadHook';
|
||||
import { useGTBEstadoCivilSaveHook } from '../../_hooks/g_tb_estadocivil/useGTBEstadoCivilSaveHook';
|
||||
import { useGTBEstadoCivilRemoveHook } from '../../_hooks/g_tb_estadocivil/useGTBEstadoCivilRemoveHook';
|
||||
|
||||
import { GTBEstadoCivilInterface } from "../../_interfaces/GTBEstadoCivilInterface";
|
||||
import { useResponse } from "@/app/_response/ResponseContext";
|
||||
import { GTBEstadoCivilInterface } from '../../_interfaces/GTBEstadoCivilInterface';
|
||||
import { useResponse } from '@/app/_response/ResponseContext';
|
||||
|
||||
const initalEstadoCivil: GTBEstadoCivilInterface = {
|
||||
tb_estadocivil_id: 0,
|
||||
sistema_id: 0,
|
||||
descricao: "",
|
||||
situacao: "A",
|
||||
descricao: '',
|
||||
situacao: 'A',
|
||||
};
|
||||
|
||||
export default function TBEstadoCivilPage() {
|
||||
|
|
@ -37,18 +37,14 @@ export default function TBEstadoCivilPage() {
|
|||
const { removeGTBEstadoCivil } = useGTBEstadoCivilRemoveHook();
|
||||
|
||||
// Estado para controlar o formulário e item selecionado
|
||||
const [selectedEstadoCivil, setSelectedEstadoCivil] =
|
||||
useState<GTBEstadoCivilInterface | null>(null);
|
||||
const [selectedEstadoCivil, setSelectedEstadoCivil] = useState<GTBEstadoCivilInterface | null>(
|
||||
null,
|
||||
);
|
||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||
const [itemToDelete, setItemToDelete] =
|
||||
useState<GTBEstadoCivilInterface | null>(null);
|
||||
const [itemToDelete, setItemToDelete] = useState<GTBEstadoCivilInterface | null>(null);
|
||||
|
||||
// Hook para o modal de confirmação
|
||||
const {
|
||||
isOpen: isConfirmOpen,
|
||||
openDialog: openConfirmDialog,
|
||||
handleCancel,
|
||||
} = useConfirmDialog();
|
||||
const { isOpen: isConfirmOpen, openDialog: openConfirmDialog, handleCancel } = useConfirmDialog();
|
||||
|
||||
// Ações do formulário
|
||||
const handleOpenForm = useCallback((data: GTBEstadoCivilInterface | null) => {
|
||||
|
|
@ -88,7 +84,7 @@ export default function TBEstadoCivilPage() {
|
|||
// Define os dados da resposta visual
|
||||
setResponse({
|
||||
status: 400,
|
||||
message: "Não foi informado um registro para exclusão",
|
||||
message: 'Não foi informado um registro para exclusão',
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
|
@ -111,9 +107,9 @@ export default function TBEstadoCivilPage() {
|
|||
<div>
|
||||
{/* Cabeçalho */}
|
||||
<Header
|
||||
title={"Estados Civis"}
|
||||
description={"Gerenciamento de Estados Civis"}
|
||||
buttonText={"Novo Estado Civil"}
|
||||
title={'Estados Civis'}
|
||||
description={'Gerenciamento de Estados Civis'}
|
||||
buttonText={'Novo Estado Civil'}
|
||||
buttonAction={(data) => {
|
||||
handleOpenForm((data = initalEstadoCivil));
|
||||
}}
|
||||
|
|
|
|||
|
|
@ -1,21 +1,21 @@
|
|||
"use client";
|
||||
'use client';
|
||||
|
||||
import { useEffect, useState, useCallback } from "react";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
import { useEffect, useState, useCallback } from 'react';
|
||||
import { Card, CardContent } from '@/components/ui/card';
|
||||
|
||||
import Loading from "@/app/_components/loading/loading";
|
||||
import GTBProfissaoTable from "../../_components/g_tb_profissao/GTBProfissaoTable";
|
||||
import GTBProfissaoForm from "../../_components/g_tb_profissao/GTBProfissaoForm";
|
||||
import Loading from '@/app/_components/loading/loading';
|
||||
import GTBProfissaoTable from '../../_components/g_tb_profissao/GTBProfissaoTable';
|
||||
import GTBProfissaoForm from '../../_components/g_tb_profissao/GTBProfissaoForm';
|
||||
|
||||
import { useGTBProfissaoReadHook } from "../../_hooks/g_tb_profissao/useGTBProfissaoReadHook";
|
||||
import { useGTBProfissaoSaveHook } from "../../_hooks/g_tb_profissao/useGTBProfissaoSaveHook";
|
||||
import { useGTBProfissaoRemoveHook } from "../../_hooks/g_tb_profissao/useGTBProfissaoRemoveHook";
|
||||
import { useGTBProfissaoReadHook } from '../../_hooks/g_tb_profissao/useGTBProfissaoReadHook';
|
||||
import { useGTBProfissaoSaveHook } from '../../_hooks/g_tb_profissao/useGTBProfissaoSaveHook';
|
||||
import { useGTBProfissaoRemoveHook } from '../../_hooks/g_tb_profissao/useGTBProfissaoRemoveHook';
|
||||
|
||||
import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog";
|
||||
import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDialog";
|
||||
import ConfirmDialog from '@/app/_components/confirm_dialog/ConfirmDialog';
|
||||
import { useConfirmDialog } from '@/app/_components/confirm_dialog/useConfirmDialog';
|
||||
|
||||
import GTBProfissaoInterface from "../../_interfaces/GTBProfissaoInterface";
|
||||
import Header from "@/app/_components/structure/Header";
|
||||
import GTBProfissaoInterface from '../../_interfaces/GTBProfissaoInterface';
|
||||
import Header from '@/app/_components/structure/Header';
|
||||
|
||||
export default function TTBAndamentoServico() {
|
||||
// Hooks para leitura e salvamento
|
||||
|
|
@ -24,13 +24,11 @@ export default function TTBAndamentoServico() {
|
|||
const { removeGTBProfissao } = useGTBProfissaoRemoveHook();
|
||||
|
||||
// Estados
|
||||
const [selectedAndamento, setSelectedAndamento] =
|
||||
useState<GTBProfissaoInterface | null>(null);
|
||||
const [selectedAndamento, setSelectedAndamento] = useState<GTBProfissaoInterface | null>(null);
|
||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||
|
||||
// Estado para saber qual item será deletado
|
||||
const [itemToDelete, setItemToDelete] =
|
||||
useState<GTBProfissaoInterface | null>(null);
|
||||
const [itemToDelete, setItemToDelete] = useState<GTBProfissaoInterface | null>(null);
|
||||
|
||||
/**
|
||||
* Hook do modal de confirmação
|
||||
|
|
@ -124,9 +122,9 @@ export default function TTBAndamentoServico() {
|
|||
<div>
|
||||
{/* Cabeçalho */}
|
||||
<Header
|
||||
title={"Profissões"}
|
||||
description={"Gerenciamento de Profissões"}
|
||||
buttonText={"Nova Profissão"}
|
||||
title={'Profissões'}
|
||||
description={'Gerenciamento de Profissões'}
|
||||
buttonText={'Nova Profissão'}
|
||||
buttonAction={() => {
|
||||
handleOpenForm(null);
|
||||
}}
|
||||
|
|
|
|||
|
|
@ -1,21 +1,21 @@
|
|||
"use client";
|
||||
'use client';
|
||||
|
||||
import { useEffect, useState, useCallback } from "react";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
import { useEffect, useState, useCallback } from 'react';
|
||||
import { Card, CardContent } from '@/components/ui/card';
|
||||
|
||||
import Loading from "@/app/_components/loading/loading";
|
||||
import GTBRegimeBensTable from "../../_components/g_tb_regimebens/GTBRegimeBensTable";
|
||||
import GTBRegimeBensForm from "../../_components/g_tb_regimebens/GTBRegimeBensForm";
|
||||
import Loading from '@/app/_components/loading/loading';
|
||||
import GTBRegimeBensTable from '../../_components/g_tb_regimebens/GTBRegimeBensTable';
|
||||
import GTBRegimeBensForm from '../../_components/g_tb_regimebens/GTBRegimeBensForm';
|
||||
|
||||
import { useGTBRegimeBensReadHook } from "../../_hooks/g_tb_regimebens/useGTBRegimeBensReadHook";
|
||||
import { useGTBRegimeBensSaveHook } from "../../_hooks/g_tb_regimebens/useGTBRegimeBensSaveHook";
|
||||
import { useGTBRegimeBensRemoveHook } from "../../_hooks/g_tb_regimebens/useGTBRegimeBensRemoveHook";
|
||||
import { useGTBRegimeBensReadHook } from '../../_hooks/g_tb_regimebens/useGTBRegimeBensReadHook';
|
||||
import { useGTBRegimeBensSaveHook } from '../../_hooks/g_tb_regimebens/useGTBRegimeBensSaveHook';
|
||||
import { useGTBRegimeBensRemoveHook } from '../../_hooks/g_tb_regimebens/useGTBRegimeBensRemoveHook';
|
||||
|
||||
import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog";
|
||||
import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDialog";
|
||||
import ConfirmDialog from '@/app/_components/confirm_dialog/ConfirmDialog';
|
||||
import { useConfirmDialog } from '@/app/_components/confirm_dialog/useConfirmDialog';
|
||||
|
||||
import GTBRegimeBensInterface from "../../_interfaces/GTBRegimeBensInterface";
|
||||
import Header from "@/app/_components/structure/Header";
|
||||
import GTBRegimeBensInterface from '../../_interfaces/GTBRegimeBensInterface';
|
||||
import Header from '@/app/_components/structure/Header';
|
||||
|
||||
export default function TTBAndamentoServico() {
|
||||
// Hooks para leitura e salvamento
|
||||
|
|
@ -24,13 +24,11 @@ export default function TTBAndamentoServico() {
|
|||
const { removeGTBRegimeComunhao } = useGTBRegimeBensRemoveHook();
|
||||
|
||||
// Estados
|
||||
const [selectedAndamento, setSelectedAndamento] =
|
||||
useState<GTBRegimeBensInterface | null>(null);
|
||||
const [selectedAndamento, setSelectedAndamento] = useState<GTBRegimeBensInterface | null>(null);
|
||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||
|
||||
// Estado para saber qual item será deletado
|
||||
const [itemToDelete, setItemToDelete] =
|
||||
useState<GTBRegimeBensInterface | null>(null);
|
||||
const [itemToDelete, setItemToDelete] = useState<GTBRegimeBensInterface | null>(null);
|
||||
|
||||
/**
|
||||
* Hook do modal de confirmação
|
||||
|
|
@ -124,9 +122,9 @@ export default function TTBAndamentoServico() {
|
|||
<div>
|
||||
{/* Cabeçalho */}
|
||||
<Header
|
||||
title={"Regimes de Bens"}
|
||||
description={"Gerenciamento de Regimes de Bens"}
|
||||
buttonText={"Novo Regime"}
|
||||
title={'Regimes de Bens'}
|
||||
description={'Gerenciamento de Regimes de Bens'}
|
||||
buttonText={'Novo Regime'}
|
||||
buttonAction={() => {
|
||||
handleOpenForm(null);
|
||||
}}
|
||||
|
|
|
|||
|
|
@ -1,37 +1,36 @@
|
|||
"use client";
|
||||
'use client';
|
||||
|
||||
import { useEffect, useState, useCallback } from "react";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
import { useEffect, useState, useCallback } from 'react';
|
||||
import { Card, CardContent } from '@/components/ui/card';
|
||||
|
||||
import Loading from "@/app/_components/loading/loading";
|
||||
import GTBRegimeComunhaoTable from "../../_components/g_tb_regimecomunhao/GTBRegimeComunhaoTable";
|
||||
import GTBRegimeComunhaoForm from "../../_components/g_tb_regimecomunhao/GTBRegimeComunhaoForm";
|
||||
import Loading from '@/app/_components/loading/loading';
|
||||
import GTBRegimeComunhaoTable from '../../_components/g_tb_regimecomunhao/GTBRegimeComunhaoTable';
|
||||
import GTBRegimeComunhaoForm from '../../_components/g_tb_regimecomunhao/GTBRegimeComunhaoForm';
|
||||
|
||||
import { useGTBRegimeComunhaoReadHook } from "../../_hooks/g_tb_regimecomunhao/useGTBRegimeComunhaoReadHook";
|
||||
import { useGTBRegimeComunhaoSaveHook } from "../../_hooks/g_tb_regimecomunhao/useGTBRegimeComunhaoSaveHook";
|
||||
import { useGTBRegimeComunhaoRemoveHook } from "../../_hooks/g_tb_regimecomunhao/useGTBRegimeComunhaoRemoveHook";
|
||||
import { useGTBRegimeComunhaoReadHook } from '../../_hooks/g_tb_regimecomunhao/useGTBRegimeComunhaoReadHook';
|
||||
import { useGTBRegimeComunhaoSaveHook } from '../../_hooks/g_tb_regimecomunhao/useGTBRegimeComunhaoSaveHook';
|
||||
import { useGTBRegimeComunhaoRemoveHook } from '../../_hooks/g_tb_regimecomunhao/useGTBRegimeComunhaoRemoveHook';
|
||||
|
||||
import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog";
|
||||
import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDialog";
|
||||
import ConfirmDialog from '@/app/_components/confirm_dialog/ConfirmDialog';
|
||||
import { useConfirmDialog } from '@/app/_components/confirm_dialog/useConfirmDialog';
|
||||
|
||||
import GTBRegimeComunhaoInterface from "../../_interfaces/GTBRegimeComunhaoInterface";
|
||||
import Header from "@/app/_components/structure/Header";
|
||||
import GTBRegimeComunhaoInterface from '../../_interfaces/GTBRegimeComunhaoInterface';
|
||||
import Header from '@/app/_components/structure/Header';
|
||||
|
||||
export default function TTBAndamentoServico() {
|
||||
// Hooks para leitura e salvamento
|
||||
const { gTBRegimeComunhao, fetchGTBRegimeComunhao } =
|
||||
useGTBRegimeComunhaoReadHook();
|
||||
const { gTBRegimeComunhao, fetchGTBRegimeComunhao } = useGTBRegimeComunhaoReadHook();
|
||||
const { saveGTBRegimeComunhao } = useGTBRegimeComunhaoSaveHook();
|
||||
const { removeGTBRegimeComunhao } = useGTBRegimeComunhaoRemoveHook();
|
||||
|
||||
// Estados
|
||||
const [selectedAndamento, setSelectedAndamento] =
|
||||
useState<GTBRegimeComunhaoInterface | null>(null);
|
||||
const [selectedAndamento, setSelectedAndamento] = useState<GTBRegimeComunhaoInterface | null>(
|
||||
null,
|
||||
);
|
||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||
|
||||
// Estado para saber qual item será deletado
|
||||
const [itemToDelete, setItemToDelete] =
|
||||
useState<GTBRegimeComunhaoInterface | null>(null);
|
||||
const [itemToDelete, setItemToDelete] = useState<GTBRegimeComunhaoInterface | null>(null);
|
||||
|
||||
/**
|
||||
* Hook do modal de confirmação
|
||||
|
|
@ -46,13 +45,10 @@ export default function TTBAndamentoServico() {
|
|||
/**
|
||||
* Abre o formulário no modo de edição ou criação
|
||||
*/
|
||||
const handleOpenForm = useCallback(
|
||||
(data: GTBRegimeComunhaoInterface | null) => {
|
||||
setSelectedAndamento(data);
|
||||
setIsFormOpen(true);
|
||||
},
|
||||
[],
|
||||
);
|
||||
const handleOpenForm = useCallback((data: GTBRegimeComunhaoInterface | null) => {
|
||||
setSelectedAndamento(data);
|
||||
setIsFormOpen(true);
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Fecha o formulário e limpa o andamento selecionado
|
||||
|
|
@ -128,9 +124,9 @@ export default function TTBAndamentoServico() {
|
|||
<div>
|
||||
{/* Cabeçalho */}
|
||||
<Header
|
||||
title={"Regimes de Comunhão"}
|
||||
description={"Gerenciamento de Regimes de Comunhão"}
|
||||
buttonText={"Novo Regime"}
|
||||
title={'Regimes de Comunhão'}
|
||||
description={'Gerenciamento de Regimes de Comunhão'}
|
||||
buttonText={'Novo Regime'}
|
||||
buttonAction={() => {
|
||||
handleOpenForm(null);
|
||||
}}
|
||||
|
|
|
|||
|
|
@ -1,22 +1,22 @@
|
|||
"use client";
|
||||
'use client';
|
||||
|
||||
import { useEffect, useState, useCallback } from "react";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDialog";
|
||||
import { useEffect, useState, useCallback } from 'react';
|
||||
import { Card, CardContent } from '@/components/ui/card';
|
||||
import { useConfirmDialog } from '@/app/_components/confirm_dialog/useConfirmDialog';
|
||||
|
||||
import Header from "@/app/_components/structure/Header";
|
||||
import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog";
|
||||
import Loading from "@/app/_components/loading/loading";
|
||||
import GTBTipoLogradouroTable from "../../_components/g_tb_tipologradouro/GTBTipoLogradouroTable";
|
||||
import GTBTipoLogradouroForm from "../../_components/g_tb_tipologradouro/GTBTipoLogradouroForm";
|
||||
import Header from '@/app/_components/structure/Header';
|
||||
import ConfirmDialog from '@/app/_components/confirm_dialog/ConfirmDialog';
|
||||
import Loading from '@/app/_components/loading/loading';
|
||||
import GTBTipoLogradouroTable from '../../_components/g_tb_tipologradouro/GTBTipoLogradouroTable';
|
||||
import GTBTipoLogradouroForm from '../../_components/g_tb_tipologradouro/GTBTipoLogradouroForm';
|
||||
|
||||
import { useGTBTipoLogradouroReadHook } from "../../_hooks/g_tb_tipologradouro/useGTBTipoLogradouroReadHook";
|
||||
import { useGTBTipoLogradouroSaveHook } from "../../_hooks/g_tb_tipologradouro/useGTBTipoLogradouroSaveHook";
|
||||
import { useGTBTipoLogradouroRemoveHook } from "../../_hooks/g_tb_tipologradouro/useGTBTipoLogradouroRemoveHook";
|
||||
import { useGTBTipoLogradouroReadHook } from '../../_hooks/g_tb_tipologradouro/useGTBTipoLogradouroReadHook';
|
||||
import { useGTBTipoLogradouroSaveHook } from '../../_hooks/g_tb_tipologradouro/useGTBTipoLogradouroSaveHook';
|
||||
import { useGTBTipoLogradouroRemoveHook } from '../../_hooks/g_tb_tipologradouro/useGTBTipoLogradouroRemoveHook';
|
||||
|
||||
import { GTBTipoLogradouroInterface } from "../../_interfaces/GTBTipoLogradouroInterface";
|
||||
import { GTBTipoLogradouroInterface } from '../../_interfaces/GTBTipoLogradouroInterface';
|
||||
|
||||
import { useResponse } from "@/app/_response/ResponseContext";
|
||||
import { useResponse } from '@/app/_response/ResponseContext';
|
||||
|
||||
export default function TTBAndamentoServico() {
|
||||
// Controle de exibição de respostas
|
||||
|
|
@ -26,39 +26,31 @@ export default function TTBAndamentoServico() {
|
|||
const [buttonIsLoading, setButtonIsLoading] = useState(false);
|
||||
|
||||
// Hooks para leitura e salvamento
|
||||
const { gTBTipoLogradouro, fetchGTBTipoLogradouro } =
|
||||
useGTBTipoLogradouroReadHook();
|
||||
const { gTBTipoLogradouro, fetchGTBTipoLogradouro } = useGTBTipoLogradouroReadHook();
|
||||
const { saveGTBTipoLogradouro } = useGTBTipoLogradouroSaveHook();
|
||||
const { removeGTBTipoLogradouro } = useGTBTipoLogradouroRemoveHook();
|
||||
|
||||
// Estados
|
||||
const [selectedTipoLogradouro, setTipoLogradouro] =
|
||||
useState<GTBTipoLogradouroInterface | null>(null);
|
||||
const [selectedTipoLogradouro, setTipoLogradouro] = useState<GTBTipoLogradouroInterface | null>(
|
||||
null,
|
||||
);
|
||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||
|
||||
// Estado para saber qual item será deletado
|
||||
const [itemToDelete, setItemToDelete] =
|
||||
useState<GTBTipoLogradouroInterface | null>(null);
|
||||
const [itemToDelete, setItemToDelete] = useState<GTBTipoLogradouroInterface | null>(null);
|
||||
|
||||
/**
|
||||
* Hook do modal de confirmação
|
||||
*/
|
||||
const {
|
||||
isOpen: isConfirmOpen,
|
||||
openDialog: openConfirmDialog,
|
||||
handleCancel,
|
||||
} = useConfirmDialog();
|
||||
const { isOpen: isConfirmOpen, openDialog: openConfirmDialog, handleCancel } = useConfirmDialog();
|
||||
|
||||
/**
|
||||
* Abre o formulário no modo de edição ou criação
|
||||
*/
|
||||
const handleOpenForm = useCallback(
|
||||
(data: GTBTipoLogradouroInterface | null) => {
|
||||
setTipoLogradouro(data);
|
||||
setIsFormOpen(true);
|
||||
},
|
||||
[],
|
||||
);
|
||||
const handleOpenForm = useCallback((data: GTBTipoLogradouroInterface | null) => {
|
||||
setTipoLogradouro(data);
|
||||
setIsFormOpen(true);
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Fecha o formulário e limpa o andamento selecionado
|
||||
|
|
@ -111,7 +103,7 @@ export default function TTBAndamentoServico() {
|
|||
// Define os dados da resposta visual
|
||||
setResponse({
|
||||
status: 400,
|
||||
message: "Não foi informado um registro para exclusão",
|
||||
message: 'Não foi informado um registro para exclusão',
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
|
@ -147,9 +139,9 @@ export default function TTBAndamentoServico() {
|
|||
<div>
|
||||
{/* Cabeçalho */}
|
||||
<Header
|
||||
title={"Tipos de Logradouros"}
|
||||
description={"Gerenciamento de tipos de Logradouros"}
|
||||
buttonText={"Novo Tipo"}
|
||||
title={'Tipos de Logradouros'}
|
||||
description={'Gerenciamento de tipos de Logradouros'}
|
||||
buttonText={'Novo Tipo'}
|
||||
buttonAction={() => {
|
||||
handleOpenForm(null);
|
||||
}}
|
||||
|
|
|
|||
|
|
@ -1,21 +1,21 @@
|
|||
"use client";
|
||||
'use client';
|
||||
|
||||
import { useEffect, useState, useCallback } from "react";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
import { useEffect, useState, useCallback } from 'react';
|
||||
import { Card, CardContent } from '@/components/ui/card';
|
||||
|
||||
import Loading from "@/app/_components/loading/loading";
|
||||
import TCensecTable from "../../_components/t_censec/TCensecTable";
|
||||
import TCensecForm from "../../_components/t_censec/TCensecForm";
|
||||
import Loading from '@/app/_components/loading/loading';
|
||||
import TCensecTable from '../../_components/t_censec/TCensecTable';
|
||||
import TCensecForm from '../../_components/t_censec/TCensecForm';
|
||||
|
||||
import { useTCensecReadHook } from "../../_hooks/t_censec/useTCensecReadHook";
|
||||
import { useTCensecSaveHook } from "../../_hooks/t_censec/useTCensecSaveHook";
|
||||
import { useTCensecDeleteHook } from "../../_hooks/t_censec/useTCensecDeleteHook";
|
||||
import { useTCensecReadHook } from '../../_hooks/t_censec/useTCensecReadHook';
|
||||
import { useTCensecSaveHook } from '../../_hooks/t_censec/useTCensecSaveHook';
|
||||
import { useTCensecDeleteHook } from '../../_hooks/t_censec/useTCensecDeleteHook';
|
||||
|
||||
import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog";
|
||||
import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDialog";
|
||||
import ConfirmDialog from '@/app/_components/confirm_dialog/ConfirmDialog';
|
||||
import { useConfirmDialog } from '@/app/_components/confirm_dialog/useConfirmDialog';
|
||||
|
||||
import TCensecInterface from "../../_interfaces/TCensecInterface";
|
||||
import Header from "@/app/_components/structure/Header";
|
||||
import TCensecInterface from '../../_interfaces/TCensecInterface';
|
||||
import Header from '@/app/_components/structure/Header';
|
||||
|
||||
export default function TTBAndamentoServico() {
|
||||
// Controle de estado do botão
|
||||
|
|
@ -27,14 +27,11 @@ export default function TTBAndamentoServico() {
|
|||
const { deleteTCensec } = useTCensecDeleteHook();
|
||||
|
||||
// Estados
|
||||
const [selectedAndamento, setSelectedAndamento] =
|
||||
useState<TCensecInterface | null>(null);
|
||||
const [selectedAndamento, setSelectedAndamento] = useState<TCensecInterface | null>(null);
|
||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||
|
||||
// Estado para saber qual item será deletado
|
||||
const [itemToDelete, setItemToDelete] = useState<TCensecInterface | null>(
|
||||
null,
|
||||
);
|
||||
const [itemToDelete, setItemToDelete] = useState<TCensecInterface | null>(null);
|
||||
|
||||
/**
|
||||
* Hook do modal de confirmação
|
||||
|
|
@ -134,9 +131,9 @@ export default function TTBAndamentoServico() {
|
|||
<div>
|
||||
{/* Cabeçalho */}
|
||||
<Header
|
||||
title={"CENSEC"}
|
||||
description={"Gerenciamento de Centrais"}
|
||||
buttonText={"Nova Central"}
|
||||
title={'CENSEC'}
|
||||
description={'Gerenciamento de Centrais'}
|
||||
buttonText={'Nova Central'}
|
||||
buttonAction={() => {
|
||||
handleOpenForm(null);
|
||||
}}
|
||||
|
|
@ -145,11 +142,7 @@ export default function TTBAndamentoServico() {
|
|||
{/* Tabela de andamentos */}
|
||||
<Card>
|
||||
<CardContent>
|
||||
<TCensecTable
|
||||
data={tCensec}
|
||||
onEdit={handleOpenForm}
|
||||
onDelete={handleConfirmDelete}
|
||||
/>
|
||||
<TCensecTable data={tCensec} onEdit={handleOpenForm} onDelete={handleConfirmDelete} />
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,27 +1,27 @@
|
|||
"use client";
|
||||
'use client';
|
||||
|
||||
import { useEffect, useState, useCallback } from "react";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDialog";
|
||||
import { useResponse } from "@/app/_response/ResponseContext";
|
||||
import { useEffect, useState, useCallback } from 'react';
|
||||
import { Card, CardContent } from '@/components/ui/card';
|
||||
import { useConfirmDialog } from '@/app/_components/confirm_dialog/useConfirmDialog';
|
||||
import { useResponse } from '@/app/_response/ResponseContext';
|
||||
|
||||
import Header from "@/app/_components/structure/Header";
|
||||
import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog";
|
||||
import Loading from "@/app/_components/loading/loading";
|
||||
import Header from '@/app/_components/structure/Header';
|
||||
import ConfirmDialog from '@/app/_components/confirm_dialog/ConfirmDialog';
|
||||
import Loading from '@/app/_components/loading/loading';
|
||||
|
||||
import TCensecNaturezaLitigioTable from "../../_components/t_censecnaturezalitigio/TCensecNaturezaLitigioTable";
|
||||
import TCensecNaturezaLitigioForm from "../../_components/t_censecnaturezalitigio/TCensecNaturezaLitigioForm";
|
||||
import TCensecNaturezaLitigioTable from '../../_components/t_censecnaturezalitigio/TCensecNaturezaLitigioTable';
|
||||
import TCensecNaturezaLitigioForm from '../../_components/t_censecnaturezalitigio/TCensecNaturezaLitigioForm';
|
||||
|
||||
import { useTCensecNaturezaLitigioReadHook } from "../../_hooks/t_censecnaturezalitigio/useTCensecNaturezaLitigioReadHook";
|
||||
import { useTCensecNaturezaLitigioSaveHook } from "../../_hooks/t_censecnaturezalitigio/useTCensecNaturezaLitigioSaveHook";
|
||||
import { useTCensecNaturezaLitigioRemoveHook } from "../../_hooks/t_censecnaturezalitigio/useTCensecNaturezaLitigioRemoveHook";
|
||||
import { useTCensecNaturezaLitigioReadHook } from '../../_hooks/t_censecnaturezalitigio/useTCensecNaturezaLitigioReadHook';
|
||||
import { useTCensecNaturezaLitigioSaveHook } from '../../_hooks/t_censecnaturezalitigio/useTCensecNaturezaLitigioSaveHook';
|
||||
import { useTCensecNaturezaLitigioRemoveHook } from '../../_hooks/t_censecnaturezalitigio/useTCensecNaturezaLitigioRemoveHook';
|
||||
|
||||
import { TCensecNaturezaLitigioInterface } from "../../_interfaces/TCensecNaturezaLitigioInterface";
|
||||
import { SituacoesEnum } from "@/enums/SituacoesEnum";
|
||||
import { TCensecNaturezaLitigioInterface } from '../../_interfaces/TCensecNaturezaLitigioInterface';
|
||||
import { SituacoesEnum } from '@/enums/SituacoesEnum';
|
||||
|
||||
const initialCensecNaturezaLitigio: TCensecNaturezaLitigioInterface = {
|
||||
censec_naturezalitigio_id: 0,
|
||||
descricao: "",
|
||||
descricao: '',
|
||||
situacao: SituacoesEnum.A,
|
||||
};
|
||||
|
||||
|
|
@ -36,31 +36,21 @@ export default function TCensecNaturezaLitigioPage() {
|
|||
const { tCensecNaturezaLitigio, fetchTCensecNaturezaLitigio } =
|
||||
useTCensecNaturezaLitigioReadHook();
|
||||
const { saveTCensecNaturezaLitigio } = useTCensecNaturezaLitigioSaveHook();
|
||||
const { removeTCensecNaturezaLitigio } =
|
||||
useTCensecNaturezaLitigioRemoveHook();
|
||||
const { removeTCensecNaturezaLitigio } = useTCensecNaturezaLitigioRemoveHook();
|
||||
|
||||
// Estados
|
||||
const [selectedItem, setSelectedItem] =
|
||||
useState<TCensecNaturezaLitigioInterface | null>(null);
|
||||
const [selectedItem, setSelectedItem] = useState<TCensecNaturezaLitigioInterface | null>(null);
|
||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||
const [itemToDelete, setItemToDelete] =
|
||||
useState<TCensecNaturezaLitigioInterface | null>(null);
|
||||
const [itemToDelete, setItemToDelete] = useState<TCensecNaturezaLitigioInterface | null>(null);
|
||||
|
||||
// Modal de confirmação
|
||||
const {
|
||||
isOpen: isConfirmOpen,
|
||||
openDialog: openConfirmDialog,
|
||||
handleCancel,
|
||||
} = useConfirmDialog();
|
||||
const { isOpen: isConfirmOpen, openDialog: openConfirmDialog, handleCancel } = useConfirmDialog();
|
||||
|
||||
// Abrir formulário (criação ou edição)
|
||||
const handleOpenForm = useCallback(
|
||||
(item: TCensecNaturezaLitigioInterface | null) => {
|
||||
setSelectedItem(item);
|
||||
setIsFormOpen(true);
|
||||
},
|
||||
[],
|
||||
);
|
||||
const handleOpenForm = useCallback((item: TCensecNaturezaLitigioInterface | null) => {
|
||||
setSelectedItem(item);
|
||||
setIsFormOpen(true);
|
||||
}, []);
|
||||
|
||||
// Fechar formulário
|
||||
const handleCloseForm = useCallback(() => {
|
||||
|
|
@ -96,7 +86,7 @@ export default function TCensecNaturezaLitigioPage() {
|
|||
// Define os dados da resposta visual
|
||||
setResponse({
|
||||
status: 400,
|
||||
message: "Não foi informado um registro para exclusão",
|
||||
message: 'Não foi informado um registro para exclusão',
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
|
@ -121,12 +111,10 @@ export default function TCensecNaturezaLitigioPage() {
|
|||
<div>
|
||||
{/* Cabeçalho */}
|
||||
<Header
|
||||
title={"Natureza do Litígio"}
|
||||
description={"Gerenciamento de Naturezas do Litígio"}
|
||||
buttonText={"Nova Natureza"}
|
||||
buttonAction={(data) =>
|
||||
handleOpenForm((data = initialCensecNaturezaLitigio))
|
||||
}
|
||||
title={'Natureza do Litígio'}
|
||||
description={'Gerenciamento de Naturezas do Litígio'}
|
||||
buttonText={'Nova Natureza'}
|
||||
buttonAction={(data) => handleOpenForm((data = initialCensecNaturezaLitigio))}
|
||||
/>
|
||||
|
||||
{/* Tabela */}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
"use client";
|
||||
'use client';
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import { useParams } from "next/navigation";
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useParams } from 'next/navigation';
|
||||
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
import MainEditor from "@/components/MainEditor";
|
||||
import { Card, CardContent } from '@/components/ui/card';
|
||||
import MainEditor from '@/components/MainEditor';
|
||||
|
||||
import Loading from "@/app/_components/loading/loading";
|
||||
import { useTMinutaReadHook } from "../../../../_hooks/t_minuta/useTMinutaReadHook";
|
||||
import { TMinutaInterface } from "../../../../_interfaces/TMinutaInterface";
|
||||
import Loading from '@/app/_components/loading/loading';
|
||||
import { useTMinutaReadHook } from '../../../../_hooks/t_minuta/useTMinutaReadHook';
|
||||
import { TMinutaInterface } from '../../../../_interfaces/TMinutaInterface';
|
||||
|
||||
export default function TMinutaDetalhes() {
|
||||
const params = useParams();
|
||||
|
|
@ -42,16 +42,14 @@ export default function TMinutaDetalhes() {
|
|||
<div>
|
||||
<Card>
|
||||
<CardContent>
|
||||
<div className="mb-4 grid gap-4 grid-cols-2">
|
||||
<div className="mb-4 grid grid-cols-2 gap-4">
|
||||
<div>
|
||||
<div className="text-2xl font-semibold">Descrição</div>
|
||||
<div className="text-xl">{tMinuta.descricao}</div>
|
||||
</div>
|
||||
<div>
|
||||
<div className="text-2xl font-semibold">Situação</div>
|
||||
<div className="text-xl">
|
||||
{tMinuta.situacao === "A" ? "Ativo" : "Inativo"}
|
||||
</div>
|
||||
<div className="text-xl">{tMinuta.situacao === 'A' ? 'Ativo' : 'Inativo'}</div>
|
||||
</div>
|
||||
<div className="col-span-2">
|
||||
<div className="text-2xl font-semibold">Texto</div>
|
||||
|
|
@ -59,10 +57,10 @@ export default function TMinutaDetalhes() {
|
|||
initialValue={editorContent} // Passa o conteúdo do editor
|
||||
onEditorChange={handleEditorChange} // Função que atualiza o estado
|
||||
margins={{
|
||||
top: "2",
|
||||
bottom: "2",
|
||||
left: "2",
|
||||
right: "2",
|
||||
top: '2',
|
||||
bottom: '2',
|
||||
left: '2',
|
||||
right: '2',
|
||||
}}
|
||||
size={{ width: 794, height: 1123 }} // Você pode ajustar o tamanho aqui
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
"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 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 { Button } from '@/components/ui/button';
|
||||
import { Checkbox } from '@/components/ui/checkbox';
|
||||
import {
|
||||
Form,
|
||||
FormControl,
|
||||
|
|
@ -14,14 +14,14 @@ import {
|
|||
FormItem,
|
||||
FormLabel,
|
||||
FormMessage,
|
||||
} from "@/components/ui/form";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
} from '@/components/ui/form';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Label } from '@/components/ui/label';
|
||||
|
||||
import MainEditor from "@/components/MainEditor";
|
||||
import { TMinutaSchema } from "../../../_schemas/TMinutaSchema";
|
||||
import { useTMinutaSaveHook } from "../../../_hooks/t_minuta/useTMinutaSaveHook";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
import MainEditor from '@/components/MainEditor';
|
||||
import { TMinutaSchema } from '../../../_schemas/TMinutaSchema';
|
||||
import { useTMinutaSaveHook } from '../../../_hooks/t_minuta/useTMinutaSaveHook';
|
||||
import { Card, CardContent } from '@/components/ui/card';
|
||||
|
||||
type FormValues = z.infer<typeof TMinutaSchema>;
|
||||
|
||||
|
|
@ -32,9 +32,9 @@ export default function TMinutaForm() {
|
|||
resolver: zodResolver(TMinutaSchema),
|
||||
defaultValues: {
|
||||
natureza_id: undefined,
|
||||
descricao: "",
|
||||
situacao: "A",
|
||||
texto: "",
|
||||
descricao: '',
|
||||
situacao: 'A',
|
||||
texto: '',
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -56,10 +56,7 @@ export default function TMinutaForm() {
|
|||
<FormItem>
|
||||
<FormLabel>Descrição</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
placeholder="Digite a descrição da minuta"
|
||||
/>
|
||||
<Input {...field} placeholder="Digite a descrição da minuta" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
|
|
@ -73,12 +70,10 @@ export default function TMinutaForm() {
|
|||
render={({ field }) => (
|
||||
<div className="flex items-center space-x-2">
|
||||
<Checkbox
|
||||
checked={field.value === "A"}
|
||||
onCheckedChange={(checked) =>
|
||||
field.onChange(checked ? "A" : "I")
|
||||
}
|
||||
checked={field.value === 'A'}
|
||||
onCheckedChange={(checked) => field.onChange(checked ? 'A' : 'I')}
|
||||
/>
|
||||
<Label>{field.value === "A" ? "Ativo" : "Inativo"}</Label>
|
||||
<Label>{field.value === 'A' ? 'Ativo' : 'Inativo'}</Label>
|
||||
</div>
|
||||
)}
|
||||
/>
|
||||
|
|
@ -90,13 +85,13 @@ export default function TMinutaForm() {
|
|||
render={({ field }) => (
|
||||
<div>
|
||||
<MainEditor
|
||||
initialValue={field.value || ""}
|
||||
initialValue={field.value || ''}
|
||||
onEditorChange={field.onChange}
|
||||
margins={{ top: "0", bottom: "0", left: "0", right: "0" }}
|
||||
margins={{ top: '0', bottom: '0', left: '0', right: '0' }}
|
||||
size={{ width: 794, height: 1123 }}
|
||||
/>
|
||||
{form.formState.errors.texto && (
|
||||
<p className="text-sm text-red-500 mt-2">
|
||||
<p className="mt-2 text-sm text-red-500">
|
||||
{form.formState.errors.texto.message}
|
||||
</p>
|
||||
)}
|
||||
|
|
|
|||
|
|
@ -1,22 +1,22 @@
|
|||
"use client";
|
||||
'use client';
|
||||
|
||||
import { useEffect, useState, useCallback } from "react";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDialog";
|
||||
import { useEffect, useState, useCallback } from 'react';
|
||||
import { Card, CardContent } from '@/components/ui/card';
|
||||
import { useConfirmDialog } from '@/app/_components/confirm_dialog/useConfirmDialog';
|
||||
|
||||
import Header from "@/app/_components/structure/Header";
|
||||
import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog";
|
||||
import Loading from "@/app/_components/loading/loading";
|
||||
import Header from '@/app/_components/structure/Header';
|
||||
import ConfirmDialog from '@/app/_components/confirm_dialog/ConfirmDialog';
|
||||
import Loading from '@/app/_components/loading/loading';
|
||||
|
||||
import TMinutaTable from "../../_components/t_minuta/TMinutaTable";
|
||||
import TMinutaForm from "../../_components/t_minuta/TMinutaForm";
|
||||
import TMinutaTable from '../../_components/t_minuta/TMinutaTable';
|
||||
import TMinutaForm from '../../_components/t_minuta/TMinutaForm';
|
||||
|
||||
import { useTMinutaReadHook } from "../../_hooks/t_minuta/useTMinutaReadHook";
|
||||
import { useTMinutaSaveHook } from "../../_hooks/t_minuta/useTMinutaSaveHook";
|
||||
import { useTMinutaRemoveHook } from "../../_hooks/t_minuta/useTMinutaRemoveHook";
|
||||
import { useTMinutaReadHook } from '../../_hooks/t_minuta/useTMinutaReadHook';
|
||||
import { useTMinutaSaveHook } from '../../_hooks/t_minuta/useTMinutaSaveHook';
|
||||
import { useTMinutaRemoveHook } from '../../_hooks/t_minuta/useTMinutaRemoveHook';
|
||||
|
||||
import { TMinutaInterface } from "../../_interfaces/TMinutaInterface";
|
||||
import { useTMinutaIndexHook } from "../../_hooks/t_minuta/useTMinutaIndexHook";
|
||||
import { TMinutaInterface } from '../../_interfaces/TMinutaInterface';
|
||||
import { useTMinutaIndexHook } from '../../_hooks/t_minuta/useTMinutaIndexHook';
|
||||
|
||||
export default function TMinutaPage() {
|
||||
// Hooks de leitura e escrita
|
||||
|
|
@ -25,13 +25,9 @@ export default function TMinutaPage() {
|
|||
const { removeTMinuta } = useTMinutaRemoveHook();
|
||||
|
||||
// Estados
|
||||
const [selectedMinuta, setSelectedMinuta] = useState<TMinutaInterface | null>(
|
||||
null,
|
||||
);
|
||||
const [selectedMinuta, setSelectedMinuta] = useState<TMinutaInterface | null>(null);
|
||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||
const [itemToDelete, setItemToDelete] = useState<TMinutaInterface | null>(
|
||||
null,
|
||||
);
|
||||
const [itemToDelete, setItemToDelete] = useState<TMinutaInterface | null>(null);
|
||||
|
||||
// Hook de confirmação
|
||||
const {
|
||||
|
|
@ -89,11 +85,7 @@ export default function TMinutaPage() {
|
|||
{/* Tabela */}
|
||||
<Card>
|
||||
<CardContent>
|
||||
<TMinutaTable
|
||||
data={tMinuta}
|
||||
onEdit={handleOpenForm}
|
||||
onDelete={handleConfirmDelete}
|
||||
/>
|
||||
<TMinutaTable data={tMinuta} onEdit={handleOpenForm} onDelete={handleConfirmDelete} />
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,20 +1,20 @@
|
|||
"use client";
|
||||
'use client';
|
||||
|
||||
import React, { useEffect, useState, useCallback } from "react";
|
||||
import React, { useEffect, useState, useCallback } from 'react';
|
||||
|
||||
import Loading from "@/app/_components/loading/loading";
|
||||
import TPessoaTable from "../../../_components/t_pessoa/TPessoaTable";
|
||||
import TPessoaForm from "../../../_components/t_pessoa/TPessoaForm";
|
||||
import Loading from '@/app/_components/loading/loading';
|
||||
import TPessoaTable from '../../../_components/t_pessoa/TPessoaTable';
|
||||
import TPessoaForm from '../../../_components/t_pessoa/TPessoaForm';
|
||||
|
||||
import { useTPessoaIndexHook } from "../../../_hooks/t_pessoa/useTPessoaIndexHook";
|
||||
import { useTPessoaSaveHook } from "../../../_hooks/t_pessoa/useTPessoaSaveHook";
|
||||
import { useTPessoaDeleteHook } from "../../../_hooks/t_pessoa/useTPessoaDeleteHook";
|
||||
import { useTPessoaIndexHook } from '../../../_hooks/t_pessoa/useTPessoaIndexHook';
|
||||
import { useTPessoaSaveHook } from '../../../_hooks/t_pessoa/useTPessoaSaveHook';
|
||||
import { useTPessoaDeleteHook } from '../../../_hooks/t_pessoa/useTPessoaDeleteHook';
|
||||
|
||||
import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog";
|
||||
import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDialog";
|
||||
import ConfirmDialog from '@/app/_components/confirm_dialog/ConfirmDialog';
|
||||
import { useConfirmDialog } from '@/app/_components/confirm_dialog/useConfirmDialog';
|
||||
|
||||
import TPessoaInterface from "../../../_interfaces/TPessoaInterface";
|
||||
import Header from "@/app/_components/structure/Header";
|
||||
import TPessoaInterface from '../../../_interfaces/TPessoaInterface';
|
||||
import Header from '@/app/_components/structure/Header';
|
||||
|
||||
export default function TPessoaFisica() {
|
||||
// Controle de estado do botão
|
||||
|
|
@ -26,14 +26,11 @@ export default function TPessoaFisica() {
|
|||
const { deleteTCensec } = useTPessoaDeleteHook();
|
||||
|
||||
// Estados
|
||||
const [selectedAndamento, setSelectedAndamento] =
|
||||
useState<TPessoaInterface | null>(null);
|
||||
const [selectedAndamento, setSelectedAndamento] = useState<TPessoaInterface | null>(null);
|
||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||
|
||||
// Estado para saber qual item será deletado
|
||||
const [itemToDelete, setItemToDelete] = useState<TPessoaInterface | null>(
|
||||
null,
|
||||
);
|
||||
const [itemToDelete, setItemToDelete] = useState<TPessoaInterface | null>(null);
|
||||
|
||||
/**
|
||||
* Hook do modal de confirmação
|
||||
|
|
@ -133,20 +130,16 @@ export default function TPessoaFisica() {
|
|||
<div>
|
||||
{/* Cabeçalho */}
|
||||
<Header
|
||||
title={"Pessoas Físicas"}
|
||||
description={"Gerenciamento de pessoas físicas"}
|
||||
buttonText={"Nova Pessoa"}
|
||||
title={'Pessoas Físicas'}
|
||||
description={'Gerenciamento de pessoas físicas'}
|
||||
buttonText={'Nova Pessoa'}
|
||||
buttonAction={() => {
|
||||
handleOpenForm(null);
|
||||
}}
|
||||
/>
|
||||
|
||||
{/* Tabela de Registros */}
|
||||
<TPessoaTable
|
||||
data={tPessoa}
|
||||
onDelete={handleConfirmDelete}
|
||||
onEdit={handleOpenForm}
|
||||
/>
|
||||
<TPessoaTable data={tPessoa} onDelete={handleConfirmDelete} onEdit={handleOpenForm} />
|
||||
|
||||
{/* Modal de confirmação */}
|
||||
<ConfirmDialog
|
||||
|
|
|
|||
|
|
@ -1,20 +1,20 @@
|
|||
"use client";
|
||||
'use client';
|
||||
|
||||
import React, { useEffect, useState, useCallback } from "react";
|
||||
import React, { useEffect, useState, useCallback } from 'react';
|
||||
|
||||
import Loading from "@/app/_components/loading/loading";
|
||||
import Loading from '@/app/_components/loading/loading';
|
||||
|
||||
import { useTPessoaSaveHook } from "../../../_hooks/t_pessoa/useTPessoaSaveHook";
|
||||
import { useTPessoaDeleteHook } from "../../../_hooks/t_pessoa/useTPessoaDeleteHook";
|
||||
import { useTPessoaSaveHook } from '../../../_hooks/t_pessoa/useTPessoaSaveHook';
|
||||
import { useTPessoaDeleteHook } from '../../../_hooks/t_pessoa/useTPessoaDeleteHook';
|
||||
|
||||
import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog";
|
||||
import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDialog";
|
||||
import ConfirmDialog from '@/app/_components/confirm_dialog/ConfirmDialog';
|
||||
import { useConfirmDialog } from '@/app/_components/confirm_dialog/useConfirmDialog';
|
||||
|
||||
import TPessoaInterface from "../../../_interfaces/TPessoaInterface";
|
||||
import Header from "@/app/_components/structure/Header";
|
||||
import TPessoaJuridicaTable from "../../../_components/t_pessoa/juridica/TPessoaJuridicaTable";
|
||||
import { useTPessoaJuridicaIndexHook } from "../../../_hooks/t_pessoa/juridica/useTPessoaJuridicaIndexHook";
|
||||
import TPessoaJuridicaForm from "../../../_components/t_pessoa/juridica/TPessoaJuridicaForm";
|
||||
import TPessoaInterface from '../../../_interfaces/TPessoaInterface';
|
||||
import Header from '@/app/_components/structure/Header';
|
||||
import TPessoaJuridicaTable from '../../../_components/t_pessoa/juridica/TPessoaJuridicaTable';
|
||||
import { useTPessoaJuridicaIndexHook } from '../../../_hooks/t_pessoa/juridica/useTPessoaJuridicaIndexHook';
|
||||
import TPessoaJuridicaForm from '../../../_components/t_pessoa/juridica/TPessoaJuridicaForm';
|
||||
|
||||
export default function TPessoaFisica() {
|
||||
// Controle de estado do botão
|
||||
|
|
@ -26,14 +26,11 @@ export default function TPessoaFisica() {
|
|||
const { deleteTCensec } = useTPessoaDeleteHook();
|
||||
|
||||
// Estados
|
||||
const [selectedAndamento, setSelectedAndamento] =
|
||||
useState<TPessoaInterface | null>(null);
|
||||
const [selectedAndamento, setSelectedAndamento] = useState<TPessoaInterface | null>(null);
|
||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||
|
||||
// Estado para saber qual item será deletado
|
||||
const [itemToDelete, setItemToDelete] = useState<TPessoaInterface | null>(
|
||||
null,
|
||||
);
|
||||
const [itemToDelete, setItemToDelete] = useState<TPessoaInterface | null>(null);
|
||||
|
||||
/**
|
||||
* Hook do modal de confirmação
|
||||
|
|
@ -133,20 +130,16 @@ export default function TPessoaFisica() {
|
|||
<div>
|
||||
{/* Cabeçalho */}
|
||||
<Header
|
||||
title={"Pessoas Jurídicas"}
|
||||
description={"Gerenciamento de pessoas jurídicas"}
|
||||
buttonText={"Nova Pessoa"}
|
||||
title={'Pessoas Jurídicas'}
|
||||
description={'Gerenciamento de pessoas jurídicas'}
|
||||
buttonText={'Nova Pessoa'}
|
||||
buttonAction={() => {
|
||||
handleOpenForm(null);
|
||||
}}
|
||||
/>
|
||||
|
||||
{/* Tabela de Registros */}
|
||||
<TPessoaJuridicaTable
|
||||
data={tPessoa}
|
||||
onDelete={handleConfirmDelete}
|
||||
onEdit={handleOpenForm}
|
||||
/>
|
||||
<TPessoaJuridicaTable data={tPessoa} onDelete={handleConfirmDelete} onEdit={handleOpenForm} />
|
||||
|
||||
{/* Modal de confirmação */}
|
||||
<ConfirmDialog
|
||||
|
|
|
|||
|
|
@ -1,37 +1,36 @@
|
|||
"use client";
|
||||
'use client';
|
||||
|
||||
import { useEffect, useState, useCallback } from "react";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
import { useEffect, useState, useCallback } from 'react';
|
||||
import { Card, CardContent } from '@/components/ui/card';
|
||||
|
||||
import Loading from "@/app/_components/loading/loading";
|
||||
import TTBAndamentoServicoTable from "../../_components/t_tb_andamentoservico/TTBAndamentoServicoTable";
|
||||
import TTBAndamentoServicoForm from "../../_components/t_tb_andamentoservico/TTBAndamentoServicoForm";
|
||||
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 { 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 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";
|
||||
import Header from "@/app/_components/structure/Header";
|
||||
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
|
||||
const { tTBAndamentosServicos, fetchTTBAndamentoServico } =
|
||||
useTTBAndamentoServicoReadHook();
|
||||
const { tTBAndamentosServicos, fetchTTBAndamentoServico } = useTTBAndamentoServicoReadHook();
|
||||
const { saveTTBAndamentoServico } = useTTBAndamentoServicoSaveHook();
|
||||
const { deleteTTBAndamentoServico } = useTTBAndamentoServicoDeleteHook();
|
||||
|
||||
// Estados
|
||||
const [selectedAndamento, setSelectedAndamento] =
|
||||
useState<TTBAndamentoServicoInterface | null>(null);
|
||||
const [selectedAndamento, setSelectedAndamento] = useState<TTBAndamentoServicoInterface | null>(
|
||||
null,
|
||||
);
|
||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||
|
||||
// Estado para saber qual item será deletado
|
||||
const [itemToDelete, setItemToDelete] =
|
||||
useState<TTBAndamentoServicoInterface | null>(null);
|
||||
const [itemToDelete, setItemToDelete] = useState<TTBAndamentoServicoInterface | null>(null);
|
||||
|
||||
/**
|
||||
* Hook do modal de confirmação
|
||||
|
|
@ -46,13 +45,10 @@ export default function TTBAndamentoServico() {
|
|||
/**
|
||||
* Abre o formulário no modo de edição ou criação
|
||||
*/
|
||||
const handleOpenForm = useCallback(
|
||||
(data: TTBAndamentoServicoInterface | null) => {
|
||||
setSelectedAndamento(data);
|
||||
setIsFormOpen(true);
|
||||
},
|
||||
[],
|
||||
);
|
||||
const handleOpenForm = useCallback((data: TTBAndamentoServicoInterface | null) => {
|
||||
setSelectedAndamento(data);
|
||||
setIsFormOpen(true);
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Fecha o formulário e limpa o andamento selecionado
|
||||
|
|
@ -125,9 +121,9 @@ export default function TTBAndamentoServico() {
|
|||
<div>
|
||||
{/* Cabeçalho */}
|
||||
<Header
|
||||
title={"Andamentos"}
|
||||
description={"Gerenciamento de Andamentos de Atos"}
|
||||
buttonText={"Novo Andamento"}
|
||||
title={'Andamentos'}
|
||||
description={'Gerenciamento de Andamentos de Atos'}
|
||||
buttonText={'Novo Andamento'}
|
||||
buttonAction={() => {
|
||||
handleOpenForm(null);
|
||||
}}
|
||||
|
|
|
|||
|
|
@ -1,21 +1,21 @@
|
|||
"use client";
|
||||
'use client';
|
||||
|
||||
import { useEffect, useState, useCallback } from "react";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
import { useEffect, useState, useCallback } from 'react';
|
||||
import { Card, CardContent } from '@/components/ui/card';
|
||||
|
||||
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";
|
||||
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';
|
||||
|
||||
import { useTTBReconhecimentoTipoReadHook } from "../../_hooks/t_tb_reconhecimentotipo/useTTBReconhecimentoTipoReadHook";
|
||||
import { useTTBReconhecimentoTipoSaveHook } from "../../_hooks/t_tb_reconhecimentotipo/useTTBReconhecimentoTipoSaveHook";
|
||||
import { useTTBReconhecimentoTipoDeleteHook } from "../../_hooks/t_tb_reconhecimentotipo/useTTBReconhecimentoTipoDeleteHook";
|
||||
import { useTTBReconhecimentoTipoReadHook } from '../../_hooks/t_tb_reconhecimentotipo/useTTBReconhecimentoTipoReadHook';
|
||||
import { useTTBReconhecimentoTipoSaveHook } from '../../_hooks/t_tb_reconhecimentotipo/useTTBReconhecimentoTipoSaveHook';
|
||||
import { useTTBReconhecimentoTipoDeleteHook } from '../../_hooks/t_tb_reconhecimentotipo/useTTBReconhecimentoTipoDeleteHook';
|
||||
|
||||
import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog";
|
||||
import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDialog";
|
||||
import ConfirmDialog from '@/app/_components/confirm_dialog/ConfirmDialog';
|
||||
import { useConfirmDialog } from '@/app/_components/confirm_dialog/useConfirmDialog';
|
||||
|
||||
import TTBReconhecimentoTipoInterface from "../../_interfaces/TTBReconhecimentoTipoInterface";
|
||||
import TTBReconhecimentoTipoInterface from '../../_interfaces/TTBReconhecimentoTipoInterface';
|
||||
|
||||
export default function TTBAndamentoServico() {
|
||||
// Hooks para leitura e salvamento
|
||||
|
|
@ -30,8 +30,7 @@ export default function TTBAndamentoServico() {
|
|||
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||
|
||||
// Estado para saber qual item será deletado
|
||||
const [itemToDelete, setItemToDelete] =
|
||||
useState<TTBReconhecimentoTipoInterface | null>(null);
|
||||
const [itemToDelete, setItemToDelete] = useState<TTBReconhecimentoTipoInterface | null>(null);
|
||||
|
||||
/**
|
||||
* Hook do modal de confirmação
|
||||
|
|
@ -46,13 +45,10 @@ export default function TTBAndamentoServico() {
|
|||
/**
|
||||
* Abre o formulário no modo de edição ou criação
|
||||
*/
|
||||
const handleOpenForm = useCallback(
|
||||
(data: TTBReconhecimentoTipoInterface | null) => {
|
||||
setReconhecimentoTipo(data);
|
||||
setIsFormOpen(true);
|
||||
},
|
||||
[],
|
||||
);
|
||||
const handleOpenForm = useCallback((data: TTBReconhecimentoTipoInterface | null) => {
|
||||
setReconhecimentoTipo(data);
|
||||
setIsFormOpen(true);
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Fecha o formulário e limpa o andamento selecionado
|
||||
|
|
@ -128,9 +124,9 @@ export default function TTBAndamentoServico() {
|
|||
<div>
|
||||
{/* Cabeçalho */}
|
||||
<Header
|
||||
title={"Reconhecimentos"}
|
||||
description={"Gerenciamento de tipos de reconhecimentos"}
|
||||
buttonText={"Novo Tipo"}
|
||||
title={'Reconhecimentos'}
|
||||
description={'Gerenciamento de tipos de reconhecimentos'}
|
||||
buttonText={'Novo Tipo'}
|
||||
buttonAction={() => {
|
||||
handleOpenForm(null);
|
||||
}}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
"use client";
|
||||
'use client';
|
||||
|
||||
import z from "zod";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import z from 'zod';
|
||||
import { useForm } from 'react-hook-form';
|
||||
import { zodResolver } from '@hookform/resolvers/zod';
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
Dialog,
|
||||
DialogClose,
|
||||
|
|
@ -13,7 +13,7 @@ import {
|
|||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from "@/components/ui/dialog";
|
||||
} from '@/components/ui/dialog';
|
||||
import {
|
||||
Form,
|
||||
FormControl,
|
||||
|
|
@ -21,21 +21,21 @@ import {
|
|||
FormItem,
|
||||
FormLabel,
|
||||
FormMessage,
|
||||
} from "@/components/ui/form";
|
||||
import { Input } from "@/components/ui/input";
|
||||
} from '@/components/ui/form';
|
||||
import { Input } from '@/components/ui/input';
|
||||
|
||||
import { GCidadeSchema } from "../../_schemas/GCidadeSchema";
|
||||
import { useEffect } from "react";
|
||||
import { GCidadeSchema } from '../../_schemas/GCidadeSchema';
|
||||
import { useEffect } from 'react';
|
||||
|
||||
// Hook responsável em trazer todos os estados brasileiros
|
||||
import { useGUfReadHook } from "../../_hooks/g_uf/useGUfReadHook";
|
||||
import { useGUfReadHook } from '../../_hooks/g_uf/useGUfReadHook';
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from "@/components/ui/select";
|
||||
} from '@/components/ui/select';
|
||||
|
||||
// Define o tipo do formulário com base no schema Zod
|
||||
type FormValues = z.infer<typeof GCidadeSchema>;
|
||||
|
|
@ -58,10 +58,10 @@ export default function GCidadeForm({ isOpen, data, onClose, onSave }: Props) {
|
|||
resolver: zodResolver(GCidadeSchema),
|
||||
defaultValues: {
|
||||
cidade_id: 0,
|
||||
uf: "",
|
||||
cidade_nome: "",
|
||||
codigo_ibge: "",
|
||||
codigo_gyn: "",
|
||||
uf: '',
|
||||
cidade_nome: '',
|
||||
codigo_ibge: '',
|
||||
codigo_gyn: '',
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -146,10 +146,7 @@ export default function GCidadeForm({ isOpen, data, onClose, onSave }: Props) {
|
|||
</FormControl>
|
||||
<SelectContent>
|
||||
{gUf.map((item) => (
|
||||
<SelectItem
|
||||
key={item.g_uf_id}
|
||||
value={String(item.sigla)}
|
||||
>
|
||||
<SelectItem key={item.g_uf_id} value={String(item.sigla)}>
|
||||
{item.nome}
|
||||
</SelectItem>
|
||||
))}
|
||||
|
|
@ -181,7 +178,7 @@ export default function GCidadeForm({ isOpen, data, onClose, onSave }: Props) {
|
|||
</DialogFooter>
|
||||
|
||||
{/* Campo oculto: ID da cidade */}
|
||||
<input type="hidden" {...form.register("cidade_id")} />
|
||||
<input type="hidden" {...form.register('cidade_id')} />
|
||||
</form>
|
||||
</Form>
|
||||
</DialogContent>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
"use client";
|
||||
'use client';
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
|
|
@ -8,7 +8,7 @@ import {
|
|||
DropdownMenuItem,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger,
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
} from '@/components/ui/dropdown-menu';
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
|
|
@ -16,10 +16,10 @@ import {
|
|||
TableHead,
|
||||
TableHeader,
|
||||
TableRow,
|
||||
} from "@/components/ui/table";
|
||||
} from '@/components/ui/table';
|
||||
|
||||
import { EllipsisIcon, PencilIcon, Trash2Icon } from "lucide-react";
|
||||
import GCidadeInterface from "../../_interfaces/GCidadeInterface";
|
||||
import { EllipsisIcon, PencilIcon, Trash2Icon } from 'lucide-react';
|
||||
import GCidadeInterface from '../../_interfaces/GCidadeInterface';
|
||||
|
||||
// Tipagem das props do componente da tabela
|
||||
interface GCidadeTableProps {
|
||||
|
|
@ -32,25 +32,21 @@ interface GCidadeTableProps {
|
|||
* Renderiza o "badge" de status da cidade (Ativo/Inativo)
|
||||
*/
|
||||
function StatusBadge({ situacao }: { situacao: string }) {
|
||||
const isActive = situacao === "A"; // define se está ativo ou inativo
|
||||
const isActive = situacao === 'A'; // define se está ativo ou inativo
|
||||
|
||||
// Estilos base
|
||||
const baseClasses = "text-xs font-medium px-2.5 py-0.5 rounded-sm me-2";
|
||||
const baseClasses = 'text-xs font-medium px-2.5 py-0.5 rounded-sm me-2';
|
||||
|
||||
// Estilo para ativo
|
||||
const activeClasses =
|
||||
"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-300";
|
||||
const activeClasses = 'bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-300';
|
||||
|
||||
// Estilo para inativo
|
||||
const inactiveClasses =
|
||||
"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300";
|
||||
const inactiveClasses = 'bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300';
|
||||
|
||||
// Retorna o badge com classe condicional
|
||||
return (
|
||||
<span
|
||||
className={`${baseClasses} ${isActive ? activeClasses : inactiveClasses}`}
|
||||
>
|
||||
{isActive ? "Ativo" : "Inativo"}
|
||||
<span className={`${baseClasses} ${isActive ? activeClasses : inactiveClasses}`}>
|
||||
{isActive ? 'Ativo' : 'Inativo'}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
|
@ -58,13 +54,9 @@ function StatusBadge({ situacao }: { situacao: string }) {
|
|||
/**
|
||||
* Componente principal da tabela de cidades
|
||||
*/
|
||||
export default function GCidadeTable({
|
||||
data,
|
||||
onEdit,
|
||||
onDelete,
|
||||
}: GCidadeTableProps) {
|
||||
export default function GCidadeTable({ data, onEdit, onDelete }: GCidadeTableProps) {
|
||||
return (
|
||||
<Table className="table-fixed w-full">
|
||||
<Table className="w-full table-fixed">
|
||||
{/* Cabeçalho da tabela */}
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
|
|
@ -97,11 +89,7 @@ export default function GCidadeTable({
|
|||
<DropdownMenu>
|
||||
{/* Botão de disparo do menu */}
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<Button variant="outline" size="icon" className="cursor-pointer">
|
||||
<EllipsisIcon />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
"use client";
|
||||
'use client';
|
||||
|
||||
import z from "zod";
|
||||
import { useEffect } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import z from 'zod';
|
||||
import { useEffect } from 'react';
|
||||
import { useForm } from 'react-hook-form';
|
||||
import { zodResolver } from '@hookform/resolvers/zod';
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
Dialog,
|
||||
DialogClose,
|
||||
|
|
@ -14,7 +14,7 @@ import {
|
|||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from "@/components/ui/dialog";
|
||||
} from '@/components/ui/dialog';
|
||||
import {
|
||||
Form,
|
||||
FormControl,
|
||||
|
|
@ -22,11 +22,11 @@ import {
|
|||
FormItem,
|
||||
FormLabel,
|
||||
FormMessage,
|
||||
} from "@/components/ui/form";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import LoadingButton from "@/app/_components/loadingButton/LoadingButton";
|
||||
import { GMedidaTipoSchema } from "../../_schemas/GMedidaTipoSchema";
|
||||
import { GMedidaTipoInterface } from "../../_interfaces/GMedidaTipoInterface";
|
||||
} from '@/components/ui/form';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import LoadingButton from '@/app/_components/loadingButton/LoadingButton';
|
||||
import { GMedidaTipoSchema } from '../../_schemas/GMedidaTipoSchema';
|
||||
import { GMedidaTipoInterface } from '../../_interfaces/GMedidaTipoInterface';
|
||||
|
||||
type FormValues = z.infer<typeof GMedidaTipoSchema>;
|
||||
|
||||
|
|
@ -50,8 +50,8 @@ export default function GMedidaTipoForm({
|
|||
resolver: zodResolver(GMedidaTipoSchema),
|
||||
defaultValues: {
|
||||
medida_tipo_id: 0,
|
||||
sigla: "",
|
||||
descricao: "",
|
||||
sigla: '',
|
||||
descricao: '',
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -127,7 +127,7 @@ export default function GMedidaTipoForm({
|
|||
</DialogFooter>
|
||||
|
||||
{/* Campo oculto */}
|
||||
<input type="hidden" {...form.register("medida_tipo_id")} />
|
||||
<input type="hidden" {...form.register('medida_tipo_id')} />
|
||||
</form>
|
||||
</Form>
|
||||
</DialogContent>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
"use client";
|
||||
'use client';
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
|
|
@ -8,7 +8,7 @@ import {
|
|||
DropdownMenuItem,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger,
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
} from '@/components/ui/dropdown-menu';
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
|
|
@ -16,9 +16,9 @@ import {
|
|||
TableHead,
|
||||
TableHeader,
|
||||
TableRow,
|
||||
} from "@/components/ui/table";
|
||||
import { EllipsisIcon, PencilIcon, Trash2Icon } from "lucide-react";
|
||||
import { GMedidaTipoInterface } from "../../_interfaces/GMedidaTipoInterface";
|
||||
} from '@/components/ui/table';
|
||||
import { EllipsisIcon, PencilIcon, Trash2Icon } from 'lucide-react';
|
||||
import { GMedidaTipoInterface } from '../../_interfaces/GMedidaTipoInterface';
|
||||
|
||||
interface GMedidaTipoTableProps {
|
||||
data: GMedidaTipoInterface[];
|
||||
|
|
@ -26,11 +26,7 @@ interface GMedidaTipoTableProps {
|
|||
onDelete: (item: GMedidaTipoInterface, isEditingFormStatus: boolean) => void;
|
||||
}
|
||||
|
||||
export default function GMedidaTipoTable({
|
||||
data,
|
||||
onEdit,
|
||||
onDelete,
|
||||
}: GMedidaTipoTableProps) {
|
||||
export default function GMedidaTipoTable({ data, onEdit, onDelete }: GMedidaTipoTableProps) {
|
||||
return (
|
||||
<Table>
|
||||
<TableHeader>
|
||||
|
|
@ -51,11 +47,7 @@ export default function GMedidaTipoTable({
|
|||
<TableCell className="text-right">
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<Button variant="outline" size="icon" className="cursor-pointer">
|
||||
<EllipsisIcon />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
"use client";
|
||||
'use client';
|
||||
|
||||
import z from "zod";
|
||||
import { useEffect, useState } from "react";
|
||||
import { useForm, Controller } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import z from 'zod';
|
||||
import { useEffect, useState } 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 { Button } from '@/components/ui/button';
|
||||
import { Checkbox } from '@/components/ui/checkbox';
|
||||
import {
|
||||
Dialog,
|
||||
DialogClose,
|
||||
|
|
@ -15,7 +15,7 @@ import {
|
|||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from "@/components/ui/dialog";
|
||||
} from '@/components/ui/dialog';
|
||||
import {
|
||||
Form,
|
||||
FormControl,
|
||||
|
|
@ -23,13 +23,13 @@ import {
|
|||
FormItem,
|
||||
FormLabel,
|
||||
FormMessage,
|
||||
} from "@/components/ui/form";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
} from '@/components/ui/form';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Label } from '@/components/ui/label';
|
||||
|
||||
import { GTBBairroSchema } from "../../_schemas/GTBBairroSchema";
|
||||
import LoadingButton from "@/app/_components/loadingButton/LoadingButton";
|
||||
import { SituacoesEnum } from "@/enums/SituacoesEnum";
|
||||
import { GTBBairroSchema } from '../../_schemas/GTBBairroSchema';
|
||||
import LoadingButton from '@/app/_components/loadingButton/LoadingButton';
|
||||
import { SituacoesEnum } from '@/enums/SituacoesEnum';
|
||||
|
||||
type FormValues = z.infer<typeof GTBBairroSchema>;
|
||||
|
||||
|
|
@ -54,7 +54,7 @@ export default function GTBBairroForm({
|
|||
defaultValues: {
|
||||
sistema_id: null,
|
||||
tb_bairro_id: 0,
|
||||
descricao: "",
|
||||
descricao: '',
|
||||
situacao: SituacoesEnum.A,
|
||||
},
|
||||
});
|
||||
|
|
@ -87,10 +87,7 @@ export default function GTBBairroForm({
|
|||
<FormItem>
|
||||
<FormLabel>Descrição</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
placeholder="Digite a descrição do bairro"
|
||||
/>
|
||||
<Input {...field} placeholder="Digite a descrição do bairro" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
|
|
@ -104,10 +101,8 @@ export default function GTBBairroForm({
|
|||
render={({ field }) => (
|
||||
<div className="flex items-center space-x-2">
|
||||
<Checkbox
|
||||
checked={field.value === "A"}
|
||||
onCheckedChange={(checked) =>
|
||||
field.onChange(checked ? "A" : "I")
|
||||
}
|
||||
checked={field.value === 'A'}
|
||||
onCheckedChange={(checked) => field.onChange(checked ? 'A' : 'I')}
|
||||
/>
|
||||
<Label>Ativo</Label>
|
||||
</div>
|
||||
|
|
@ -136,8 +131,8 @@ export default function GTBBairroForm({
|
|||
</DialogFooter>
|
||||
|
||||
{/* Campos ocultos */}
|
||||
<input type="hidden" {...form.register("tb_bairro_id")} />
|
||||
<input type="hidden" {...form.register("sistema_id")} />
|
||||
<input type="hidden" {...form.register('tb_bairro_id')} />
|
||||
<input type="hidden" {...form.register('sistema_id')} />
|
||||
</form>
|
||||
</Form>
|
||||
</DialogContent>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
"use client";
|
||||
'use client';
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
|
|
@ -8,7 +8,7 @@ import {
|
|||
DropdownMenuItem,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger,
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
} from '@/components/ui/dropdown-menu';
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
|
|
@ -16,9 +16,9 @@ import {
|
|||
TableHead,
|
||||
TableHeader,
|
||||
TableRow,
|
||||
} from "@/components/ui/table";
|
||||
import { EllipsisIcon, PencilIcon, Trash2Icon } from "lucide-react";
|
||||
import { GTBBairroInterface } from "../../_interfaces/GTBBairroInterface";
|
||||
} from '@/components/ui/table';
|
||||
import { EllipsisIcon, PencilIcon, Trash2Icon } from 'lucide-react';
|
||||
import { GTBBairroInterface } from '../../_interfaces/GTBBairroInterface';
|
||||
|
||||
interface GTBBairroTableProps {
|
||||
data: GTBBairroInterface[];
|
||||
|
|
@ -29,31 +29,23 @@ interface GTBBairroTableProps {
|
|||
/**
|
||||
* Renderiza o badge de situação
|
||||
*/
|
||||
function StatusBadge({ situacao }: { situacao: "A" | "I" }) {
|
||||
const isActive = situacao === "A";
|
||||
function StatusBadge({ situacao }: { situacao: 'A' | 'I' }) {
|
||||
const isActive = situacao === 'A';
|
||||
|
||||
const baseClasses = "text-xs font-medium px-2.5 py-0.5 rounded-sm me-2";
|
||||
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 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";
|
||||
const inactiveClasses = 'bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300';
|
||||
|
||||
return (
|
||||
<span
|
||||
className={`${baseClasses} ${isActive ? activeClasses : inactiveClasses}`}
|
||||
>
|
||||
{isActive ? "Ativo" : "Inativo"}
|
||||
<span className={`${baseClasses} ${isActive ? activeClasses : inactiveClasses}`}>
|
||||
{isActive ? 'Ativo' : 'Inativo'}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
export default function GTBBairroTable({
|
||||
data,
|
||||
onEdit,
|
||||
onDelete,
|
||||
}: GTBBairroTableProps) {
|
||||
export default function GTBBairroTable({ data, onEdit, onDelete }: GTBBairroTableProps) {
|
||||
return (
|
||||
<Table>
|
||||
<TableHeader>
|
||||
|
|
@ -79,11 +71,7 @@ export default function GTBBairroTable({
|
|||
<TableCell className="text-right">
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<Button variant="outline" size="icon" className="cursor-pointer">
|
||||
<EllipsisIcon />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
"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 z from 'zod';
|
||||
import { useEffect } from 'react';
|
||||
import { useForm, Controller } from 'react-hook-form';
|
||||
import { zodResolver } from '@hookform/resolvers/zod';
|
||||
|
||||
import LoadingButton from "@/app/_components/loadingButton/LoadingButton";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Checkbox } from "@/components/ui/checkbox";
|
||||
import LoadingButton from '@/app/_components/loadingButton/LoadingButton';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Checkbox } from '@/components/ui/checkbox';
|
||||
import {
|
||||
Dialog,
|
||||
DialogClose,
|
||||
|
|
@ -16,7 +16,7 @@ import {
|
|||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from "@/components/ui/dialog";
|
||||
} from '@/components/ui/dialog';
|
||||
import {
|
||||
Form,
|
||||
FormControl,
|
||||
|
|
@ -24,12 +24,12 @@ import {
|
|||
FormItem,
|
||||
FormLabel,
|
||||
FormMessage,
|
||||
} from "@/components/ui/form";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
} from '@/components/ui/form';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Label } from '@/components/ui/label';
|
||||
|
||||
import { GTBEstadoCivilSchema } from "../../_schemas/GTBEstadoCivilSchema";
|
||||
import { GTBEstadoCivilInterface } from "../../_interfaces/GTBEstadoCivilInterface";
|
||||
import { GTBEstadoCivilSchema } from '../../_schemas/GTBEstadoCivilSchema';
|
||||
import { GTBEstadoCivilInterface } from '../../_interfaces/GTBEstadoCivilInterface';
|
||||
|
||||
type FormValues = z.infer<typeof GTBEstadoCivilSchema>;
|
||||
|
||||
|
|
@ -54,8 +54,8 @@ export default function GTBEstadoCivilForm({
|
|||
defaultValues: {
|
||||
tb_estadocivil_id: 0,
|
||||
sistema_id: 0,
|
||||
descricao: "",
|
||||
situacao: "A",
|
||||
descricao: '',
|
||||
situacao: 'A',
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -101,10 +101,8 @@ export default function GTBEstadoCivilForm({
|
|||
render={({ field }) => (
|
||||
<div className="flex items-center space-x-2">
|
||||
<Checkbox
|
||||
checked={field.value === "A"}
|
||||
onCheckedChange={(checked) =>
|
||||
field.onChange(checked ? "A" : "I")
|
||||
}
|
||||
checked={field.value === 'A'}
|
||||
onCheckedChange={(checked) => field.onChange(checked ? 'A' : 'I')}
|
||||
/>
|
||||
<Label>Ativo</Label>
|
||||
</div>
|
||||
|
|
@ -133,14 +131,8 @@ export default function GTBEstadoCivilForm({
|
|||
</DialogFooter>
|
||||
|
||||
{/* Campos ocultos */}
|
||||
<input
|
||||
type="hidden"
|
||||
{...form.register("tb_estadocivil_id", { valueAsNumber: true })}
|
||||
/>
|
||||
<input
|
||||
type="hidden"
|
||||
{...form.register("sistema_id", { valueAsNumber: true })}
|
||||
/>
|
||||
<input type="hidden" {...form.register('tb_estadocivil_id', { valueAsNumber: true })} />
|
||||
<input type="hidden" {...form.register('sistema_id', { valueAsNumber: true })} />
|
||||
</form>
|
||||
</Form>
|
||||
</DialogContent>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
"use client";
|
||||
'use client';
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
|
|
@ -8,7 +8,7 @@ import {
|
|||
DropdownMenuItem,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger,
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
} from '@/components/ui/dropdown-menu';
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
|
|
@ -16,47 +16,36 @@ import {
|
|||
TableHead,
|
||||
TableHeader,
|
||||
TableRow,
|
||||
} from "@/components/ui/table";
|
||||
import { EllipsisIcon, PencilIcon, Trash2Icon } from "lucide-react";
|
||||
import { GTBEstadoCivilInterface } from "../../_interfaces/GTBEstadoCivilInterface";
|
||||
} from '@/components/ui/table';
|
||||
import { EllipsisIcon, PencilIcon, Trash2Icon } from 'lucide-react';
|
||||
import { GTBEstadoCivilInterface } from '../../_interfaces/GTBEstadoCivilInterface';
|
||||
|
||||
interface TBEstadoCivilTableProps {
|
||||
data: GTBEstadoCivilInterface[];
|
||||
onEdit: (item: GTBEstadoCivilInterface, isEditingFormStatus: boolean) => void;
|
||||
onDelete: (
|
||||
item: GTBEstadoCivilInterface,
|
||||
isEditingFormStatus: boolean,
|
||||
) => void;
|
||||
onDelete: (item: GTBEstadoCivilInterface, isEditingFormStatus: boolean) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renderiza o badge de situação
|
||||
*/
|
||||
function StatusBadge({ situacao }: { situacao: "A" | "I" }) {
|
||||
const isActive = situacao === "A";
|
||||
function StatusBadge({ situacao }: { situacao: 'A' | 'I' }) {
|
||||
const isActive = situacao === 'A';
|
||||
|
||||
const baseClasses = "text-xs font-medium px-2.5 py-0.5 rounded-sm me-2";
|
||||
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 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";
|
||||
const inactiveClasses = 'bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300';
|
||||
|
||||
return (
|
||||
<span
|
||||
className={`${baseClasses} ${isActive ? activeClasses : inactiveClasses}`}
|
||||
>
|
||||
{isActive ? "Ativo" : "Inativo"}
|
||||
<span className={`${baseClasses} ${isActive ? activeClasses : inactiveClasses}`}>
|
||||
{isActive ? 'Ativo' : 'Inativo'}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
export default function GTBEstadoCivilTable({
|
||||
data,
|
||||
onEdit,
|
||||
onDelete,
|
||||
}: TBEstadoCivilTableProps) {
|
||||
export default function GTBEstadoCivilTable({ data, onEdit, onDelete }: TBEstadoCivilTableProps) {
|
||||
return (
|
||||
<Table>
|
||||
<TableHeader>
|
||||
|
|
@ -71,9 +60,7 @@ export default function GTBEstadoCivilTable({
|
|||
<TableBody>
|
||||
{data.map((item) => (
|
||||
<TableRow key={item.tb_estadocivil_id} className="cursor-pointer">
|
||||
<TableCell className="font-medium">
|
||||
{item.tb_estadocivil_id}
|
||||
</TableCell>
|
||||
<TableCell className="font-medium">{item.tb_estadocivil_id}</TableCell>
|
||||
|
||||
<TableCell>
|
||||
<StatusBadge situacao={item.situacao} />
|
||||
|
|
@ -84,11 +71,7 @@ export default function GTBEstadoCivilTable({
|
|||
<TableCell className="text-right">
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<Button variant="outline" size="icon" className="cursor-pointer">
|
||||
<EllipsisIcon />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
"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 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 { Button } from '@/components/ui/button';
|
||||
import { Checkbox } from '@/components/ui/checkbox';
|
||||
import {
|
||||
Dialog,
|
||||
DialogClose,
|
||||
|
|
@ -15,7 +15,7 @@ import {
|
|||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from "@/components/ui/dialog";
|
||||
} from '@/components/ui/dialog';
|
||||
import {
|
||||
Form,
|
||||
FormControl,
|
||||
|
|
@ -23,11 +23,11 @@ import {
|
|||
FormItem,
|
||||
FormLabel,
|
||||
FormMessage,
|
||||
} from "@/components/ui/form";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
} from '@/components/ui/form';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Label } from '@/components/ui/label';
|
||||
|
||||
import { GTBProfissaoSchema } from "../../_schemas/GTBProfissaoSchema";
|
||||
import { GTBProfissaoSchema } from '../../_schemas/GTBProfissaoSchema';
|
||||
|
||||
type FormValues = z.infer<typeof GTBProfissaoSchema>;
|
||||
|
||||
|
|
@ -38,19 +38,14 @@ interface Props {
|
|||
onSave: (data: FormValues) => void;
|
||||
}
|
||||
|
||||
export default function GTBProfissaoForm({
|
||||
isOpen,
|
||||
data,
|
||||
onClose,
|
||||
onSave,
|
||||
}: Props) {
|
||||
export default function GTBProfissaoForm({ isOpen, data, onClose, onSave }: Props) {
|
||||
// Inicializa o react-hook-form com schema zod
|
||||
const form = useForm<FormValues>({
|
||||
resolver: zodResolver(GTBProfissaoSchema),
|
||||
defaultValues: {
|
||||
descricao: "",
|
||||
cod_cbo: "",
|
||||
situacao: "A",
|
||||
descricao: '',
|
||||
cod_cbo: '',
|
||||
situacao: 'A',
|
||||
tb_profissao_id: 0,
|
||||
},
|
||||
});
|
||||
|
|
@ -83,11 +78,7 @@ export default function GTBProfissaoForm({
|
|||
<FormItem>
|
||||
<FormLabel>Descrição</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
type="text"
|
||||
{...field}
|
||||
placeholder="Digite a descrição"
|
||||
/>
|
||||
<Input type="text" {...field} placeholder="Digite a descrição" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
|
|
@ -102,11 +93,7 @@ export default function GTBProfissaoForm({
|
|||
<FormItem>
|
||||
<FormLabel>CBO</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
type="nubmer"
|
||||
{...field}
|
||||
placeholder="Digite o código"
|
||||
/>
|
||||
<Input type="nubmer" {...field} placeholder="Digite o código" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
|
|
@ -120,10 +107,8 @@ export default function GTBProfissaoForm({
|
|||
render={({ field }) => (
|
||||
<div className="flex items-center space-x-2">
|
||||
<Checkbox
|
||||
checked={field.value === "A"}
|
||||
onCheckedChange={(checked) =>
|
||||
field.onChange(checked ? "A" : "I")
|
||||
}
|
||||
checked={field.value === 'A'}
|
||||
onCheckedChange={(checked) => field.onChange(checked ? 'A' : 'I')}
|
||||
/>
|
||||
<Label>Ativo</Label>
|
||||
</div>
|
||||
|
|
@ -148,7 +133,7 @@ export default function GTBProfissaoForm({
|
|||
</DialogFooter>
|
||||
|
||||
{/* Campo oculto */}
|
||||
<input type="hidden" {...form.register("tb_profissao_id")} />
|
||||
<input type="hidden" {...form.register('tb_profissao_id')} />
|
||||
</form>
|
||||
</Form>
|
||||
</DialogContent>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
"use client";
|
||||
'use client';
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
|
|
@ -8,7 +8,7 @@ import {
|
|||
DropdownMenuItem,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger,
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
} from '@/components/ui/dropdown-menu';
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
|
|
@ -16,10 +16,10 @@ import {
|
|||
TableHead,
|
||||
TableHeader,
|
||||
TableRow,
|
||||
} from "@/components/ui/table";
|
||||
} from '@/components/ui/table';
|
||||
|
||||
import { EllipsisIcon, PencilIcon, Trash2Icon } from "lucide-react";
|
||||
import GTBProfissaoInterface from "../../_interfaces/GTBProfissaoInterface";
|
||||
import { EllipsisIcon, PencilIcon, Trash2Icon } from 'lucide-react';
|
||||
import GTBProfissaoInterface from '../../_interfaces/GTBProfissaoInterface';
|
||||
|
||||
interface GTBProfissaoTableProps {
|
||||
data: GTBProfissaoInterface[];
|
||||
|
|
@ -31,30 +31,22 @@ interface GTBProfissaoTableProps {
|
|||
* Renderiza o badge de situação
|
||||
*/
|
||||
function StatusBadge({ situacao }: { situacao: string }) {
|
||||
const isActive = situacao === "A";
|
||||
const isActive = situacao === 'A';
|
||||
|
||||
const baseClasses = "text-xs font-medium px-2.5 py-0.5 rounded-sm me-2";
|
||||
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 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";
|
||||
const inactiveClasses = 'bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300';
|
||||
|
||||
return (
|
||||
<span
|
||||
className={`${baseClasses} ${isActive ? activeClasses : inactiveClasses}`}
|
||||
>
|
||||
{isActive ? "Ativo" : "Inativo"}
|
||||
<span className={`${baseClasses} ${isActive ? activeClasses : inactiveClasses}`}>
|
||||
{isActive ? 'Ativo' : 'Inativo'}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
export default function GTBProfissaoTable({
|
||||
data,
|
||||
onEdit,
|
||||
onDelete,
|
||||
}: GTBProfissaoTableProps) {
|
||||
export default function GTBProfissaoTable({ data, onEdit, onDelete }: GTBProfissaoTableProps) {
|
||||
return (
|
||||
<Table>
|
||||
<TableHeader>
|
||||
|
|
@ -70,9 +62,7 @@ export default function GTBProfissaoTable({
|
|||
<TableBody>
|
||||
{data.map((item) => (
|
||||
<TableRow key={item.tb_profissao_id} className="cursor-pointer">
|
||||
<TableCell className="font-medium">
|
||||
{item.tb_profissao_id}
|
||||
</TableCell>
|
||||
<TableCell className="font-medium">{item.tb_profissao_id}</TableCell>
|
||||
|
||||
<TableCell>
|
||||
<StatusBadge situacao={item.situacao} />
|
||||
|
|
@ -85,11 +75,7 @@ export default function GTBProfissaoTable({
|
|||
<TableCell className="text-right">
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<Button variant="outline" size="icon" className="cursor-pointer">
|
||||
<EllipsisIcon />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
"use client";
|
||||
'use client';
|
||||
|
||||
import z from "zod";
|
||||
import { useForm, Controller } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import z from 'zod';
|
||||
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 { Button } from '@/components/ui/button';
|
||||
import { Checkbox } from '@/components/ui/checkbox';
|
||||
import {
|
||||
Dialog,
|
||||
DialogClose,
|
||||
|
|
@ -14,7 +14,7 @@ import {
|
|||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from "@/components/ui/dialog";
|
||||
} from '@/components/ui/dialog';
|
||||
import {
|
||||
Form,
|
||||
FormControl,
|
||||
|
|
@ -22,12 +22,12 @@ import {
|
|||
FormItem,
|
||||
FormLabel,
|
||||
FormMessage,
|
||||
} from "@/components/ui/form";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
} from '@/components/ui/form';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Label } from '@/components/ui/label';
|
||||
|
||||
import { GTBRegimeBensSchema } from "../../_schemas/GTBRegimeBensSchema";
|
||||
import { useEffect } from "react";
|
||||
import { GTBRegimeBensSchema } from '../../_schemas/GTBRegimeBensSchema';
|
||||
import { useEffect } from 'react';
|
||||
|
||||
type FormValues = z.infer<typeof GTBRegimeBensSchema>;
|
||||
|
||||
|
|
@ -38,19 +38,14 @@ interface Props {
|
|||
onSave: (data: FormValues) => void;
|
||||
}
|
||||
|
||||
export default function GTBRegimeComunhaoForm({
|
||||
isOpen,
|
||||
data,
|
||||
onClose,
|
||||
onSave,
|
||||
}: Props) {
|
||||
export default function GTBRegimeComunhaoForm({ isOpen, data, onClose, onSave }: Props) {
|
||||
// Inicializa o react-hook-form com schema zod
|
||||
const form = useForm<FormValues>({
|
||||
resolver: zodResolver(GTBRegimeBensSchema),
|
||||
defaultValues: {
|
||||
tb_regimebens_id: 0,
|
||||
descricao: "",
|
||||
situacao: "",
|
||||
descricao: '',
|
||||
situacao: '',
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -96,10 +91,8 @@ export default function GTBRegimeComunhaoForm({
|
|||
render={({ field }) => (
|
||||
<div className="flex items-center space-x-2">
|
||||
<Checkbox
|
||||
checked={field.value === "A"}
|
||||
onCheckedChange={(checked) =>
|
||||
field.onChange(checked ? "A" : "I")
|
||||
}
|
||||
checked={field.value === 'A'}
|
||||
onCheckedChange={(checked) => field.onChange(checked ? 'A' : 'I')}
|
||||
/>
|
||||
<Label>Ativo</Label>
|
||||
</div>
|
||||
|
|
@ -124,7 +117,7 @@ export default function GTBRegimeComunhaoForm({
|
|||
</DialogFooter>
|
||||
|
||||
{/* Campo oculto */}
|
||||
<input type="hidden" {...form.register("tb_regimebens_id")} />
|
||||
<input type="hidden" {...form.register('tb_regimebens_id')} />
|
||||
</form>
|
||||
</Form>
|
||||
</DialogContent>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
"use client";
|
||||
'use client';
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
|
|
@ -8,7 +8,7 @@ import {
|
|||
DropdownMenuItem,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger,
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
} from '@/components/ui/dropdown-menu';
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
|
|
@ -16,48 +16,37 @@ import {
|
|||
TableHead,
|
||||
TableHeader,
|
||||
TableRow,
|
||||
} from "@/components/ui/table";
|
||||
} from '@/components/ui/table';
|
||||
|
||||
import { EllipsisIcon, PencilIcon, Trash2Icon } from "lucide-react";
|
||||
import GTBRegimeBensInterface from "../../_interfaces/GTBRegimeBensInterface";
|
||||
import { EllipsisIcon, PencilIcon, Trash2Icon } from 'lucide-react';
|
||||
import GTBRegimeBensInterface from '../../_interfaces/GTBRegimeBensInterface';
|
||||
|
||||
interface GTBRegimeBensTableProps {
|
||||
data: GTBRegimeBensInterface[];
|
||||
onEdit: (item: GTBRegimeBensInterface, isEditingFormStatus: boolean) => void;
|
||||
onDelete: (
|
||||
item: GTBRegimeBensInterface,
|
||||
isEditingFormStatus: boolean,
|
||||
) => void;
|
||||
onDelete: (item: GTBRegimeBensInterface, isEditingFormStatus: boolean) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renderiza o badge de situação
|
||||
*/
|
||||
function StatusBadge({ situacao }: { situacao: string }) {
|
||||
const isActive = situacao === "A";
|
||||
const isActive = situacao === 'A';
|
||||
|
||||
const baseClasses = "text-xs font-medium px-2.5 py-0.5 rounded-sm me-2";
|
||||
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 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";
|
||||
const inactiveClasses = 'bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300';
|
||||
|
||||
return (
|
||||
<span
|
||||
className={`${baseClasses} ${isActive ? activeClasses : inactiveClasses}`}
|
||||
>
|
||||
{isActive ? "Ativo" : "Inativo"}
|
||||
<span className={`${baseClasses} ${isActive ? activeClasses : inactiveClasses}`}>
|
||||
{isActive ? 'Ativo' : 'Inativo'}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
export default function GTBRegimeBensTable({
|
||||
data,
|
||||
onEdit,
|
||||
onDelete,
|
||||
}: GTBRegimeBensTableProps) {
|
||||
export default function GTBRegimeBensTable({ data, onEdit, onDelete }: GTBRegimeBensTableProps) {
|
||||
return (
|
||||
<Table>
|
||||
<TableHeader>
|
||||
|
|
@ -72,9 +61,7 @@ export default function GTBRegimeBensTable({
|
|||
<TableBody>
|
||||
{data.map((item) => (
|
||||
<TableRow key={item.tb_regimebens_id} className="cursor-pointer">
|
||||
<TableCell className="font-medium">
|
||||
{item.tb_regimebens_id}
|
||||
</TableCell>
|
||||
<TableCell className="font-medium">{item.tb_regimebens_id}</TableCell>
|
||||
|
||||
<TableCell>
|
||||
<StatusBadge situacao={item.situacao} />
|
||||
|
|
@ -85,11 +72,7 @@ export default function GTBRegimeBensTable({
|
|||
<TableCell className="text-right">
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<Button variant="outline" size="icon" className="cursor-pointer">
|
||||
<EllipsisIcon />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
"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 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 { Button } from '@/components/ui/button';
|
||||
import { Checkbox } from '@/components/ui/checkbox';
|
||||
import {
|
||||
Dialog,
|
||||
DialogClose,
|
||||
|
|
@ -15,7 +15,7 @@ import {
|
|||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from "@/components/ui/dialog";
|
||||
} from '@/components/ui/dialog';
|
||||
import {
|
||||
Form,
|
||||
FormControl,
|
||||
|
|
@ -23,19 +23,19 @@ import {
|
|||
FormItem,
|
||||
FormLabel,
|
||||
FormMessage,
|
||||
} from "@/components/ui/form";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
} from '@/components/ui/form';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Label } from '@/components/ui/label';
|
||||
|
||||
import { GTBRegimeComunhaoSchema } from "../../_schemas/GTBRegimeComunhaoSchema";
|
||||
import { GTBRegimeComunhaoSchema } from '../../_schemas/GTBRegimeComunhaoSchema';
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from "@/components/ui/select";
|
||||
import { useGTBRegimeBensReadHook } from "../../_hooks/g_tb_regimebens/useGTBRegimeBensReadHook";
|
||||
} from '@/components/ui/select';
|
||||
import { useGTBRegimeBensReadHook } from '../../_hooks/g_tb_regimebens/useGTBRegimeBensReadHook';
|
||||
|
||||
type FormValues = z.infer<typeof GTBRegimeComunhaoSchema>;
|
||||
|
||||
|
|
@ -46,12 +46,7 @@ interface Props {
|
|||
onSave: (data: FormValues) => void;
|
||||
}
|
||||
|
||||
export default function GTBRegimeComunhaoForm({
|
||||
isOpen,
|
||||
data,
|
||||
onClose,
|
||||
onSave,
|
||||
}: Props) {
|
||||
export default function GTBRegimeComunhaoForm({ isOpen, data, onClose, onSave }: Props) {
|
||||
const { gTBRegimeBens, fetchGTBRegimeBens } = useGTBRegimeBensReadHook();
|
||||
|
||||
// Inicializa o react-hook-form com schema zod
|
||||
|
|
@ -60,9 +55,9 @@ export default function GTBRegimeComunhaoForm({
|
|||
defaultValues: {
|
||||
tb_regimecomunhao_id: 0,
|
||||
tb_regimebens_id: 0,
|
||||
descricao: "",
|
||||
texto: "",
|
||||
situacao: "",
|
||||
descricao: '',
|
||||
texto: '',
|
||||
situacao: '',
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -165,10 +160,8 @@ export default function GTBRegimeComunhaoForm({
|
|||
render={({ field }) => (
|
||||
<div className="flex items-center space-x-2">
|
||||
<Checkbox
|
||||
checked={field.value === "A"}
|
||||
onCheckedChange={(checked) =>
|
||||
field.onChange(checked ? "A" : "I")
|
||||
}
|
||||
checked={field.value === 'A'}
|
||||
onCheckedChange={(checked) => field.onChange(checked ? 'A' : 'I')}
|
||||
/>
|
||||
<Label>Ativo</Label>
|
||||
</div>
|
||||
|
|
@ -193,7 +186,7 @@ export default function GTBRegimeComunhaoForm({
|
|||
</DialogFooter>
|
||||
|
||||
{/* Campo oculto */}
|
||||
<input type="hidden" {...form.register("tb_regimecomunhao_id")} />
|
||||
<input type="hidden" {...form.register('tb_regimecomunhao_id')} />
|
||||
</form>
|
||||
</Form>
|
||||
</DialogContent>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
"use client";
|
||||
'use client';
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
|
|
@ -8,7 +8,7 @@ import {
|
|||
DropdownMenuItem,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger,
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
} from '@/components/ui/dropdown-menu';
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
|
|
@ -16,42 +16,32 @@ import {
|
|||
TableHead,
|
||||
TableHeader,
|
||||
TableRow,
|
||||
} from "@/components/ui/table";
|
||||
} from '@/components/ui/table';
|
||||
|
||||
import { EllipsisIcon, PencilIcon, Trash2Icon } from "lucide-react";
|
||||
import GTBRegimeComunhaoInterface from "../../_interfaces/GTBRegimeComunhaoInterface";
|
||||
import { EllipsisIcon, PencilIcon, Trash2Icon } from 'lucide-react';
|
||||
import GTBRegimeComunhaoInterface from '../../_interfaces/GTBRegimeComunhaoInterface';
|
||||
|
||||
interface GTBRegimeComunhaoTableProps {
|
||||
data: GTBRegimeComunhaoInterface[];
|
||||
onEdit: (
|
||||
item: GTBRegimeComunhaoInterface,
|
||||
isEditingFormStatus: boolean,
|
||||
) => void;
|
||||
onDelete: (
|
||||
item: GTBRegimeComunhaoInterface,
|
||||
isEditingFormStatus: boolean,
|
||||
) => void;
|
||||
onEdit: (item: GTBRegimeComunhaoInterface, isEditingFormStatus: boolean) => void;
|
||||
onDelete: (item: GTBRegimeComunhaoInterface, isEditingFormStatus: boolean) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renderiza o badge de situação
|
||||
*/
|
||||
function StatusBadge({ situacao }: { situacao: string }) {
|
||||
const isActive = situacao === "A";
|
||||
const isActive = situacao === 'A';
|
||||
|
||||
const baseClasses = "text-xs font-medium px-2.5 py-0.5 rounded-sm me-2";
|
||||
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 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";
|
||||
const inactiveClasses = 'bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300';
|
||||
|
||||
return (
|
||||
<span
|
||||
className={`${baseClasses} ${isActive ? activeClasses : inactiveClasses}`}
|
||||
>
|
||||
{isActive ? "Ativo" : "Inativo"}
|
||||
<span className={`${baseClasses} ${isActive ? activeClasses : inactiveClasses}`}>
|
||||
{isActive ? 'Ativo' : 'Inativo'}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
|
@ -75,9 +65,7 @@ export default function GTBRegimeComunhaoTable({
|
|||
<TableBody>
|
||||
{data.map((item) => (
|
||||
<TableRow key={item.tb_regimecomunhao_id} className="cursor-pointer">
|
||||
<TableCell className="font-medium">
|
||||
{item.tb_regimecomunhao_id}
|
||||
</TableCell>
|
||||
<TableCell className="font-medium">{item.tb_regimecomunhao_id}</TableCell>
|
||||
|
||||
<TableCell>
|
||||
<StatusBadge situacao={item.situacao} />
|
||||
|
|
@ -88,11 +76,7 @@ export default function GTBRegimeComunhaoTable({
|
|||
<TableCell className="text-right">
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<Button variant="outline" size="icon" className="cursor-pointer">
|
||||
<EllipsisIcon />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
"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 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 { Button } from '@/components/ui/button';
|
||||
import { Checkbox } from '@/components/ui/checkbox';
|
||||
import {
|
||||
Dialog,
|
||||
DialogClose,
|
||||
|
|
@ -15,7 +15,7 @@ import {
|
|||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from "@/components/ui/dialog";
|
||||
} from '@/components/ui/dialog';
|
||||
import {
|
||||
Form,
|
||||
FormControl,
|
||||
|
|
@ -23,14 +23,14 @@ import {
|
|||
FormItem,
|
||||
FormLabel,
|
||||
FormMessage,
|
||||
} from "@/components/ui/form";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
} from '@/components/ui/form';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Label } from '@/components/ui/label';
|
||||
|
||||
import LoadingButton from "@/app/_components/loadingButton/LoadingButton";
|
||||
import LoadingButton from '@/app/_components/loadingButton/LoadingButton';
|
||||
|
||||
import { GTBTipoLogradouroSchema } from "../../_schemas/GTBTipoLogradouroSchema";
|
||||
import { GTBTipoLogradouroInterface } from "../../_interfaces/GTBTipoLogradouroInterface";
|
||||
import { GTBTipoLogradouroSchema } from '../../_schemas/GTBTipoLogradouroSchema';
|
||||
import { GTBTipoLogradouroInterface } from '../../_interfaces/GTBTipoLogradouroInterface';
|
||||
|
||||
type FormValues = z.infer<typeof GTBTipoLogradouroSchema>;
|
||||
|
||||
|
|
@ -56,8 +56,8 @@ export default function GTBTipoLogradouroForm({
|
|||
sistema_id: null,
|
||||
tb_tipologradouro_id: 0,
|
||||
situacao_id: null,
|
||||
descricao: "",
|
||||
situacao: "A",
|
||||
descricao: '',
|
||||
situacao: 'A',
|
||||
onr_tipo_logradouro_id: 0,
|
||||
},
|
||||
});
|
||||
|
|
@ -77,9 +77,7 @@ export default function GTBTipoLogradouroForm({
|
|||
<DialogContent className="sm:max-w-[425px]">
|
||||
<DialogHeader>
|
||||
<DialogTitle>Tipo de Logradouro</DialogTitle>
|
||||
<DialogDescription>
|
||||
Crie ou edite um tipo de logradouro
|
||||
</DialogDescription>
|
||||
<DialogDescription>Crie ou edite um tipo de logradouro</DialogDescription>
|
||||
</DialogHeader>
|
||||
|
||||
<Form {...form}>
|
||||
|
|
@ -121,10 +119,8 @@ export default function GTBTipoLogradouroForm({
|
|||
render={({ field }) => (
|
||||
<div className="flex items-center space-x-2">
|
||||
<Checkbox
|
||||
checked={field.value === "A"}
|
||||
onCheckedChange={(checked) =>
|
||||
field.onChange(checked ? "A" : "I")
|
||||
}
|
||||
checked={field.value === 'A'}
|
||||
onCheckedChange={(checked) => field.onChange(checked ? 'A' : 'I')}
|
||||
/>
|
||||
<Label>Ativo</Label>
|
||||
</div>
|
||||
|
|
@ -153,10 +149,10 @@ export default function GTBTipoLogradouroForm({
|
|||
</DialogFooter>
|
||||
|
||||
{/* Campos ocultos */}
|
||||
<input type="hidden" {...form.register("tb_tipologradouro_id")} />
|
||||
<input type="hidden" {...form.register("sistema_id")} />
|
||||
<input type="hidden" {...form.register("situacao_id")} />
|
||||
<input type="hidden" {...form.register("onr_tipo_logradouro_id")} />
|
||||
<input type="hidden" {...form.register('tb_tipologradouro_id')} />
|
||||
<input type="hidden" {...form.register('sistema_id')} />
|
||||
<input type="hidden" {...form.register('situacao_id')} />
|
||||
<input type="hidden" {...form.register('onr_tipo_logradouro_id')} />
|
||||
</form>
|
||||
</Form>
|
||||
</DialogContent>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
"use client";
|
||||
'use client';
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
|
|
@ -8,7 +8,7 @@ import {
|
|||
DropdownMenuItem,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger,
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
} from '@/components/ui/dropdown-menu';
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
|
|
@ -16,41 +16,31 @@ import {
|
|||
TableHead,
|
||||
TableHeader,
|
||||
TableRow,
|
||||
} from "@/components/ui/table";
|
||||
import { EllipsisIcon, PencilIcon, Trash2Icon } from "lucide-react";
|
||||
import { GTBTipoLogradouroInterface } from "../../_interfaces/GTBTipoLogradouroInterface";
|
||||
} from '@/components/ui/table';
|
||||
import { EllipsisIcon, PencilIcon, Trash2Icon } from 'lucide-react';
|
||||
import { GTBTipoLogradouroInterface } from '../../_interfaces/GTBTipoLogradouroInterface';
|
||||
|
||||
interface GTBTipoLogradouroTableProps {
|
||||
data: GTBTipoLogradouroInterface[];
|
||||
onEdit: (
|
||||
item: GTBTipoLogradouroInterface,
|
||||
isEditingFormStatus: boolean,
|
||||
) => void;
|
||||
onDelete: (
|
||||
item: GTBTipoLogradouroInterface,
|
||||
isEditingFormStatus: boolean,
|
||||
) => void;
|
||||
onEdit: (item: GTBTipoLogradouroInterface, isEditingFormStatus: boolean) => void;
|
||||
onDelete: (item: GTBTipoLogradouroInterface, isEditingFormStatus: boolean) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renderiza o badge de situação
|
||||
*/
|
||||
function StatusBadge({ situacao }: { situacao: "A" | "I" }) {
|
||||
const isActive = situacao === "A";
|
||||
function StatusBadge({ situacao }: { situacao: 'A' | 'I' }) {
|
||||
const isActive = situacao === 'A';
|
||||
|
||||
const baseClasses = "text-xs font-medium px-2.5 py-0.5 rounded-sm me-2";
|
||||
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 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";
|
||||
const inactiveClasses = 'bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300';
|
||||
|
||||
return (
|
||||
<span
|
||||
className={`${baseClasses} ${isActive ? activeClasses : inactiveClasses}`}
|
||||
>
|
||||
{isActive ? "Ativo" : "Inativo"}
|
||||
<span className={`${baseClasses} ${isActive ? activeClasses : inactiveClasses}`}>
|
||||
{isActive ? 'Ativo' : 'Inativo'}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
|
@ -74,9 +64,7 @@ export default function GTBTipoLogradouroTable({
|
|||
<TableBody>
|
||||
{data.map((item) => (
|
||||
<TableRow key={item.tb_tipologradouro_id} className="cursor-pointer">
|
||||
<TableCell className="font-medium">
|
||||
{item.tb_tipologradouro_id}
|
||||
</TableCell>
|
||||
<TableCell className="font-medium">{item.tb_tipologradouro_id}</TableCell>
|
||||
|
||||
<TableCell>
|
||||
<StatusBadge situacao={item.situacao} />
|
||||
|
|
@ -87,11 +75,7 @@ export default function GTBTipoLogradouroTable({
|
|||
<TableCell className="text-right">
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<Button variant="outline" size="icon" className="cursor-pointer">
|
||||
<EllipsisIcon />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
"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 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 { Button } from '@/components/ui/button';
|
||||
import { Checkbox } from '@/components/ui/checkbox';
|
||||
import {
|
||||
Dialog,
|
||||
DialogClose,
|
||||
|
|
@ -15,7 +15,7 @@ import {
|
|||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from "@/components/ui/dialog";
|
||||
} from '@/components/ui/dialog';
|
||||
import {
|
||||
Form,
|
||||
FormControl,
|
||||
|
|
@ -23,13 +23,13 @@ import {
|
|||
FormItem,
|
||||
FormLabel,
|
||||
FormMessage,
|
||||
} from "@/components/ui/form";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
} from '@/components/ui/form';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Label } from '@/components/ui/label';
|
||||
|
||||
import { TCensecSchema } from "../../_schemas/TCensecSchema";
|
||||
import { SituacoesEnum } from "@/enums/SituacoesEnum";
|
||||
import LoadingButton from "@/app/_components/loadingButton/LoadingButton";
|
||||
import { TCensecSchema } from '../../_schemas/TCensecSchema';
|
||||
import { SituacoesEnum } from '@/enums/SituacoesEnum';
|
||||
import LoadingButton from '@/app/_components/loadingButton/LoadingButton';
|
||||
|
||||
type FormValues = z.infer<typeof TCensecSchema>;
|
||||
|
||||
|
|
@ -41,18 +41,12 @@ interface Props {
|
|||
buttonIsLoading: boolean;
|
||||
}
|
||||
|
||||
export default function TCensecForm({
|
||||
isOpen,
|
||||
data,
|
||||
onClose,
|
||||
onSave,
|
||||
buttonIsLoading,
|
||||
}: Props) {
|
||||
export default function TCensecForm({ isOpen, data, onClose, onSave, buttonIsLoading }: Props) {
|
||||
// Inicializa o react-hook-form com schema zod
|
||||
const form = useForm<FormValues>({
|
||||
resolver: zodResolver(TCensecSchema),
|
||||
defaultValues: {
|
||||
descricao: "",
|
||||
descricao: '',
|
||||
situacao: SituacoesEnum.A,
|
||||
censec_id: 0,
|
||||
},
|
||||
|
|
@ -86,11 +80,7 @@ export default function TCensecForm({
|
|||
<FormItem>
|
||||
<FormLabel>Descrição</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
type="text"
|
||||
{...field}
|
||||
placeholder="Digite a descrição"
|
||||
/>
|
||||
<Input type="text" {...field} placeholder="Digite a descrição" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
|
|
@ -104,10 +94,8 @@ export default function TCensecForm({
|
|||
render={({ field }) => (
|
||||
<div className="flex items-center space-x-2">
|
||||
<Checkbox
|
||||
checked={field.value === "A"}
|
||||
onCheckedChange={(checked) =>
|
||||
field.onChange(checked ? "A" : "I")
|
||||
}
|
||||
checked={field.value === 'A'}
|
||||
onCheckedChange={(checked) => field.onChange(checked ? 'A' : 'I')}
|
||||
/>
|
||||
<Label>Ativo</Label>
|
||||
</div>
|
||||
|
|
@ -136,7 +124,7 @@ export default function TCensecForm({
|
|||
</DialogFooter>
|
||||
|
||||
{/* Campo oculto */}
|
||||
<input type="hidden" {...form.register("censec_id")} />
|
||||
<input type="hidden" {...form.register('censec_id')} />
|
||||
</form>
|
||||
</Form>
|
||||
</DialogContent>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
"use client";
|
||||
'use client';
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
|
|
@ -8,7 +8,7 @@ import {
|
|||
DropdownMenuItem,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger,
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
} from '@/components/ui/dropdown-menu';
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
|
|
@ -16,10 +16,10 @@ import {
|
|||
TableHead,
|
||||
TableHeader,
|
||||
TableRow,
|
||||
} from "@/components/ui/table";
|
||||
} from '@/components/ui/table';
|
||||
|
||||
import { EllipsisIcon, PencilIcon, Trash2Icon } from "lucide-react";
|
||||
import TCensecInterface from "../../_interfaces/TCensecInterface";
|
||||
import { EllipsisIcon, PencilIcon, Trash2Icon } from 'lucide-react';
|
||||
import TCensecInterface from '../../_interfaces/TCensecInterface';
|
||||
|
||||
interface TCensecTableProps {
|
||||
data: TCensecInterface[];
|
||||
|
|
@ -31,30 +31,22 @@ interface TCensecTableProps {
|
|||
* Renderiza o badge de situação
|
||||
*/
|
||||
function StatusBadge({ situacao }: { situacao: string }) {
|
||||
const isActive = situacao === "A";
|
||||
const isActive = situacao === 'A';
|
||||
|
||||
const baseClasses = "text-xs font-medium px-2.5 py-0.5 rounded-sm me-2";
|
||||
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 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";
|
||||
const inactiveClasses = 'bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300';
|
||||
|
||||
return (
|
||||
<span
|
||||
className={`${baseClasses} ${isActive ? activeClasses : inactiveClasses}`}
|
||||
>
|
||||
{isActive ? "Ativo" : "Inativo"}
|
||||
<span className={`${baseClasses} ${isActive ? activeClasses : inactiveClasses}`}>
|
||||
{isActive ? 'Ativo' : 'Inativo'}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
export default function TCensecTable({
|
||||
data,
|
||||
onEdit,
|
||||
onDelete,
|
||||
}: TCensecTableProps) {
|
||||
export default function TCensecTable({ data, onEdit, onDelete }: TCensecTableProps) {
|
||||
return (
|
||||
<Table>
|
||||
<TableHeader>
|
||||
|
|
@ -81,11 +73,7 @@ export default function TCensecTable({
|
|||
<TableCell className="text-right">
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<Button variant="outline" size="icon" className="cursor-pointer">
|
||||
<EllipsisIcon />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
"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 z from 'zod';
|
||||
import { useEffect } from 'react';
|
||||
import { useForm, Controller } from 'react-hook-form';
|
||||
import { zodResolver } from '@hookform/resolvers/zod';
|
||||
|
||||
import LoadingButton from "@/app/_components/loadingButton/LoadingButton";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Checkbox } from "@/components/ui/checkbox";
|
||||
import LoadingButton from '@/app/_components/loadingButton/LoadingButton';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Checkbox } from '@/components/ui/checkbox';
|
||||
import {
|
||||
Dialog,
|
||||
DialogClose,
|
||||
|
|
@ -16,7 +16,7 @@ import {
|
|||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from "@/components/ui/dialog";
|
||||
} from '@/components/ui/dialog';
|
||||
import {
|
||||
Form,
|
||||
FormControl,
|
||||
|
|
@ -24,11 +24,11 @@ import {
|
|||
FormItem,
|
||||
FormLabel,
|
||||
FormMessage,
|
||||
} from "@/components/ui/form";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
} from '@/components/ui/form';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Label } from '@/components/ui/label';
|
||||
|
||||
import { TCensecNaturezaLitigioSchema } from "../../_schemas/TCensecNaturezaLitigioSchema";
|
||||
import { TCensecNaturezaLitigioSchema } from '../../_schemas/TCensecNaturezaLitigioSchema';
|
||||
|
||||
type FormValues = z.infer<typeof TCensecNaturezaLitigioSchema>;
|
||||
|
||||
|
|
@ -51,8 +51,8 @@ export default function TCensecNaturezaLitigioForm({
|
|||
resolver: zodResolver(TCensecNaturezaLitigioSchema),
|
||||
defaultValues: {
|
||||
censec_naturezalitigio_id: 0,
|
||||
descricao: "",
|
||||
situacao: "A",
|
||||
descricao: '',
|
||||
situacao: 'A',
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -70,9 +70,7 @@ export default function TCensecNaturezaLitigioForm({
|
|||
<DialogContent className="sm:max-w-[425px]">
|
||||
<DialogHeader>
|
||||
<DialogTitle>Natureza do Litígio</DialogTitle>
|
||||
<DialogDescription>
|
||||
Crie ou edite uma natureza do litígio
|
||||
</DialogDescription>
|
||||
<DialogDescription>Crie ou edite uma natureza do litígio</DialogDescription>
|
||||
</DialogHeader>
|
||||
|
||||
<Form {...form}>
|
||||
|
|
@ -99,10 +97,8 @@ export default function TCensecNaturezaLitigioForm({
|
|||
render={({ field }) => (
|
||||
<div className="flex items-center space-x-2">
|
||||
<Checkbox
|
||||
checked={field.value === "A"}
|
||||
onCheckedChange={(checked) =>
|
||||
field.onChange(checked ? "A" : "I")
|
||||
}
|
||||
checked={field.value === 'A'}
|
||||
onCheckedChange={(checked) => field.onChange(checked ? 'A' : 'I')}
|
||||
/>
|
||||
<Label>Ativo</Label>
|
||||
</div>
|
||||
|
|
@ -112,11 +108,7 @@ export default function TCensecNaturezaLitigioForm({
|
|||
{/* Rodapé */}
|
||||
<DialogFooter className="mt-4">
|
||||
<DialogClose asChild>
|
||||
<Button
|
||||
variant="outline"
|
||||
type="button"
|
||||
onClick={() => onClose(null, false)}
|
||||
>
|
||||
<Button variant="outline" type="button" onClick={() => onClose(null, false)}>
|
||||
Cancelar
|
||||
</Button>
|
||||
</DialogClose>
|
||||
|
|
@ -130,10 +122,7 @@ export default function TCensecNaturezaLitigioForm({
|
|||
</DialogFooter>
|
||||
|
||||
{/* Campo oculto */}
|
||||
<input
|
||||
type="hidden"
|
||||
{...form.register("censec_naturezalitigio_id")}
|
||||
/>
|
||||
<input type="hidden" {...form.register('censec_naturezalitigio_id')} />
|
||||
</form>
|
||||
</Form>
|
||||
</DialogContent>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
"use client";
|
||||
'use client';
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
|
|
@ -8,7 +8,7 @@ import {
|
|||
DropdownMenuItem,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger,
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
} from '@/components/ui/dropdown-menu';
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
|
|
@ -16,41 +16,31 @@ import {
|
|||
TableHead,
|
||||
TableHeader,
|
||||
TableRow,
|
||||
} from "@/components/ui/table";
|
||||
import { EllipsisIcon, PencilIcon, Trash2Icon } from "lucide-react";
|
||||
import { TCensecNaturezaLitigioInterface } from "../../_interfaces/TCensecNaturezaLitigioInterface";
|
||||
} from '@/components/ui/table';
|
||||
import { EllipsisIcon, PencilIcon, Trash2Icon } from 'lucide-react';
|
||||
import { TCensecNaturezaLitigioInterface } from '../../_interfaces/TCensecNaturezaLitigioInterface';
|
||||
|
||||
interface TCensecNaturezaLitigioTableProps {
|
||||
data: TCensecNaturezaLitigioInterface[];
|
||||
onEdit: (
|
||||
item: TCensecNaturezaLitigioInterface,
|
||||
isEditingFormStatus: boolean,
|
||||
) => void;
|
||||
onDelete: (
|
||||
item: TCensecNaturezaLitigioInterface,
|
||||
isEditingFormStatus: boolean,
|
||||
) => void;
|
||||
onEdit: (item: TCensecNaturezaLitigioInterface, isEditingFormStatus: boolean) => void;
|
||||
onDelete: (item: TCensecNaturezaLitigioInterface, isEditingFormStatus: boolean) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renderiza o badge de situação
|
||||
*/
|
||||
function StatusBadge({ situacao }: { situacao: "A" | "I" }) {
|
||||
const isActive = situacao === "A";
|
||||
function StatusBadge({ situacao }: { situacao: 'A' | 'I' }) {
|
||||
const isActive = situacao === 'A';
|
||||
|
||||
const baseClasses = "text-xs font-medium px-2.5 py-0.5 rounded-sm me-2";
|
||||
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 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";
|
||||
const inactiveClasses = 'bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300';
|
||||
|
||||
return (
|
||||
<span
|
||||
className={`${baseClasses} ${isActive ? activeClasses : inactiveClasses}`}
|
||||
>
|
||||
{isActive ? "Ativo" : "Inativo"}
|
||||
<span className={`${baseClasses} ${isActive ? activeClasses : inactiveClasses}`}>
|
||||
{isActive ? 'Ativo' : 'Inativo'}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
|
@ -73,13 +63,8 @@ export default function TCensecNaturezaLitigioTable({
|
|||
|
||||
<TableBody>
|
||||
{data.map((item) => (
|
||||
<TableRow
|
||||
key={item.censec_naturezalitigio_id}
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<TableCell className="font-medium">
|
||||
{item.censec_naturezalitigio_id}
|
||||
</TableCell>
|
||||
<TableRow key={item.censec_naturezalitigio_id} className="cursor-pointer">
|
||||
<TableCell className="font-medium">{item.censec_naturezalitigio_id}</TableCell>
|
||||
|
||||
<TableCell>
|
||||
<StatusBadge situacao={item.situacao} />
|
||||
|
|
@ -90,11 +75,7 @@ export default function TCensecNaturezaLitigioTable({
|
|||
<TableCell className="text-right">
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<Button variant="outline" size="icon" className="cursor-pointer">
|
||||
<EllipsisIcon />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
"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 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 { Button } from '@/components/ui/button';
|
||||
import { Checkbox } from '@/components/ui/checkbox';
|
||||
import {
|
||||
Dialog,
|
||||
DialogClose,
|
||||
|
|
@ -15,7 +15,7 @@ import {
|
|||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from "@/components/ui/dialog";
|
||||
} from '@/components/ui/dialog';
|
||||
import {
|
||||
Form,
|
||||
FormControl,
|
||||
|
|
@ -23,13 +23,13 @@ import {
|
|||
FormItem,
|
||||
FormLabel,
|
||||
FormMessage,
|
||||
} from "@/components/ui/form";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
} from '@/components/ui/form';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Label } from '@/components/ui/label';
|
||||
|
||||
import MainEditor from "@/components/MainEditor";
|
||||
import { TMinutaInterface } from "../../_interfaces/TMinutaInterface";
|
||||
import { TMinutaSchema } from "../../_schemas/TMinutaSchema";
|
||||
import MainEditor from '@/components/MainEditor';
|
||||
import { TMinutaInterface } from '../../_interfaces/TMinutaInterface';
|
||||
import { TMinutaSchema } from '../../_schemas/TMinutaSchema';
|
||||
|
||||
type FormValues = z.infer<typeof TMinutaSchema>;
|
||||
|
||||
|
|
@ -40,20 +40,15 @@ interface TMinutaFormProps {
|
|||
onSave: (data: FormValues) => void;
|
||||
}
|
||||
|
||||
export default function TMinutaForm({
|
||||
isOpen,
|
||||
data,
|
||||
onClose,
|
||||
onSave,
|
||||
}: TMinutaFormProps) {
|
||||
export default function TMinutaForm({ isOpen, data, onClose, onSave }: TMinutaFormProps) {
|
||||
const form = useForm<FormValues>({
|
||||
resolver: zodResolver(TMinutaSchema),
|
||||
defaultValues: {
|
||||
minuta_id: 0,
|
||||
natureza_id: undefined,
|
||||
descricao: "",
|
||||
situacao: "A",
|
||||
texto: "",
|
||||
descricao: '',
|
||||
situacao: 'A',
|
||||
texto: '',
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -69,13 +64,11 @@ export default function TMinutaForm({
|
|||
}}
|
||||
>
|
||||
<DialogContent className="mx-auto">
|
||||
{" "}
|
||||
{' '}
|
||||
{/* tamanho maior para comportar o editor */}
|
||||
<DialogHeader>
|
||||
<DialogTitle>Minuta</DialogTitle>
|
||||
<DialogDescription>
|
||||
Crie ou edite uma minuta de ato notarial.
|
||||
</DialogDescription>
|
||||
<DialogDescription>Crie ou edite uma minuta de ato notarial.</DialogDescription>
|
||||
</DialogHeader>
|
||||
<Form {...form}>
|
||||
<form onSubmit={form.handleSubmit(onSave)} className="space-y-6">
|
||||
|
|
@ -87,10 +80,7 @@ export default function TMinutaForm({
|
|||
<FormItem>
|
||||
<FormLabel>Descrição</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
placeholder="Digite a descrição da minuta"
|
||||
/>
|
||||
<Input {...field} placeholder="Digite a descrição da minuta" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
|
|
@ -104,12 +94,10 @@ export default function TMinutaForm({
|
|||
render={({ field }) => (
|
||||
<div className="flex items-center space-x-2">
|
||||
<Checkbox
|
||||
checked={field.value === "A"}
|
||||
onCheckedChange={(checked) =>
|
||||
field.onChange(checked ? "A" : "I")
|
||||
}
|
||||
checked={field.value === 'A'}
|
||||
onCheckedChange={(checked) => field.onChange(checked ? 'A' : 'I')}
|
||||
/>
|
||||
<Label>{field.value === "A" ? "Ativo" : "Inativo"}</Label>
|
||||
<Label>{field.value === 'A' ? 'Ativo' : 'Inativo'}</Label>
|
||||
</div>
|
||||
)}
|
||||
/>
|
||||
|
|
@ -121,13 +109,13 @@ export default function TMinutaForm({
|
|||
render={({ field }) => (
|
||||
<div>
|
||||
<MainEditor
|
||||
initialValue={field.value || ""}
|
||||
initialValue={field.value || ''}
|
||||
onEditorChange={field.onChange}
|
||||
margins={{ top: "2", bottom: "2", left: "3", right: "3" }}
|
||||
margins={{ top: '2', bottom: '2', left: '3', right: '3' }}
|
||||
size={{ width: 800, height: 500 }}
|
||||
/>
|
||||
{form.formState.errors.texto && (
|
||||
<p className="text-sm text-red-500 mt-2">
|
||||
<p className="mt-2 text-sm text-red-500">
|
||||
{form.formState.errors.texto.message}
|
||||
</p>
|
||||
)}
|
||||
|
|
@ -138,22 +126,18 @@ export default function TMinutaForm({
|
|||
{/* Rodapé do Dialog */}
|
||||
<DialogFooter className="mt-4">
|
||||
<DialogClose asChild>
|
||||
<Button
|
||||
variant="outline"
|
||||
type="button"
|
||||
onClick={() => onClose(null, false)}
|
||||
>
|
||||
<Button variant="outline" type="button" onClick={() => onClose(null, false)}>
|
||||
Cancelar
|
||||
</Button>
|
||||
</DialogClose>
|
||||
<Button type="submit" disabled={form.formState.isSubmitting}>
|
||||
{form.formState.isSubmitting ? "Salvando..." : "Salvar"}
|
||||
{form.formState.isSubmitting ? 'Salvando...' : 'Salvar'}
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
|
||||
{/* Campos ocultos */}
|
||||
<input type="hidden" {...form.register("minuta_id")} />
|
||||
<input type="hidden" {...form.register("natureza_id")} />
|
||||
<input type="hidden" {...form.register('minuta_id')} />
|
||||
<input type="hidden" {...form.register('natureza_id')} />
|
||||
</form>
|
||||
</Form>
|
||||
</DialogContent>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
"use client";
|
||||
'use client';
|
||||
|
||||
import Link from "next/link";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import Link from 'next/link';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
|
|
@ -9,7 +9,7 @@ import {
|
|||
DropdownMenuItem,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger,
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
} from '@/components/ui/dropdown-menu';
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
|
|
@ -17,9 +17,9 @@ import {
|
|||
TableHead,
|
||||
TableHeader,
|
||||
TableRow,
|
||||
} from "@/components/ui/table";
|
||||
import { EllipsisIcon, PencilIcon, Trash2Icon } from "lucide-react";
|
||||
import { TMinutaInterface } from "../../_interfaces/TMinutaInterface";
|
||||
} from '@/components/ui/table';
|
||||
import { EllipsisIcon, PencilIcon, Trash2Icon } from 'lucide-react';
|
||||
import { TMinutaInterface } from '../../_interfaces/TMinutaInterface';
|
||||
|
||||
interface TMinutaTableProps {
|
||||
data: TMinutaInterface[];
|
||||
|
|
@ -30,22 +30,18 @@ interface TMinutaTableProps {
|
|||
/**
|
||||
* Renderiza o badge de situação
|
||||
*/
|
||||
function StatusBadge({ situacao }: { situacao: "A" | "I" }) {
|
||||
const isActive = situacao === "A";
|
||||
function StatusBadge({ situacao }: { situacao: 'A' | 'I' }) {
|
||||
const isActive = situacao === 'A';
|
||||
|
||||
const baseClasses = "text-xs font-medium px-2.5 py-0.5 rounded-sm mr-2";
|
||||
const baseClasses = 'text-xs font-medium px-2.5 py-0.5 rounded-sm mr-2';
|
||||
|
||||
const activeClasses =
|
||||
"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-300";
|
||||
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";
|
||||
const inactiveClasses = 'bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300';
|
||||
|
||||
return (
|
||||
<span
|
||||
className={`${baseClasses} ${isActive ? activeClasses : inactiveClasses}`}
|
||||
>
|
||||
{isActive ? "Ativo" : "Inativo"}
|
||||
<span className={`${baseClasses} ${isActive ? activeClasses : inactiveClasses}`}>
|
||||
{isActive ? 'Ativo' : 'Inativo'}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
|
@ -64,10 +60,7 @@ export default function TMinutaTable({ data }: TMinutaTableProps) {
|
|||
<TableBody>
|
||||
{data.length === 0 ? (
|
||||
<TableRow>
|
||||
<TableCell
|
||||
colSpan={4}
|
||||
className="text-center text-muted-foreground"
|
||||
>
|
||||
<TableCell colSpan={4} className="text-muted-foreground text-center">
|
||||
Nenhuma minuta encontrada.
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
|
|
@ -84,9 +77,7 @@ export default function TMinutaTable({ data }: TMinutaTableProps) {
|
|||
|
||||
<TableCell className="text-right">
|
||||
<Button asChild>
|
||||
<Link href={`/cadastros/minuta/${item.t_minuta_id}/detalhes`}>
|
||||
Detalhes
|
||||
</Link>
|
||||
<Link href={`/cadastros/minuta/${item.t_minuta_id}/detalhes`}>Detalhes</Link>
|
||||
</Button>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
"use client";
|
||||
'use client';
|
||||
|
||||
import z from "zod";
|
||||
import React, { useEffect } from "react";
|
||||
import { useForm, Controller } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import z from 'zod';
|
||||
import React, { useEffect } from 'react';
|
||||
import { useForm, Controller } from 'react-hook-form';
|
||||
import { zodResolver } from '@hookform/resolvers/zod';
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
Dialog,
|
||||
DialogClose,
|
||||
|
|
@ -14,7 +14,7 @@ import {
|
|||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from "@/components/ui/dialog";
|
||||
} from '@/components/ui/dialog';
|
||||
import {
|
||||
Form,
|
||||
FormControl,
|
||||
|
|
@ -22,36 +22,26 @@ import {
|
|||
FormItem,
|
||||
FormLabel,
|
||||
FormMessage,
|
||||
} from "@/components/ui/form";
|
||||
import { Input } from "@/components/ui/input";
|
||||
} from '@/components/ui/form';
|
||||
import { Input } from '@/components/ui/input';
|
||||
|
||||
import { TPessoaSchema } from "../../_schemas/TPessoaSchema";
|
||||
import LoadingButton from "@/app/_components/loadingButton/LoadingButton";
|
||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||
import { TPessoaSchema } from '../../_schemas/TPessoaSchema';
|
||||
import LoadingButton from '@/app/_components/loadingButton/LoadingButton';
|
||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from "@/components/ui/select";
|
||||
import {
|
||||
CheckIcon,
|
||||
ChevronsUpDownIcon,
|
||||
HouseIcon,
|
||||
IdCardIcon,
|
||||
UserIcon,
|
||||
} from "lucide-react";
|
||||
import { Sexo } from "@/enums/SexoEnum";
|
||||
import { useGTBEstadoCivilReadHook } from "../../_hooks/g_tb_estadocivil/useGTBEstadoCivilReadHook";
|
||||
import GetCapitalize from "@/actions/text/GetCapitalize";
|
||||
import { useGTBRegimeComunhaoReadHook } from "../../_hooks/g_tb_regimecomunhao/useGTBRegimeComunhaoReadHook";
|
||||
import { useGTBProfissaoReadHook } from "../../_hooks/g_tb_profissao/useGTBProfissaoReadHook";
|
||||
import {
|
||||
Popover,
|
||||
PopoverContent,
|
||||
PopoverTrigger,
|
||||
} from "@/components/ui/popover";
|
||||
} from '@/components/ui/select';
|
||||
import { CheckIcon, ChevronsUpDownIcon, HouseIcon, IdCardIcon, UserIcon } from 'lucide-react';
|
||||
import { Sexo } from '@/enums/SexoEnum';
|
||||
import { useGTBEstadoCivilReadHook } from '../../_hooks/g_tb_estadocivil/useGTBEstadoCivilReadHook';
|
||||
import GetCapitalize from '@/actions/text/GetCapitalize';
|
||||
import { useGTBRegimeComunhaoReadHook } from '../../_hooks/g_tb_regimecomunhao/useGTBRegimeComunhaoReadHook';
|
||||
import { useGTBProfissaoReadHook } from '../../_hooks/g_tb_profissao/useGTBProfissaoReadHook';
|
||||
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';
|
||||
import {
|
||||
Command,
|
||||
CommandEmpty,
|
||||
|
|
@ -59,8 +49,8 @@ import {
|
|||
CommandInput,
|
||||
CommandItem,
|
||||
CommandList,
|
||||
} from "@/components/ui/command";
|
||||
import { cn } from "@/lib/utils";
|
||||
} from '@/components/ui/command';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
type FormValues = z.infer<typeof TPessoaSchema>;
|
||||
|
||||
|
|
@ -81,14 +71,13 @@ export default function TCensecForm({
|
|||
}: TPessoaFormProps) {
|
||||
const { gTBProfissao, fetchGTBProfissao } = useGTBProfissaoReadHook();
|
||||
const { gTBEstadoCivil, fetchGTBEstadoCivil } = useGTBEstadoCivilReadHook();
|
||||
const { gTBRegimeComunhao, fetchGTBRegimeComunhao } =
|
||||
useGTBRegimeComunhaoReadHook();
|
||||
const { gTBRegimeComunhao, fetchGTBRegimeComunhao } = useGTBRegimeComunhaoReadHook();
|
||||
|
||||
// Inicializa o react-hook-form com schema zod
|
||||
const form = useForm<FormValues>({
|
||||
resolver: zodResolver(TPessoaSchema),
|
||||
defaultValues: {
|
||||
nome: "",
|
||||
nome: '',
|
||||
pessoa_id: 0,
|
||||
},
|
||||
});
|
||||
|
|
@ -117,7 +106,7 @@ export default function TCensecForm({
|
|||
if (!open) onClose(null, false);
|
||||
}}
|
||||
>
|
||||
<DialogContent className="w-full max-w-full sm:max-w-3xl md:max-w-4xl lg:max-w-5xl p-6">
|
||||
<DialogContent className="w-full max-w-full p-6 sm:max-w-3xl md:max-w-4xl lg:max-w-5xl">
|
||||
<DialogHeader>
|
||||
<DialogTitle>Pessoa</DialogTitle>
|
||||
<DialogDescription>Preencha os dados da pessoa</DialogDescription>
|
||||
|
|
@ -127,31 +116,22 @@ export default function TCensecForm({
|
|||
<form onSubmit={form.handleSubmit(onSave)} className="space-y-6">
|
||||
{/* Tabs */}
|
||||
<Tabs defaultValue="dadosPessoais" className="space-y-4">
|
||||
<TabsList className="w-full flex">
|
||||
<TabsTrigger
|
||||
className="flex-1 text-center cursor-pointer"
|
||||
value="dadosPessoais"
|
||||
>
|
||||
<TabsList className="flex w-full">
|
||||
<TabsTrigger className="flex-1 cursor-pointer text-center" value="dadosPessoais">
|
||||
<UserIcon className="me-1" />
|
||||
Dados Pessoais
|
||||
</TabsTrigger>
|
||||
<TabsTrigger
|
||||
className="flex-1 text-center cursor-pointer"
|
||||
value="endereco"
|
||||
>
|
||||
<TabsTrigger className="flex-1 cursor-pointer text-center" value="endereco">
|
||||
<HouseIcon /> Endereço
|
||||
</TabsTrigger>
|
||||
<TabsTrigger
|
||||
className="flex-1 text-center cursor-pointer"
|
||||
value="documentos"
|
||||
>
|
||||
<TabsTrigger className="flex-1 cursor-pointer text-center" value="documentos">
|
||||
<IdCardIcon /> Documentos
|
||||
</TabsTrigger>
|
||||
</TabsList>
|
||||
|
||||
{/* Dados Pessoais */}
|
||||
<TabsContent value="dadosPessoais" className="space-y-4">
|
||||
<div className="grid grid-cols-12 gap-4 w-full">
|
||||
<div className="grid w-full grid-cols-12 gap-4">
|
||||
{/* Nome */}
|
||||
<div className="col-span-12 sm:col-span-12 md:col-span-6">
|
||||
<FormField
|
||||
|
|
@ -161,11 +141,7 @@ export default function TCensecForm({
|
|||
<FormItem className="w-full">
|
||||
<FormLabel>Nome</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
placeholder="Digite o nome"
|
||||
className="w-full"
|
||||
/>
|
||||
<Input {...field} placeholder="Digite o nome" className="w-full" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
|
|
@ -197,22 +173,13 @@ export default function TCensecForm({
|
|||
<FormItem className="w-full">
|
||||
<FormLabel>Sexo</FormLabel>
|
||||
<FormControl>
|
||||
<Select
|
||||
value={field.value}
|
||||
onValueChange={field.onChange}
|
||||
>
|
||||
<Select value={field.value} onValueChange={field.onChange}>
|
||||
<SelectTrigger className="w-full">
|
||||
{field.value
|
||||
? Sexo[field.value as keyof typeof Sexo]
|
||||
: "Selecione"}
|
||||
{field.value ? Sexo[field.value as keyof typeof Sexo] : 'Selecione'}
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{Object.entries(Sexo).map(([key, label]) => (
|
||||
<SelectItem
|
||||
key={key}
|
||||
value={key}
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<SelectItem key={key} value={key} className="cursor-pointer">
|
||||
{label}
|
||||
</SelectItem>
|
||||
))}
|
||||
|
|
@ -347,10 +314,9 @@ export default function TCensecForm({
|
|||
{field.value
|
||||
? gTBEstadoCivil.find(
|
||||
(item) =>
|
||||
String(item.tb_estadocivil_id) ===
|
||||
String(field.value),
|
||||
String(item.tb_estadocivil_id) === String(field.value),
|
||||
)?.descricao
|
||||
: "Escolha o estado civil"}
|
||||
: 'Escolha o estado civil'}
|
||||
<ChevronsUpDownIcon className="ml-2 h-4 w-4 shrink-0 opacity-50" />
|
||||
</Button>
|
||||
</FormControl>
|
||||
|
|
@ -359,30 +325,23 @@ export default function TCensecForm({
|
|||
<Command>
|
||||
<CommandInput placeholder="Buscar estado civil..." />
|
||||
<CommandList>
|
||||
<CommandEmpty>
|
||||
Nenhum resultado encontrado.
|
||||
</CommandEmpty>
|
||||
<CommandEmpty>Nenhum resultado encontrado.</CommandEmpty>
|
||||
<CommandGroup>
|
||||
{gTBEstadoCivil?.map((item) => (
|
||||
<CommandItem
|
||||
key={item.tb_estadocivil_id}
|
||||
value={(
|
||||
item.descricao ?? ""
|
||||
).toLowerCase()}
|
||||
value={(item.descricao ?? '').toLowerCase()}
|
||||
onSelect={() => {
|
||||
field.onChange(
|
||||
Number(item.tb_estadocivil_id),
|
||||
);
|
||||
field.onChange(Number(item.tb_estadocivil_id));
|
||||
setOpen(false);
|
||||
}}
|
||||
>
|
||||
<CheckIcon
|
||||
className={cn(
|
||||
"mr-2 h-4 w-4",
|
||||
String(field.value) ===
|
||||
String(item.tb_estadocivil_id)
|
||||
? "opacity-100"
|
||||
: "opacity-0",
|
||||
'mr-2 h-4 w-4',
|
||||
String(field.value) === String(item.tb_estadocivil_id)
|
||||
? 'opacity-100'
|
||||
: 'opacity-0',
|
||||
)}
|
||||
/>
|
||||
{GetCapitalize(item.descricao)}
|
||||
|
|
@ -421,11 +380,10 @@ export default function TCensecForm({
|
|||
{field.value
|
||||
? gTBRegimeComunhao.find(
|
||||
(item) =>
|
||||
String(
|
||||
item.tb_regimecomunhao_id,
|
||||
) === String(field.value),
|
||||
String(item.tb_regimecomunhao_id) ===
|
||||
String(field.value),
|
||||
)?.descricao
|
||||
: "Escolha o regime"}
|
||||
: 'Escolha o regime'}
|
||||
<ChevronsUpDownIcon className="ml-2 h-4 w-4 shrink-0 opacity-50" />
|
||||
</Button>
|
||||
</FormControl>
|
||||
|
|
@ -434,32 +392,24 @@ export default function TCensecForm({
|
|||
<Command>
|
||||
<CommandInput placeholder="Buscar estado civil..." />
|
||||
<CommandList>
|
||||
<CommandEmpty>
|
||||
Nenhum regime encontrado.
|
||||
</CommandEmpty>
|
||||
<CommandEmpty>Nenhum regime encontrado.</CommandEmpty>
|
||||
<CommandGroup>
|
||||
{gTBRegimeComunhao?.map((item) => (
|
||||
<CommandItem
|
||||
key={item.tb_regimecomunhao_id}
|
||||
value={(
|
||||
item.descricao ?? ""
|
||||
).toLowerCase()}
|
||||
value={(item.descricao ?? '').toLowerCase()}
|
||||
onSelect={() => {
|
||||
field.onChange(
|
||||
Number(item.tb_regimecomunhao_id),
|
||||
);
|
||||
field.onChange(Number(item.tb_regimecomunhao_id));
|
||||
setOpen(false);
|
||||
}}
|
||||
>
|
||||
<CheckIcon
|
||||
className={cn(
|
||||
"mr-2 h-4 w-4",
|
||||
'mr-2 h-4 w-4',
|
||||
String(field.value) ===
|
||||
String(
|
||||
item.tb_regimecomunhao_id,
|
||||
)
|
||||
? "opacity-100"
|
||||
: "opacity-0",
|
||||
String(item.tb_regimecomunhao_id)
|
||||
? 'opacity-100'
|
||||
: 'opacity-0',
|
||||
)}
|
||||
/>
|
||||
{GetCapitalize(item.descricao)}
|
||||
|
|
@ -498,10 +448,9 @@ export default function TCensecForm({
|
|||
{field.value
|
||||
? gTBProfissao.find(
|
||||
(item) =>
|
||||
String(item.tb_profissao_id) ===
|
||||
String(field.value),
|
||||
String(item.tb_profissao_id) === String(field.value),
|
||||
)?.descricao
|
||||
: "Escolha a profissão"}
|
||||
: 'Escolha a profissão'}
|
||||
<ChevronsUpDownIcon className="ml-2 h-4 w-4 shrink-0 opacity-50" />
|
||||
</Button>
|
||||
</FormControl>
|
||||
|
|
@ -510,30 +459,23 @@ export default function TCensecForm({
|
|||
<Command>
|
||||
<CommandInput placeholder="Buscar profissão..." />
|
||||
<CommandList>
|
||||
<CommandEmpty>
|
||||
Nenhuma profissão encontrado.
|
||||
</CommandEmpty>
|
||||
<CommandEmpty>Nenhuma profissão encontrado.</CommandEmpty>
|
||||
<CommandGroup>
|
||||
{gTBProfissao?.map((item) => (
|
||||
<CommandItem
|
||||
key={item.tb_profissao_id}
|
||||
value={(
|
||||
item.descricao ?? ""
|
||||
).toLowerCase()}
|
||||
value={(item.descricao ?? '').toLowerCase()}
|
||||
onSelect={() => {
|
||||
field.onChange(
|
||||
Number(item.tb_profissao_id),
|
||||
);
|
||||
field.onChange(Number(item.tb_profissao_id));
|
||||
setOpen(false);
|
||||
}}
|
||||
>
|
||||
<CheckIcon
|
||||
className={cn(
|
||||
"mr-2 h-4 w-4",
|
||||
String(field.value) ===
|
||||
String(item.tb_profissao_id)
|
||||
? "opacity-100"
|
||||
: "opacity-0",
|
||||
'mr-2 h-4 w-4',
|
||||
String(field.value) === String(item.tb_profissao_id)
|
||||
? 'opacity-100'
|
||||
: 'opacity-0',
|
||||
)}
|
||||
/>
|
||||
{GetCapitalize(item.descricao)}
|
||||
|
|
@ -595,7 +537,7 @@ export default function TCensecForm({
|
|||
|
||||
{/* Endereço */}
|
||||
<TabsContent value="endereco" className="space-y-4">
|
||||
<div className="grid grid-cols-12 gap-4 w-full">
|
||||
<div className="grid w-full grid-cols-12 gap-4">
|
||||
{/* País */}
|
||||
<div className="col-span-12 sm:col-span-12 md:col-span-6">
|
||||
<FormField
|
||||
|
|
@ -605,11 +547,7 @@ export default function TCensecForm({
|
|||
<FormItem className="w-full">
|
||||
<FormLabel>País</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
placeholder="Digite o nome"
|
||||
className="w-full"
|
||||
/>
|
||||
<Input {...field} placeholder="Digite o nome" className="w-full" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
|
|
@ -625,11 +563,7 @@ export default function TCensecForm({
|
|||
<FormItem className="w-full">
|
||||
<FormLabel>UF</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
placeholder="Digite o nome"
|
||||
className="w-full"
|
||||
/>
|
||||
<Input {...field} placeholder="Digite o nome" className="w-full" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
|
|
@ -645,11 +579,7 @@ export default function TCensecForm({
|
|||
<FormItem className="w-full">
|
||||
<FormLabel>CEP</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
placeholder="Digite o nome"
|
||||
className="w-full"
|
||||
/>
|
||||
<Input {...field} placeholder="Digite o nome" className="w-full" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
|
|
@ -665,11 +595,7 @@ export default function TCensecForm({
|
|||
<FormItem className="w-full">
|
||||
<FormLabel>Cidade</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
placeholder="Digite o nome"
|
||||
className="w-full"
|
||||
/>
|
||||
<Input {...field} placeholder="Digite o nome" className="w-full" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
|
|
@ -685,11 +611,7 @@ export default function TCensecForm({
|
|||
<FormItem className="w-full">
|
||||
<FormLabel>Município</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
placeholder="Digite o nome"
|
||||
className="w-full"
|
||||
/>
|
||||
<Input {...field} placeholder="Digite o nome" className="w-full" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
|
|
@ -705,11 +627,7 @@ export default function TCensecForm({
|
|||
<FormItem className="w-full">
|
||||
<FormLabel>Bairro</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
placeholder="Digite o nome"
|
||||
className="w-full"
|
||||
/>
|
||||
<Input {...field} placeholder="Digite o nome" className="w-full" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
|
|
@ -725,11 +643,7 @@ export default function TCensecForm({
|
|||
<FormItem className="w-full">
|
||||
<FormLabel>Logradouro</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
placeholder="Digite o nome"
|
||||
className="w-full"
|
||||
/>
|
||||
<Input {...field} placeholder="Digite o nome" className="w-full" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
|
|
@ -745,11 +659,7 @@ export default function TCensecForm({
|
|||
<FormItem className="w-full">
|
||||
<FormLabel>Número</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
placeholder="Digite o nome"
|
||||
className="w-full"
|
||||
/>
|
||||
<Input {...field} placeholder="Digite o nome" className="w-full" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
|
|
@ -765,11 +675,7 @@ export default function TCensecForm({
|
|||
<FormItem className="w-full">
|
||||
<FormLabel>Unidade</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
placeholder="Digite o nome"
|
||||
className="w-full"
|
||||
/>
|
||||
<Input {...field} placeholder="Digite o nome" className="w-full" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
|
|
@ -785,11 +691,7 @@ export default function TCensecForm({
|
|||
<FormItem className="w-full">
|
||||
<FormLabel>Cidade não encontrada</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
placeholder="Digite o nome"
|
||||
className="w-full"
|
||||
/>
|
||||
<Input {...field} placeholder="Digite o nome" className="w-full" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
|
|
@ -801,7 +703,7 @@ export default function TCensecForm({
|
|||
|
||||
{/* Documentos */}
|
||||
<TabsContent value="documentos" className="space-y-4">
|
||||
<div className="grid grid-cols-12 gap-4 w-full">
|
||||
<div className="grid w-full grid-cols-12 gap-4">
|
||||
{/* Tipo */}
|
||||
<div className="col-span-12 sm:col-span-12 md:col-span-3">
|
||||
<FormField
|
||||
|
|
@ -811,11 +713,7 @@ export default function TCensecForm({
|
|||
<FormItem className="w-full">
|
||||
<FormLabel>Tipo</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
placeholder="Digite o tipo"
|
||||
className="w-full"
|
||||
/>
|
||||
<Input {...field} placeholder="Digite o tipo" className="w-full" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
|
|
@ -832,11 +730,7 @@ export default function TCensecForm({
|
|||
<FormItem className="w-full">
|
||||
<FormLabel>Número</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
placeholder="Digite o número"
|
||||
className="w-full"
|
||||
/>
|
||||
<Input {...field} placeholder="Digite o número" className="w-full" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
|
|
@ -853,11 +747,7 @@ export default function TCensecForm({
|
|||
<FormItem className="w-full">
|
||||
<FormLabel>CPF</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
placeholder="Digite o CPF"
|
||||
className="w-full"
|
||||
/>
|
||||
<Input {...field} placeholder="Digite o CPF" className="w-full" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
|
|
@ -895,11 +785,7 @@ export default function TCensecForm({
|
|||
<FormItem className="w-full">
|
||||
<FormLabel>UF</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
placeholder="UF"
|
||||
className="w-full"
|
||||
/>
|
||||
<Input {...field} placeholder="UF" className="w-full" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
|
|
@ -965,7 +851,7 @@ export default function TCensecForm({
|
|||
</DialogFooter>
|
||||
|
||||
{/* Campo oculto */}
|
||||
<input type="hidden" {...form.register("pessoa_id")} />
|
||||
<input type="hidden" {...form.register('pessoa_id')} />
|
||||
</form>
|
||||
</Form>
|
||||
</DialogContent>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
"use client";
|
||||
'use client';
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
|
|
@ -8,24 +8,19 @@ import {
|
|||
DropdownMenuItem,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger,
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
} from '@/components/ui/dropdown-menu';
|
||||
|
||||
import {
|
||||
ArrowUpDownIcon,
|
||||
EllipsisIcon,
|
||||
PencilIcon,
|
||||
Trash2Icon,
|
||||
} from "lucide-react";
|
||||
import { ColumnDef } from "@tanstack/react-table";
|
||||
import { ArrowUpDownIcon, EllipsisIcon, PencilIcon, Trash2Icon } from 'lucide-react';
|
||||
import { ColumnDef } from '@tanstack/react-table';
|
||||
|
||||
import GetNameInitials from "@/actions/text/GetNameInitials";
|
||||
import { DataTable } from "@/app/_components/dataTable/DataTable";
|
||||
import GetNameInitials from '@/actions/text/GetNameInitials';
|
||||
import { DataTable } from '@/app/_components/dataTable/DataTable';
|
||||
|
||||
import TPessoaInterface from "../../_interfaces/TPessoaInterface";
|
||||
import { FormatCPF } from "@/actions/CPF/FormatCPF";
|
||||
import { FormatPhone } from "@/actions/phone/FormatPhone";
|
||||
import { FormatDateTime } from "@/actions/dateTime/FormatDateTime";
|
||||
import empty from "@/actions/validations/empty";
|
||||
import TPessoaInterface from '../../_interfaces/TPessoaInterface';
|
||||
import { FormatCPF } from '@/actions/CPF/FormatCPF';
|
||||
import { FormatPhone } from '@/actions/phone/FormatPhone';
|
||||
import { FormatDateTime } from '@/actions/dateTime/FormatDateTime';
|
||||
import empty from '@/actions/validations/empty';
|
||||
|
||||
// Tipagem das props
|
||||
interface TPessoaTableProps {
|
||||
|
|
@ -44,30 +39,29 @@ function createPessoaColumns(
|
|||
return [
|
||||
// ID
|
||||
{
|
||||
accessorKey: "pessoa_id",
|
||||
accessorKey: 'pessoa_id',
|
||||
header: ({ column }) => (
|
||||
<Button
|
||||
variant="ghost"
|
||||
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")}
|
||||
onClick={() => column.toggleSorting(column.getIsSorted() === 'asc')}
|
||||
>
|
||||
# <ArrowUpDownIcon className="ml-1 h-4 w-4" />
|
||||
</Button>
|
||||
),
|
||||
cell: ({ row }) => Number(row.getValue("pessoa_id")),
|
||||
cell: ({ row }) => Number(row.getValue('pessoa_id')),
|
||||
enableSorting: false,
|
||||
},
|
||||
|
||||
// Nome / Email / Foto
|
||||
{
|
||||
id: "nome_completo",
|
||||
id: 'nome_completo',
|
||||
accessorFn: (row) => row,
|
||||
header: ({ column }) => (
|
||||
<Button
|
||||
variant="ghost"
|
||||
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")}
|
||||
onClick={() => column.toggleSorting(column.getIsSorted() === 'asc')}
|
||||
>
|
||||
Nome / Email{" "}
|
||||
<ArrowUpDownIcon className="ml-1 h-4 w-4 cursor-pointer" />
|
||||
Nome / Email <ArrowUpDownIcon className="ml-1 h-4 w-4 cursor-pointer" />
|
||||
</Button>
|
||||
),
|
||||
cell: ({ row }) => {
|
||||
|
|
@ -76,12 +70,12 @@ function createPessoaColumns(
|
|||
return (
|
||||
<div className="flex items-center gap-3">
|
||||
{/* Foto ou Iniciais */}
|
||||
<div className="w-10 h-10 rounded-full bg-gray-200 flex items-center justify-center overflow-hidden">
|
||||
<div className="flex h-10 w-10 items-center justify-center overflow-hidden rounded-full bg-gray-200">
|
||||
{pessoa.foto ? (
|
||||
<img
|
||||
src={pessoa.foto}
|
||||
alt={pessoa.nome || "Avatar"}
|
||||
className="w-full h-full object-cover"
|
||||
alt={pessoa.nome || 'Avatar'}
|
||||
className="h-full w-full object-cover"
|
||||
/>
|
||||
) : (
|
||||
<span className="text-sm font-medium text-gray-700">
|
||||
|
|
@ -92,63 +86,59 @@ function createPessoaColumns(
|
|||
|
||||
{/* Nome e Email */}
|
||||
<div>
|
||||
<div className="font-semibold text-gray-900 capitalize">
|
||||
{pessoa.nome || "-"}
|
||||
</div>
|
||||
<div className="font-semibold text-gray-900 capitalize">{pessoa.nome || '-'}</div>
|
||||
<div className="text-sm text-gray-500">
|
||||
{empty(pessoa.email) ? "Email não informado" : pessoa.email}
|
||||
{empty(pessoa.email) ? 'Email não informado' : pessoa.email}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
sortingFn: (a, b) =>
|
||||
(a.original.nome?.toLowerCase() || "").localeCompare(
|
||||
b.original.nome?.toLowerCase() || "",
|
||||
),
|
||||
(a.original.nome?.toLowerCase() || '').localeCompare(b.original.nome?.toLowerCase() || ''),
|
||||
},
|
||||
|
||||
// CPF
|
||||
{
|
||||
accessorKey: "cpf_cnpj",
|
||||
accessorKey: 'cpf_cnpj',
|
||||
header: ({ column }) => (
|
||||
<Button
|
||||
variant="ghost"
|
||||
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")}
|
||||
onClick={() => column.toggleSorting(column.getIsSorted() === 'asc')}
|
||||
>
|
||||
CPF <ArrowUpDownIcon className="ml-1 h-4 w-4 cursor-pointer" />
|
||||
</Button>
|
||||
),
|
||||
cell: ({ row }) => FormatCPF(row.getValue("cpf_cnpj")),
|
||||
cell: ({ row }) => FormatCPF(row.getValue('cpf_cnpj')),
|
||||
},
|
||||
|
||||
// Telefone
|
||||
{
|
||||
accessorKey: "telefone",
|
||||
accessorKey: 'telefone',
|
||||
header: ({ column }) => (
|
||||
<Button
|
||||
variant="ghost"
|
||||
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")}
|
||||
onClick={() => column.toggleSorting(column.getIsSorted() === 'asc')}
|
||||
>
|
||||
Telefone <ArrowUpDownIcon className="ml-1 h-4 w-4 cursor-pointer" />
|
||||
</Button>
|
||||
),
|
||||
cell: ({ row }) => FormatPhone(row.getValue("telefone")),
|
||||
cell: ({ row }) => FormatPhone(row.getValue('telefone')),
|
||||
},
|
||||
|
||||
// Cidade / UF
|
||||
{
|
||||
id: "cidade_uf",
|
||||
id: 'cidade_uf',
|
||||
accessorFn: (row) => `${row.cidade}/${row.uf}`,
|
||||
header: ({ column }) => (
|
||||
<Button
|
||||
variant="ghost"
|
||||
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")}
|
||||
onClick={() => column.toggleSorting(column.getIsSorted() === 'asc')}
|
||||
>
|
||||
Cidade/UF <ArrowUpDownIcon className="ml-1 h-4 w-4 cursor-pointer" />
|
||||
</Button>
|
||||
),
|
||||
cell: ({ row }) => <span>{row.getValue("cidade_uf") || "-"}</span>,
|
||||
cell: ({ row }) => <span>{row.getValue('cidade_uf') || '-'}</span>,
|
||||
sortingFn: (a, b) =>
|
||||
`${a.original.cidade}/${a.original.uf}`
|
||||
.toLowerCase()
|
||||
|
|
@ -157,23 +147,23 @@ function createPessoaColumns(
|
|||
|
||||
// Data de cadastro
|
||||
{
|
||||
accessorKey: "data_cadastro",
|
||||
accessorKey: 'data_cadastro',
|
||||
header: ({ column }) => (
|
||||
<Button
|
||||
variant="ghost"
|
||||
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")}
|
||||
onClick={() => column.toggleSorting(column.getIsSorted() === 'asc')}
|
||||
>
|
||||
Cadastro <ArrowUpDownIcon className="ml-1 h-4 w-4 cursor-pointer" />
|
||||
</Button>
|
||||
),
|
||||
cell: ({ row }) => FormatDateTime(row.getValue("data_cadastro")),
|
||||
sortingFn: "datetime",
|
||||
cell: ({ row }) => FormatDateTime(row.getValue('data_cadastro')),
|
||||
sortingFn: 'datetime',
|
||||
},
|
||||
|
||||
// Ações
|
||||
{
|
||||
id: "actions",
|
||||
header: "Ações",
|
||||
id: 'actions',
|
||||
header: 'Ações',
|
||||
cell: ({ row }) => {
|
||||
const pessoa = row.original;
|
||||
return (
|
||||
|
|
@ -185,10 +175,7 @@ function createPessoaColumns(
|
|||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent side="left" align="start">
|
||||
<DropdownMenuGroup>
|
||||
<DropdownMenuItem
|
||||
className="cursor-pointer"
|
||||
onSelect={() => onEdit(pessoa, true)}
|
||||
>
|
||||
<DropdownMenuItem className="cursor-pointer" onSelect={() => onEdit(pessoa, true)}>
|
||||
<PencilIcon className="mr-2 h-4 w-4" />
|
||||
Editar
|
||||
</DropdownMenuItem>
|
||||
|
|
@ -214,11 +201,7 @@ function createPessoaColumns(
|
|||
/**
|
||||
* Componente principal da tabela
|
||||
*/
|
||||
export default function TPessoaTable({
|
||||
data,
|
||||
onEdit,
|
||||
onDelete,
|
||||
}: TPessoaTableProps) {
|
||||
export default function TPessoaTable({ data, onEdit, onDelete }: TPessoaTableProps) {
|
||||
const columns = createPessoaColumns(onEdit, onDelete);
|
||||
return (
|
||||
<div>
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
"use client";
|
||||
'use client';
|
||||
|
||||
import z from "zod";
|
||||
import React, { useEffect } from "react";
|
||||
import { useForm, Controller } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import z from 'zod';
|
||||
import React, { useEffect } from 'react';
|
||||
import { useForm, Controller } from 'react-hook-form';
|
||||
import { zodResolver } from '@hookform/resolvers/zod';
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
Dialog,
|
||||
DialogClose,
|
||||
|
|
@ -14,7 +14,7 @@ import {
|
|||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from "@/components/ui/dialog";
|
||||
} from '@/components/ui/dialog';
|
||||
import {
|
||||
Form,
|
||||
FormControl,
|
||||
|
|
@ -22,16 +22,16 @@ import {
|
|||
FormItem,
|
||||
FormLabel,
|
||||
FormMessage,
|
||||
} from "@/components/ui/form";
|
||||
import { Input } from "@/components/ui/input";
|
||||
} from '@/components/ui/form';
|
||||
import { Input } from '@/components/ui/input';
|
||||
|
||||
import { TPessoaSchema } from "../../../_schemas/TPessoaSchema";
|
||||
import LoadingButton from "@/app/_components/loadingButton/LoadingButton";
|
||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||
import { HouseIcon, IdCardIcon, UserIcon } from "lucide-react";
|
||||
import { Textarea } from "@/components/ui/textarea";
|
||||
import { useTPessoaRepresentanteIndexHook } from "../../../_hooks/t_pessoa_representante/useTPessoaRepresentanteIndexHook";
|
||||
import TPessoaRepresentantePage from "../../t_pessoa_representante/TPessoaRepresentantePage";
|
||||
import { TPessoaSchema } from '../../../_schemas/TPessoaSchema';
|
||||
import LoadingButton from '@/app/_components/loadingButton/LoadingButton';
|
||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
|
||||
import { HouseIcon, IdCardIcon, UserIcon } from 'lucide-react';
|
||||
import { Textarea } from '@/components/ui/textarea';
|
||||
import { useTPessoaRepresentanteIndexHook } from '../../../_hooks/t_pessoa_representante/useTPessoaRepresentanteIndexHook';
|
||||
import TPessoaRepresentantePage from '../../t_pessoa_representante/TPessoaRepresentantePage';
|
||||
|
||||
type FormValues = z.infer<typeof TPessoaSchema>;
|
||||
|
||||
|
|
@ -50,14 +50,13 @@ export default function TPessoaJuridicaForm({
|
|||
onSave,
|
||||
buttonIsLoading,
|
||||
}: TPessoaFormProps) {
|
||||
const { tPessoaRepresentante, fetchTPessoaRepresentante } =
|
||||
useTPessoaRepresentanteIndexHook();
|
||||
const { tPessoaRepresentante, fetchTPessoaRepresentante } = useTPessoaRepresentanteIndexHook();
|
||||
|
||||
// Inicializa o react-hook-form com schema zod
|
||||
const form = useForm<FormValues>({
|
||||
resolver: zodResolver(TPessoaSchema),
|
||||
defaultValues: {
|
||||
nome: "",
|
||||
nome: '',
|
||||
pessoa_id: 0,
|
||||
},
|
||||
});
|
||||
|
|
@ -84,7 +83,7 @@ export default function TPessoaJuridicaForm({
|
|||
if (!open) onClose(null, false);
|
||||
}}
|
||||
>
|
||||
<DialogContent className="w-full max-w-full sm:max-w-3xl md:max-w-4xl lg:max-w-5xl p-6">
|
||||
<DialogContent className="w-full max-w-full p-6 sm:max-w-3xl md:max-w-4xl lg:max-w-5xl">
|
||||
<DialogHeader>
|
||||
<DialogTitle>Pessoa</DialogTitle>
|
||||
<DialogDescription>Preencha os dados da pessoa</DialogDescription>
|
||||
|
|
@ -93,24 +92,15 @@ export default function TPessoaJuridicaForm({
|
|||
<form onSubmit={form.handleSubmit(onSave)} className="space-y-6">
|
||||
{/* Tabs */}
|
||||
<Tabs defaultValue="dadosPessoais" className="space-y-4">
|
||||
<TabsList className="w-full flex">
|
||||
<TabsTrigger
|
||||
className="flex-1 text-center cursor-pointer"
|
||||
value="dadosPessoais"
|
||||
>
|
||||
<TabsList className="flex w-full">
|
||||
<TabsTrigger className="flex-1 cursor-pointer text-center" value="dadosPessoais">
|
||||
<UserIcon className="me-1" />
|
||||
Dados Pessoais
|
||||
</TabsTrigger>
|
||||
<TabsTrigger
|
||||
className="flex-1 text-center cursor-pointer"
|
||||
value="endereco"
|
||||
>
|
||||
<TabsTrigger className="flex-1 cursor-pointer text-center" value="endereco">
|
||||
<HouseIcon /> Endereço
|
||||
</TabsTrigger>
|
||||
<TabsTrigger
|
||||
className="flex-1 text-center cursor-pointer"
|
||||
value="documentos"
|
||||
>
|
||||
<TabsTrigger className="flex-1 cursor-pointer text-center" value="documentos">
|
||||
<IdCardIcon /> Representantes
|
||||
</TabsTrigger>
|
||||
</TabsList>
|
||||
|
|
@ -190,11 +180,7 @@ export default function TPessoaJuridicaForm({
|
|||
<FormItem className="w-full">
|
||||
<FormLabel>CNPJ</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
placeholder="Digite o CNPJ"
|
||||
className="w-full"
|
||||
/>
|
||||
<Input {...field} placeholder="Digite o CNPJ" className="w-full" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
|
|
@ -226,7 +212,7 @@ export default function TPessoaJuridicaForm({
|
|||
</TabsContent>
|
||||
{/* Endereço */}
|
||||
<TabsContent value="endereco" className="space-y-4">
|
||||
<div className="grid grid-cols-12 gap-4 w-full">
|
||||
<div className="grid w-full grid-cols-12 gap-4">
|
||||
{/* País */}
|
||||
<div className="col-span-12 sm:col-span-12 md:col-span-6">
|
||||
<FormField
|
||||
|
|
@ -236,11 +222,7 @@ export default function TPessoaJuridicaForm({
|
|||
<FormItem className="w-full">
|
||||
<FormLabel>País</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
placeholder="Digite o nome"
|
||||
className="w-full"
|
||||
/>
|
||||
<Input {...field} placeholder="Digite o nome" className="w-full" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
|
|
@ -256,11 +238,7 @@ export default function TPessoaJuridicaForm({
|
|||
<FormItem className="w-full">
|
||||
<FormLabel>UF</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
placeholder="Digite o nome"
|
||||
className="w-full"
|
||||
/>
|
||||
<Input {...field} placeholder="Digite o nome" className="w-full" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
|
|
@ -276,11 +254,7 @@ export default function TPessoaJuridicaForm({
|
|||
<FormItem className="w-full">
|
||||
<FormLabel>CEP</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
placeholder="Digite o nome"
|
||||
className="w-full"
|
||||
/>
|
||||
<Input {...field} placeholder="Digite o nome" className="w-full" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
|
|
@ -296,11 +270,7 @@ export default function TPessoaJuridicaForm({
|
|||
<FormItem className="w-full">
|
||||
<FormLabel>Cidade</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
placeholder="Digite o nome"
|
||||
className="w-full"
|
||||
/>
|
||||
<Input {...field} placeholder="Digite o nome" className="w-full" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
|
|
@ -316,11 +286,7 @@ export default function TPessoaJuridicaForm({
|
|||
<FormItem className="w-full">
|
||||
<FormLabel>Município</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
placeholder="Digite o nome"
|
||||
className="w-full"
|
||||
/>
|
||||
<Input {...field} placeholder="Digite o nome" className="w-full" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
|
|
@ -336,11 +302,7 @@ export default function TPessoaJuridicaForm({
|
|||
<FormItem className="w-full">
|
||||
<FormLabel>Bairro</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
placeholder="Digite o nome"
|
||||
className="w-full"
|
||||
/>
|
||||
<Input {...field} placeholder="Digite o nome" className="w-full" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
|
|
@ -356,11 +318,7 @@ export default function TPessoaJuridicaForm({
|
|||
<FormItem className="w-full">
|
||||
<FormLabel>Logradouro</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
placeholder="Digite o nome"
|
||||
className="w-full"
|
||||
/>
|
||||
<Input {...field} placeholder="Digite o nome" className="w-full" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
|
|
@ -376,11 +334,7 @@ export default function TPessoaJuridicaForm({
|
|||
<FormItem className="w-full">
|
||||
<FormLabel>Número</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
placeholder="Digite o nome"
|
||||
className="w-full"
|
||||
/>
|
||||
<Input {...field} placeholder="Digite o nome" className="w-full" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
|
|
@ -396,11 +350,7 @@ export default function TPessoaJuridicaForm({
|
|||
<FormItem className="w-full">
|
||||
<FormLabel>Unidade</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
placeholder="Digite o nome"
|
||||
className="w-full"
|
||||
/>
|
||||
<Input {...field} placeholder="Digite o nome" className="w-full" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
|
|
@ -416,11 +366,7 @@ export default function TPessoaJuridicaForm({
|
|||
<FormItem className="w-full">
|
||||
<FormLabel>Cidade não encontrada</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
placeholder="Digite o nome"
|
||||
className="w-full"
|
||||
/>
|
||||
<Input {...field} placeholder="Digite o nome" className="w-full" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
|
|
@ -455,7 +401,7 @@ export default function TPessoaJuridicaForm({
|
|||
/>
|
||||
</DialogFooter>
|
||||
{/* Campo oculto */}
|
||||
<input type="hidden" {...form.register("pessoa_id")} />
|
||||
<input type="hidden" {...form.register('pessoa_id')} />
|
||||
</form>
|
||||
</Form>
|
||||
</DialogContent>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
"use client";
|
||||
'use client';
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
|
|
@ -8,25 +8,20 @@ import {
|
|||
DropdownMenuItem,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger,
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
} from '@/components/ui/dropdown-menu';
|
||||
|
||||
import {
|
||||
ArrowUpDownIcon,
|
||||
EllipsisIcon,
|
||||
PencilIcon,
|
||||
Trash2Icon,
|
||||
} from "lucide-react";
|
||||
import { ColumnDef } from "@tanstack/react-table";
|
||||
import { ArrowUpDownIcon, EllipsisIcon, PencilIcon, Trash2Icon } from 'lucide-react';
|
||||
import { ColumnDef } from '@tanstack/react-table';
|
||||
|
||||
import GetNameInitials from "@/actions/text/GetNameInitials";
|
||||
import { DataTable } from "@/app/_components/dataTable/DataTable";
|
||||
import GetNameInitials from '@/actions/text/GetNameInitials';
|
||||
import { DataTable } from '@/app/_components/dataTable/DataTable';
|
||||
|
||||
import TPessoaInterface from "../../../_interfaces/TPessoaInterface";
|
||||
import { FormatCPF } from "@/actions/CPF/FormatCPF";
|
||||
import { FormatPhone } from "@/actions/phone/FormatPhone";
|
||||
import { FormatDateTime } from "@/actions/dateTime/FormatDateTime";
|
||||
import empty from "@/actions/validations/empty";
|
||||
import { FormatCNPJ } from "@/actions/CNPJ/FormatCNPJ";
|
||||
import TPessoaInterface from '../../../_interfaces/TPessoaInterface';
|
||||
import { FormatCPF } from '@/actions/CPF/FormatCPF';
|
||||
import { FormatPhone } from '@/actions/phone/FormatPhone';
|
||||
import { FormatDateTime } from '@/actions/dateTime/FormatDateTime';
|
||||
import empty from '@/actions/validations/empty';
|
||||
import { FormatCNPJ } from '@/actions/CNPJ/FormatCNPJ';
|
||||
|
||||
// Tipagem das props
|
||||
interface TPessoaJuridicaTableProps {
|
||||
|
|
@ -45,30 +40,29 @@ function createPessoaColumns(
|
|||
return [
|
||||
// ID
|
||||
{
|
||||
accessorKey: "pessoa_id",
|
||||
accessorKey: 'pessoa_id',
|
||||
header: ({ column }) => (
|
||||
<Button
|
||||
variant="ghost"
|
||||
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")}
|
||||
onClick={() => column.toggleSorting(column.getIsSorted() === 'asc')}
|
||||
>
|
||||
# <ArrowUpDownIcon className="ml-1 h-4 w-4" />
|
||||
</Button>
|
||||
),
|
||||
cell: ({ row }) => Number(row.getValue("pessoa_id")),
|
||||
cell: ({ row }) => Number(row.getValue('pessoa_id')),
|
||||
enableSorting: false,
|
||||
},
|
||||
|
||||
// Nome / Email / Foto
|
||||
{
|
||||
id: "nome_completo",
|
||||
id: 'nome_completo',
|
||||
accessorFn: (row) => row,
|
||||
header: ({ column }) => (
|
||||
<Button
|
||||
variant="ghost"
|
||||
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")}
|
||||
onClick={() => column.toggleSorting(column.getIsSorted() === 'asc')}
|
||||
>
|
||||
Nome / Email{" "}
|
||||
<ArrowUpDownIcon className="ml-1 h-4 w-4 cursor-pointer" />
|
||||
Nome / Email <ArrowUpDownIcon className="ml-1 h-4 w-4 cursor-pointer" />
|
||||
</Button>
|
||||
),
|
||||
cell: ({ row }) => {
|
||||
|
|
@ -77,63 +71,59 @@ function createPessoaColumns(
|
|||
<div className="flex items-center gap-3">
|
||||
{/* Nome e Email */}
|
||||
<div>
|
||||
<div className="font-semibold text-gray-900 capitalize">
|
||||
{pessoa.nome || "-"}
|
||||
</div>
|
||||
<div className="font-semibold text-gray-900 capitalize">{pessoa.nome || '-'}</div>
|
||||
<div className="text-sm text-gray-500">
|
||||
{empty(pessoa.email) ? "Email não informado" : pessoa.email}
|
||||
{empty(pessoa.email) ? 'Email não informado' : pessoa.email}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
sortingFn: (a, b) =>
|
||||
(a.original.nome?.toLowerCase() || "").localeCompare(
|
||||
b.original.nome?.toLowerCase() || "",
|
||||
),
|
||||
(a.original.nome?.toLowerCase() || '').localeCompare(b.original.nome?.toLowerCase() || ''),
|
||||
},
|
||||
|
||||
// CPF
|
||||
{
|
||||
accessorKey: "cpf_cnpj",
|
||||
accessorKey: 'cpf_cnpj',
|
||||
header: ({ column }) => (
|
||||
<Button
|
||||
variant="ghost"
|
||||
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")}
|
||||
onClick={() => column.toggleSorting(column.getIsSorted() === 'asc')}
|
||||
>
|
||||
CNPJ <ArrowUpDownIcon className="ml-1 h-4 w-4 cursor-pointer" />
|
||||
</Button>
|
||||
),
|
||||
cell: ({ row }) => FormatCNPJ(row.getValue("cpf_cnpj")),
|
||||
cell: ({ row }) => FormatCNPJ(row.getValue('cpf_cnpj')),
|
||||
},
|
||||
|
||||
// Telefone
|
||||
{
|
||||
accessorKey: "telefone",
|
||||
accessorKey: 'telefone',
|
||||
header: ({ column }) => (
|
||||
<Button
|
||||
variant="ghost"
|
||||
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")}
|
||||
onClick={() => column.toggleSorting(column.getIsSorted() === 'asc')}
|
||||
>
|
||||
Telefone <ArrowUpDownIcon className="ml-1 h-4 w-4 cursor-pointer" />
|
||||
</Button>
|
||||
),
|
||||
cell: ({ row }) => FormatPhone(row.getValue("telefone")),
|
||||
cell: ({ row }) => FormatPhone(row.getValue('telefone')),
|
||||
},
|
||||
|
||||
// Cidade / UF
|
||||
{
|
||||
id: "cidade_uf",
|
||||
id: 'cidade_uf',
|
||||
accessorFn: (row) => `${row.cidade}/${row.uf}`,
|
||||
header: ({ column }) => (
|
||||
<Button
|
||||
variant="ghost"
|
||||
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")}
|
||||
onClick={() => column.toggleSorting(column.getIsSorted() === 'asc')}
|
||||
>
|
||||
Cidade/UF <ArrowUpDownIcon className="ml-1 h-4 w-4 cursor-pointer" />
|
||||
</Button>
|
||||
),
|
||||
cell: ({ row }) => <span>{row.getValue("cidade_uf") || "-"}</span>,
|
||||
cell: ({ row }) => <span>{row.getValue('cidade_uf') || '-'}</span>,
|
||||
sortingFn: (a, b) =>
|
||||
`${a.original.cidade}/${a.original.uf}`
|
||||
.toLowerCase()
|
||||
|
|
@ -142,23 +132,23 @@ function createPessoaColumns(
|
|||
|
||||
// Data de cadastro
|
||||
{
|
||||
accessorKey: "data_cadastro",
|
||||
accessorKey: 'data_cadastro',
|
||||
header: ({ column }) => (
|
||||
<Button
|
||||
variant="ghost"
|
||||
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")}
|
||||
onClick={() => column.toggleSorting(column.getIsSorted() === 'asc')}
|
||||
>
|
||||
Cadastro <ArrowUpDownIcon className="ml-1 h-4 w-4 cursor-pointer" />
|
||||
</Button>
|
||||
),
|
||||
cell: ({ row }) => FormatDateTime(row.getValue("data_cadastro")),
|
||||
sortingFn: "datetime",
|
||||
cell: ({ row }) => FormatDateTime(row.getValue('data_cadastro')),
|
||||
sortingFn: 'datetime',
|
||||
},
|
||||
|
||||
// Ações
|
||||
{
|
||||
id: "actions",
|
||||
header: "Ações",
|
||||
id: 'actions',
|
||||
header: 'Ações',
|
||||
cell: ({ row }) => {
|
||||
const pessoa = row.original;
|
||||
return (
|
||||
|
|
@ -170,10 +160,7 @@ function createPessoaColumns(
|
|||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent side="left" align="start">
|
||||
<DropdownMenuGroup>
|
||||
<DropdownMenuItem
|
||||
className="cursor-pointer"
|
||||
onSelect={() => onEdit(pessoa, true)}
|
||||
>
|
||||
<DropdownMenuItem className="cursor-pointer" onSelect={() => onEdit(pessoa, true)}>
|
||||
<PencilIcon className="mr-2 h-4 w-4" />
|
||||
Editar
|
||||
</DropdownMenuItem>
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
"use client";
|
||||
'use client';
|
||||
|
||||
import z from "zod";
|
||||
import React, { useEffect } from "react";
|
||||
import { useForm, Controller } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import z from 'zod';
|
||||
import React, { useEffect } from 'react';
|
||||
import { useForm, Controller } from 'react-hook-form';
|
||||
import { zodResolver } from '@hookform/resolvers/zod';
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
Dialog,
|
||||
DialogClose,
|
||||
|
|
@ -14,7 +14,7 @@ import {
|
|||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from "@/components/ui/dialog";
|
||||
} from '@/components/ui/dialog';
|
||||
import {
|
||||
Form,
|
||||
FormControl,
|
||||
|
|
@ -22,19 +22,19 @@ import {
|
|||
FormItem,
|
||||
FormLabel,
|
||||
FormMessage,
|
||||
} from "@/components/ui/form";
|
||||
import { Input } from "@/components/ui/input";
|
||||
} from '@/components/ui/form';
|
||||
import { Input } from '@/components/ui/input';
|
||||
|
||||
import { TPessoaSchema } from "../../_schemas/TPessoaSchema";
|
||||
import LoadingButton from "@/app/_components/loadingButton/LoadingButton";
|
||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||
import { TPessoaSchema } from '../../_schemas/TPessoaSchema';
|
||||
import LoadingButton from '@/app/_components/loadingButton/LoadingButton';
|
||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from "@/components/ui/select";
|
||||
} from '@/components/ui/select';
|
||||
import {
|
||||
ArrowUpDownIcon,
|
||||
CheckIcon,
|
||||
|
|
@ -45,17 +45,13 @@ import {
|
|||
PencilIcon,
|
||||
Trash2Icon,
|
||||
UserIcon,
|
||||
} from "lucide-react";
|
||||
import { Sexo } from "@/enums/SexoEnum";
|
||||
import { useGTBEstadoCivilReadHook } from "../../_hooks/g_tb_estadocivil/useGTBEstadoCivilReadHook";
|
||||
import GetCapitalize from "@/actions/text/GetCapitalize";
|
||||
import { useGTBRegimeComunhaoReadHook } from "../../_hooks/g_tb_regimecomunhao/useGTBRegimeComunhaoReadHook";
|
||||
import { useGTBProfissaoReadHook } from "../../_hooks/g_tb_profissao/useGTBProfissaoReadHook";
|
||||
import {
|
||||
Popover,
|
||||
PopoverContent,
|
||||
PopoverTrigger,
|
||||
} from "@/components/ui/popover";
|
||||
} from 'lucide-react';
|
||||
import { Sexo } from '@/enums/SexoEnum';
|
||||
import { useGTBEstadoCivilReadHook } from '../../_hooks/g_tb_estadocivil/useGTBEstadoCivilReadHook';
|
||||
import GetCapitalize from '@/actions/text/GetCapitalize';
|
||||
import { useGTBRegimeComunhaoReadHook } from '../../_hooks/g_tb_regimecomunhao/useGTBRegimeComunhaoReadHook';
|
||||
import { useGTBProfissaoReadHook } from '../../_hooks/g_tb_profissao/useGTBProfissaoReadHook';
|
||||
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';
|
||||
import {
|
||||
Command,
|
||||
CommandEmpty,
|
||||
|
|
@ -63,26 +59,26 @@ import {
|
|||
CommandInput,
|
||||
CommandItem,
|
||||
CommandList,
|
||||
} from "@/components/ui/command";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { useTPessoaIndexHook } from "../../_hooks/t_pessoa/useTPessoaIndexHook";
|
||||
import TPessoaTable from "../t_pessoa/TPessoaTable";
|
||||
import TPessoaInterface from "../../_interfaces/TPessoaInterface";
|
||||
import { ColumnDef } from "@tanstack/react-table";
|
||||
import GetNameInitials from "@/actions/text/GetNameInitials";
|
||||
import empty from "@/actions/validations/empty";
|
||||
import { FormatCPF } from "@/actions/CPF/FormatCPF";
|
||||
import { FormatPhone } from "@/actions/phone/FormatPhone";
|
||||
} from '@/components/ui/command';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { useTPessoaIndexHook } from '../../_hooks/t_pessoa/useTPessoaIndexHook';
|
||||
import TPessoaTable from '../t_pessoa/TPessoaTable';
|
||||
import TPessoaInterface from '../../_interfaces/TPessoaInterface';
|
||||
import { ColumnDef } from '@tanstack/react-table';
|
||||
import GetNameInitials from '@/actions/text/GetNameInitials';
|
||||
import empty from '@/actions/validations/empty';
|
||||
import { FormatCPF } from '@/actions/CPF/FormatCPF';
|
||||
import { FormatPhone } from '@/actions/phone/FormatPhone';
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuGroup,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger,
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
import { DropdownMenuContent } from "@radix-ui/react-dropdown-menu";
|
||||
import { DataTable } from "@/app/_components/dataTable/DataTable";
|
||||
import { Checkbox } from "@/components/ui/checkbox";
|
||||
} from '@/components/ui/dropdown-menu';
|
||||
import { DropdownMenuContent } from '@radix-ui/react-dropdown-menu';
|
||||
import { DataTable } from '@/app/_components/dataTable/DataTable';
|
||||
import { Checkbox } from '@/components/ui/checkbox';
|
||||
|
||||
type FormValues = z.infer<typeof TPessoaSchema>;
|
||||
|
||||
|
|
@ -103,12 +99,12 @@ function createPessoaColumns(
|
|||
): ColumnDef<TPessoaInterface>[] {
|
||||
return [
|
||||
{
|
||||
id: "select",
|
||||
id: 'select',
|
||||
header: ({ table }) => (
|
||||
<Checkbox
|
||||
checked={
|
||||
table.getIsAllPageRowsSelected() ||
|
||||
(table.getIsSomePageRowsSelected() && "indeterminate")
|
||||
(table.getIsSomePageRowsSelected() && 'indeterminate')
|
||||
}
|
||||
onCheckedChange={(value) => table.toggleAllPageRowsSelected(!!value)}
|
||||
aria-label="Select all"
|
||||
|
|
@ -126,30 +122,29 @@ function createPessoaColumns(
|
|||
},
|
||||
// ID
|
||||
{
|
||||
accessorKey: "pessoa_representante_id",
|
||||
accessorKey: 'pessoa_representante_id',
|
||||
header: ({ column }) => (
|
||||
<Button
|
||||
variant="ghost"
|
||||
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")}
|
||||
onClick={() => column.toggleSorting(column.getIsSorted() === 'asc')}
|
||||
>
|
||||
# <ArrowUpDownIcon className="ml-1 h-4 w-4" />
|
||||
</Button>
|
||||
),
|
||||
cell: ({ row }) => Number(row.getValue("pessoa_representante_id")),
|
||||
cell: ({ row }) => Number(row.getValue('pessoa_representante_id')),
|
||||
enableSorting: false,
|
||||
},
|
||||
|
||||
// Nome / Email / Foto
|
||||
{
|
||||
id: "nome_completo",
|
||||
id: 'nome_completo',
|
||||
accessorFn: (row) => row,
|
||||
header: ({ column }) => (
|
||||
<Button
|
||||
variant="ghost"
|
||||
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")}
|
||||
onClick={() => column.toggleSorting(column.getIsSorted() === 'asc')}
|
||||
>
|
||||
Nome / Email{" "}
|
||||
<ArrowUpDownIcon className="ml-1 h-4 w-4 cursor-pointer" />
|
||||
Nome / Email <ArrowUpDownIcon className="ml-1 h-4 w-4 cursor-pointer" />
|
||||
</Button>
|
||||
),
|
||||
cell: ({ row }) => {
|
||||
|
|
@ -158,12 +153,12 @@ function createPessoaColumns(
|
|||
return (
|
||||
<div className="flex items-center gap-3">
|
||||
{/* Foto ou Iniciais */}
|
||||
<div className="w-10 h-10 rounded-full bg-gray-200 flex items-center justify-center overflow-hidden">
|
||||
<div className="flex h-10 w-10 items-center justify-center overflow-hidden rounded-full bg-gray-200">
|
||||
{pessoa.foto ? (
|
||||
<img
|
||||
src={pessoa.foto}
|
||||
alt={pessoa.nome || "Avatar"}
|
||||
className="w-full h-full object-cover"
|
||||
alt={pessoa.nome || 'Avatar'}
|
||||
className="h-full w-full object-cover"
|
||||
/>
|
||||
) : (
|
||||
<span className="text-sm font-medium text-gray-700">
|
||||
|
|
@ -174,54 +169,50 @@ function createPessoaColumns(
|
|||
|
||||
{/* Nome e Email */}
|
||||
<div>
|
||||
<div className="font-semibold text-gray-900 capitalize">
|
||||
{pessoa.nome || "-"}
|
||||
</div>
|
||||
<div className="font-semibold text-gray-900 capitalize">{pessoa.nome || '-'}</div>
|
||||
<div className="text-sm text-gray-500">
|
||||
{empty(pessoa.email) ? "Email não informado" : pessoa.email}
|
||||
{empty(pessoa.email) ? 'Email não informado' : pessoa.email}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
sortingFn: (a, b) =>
|
||||
(a.original.nome?.toLowerCase() || "").localeCompare(
|
||||
b.original.nome?.toLowerCase() || "",
|
||||
),
|
||||
(a.original.nome?.toLowerCase() || '').localeCompare(b.original.nome?.toLowerCase() || ''),
|
||||
},
|
||||
|
||||
// CPF
|
||||
{
|
||||
accessorKey: "cpf_cnpj",
|
||||
accessorKey: 'cpf_cnpj',
|
||||
header: ({ column }) => (
|
||||
<Button
|
||||
variant="ghost"
|
||||
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")}
|
||||
onClick={() => column.toggleSorting(column.getIsSorted() === 'asc')}
|
||||
>
|
||||
CPF <ArrowUpDownIcon className="ml-1 h-4 w-4 cursor-pointer" />
|
||||
</Button>
|
||||
),
|
||||
cell: ({ row }) => FormatCPF(row.getValue("cpf_cnpj")),
|
||||
cell: ({ row }) => FormatCPF(row.getValue('cpf_cnpj')),
|
||||
},
|
||||
|
||||
// Telefone
|
||||
{
|
||||
accessorKey: "telefone",
|
||||
accessorKey: 'telefone',
|
||||
header: ({ column }) => (
|
||||
<Button
|
||||
variant="ghost"
|
||||
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")}
|
||||
onClick={() => column.toggleSorting(column.getIsSorted() === 'asc')}
|
||||
>
|
||||
Telefone <ArrowUpDownIcon className="ml-1 h-4 w-4 cursor-pointer" />
|
||||
</Button>
|
||||
),
|
||||
cell: ({ row }) => FormatPhone(row.getValue("telefone")),
|
||||
cell: ({ row }) => FormatPhone(row.getValue('telefone')),
|
||||
},
|
||||
|
||||
// Ações
|
||||
{
|
||||
id: "actions",
|
||||
header: "Ações",
|
||||
id: 'actions',
|
||||
header: 'Ações',
|
||||
cell: ({ row }) => {
|
||||
const pessoa = row.original;
|
||||
return (
|
||||
|
|
@ -233,10 +224,7 @@ function createPessoaColumns(
|
|||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent side="left" align="start">
|
||||
<DropdownMenuGroup>
|
||||
<DropdownMenuItem
|
||||
className="cursor-pointer"
|
||||
onSelect={() => onEdit(pessoa, true)}
|
||||
>
|
||||
<DropdownMenuItem className="cursor-pointer" onSelect={() => onEdit(pessoa, true)}>
|
||||
<PencilIcon className="mr-2 h-4 w-4" />
|
||||
Editar
|
||||
</DropdownMenuItem>
|
||||
|
|
@ -272,7 +260,7 @@ export default function TPessoaRepresentanteForm({
|
|||
const form = useForm<FormValues>({
|
||||
resolver: zodResolver(TPessoaSchema),
|
||||
defaultValues: {
|
||||
nome: "",
|
||||
nome: '',
|
||||
pessoa_id: 0,
|
||||
},
|
||||
});
|
||||
|
|
@ -302,7 +290,7 @@ export default function TPessoaRepresentanteForm({
|
|||
if (!open) onClose(null, false);
|
||||
}}
|
||||
>
|
||||
<DialogContent className="w-full max-w-full sm:max-w-3xl md:max-w-4xl lg:max-w-5xl p-6">
|
||||
<DialogContent className="w-full max-w-full p-6 sm:max-w-3xl md:max-w-4xl lg:max-w-5xl">
|
||||
<DialogHeader>
|
||||
<DialogTitle>Representante</DialogTitle>
|
||||
<DialogDescription>Busque o representante desejado</DialogDescription>
|
||||
|
|
@ -337,7 +325,7 @@ export default function TPessoaRepresentanteForm({
|
|||
/>
|
||||
</DialogFooter>
|
||||
{/* Campo oculto */}
|
||||
<input type="hidden" {...form.register("pessoa_id")} />
|
||||
<input type="hidden" {...form.register('pessoa_id')} />
|
||||
</form>
|
||||
</Form>
|
||||
</DialogContent>
|
||||
|
|
|
|||
|
|
@ -1,43 +1,39 @@
|
|||
"use client";
|
||||
'use client';
|
||||
|
||||
import React, { useEffect, useState, useCallback } from "react";
|
||||
import React, { useEffect, useState, useCallback } from 'react';
|
||||
|
||||
import Loading from "@/app/_components/loading/loading";
|
||||
import TPessoaForm from "../../_components/t_pessoa/TPessoaForm";
|
||||
import Loading from '@/app/_components/loading/loading';
|
||||
import TPessoaForm from '../../_components/t_pessoa/TPessoaForm';
|
||||
|
||||
import { useTPessoaIndexHook } from "../../_hooks/t_pessoa/useTPessoaIndexHook";
|
||||
import { useTPessoaSaveHook } from "../../_hooks/t_pessoa/useTPessoaSaveHook";
|
||||
import { useTPessoaDeleteHook } from "../../_hooks/t_pessoa/useTPessoaDeleteHook";
|
||||
import { useTPessoaIndexHook } from '../../_hooks/t_pessoa/useTPessoaIndexHook';
|
||||
import { useTPessoaSaveHook } from '../../_hooks/t_pessoa/useTPessoaSaveHook';
|
||||
import { useTPessoaDeleteHook } from '../../_hooks/t_pessoa/useTPessoaDeleteHook';
|
||||
|
||||
import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog";
|
||||
import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDialog";
|
||||
import ConfirmDialog from '@/app/_components/confirm_dialog/ConfirmDialog';
|
||||
import { useConfirmDialog } from '@/app/_components/confirm_dialog/useConfirmDialog';
|
||||
|
||||
import TPessoaInterface from "../../_interfaces/TPessoaInterface";
|
||||
import TPessoaRepresentanteTable from "./TPessoaRepresentanteTable";
|
||||
import { useTPessoaRepresentanteIndexHook } from "../../_hooks/t_pessoa_representante/useTPessoaRepresentanteIndexHook";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import Header from "@/app/_components/structure/Header";
|
||||
import TPessoaRepresentanteForm from "./TPessoaRepresentanteForm";
|
||||
import TPessoaInterface from '../../_interfaces/TPessoaInterface';
|
||||
import TPessoaRepresentanteTable from './TPessoaRepresentanteTable';
|
||||
import { useTPessoaRepresentanteIndexHook } from '../../_hooks/t_pessoa_representante/useTPessoaRepresentanteIndexHook';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import Header from '@/app/_components/structure/Header';
|
||||
import TPessoaRepresentanteForm from './TPessoaRepresentanteForm';
|
||||
|
||||
export default function TPessoaRepresentantePage() {
|
||||
// Controle de estado do botão
|
||||
const [buttonIsLoading, setButtonIsLoading] = useState(false);
|
||||
|
||||
// Hooks para leitura e salvamento
|
||||
const { tPessoaRepresentante, fetchTPessoaRepresentante } =
|
||||
useTPessoaRepresentanteIndexHook();
|
||||
const { tPessoaRepresentante, fetchTPessoaRepresentante } = useTPessoaRepresentanteIndexHook();
|
||||
const { saveTCensec } = useTPessoaSaveHook();
|
||||
const { deleteTCensec } = useTPessoaDeleteHook();
|
||||
|
||||
// Estados
|
||||
const [selectedAndamento, setSelectedAndamento] =
|
||||
useState<TPessoaInterface | null>(null);
|
||||
const [selectedAndamento, setSelectedAndamento] = useState<TPessoaInterface | null>(null);
|
||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||
|
||||
// Estado para saber qual item será deletado
|
||||
const [itemToDelete, setItemToDelete] = useState<TPessoaInterface | null>(
|
||||
null,
|
||||
);
|
||||
const [itemToDelete, setItemToDelete] = useState<TPessoaInterface | null>(null);
|
||||
|
||||
/**
|
||||
* Hook do modal de confirmação
|
||||
|
|
@ -137,9 +133,9 @@ export default function TPessoaRepresentantePage() {
|
|||
<div>
|
||||
{/* Cabeçalho */}
|
||||
<Header
|
||||
title={"Representantes"}
|
||||
description={"Gerenciamento de representantes"}
|
||||
buttonText={"Novo representante"}
|
||||
title={'Representantes'}
|
||||
description={'Gerenciamento de representantes'}
|
||||
buttonText={'Novo representante'}
|
||||
buttonAction={() => {
|
||||
handleOpenForm(null);
|
||||
}}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
"use client";
|
||||
'use client';
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
|
|
@ -8,24 +8,19 @@ import {
|
|||
DropdownMenuItem,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger,
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
} from '@/components/ui/dropdown-menu';
|
||||
|
||||
import {
|
||||
ArrowUpDownIcon,
|
||||
EllipsisIcon,
|
||||
PencilIcon,
|
||||
Trash2Icon,
|
||||
} from "lucide-react";
|
||||
import { ColumnDef } from "@tanstack/react-table";
|
||||
import { ArrowUpDownIcon, EllipsisIcon, PencilIcon, Trash2Icon } from 'lucide-react';
|
||||
import { ColumnDef } from '@tanstack/react-table';
|
||||
|
||||
import GetNameInitials from "@/actions/text/GetNameInitials";
|
||||
import { DataTable } from "@/app/_components/dataTable/DataTable";
|
||||
import GetNameInitials from '@/actions/text/GetNameInitials';
|
||||
import { DataTable } from '@/app/_components/dataTable/DataTable';
|
||||
|
||||
import TPessoaInterface from "../../_interfaces/TPessoaInterface";
|
||||
import { FormatCPF } from "@/actions/CPF/FormatCPF";
|
||||
import { FormatPhone } from "@/actions/phone/FormatPhone";
|
||||
import empty from "@/actions/validations/empty";
|
||||
import { Checkbox } from "@/components/ui/checkbox";
|
||||
import TPessoaInterface from '../../_interfaces/TPessoaInterface';
|
||||
import { FormatCPF } from '@/actions/CPF/FormatCPF';
|
||||
import { FormatPhone } from '@/actions/phone/FormatPhone';
|
||||
import empty from '@/actions/validations/empty';
|
||||
import { Checkbox } from '@/components/ui/checkbox';
|
||||
|
||||
// Tipagem das props
|
||||
interface TPessoaRepresentanteTableProps {
|
||||
|
|
@ -44,30 +39,29 @@ function createPessoaColumns(
|
|||
return [
|
||||
// ID
|
||||
{
|
||||
accessorKey: "pessoa_representante_id",
|
||||
accessorKey: 'pessoa_representante_id',
|
||||
header: ({ column }) => (
|
||||
<Button
|
||||
variant="ghost"
|
||||
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")}
|
||||
onClick={() => column.toggleSorting(column.getIsSorted() === 'asc')}
|
||||
>
|
||||
# <ArrowUpDownIcon className="ml-1 h-4 w-4" />
|
||||
</Button>
|
||||
),
|
||||
cell: ({ row }) => Number(row.getValue("pessoa_representante_id")),
|
||||
cell: ({ row }) => Number(row.getValue('pessoa_representante_id')),
|
||||
enableSorting: false,
|
||||
},
|
||||
|
||||
// Nome / Email / Foto
|
||||
{
|
||||
id: "nome_completo",
|
||||
id: 'nome_completo',
|
||||
accessorFn: (row) => row,
|
||||
header: ({ column }) => (
|
||||
<Button
|
||||
variant="ghost"
|
||||
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")}
|
||||
onClick={() => column.toggleSorting(column.getIsSorted() === 'asc')}
|
||||
>
|
||||
Nome / Email{" "}
|
||||
<ArrowUpDownIcon className="ml-1 h-4 w-4 cursor-pointer" />
|
||||
Nome / Email <ArrowUpDownIcon className="ml-1 h-4 w-4 cursor-pointer" />
|
||||
</Button>
|
||||
),
|
||||
cell: ({ row }) => {
|
||||
|
|
@ -76,12 +70,12 @@ function createPessoaColumns(
|
|||
return (
|
||||
<div className="flex items-center gap-3">
|
||||
{/* Foto ou Iniciais */}
|
||||
<div className="w-10 h-10 rounded-full bg-gray-200 flex items-center justify-center overflow-hidden">
|
||||
<div className="flex h-10 w-10 items-center justify-center overflow-hidden rounded-full bg-gray-200">
|
||||
{pessoa.foto ? (
|
||||
<img
|
||||
src={pessoa.foto}
|
||||
alt={pessoa.nome || "Avatar"}
|
||||
className="w-full h-full object-cover"
|
||||
alt={pessoa.nome || 'Avatar'}
|
||||
className="h-full w-full object-cover"
|
||||
/>
|
||||
) : (
|
||||
<span className="text-sm font-medium text-gray-700">
|
||||
|
|
@ -92,54 +86,50 @@ function createPessoaColumns(
|
|||
|
||||
{/* Nome e Email */}
|
||||
<div>
|
||||
<div className="font-semibold text-gray-900 capitalize">
|
||||
{pessoa.nome || "-"}
|
||||
</div>
|
||||
<div className="font-semibold text-gray-900 capitalize">{pessoa.nome || '-'}</div>
|
||||
<div className="text-sm text-gray-500">
|
||||
{empty(pessoa.email) ? "Email não informado" : pessoa.email}
|
||||
{empty(pessoa.email) ? 'Email não informado' : pessoa.email}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
sortingFn: (a, b) =>
|
||||
(a.original.nome?.toLowerCase() || "").localeCompare(
|
||||
b.original.nome?.toLowerCase() || "",
|
||||
),
|
||||
(a.original.nome?.toLowerCase() || '').localeCompare(b.original.nome?.toLowerCase() || ''),
|
||||
},
|
||||
|
||||
// CPF
|
||||
{
|
||||
accessorKey: "cpf_cnpj",
|
||||
accessorKey: 'cpf_cnpj',
|
||||
header: ({ column }) => (
|
||||
<Button
|
||||
variant="ghost"
|
||||
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")}
|
||||
onClick={() => column.toggleSorting(column.getIsSorted() === 'asc')}
|
||||
>
|
||||
CPF <ArrowUpDownIcon className="ml-1 h-4 w-4 cursor-pointer" />
|
||||
</Button>
|
||||
),
|
||||
cell: ({ row }) => FormatCPF(row.getValue("cpf_cnpj")),
|
||||
cell: ({ row }) => FormatCPF(row.getValue('cpf_cnpj')),
|
||||
},
|
||||
|
||||
// Telefone
|
||||
{
|
||||
accessorKey: "telefone",
|
||||
accessorKey: 'telefone',
|
||||
header: ({ column }) => (
|
||||
<Button
|
||||
variant="ghost"
|
||||
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")}
|
||||
onClick={() => column.toggleSorting(column.getIsSorted() === 'asc')}
|
||||
>
|
||||
Telefone <ArrowUpDownIcon className="ml-1 h-4 w-4 cursor-pointer" />
|
||||
</Button>
|
||||
),
|
||||
cell: ({ row }) => FormatPhone(row.getValue("telefone")),
|
||||
cell: ({ row }) => FormatPhone(row.getValue('telefone')),
|
||||
},
|
||||
|
||||
// Ações
|
||||
{
|
||||
id: "actions",
|
||||
header: "Ações",
|
||||
id: 'actions',
|
||||
header: 'Ações',
|
||||
cell: ({ row }) => {
|
||||
const pessoa = row.original;
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
"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 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 { Button } from '@/components/ui/button';
|
||||
import { Checkbox } from '@/components/ui/checkbox';
|
||||
import {
|
||||
Dialog,
|
||||
DialogClose,
|
||||
|
|
@ -15,7 +15,7 @@ import {
|
|||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from "@/components/ui/dialog";
|
||||
} from '@/components/ui/dialog';
|
||||
import {
|
||||
Form,
|
||||
FormControl,
|
||||
|
|
@ -23,19 +23,19 @@ import {
|
|||
FormItem,
|
||||
FormLabel,
|
||||
FormMessage,
|
||||
} from "@/components/ui/form";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
} 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";
|
||||
} from '@/components/ui/select';
|
||||
|
||||
import { TTBAndamentoServicoSchema } from "../../_schemas/TTBAndamentoServicoSchema";
|
||||
import { tipoEnum } from "../../_interfaces/TTBAndamentoServicoInterface";
|
||||
import { TTBAndamentoServicoSchema } from '../../_schemas/TTBAndamentoServicoSchema';
|
||||
import { tipoEnum } from '../../_interfaces/TTBAndamentoServicoInterface';
|
||||
|
||||
type FormValues = z.infer<typeof TTBAndamentoServicoSchema>;
|
||||
|
||||
|
|
@ -46,20 +46,15 @@ interface Props {
|
|||
onSave: (data: FormValues) => void;
|
||||
}
|
||||
|
||||
export default function TTBAndamentoServicoForm({
|
||||
isOpen,
|
||||
data,
|
||||
onClose,
|
||||
onSave,
|
||||
}: Props) {
|
||||
export default function TTBAndamentoServicoForm({ isOpen, data, onClose, onSave }: Props) {
|
||||
// Inicializa o react-hook-form com schema zod
|
||||
const form = useForm<FormValues>({
|
||||
resolver: zodResolver(TTBAndamentoServicoSchema),
|
||||
defaultValues: {
|
||||
descricao: "",
|
||||
descricao: '',
|
||||
tipo: tipoEnum.OUTROS,
|
||||
situacao: "A",
|
||||
usa_email: "I",
|
||||
situacao: 'A',
|
||||
usa_email: 'I',
|
||||
tb_andamentoservico_id: 0,
|
||||
},
|
||||
});
|
||||
|
|
@ -68,17 +63,17 @@ export default function TTBAndamentoServicoForm({
|
|||
const tipoOptions = Object.values(tipoEnum).map((value) => ({
|
||||
value,
|
||||
label:
|
||||
value === "C"
|
||||
? "Cancelado"
|
||||
: value === "E"
|
||||
? "Estornado"
|
||||
: value === "PT"
|
||||
? "Protocolado"
|
||||
: value === "PD"
|
||||
? "Pedido"
|
||||
: value === "NC"
|
||||
? "Não Consta"
|
||||
: "Outros",
|
||||
value === 'C'
|
||||
? 'Cancelado'
|
||||
: value === 'E'
|
||||
? 'Estornado'
|
||||
: value === 'PT'
|
||||
? 'Protocolado'
|
||||
: value === 'PD'
|
||||
? 'Pedido'
|
||||
: value === 'NC'
|
||||
? 'Não Consta'
|
||||
: 'Outros',
|
||||
}));
|
||||
|
||||
// Atualiza o formulário quando recebe dados para edição
|
||||
|
|
@ -149,10 +144,8 @@ export default function TTBAndamentoServicoForm({
|
|||
render={({ field }) => (
|
||||
<div className="flex items-center space-x-2">
|
||||
<Checkbox
|
||||
checked={field.value === "A"}
|
||||
onCheckedChange={(checked) =>
|
||||
field.onChange(checked ? "A" : "I")
|
||||
}
|
||||
checked={field.value === 'A'}
|
||||
onCheckedChange={(checked) => field.onChange(checked ? 'A' : 'I')}
|
||||
/>
|
||||
<Label>Ativo</Label>
|
||||
</div>
|
||||
|
|
@ -166,10 +159,8 @@ export default function TTBAndamentoServicoForm({
|
|||
render={({ field }) => (
|
||||
<div className="flex items-center space-x-2">
|
||||
<Checkbox
|
||||
checked={field.value === "A"}
|
||||
onCheckedChange={(checked) =>
|
||||
field.onChange(checked ? "A" : "I")
|
||||
}
|
||||
checked={field.value === 'A'}
|
||||
onCheckedChange={(checked) => field.onChange(checked ? 'A' : 'I')}
|
||||
/>
|
||||
<Label>Usar e-mail</Label>
|
||||
</div>
|
||||
|
|
@ -194,7 +185,7 @@ export default function TTBAndamentoServicoForm({
|
|||
</DialogFooter>
|
||||
|
||||
{/* Campo oculto */}
|
||||
<input type="hidden" {...form.register("tb_andamentoservico_id")} />
|
||||
<input type="hidden" {...form.register('tb_andamentoservico_id')} />
|
||||
</form>
|
||||
</Form>
|
||||
</DialogContent>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
"use client";
|
||||
'use client';
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
|
|
@ -8,7 +8,7 @@ import {
|
|||
DropdownMenuItem,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger,
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
} from '@/components/ui/dropdown-menu';
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
|
|
@ -16,42 +16,32 @@ import {
|
|||
TableHead,
|
||||
TableHeader,
|
||||
TableRow,
|
||||
} from "@/components/ui/table";
|
||||
} from '@/components/ui/table';
|
||||
|
||||
import { EllipsisIcon, PencilIcon, Trash2Icon } from "lucide-react";
|
||||
import TTBAndamentoServicoInteface from "../../_interfaces/TTBAndamentoServicoInterface";
|
||||
import { EllipsisIcon, PencilIcon, Trash2Icon } from 'lucide-react';
|
||||
import TTBAndamentoServicoInteface from '../../_interfaces/TTBAndamentoServicoInterface';
|
||||
|
||||
interface TTBAndamentoServicoTableProps {
|
||||
data: TTBAndamentoServicoInteface[];
|
||||
onEdit: (
|
||||
item: TTBAndamentoServicoInteface,
|
||||
isEditingFormStatus: boolean,
|
||||
) => void;
|
||||
onDelete: (
|
||||
item: TTBAndamentoServicoInteface,
|
||||
isEditingFormStatus: boolean,
|
||||
) => void;
|
||||
onEdit: (item: TTBAndamentoServicoInteface, isEditingFormStatus: boolean) => void;
|
||||
onDelete: (item: TTBAndamentoServicoInteface, isEditingFormStatus: boolean) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renderiza o badge de situação
|
||||
*/
|
||||
function StatusBadge({ situacao }: { situacao: string }) {
|
||||
const isActive = situacao === "A";
|
||||
const isActive = situacao === 'A';
|
||||
|
||||
const baseClasses = "text-xs font-medium px-2.5 py-0.5 rounded-sm me-2";
|
||||
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 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";
|
||||
const inactiveClasses = 'bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300';
|
||||
|
||||
return (
|
||||
<span
|
||||
className={`${baseClasses} ${isActive ? activeClasses : inactiveClasses}`}
|
||||
>
|
||||
{isActive ? "Ativo" : "Inativo"}
|
||||
<span className={`${baseClasses} ${isActive ? activeClasses : inactiveClasses}`}>
|
||||
{isActive ? 'Ativo' : 'Inativo'}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
|
@ -74,13 +64,8 @@ export default function TTBAndamentoServicoTable({
|
|||
|
||||
<TableBody>
|
||||
{data.map((item) => (
|
||||
<TableRow
|
||||
key={item.tb_andamentoservico_id}
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<TableCell className="font-medium">
|
||||
{item.tb_andamentoservico_id}
|
||||
</TableCell>
|
||||
<TableRow key={item.tb_andamentoservico_id} className="cursor-pointer">
|
||||
<TableCell className="font-medium">{item.tb_andamentoservico_id}</TableCell>
|
||||
|
||||
<TableCell>
|
||||
<StatusBadge situacao={item.situacao} />
|
||||
|
|
@ -91,11 +76,7 @@ export default function TTBAndamentoServicoTable({
|
|||
<TableCell className="text-right">
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<Button variant="outline" size="icon" className="cursor-pointer">
|
||||
<EllipsisIcon />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
"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 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 { Button } from '@/components/ui/button';
|
||||
import { Checkbox } from '@/components/ui/checkbox';
|
||||
import {
|
||||
Dialog,
|
||||
DialogClose,
|
||||
|
|
@ -15,7 +15,7 @@ import {
|
|||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from "@/components/ui/dialog";
|
||||
} from '@/components/ui/dialog';
|
||||
import {
|
||||
Form,
|
||||
FormControl,
|
||||
|
|
@ -23,12 +23,12 @@ import {
|
|||
FormItem,
|
||||
FormLabel,
|
||||
FormMessage,
|
||||
} from "@/components/ui/form";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
} from '@/components/ui/form';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Label } from '@/components/ui/label';
|
||||
|
||||
import { TTBReconhecimentoTipoSchema } from "../../_schemas/TTBReconhecimentoTipoSchema";
|
||||
import { situacaoEnum } from "../../_interfaces/TTBReconhecimentoTipoInterface";
|
||||
import { TTBReconhecimentoTipoSchema } from '../../_schemas/TTBReconhecimentoTipoSchema';
|
||||
import { situacaoEnum } from '../../_interfaces/TTBReconhecimentoTipoInterface';
|
||||
|
||||
type FormValues = z.infer<typeof TTBReconhecimentoTipoSchema>;
|
||||
|
||||
|
|
@ -50,7 +50,7 @@ export default function TTBReconhecimentoTipoForm({
|
|||
resolver: zodResolver(TTBReconhecimentoTipoSchema),
|
||||
defaultValues: {
|
||||
tb_reconhecimentotipo_id: 0,
|
||||
descricao: "",
|
||||
descricao: '',
|
||||
situacao: situacaoEnum.ATIVO,
|
||||
},
|
||||
});
|
||||
|
|
@ -97,10 +97,8 @@ export default function TTBReconhecimentoTipoForm({
|
|||
render={({ field }) => (
|
||||
<div className="flex items-center space-x-2">
|
||||
<Checkbox
|
||||
checked={field.value === "A"}
|
||||
onCheckedChange={(checked) =>
|
||||
field.onChange(checked ? "A" : "I")
|
||||
}
|
||||
checked={field.value === 'A'}
|
||||
onCheckedChange={(checked) => field.onChange(checked ? 'A' : 'I')}
|
||||
/>
|
||||
<Label>Ativo</Label>
|
||||
</div>
|
||||
|
|
@ -125,10 +123,7 @@ export default function TTBReconhecimentoTipoForm({
|
|||
</DialogFooter>
|
||||
|
||||
{/* Campo oculto */}
|
||||
<input
|
||||
type="hidden"
|
||||
{...form.register("tb_reconhecimentotipo_id")}
|
||||
/>
|
||||
<input type="hidden" {...form.register('tb_reconhecimentotipo_id')} />
|
||||
</form>
|
||||
</Form>
|
||||
</DialogContent>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
"use client";
|
||||
'use client';
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
|
|
@ -8,7 +8,7 @@ import {
|
|||
DropdownMenuItem,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger,
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
} from '@/components/ui/dropdown-menu';
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
|
|
@ -16,42 +16,32 @@ import {
|
|||
TableHead,
|
||||
TableHeader,
|
||||
TableRow,
|
||||
} from "@/components/ui/table";
|
||||
} from '@/components/ui/table';
|
||||
|
||||
import { EllipsisIcon, PencilIcon, Trash2Icon } from "lucide-react";
|
||||
import TTBReconhecimentoTipoInterface from "../../_interfaces/TTBReconhecimentoTipoInterface";
|
||||
import { EllipsisIcon, PencilIcon, Trash2Icon } from 'lucide-react';
|
||||
import TTBReconhecimentoTipoInterface from '../../_interfaces/TTBReconhecimentoTipoInterface';
|
||||
|
||||
interface TTBReconhecimentoTipoTableProps {
|
||||
data: TTBReconhecimentoTipoInterface[];
|
||||
onEdit: (
|
||||
item: TTBReconhecimentoTipoInterface,
|
||||
isEditingFormStatus: boolean,
|
||||
) => void;
|
||||
onDelete: (
|
||||
item: TTBReconhecimentoTipoInterface,
|
||||
isEditingFormStatus: boolean,
|
||||
) => void;
|
||||
onEdit: (item: TTBReconhecimentoTipoInterface, isEditingFormStatus: boolean) => void;
|
||||
onDelete: (item: TTBReconhecimentoTipoInterface, isEditingFormStatus: boolean) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renderiza o badge de situação
|
||||
*/
|
||||
function StatusBadge({ situacao }: { situacao: string }) {
|
||||
const isActive = situacao === "A";
|
||||
const isActive = situacao === 'A';
|
||||
|
||||
const baseClasses = "text-xs font-medium px-2.5 py-0.5 rounded-sm me-2";
|
||||
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 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";
|
||||
const inactiveClasses = 'bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300';
|
||||
|
||||
return (
|
||||
<span
|
||||
className={`${baseClasses} ${isActive ? activeClasses : inactiveClasses}`}
|
||||
>
|
||||
{isActive ? "Ativo" : "Inativo"}
|
||||
<span className={`${baseClasses} ${isActive ? activeClasses : inactiveClasses}`}>
|
||||
{isActive ? 'Ativo' : 'Inativo'}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
|
@ -74,13 +64,8 @@ export default function TTBReconhecimentoTipoTable({
|
|||
|
||||
<TableBody>
|
||||
{data.map((item) => (
|
||||
<TableRow
|
||||
key={item.tb_reconhecimentotipo_id}
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<TableCell className="font-medium">
|
||||
{item.tb_reconhecimentotipo_id}
|
||||
</TableCell>
|
||||
<TableRow key={item.tb_reconhecimentotipo_id} className="cursor-pointer">
|
||||
<TableCell className="font-medium">{item.tb_reconhecimentotipo_id}</TableCell>
|
||||
|
||||
<TableCell>
|
||||
<StatusBadge situacao={item.situacao} />
|
||||
|
|
@ -91,11 +76,7 @@ export default function TTBReconhecimentoTipoTable({
|
|||
<TableCell className="text-right">
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<Button variant="outline" size="icon" className="cursor-pointer">
|
||||
<EllipsisIcon />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
|
|
|
|||
|
|
@ -1,78 +1,78 @@
|
|||
import API from "@/services/api/Api";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
import API from '@/services/api/Api';
|
||||
import { Methods } from '@/services/api/enums/ApiMethodEnum';
|
||||
|
||||
export default async function GCidadeIndexData() {
|
||||
return Promise.resolve({
|
||||
status: 200,
|
||||
message: "Dados localizados",
|
||||
message: 'Dados localizados',
|
||||
data: [
|
||||
{
|
||||
cidade_id: 1,
|
||||
uf: "AC",
|
||||
cidade_nome: "Acrelândia",
|
||||
uf: 'AC',
|
||||
cidade_nome: 'Acrelândia',
|
||||
codigo_ibge: null,
|
||||
codigo_gyn: null,
|
||||
},
|
||||
{
|
||||
cidade_id: 2,
|
||||
uf: "AC",
|
||||
cidade_nome: "Assis Brasil",
|
||||
uf: 'AC',
|
||||
cidade_nome: 'Assis Brasil',
|
||||
codigo_ibge: null,
|
||||
codigo_gyn: null,
|
||||
},
|
||||
{
|
||||
cidade_id: 3,
|
||||
uf: "AC",
|
||||
cidade_nome: "Brasiléia",
|
||||
uf: 'AC',
|
||||
cidade_nome: 'Brasiléia',
|
||||
codigo_ibge: null,
|
||||
codigo_gyn: null,
|
||||
},
|
||||
{
|
||||
cidade_id: 4,
|
||||
uf: "AC",
|
||||
cidade_nome: "Bujari",
|
||||
uf: 'AC',
|
||||
cidade_nome: 'Bujari',
|
||||
codigo_ibge: null,
|
||||
codigo_gyn: null,
|
||||
},
|
||||
{
|
||||
cidade_id: 5,
|
||||
uf: "AC",
|
||||
cidade_nome: "Capixaba",
|
||||
uf: 'AC',
|
||||
cidade_nome: 'Capixaba',
|
||||
codigo_ibge: null,
|
||||
codigo_gyn: null,
|
||||
},
|
||||
{
|
||||
cidade_id: 6,
|
||||
uf: "AC",
|
||||
cidade_nome: "Cruzeiro do Sul",
|
||||
uf: 'AC',
|
||||
cidade_nome: 'Cruzeiro do Sul',
|
||||
codigo_ibge: null,
|
||||
codigo_gyn: null,
|
||||
},
|
||||
{
|
||||
cidade_id: 7,
|
||||
uf: "AC",
|
||||
cidade_nome: "Epitaciolândia",
|
||||
uf: 'AC',
|
||||
cidade_nome: 'Epitaciolândia',
|
||||
codigo_ibge: null,
|
||||
codigo_gyn: null,
|
||||
},
|
||||
{
|
||||
cidade_id: 8,
|
||||
uf: "AC",
|
||||
cidade_nome: "Feijó",
|
||||
uf: 'AC',
|
||||
cidade_nome: 'Feijó',
|
||||
codigo_ibge: null,
|
||||
codigo_gyn: null,
|
||||
},
|
||||
{
|
||||
cidade_id: 9,
|
||||
uf: "AC",
|
||||
cidade_nome: "Jordão",
|
||||
uf: 'AC',
|
||||
cidade_nome: 'Jordão',
|
||||
codigo_ibge: null,
|
||||
codigo_gyn: null,
|
||||
},
|
||||
{
|
||||
cidade_id: 10,
|
||||
uf: "AC",
|
||||
cidade_nome: "Mâncio Lima",
|
||||
uf: 'AC',
|
||||
cidade_nome: 'Mâncio Lima',
|
||||
codigo_ibge: null,
|
||||
codigo_gyn: null,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
import API from "@/services/api/Api";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
import GCidadeInterface from "../../_interfaces/GCidadeInterface";
|
||||
import API from '@/services/api/Api';
|
||||
import { Methods } from '@/services/api/enums/ApiMethodEnum';
|
||||
import GCidadeInterface from '../../_interfaces/GCidadeInterface';
|
||||
|
||||
export default async function GCidadeRemoveData(data: GCidadeInterface) {
|
||||
return Promise.resolve({
|
||||
status: 200,
|
||||
message: "Dados removidos",
|
||||
message: 'Dados removidos',
|
||||
data: null,
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
// Importa o serviço de API que será utilizado para realizar requisições HTTP
|
||||
import API from "@/services/api/Api";
|
||||
import API from '@/services/api/Api';
|
||||
|
||||
// Importa o enum que contém os métodos HTTP disponíveis (GET, POST, PUT, DELETE)
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
import { Methods } from '@/services/api/enums/ApiMethodEnum';
|
||||
|
||||
// Importa a interface tipada que define a estrutura dos dados de uma cidade
|
||||
import GCidadeInterface from "../../_interfaces/GCidadeInterface";
|
||||
import GCidadeInterface from '../../_interfaces/GCidadeInterface';
|
||||
|
||||
// Importa função que encapsula chamadas assíncronas e trata erros automaticamente
|
||||
import { withClientErrorHandler } from "@/actions/withClientErrorHandler/withClientErrorHandler";
|
||||
import { withClientErrorHandler } from '@/actions/withClientErrorHandler/withClientErrorHandler';
|
||||
|
||||
// Função assíncrona que implementa a lógica de salvar (criar/atualizar) uma cidade
|
||||
async function executeGcidadeSaveData(data: GCidadeInterface) {
|
||||
|
|
@ -21,7 +21,7 @@ async function executeGcidadeSaveData(data: GCidadeInterface) {
|
|||
// Executa a requisição para a API com o método apropriado e envia os dados no corpo
|
||||
return await api.send({
|
||||
method: isUpdate ? Methods.PUT : Methods.POST, // PUT se atualizar, POST se criar
|
||||
endpoint: `administrativo/g_cidade/${data.cidade_id || ""}`, // endpoint dinâmico
|
||||
endpoint: `administrativo/g_cidade/${data.cidade_id || ''}`, // endpoint dinâmico
|
||||
body: data, // payload enviado para a API
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { withClientErrorHandler } from "@/actions/withClientErrorHandler/withClientErrorHandler";
|
||||
import API from "@/services/api/Api";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
import { withClientErrorHandler } from '@/actions/withClientErrorHandler/withClientErrorHandler';
|
||||
import API from '@/services/api/Api';
|
||||
import { Methods } from '@/services/api/enums/ApiMethodEnum';
|
||||
|
||||
async function executeGMedidaTipoIndexData() {
|
||||
const api = new API();
|
||||
|
|
@ -10,6 +10,4 @@ async function executeGMedidaTipoIndexData() {
|
|||
});
|
||||
}
|
||||
|
||||
export const GMedidaTipoIndexData = withClientErrorHandler(
|
||||
executeGMedidaTipoIndexData,
|
||||
);
|
||||
export const GMedidaTipoIndexData = withClientErrorHandler(executeGMedidaTipoIndexData);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import API from "@/services/api/Api";
|
||||
import { GMedidaTipoInterface } from "../../_interfaces/GMedidaTipoInterface";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
import { withClientErrorHandler } from "@/actions/withClientErrorHandler/withClientErrorHandler";
|
||||
import API from '@/services/api/Api';
|
||||
import { GMedidaTipoInterface } from '../../_interfaces/GMedidaTipoInterface';
|
||||
import { Methods } from '@/services/api/enums/ApiMethodEnum';
|
||||
import { withClientErrorHandler } from '@/actions/withClientErrorHandler/withClientErrorHandler';
|
||||
|
||||
async function executeGMedidaTipoRemoveData(data: GMedidaTipoInterface) {
|
||||
const api = new API();
|
||||
|
|
@ -12,6 +12,4 @@ async function executeGMedidaTipoRemoveData(data: GMedidaTipoInterface) {
|
|||
});
|
||||
}
|
||||
|
||||
export const GMedidaTipoRemoveData = withClientErrorHandler(
|
||||
executeGMedidaTipoRemoveData,
|
||||
);
|
||||
export const GMedidaTipoRemoveData = withClientErrorHandler(executeGMedidaTipoRemoveData);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import API from "@/services/api/Api";
|
||||
import { GMedidaTipoInterface } from "../../_interfaces/GMedidaTipoInterface";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
import { withClientErrorHandler } from "@/actions/withClientErrorHandler/withClientErrorHandler";
|
||||
import API from '@/services/api/Api';
|
||||
import { GMedidaTipoInterface } from '../../_interfaces/GMedidaTipoInterface';
|
||||
import { Methods } from '@/services/api/enums/ApiMethodEnum';
|
||||
import { withClientErrorHandler } from '@/actions/withClientErrorHandler/withClientErrorHandler';
|
||||
|
||||
async function executeGMedidaTipoSaveData(data: GMedidaTipoInterface) {
|
||||
const isUpdate = Boolean(data.medida_tipo_id);
|
||||
|
|
@ -10,11 +10,9 @@ async function executeGMedidaTipoSaveData(data: GMedidaTipoInterface) {
|
|||
|
||||
return await api.send({
|
||||
method: isUpdate ? Methods.PUT : Methods.POST,
|
||||
endpoint: `administrativo/g_medida_tipo/${data.medida_tipo_id || ""}`,
|
||||
endpoint: `administrativo/g_medida_tipo/${data.medida_tipo_id || ''}`,
|
||||
body: data,
|
||||
});
|
||||
}
|
||||
|
||||
export const GMedidaTipoSaveData = withClientErrorHandler(
|
||||
executeGMedidaTipoSaveData,
|
||||
);
|
||||
export const GMedidaTipoSaveData = withClientErrorHandler(executeGMedidaTipoSaveData);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { withClientErrorHandler } from "@/actions/withClientErrorHandler/withClientErrorHandler";
|
||||
import API from "@/services/api/Api";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
import { withClientErrorHandler } from '@/actions/withClientErrorHandler/withClientErrorHandler';
|
||||
import API from '@/services/api/Api';
|
||||
import { Methods } from '@/services/api/enums/ApiMethodEnum';
|
||||
|
||||
async function executeGTBBairroIndexData() {
|
||||
const api = new API();
|
||||
|
|
@ -13,6 +13,4 @@ async function executeGTBBairroIndexData() {
|
|||
return dados;
|
||||
}
|
||||
|
||||
export const GTBBairroIndexData = withClientErrorHandler(
|
||||
executeGTBBairroIndexData,
|
||||
);
|
||||
export const GTBBairroIndexData = withClientErrorHandler(executeGTBBairroIndexData);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import API from "@/services/api/Api";
|
||||
import { GTBBairroInterface } from "../../_interfaces/GTBBairroInterface";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
import { withClientErrorHandler } from "@/actions/withClientErrorHandler/withClientErrorHandler";
|
||||
import API from '@/services/api/Api';
|
||||
import { GTBBairroInterface } from '../../_interfaces/GTBBairroInterface';
|
||||
import { Methods } from '@/services/api/enums/ApiMethodEnum';
|
||||
import { withClientErrorHandler } from '@/actions/withClientErrorHandler/withClientErrorHandler';
|
||||
|
||||
async function executeGTBBairroRemoveData(data: GTBBairroInterface) {
|
||||
const api = new API();
|
||||
|
|
@ -12,6 +12,4 @@ async function executeGTBBairroRemoveData(data: GTBBairroInterface) {
|
|||
});
|
||||
}
|
||||
|
||||
export const GTBBairroRemoveData = withClientErrorHandler(
|
||||
executeGTBBairroRemoveData,
|
||||
);
|
||||
export const GTBBairroRemoveData = withClientErrorHandler(executeGTBBairroRemoveData);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import API from "@/services/api/Api";
|
||||
import { GTBBairroInterface } from "../../_interfaces/GTBBairroInterface";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
import { withClientErrorHandler } from "@/actions/withClientErrorHandler/withClientErrorHandler";
|
||||
import API from '@/services/api/Api';
|
||||
import { GTBBairroInterface } from '../../_interfaces/GTBBairroInterface';
|
||||
import { Methods } from '@/services/api/enums/ApiMethodEnum';
|
||||
import { withClientErrorHandler } from '@/actions/withClientErrorHandler/withClientErrorHandler';
|
||||
|
||||
async function executeGTBBairroSaveData(data: GTBBairroInterface) {
|
||||
const isUpdate = Boolean(data.tb_bairro_id);
|
||||
|
|
@ -10,11 +10,9 @@ async function executeGTBBairroSaveData(data: GTBBairroInterface) {
|
|||
|
||||
return await api.send({
|
||||
method: isUpdate ? Methods.PUT : Methods.POST,
|
||||
endpoint: `administrativo/g_tb_bairro/${data.tb_bairro_id || ""}`,
|
||||
endpoint: `administrativo/g_tb_bairro/${data.tb_bairro_id || ''}`,
|
||||
body: data,
|
||||
});
|
||||
}
|
||||
|
||||
export const GTBBairroSaveData = withClientErrorHandler(
|
||||
executeGTBBairroSaveData,
|
||||
);
|
||||
export const GTBBairroSaveData = withClientErrorHandler(executeGTBBairroSaveData);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { withClientErrorHandler } from "@/actions/withClientErrorHandler/withClientErrorHandler";
|
||||
import API from "@/services/api/Api";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
import { withClientErrorHandler } from '@/actions/withClientErrorHandler/withClientErrorHandler';
|
||||
import API from '@/services/api/Api';
|
||||
import { Methods } from '@/services/api/enums/ApiMethodEnum';
|
||||
|
||||
async function executeGTBEstadoCivilIndexData() {
|
||||
const api = new API();
|
||||
|
|
@ -11,6 +11,4 @@ async function executeGTBEstadoCivilIndexData() {
|
|||
});
|
||||
}
|
||||
|
||||
export const GTBEstadoCivilIndexData = withClientErrorHandler(
|
||||
executeGTBEstadoCivilIndexData,
|
||||
);
|
||||
export const GTBEstadoCivilIndexData = withClientErrorHandler(executeGTBEstadoCivilIndexData);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import API from "@/services/api/Api";
|
||||
import { GTBEstadoCivilInterface } from "../../_interfaces/GTBEstadoCivilInterface";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
import { withClientErrorHandler } from "@/actions/withClientErrorHandler/withClientErrorHandler";
|
||||
import API from '@/services/api/Api';
|
||||
import { GTBEstadoCivilInterface } from '../../_interfaces/GTBEstadoCivilInterface';
|
||||
import { Methods } from '@/services/api/enums/ApiMethodEnum';
|
||||
import { withClientErrorHandler } from '@/actions/withClientErrorHandler/withClientErrorHandler';
|
||||
|
||||
async function executeGTBEstadoCivilRemoveData(data: GTBEstadoCivilInterface) {
|
||||
const api = new API();
|
||||
|
|
@ -12,6 +12,4 @@ async function executeGTBEstadoCivilRemoveData(data: GTBEstadoCivilInterface) {
|
|||
});
|
||||
}
|
||||
|
||||
export const GTBEstadoCivilRemoveData = withClientErrorHandler(
|
||||
executeGTBEstadoCivilRemoveData,
|
||||
);
|
||||
export const GTBEstadoCivilRemoveData = withClientErrorHandler(executeGTBEstadoCivilRemoveData);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import API from "@/services/api/Api";
|
||||
import { GTBEstadoCivilInterface } from "../../_interfaces/GTBEstadoCivilInterface";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
import { withClientErrorHandler } from "@/actions/withClientErrorHandler/withClientErrorHandler";
|
||||
import API from '@/services/api/Api';
|
||||
import { GTBEstadoCivilInterface } from '../../_interfaces/GTBEstadoCivilInterface';
|
||||
import { Methods } from '@/services/api/enums/ApiMethodEnum';
|
||||
import { withClientErrorHandler } from '@/actions/withClientErrorHandler/withClientErrorHandler';
|
||||
|
||||
async function executeGTBEstadoCivilSaveData(data: GTBEstadoCivilInterface) {
|
||||
const isUpdate = Boolean(data.tb_estadocivil_id);
|
||||
|
|
@ -10,11 +10,9 @@ async function executeGTBEstadoCivilSaveData(data: GTBEstadoCivilInterface) {
|
|||
|
||||
return await api.send({
|
||||
method: isUpdate ? Methods.PUT : Methods.POST,
|
||||
endpoint: `administrativo/g_tb_bairro/${data.tb_estadocivil_id || ""}`,
|
||||
endpoint: `administrativo/g_tb_bairro/${data.tb_estadocivil_id || ''}`,
|
||||
body: data,
|
||||
});
|
||||
}
|
||||
|
||||
export const GTBEstadoCivilSaveData = withClientErrorHandler(
|
||||
executeGTBEstadoCivilSaveData,
|
||||
);
|
||||
export const GTBEstadoCivilSaveData = withClientErrorHandler(executeGTBEstadoCivilSaveData);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import API from "@/services/api/Api";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
import API from '@/services/api/Api';
|
||||
import { Methods } from '@/services/api/enums/ApiMethodEnum';
|
||||
|
||||
export default async function GTBProfissoesIndexData() {
|
||||
const api = new API();
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue