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 next from 'eslint-config-next';
|
||||||
import importPlugin from "eslint-plugin-import";
|
import importPlugin from 'eslint-plugin-import';
|
||||||
|
|
||||||
export default [
|
export default [
|
||||||
next,
|
next,
|
||||||
|
|
@ -8,21 +8,16 @@ export default [
|
||||||
import: importPlugin,
|
import: importPlugin,
|
||||||
},
|
},
|
||||||
rules: {
|
rules: {
|
||||||
"import/order": [
|
'import/order': [
|
||||||
"error",
|
'error',
|
||||||
{
|
{
|
||||||
groups: [
|
groups: ['builtin', 'external', 'internal', ['parent', 'sibling', 'index']],
|
||||||
"builtin",
|
'newlines-between': 'always',
|
||||||
"external",
|
alphabetize: { order: 'asc', caseInsensitive: true },
|
||||||
"internal",
|
|
||||||
["parent", "sibling", "index"],
|
|
||||||
],
|
|
||||||
"newlines-between": "always",
|
|
||||||
alphabetize: { order: "asc", caseInsensitive: true },
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
semi: ["error", "always"],
|
semi: ['error', 'always'],
|
||||||
quotes: ["error", "double"],
|
quotes: ['error', 'double'],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
import type { NextConfig } from "next";
|
import type { NextConfig } from 'next';
|
||||||
|
|
||||||
const nextConfig: NextConfig = {
|
const nextConfig: NextConfig = {
|
||||||
// Isso gera um diretório otimizado que inclui tudo o que a aplicação precisa para rodar
|
// Isso gera um diretório otimizado que inclui tudo o que a aplicação precisa para rodar
|
||||||
output: "standalone",
|
output: 'standalone',
|
||||||
};
|
};
|
||||||
|
|
||||||
export default nextConfig;
|
export default nextConfig;
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,9 @@
|
||||||
"dev": "next dev --turbopack",
|
"dev": "next dev --turbopack",
|
||||||
"build": "next build",
|
"build": "next build",
|
||||||
"start": "next start",
|
"start": "next start",
|
||||||
"lint": "next lint"
|
"lint": "next lint",
|
||||||
|
"lint:fix": "npm run lint -- --fix",
|
||||||
|
"format": "prettier --write . --ignore-path .gitignore"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@faker-js/faker": "^10.0.0",
|
"@faker-js/faker": "^10.0.0",
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
const config = {
|
const config = {
|
||||||
plugins: ["@tailwindcss/postcss"],
|
plugins: ['@tailwindcss/postcss'],
|
||||||
};
|
};
|
||||||
|
|
||||||
export default config;
|
export default config;
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,10 @@
|
||||||
* @returns CNPJ formatado ou string parcial se incompleto
|
* @returns CNPJ formatado ou string parcial se incompleto
|
||||||
*/
|
*/
|
||||||
export function FormatCNPJ(value: string | number): string {
|
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
|
// 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
|
// Garante que tenha no máximo 14 dígitos
|
||||||
const cleanValue = digits.slice(0, 14);
|
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
|
// Retorna parcialmente formatado se ainda não tiver 14 dígitos
|
||||||
if (cleanValue.length < 14) return cleanValue;
|
if (cleanValue.length < 14) return cleanValue;
|
||||||
|
|
||||||
return cleanValue.replace(
|
return cleanValue.replace(/(\d{2})(\d{3})(\d{3})(\d{4})(\d{2})/, '$1.$2.$3/$4-$5');
|
||||||
/(\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
|
* @returns CPF formatado ou string vazia se inválido
|
||||||
*/
|
*/
|
||||||
export function FormatCPF(value: string | number): string {
|
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
|
// 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
|
// Garante que tenha no máximo 11 dígitos
|
||||||
const cleanValue = digits.slice(0, 11);
|
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
|
// Retorna formatado ou vazio se não tiver tamanho suficiente
|
||||||
if (cleanValue.length !== 11) return cleanValue;
|
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
|
* 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
|
* @param value - Data ou hora em string, Date ou timestamp
|
||||||
* @returns Data formatada no padrão DD/MM/YYYY HH:mm ou parcial
|
* @returns Data formatada no padrão DD/MM/YYYY HH:mm ou parcial
|
||||||
*/
|
*/
|
||||||
export function FormatDateTime(
|
export function FormatDateTime(value: string | Date | number | null | undefined): string {
|
||||||
value: string | Date | number | null | undefined,
|
if (!value) return '-';
|
||||||
): string {
|
|
||||||
if (!value) return "-";
|
|
||||||
|
|
||||||
let date: Date;
|
let date: Date;
|
||||||
|
|
||||||
// Converte entrada para Date
|
// Converte entrada para Date
|
||||||
if (value instanceof Date) {
|
if (value instanceof Date) {
|
||||||
date = value;
|
date = value;
|
||||||
} else if (typeof value === "number") {
|
} else if (typeof value === 'number') {
|
||||||
date = new Date(value);
|
date = new Date(value);
|
||||||
} else if (typeof value === "string") {
|
} else if (typeof value === 'string') {
|
||||||
// Remove caracteres extras e tenta criar Date
|
// 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) {
|
if (cleanValue.length === 8) {
|
||||||
// DDMMYYYY
|
// DDMMYYYY
|
||||||
|
|
@ -34,22 +32,22 @@ export function FormatDateTime(
|
||||||
} else {
|
} else {
|
||||||
// Tenta parse padrão
|
// Tenta parse padrão
|
||||||
const parsed = new Date(value);
|
const parsed = new Date(value);
|
||||||
if (isNaN(parsed.getTime())) return "-";
|
if (isNaN(parsed.getTime())) return '-';
|
||||||
date = parsed;
|
date = parsed;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return "-";
|
return '-';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extrai partes da data
|
// Extrai partes da data
|
||||||
const day = date.getDate().toString().padStart(2, "0");
|
const day = date.getDate().toString().padStart(2, '0');
|
||||||
const month = (date.getMonth() + 1).toString().padStart(2, "0");
|
const month = (date.getMonth() + 1).toString().padStart(2, '0');
|
||||||
const year = date.getFullYear();
|
const year = date.getFullYear();
|
||||||
const hours = date.getHours().toString().padStart(2, "0");
|
const hours = date.getHours().toString().padStart(2, '0');
|
||||||
const minutes = date.getMinutes().toString().padStart(2, "0");
|
const minutes = date.getMinutes().toString().padStart(2, '0');
|
||||||
|
|
||||||
// Monta string parcialmente, dependendo da hora estar disponível
|
// 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 {
|
export default class Json {
|
||||||
static execute() {
|
static execute() {
|
||||||
return appConfig;
|
return appConfig;
|
||||||
|
|
|
||||||
|
|
@ -10,13 +10,13 @@
|
||||||
* @returns Telefone formatado ou "-" se vazio
|
* @returns Telefone formatado ou "-" se vazio
|
||||||
*/
|
*/
|
||||||
export function FormatPhone(value: string | number): string {
|
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
|
// 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 "-"
|
// 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
|
// Garante no máximo 11 dígitos
|
||||||
const cleanValue = digits.slice(0, 11);
|
const cleanValue = digits.slice(0, 11);
|
||||||
|
|
@ -26,7 +26,7 @@ export function FormatPhone(value: string | number): string {
|
||||||
// -------------------------------
|
// -------------------------------
|
||||||
if (cleanValue.length <= 8) {
|
if (cleanValue.length <= 8) {
|
||||||
// Até 8 dígitos → formato parcial
|
// 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) {
|
if (cleanValue.length === 9 || cleanValue.length === 10) {
|
||||||
// DDD + telefone de 8 dígitos
|
// DDD + telefone de 8 dígitos
|
||||||
return cleanValue
|
return cleanValue.replace(/^(\d{2})(\d{4})(\d{0,4})$/, '($1) $2-$3').replace(/-$/, '');
|
||||||
.replace(/^(\d{2})(\d{4})(\d{0,4})$/, "($1) $2-$3")
|
|
||||||
.replace(/-$/, "");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cleanValue.length === 11) {
|
if (cleanValue.length === 11) {
|
||||||
// DDD + telefone de 9 dígitos
|
// DDD + telefone de 9 dígitos
|
||||||
return cleanValue
|
return cleanValue.replace(/^(\d{2})(\d{5})(\d{0,4})$/, '($1) $2-$3').replace(/-$/, '');
|
||||||
.replace(/^(\d{2})(\d{5})(\d{0,4})$/, "($1) $2-$3")
|
|
||||||
.replace(/-$/, "");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Caso genérico, se não cair em nenhuma regra
|
// Caso genérico, se não cair em nenhuma regra
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
* @returns String com a primeira letra em maiúscula
|
* @returns String com a primeira letra em maiúscula
|
||||||
*/
|
*/
|
||||||
export default function GetCapitalize(text: string): string {
|
export default function GetCapitalize(text: string): string {
|
||||||
if (!text) return "";
|
if (!text) return '';
|
||||||
|
|
||||||
return text.charAt(0).toUpperCase() + text.slice(1).toLowerCase();
|
return text.charAt(0).toUpperCase() + text.slice(1).toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
export default function GetNameInitials(data?: string): string {
|
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
|
// Remove espaços extras no início e no fim e divide em palavras
|
||||||
const palavras = data.trim().split(/\s+/);
|
const palavras = data.trim().split(/\s+/);
|
||||||
|
|
||||||
if (palavras.length === 0) return "";
|
if (palavras.length === 0) return '';
|
||||||
|
|
||||||
if (palavras.length === 1) {
|
if (palavras.length === 1) {
|
||||||
// Apenas uma palavra → retorna as duas primeiras letras
|
// Apenas uma palavra → retorna as duas primeiras letras
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
export default function GetSigla(data: string): string {
|
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
|
// Remove espaços extras no início e no fim e divide em palavras
|
||||||
const palavras = data.trim().split(/\s+/);
|
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
|
// 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() {
|
export default async function TokenGet() {
|
||||||
const cookieStore = await cookies();
|
const cookieStore = await cookies();
|
||||||
const token = cookieStore.get("access_token");
|
const token = cookieStore.get('access_token');
|
||||||
return token?.value;
|
return token?.value;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,5 +5,5 @@
|
||||||
* @returns true se estiver vazio, null ou undefined
|
* @returns true se estiver vazio, null ou undefined
|
||||||
*/
|
*/
|
||||||
export default function empty(data: unknown): boolean {
|
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
|
* 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<
|
export function withClientErrorHandler<T extends (...args: any[]) => Promise<any>>(action: T) {
|
||||||
T extends (...args: any[]) => Promise<any>,
|
return async (...args: Parameters<T>): Promise<withClientErrorHandlerInterface> => {
|
||||||
>(action: T) {
|
|
||||||
return async (
|
|
||||||
...args: Parameters<T>
|
|
||||||
): Promise<withClientErrorHandlerInterface> => {
|
|
||||||
try {
|
try {
|
||||||
// Executa a função definida
|
// Executa a função definida
|
||||||
const data = await action(...args);
|
const data = await action(...args);
|
||||||
|
|
@ -19,7 +15,7 @@ export function withClientErrorHandler<
|
||||||
// Retorna o erro de execuçãformatado
|
// Retorna o erro de execuçãformatado
|
||||||
return {
|
return {
|
||||||
status: 600,
|
status: 600,
|
||||||
message: error?.message || "Erro interno do servidor",
|
message: error?.message || 'Erro interno do servidor',
|
||||||
data: error,
|
data: error,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
"use client";
|
'use client';
|
||||||
|
|
||||||
import { useEffect } from "react";
|
import { useEffect } from 'react';
|
||||||
import { useParams } from "next/navigation";
|
import { useParams } from 'next/navigation';
|
||||||
|
|
||||||
import { Card, CardContent } from "@/components/ui/card";
|
import { Card, CardContent } from '@/components/ui/card';
|
||||||
import { useGUsuarioReadHooks } from "@/app/(protected)/(administrativo)/_hooks/g_usuario/useGUsuarioReadHooks";
|
import { useGUsuarioReadHooks } from '@/app/(protected)/(administrativo)/_hooks/g_usuario/useGUsuarioReadHooks';
|
||||||
import Usuario from "@/app/(protected)/(administrativo)/_interfaces/GUsuarioInterface";
|
import Usuario from '@/app/(protected)/(administrativo)/_interfaces/GUsuarioInterface';
|
||||||
import Loading from "@/app/_components/loading/loading";
|
import Loading from '@/app/_components/loading/loading';
|
||||||
|
|
||||||
export default function UsuarioDetalhes() {
|
export default function UsuarioDetalhes() {
|
||||||
const params = useParams();
|
const params = useParams();
|
||||||
|
|
@ -17,7 +17,7 @@ export default function UsuarioDetalhes() {
|
||||||
if (params.id) {
|
if (params.id) {
|
||||||
fetchUsuario({ usuario_id: Number(params.id) } as Usuario);
|
fetchUsuario({ usuario_id: Number(params.id) } as Usuario);
|
||||||
}
|
}
|
||||||
console.log("pagina", usuario);
|
console.log('pagina', usuario);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
if (!usuario) return <Loading type={1} />;
|
if (!usuario) return <Loading type={1} />;
|
||||||
|
|
@ -26,7 +26,7 @@ export default function UsuarioDetalhes() {
|
||||||
<div>
|
<div>
|
||||||
<Card>
|
<Card>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
<div className="mb-4 grid gap-4 grid-cols-4">
|
<div className="mb-4 grid grid-cols-4 gap-4">
|
||||||
<div>
|
<div>
|
||||||
<div className="text-2xl font-semibold">Nome</div>
|
<div className="text-2xl font-semibold">Nome</div>
|
||||||
<div className="text-xl">{usuario?.nome_completo}</div>
|
<div className="text-xl">{usuario?.nome_completo}</div>
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
"use client";
|
'use client';
|
||||||
|
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from '@hookform/resolvers/zod';
|
||||||
import { useForm } from "react-hook-form";
|
import { useForm } from 'react-hook-form';
|
||||||
import { z } from "zod";
|
import { z } from 'zod';
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from '@/components/ui/input';
|
||||||
import { GUsuarioSchema } from "../../../_schemas/GUsuarioSchema";
|
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 {
|
import {
|
||||||
Form,
|
Form,
|
||||||
|
|
@ -17,9 +17,9 @@ import {
|
||||||
FormItem,
|
FormItem,
|
||||||
FormLabel,
|
FormLabel,
|
||||||
FormMessage,
|
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>;
|
type FormValues = z.infer<typeof GUsuarioSchema>;
|
||||||
|
|
||||||
|
|
@ -29,11 +29,11 @@ export default function UsuarioFormularioPage() {
|
||||||
const form = useForm<FormValues>({
|
const form = useForm<FormValues>({
|
||||||
resolver: zodResolver(GUsuarioSchema),
|
resolver: zodResolver(GUsuarioSchema),
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
login: "",
|
login: '',
|
||||||
nome_completo: "",
|
nome_completo: '',
|
||||||
funcao: "",
|
funcao: '',
|
||||||
email: "",
|
email: '',
|
||||||
cpf: "",
|
cpf: '',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
"use client";
|
'use client';
|
||||||
|
|
||||||
import { Card, CardContent } from "@/components/ui/card";
|
import { Card, CardContent } from '@/components/ui/card';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Table,
|
Table,
|
||||||
|
|
@ -9,14 +9,14 @@ import {
|
||||||
TableHead,
|
TableHead,
|
||||||
TableHeader,
|
TableHeader,
|
||||||
TableRow,
|
TableRow,
|
||||||
} from "@/components/ui/table";
|
} from '@/components/ui/table';
|
||||||
|
|
||||||
import Usuario from "../../_interfaces/GUsuarioInterface";
|
import Usuario from '../../_interfaces/GUsuarioInterface';
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from '@/components/ui/button';
|
||||||
import Link from "next/link";
|
import Link from 'next/link';
|
||||||
import { useGUsuarioIndexHook } from "../../_hooks/g_usuario/useGUsuarioIndexHook";
|
import { useGUsuarioIndexHook } from '../../_hooks/g_usuario/useGUsuarioIndexHook';
|
||||||
import { useEffect } from "react";
|
import { useEffect } from 'react';
|
||||||
import Loading from "@/app/_components/loading/loading";
|
import Loading from '@/app/_components/loading/loading';
|
||||||
|
|
||||||
export default function UsuarioPage() {
|
export default function UsuarioPage() {
|
||||||
const { usuarios, fetchUsuarios } = useGUsuarioIndexHook();
|
const { usuarios, fetchUsuarios } = useGUsuarioIndexHook();
|
||||||
|
|
@ -54,15 +54,11 @@ export default function UsuarioPage() {
|
||||||
<TableBody>
|
<TableBody>
|
||||||
{usuarios.map((usuario: Usuario) => (
|
{usuarios.map((usuario: Usuario) => (
|
||||||
<TableRow key={usuario.usuario_id} className="cursor-pointer">
|
<TableRow key={usuario.usuario_id} className="cursor-pointer">
|
||||||
<TableCell className="text-center">
|
<TableCell className="text-center">{usuario.usuario_id}</TableCell>
|
||||||
{usuario.usuario_id}
|
<TableCell className="font-medium">{usuario.situacao}</TableCell>
|
||||||
</TableCell>
|
|
||||||
<TableCell className="font-medium">
|
|
||||||
{usuario.situacao}
|
|
||||||
</TableCell>
|
|
||||||
<TableCell className="font-medium">{usuario.cpf}</TableCell>
|
<TableCell className="font-medium">{usuario.cpf}</TableCell>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
<div className="font-semibold text-xs">
|
<div className="text-xs font-semibold">
|
||||||
{usuario.login} - {usuario.sigla}
|
{usuario.login} - {usuario.sigla}
|
||||||
</div>
|
</div>
|
||||||
<div className="text-base">{usuario.nome_completo}</div>
|
<div className="text-base">{usuario.nome_completo}</div>
|
||||||
|
|
@ -72,9 +68,7 @@ export default function UsuarioPage() {
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
<Button asChild>
|
<Button asChild>
|
||||||
<Link href={`/usuarios/${usuario.usuario_id}/detalhes`}>
|
<Link href={`/usuarios/${usuario.usuario_id}/detalhes`}>Detalhes</Link>
|
||||||
Detalhes
|
|
||||||
</Link>
|
|
||||||
</Button>
|
</Button>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
"use server";
|
'use server';
|
||||||
|
|
||||||
import API from "@/services/api/Api";
|
import API from '@/services/api/Api';
|
||||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
import { Methods } from '@/services/api/enums/ApiMethodEnum';
|
||||||
|
|
||||||
export default async function GUsuarioDeleteData(usuarioId: number) {
|
export default async function GUsuarioDeleteData(usuarioId: number) {
|
||||||
const api = new API();
|
const api = new API();
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
"use server";
|
'use server';
|
||||||
|
|
||||||
import API from "@/services/api/Api";
|
import API from '@/services/api/Api';
|
||||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
import { Methods } from '@/services/api/enums/ApiMethodEnum';
|
||||||
|
|
||||||
export default async function GUsuarioIndexData() {
|
export default async function GUsuarioIndexData() {
|
||||||
const api = new API();
|
const api = new API();
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
"use server";
|
'use server';
|
||||||
|
|
||||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
import { Methods } from '@/services/api/enums/ApiMethodEnum';
|
||||||
import API from "@/services/api/Api";
|
import API from '@/services/api/Api';
|
||||||
|
|
||||||
export default async function GUsuarioLoginData(form: any) {
|
export default async function GUsuarioLoginData(form: any) {
|
||||||
const api = new API();
|
const api = new API();
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
"use server";
|
'use server';
|
||||||
|
|
||||||
import API from "@/services/api/Api";
|
import API from '@/services/api/Api';
|
||||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
import { Methods } from '@/services/api/enums/ApiMethodEnum';
|
||||||
|
|
||||||
export default async function GUsuarioReadData(usuarioId: number) {
|
export default async function GUsuarioReadData(usuarioId: number) {
|
||||||
const api = new API();
|
const api = new API();
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
"use server";
|
'use server';
|
||||||
|
|
||||||
import API from "@/services/api/Api";
|
import API from '@/services/api/Api';
|
||||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
import { Methods } from '@/services/api/enums/ApiMethodEnum';
|
||||||
|
|
||||||
export default async function GUsuarioSaveData(form: any) {
|
export default async function GUsuarioSaveData(form: any) {
|
||||||
const api = new API();
|
const api = new API();
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
"use client";
|
'use client';
|
||||||
|
|
||||||
import { useState } from "react";
|
import { useState } from 'react';
|
||||||
import Usuario from "../../_interfaces/GUsuarioInterface";
|
import Usuario from '../../_interfaces/GUsuarioInterface';
|
||||||
import GUsuarioIndex from "../../_services/g_usuario/GUsuarioIndex";
|
import GUsuarioIndex from '../../_services/g_usuario/GUsuarioIndex';
|
||||||
import { useResponse } from "@/app/_response/ResponseContext";
|
import { useResponse } from '@/app/_response/ResponseContext';
|
||||||
|
|
||||||
export const useGUsuarioIndexHook = () => {
|
export const useGUsuarioIndexHook = () => {
|
||||||
const { setResponse } = useResponse();
|
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 = () => {
|
export const useGUsuarioLogoutHook = () => {
|
||||||
const logoutUsuario = async () => {
|
const logoutUsuario = async () => {
|
||||||
await GUsuarioLogoutService("access_token");
|
await GUsuarioLogoutService('access_token');
|
||||||
};
|
};
|
||||||
|
|
||||||
return { logoutUsuario };
|
return { logoutUsuario };
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
"use client";
|
'use client';
|
||||||
|
|
||||||
import { useState } from "react";
|
import { useState } from 'react';
|
||||||
import Usuario from "../../_interfaces/GUsuarioInterface";
|
import Usuario from '../../_interfaces/GUsuarioInterface';
|
||||||
import GUsuarioRead from "../../_services/g_usuario/GUsuarioRead";
|
import GUsuarioRead from '../../_services/g_usuario/GUsuarioRead';
|
||||||
import { useResponse } from "@/app/_response/ResponseContext";
|
import { useResponse } from '@/app/_response/ResponseContext';
|
||||||
|
|
||||||
export const useGUsuarioReadHooks = () => {
|
export const useGUsuarioReadHooks = () => {
|
||||||
const { setResponse } = useResponse();
|
const { setResponse } = useResponse();
|
||||||
|
|
@ -12,7 +12,7 @@ export const useGUsuarioReadHooks = () => {
|
||||||
|
|
||||||
const fetchUsuario = async (Usuario: Usuario) => {
|
const fetchUsuario = async (Usuario: Usuario) => {
|
||||||
const response = await GUsuarioRead(Usuario.usuario_id);
|
const response = await GUsuarioRead(Usuario.usuario_id);
|
||||||
console.log("hook", response.data);
|
console.log('hook', response.data);
|
||||||
|
|
||||||
setUsuario(response.data);
|
setUsuario(response.data);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
"use client";
|
'use client';
|
||||||
|
|
||||||
import { useState } from "react";
|
import { useState } from 'react';
|
||||||
import Usuario from "../../_interfaces/GUsuarioInterface";
|
import Usuario from '../../_interfaces/GUsuarioInterface';
|
||||||
import GUsuarioSave from "../../_services/g_usuario/GUsuarioSave";
|
import GUsuarioSave from '../../_services/g_usuario/GUsuarioSave';
|
||||||
import { useResponse } from "@/app/_response/ResponseContext";
|
import { useResponse } from '@/app/_response/ResponseContext';
|
||||||
|
|
||||||
export const useGUsuarioSaveHook = () => {
|
export const useGUsuarioSaveHook = () => {
|
||||||
const { setResponse } = useResponse();
|
const { setResponse } = useResponse();
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { z } from "zod";
|
import { z } from 'zod';
|
||||||
|
|
||||||
export const GUsuarioLoginSchema = z.object({
|
export const GUsuarioLoginSchema = z.object({
|
||||||
login: 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"),
|
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({
|
export const GUsuarioSchema = z.object({
|
||||||
trocarsenha: z.string().optional(),
|
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() {
|
export default async function GUsuarioIndex() {
|
||||||
const response = await GUsuarioIndexData();
|
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 GUsuarioLoginData from '../../_data/g_usuario/GUsuarioLoginData';
|
||||||
import { redirect } from "next/navigation";
|
import { redirect } from 'next/navigation';
|
||||||
|
|
||||||
export default async function GUsuarioLoginService(form: any) {
|
export default async function GUsuarioLoginService(form: any) {
|
||||||
// Obtem a resposta da requisição
|
// Obtem a resposta da requisição
|
||||||
|
|
@ -13,7 +13,7 @@ export default async function GUsuarioLoginService(form: any) {
|
||||||
if (response.data.usuario_id <= 0) {
|
if (response.data.usuario_id <= 0) {
|
||||||
return {
|
return {
|
||||||
code: 404,
|
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();
|
const cookieStore = await cookies();
|
||||||
|
|
||||||
// Cria um novo cookie
|
// Cria um novo cookie
|
||||||
cookieStore.set("access_token", response.data.token, {
|
cookieStore.set('access_token', response.data.token, {
|
||||||
httpOnly: true,
|
httpOnly: true,
|
||||||
secure: process.env.NODE_ENV === "production",
|
secure: process.env.NODE_ENV === 'production',
|
||||||
sameSite: "strict",
|
sameSite: 'strict',
|
||||||
path: "/",
|
path: '/',
|
||||||
maxAge: 60 * 60 * 24,
|
maxAge: 60 * 60 * 24,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Redireciona para a págian desejada
|
// 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) {
|
export default async function GUsuarioLogoutService(token: string) {
|
||||||
const cookieStore = await cookies();
|
const cookieStore = await cookies();
|
||||||
cookieStore.set(token, "", {
|
cookieStore.set(token, '', {
|
||||||
expires: new Date(0),
|
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) {
|
export default async function GUsuarioRead(usuarioId: number) {
|
||||||
// Verifica se o id informado é válido
|
// Verifica se o id informado é válido
|
||||||
if (usuarioId <= 0) {
|
if (usuarioId <= 0) {
|
||||||
return {
|
return {
|
||||||
code: 400,
|
code: 400,
|
||||||
message: "Usuário informado inválido",
|
message: 'Usuário informado inválido',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await GUsuarioReadData(usuarioId);
|
const response = await GUsuarioReadData(usuarioId);
|
||||||
console.log("service", response);
|
console.log('service', response);
|
||||||
return response;
|
return response;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(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) {
|
export default async function GUsuarioSave(form: any) {
|
||||||
return await GUsuarioSaveData(form);
|
return await GUsuarioSaveData(form);
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,21 @@
|
||||||
"use client";
|
'use client';
|
||||||
|
|
||||||
import { useEffect, useState, useCallback } from "react";
|
import { useEffect, useState, useCallback } from 'react';
|
||||||
import { Card, CardContent } from "@/components/ui/card";
|
import { Card, CardContent } from '@/components/ui/card';
|
||||||
|
|
||||||
import Loading from "@/app/_components/loading/loading";
|
import Loading from '@/app/_components/loading/loading';
|
||||||
import GCidadeTable from "../../_components/g_cidade/GCidadeTable";
|
import GCidadeTable from '../../_components/g_cidade/GCidadeTable';
|
||||||
import GCidadeForm from "../../_components/g_cidade/GCidadeForm";
|
import GCidadeForm from '../../_components/g_cidade/GCidadeForm';
|
||||||
|
|
||||||
import { useGCidadeReadHook } from "../../_hooks/g_cidade/useGCidadeReadHook";
|
import { useGCidadeReadHook } from '../../_hooks/g_cidade/useGCidadeReadHook';
|
||||||
import { useGCidadeSaveHook } from "../../_hooks/g_cidade/useGCidadeSaveHook";
|
import { useGCidadeSaveHook } from '../../_hooks/g_cidade/useGCidadeSaveHook';
|
||||||
import { useGCidadeRemoveHook } from "../../_hooks/g_cidade/useGCidadeRemoveHook";
|
import { useGCidadeRemoveHook } from '../../_hooks/g_cidade/useGCidadeRemoveHook';
|
||||||
|
|
||||||
import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog";
|
import ConfirmDialog from '@/app/_components/confirm_dialog/ConfirmDialog';
|
||||||
import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDialog";
|
import { useConfirmDialog } from '@/app/_components/confirm_dialog/useConfirmDialog';
|
||||||
|
|
||||||
import GCidadeInterface from "../../_interfaces/GCidadeInterface";
|
import GCidadeInterface from '../../_interfaces/GCidadeInterface';
|
||||||
import Header from "@/app/_components/structure/Header";
|
import Header from '@/app/_components/structure/Header';
|
||||||
|
|
||||||
export default function GCidadePage() {
|
export default function GCidadePage() {
|
||||||
// Hooks para leitura e salvamento
|
// Hooks para leitura e salvamento
|
||||||
|
|
@ -24,15 +24,11 @@ export default function GCidadePage() {
|
||||||
const { removeGCidade } = useGCidadeRemoveHook();
|
const { removeGCidade } = useGCidadeRemoveHook();
|
||||||
|
|
||||||
// Estados
|
// Estados
|
||||||
const [selectedCidade, setSelectedCidade] = useState<GCidadeInterface | null>(
|
const [selectedCidade, setSelectedCidade] = useState<GCidadeInterface | null>(null);
|
||||||
null,
|
|
||||||
);
|
|
||||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||||
|
|
||||||
// Estado para saber qual item será deletado
|
// Estado para saber qual item será deletado
|
||||||
const [itemToDelete, setItemToDelete] = useState<GCidadeInterface | null>(
|
const [itemToDelete, setItemToDelete] = useState<GCidadeInterface | null>(null);
|
||||||
null,
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hook do modal de confirmação
|
* Hook do modal de confirmação
|
||||||
|
|
@ -126,9 +122,9 @@ export default function GCidadePage() {
|
||||||
<div>
|
<div>
|
||||||
{/* Cabeçalho */}
|
{/* Cabeçalho */}
|
||||||
<Header
|
<Header
|
||||||
title={"Cidades"}
|
title={'Cidades'}
|
||||||
description={"Gerenciamento de Cidades"}
|
description={'Gerenciamento de Cidades'}
|
||||||
buttonText={"Nova Cidade"}
|
buttonText={'Nova Cidade'}
|
||||||
buttonAction={() => {
|
buttonAction={() => {
|
||||||
handleOpenForm(null);
|
handleOpenForm(null);
|
||||||
}}
|
}}
|
||||||
|
|
@ -137,11 +133,7 @@ export default function GCidadePage() {
|
||||||
{/* Tabela de andamentos */}
|
{/* Tabela de andamentos */}
|
||||||
<Card>
|
<Card>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
<GCidadeTable
|
<GCidadeTable data={gCidade} onEdit={handleOpenForm} onDelete={handleConfirmDelete} />
|
||||||
data={gCidade}
|
|
||||||
onEdit={handleOpenForm}
|
|
||||||
onDelete={handleConfirmDelete}
|
|
||||||
/>
|
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,27 @@
|
||||||
"use client";
|
'use client';
|
||||||
|
|
||||||
import { useEffect, useState, useCallback } from "react";
|
import { useEffect, useState, useCallback } from 'react';
|
||||||
import { Card, CardContent } from "@/components/ui/card";
|
import { Card, CardContent } from '@/components/ui/card';
|
||||||
import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDialog";
|
import { useConfirmDialog } from '@/app/_components/confirm_dialog/useConfirmDialog';
|
||||||
import { useResponse } from "@/app/_response/ResponseContext";
|
import { useResponse } from '@/app/_response/ResponseContext';
|
||||||
|
|
||||||
import Header from "@/app/_components/structure/Header";
|
import Header from '@/app/_components/structure/Header';
|
||||||
import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog";
|
import ConfirmDialog from '@/app/_components/confirm_dialog/ConfirmDialog';
|
||||||
import Loading from "@/app/_components/loading/loading";
|
import Loading from '@/app/_components/loading/loading';
|
||||||
import GMedidaTipoTable from "../../_components/g_medidatipo/GMedidaTipoTable";
|
import GMedidaTipoTable from '../../_components/g_medidatipo/GMedidaTipoTable';
|
||||||
import GMedidaTipoForm from "../../_components/g_medidatipo/GMedidaTipoForm";
|
import GMedidaTipoForm from '../../_components/g_medidatipo/GMedidaTipoForm';
|
||||||
|
|
||||||
import { useGMedidaTipoReadHook } from "../../_hooks/g_medidatipo/useGMedidaTipoReadHook";
|
import { useGMedidaTipoReadHook } from '../../_hooks/g_medidatipo/useGMedidaTipoReadHook';
|
||||||
import { useGMedidaTipoSaveHook } from "../../_hooks/g_medidatipo/useGMedidaTipoSaveHook";
|
import { useGMedidaTipoSaveHook } from '../../_hooks/g_medidatipo/useGMedidaTipoSaveHook';
|
||||||
import { useGMedidaTipoRemoveHook } from "../../_hooks/g_medidatipo/useGMedidaTipoRemoveHook";
|
import { useGMedidaTipoRemoveHook } from '../../_hooks/g_medidatipo/useGMedidaTipoRemoveHook';
|
||||||
|
|
||||||
import { GMedidaTipoInterface } from "../../_interfaces/GMedidaTipoInterface";
|
import { GMedidaTipoInterface } from '../../_interfaces/GMedidaTipoInterface';
|
||||||
import { SituacoesEnum } from "@/enums/SituacoesEnum";
|
import { SituacoesEnum } from '@/enums/SituacoesEnum';
|
||||||
|
|
||||||
const initialMedidaTipo: GMedidaTipoInterface = {
|
const initialMedidaTipo: GMedidaTipoInterface = {
|
||||||
medida_tipo_id: 0,
|
medida_tipo_id: 0,
|
||||||
sigla: "",
|
sigla: '',
|
||||||
descricao: "",
|
descricao: '',
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function GMedidaTipoPage() {
|
export default function GMedidaTipoPage() {
|
||||||
|
|
@ -37,19 +37,12 @@ export default function GMedidaTipoPage() {
|
||||||
const { removeGMedidaTipo } = useGMedidaTipoRemoveHook();
|
const { removeGMedidaTipo } = useGMedidaTipoRemoveHook();
|
||||||
|
|
||||||
// Estado para controlar o formulário e o item selecionado
|
// Estado para controlar o formulário e o item selecionado
|
||||||
const [selectedMedidaTipo, setSelectedMedidaTipo] =
|
const [selectedMedidaTipo, setSelectedMedidaTipo] = useState<GMedidaTipoInterface | null>(null);
|
||||||
useState<GMedidaTipoInterface | null>(null);
|
|
||||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||||
const [itemToDelete, setItemToDelete] = useState<GMedidaTipoInterface | null>(
|
const [itemToDelete, setItemToDelete] = useState<GMedidaTipoInterface | null>(null);
|
||||||
null,
|
|
||||||
);
|
|
||||||
|
|
||||||
// Hook para o modal de confirmação
|
// Hook para o modal de confirmação
|
||||||
const {
|
const { isOpen: isConfirmOpen, openDialog: openConfirmDialog, handleCancel } = useConfirmDialog();
|
||||||
isOpen: isConfirmOpen,
|
|
||||||
openDialog: openConfirmDialog,
|
|
||||||
handleCancel,
|
|
||||||
} = useConfirmDialog();
|
|
||||||
|
|
||||||
// Ações do formulário
|
// Ações do formulário
|
||||||
const handleOpenForm = useCallback((data: GMedidaTipoInterface | null) => {
|
const handleOpenForm = useCallback((data: GMedidaTipoInterface | null) => {
|
||||||
|
|
@ -90,7 +83,7 @@ export default function GMedidaTipoPage() {
|
||||||
// Define os dados da resposta visual
|
// Define os dados da resposta visual
|
||||||
setResponse({
|
setResponse({
|
||||||
status: 400,
|
status: 400,
|
||||||
message: "Não foi informado um registro para exclusão",
|
message: 'Não foi informado um registro para exclusão',
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -114,9 +107,9 @@ export default function GMedidaTipoPage() {
|
||||||
<div>
|
<div>
|
||||||
{/* Cabeçalho */}
|
{/* Cabeçalho */}
|
||||||
<Header
|
<Header
|
||||||
title={"Tipos de Medida"}
|
title={'Tipos de Medida'}
|
||||||
description={"Gerenciamento de tipos de medida"}
|
description={'Gerenciamento de tipos de medida'}
|
||||||
buttonText={"Novo Tipo de Medida"}
|
buttonText={'Novo Tipo de Medida'}
|
||||||
buttonAction={(data) => {
|
buttonAction={(data) => {
|
||||||
handleOpenForm((data = initialMedidaTipo));
|
handleOpenForm((data = initialMedidaTipo));
|
||||||
}}
|
}}
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,27 @@
|
||||||
"use client";
|
'use client';
|
||||||
|
|
||||||
import { useEffect, useState, useCallback } from "react";
|
import { useEffect, useState, useCallback } from 'react';
|
||||||
import { Card, CardContent } from "@/components/ui/card";
|
import { Card, CardContent } from '@/components/ui/card';
|
||||||
import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDialog";
|
import { useConfirmDialog } from '@/app/_components/confirm_dialog/useConfirmDialog';
|
||||||
import { useResponse } from "@/app/_response/ResponseContext";
|
import { useResponse } from '@/app/_response/ResponseContext';
|
||||||
|
|
||||||
import Header from "@/app/_components/structure/Header";
|
import Header from '@/app/_components/structure/Header';
|
||||||
import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog";
|
import ConfirmDialog from '@/app/_components/confirm_dialog/ConfirmDialog';
|
||||||
import Loading from "@/app/_components/loading/loading";
|
import Loading from '@/app/_components/loading/loading';
|
||||||
import GTBBairroTable from "../../_components/g_tb_bairro/GTBBairroTable";
|
import GTBBairroTable from '../../_components/g_tb_bairro/GTBBairroTable';
|
||||||
import GTBBairroForm from "../../_components/g_tb_bairro/GTBBairroForm";
|
import GTBBairroForm from '../../_components/g_tb_bairro/GTBBairroForm';
|
||||||
|
|
||||||
import { useGTBBairroReadHook } from "../../_hooks/g_tb_bairro/useGTBBairroReadHook";
|
import { useGTBBairroReadHook } from '../../_hooks/g_tb_bairro/useGTBBairroReadHook';
|
||||||
import { useGTBBairroSaveHook } from "../../_hooks/g_tb_bairro/useGTBBairroSaveHook";
|
import { useGTBBairroSaveHook } from '../../_hooks/g_tb_bairro/useGTBBairroSaveHook';
|
||||||
import { useGTBBairroRemoveHook } from "../../_hooks/g_tb_bairro/useGTBBairroRemoveHook";
|
import { useGTBBairroRemoveHook } from '../../_hooks/g_tb_bairro/useGTBBairroRemoveHook';
|
||||||
|
|
||||||
import { GTBBairroInterface } from "../../_interfaces/GTBBairroInterface";
|
import { GTBBairroInterface } from '../../_interfaces/GTBBairroInterface';
|
||||||
import { SituacoesEnum } from "@/enums/SituacoesEnum";
|
import { SituacoesEnum } from '@/enums/SituacoesEnum';
|
||||||
|
|
||||||
const initialBairro: GTBBairroInterface = {
|
const initialBairro: GTBBairroInterface = {
|
||||||
sistema_id: null,
|
sistema_id: null,
|
||||||
tb_bairro_id: 0,
|
tb_bairro_id: 0,
|
||||||
descricao: "",
|
descricao: '',
|
||||||
situacao: SituacoesEnum.A,
|
situacao: SituacoesEnum.A,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -40,16 +40,10 @@ export default function GTBBairroPage() {
|
||||||
// Estado para controlar o formulário e item selecionado
|
// Estado para controlar o formulário e item selecionado
|
||||||
const [selectedBairro, setBairro] = useState<GTBBairroInterface | null>(null);
|
const [selectedBairro, setBairro] = useState<GTBBairroInterface | null>(null);
|
||||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||||
const [itemToDelete, setItemToDelete] = useState<GTBBairroInterface | null>(
|
const [itemToDelete, setItemToDelete] = useState<GTBBairroInterface | null>(null);
|
||||||
null,
|
|
||||||
);
|
|
||||||
|
|
||||||
// Hook para o modal de confirmação
|
// Hook para o modal de confirmação
|
||||||
const {
|
const { isOpen: isConfirmOpen, openDialog: openConfirmDialog, handleCancel } = useConfirmDialog();
|
||||||
isOpen: isConfirmOpen,
|
|
||||||
openDialog: openConfirmDialog,
|
|
||||||
handleCancel,
|
|
||||||
} = useConfirmDialog();
|
|
||||||
|
|
||||||
// Ações do formulário
|
// Ações do formulário
|
||||||
const handleOpenForm = useCallback((data: GTBBairroInterface | null) => {
|
const handleOpenForm = useCallback((data: GTBBairroInterface | null) => {
|
||||||
|
|
@ -94,7 +88,7 @@ export default function GTBBairroPage() {
|
||||||
// Define os dados da resposta visual
|
// Define os dados da resposta visual
|
||||||
setResponse({
|
setResponse({
|
||||||
status: 400,
|
status: 400,
|
||||||
message: "Não foi informado um registro para exclusão",
|
message: 'Não foi informado um registro para exclusão',
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -127,9 +121,9 @@ export default function GTBBairroPage() {
|
||||||
<div>
|
<div>
|
||||||
{/* Cabeçalho */}
|
{/* Cabeçalho */}
|
||||||
<Header
|
<Header
|
||||||
title={"Bairros"}
|
title={'Bairros'}
|
||||||
description={"Gerenciamento de Bairros"}
|
description={'Gerenciamento de Bairros'}
|
||||||
buttonText={"Novo Bairro"}
|
buttonText={'Novo Bairro'}
|
||||||
buttonAction={(data) => {
|
buttonAction={(data) => {
|
||||||
handleOpenForm((data = initialBairro));
|
handleOpenForm((data = initialBairro));
|
||||||
}}
|
}}
|
||||||
|
|
@ -138,11 +132,7 @@ export default function GTBBairroPage() {
|
||||||
{/* Tabela de Bairros */}
|
{/* Tabela de Bairros */}
|
||||||
<Card>
|
<Card>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
<GTBBairroTable
|
<GTBBairroTable data={gTBBairro} onEdit={handleOpenForm} onDelete={handleConfirmDelete} />
|
||||||
data={gTBBairro}
|
|
||||||
onEdit={handleOpenForm}
|
|
||||||
onDelete={handleConfirmDelete}
|
|
||||||
/>
|
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,27 @@
|
||||||
"use client";
|
'use client';
|
||||||
|
|
||||||
import { useEffect, useState, useCallback } from "react";
|
import { useEffect, useState, useCallback } from 'react';
|
||||||
import { Card, CardContent } from "@/components/ui/card";
|
import { Card, CardContent } from '@/components/ui/card';
|
||||||
import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDialog";
|
import { useConfirmDialog } from '@/app/_components/confirm_dialog/useConfirmDialog';
|
||||||
|
|
||||||
import Header from "@/app/_components/structure/Header";
|
import Header from '@/app/_components/structure/Header';
|
||||||
import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog";
|
import ConfirmDialog from '@/app/_components/confirm_dialog/ConfirmDialog';
|
||||||
import Loading from "@/app/_components/loading/loading";
|
import Loading from '@/app/_components/loading/loading';
|
||||||
import GTBEstadoCivilTable from "../../_components/g_tb_estadocivil/GTBEstadoCivilTable";
|
import GTBEstadoCivilTable from '../../_components/g_tb_estadocivil/GTBEstadoCivilTable';
|
||||||
import GTBEstadoCivilForm from "../../_components/g_tb_estadocivil/GTBEstadoCivilForm";
|
import GTBEstadoCivilForm from '../../_components/g_tb_estadocivil/GTBEstadoCivilForm';
|
||||||
|
|
||||||
import { useGTBEstadoCivilReadHook } from "../../_hooks/g_tb_estadocivil/useGTBEstadoCivilReadHook";
|
import { useGTBEstadoCivilReadHook } from '../../_hooks/g_tb_estadocivil/useGTBEstadoCivilReadHook';
|
||||||
import { useGTBEstadoCivilSaveHook } from "../../_hooks/g_tb_estadocivil/useGTBEstadoCivilSaveHook";
|
import { useGTBEstadoCivilSaveHook } from '../../_hooks/g_tb_estadocivil/useGTBEstadoCivilSaveHook';
|
||||||
import { useGTBEstadoCivilRemoveHook } from "../../_hooks/g_tb_estadocivil/useGTBEstadoCivilRemoveHook";
|
import { useGTBEstadoCivilRemoveHook } from '../../_hooks/g_tb_estadocivil/useGTBEstadoCivilRemoveHook';
|
||||||
|
|
||||||
import { GTBEstadoCivilInterface } from "../../_interfaces/GTBEstadoCivilInterface";
|
import { GTBEstadoCivilInterface } from '../../_interfaces/GTBEstadoCivilInterface';
|
||||||
import { useResponse } from "@/app/_response/ResponseContext";
|
import { useResponse } from '@/app/_response/ResponseContext';
|
||||||
|
|
||||||
const initalEstadoCivil: GTBEstadoCivilInterface = {
|
const initalEstadoCivil: GTBEstadoCivilInterface = {
|
||||||
tb_estadocivil_id: 0,
|
tb_estadocivil_id: 0,
|
||||||
sistema_id: 0,
|
sistema_id: 0,
|
||||||
descricao: "",
|
descricao: '',
|
||||||
situacao: "A",
|
situacao: 'A',
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function TBEstadoCivilPage() {
|
export default function TBEstadoCivilPage() {
|
||||||
|
|
@ -37,18 +37,14 @@ export default function TBEstadoCivilPage() {
|
||||||
const { removeGTBEstadoCivil } = useGTBEstadoCivilRemoveHook();
|
const { removeGTBEstadoCivil } = useGTBEstadoCivilRemoveHook();
|
||||||
|
|
||||||
// Estado para controlar o formulário e item selecionado
|
// Estado para controlar o formulário e item selecionado
|
||||||
const [selectedEstadoCivil, setSelectedEstadoCivil] =
|
const [selectedEstadoCivil, setSelectedEstadoCivil] = useState<GTBEstadoCivilInterface | null>(
|
||||||
useState<GTBEstadoCivilInterface | null>(null);
|
null,
|
||||||
|
);
|
||||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||||
const [itemToDelete, setItemToDelete] =
|
const [itemToDelete, setItemToDelete] = useState<GTBEstadoCivilInterface | null>(null);
|
||||||
useState<GTBEstadoCivilInterface | null>(null);
|
|
||||||
|
|
||||||
// Hook para o modal de confirmação
|
// Hook para o modal de confirmação
|
||||||
const {
|
const { isOpen: isConfirmOpen, openDialog: openConfirmDialog, handleCancel } = useConfirmDialog();
|
||||||
isOpen: isConfirmOpen,
|
|
||||||
openDialog: openConfirmDialog,
|
|
||||||
handleCancel,
|
|
||||||
} = useConfirmDialog();
|
|
||||||
|
|
||||||
// Ações do formulário
|
// Ações do formulário
|
||||||
const handleOpenForm = useCallback((data: GTBEstadoCivilInterface | null) => {
|
const handleOpenForm = useCallback((data: GTBEstadoCivilInterface | null) => {
|
||||||
|
|
@ -88,7 +84,7 @@ export default function TBEstadoCivilPage() {
|
||||||
// Define os dados da resposta visual
|
// Define os dados da resposta visual
|
||||||
setResponse({
|
setResponse({
|
||||||
status: 400,
|
status: 400,
|
||||||
message: "Não foi informado um registro para exclusão",
|
message: 'Não foi informado um registro para exclusão',
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -111,9 +107,9 @@ export default function TBEstadoCivilPage() {
|
||||||
<div>
|
<div>
|
||||||
{/* Cabeçalho */}
|
{/* Cabeçalho */}
|
||||||
<Header
|
<Header
|
||||||
title={"Estados Civis"}
|
title={'Estados Civis'}
|
||||||
description={"Gerenciamento de Estados Civis"}
|
description={'Gerenciamento de Estados Civis'}
|
||||||
buttonText={"Novo Estado Civil"}
|
buttonText={'Novo Estado Civil'}
|
||||||
buttonAction={(data) => {
|
buttonAction={(data) => {
|
||||||
handleOpenForm((data = initalEstadoCivil));
|
handleOpenForm((data = initalEstadoCivil));
|
||||||
}}
|
}}
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,21 @@
|
||||||
"use client";
|
'use client';
|
||||||
|
|
||||||
import { useEffect, useState, useCallback } from "react";
|
import { useEffect, useState, useCallback } from 'react';
|
||||||
import { Card, CardContent } from "@/components/ui/card";
|
import { Card, CardContent } from '@/components/ui/card';
|
||||||
|
|
||||||
import Loading from "@/app/_components/loading/loading";
|
import Loading from '@/app/_components/loading/loading';
|
||||||
import GTBProfissaoTable from "../../_components/g_tb_profissao/GTBProfissaoTable";
|
import GTBProfissaoTable from '../../_components/g_tb_profissao/GTBProfissaoTable';
|
||||||
import GTBProfissaoForm from "../../_components/g_tb_profissao/GTBProfissaoForm";
|
import GTBProfissaoForm from '../../_components/g_tb_profissao/GTBProfissaoForm';
|
||||||
|
|
||||||
import { useGTBProfissaoReadHook } from "../../_hooks/g_tb_profissao/useGTBProfissaoReadHook";
|
import { useGTBProfissaoReadHook } from '../../_hooks/g_tb_profissao/useGTBProfissaoReadHook';
|
||||||
import { useGTBProfissaoSaveHook } from "../../_hooks/g_tb_profissao/useGTBProfissaoSaveHook";
|
import { useGTBProfissaoSaveHook } from '../../_hooks/g_tb_profissao/useGTBProfissaoSaveHook';
|
||||||
import { useGTBProfissaoRemoveHook } from "../../_hooks/g_tb_profissao/useGTBProfissaoRemoveHook";
|
import { useGTBProfissaoRemoveHook } from '../../_hooks/g_tb_profissao/useGTBProfissaoRemoveHook';
|
||||||
|
|
||||||
import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog";
|
import ConfirmDialog from '@/app/_components/confirm_dialog/ConfirmDialog';
|
||||||
import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDialog";
|
import { useConfirmDialog } from '@/app/_components/confirm_dialog/useConfirmDialog';
|
||||||
|
|
||||||
import GTBProfissaoInterface from "../../_interfaces/GTBProfissaoInterface";
|
import GTBProfissaoInterface from '../../_interfaces/GTBProfissaoInterface';
|
||||||
import Header from "@/app/_components/structure/Header";
|
import Header from '@/app/_components/structure/Header';
|
||||||
|
|
||||||
export default function TTBAndamentoServico() {
|
export default function TTBAndamentoServico() {
|
||||||
// Hooks para leitura e salvamento
|
// Hooks para leitura e salvamento
|
||||||
|
|
@ -24,13 +24,11 @@ export default function TTBAndamentoServico() {
|
||||||
const { removeGTBProfissao } = useGTBProfissaoRemoveHook();
|
const { removeGTBProfissao } = useGTBProfissaoRemoveHook();
|
||||||
|
|
||||||
// Estados
|
// Estados
|
||||||
const [selectedAndamento, setSelectedAndamento] =
|
const [selectedAndamento, setSelectedAndamento] = useState<GTBProfissaoInterface | null>(null);
|
||||||
useState<GTBProfissaoInterface | null>(null);
|
|
||||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||||
|
|
||||||
// Estado para saber qual item será deletado
|
// Estado para saber qual item será deletado
|
||||||
const [itemToDelete, setItemToDelete] =
|
const [itemToDelete, setItemToDelete] = useState<GTBProfissaoInterface | null>(null);
|
||||||
useState<GTBProfissaoInterface | null>(null);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hook do modal de confirmação
|
* Hook do modal de confirmação
|
||||||
|
|
@ -124,9 +122,9 @@ export default function TTBAndamentoServico() {
|
||||||
<div>
|
<div>
|
||||||
{/* Cabeçalho */}
|
{/* Cabeçalho */}
|
||||||
<Header
|
<Header
|
||||||
title={"Profissões"}
|
title={'Profissões'}
|
||||||
description={"Gerenciamento de Profissões"}
|
description={'Gerenciamento de Profissões'}
|
||||||
buttonText={"Nova Profissão"}
|
buttonText={'Nova Profissão'}
|
||||||
buttonAction={() => {
|
buttonAction={() => {
|
||||||
handleOpenForm(null);
|
handleOpenForm(null);
|
||||||
}}
|
}}
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,21 @@
|
||||||
"use client";
|
'use client';
|
||||||
|
|
||||||
import { useEffect, useState, useCallback } from "react";
|
import { useEffect, useState, useCallback } from 'react';
|
||||||
import { Card, CardContent } from "@/components/ui/card";
|
import { Card, CardContent } from '@/components/ui/card';
|
||||||
|
|
||||||
import Loading from "@/app/_components/loading/loading";
|
import Loading from '@/app/_components/loading/loading';
|
||||||
import GTBRegimeBensTable from "../../_components/g_tb_regimebens/GTBRegimeBensTable";
|
import GTBRegimeBensTable from '../../_components/g_tb_regimebens/GTBRegimeBensTable';
|
||||||
import GTBRegimeBensForm from "../../_components/g_tb_regimebens/GTBRegimeBensForm";
|
import GTBRegimeBensForm from '../../_components/g_tb_regimebens/GTBRegimeBensForm';
|
||||||
|
|
||||||
import { useGTBRegimeBensReadHook } from "../../_hooks/g_tb_regimebens/useGTBRegimeBensReadHook";
|
import { useGTBRegimeBensReadHook } from '../../_hooks/g_tb_regimebens/useGTBRegimeBensReadHook';
|
||||||
import { useGTBRegimeBensSaveHook } from "../../_hooks/g_tb_regimebens/useGTBRegimeBensSaveHook";
|
import { useGTBRegimeBensSaveHook } from '../../_hooks/g_tb_regimebens/useGTBRegimeBensSaveHook';
|
||||||
import { useGTBRegimeBensRemoveHook } from "../../_hooks/g_tb_regimebens/useGTBRegimeBensRemoveHook";
|
import { useGTBRegimeBensRemoveHook } from '../../_hooks/g_tb_regimebens/useGTBRegimeBensRemoveHook';
|
||||||
|
|
||||||
import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog";
|
import ConfirmDialog from '@/app/_components/confirm_dialog/ConfirmDialog';
|
||||||
import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDialog";
|
import { useConfirmDialog } from '@/app/_components/confirm_dialog/useConfirmDialog';
|
||||||
|
|
||||||
import GTBRegimeBensInterface from "../../_interfaces/GTBRegimeBensInterface";
|
import GTBRegimeBensInterface from '../../_interfaces/GTBRegimeBensInterface';
|
||||||
import Header from "@/app/_components/structure/Header";
|
import Header from '@/app/_components/structure/Header';
|
||||||
|
|
||||||
export default function TTBAndamentoServico() {
|
export default function TTBAndamentoServico() {
|
||||||
// Hooks para leitura e salvamento
|
// Hooks para leitura e salvamento
|
||||||
|
|
@ -24,13 +24,11 @@ export default function TTBAndamentoServico() {
|
||||||
const { removeGTBRegimeComunhao } = useGTBRegimeBensRemoveHook();
|
const { removeGTBRegimeComunhao } = useGTBRegimeBensRemoveHook();
|
||||||
|
|
||||||
// Estados
|
// Estados
|
||||||
const [selectedAndamento, setSelectedAndamento] =
|
const [selectedAndamento, setSelectedAndamento] = useState<GTBRegimeBensInterface | null>(null);
|
||||||
useState<GTBRegimeBensInterface | null>(null);
|
|
||||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||||
|
|
||||||
// Estado para saber qual item será deletado
|
// Estado para saber qual item será deletado
|
||||||
const [itemToDelete, setItemToDelete] =
|
const [itemToDelete, setItemToDelete] = useState<GTBRegimeBensInterface | null>(null);
|
||||||
useState<GTBRegimeBensInterface | null>(null);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hook do modal de confirmação
|
* Hook do modal de confirmação
|
||||||
|
|
@ -124,9 +122,9 @@ export default function TTBAndamentoServico() {
|
||||||
<div>
|
<div>
|
||||||
{/* Cabeçalho */}
|
{/* Cabeçalho */}
|
||||||
<Header
|
<Header
|
||||||
title={"Regimes de Bens"}
|
title={'Regimes de Bens'}
|
||||||
description={"Gerenciamento de Regimes de Bens"}
|
description={'Gerenciamento de Regimes de Bens'}
|
||||||
buttonText={"Novo Regime"}
|
buttonText={'Novo Regime'}
|
||||||
buttonAction={() => {
|
buttonAction={() => {
|
||||||
handleOpenForm(null);
|
handleOpenForm(null);
|
||||||
}}
|
}}
|
||||||
|
|
|
||||||
|
|
@ -1,37 +1,36 @@
|
||||||
"use client";
|
'use client';
|
||||||
|
|
||||||
import { useEffect, useState, useCallback } from "react";
|
import { useEffect, useState, useCallback } from 'react';
|
||||||
import { Card, CardContent } from "@/components/ui/card";
|
import { Card, CardContent } from '@/components/ui/card';
|
||||||
|
|
||||||
import Loading from "@/app/_components/loading/loading";
|
import Loading from '@/app/_components/loading/loading';
|
||||||
import GTBRegimeComunhaoTable from "../../_components/g_tb_regimecomunhao/GTBRegimeComunhaoTable";
|
import GTBRegimeComunhaoTable from '../../_components/g_tb_regimecomunhao/GTBRegimeComunhaoTable';
|
||||||
import GTBRegimeComunhaoForm from "../../_components/g_tb_regimecomunhao/GTBRegimeComunhaoForm";
|
import GTBRegimeComunhaoForm from '../../_components/g_tb_regimecomunhao/GTBRegimeComunhaoForm';
|
||||||
|
|
||||||
import { useGTBRegimeComunhaoReadHook } from "../../_hooks/g_tb_regimecomunhao/useGTBRegimeComunhaoReadHook";
|
import { useGTBRegimeComunhaoReadHook } from '../../_hooks/g_tb_regimecomunhao/useGTBRegimeComunhaoReadHook';
|
||||||
import { useGTBRegimeComunhaoSaveHook } from "../../_hooks/g_tb_regimecomunhao/useGTBRegimeComunhaoSaveHook";
|
import { useGTBRegimeComunhaoSaveHook } from '../../_hooks/g_tb_regimecomunhao/useGTBRegimeComunhaoSaveHook';
|
||||||
import { useGTBRegimeComunhaoRemoveHook } from "../../_hooks/g_tb_regimecomunhao/useGTBRegimeComunhaoRemoveHook";
|
import { useGTBRegimeComunhaoRemoveHook } from '../../_hooks/g_tb_regimecomunhao/useGTBRegimeComunhaoRemoveHook';
|
||||||
|
|
||||||
import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog";
|
import ConfirmDialog from '@/app/_components/confirm_dialog/ConfirmDialog';
|
||||||
import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDialog";
|
import { useConfirmDialog } from '@/app/_components/confirm_dialog/useConfirmDialog';
|
||||||
|
|
||||||
import GTBRegimeComunhaoInterface from "../../_interfaces/GTBRegimeComunhaoInterface";
|
import GTBRegimeComunhaoInterface from '../../_interfaces/GTBRegimeComunhaoInterface';
|
||||||
import Header from "@/app/_components/structure/Header";
|
import Header from '@/app/_components/structure/Header';
|
||||||
|
|
||||||
export default function TTBAndamentoServico() {
|
export default function TTBAndamentoServico() {
|
||||||
// Hooks para leitura e salvamento
|
// Hooks para leitura e salvamento
|
||||||
const { gTBRegimeComunhao, fetchGTBRegimeComunhao } =
|
const { gTBRegimeComunhao, fetchGTBRegimeComunhao } = useGTBRegimeComunhaoReadHook();
|
||||||
useGTBRegimeComunhaoReadHook();
|
|
||||||
const { saveGTBRegimeComunhao } = useGTBRegimeComunhaoSaveHook();
|
const { saveGTBRegimeComunhao } = useGTBRegimeComunhaoSaveHook();
|
||||||
const { removeGTBRegimeComunhao } = useGTBRegimeComunhaoRemoveHook();
|
const { removeGTBRegimeComunhao } = useGTBRegimeComunhaoRemoveHook();
|
||||||
|
|
||||||
// Estados
|
// Estados
|
||||||
const [selectedAndamento, setSelectedAndamento] =
|
const [selectedAndamento, setSelectedAndamento] = useState<GTBRegimeComunhaoInterface | null>(
|
||||||
useState<GTBRegimeComunhaoInterface | null>(null);
|
null,
|
||||||
|
);
|
||||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||||
|
|
||||||
// Estado para saber qual item será deletado
|
// Estado para saber qual item será deletado
|
||||||
const [itemToDelete, setItemToDelete] =
|
const [itemToDelete, setItemToDelete] = useState<GTBRegimeComunhaoInterface | null>(null);
|
||||||
useState<GTBRegimeComunhaoInterface | null>(null);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hook do modal de confirmação
|
* 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
|
* Abre o formulário no modo de edição ou criação
|
||||||
*/
|
*/
|
||||||
const handleOpenForm = useCallback(
|
const handleOpenForm = useCallback((data: GTBRegimeComunhaoInterface | null) => {
|
||||||
(data: GTBRegimeComunhaoInterface | null) => {
|
setSelectedAndamento(data);
|
||||||
setSelectedAndamento(data);
|
setIsFormOpen(true);
|
||||||
setIsFormOpen(true);
|
}, []);
|
||||||
},
|
|
||||||
[],
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fecha o formulário e limpa o andamento selecionado
|
* Fecha o formulário e limpa o andamento selecionado
|
||||||
|
|
@ -128,9 +124,9 @@ export default function TTBAndamentoServico() {
|
||||||
<div>
|
<div>
|
||||||
{/* Cabeçalho */}
|
{/* Cabeçalho */}
|
||||||
<Header
|
<Header
|
||||||
title={"Regimes de Comunhão"}
|
title={'Regimes de Comunhão'}
|
||||||
description={"Gerenciamento de Regimes de Comunhão"}
|
description={'Gerenciamento de Regimes de Comunhão'}
|
||||||
buttonText={"Novo Regime"}
|
buttonText={'Novo Regime'}
|
||||||
buttonAction={() => {
|
buttonAction={() => {
|
||||||
handleOpenForm(null);
|
handleOpenForm(null);
|
||||||
}}
|
}}
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,22 @@
|
||||||
"use client";
|
'use client';
|
||||||
|
|
||||||
import { useEffect, useState, useCallback } from "react";
|
import { useEffect, useState, useCallback } from 'react';
|
||||||
import { Card, CardContent } from "@/components/ui/card";
|
import { Card, CardContent } from '@/components/ui/card';
|
||||||
import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDialog";
|
import { useConfirmDialog } from '@/app/_components/confirm_dialog/useConfirmDialog';
|
||||||
|
|
||||||
import Header from "@/app/_components/structure/Header";
|
import Header from '@/app/_components/structure/Header';
|
||||||
import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog";
|
import ConfirmDialog from '@/app/_components/confirm_dialog/ConfirmDialog';
|
||||||
import Loading from "@/app/_components/loading/loading";
|
import Loading from '@/app/_components/loading/loading';
|
||||||
import GTBTipoLogradouroTable from "../../_components/g_tb_tipologradouro/GTBTipoLogradouroTable";
|
import GTBTipoLogradouroTable from '../../_components/g_tb_tipologradouro/GTBTipoLogradouroTable';
|
||||||
import GTBTipoLogradouroForm from "../../_components/g_tb_tipologradouro/GTBTipoLogradouroForm";
|
import GTBTipoLogradouroForm from '../../_components/g_tb_tipologradouro/GTBTipoLogradouroForm';
|
||||||
|
|
||||||
import { useGTBTipoLogradouroReadHook } from "../../_hooks/g_tb_tipologradouro/useGTBTipoLogradouroReadHook";
|
import { useGTBTipoLogradouroReadHook } from '../../_hooks/g_tb_tipologradouro/useGTBTipoLogradouroReadHook';
|
||||||
import { useGTBTipoLogradouroSaveHook } from "../../_hooks/g_tb_tipologradouro/useGTBTipoLogradouroSaveHook";
|
import { useGTBTipoLogradouroSaveHook } from '../../_hooks/g_tb_tipologradouro/useGTBTipoLogradouroSaveHook';
|
||||||
import { useGTBTipoLogradouroRemoveHook } from "../../_hooks/g_tb_tipologradouro/useGTBTipoLogradouroRemoveHook";
|
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() {
|
export default function TTBAndamentoServico() {
|
||||||
// Controle de exibição de respostas
|
// Controle de exibição de respostas
|
||||||
|
|
@ -26,39 +26,31 @@ export default function TTBAndamentoServico() {
|
||||||
const [buttonIsLoading, setButtonIsLoading] = useState(false);
|
const [buttonIsLoading, setButtonIsLoading] = useState(false);
|
||||||
|
|
||||||
// Hooks para leitura e salvamento
|
// Hooks para leitura e salvamento
|
||||||
const { gTBTipoLogradouro, fetchGTBTipoLogradouro } =
|
const { gTBTipoLogradouro, fetchGTBTipoLogradouro } = useGTBTipoLogradouroReadHook();
|
||||||
useGTBTipoLogradouroReadHook();
|
|
||||||
const { saveGTBTipoLogradouro } = useGTBTipoLogradouroSaveHook();
|
const { saveGTBTipoLogradouro } = useGTBTipoLogradouroSaveHook();
|
||||||
const { removeGTBTipoLogradouro } = useGTBTipoLogradouroRemoveHook();
|
const { removeGTBTipoLogradouro } = useGTBTipoLogradouroRemoveHook();
|
||||||
|
|
||||||
// Estados
|
// Estados
|
||||||
const [selectedTipoLogradouro, setTipoLogradouro] =
|
const [selectedTipoLogradouro, setTipoLogradouro] = useState<GTBTipoLogradouroInterface | null>(
|
||||||
useState<GTBTipoLogradouroInterface | null>(null);
|
null,
|
||||||
|
);
|
||||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||||
|
|
||||||
// Estado para saber qual item será deletado
|
// Estado para saber qual item será deletado
|
||||||
const [itemToDelete, setItemToDelete] =
|
const [itemToDelete, setItemToDelete] = useState<GTBTipoLogradouroInterface | null>(null);
|
||||||
useState<GTBTipoLogradouroInterface | null>(null);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hook do modal de confirmação
|
* Hook do modal de confirmação
|
||||||
*/
|
*/
|
||||||
const {
|
const { isOpen: isConfirmOpen, openDialog: openConfirmDialog, handleCancel } = useConfirmDialog();
|
||||||
isOpen: isConfirmOpen,
|
|
||||||
openDialog: openConfirmDialog,
|
|
||||||
handleCancel,
|
|
||||||
} = useConfirmDialog();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abre o formulário no modo de edição ou criação
|
* Abre o formulário no modo de edição ou criação
|
||||||
*/
|
*/
|
||||||
const handleOpenForm = useCallback(
|
const handleOpenForm = useCallback((data: GTBTipoLogradouroInterface | null) => {
|
||||||
(data: GTBTipoLogradouroInterface | null) => {
|
setTipoLogradouro(data);
|
||||||
setTipoLogradouro(data);
|
setIsFormOpen(true);
|
||||||
setIsFormOpen(true);
|
}, []);
|
||||||
},
|
|
||||||
[],
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fecha o formulário e limpa o andamento selecionado
|
* Fecha o formulário e limpa o andamento selecionado
|
||||||
|
|
@ -111,7 +103,7 @@ export default function TTBAndamentoServico() {
|
||||||
// Define os dados da resposta visual
|
// Define os dados da resposta visual
|
||||||
setResponse({
|
setResponse({
|
||||||
status: 400,
|
status: 400,
|
||||||
message: "Não foi informado um registro para exclusão",
|
message: 'Não foi informado um registro para exclusão',
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -147,9 +139,9 @@ export default function TTBAndamentoServico() {
|
||||||
<div>
|
<div>
|
||||||
{/* Cabeçalho */}
|
{/* Cabeçalho */}
|
||||||
<Header
|
<Header
|
||||||
title={"Tipos de Logradouros"}
|
title={'Tipos de Logradouros'}
|
||||||
description={"Gerenciamento de tipos de Logradouros"}
|
description={'Gerenciamento de tipos de Logradouros'}
|
||||||
buttonText={"Novo Tipo"}
|
buttonText={'Novo Tipo'}
|
||||||
buttonAction={() => {
|
buttonAction={() => {
|
||||||
handleOpenForm(null);
|
handleOpenForm(null);
|
||||||
}}
|
}}
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,21 @@
|
||||||
"use client";
|
'use client';
|
||||||
|
|
||||||
import { useEffect, useState, useCallback } from "react";
|
import { useEffect, useState, useCallback } from 'react';
|
||||||
import { Card, CardContent } from "@/components/ui/card";
|
import { Card, CardContent } from '@/components/ui/card';
|
||||||
|
|
||||||
import Loading from "@/app/_components/loading/loading";
|
import Loading from '@/app/_components/loading/loading';
|
||||||
import TCensecTable from "../../_components/t_censec/TCensecTable";
|
import TCensecTable from '../../_components/t_censec/TCensecTable';
|
||||||
import TCensecForm from "../../_components/t_censec/TCensecForm";
|
import TCensecForm from '../../_components/t_censec/TCensecForm';
|
||||||
|
|
||||||
import { useTCensecReadHook } from "../../_hooks/t_censec/useTCensecReadHook";
|
import { useTCensecReadHook } from '../../_hooks/t_censec/useTCensecReadHook';
|
||||||
import { useTCensecSaveHook } from "../../_hooks/t_censec/useTCensecSaveHook";
|
import { useTCensecSaveHook } from '../../_hooks/t_censec/useTCensecSaveHook';
|
||||||
import { useTCensecDeleteHook } from "../../_hooks/t_censec/useTCensecDeleteHook";
|
import { useTCensecDeleteHook } from '../../_hooks/t_censec/useTCensecDeleteHook';
|
||||||
|
|
||||||
import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog";
|
import ConfirmDialog from '@/app/_components/confirm_dialog/ConfirmDialog';
|
||||||
import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDialog";
|
import { useConfirmDialog } from '@/app/_components/confirm_dialog/useConfirmDialog';
|
||||||
|
|
||||||
import TCensecInterface from "../../_interfaces/TCensecInterface";
|
import TCensecInterface from '../../_interfaces/TCensecInterface';
|
||||||
import Header from "@/app/_components/structure/Header";
|
import Header from '@/app/_components/structure/Header';
|
||||||
|
|
||||||
export default function TTBAndamentoServico() {
|
export default function TTBAndamentoServico() {
|
||||||
// Controle de estado do botão
|
// Controle de estado do botão
|
||||||
|
|
@ -27,14 +27,11 @@ export default function TTBAndamentoServico() {
|
||||||
const { deleteTCensec } = useTCensecDeleteHook();
|
const { deleteTCensec } = useTCensecDeleteHook();
|
||||||
|
|
||||||
// Estados
|
// Estados
|
||||||
const [selectedAndamento, setSelectedAndamento] =
|
const [selectedAndamento, setSelectedAndamento] = useState<TCensecInterface | null>(null);
|
||||||
useState<TCensecInterface | null>(null);
|
|
||||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||||
|
|
||||||
// Estado para saber qual item será deletado
|
// Estado para saber qual item será deletado
|
||||||
const [itemToDelete, setItemToDelete] = useState<TCensecInterface | null>(
|
const [itemToDelete, setItemToDelete] = useState<TCensecInterface | null>(null);
|
||||||
null,
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hook do modal de confirmação
|
* Hook do modal de confirmação
|
||||||
|
|
@ -134,9 +131,9 @@ export default function TTBAndamentoServico() {
|
||||||
<div>
|
<div>
|
||||||
{/* Cabeçalho */}
|
{/* Cabeçalho */}
|
||||||
<Header
|
<Header
|
||||||
title={"CENSEC"}
|
title={'CENSEC'}
|
||||||
description={"Gerenciamento de Centrais"}
|
description={'Gerenciamento de Centrais'}
|
||||||
buttonText={"Nova Central"}
|
buttonText={'Nova Central'}
|
||||||
buttonAction={() => {
|
buttonAction={() => {
|
||||||
handleOpenForm(null);
|
handleOpenForm(null);
|
||||||
}}
|
}}
|
||||||
|
|
@ -145,11 +142,7 @@ export default function TTBAndamentoServico() {
|
||||||
{/* Tabela de andamentos */}
|
{/* Tabela de andamentos */}
|
||||||
<Card>
|
<Card>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
<TCensecTable
|
<TCensecTable data={tCensec} onEdit={handleOpenForm} onDelete={handleConfirmDelete} />
|
||||||
data={tCensec}
|
|
||||||
onEdit={handleOpenForm}
|
|
||||||
onDelete={handleConfirmDelete}
|
|
||||||
/>
|
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,27 @@
|
||||||
"use client";
|
'use client';
|
||||||
|
|
||||||
import { useEffect, useState, useCallback } from "react";
|
import { useEffect, useState, useCallback } from 'react';
|
||||||
import { Card, CardContent } from "@/components/ui/card";
|
import { Card, CardContent } from '@/components/ui/card';
|
||||||
import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDialog";
|
import { useConfirmDialog } from '@/app/_components/confirm_dialog/useConfirmDialog';
|
||||||
import { useResponse } from "@/app/_response/ResponseContext";
|
import { useResponse } from '@/app/_response/ResponseContext';
|
||||||
|
|
||||||
import Header from "@/app/_components/structure/Header";
|
import Header from '@/app/_components/structure/Header';
|
||||||
import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog";
|
import ConfirmDialog from '@/app/_components/confirm_dialog/ConfirmDialog';
|
||||||
import Loading from "@/app/_components/loading/loading";
|
import Loading from '@/app/_components/loading/loading';
|
||||||
|
|
||||||
import TCensecNaturezaLitigioTable from "../../_components/t_censecnaturezalitigio/TCensecNaturezaLitigioTable";
|
import TCensecNaturezaLitigioTable from '../../_components/t_censecnaturezalitigio/TCensecNaturezaLitigioTable';
|
||||||
import TCensecNaturezaLitigioForm from "../../_components/t_censecnaturezalitigio/TCensecNaturezaLitigioForm";
|
import TCensecNaturezaLitigioForm from '../../_components/t_censecnaturezalitigio/TCensecNaturezaLitigioForm';
|
||||||
|
|
||||||
import { useTCensecNaturezaLitigioReadHook } from "../../_hooks/t_censecnaturezalitigio/useTCensecNaturezaLitigioReadHook";
|
import { useTCensecNaturezaLitigioReadHook } from '../../_hooks/t_censecnaturezalitigio/useTCensecNaturezaLitigioReadHook';
|
||||||
import { useTCensecNaturezaLitigioSaveHook } from "../../_hooks/t_censecnaturezalitigio/useTCensecNaturezaLitigioSaveHook";
|
import { useTCensecNaturezaLitigioSaveHook } from '../../_hooks/t_censecnaturezalitigio/useTCensecNaturezaLitigioSaveHook';
|
||||||
import { useTCensecNaturezaLitigioRemoveHook } from "../../_hooks/t_censecnaturezalitigio/useTCensecNaturezaLitigioRemoveHook";
|
import { useTCensecNaturezaLitigioRemoveHook } from '../../_hooks/t_censecnaturezalitigio/useTCensecNaturezaLitigioRemoveHook';
|
||||||
|
|
||||||
import { TCensecNaturezaLitigioInterface } from "../../_interfaces/TCensecNaturezaLitigioInterface";
|
import { TCensecNaturezaLitigioInterface } from '../../_interfaces/TCensecNaturezaLitigioInterface';
|
||||||
import { SituacoesEnum } from "@/enums/SituacoesEnum";
|
import { SituacoesEnum } from '@/enums/SituacoesEnum';
|
||||||
|
|
||||||
const initialCensecNaturezaLitigio: TCensecNaturezaLitigioInterface = {
|
const initialCensecNaturezaLitigio: TCensecNaturezaLitigioInterface = {
|
||||||
censec_naturezalitigio_id: 0,
|
censec_naturezalitigio_id: 0,
|
||||||
descricao: "",
|
descricao: '',
|
||||||
situacao: SituacoesEnum.A,
|
situacao: SituacoesEnum.A,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -36,31 +36,21 @@ export default function TCensecNaturezaLitigioPage() {
|
||||||
const { tCensecNaturezaLitigio, fetchTCensecNaturezaLitigio } =
|
const { tCensecNaturezaLitigio, fetchTCensecNaturezaLitigio } =
|
||||||
useTCensecNaturezaLitigioReadHook();
|
useTCensecNaturezaLitigioReadHook();
|
||||||
const { saveTCensecNaturezaLitigio } = useTCensecNaturezaLitigioSaveHook();
|
const { saveTCensecNaturezaLitigio } = useTCensecNaturezaLitigioSaveHook();
|
||||||
const { removeTCensecNaturezaLitigio } =
|
const { removeTCensecNaturezaLitigio } = useTCensecNaturezaLitigioRemoveHook();
|
||||||
useTCensecNaturezaLitigioRemoveHook();
|
|
||||||
|
|
||||||
// Estados
|
// Estados
|
||||||
const [selectedItem, setSelectedItem] =
|
const [selectedItem, setSelectedItem] = useState<TCensecNaturezaLitigioInterface | null>(null);
|
||||||
useState<TCensecNaturezaLitigioInterface | null>(null);
|
|
||||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||||
const [itemToDelete, setItemToDelete] =
|
const [itemToDelete, setItemToDelete] = useState<TCensecNaturezaLitigioInterface | null>(null);
|
||||||
useState<TCensecNaturezaLitigioInterface | null>(null);
|
|
||||||
|
|
||||||
// Modal de confirmação
|
// Modal de confirmação
|
||||||
const {
|
const { isOpen: isConfirmOpen, openDialog: openConfirmDialog, handleCancel } = useConfirmDialog();
|
||||||
isOpen: isConfirmOpen,
|
|
||||||
openDialog: openConfirmDialog,
|
|
||||||
handleCancel,
|
|
||||||
} = useConfirmDialog();
|
|
||||||
|
|
||||||
// Abrir formulário (criação ou edição)
|
// Abrir formulário (criação ou edição)
|
||||||
const handleOpenForm = useCallback(
|
const handleOpenForm = useCallback((item: TCensecNaturezaLitigioInterface | null) => {
|
||||||
(item: TCensecNaturezaLitigioInterface | null) => {
|
setSelectedItem(item);
|
||||||
setSelectedItem(item);
|
setIsFormOpen(true);
|
||||||
setIsFormOpen(true);
|
}, []);
|
||||||
},
|
|
||||||
[],
|
|
||||||
);
|
|
||||||
|
|
||||||
// Fechar formulário
|
// Fechar formulário
|
||||||
const handleCloseForm = useCallback(() => {
|
const handleCloseForm = useCallback(() => {
|
||||||
|
|
@ -96,7 +86,7 @@ export default function TCensecNaturezaLitigioPage() {
|
||||||
// Define os dados da resposta visual
|
// Define os dados da resposta visual
|
||||||
setResponse({
|
setResponse({
|
||||||
status: 400,
|
status: 400,
|
||||||
message: "Não foi informado um registro para exclusão",
|
message: 'Não foi informado um registro para exclusão',
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -121,12 +111,10 @@ export default function TCensecNaturezaLitigioPage() {
|
||||||
<div>
|
<div>
|
||||||
{/* Cabeçalho */}
|
{/* Cabeçalho */}
|
||||||
<Header
|
<Header
|
||||||
title={"Natureza do Litígio"}
|
title={'Natureza do Litígio'}
|
||||||
description={"Gerenciamento de Naturezas do Litígio"}
|
description={'Gerenciamento de Naturezas do Litígio'}
|
||||||
buttonText={"Nova Natureza"}
|
buttonText={'Nova Natureza'}
|
||||||
buttonAction={(data) =>
|
buttonAction={(data) => handleOpenForm((data = initialCensecNaturezaLitigio))}
|
||||||
handleOpenForm((data = initialCensecNaturezaLitigio))
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Tabela */}
|
{/* Tabela */}
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
"use client";
|
'use client';
|
||||||
|
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from 'react';
|
||||||
import { useParams } from "next/navigation";
|
import { useParams } from 'next/navigation';
|
||||||
|
|
||||||
import { Card, CardContent } from "@/components/ui/card";
|
import { Card, CardContent } from '@/components/ui/card';
|
||||||
import MainEditor from "@/components/MainEditor";
|
import MainEditor from '@/components/MainEditor';
|
||||||
|
|
||||||
import Loading from "@/app/_components/loading/loading";
|
import Loading from '@/app/_components/loading/loading';
|
||||||
import { useTMinutaReadHook } from "../../../../_hooks/t_minuta/useTMinutaReadHook";
|
import { useTMinutaReadHook } from '../../../../_hooks/t_minuta/useTMinutaReadHook';
|
||||||
import { TMinutaInterface } from "../../../../_interfaces/TMinutaInterface";
|
import { TMinutaInterface } from '../../../../_interfaces/TMinutaInterface';
|
||||||
|
|
||||||
export default function TMinutaDetalhes() {
|
export default function TMinutaDetalhes() {
|
||||||
const params = useParams();
|
const params = useParams();
|
||||||
|
|
@ -42,16 +42,14 @@ export default function TMinutaDetalhes() {
|
||||||
<div>
|
<div>
|
||||||
<Card>
|
<Card>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
<div className="mb-4 grid gap-4 grid-cols-2">
|
<div className="mb-4 grid grid-cols-2 gap-4">
|
||||||
<div>
|
<div>
|
||||||
<div className="text-2xl font-semibold">Descrição</div>
|
<div className="text-2xl font-semibold">Descrição</div>
|
||||||
<div className="text-xl">{tMinuta.descricao}</div>
|
<div className="text-xl">{tMinuta.descricao}</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<div className="text-2xl font-semibold">Situação</div>
|
<div className="text-2xl font-semibold">Situação</div>
|
||||||
<div className="text-xl">
|
<div className="text-xl">{tMinuta.situacao === 'A' ? 'Ativo' : 'Inativo'}</div>
|
||||||
{tMinuta.situacao === "A" ? "Ativo" : "Inativo"}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div className="col-span-2">
|
<div className="col-span-2">
|
||||||
<div className="text-2xl font-semibold">Texto</div>
|
<div className="text-2xl font-semibold">Texto</div>
|
||||||
|
|
@ -59,10 +57,10 @@ export default function TMinutaDetalhes() {
|
||||||
initialValue={editorContent} // Passa o conteúdo do editor
|
initialValue={editorContent} // Passa o conteúdo do editor
|
||||||
onEditorChange={handleEditorChange} // Função que atualiza o estado
|
onEditorChange={handleEditorChange} // Função que atualiza o estado
|
||||||
margins={{
|
margins={{
|
||||||
top: "2",
|
top: '2',
|
||||||
bottom: "2",
|
bottom: '2',
|
||||||
left: "2",
|
left: '2',
|
||||||
right: "2",
|
right: '2',
|
||||||
}}
|
}}
|
||||||
size={{ width: 794, height: 1123 }} // Você pode ajustar o tamanho aqui
|
size={{ width: 794, height: 1123 }} // Você pode ajustar o tamanho aqui
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
"use client";
|
'use client';
|
||||||
|
|
||||||
import z from "zod";
|
import z from 'zod';
|
||||||
import { useEffect } from "react";
|
import { useEffect } from 'react';
|
||||||
import { useForm, Controller } from "react-hook-form";
|
import { useForm, Controller } from 'react-hook-form';
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from '@hookform/resolvers/zod';
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from '@/components/ui/button';
|
||||||
import { Checkbox } from "@/components/ui/checkbox";
|
import { Checkbox } from '@/components/ui/checkbox';
|
||||||
import {
|
import {
|
||||||
Form,
|
Form,
|
||||||
FormControl,
|
FormControl,
|
||||||
|
|
@ -14,14 +14,14 @@ import {
|
||||||
FormItem,
|
FormItem,
|
||||||
FormLabel,
|
FormLabel,
|
||||||
FormMessage,
|
FormMessage,
|
||||||
} from "@/components/ui/form";
|
} from '@/components/ui/form';
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from '@/components/ui/input';
|
||||||
import { Label } from "@/components/ui/label";
|
import { Label } from '@/components/ui/label';
|
||||||
|
|
||||||
import MainEditor from "@/components/MainEditor";
|
import MainEditor from '@/components/MainEditor';
|
||||||
import { TMinutaSchema } from "../../../_schemas/TMinutaSchema";
|
import { TMinutaSchema } from '../../../_schemas/TMinutaSchema';
|
||||||
import { useTMinutaSaveHook } from "../../../_hooks/t_minuta/useTMinutaSaveHook";
|
import { useTMinutaSaveHook } from '../../../_hooks/t_minuta/useTMinutaSaveHook';
|
||||||
import { Card, CardContent } from "@/components/ui/card";
|
import { Card, CardContent } from '@/components/ui/card';
|
||||||
|
|
||||||
type FormValues = z.infer<typeof TMinutaSchema>;
|
type FormValues = z.infer<typeof TMinutaSchema>;
|
||||||
|
|
||||||
|
|
@ -32,9 +32,9 @@ export default function TMinutaForm() {
|
||||||
resolver: zodResolver(TMinutaSchema),
|
resolver: zodResolver(TMinutaSchema),
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
natureza_id: undefined,
|
natureza_id: undefined,
|
||||||
descricao: "",
|
descricao: '',
|
||||||
situacao: "A",
|
situacao: 'A',
|
||||||
texto: "",
|
texto: '',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -56,10 +56,7 @@ export default function TMinutaForm() {
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>Descrição</FormLabel>
|
<FormLabel>Descrição</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input
|
<Input {...field} placeholder="Digite a descrição da minuta" />
|
||||||
{...field}
|
|
||||||
placeholder="Digite a descrição da minuta"
|
|
||||||
/>
|
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
|
@ -73,12 +70,10 @@ export default function TMinutaForm() {
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<div className="flex items-center space-x-2">
|
<div className="flex items-center space-x-2">
|
||||||
<Checkbox
|
<Checkbox
|
||||||
checked={field.value === "A"}
|
checked={field.value === 'A'}
|
||||||
onCheckedChange={(checked) =>
|
onCheckedChange={(checked) => field.onChange(checked ? 'A' : 'I')}
|
||||||
field.onChange(checked ? "A" : "I")
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
<Label>{field.value === "A" ? "Ativo" : "Inativo"}</Label>
|
<Label>{field.value === 'A' ? 'Ativo' : 'Inativo'}</Label>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|
@ -90,13 +85,13 @@ export default function TMinutaForm() {
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<div>
|
<div>
|
||||||
<MainEditor
|
<MainEditor
|
||||||
initialValue={field.value || ""}
|
initialValue={field.value || ''}
|
||||||
onEditorChange={field.onChange}
|
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 }}
|
size={{ width: 794, height: 1123 }}
|
||||||
/>
|
/>
|
||||||
{form.formState.errors.texto && (
|
{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}
|
{form.formState.errors.texto.message}
|
||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,22 @@
|
||||||
"use client";
|
'use client';
|
||||||
|
|
||||||
import { useEffect, useState, useCallback } from "react";
|
import { useEffect, useState, useCallback } from 'react';
|
||||||
import { Card, CardContent } from "@/components/ui/card";
|
import { Card, CardContent } from '@/components/ui/card';
|
||||||
import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDialog";
|
import { useConfirmDialog } from '@/app/_components/confirm_dialog/useConfirmDialog';
|
||||||
|
|
||||||
import Header from "@/app/_components/structure/Header";
|
import Header from '@/app/_components/structure/Header';
|
||||||
import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog";
|
import ConfirmDialog from '@/app/_components/confirm_dialog/ConfirmDialog';
|
||||||
import Loading from "@/app/_components/loading/loading";
|
import Loading from '@/app/_components/loading/loading';
|
||||||
|
|
||||||
import TMinutaTable from "../../_components/t_minuta/TMinutaTable";
|
import TMinutaTable from '../../_components/t_minuta/TMinutaTable';
|
||||||
import TMinutaForm from "../../_components/t_minuta/TMinutaForm";
|
import TMinutaForm from '../../_components/t_minuta/TMinutaForm';
|
||||||
|
|
||||||
import { useTMinutaReadHook } from "../../_hooks/t_minuta/useTMinutaReadHook";
|
import { useTMinutaReadHook } from '../../_hooks/t_minuta/useTMinutaReadHook';
|
||||||
import { useTMinutaSaveHook } from "../../_hooks/t_minuta/useTMinutaSaveHook";
|
import { useTMinutaSaveHook } from '../../_hooks/t_minuta/useTMinutaSaveHook';
|
||||||
import { useTMinutaRemoveHook } from "../../_hooks/t_minuta/useTMinutaRemoveHook";
|
import { useTMinutaRemoveHook } from '../../_hooks/t_minuta/useTMinutaRemoveHook';
|
||||||
|
|
||||||
import { TMinutaInterface } from "../../_interfaces/TMinutaInterface";
|
import { TMinutaInterface } from '../../_interfaces/TMinutaInterface';
|
||||||
import { useTMinutaIndexHook } from "../../_hooks/t_minuta/useTMinutaIndexHook";
|
import { useTMinutaIndexHook } from '../../_hooks/t_minuta/useTMinutaIndexHook';
|
||||||
|
|
||||||
export default function TMinutaPage() {
|
export default function TMinutaPage() {
|
||||||
// Hooks de leitura e escrita
|
// Hooks de leitura e escrita
|
||||||
|
|
@ -25,13 +25,9 @@ export default function TMinutaPage() {
|
||||||
const { removeTMinuta } = useTMinutaRemoveHook();
|
const { removeTMinuta } = useTMinutaRemoveHook();
|
||||||
|
|
||||||
// Estados
|
// Estados
|
||||||
const [selectedMinuta, setSelectedMinuta] = useState<TMinutaInterface | null>(
|
const [selectedMinuta, setSelectedMinuta] = useState<TMinutaInterface | null>(null);
|
||||||
null,
|
|
||||||
);
|
|
||||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||||
const [itemToDelete, setItemToDelete] = useState<TMinutaInterface | null>(
|
const [itemToDelete, setItemToDelete] = useState<TMinutaInterface | null>(null);
|
||||||
null,
|
|
||||||
);
|
|
||||||
|
|
||||||
// Hook de confirmação
|
// Hook de confirmação
|
||||||
const {
|
const {
|
||||||
|
|
@ -89,11 +85,7 @@ export default function TMinutaPage() {
|
||||||
{/* Tabela */}
|
{/* Tabela */}
|
||||||
<Card>
|
<Card>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
<TMinutaTable
|
<TMinutaTable data={tMinuta} onEdit={handleOpenForm} onDelete={handleConfirmDelete} />
|
||||||
data={tMinuta}
|
|
||||||
onEdit={handleOpenForm}
|
|
||||||
onDelete={handleConfirmDelete}
|
|
||||||
/>
|
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</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 Loading from '@/app/_components/loading/loading';
|
||||||
import TPessoaTable from "../../../_components/t_pessoa/TPessoaTable";
|
import TPessoaTable from '../../../_components/t_pessoa/TPessoaTable';
|
||||||
import TPessoaForm from "../../../_components/t_pessoa/TPessoaForm";
|
import TPessoaForm from '../../../_components/t_pessoa/TPessoaForm';
|
||||||
|
|
||||||
import { useTPessoaIndexHook } from "../../../_hooks/t_pessoa/useTPessoaIndexHook";
|
import { useTPessoaIndexHook } from '../../../_hooks/t_pessoa/useTPessoaIndexHook';
|
||||||
import { useTPessoaSaveHook } from "../../../_hooks/t_pessoa/useTPessoaSaveHook";
|
import { useTPessoaSaveHook } from '../../../_hooks/t_pessoa/useTPessoaSaveHook';
|
||||||
import { useTPessoaDeleteHook } from "../../../_hooks/t_pessoa/useTPessoaDeleteHook";
|
import { useTPessoaDeleteHook } from '../../../_hooks/t_pessoa/useTPessoaDeleteHook';
|
||||||
|
|
||||||
import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog";
|
import ConfirmDialog from '@/app/_components/confirm_dialog/ConfirmDialog';
|
||||||
import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDialog";
|
import { useConfirmDialog } from '@/app/_components/confirm_dialog/useConfirmDialog';
|
||||||
|
|
||||||
import TPessoaInterface from "../../../_interfaces/TPessoaInterface";
|
import TPessoaInterface from '../../../_interfaces/TPessoaInterface';
|
||||||
import Header from "@/app/_components/structure/Header";
|
import Header from '@/app/_components/structure/Header';
|
||||||
|
|
||||||
export default function TPessoaFisica() {
|
export default function TPessoaFisica() {
|
||||||
// Controle de estado do botão
|
// Controle de estado do botão
|
||||||
|
|
@ -26,14 +26,11 @@ export default function TPessoaFisica() {
|
||||||
const { deleteTCensec } = useTPessoaDeleteHook();
|
const { deleteTCensec } = useTPessoaDeleteHook();
|
||||||
|
|
||||||
// Estados
|
// Estados
|
||||||
const [selectedAndamento, setSelectedAndamento] =
|
const [selectedAndamento, setSelectedAndamento] = useState<TPessoaInterface | null>(null);
|
||||||
useState<TPessoaInterface | null>(null);
|
|
||||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||||
|
|
||||||
// Estado para saber qual item será deletado
|
// Estado para saber qual item será deletado
|
||||||
const [itemToDelete, setItemToDelete] = useState<TPessoaInterface | null>(
|
const [itemToDelete, setItemToDelete] = useState<TPessoaInterface | null>(null);
|
||||||
null,
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hook do modal de confirmação
|
* Hook do modal de confirmação
|
||||||
|
|
@ -133,20 +130,16 @@ export default function TPessoaFisica() {
|
||||||
<div>
|
<div>
|
||||||
{/* Cabeçalho */}
|
{/* Cabeçalho */}
|
||||||
<Header
|
<Header
|
||||||
title={"Pessoas Físicas"}
|
title={'Pessoas Físicas'}
|
||||||
description={"Gerenciamento de pessoas físicas"}
|
description={'Gerenciamento de pessoas físicas'}
|
||||||
buttonText={"Nova Pessoa"}
|
buttonText={'Nova Pessoa'}
|
||||||
buttonAction={() => {
|
buttonAction={() => {
|
||||||
handleOpenForm(null);
|
handleOpenForm(null);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Tabela de Registros */}
|
{/* Tabela de Registros */}
|
||||||
<TPessoaTable
|
<TPessoaTable data={tPessoa} onDelete={handleConfirmDelete} onEdit={handleOpenForm} />
|
||||||
data={tPessoa}
|
|
||||||
onDelete={handleConfirmDelete}
|
|
||||||
onEdit={handleOpenForm}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{/* Modal de confirmação */}
|
{/* Modal de confirmação */}
|
||||||
<ConfirmDialog
|
<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 { useTPessoaSaveHook } from '../../../_hooks/t_pessoa/useTPessoaSaveHook';
|
||||||
import { useTPessoaDeleteHook } from "../../../_hooks/t_pessoa/useTPessoaDeleteHook";
|
import { useTPessoaDeleteHook } from '../../../_hooks/t_pessoa/useTPessoaDeleteHook';
|
||||||
|
|
||||||
import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog";
|
import ConfirmDialog from '@/app/_components/confirm_dialog/ConfirmDialog';
|
||||||
import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDialog";
|
import { useConfirmDialog } from '@/app/_components/confirm_dialog/useConfirmDialog';
|
||||||
|
|
||||||
import TPessoaInterface from "../../../_interfaces/TPessoaInterface";
|
import TPessoaInterface from '../../../_interfaces/TPessoaInterface';
|
||||||
import Header from "@/app/_components/structure/Header";
|
import Header from '@/app/_components/structure/Header';
|
||||||
import TPessoaJuridicaTable from "../../../_components/t_pessoa/juridica/TPessoaJuridicaTable";
|
import TPessoaJuridicaTable from '../../../_components/t_pessoa/juridica/TPessoaJuridicaTable';
|
||||||
import { useTPessoaJuridicaIndexHook } from "../../../_hooks/t_pessoa/juridica/useTPessoaJuridicaIndexHook";
|
import { useTPessoaJuridicaIndexHook } from '../../../_hooks/t_pessoa/juridica/useTPessoaJuridicaIndexHook';
|
||||||
import TPessoaJuridicaForm from "../../../_components/t_pessoa/juridica/TPessoaJuridicaForm";
|
import TPessoaJuridicaForm from '../../../_components/t_pessoa/juridica/TPessoaJuridicaForm';
|
||||||
|
|
||||||
export default function TPessoaFisica() {
|
export default function TPessoaFisica() {
|
||||||
// Controle de estado do botão
|
// Controle de estado do botão
|
||||||
|
|
@ -26,14 +26,11 @@ export default function TPessoaFisica() {
|
||||||
const { deleteTCensec } = useTPessoaDeleteHook();
|
const { deleteTCensec } = useTPessoaDeleteHook();
|
||||||
|
|
||||||
// Estados
|
// Estados
|
||||||
const [selectedAndamento, setSelectedAndamento] =
|
const [selectedAndamento, setSelectedAndamento] = useState<TPessoaInterface | null>(null);
|
||||||
useState<TPessoaInterface | null>(null);
|
|
||||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||||
|
|
||||||
// Estado para saber qual item será deletado
|
// Estado para saber qual item será deletado
|
||||||
const [itemToDelete, setItemToDelete] = useState<TPessoaInterface | null>(
|
const [itemToDelete, setItemToDelete] = useState<TPessoaInterface | null>(null);
|
||||||
null,
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hook do modal de confirmação
|
* Hook do modal de confirmação
|
||||||
|
|
@ -133,20 +130,16 @@ export default function TPessoaFisica() {
|
||||||
<div>
|
<div>
|
||||||
{/* Cabeçalho */}
|
{/* Cabeçalho */}
|
||||||
<Header
|
<Header
|
||||||
title={"Pessoas Jurídicas"}
|
title={'Pessoas Jurídicas'}
|
||||||
description={"Gerenciamento de pessoas jurídicas"}
|
description={'Gerenciamento de pessoas jurídicas'}
|
||||||
buttonText={"Nova Pessoa"}
|
buttonText={'Nova Pessoa'}
|
||||||
buttonAction={() => {
|
buttonAction={() => {
|
||||||
handleOpenForm(null);
|
handleOpenForm(null);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Tabela de Registros */}
|
{/* Tabela de Registros */}
|
||||||
<TPessoaJuridicaTable
|
<TPessoaJuridicaTable data={tPessoa} onDelete={handleConfirmDelete} onEdit={handleOpenForm} />
|
||||||
data={tPessoa}
|
|
||||||
onDelete={handleConfirmDelete}
|
|
||||||
onEdit={handleOpenForm}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{/* Modal de confirmação */}
|
{/* Modal de confirmação */}
|
||||||
<ConfirmDialog
|
<ConfirmDialog
|
||||||
|
|
|
||||||
|
|
@ -1,37 +1,36 @@
|
||||||
"use client";
|
'use client';
|
||||||
|
|
||||||
import { useEffect, useState, useCallback } from "react";
|
import { useEffect, useState, useCallback } from 'react';
|
||||||
import { Card, CardContent } from "@/components/ui/card";
|
import { Card, CardContent } from '@/components/ui/card';
|
||||||
|
|
||||||
import Loading from "@/app/_components/loading/loading";
|
import Loading from '@/app/_components/loading/loading';
|
||||||
import TTBAndamentoServicoTable from "../../_components/t_tb_andamentoservico/TTBAndamentoServicoTable";
|
import TTBAndamentoServicoTable from '../../_components/t_tb_andamentoservico/TTBAndamentoServicoTable';
|
||||||
import TTBAndamentoServicoForm from "../../_components/t_tb_andamentoservico/TTBAndamentoServicoForm";
|
import TTBAndamentoServicoForm from '../../_components/t_tb_andamentoservico/TTBAndamentoServicoForm';
|
||||||
|
|
||||||
import { useTTBAndamentoServicoReadHook } from "../../_hooks/t_tb_andamentoservico/useTTBAndamentoServicoReadHook";
|
import { useTTBAndamentoServicoReadHook } from '../../_hooks/t_tb_andamentoservico/useTTBAndamentoServicoReadHook';
|
||||||
import { useTTBAndamentoServicoSaveHook } from "../../_hooks/t_tb_andamentoservico/useTTBAndamentoServicoSaveHook";
|
import { useTTBAndamentoServicoSaveHook } from '../../_hooks/t_tb_andamentoservico/useTTBAndamentoServicoSaveHook';
|
||||||
|
|
||||||
import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog";
|
import ConfirmDialog from '@/app/_components/confirm_dialog/ConfirmDialog';
|
||||||
import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDialog";
|
import { useConfirmDialog } from '@/app/_components/confirm_dialog/useConfirmDialog';
|
||||||
|
|
||||||
import TTBAndamentoServicoInterface from "../../_interfaces/TTBAndamentoServicoInterface";
|
import TTBAndamentoServicoInterface from '../../_interfaces/TTBAndamentoServicoInterface';
|
||||||
import { useTTBAndamentoServicoDeleteHook } from "../../_hooks/t_tb_andamentoservico/useTTBAndamentoServicoDeleteHook";
|
import { useTTBAndamentoServicoDeleteHook } from '../../_hooks/t_tb_andamentoservico/useTTBAndamentoServicoDeleteHook';
|
||||||
import Header from "@/app/_components/structure/Header";
|
import Header from '@/app/_components/structure/Header';
|
||||||
|
|
||||||
export default function TTBAndamentoServico() {
|
export default function TTBAndamentoServico() {
|
||||||
// Hooks para leitura e salvamento
|
// Hooks para leitura e salvamento
|
||||||
const { tTBAndamentosServicos, fetchTTBAndamentoServico } =
|
const { tTBAndamentosServicos, fetchTTBAndamentoServico } = useTTBAndamentoServicoReadHook();
|
||||||
useTTBAndamentoServicoReadHook();
|
|
||||||
const { saveTTBAndamentoServico } = useTTBAndamentoServicoSaveHook();
|
const { saveTTBAndamentoServico } = useTTBAndamentoServicoSaveHook();
|
||||||
const { deleteTTBAndamentoServico } = useTTBAndamentoServicoDeleteHook();
|
const { deleteTTBAndamentoServico } = useTTBAndamentoServicoDeleteHook();
|
||||||
|
|
||||||
// Estados
|
// Estados
|
||||||
const [selectedAndamento, setSelectedAndamento] =
|
const [selectedAndamento, setSelectedAndamento] = useState<TTBAndamentoServicoInterface | null>(
|
||||||
useState<TTBAndamentoServicoInterface | null>(null);
|
null,
|
||||||
|
);
|
||||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||||
|
|
||||||
// Estado para saber qual item será deletado
|
// Estado para saber qual item será deletado
|
||||||
const [itemToDelete, setItemToDelete] =
|
const [itemToDelete, setItemToDelete] = useState<TTBAndamentoServicoInterface | null>(null);
|
||||||
useState<TTBAndamentoServicoInterface | null>(null);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hook do modal de confirmação
|
* 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
|
* Abre o formulário no modo de edição ou criação
|
||||||
*/
|
*/
|
||||||
const handleOpenForm = useCallback(
|
const handleOpenForm = useCallback((data: TTBAndamentoServicoInterface | null) => {
|
||||||
(data: TTBAndamentoServicoInterface | null) => {
|
setSelectedAndamento(data);
|
||||||
setSelectedAndamento(data);
|
setIsFormOpen(true);
|
||||||
setIsFormOpen(true);
|
}, []);
|
||||||
},
|
|
||||||
[],
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fecha o formulário e limpa o andamento selecionado
|
* Fecha o formulário e limpa o andamento selecionado
|
||||||
|
|
@ -125,9 +121,9 @@ export default function TTBAndamentoServico() {
|
||||||
<div>
|
<div>
|
||||||
{/* Cabeçalho */}
|
{/* Cabeçalho */}
|
||||||
<Header
|
<Header
|
||||||
title={"Andamentos"}
|
title={'Andamentos'}
|
||||||
description={"Gerenciamento de Andamentos de Atos"}
|
description={'Gerenciamento de Andamentos de Atos'}
|
||||||
buttonText={"Novo Andamento"}
|
buttonText={'Novo Andamento'}
|
||||||
buttonAction={() => {
|
buttonAction={() => {
|
||||||
handleOpenForm(null);
|
handleOpenForm(null);
|
||||||
}}
|
}}
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,21 @@
|
||||||
"use client";
|
'use client';
|
||||||
|
|
||||||
import { useEffect, useState, useCallback } from "react";
|
import { useEffect, useState, useCallback } from 'react';
|
||||||
import { Card, CardContent } from "@/components/ui/card";
|
import { Card, CardContent } from '@/components/ui/card';
|
||||||
|
|
||||||
import Loading from "@/app/_components/loading/loading";
|
import Loading from '@/app/_components/loading/loading';
|
||||||
import Header from "@/app/_components/structure/Header";
|
import Header from '@/app/_components/structure/Header';
|
||||||
import TTBReconhecimentoTipoTable from "../../_components/t_tb_reconhecimentotipo/TTBReconhecimentoTipoTable";
|
import TTBReconhecimentoTipoTable from '../../_components/t_tb_reconhecimentotipo/TTBReconhecimentoTipoTable';
|
||||||
import TTBReconhecimentoTipoForm from "../../_components/t_tb_reconhecimentotipo/TTBReconhecimentoTipoForm";
|
import TTBReconhecimentoTipoForm from '../../_components/t_tb_reconhecimentotipo/TTBReconhecimentoTipoForm';
|
||||||
|
|
||||||
import { useTTBReconhecimentoTipoReadHook } from "../../_hooks/t_tb_reconhecimentotipo/useTTBReconhecimentoTipoReadHook";
|
import { useTTBReconhecimentoTipoReadHook } from '../../_hooks/t_tb_reconhecimentotipo/useTTBReconhecimentoTipoReadHook';
|
||||||
import { useTTBReconhecimentoTipoSaveHook } from "../../_hooks/t_tb_reconhecimentotipo/useTTBReconhecimentoTipoSaveHook";
|
import { useTTBReconhecimentoTipoSaveHook } from '../../_hooks/t_tb_reconhecimentotipo/useTTBReconhecimentoTipoSaveHook';
|
||||||
import { useTTBReconhecimentoTipoDeleteHook } from "../../_hooks/t_tb_reconhecimentotipo/useTTBReconhecimentoTipoDeleteHook";
|
import { useTTBReconhecimentoTipoDeleteHook } from '../../_hooks/t_tb_reconhecimentotipo/useTTBReconhecimentoTipoDeleteHook';
|
||||||
|
|
||||||
import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog";
|
import ConfirmDialog from '@/app/_components/confirm_dialog/ConfirmDialog';
|
||||||
import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDialog";
|
import { useConfirmDialog } from '@/app/_components/confirm_dialog/useConfirmDialog';
|
||||||
|
|
||||||
import TTBReconhecimentoTipoInterface from "../../_interfaces/TTBReconhecimentoTipoInterface";
|
import TTBReconhecimentoTipoInterface from '../../_interfaces/TTBReconhecimentoTipoInterface';
|
||||||
|
|
||||||
export default function TTBAndamentoServico() {
|
export default function TTBAndamentoServico() {
|
||||||
// Hooks para leitura e salvamento
|
// Hooks para leitura e salvamento
|
||||||
|
|
@ -30,8 +30,7 @@ export default function TTBAndamentoServico() {
|
||||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||||
|
|
||||||
// Estado para saber qual item será deletado
|
// Estado para saber qual item será deletado
|
||||||
const [itemToDelete, setItemToDelete] =
|
const [itemToDelete, setItemToDelete] = useState<TTBReconhecimentoTipoInterface | null>(null);
|
||||||
useState<TTBReconhecimentoTipoInterface | null>(null);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hook do modal de confirmação
|
* 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
|
* Abre o formulário no modo de edição ou criação
|
||||||
*/
|
*/
|
||||||
const handleOpenForm = useCallback(
|
const handleOpenForm = useCallback((data: TTBReconhecimentoTipoInterface | null) => {
|
||||||
(data: TTBReconhecimentoTipoInterface | null) => {
|
setReconhecimentoTipo(data);
|
||||||
setReconhecimentoTipo(data);
|
setIsFormOpen(true);
|
||||||
setIsFormOpen(true);
|
}, []);
|
||||||
},
|
|
||||||
[],
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fecha o formulário e limpa o andamento selecionado
|
* Fecha o formulário e limpa o andamento selecionado
|
||||||
|
|
@ -128,9 +124,9 @@ export default function TTBAndamentoServico() {
|
||||||
<div>
|
<div>
|
||||||
{/* Cabeçalho */}
|
{/* Cabeçalho */}
|
||||||
<Header
|
<Header
|
||||||
title={"Reconhecimentos"}
|
title={'Reconhecimentos'}
|
||||||
description={"Gerenciamento de tipos de reconhecimentos"}
|
description={'Gerenciamento de tipos de reconhecimentos'}
|
||||||
buttonText={"Novo Tipo"}
|
buttonText={'Novo Tipo'}
|
||||||
buttonAction={() => {
|
buttonAction={() => {
|
||||||
handleOpenForm(null);
|
handleOpenForm(null);
|
||||||
}}
|
}}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
"use client";
|
'use client';
|
||||||
|
|
||||||
import z from "zod";
|
import z from 'zod';
|
||||||
import { useForm } from "react-hook-form";
|
import { useForm } from 'react-hook-form';
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from '@hookform/resolvers/zod';
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from '@/components/ui/button';
|
||||||
import {
|
import {
|
||||||
Dialog,
|
Dialog,
|
||||||
DialogClose,
|
DialogClose,
|
||||||
|
|
@ -13,7 +13,7 @@ import {
|
||||||
DialogFooter,
|
DialogFooter,
|
||||||
DialogHeader,
|
DialogHeader,
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
} from "@/components/ui/dialog";
|
} from '@/components/ui/dialog';
|
||||||
import {
|
import {
|
||||||
Form,
|
Form,
|
||||||
FormControl,
|
FormControl,
|
||||||
|
|
@ -21,21 +21,21 @@ import {
|
||||||
FormItem,
|
FormItem,
|
||||||
FormLabel,
|
FormLabel,
|
||||||
FormMessage,
|
FormMessage,
|
||||||
} from "@/components/ui/form";
|
} from '@/components/ui/form';
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from '@/components/ui/input';
|
||||||
|
|
||||||
import { GCidadeSchema } from "../../_schemas/GCidadeSchema";
|
import { GCidadeSchema } from '../../_schemas/GCidadeSchema';
|
||||||
import { useEffect } from "react";
|
import { useEffect } from 'react';
|
||||||
|
|
||||||
// Hook responsável em trazer todos os estados brasileiros
|
// Hook responsável em trazer todos os estados brasileiros
|
||||||
import { useGUfReadHook } from "../../_hooks/g_uf/useGUfReadHook";
|
import { useGUfReadHook } from '../../_hooks/g_uf/useGUfReadHook';
|
||||||
import {
|
import {
|
||||||
Select,
|
Select,
|
||||||
SelectContent,
|
SelectContent,
|
||||||
SelectItem,
|
SelectItem,
|
||||||
SelectTrigger,
|
SelectTrigger,
|
||||||
SelectValue,
|
SelectValue,
|
||||||
} from "@/components/ui/select";
|
} from '@/components/ui/select';
|
||||||
|
|
||||||
// Define o tipo do formulário com base no schema Zod
|
// Define o tipo do formulário com base no schema Zod
|
||||||
type FormValues = z.infer<typeof GCidadeSchema>;
|
type FormValues = z.infer<typeof GCidadeSchema>;
|
||||||
|
|
@ -58,10 +58,10 @@ export default function GCidadeForm({ isOpen, data, onClose, onSave }: Props) {
|
||||||
resolver: zodResolver(GCidadeSchema),
|
resolver: zodResolver(GCidadeSchema),
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
cidade_id: 0,
|
cidade_id: 0,
|
||||||
uf: "",
|
uf: '',
|
||||||
cidade_nome: "",
|
cidade_nome: '',
|
||||||
codigo_ibge: "",
|
codigo_ibge: '',
|
||||||
codigo_gyn: "",
|
codigo_gyn: '',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -146,10 +146,7 @@ export default function GCidadeForm({ isOpen, data, onClose, onSave }: Props) {
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
{gUf.map((item) => (
|
{gUf.map((item) => (
|
||||||
<SelectItem
|
<SelectItem key={item.g_uf_id} value={String(item.sigla)}>
|
||||||
key={item.g_uf_id}
|
|
||||||
value={String(item.sigla)}
|
|
||||||
>
|
|
||||||
{item.nome}
|
{item.nome}
|
||||||
</SelectItem>
|
</SelectItem>
|
||||||
))}
|
))}
|
||||||
|
|
@ -181,7 +178,7 @@ export default function GCidadeForm({ isOpen, data, onClose, onSave }: Props) {
|
||||||
</DialogFooter>
|
</DialogFooter>
|
||||||
|
|
||||||
{/* Campo oculto: ID da cidade */}
|
{/* Campo oculto: ID da cidade */}
|
||||||
<input type="hidden" {...form.register("cidade_id")} />
|
<input type="hidden" {...form.register('cidade_id')} />
|
||||||
</form>
|
</form>
|
||||||
</Form>
|
</Form>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
"use client";
|
'use client';
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from '@/components/ui/button';
|
||||||
import {
|
import {
|
||||||
DropdownMenu,
|
DropdownMenu,
|
||||||
DropdownMenuContent,
|
DropdownMenuContent,
|
||||||
|
|
@ -8,7 +8,7 @@ import {
|
||||||
DropdownMenuItem,
|
DropdownMenuItem,
|
||||||
DropdownMenuSeparator,
|
DropdownMenuSeparator,
|
||||||
DropdownMenuTrigger,
|
DropdownMenuTrigger,
|
||||||
} from "@/components/ui/dropdown-menu";
|
} from '@/components/ui/dropdown-menu';
|
||||||
import {
|
import {
|
||||||
Table,
|
Table,
|
||||||
TableBody,
|
TableBody,
|
||||||
|
|
@ -16,10 +16,10 @@ import {
|
||||||
TableHead,
|
TableHead,
|
||||||
TableHeader,
|
TableHeader,
|
||||||
TableRow,
|
TableRow,
|
||||||
} from "@/components/ui/table";
|
} from '@/components/ui/table';
|
||||||
|
|
||||||
import { EllipsisIcon, PencilIcon, Trash2Icon } from "lucide-react";
|
import { EllipsisIcon, PencilIcon, Trash2Icon } from 'lucide-react';
|
||||||
import GCidadeInterface from "../../_interfaces/GCidadeInterface";
|
import GCidadeInterface from '../../_interfaces/GCidadeInterface';
|
||||||
|
|
||||||
// Tipagem das props do componente da tabela
|
// Tipagem das props do componente da tabela
|
||||||
interface GCidadeTableProps {
|
interface GCidadeTableProps {
|
||||||
|
|
@ -32,25 +32,21 @@ interface GCidadeTableProps {
|
||||||
* Renderiza o "badge" de status da cidade (Ativo/Inativo)
|
* Renderiza o "badge" de status da cidade (Ativo/Inativo)
|
||||||
*/
|
*/
|
||||||
function StatusBadge({ situacao }: { situacao: string }) {
|
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
|
// 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
|
// Estilo para ativo
|
||||||
const activeClasses =
|
const activeClasses = 'bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-300';
|
||||||
"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-300";
|
|
||||||
|
|
||||||
// Estilo para inativo
|
// Estilo para inativo
|
||||||
const inactiveClasses =
|
const inactiveClasses = 'bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300';
|
||||||
"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300";
|
|
||||||
|
|
||||||
// Retorna o badge com classe condicional
|
// Retorna o badge com classe condicional
|
||||||
return (
|
return (
|
||||||
<span
|
<span className={`${baseClasses} ${isActive ? activeClasses : inactiveClasses}`}>
|
||||||
className={`${baseClasses} ${isActive ? activeClasses : inactiveClasses}`}
|
{isActive ? 'Ativo' : 'Inativo'}
|
||||||
>
|
|
||||||
{isActive ? "Ativo" : "Inativo"}
|
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -58,13 +54,9 @@ function StatusBadge({ situacao }: { situacao: string }) {
|
||||||
/**
|
/**
|
||||||
* Componente principal da tabela de cidades
|
* Componente principal da tabela de cidades
|
||||||
*/
|
*/
|
||||||
export default function GCidadeTable({
|
export default function GCidadeTable({ data, onEdit, onDelete }: GCidadeTableProps) {
|
||||||
data,
|
|
||||||
onEdit,
|
|
||||||
onDelete,
|
|
||||||
}: GCidadeTableProps) {
|
|
||||||
return (
|
return (
|
||||||
<Table className="table-fixed w-full">
|
<Table className="w-full table-fixed">
|
||||||
{/* Cabeçalho da tabela */}
|
{/* Cabeçalho da tabela */}
|
||||||
<TableHeader>
|
<TableHeader>
|
||||||
<TableRow>
|
<TableRow>
|
||||||
|
|
@ -97,11 +89,7 @@ export default function GCidadeTable({
|
||||||
<DropdownMenu>
|
<DropdownMenu>
|
||||||
{/* Botão de disparo do menu */}
|
{/* Botão de disparo do menu */}
|
||||||
<DropdownMenuTrigger asChild>
|
<DropdownMenuTrigger asChild>
|
||||||
<Button
|
<Button variant="outline" size="icon" className="cursor-pointer">
|
||||||
variant="outline"
|
|
||||||
size="icon"
|
|
||||||
className="cursor-pointer"
|
|
||||||
>
|
|
||||||
<EllipsisIcon />
|
<EllipsisIcon />
|
||||||
</Button>
|
</Button>
|
||||||
</DropdownMenuTrigger>
|
</DropdownMenuTrigger>
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
"use client";
|
'use client';
|
||||||
|
|
||||||
import z from "zod";
|
import z from 'zod';
|
||||||
import { useEffect } from "react";
|
import { useEffect } from 'react';
|
||||||
import { useForm } from "react-hook-form";
|
import { useForm } from 'react-hook-form';
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from '@hookform/resolvers/zod';
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from '@/components/ui/button';
|
||||||
import {
|
import {
|
||||||
Dialog,
|
Dialog,
|
||||||
DialogClose,
|
DialogClose,
|
||||||
|
|
@ -14,7 +14,7 @@ import {
|
||||||
DialogFooter,
|
DialogFooter,
|
||||||
DialogHeader,
|
DialogHeader,
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
} from "@/components/ui/dialog";
|
} from '@/components/ui/dialog';
|
||||||
import {
|
import {
|
||||||
Form,
|
Form,
|
||||||
FormControl,
|
FormControl,
|
||||||
|
|
@ -22,11 +22,11 @@ import {
|
||||||
FormItem,
|
FormItem,
|
||||||
FormLabel,
|
FormLabel,
|
||||||
FormMessage,
|
FormMessage,
|
||||||
} from "@/components/ui/form";
|
} from '@/components/ui/form';
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from '@/components/ui/input';
|
||||||
import LoadingButton from "@/app/_components/loadingButton/LoadingButton";
|
import LoadingButton from '@/app/_components/loadingButton/LoadingButton';
|
||||||
import { GMedidaTipoSchema } from "../../_schemas/GMedidaTipoSchema";
|
import { GMedidaTipoSchema } from '../../_schemas/GMedidaTipoSchema';
|
||||||
import { GMedidaTipoInterface } from "../../_interfaces/GMedidaTipoInterface";
|
import { GMedidaTipoInterface } from '../../_interfaces/GMedidaTipoInterface';
|
||||||
|
|
||||||
type FormValues = z.infer<typeof GMedidaTipoSchema>;
|
type FormValues = z.infer<typeof GMedidaTipoSchema>;
|
||||||
|
|
||||||
|
|
@ -50,8 +50,8 @@ export default function GMedidaTipoForm({
|
||||||
resolver: zodResolver(GMedidaTipoSchema),
|
resolver: zodResolver(GMedidaTipoSchema),
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
medida_tipo_id: 0,
|
medida_tipo_id: 0,
|
||||||
sigla: "",
|
sigla: '',
|
||||||
descricao: "",
|
descricao: '',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -127,7 +127,7 @@ export default function GMedidaTipoForm({
|
||||||
</DialogFooter>
|
</DialogFooter>
|
||||||
|
|
||||||
{/* Campo oculto */}
|
{/* Campo oculto */}
|
||||||
<input type="hidden" {...form.register("medida_tipo_id")} />
|
<input type="hidden" {...form.register('medida_tipo_id')} />
|
||||||
</form>
|
</form>
|
||||||
</Form>
|
</Form>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
"use client";
|
'use client';
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from '@/components/ui/button';
|
||||||
import {
|
import {
|
||||||
DropdownMenu,
|
DropdownMenu,
|
||||||
DropdownMenuContent,
|
DropdownMenuContent,
|
||||||
|
|
@ -8,7 +8,7 @@ import {
|
||||||
DropdownMenuItem,
|
DropdownMenuItem,
|
||||||
DropdownMenuSeparator,
|
DropdownMenuSeparator,
|
||||||
DropdownMenuTrigger,
|
DropdownMenuTrigger,
|
||||||
} from "@/components/ui/dropdown-menu";
|
} from '@/components/ui/dropdown-menu';
|
||||||
import {
|
import {
|
||||||
Table,
|
Table,
|
||||||
TableBody,
|
TableBody,
|
||||||
|
|
@ -16,9 +16,9 @@ import {
|
||||||
TableHead,
|
TableHead,
|
||||||
TableHeader,
|
TableHeader,
|
||||||
TableRow,
|
TableRow,
|
||||||
} from "@/components/ui/table";
|
} from '@/components/ui/table';
|
||||||
import { EllipsisIcon, PencilIcon, Trash2Icon } from "lucide-react";
|
import { EllipsisIcon, PencilIcon, Trash2Icon } from 'lucide-react';
|
||||||
import { GMedidaTipoInterface } from "../../_interfaces/GMedidaTipoInterface";
|
import { GMedidaTipoInterface } from '../../_interfaces/GMedidaTipoInterface';
|
||||||
|
|
||||||
interface GMedidaTipoTableProps {
|
interface GMedidaTipoTableProps {
|
||||||
data: GMedidaTipoInterface[];
|
data: GMedidaTipoInterface[];
|
||||||
|
|
@ -26,11 +26,7 @@ interface GMedidaTipoTableProps {
|
||||||
onDelete: (item: GMedidaTipoInterface, isEditingFormStatus: boolean) => void;
|
onDelete: (item: GMedidaTipoInterface, isEditingFormStatus: boolean) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function GMedidaTipoTable({
|
export default function GMedidaTipoTable({ data, onEdit, onDelete }: GMedidaTipoTableProps) {
|
||||||
data,
|
|
||||||
onEdit,
|
|
||||||
onDelete,
|
|
||||||
}: GMedidaTipoTableProps) {
|
|
||||||
return (
|
return (
|
||||||
<Table>
|
<Table>
|
||||||
<TableHeader>
|
<TableHeader>
|
||||||
|
|
@ -51,11 +47,7 @@ export default function GMedidaTipoTable({
|
||||||
<TableCell className="text-right">
|
<TableCell className="text-right">
|
||||||
<DropdownMenu>
|
<DropdownMenu>
|
||||||
<DropdownMenuTrigger asChild>
|
<DropdownMenuTrigger asChild>
|
||||||
<Button
|
<Button variant="outline" size="icon" className="cursor-pointer">
|
||||||
variant="outline"
|
|
||||||
size="icon"
|
|
||||||
className="cursor-pointer"
|
|
||||||
>
|
|
||||||
<EllipsisIcon />
|
<EllipsisIcon />
|
||||||
</Button>
|
</Button>
|
||||||
</DropdownMenuTrigger>
|
</DropdownMenuTrigger>
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
"use client";
|
'use client';
|
||||||
|
|
||||||
import z from "zod";
|
import z from 'zod';
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from 'react';
|
||||||
import { useForm, Controller } from "react-hook-form";
|
import { useForm, Controller } from 'react-hook-form';
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from '@hookform/resolvers/zod';
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from '@/components/ui/button';
|
||||||
import { Checkbox } from "@/components/ui/checkbox";
|
import { Checkbox } from '@/components/ui/checkbox';
|
||||||
import {
|
import {
|
||||||
Dialog,
|
Dialog,
|
||||||
DialogClose,
|
DialogClose,
|
||||||
|
|
@ -15,7 +15,7 @@ import {
|
||||||
DialogFooter,
|
DialogFooter,
|
||||||
DialogHeader,
|
DialogHeader,
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
} from "@/components/ui/dialog";
|
} from '@/components/ui/dialog';
|
||||||
import {
|
import {
|
||||||
Form,
|
Form,
|
||||||
FormControl,
|
FormControl,
|
||||||
|
|
@ -23,13 +23,13 @@ import {
|
||||||
FormItem,
|
FormItem,
|
||||||
FormLabel,
|
FormLabel,
|
||||||
FormMessage,
|
FormMessage,
|
||||||
} from "@/components/ui/form";
|
} from '@/components/ui/form';
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from '@/components/ui/input';
|
||||||
import { Label } from "@/components/ui/label";
|
import { Label } from '@/components/ui/label';
|
||||||
|
|
||||||
import { GTBBairroSchema } from "../../_schemas/GTBBairroSchema";
|
import { GTBBairroSchema } from '../../_schemas/GTBBairroSchema';
|
||||||
import LoadingButton from "@/app/_components/loadingButton/LoadingButton";
|
import LoadingButton from '@/app/_components/loadingButton/LoadingButton';
|
||||||
import { SituacoesEnum } from "@/enums/SituacoesEnum";
|
import { SituacoesEnum } from '@/enums/SituacoesEnum';
|
||||||
|
|
||||||
type FormValues = z.infer<typeof GTBBairroSchema>;
|
type FormValues = z.infer<typeof GTBBairroSchema>;
|
||||||
|
|
||||||
|
|
@ -54,7 +54,7 @@ export default function GTBBairroForm({
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
sistema_id: null,
|
sistema_id: null,
|
||||||
tb_bairro_id: 0,
|
tb_bairro_id: 0,
|
||||||
descricao: "",
|
descricao: '',
|
||||||
situacao: SituacoesEnum.A,
|
situacao: SituacoesEnum.A,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
@ -87,10 +87,7 @@ export default function GTBBairroForm({
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>Descrição</FormLabel>
|
<FormLabel>Descrição</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input
|
<Input {...field} placeholder="Digite a descrição do bairro" />
|
||||||
{...field}
|
|
||||||
placeholder="Digite a descrição do bairro"
|
|
||||||
/>
|
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
|
@ -104,10 +101,8 @@ export default function GTBBairroForm({
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<div className="flex items-center space-x-2">
|
<div className="flex items-center space-x-2">
|
||||||
<Checkbox
|
<Checkbox
|
||||||
checked={field.value === "A"}
|
checked={field.value === 'A'}
|
||||||
onCheckedChange={(checked) =>
|
onCheckedChange={(checked) => field.onChange(checked ? 'A' : 'I')}
|
||||||
field.onChange(checked ? "A" : "I")
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
<Label>Ativo</Label>
|
<Label>Ativo</Label>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -136,8 +131,8 @@ export default function GTBBairroForm({
|
||||||
</DialogFooter>
|
</DialogFooter>
|
||||||
|
|
||||||
{/* Campos ocultos */}
|
{/* Campos ocultos */}
|
||||||
<input type="hidden" {...form.register("tb_bairro_id")} />
|
<input type="hidden" {...form.register('tb_bairro_id')} />
|
||||||
<input type="hidden" {...form.register("sistema_id")} />
|
<input type="hidden" {...form.register('sistema_id')} />
|
||||||
</form>
|
</form>
|
||||||
</Form>
|
</Form>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
"use client";
|
'use client';
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from '@/components/ui/button';
|
||||||
import {
|
import {
|
||||||
DropdownMenu,
|
DropdownMenu,
|
||||||
DropdownMenuContent,
|
DropdownMenuContent,
|
||||||
|
|
@ -8,7 +8,7 @@ import {
|
||||||
DropdownMenuItem,
|
DropdownMenuItem,
|
||||||
DropdownMenuSeparator,
|
DropdownMenuSeparator,
|
||||||
DropdownMenuTrigger,
|
DropdownMenuTrigger,
|
||||||
} from "@/components/ui/dropdown-menu";
|
} from '@/components/ui/dropdown-menu';
|
||||||
import {
|
import {
|
||||||
Table,
|
Table,
|
||||||
TableBody,
|
TableBody,
|
||||||
|
|
@ -16,9 +16,9 @@ import {
|
||||||
TableHead,
|
TableHead,
|
||||||
TableHeader,
|
TableHeader,
|
||||||
TableRow,
|
TableRow,
|
||||||
} from "@/components/ui/table";
|
} from '@/components/ui/table';
|
||||||
import { EllipsisIcon, PencilIcon, Trash2Icon } from "lucide-react";
|
import { EllipsisIcon, PencilIcon, Trash2Icon } from 'lucide-react';
|
||||||
import { GTBBairroInterface } from "../../_interfaces/GTBBairroInterface";
|
import { GTBBairroInterface } from '../../_interfaces/GTBBairroInterface';
|
||||||
|
|
||||||
interface GTBBairroTableProps {
|
interface GTBBairroTableProps {
|
||||||
data: GTBBairroInterface[];
|
data: GTBBairroInterface[];
|
||||||
|
|
@ -29,31 +29,23 @@ interface GTBBairroTableProps {
|
||||||
/**
|
/**
|
||||||
* Renderiza o badge de situação
|
* Renderiza o badge de situação
|
||||||
*/
|
*/
|
||||||
function StatusBadge({ situacao }: { situacao: "A" | "I" }) {
|
function StatusBadge({ situacao }: { situacao: 'A' | 'I' }) {
|
||||||
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 =
|
const activeClasses = 'bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-300';
|
||||||
"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-300";
|
|
||||||
|
|
||||||
const inactiveClasses =
|
const inactiveClasses = 'bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300';
|
||||||
"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300";
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<span
|
<span className={`${baseClasses} ${isActive ? activeClasses : inactiveClasses}`}>
|
||||||
className={`${baseClasses} ${isActive ? activeClasses : inactiveClasses}`}
|
{isActive ? 'Ativo' : 'Inativo'}
|
||||||
>
|
|
||||||
{isActive ? "Ativo" : "Inativo"}
|
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function GTBBairroTable({
|
export default function GTBBairroTable({ data, onEdit, onDelete }: GTBBairroTableProps) {
|
||||||
data,
|
|
||||||
onEdit,
|
|
||||||
onDelete,
|
|
||||||
}: GTBBairroTableProps) {
|
|
||||||
return (
|
return (
|
||||||
<Table>
|
<Table>
|
||||||
<TableHeader>
|
<TableHeader>
|
||||||
|
|
@ -79,11 +71,7 @@ export default function GTBBairroTable({
|
||||||
<TableCell className="text-right">
|
<TableCell className="text-right">
|
||||||
<DropdownMenu>
|
<DropdownMenu>
|
||||||
<DropdownMenuTrigger asChild>
|
<DropdownMenuTrigger asChild>
|
||||||
<Button
|
<Button variant="outline" size="icon" className="cursor-pointer">
|
||||||
variant="outline"
|
|
||||||
size="icon"
|
|
||||||
className="cursor-pointer"
|
|
||||||
>
|
|
||||||
<EllipsisIcon />
|
<EllipsisIcon />
|
||||||
</Button>
|
</Button>
|
||||||
</DropdownMenuTrigger>
|
</DropdownMenuTrigger>
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
"use client";
|
'use client';
|
||||||
|
|
||||||
import z from "zod";
|
import z from 'zod';
|
||||||
import { useEffect } from "react";
|
import { useEffect } from 'react';
|
||||||
import { useForm, Controller } from "react-hook-form";
|
import { useForm, Controller } from 'react-hook-form';
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from '@hookform/resolvers/zod';
|
||||||
|
|
||||||
import LoadingButton from "@/app/_components/loadingButton/LoadingButton";
|
import LoadingButton from '@/app/_components/loadingButton/LoadingButton';
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from '@/components/ui/button';
|
||||||
import { Checkbox } from "@/components/ui/checkbox";
|
import { Checkbox } from '@/components/ui/checkbox';
|
||||||
import {
|
import {
|
||||||
Dialog,
|
Dialog,
|
||||||
DialogClose,
|
DialogClose,
|
||||||
|
|
@ -16,7 +16,7 @@ import {
|
||||||
DialogFooter,
|
DialogFooter,
|
||||||
DialogHeader,
|
DialogHeader,
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
} from "@/components/ui/dialog";
|
} from '@/components/ui/dialog';
|
||||||
import {
|
import {
|
||||||
Form,
|
Form,
|
||||||
FormControl,
|
FormControl,
|
||||||
|
|
@ -24,12 +24,12 @@ import {
|
||||||
FormItem,
|
FormItem,
|
||||||
FormLabel,
|
FormLabel,
|
||||||
FormMessage,
|
FormMessage,
|
||||||
} from "@/components/ui/form";
|
} from '@/components/ui/form';
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from '@/components/ui/input';
|
||||||
import { Label } from "@/components/ui/label";
|
import { Label } from '@/components/ui/label';
|
||||||
|
|
||||||
import { GTBEstadoCivilSchema } from "../../_schemas/GTBEstadoCivilSchema";
|
import { GTBEstadoCivilSchema } from '../../_schemas/GTBEstadoCivilSchema';
|
||||||
import { GTBEstadoCivilInterface } from "../../_interfaces/GTBEstadoCivilInterface";
|
import { GTBEstadoCivilInterface } from '../../_interfaces/GTBEstadoCivilInterface';
|
||||||
|
|
||||||
type FormValues = z.infer<typeof GTBEstadoCivilSchema>;
|
type FormValues = z.infer<typeof GTBEstadoCivilSchema>;
|
||||||
|
|
||||||
|
|
@ -54,8 +54,8 @@ export default function GTBEstadoCivilForm({
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
tb_estadocivil_id: 0,
|
tb_estadocivil_id: 0,
|
||||||
sistema_id: 0,
|
sistema_id: 0,
|
||||||
descricao: "",
|
descricao: '',
|
||||||
situacao: "A",
|
situacao: 'A',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -101,10 +101,8 @@ export default function GTBEstadoCivilForm({
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<div className="flex items-center space-x-2">
|
<div className="flex items-center space-x-2">
|
||||||
<Checkbox
|
<Checkbox
|
||||||
checked={field.value === "A"}
|
checked={field.value === 'A'}
|
||||||
onCheckedChange={(checked) =>
|
onCheckedChange={(checked) => field.onChange(checked ? 'A' : 'I')}
|
||||||
field.onChange(checked ? "A" : "I")
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
<Label>Ativo</Label>
|
<Label>Ativo</Label>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -133,14 +131,8 @@ export default function GTBEstadoCivilForm({
|
||||||
</DialogFooter>
|
</DialogFooter>
|
||||||
|
|
||||||
{/* Campos ocultos */}
|
{/* Campos ocultos */}
|
||||||
<input
|
<input type="hidden" {...form.register('tb_estadocivil_id', { valueAsNumber: true })} />
|
||||||
type="hidden"
|
<input type="hidden" {...form.register('sistema_id', { valueAsNumber: true })} />
|
||||||
{...form.register("tb_estadocivil_id", { valueAsNumber: true })}
|
|
||||||
/>
|
|
||||||
<input
|
|
||||||
type="hidden"
|
|
||||||
{...form.register("sistema_id", { valueAsNumber: true })}
|
|
||||||
/>
|
|
||||||
</form>
|
</form>
|
||||||
</Form>
|
</Form>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
"use client";
|
'use client';
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from '@/components/ui/button';
|
||||||
import {
|
import {
|
||||||
DropdownMenu,
|
DropdownMenu,
|
||||||
DropdownMenuContent,
|
DropdownMenuContent,
|
||||||
|
|
@ -8,7 +8,7 @@ import {
|
||||||
DropdownMenuItem,
|
DropdownMenuItem,
|
||||||
DropdownMenuSeparator,
|
DropdownMenuSeparator,
|
||||||
DropdownMenuTrigger,
|
DropdownMenuTrigger,
|
||||||
} from "@/components/ui/dropdown-menu";
|
} from '@/components/ui/dropdown-menu';
|
||||||
import {
|
import {
|
||||||
Table,
|
Table,
|
||||||
TableBody,
|
TableBody,
|
||||||
|
|
@ -16,47 +16,36 @@ import {
|
||||||
TableHead,
|
TableHead,
|
||||||
TableHeader,
|
TableHeader,
|
||||||
TableRow,
|
TableRow,
|
||||||
} from "@/components/ui/table";
|
} from '@/components/ui/table';
|
||||||
import { EllipsisIcon, PencilIcon, Trash2Icon } from "lucide-react";
|
import { EllipsisIcon, PencilIcon, Trash2Icon } from 'lucide-react';
|
||||||
import { GTBEstadoCivilInterface } from "../../_interfaces/GTBEstadoCivilInterface";
|
import { GTBEstadoCivilInterface } from '../../_interfaces/GTBEstadoCivilInterface';
|
||||||
|
|
||||||
interface TBEstadoCivilTableProps {
|
interface TBEstadoCivilTableProps {
|
||||||
data: GTBEstadoCivilInterface[];
|
data: GTBEstadoCivilInterface[];
|
||||||
onEdit: (item: GTBEstadoCivilInterface, isEditingFormStatus: boolean) => void;
|
onEdit: (item: GTBEstadoCivilInterface, isEditingFormStatus: boolean) => void;
|
||||||
onDelete: (
|
onDelete: (item: GTBEstadoCivilInterface, isEditingFormStatus: boolean) => void;
|
||||||
item: GTBEstadoCivilInterface,
|
|
||||||
isEditingFormStatus: boolean,
|
|
||||||
) => void;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renderiza o badge de situação
|
* Renderiza o badge de situação
|
||||||
*/
|
*/
|
||||||
function StatusBadge({ situacao }: { situacao: "A" | "I" }) {
|
function StatusBadge({ situacao }: { situacao: 'A' | 'I' }) {
|
||||||
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 =
|
const activeClasses = 'bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-300';
|
||||||
"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-300";
|
|
||||||
|
|
||||||
const inactiveClasses =
|
const inactiveClasses = 'bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300';
|
||||||
"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300";
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<span
|
<span className={`${baseClasses} ${isActive ? activeClasses : inactiveClasses}`}>
|
||||||
className={`${baseClasses} ${isActive ? activeClasses : inactiveClasses}`}
|
{isActive ? 'Ativo' : 'Inativo'}
|
||||||
>
|
|
||||||
{isActive ? "Ativo" : "Inativo"}
|
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function GTBEstadoCivilTable({
|
export default function GTBEstadoCivilTable({ data, onEdit, onDelete }: TBEstadoCivilTableProps) {
|
||||||
data,
|
|
||||||
onEdit,
|
|
||||||
onDelete,
|
|
||||||
}: TBEstadoCivilTableProps) {
|
|
||||||
return (
|
return (
|
||||||
<Table>
|
<Table>
|
||||||
<TableHeader>
|
<TableHeader>
|
||||||
|
|
@ -71,9 +60,7 @@ export default function GTBEstadoCivilTable({
|
||||||
<TableBody>
|
<TableBody>
|
||||||
{data.map((item) => (
|
{data.map((item) => (
|
||||||
<TableRow key={item.tb_estadocivil_id} className="cursor-pointer">
|
<TableRow key={item.tb_estadocivil_id} className="cursor-pointer">
|
||||||
<TableCell className="font-medium">
|
<TableCell className="font-medium">{item.tb_estadocivil_id}</TableCell>
|
||||||
{item.tb_estadocivil_id}
|
|
||||||
</TableCell>
|
|
||||||
|
|
||||||
<TableCell>
|
<TableCell>
|
||||||
<StatusBadge situacao={item.situacao} />
|
<StatusBadge situacao={item.situacao} />
|
||||||
|
|
@ -84,11 +71,7 @@ export default function GTBEstadoCivilTable({
|
||||||
<TableCell className="text-right">
|
<TableCell className="text-right">
|
||||||
<DropdownMenu>
|
<DropdownMenu>
|
||||||
<DropdownMenuTrigger asChild>
|
<DropdownMenuTrigger asChild>
|
||||||
<Button
|
<Button variant="outline" size="icon" className="cursor-pointer">
|
||||||
variant="outline"
|
|
||||||
size="icon"
|
|
||||||
className="cursor-pointer"
|
|
||||||
>
|
|
||||||
<EllipsisIcon />
|
<EllipsisIcon />
|
||||||
</Button>
|
</Button>
|
||||||
</DropdownMenuTrigger>
|
</DropdownMenuTrigger>
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
"use client";
|
'use client';
|
||||||
|
|
||||||
import z from "zod";
|
import z from 'zod';
|
||||||
import { useEffect } from "react";
|
import { useEffect } from 'react';
|
||||||
import { useForm, Controller } from "react-hook-form";
|
import { useForm, Controller } from 'react-hook-form';
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from '@hookform/resolvers/zod';
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from '@/components/ui/button';
|
||||||
import { Checkbox } from "@/components/ui/checkbox";
|
import { Checkbox } from '@/components/ui/checkbox';
|
||||||
import {
|
import {
|
||||||
Dialog,
|
Dialog,
|
||||||
DialogClose,
|
DialogClose,
|
||||||
|
|
@ -15,7 +15,7 @@ import {
|
||||||
DialogFooter,
|
DialogFooter,
|
||||||
DialogHeader,
|
DialogHeader,
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
} from "@/components/ui/dialog";
|
} from '@/components/ui/dialog';
|
||||||
import {
|
import {
|
||||||
Form,
|
Form,
|
||||||
FormControl,
|
FormControl,
|
||||||
|
|
@ -23,11 +23,11 @@ import {
|
||||||
FormItem,
|
FormItem,
|
||||||
FormLabel,
|
FormLabel,
|
||||||
FormMessage,
|
FormMessage,
|
||||||
} from "@/components/ui/form";
|
} from '@/components/ui/form';
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from '@/components/ui/input';
|
||||||
import { Label } from "@/components/ui/label";
|
import { Label } from '@/components/ui/label';
|
||||||
|
|
||||||
import { GTBProfissaoSchema } from "../../_schemas/GTBProfissaoSchema";
|
import { GTBProfissaoSchema } from '../../_schemas/GTBProfissaoSchema';
|
||||||
|
|
||||||
type FormValues = z.infer<typeof GTBProfissaoSchema>;
|
type FormValues = z.infer<typeof GTBProfissaoSchema>;
|
||||||
|
|
||||||
|
|
@ -38,19 +38,14 @@ interface Props {
|
||||||
onSave: (data: FormValues) => void;
|
onSave: (data: FormValues) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function GTBProfissaoForm({
|
export default function GTBProfissaoForm({ isOpen, data, onClose, onSave }: Props) {
|
||||||
isOpen,
|
|
||||||
data,
|
|
||||||
onClose,
|
|
||||||
onSave,
|
|
||||||
}: Props) {
|
|
||||||
// Inicializa o react-hook-form com schema zod
|
// Inicializa o react-hook-form com schema zod
|
||||||
const form = useForm<FormValues>({
|
const form = useForm<FormValues>({
|
||||||
resolver: zodResolver(GTBProfissaoSchema),
|
resolver: zodResolver(GTBProfissaoSchema),
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
descricao: "",
|
descricao: '',
|
||||||
cod_cbo: "",
|
cod_cbo: '',
|
||||||
situacao: "A",
|
situacao: 'A',
|
||||||
tb_profissao_id: 0,
|
tb_profissao_id: 0,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
@ -83,11 +78,7 @@ export default function GTBProfissaoForm({
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>Descrição</FormLabel>
|
<FormLabel>Descrição</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input
|
<Input type="text" {...field} placeholder="Digite a descrição" />
|
||||||
type="text"
|
|
||||||
{...field}
|
|
||||||
placeholder="Digite a descrição"
|
|
||||||
/>
|
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
|
@ -102,11 +93,7 @@ export default function GTBProfissaoForm({
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>CBO</FormLabel>
|
<FormLabel>CBO</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input
|
<Input type="nubmer" {...field} placeholder="Digite o código" />
|
||||||
type="nubmer"
|
|
||||||
{...field}
|
|
||||||
placeholder="Digite o código"
|
|
||||||
/>
|
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
|
@ -120,10 +107,8 @@ export default function GTBProfissaoForm({
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<div className="flex items-center space-x-2">
|
<div className="flex items-center space-x-2">
|
||||||
<Checkbox
|
<Checkbox
|
||||||
checked={field.value === "A"}
|
checked={field.value === 'A'}
|
||||||
onCheckedChange={(checked) =>
|
onCheckedChange={(checked) => field.onChange(checked ? 'A' : 'I')}
|
||||||
field.onChange(checked ? "A" : "I")
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
<Label>Ativo</Label>
|
<Label>Ativo</Label>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -148,7 +133,7 @@ export default function GTBProfissaoForm({
|
||||||
</DialogFooter>
|
</DialogFooter>
|
||||||
|
|
||||||
{/* Campo oculto */}
|
{/* Campo oculto */}
|
||||||
<input type="hidden" {...form.register("tb_profissao_id")} />
|
<input type="hidden" {...form.register('tb_profissao_id')} />
|
||||||
</form>
|
</form>
|
||||||
</Form>
|
</Form>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
"use client";
|
'use client';
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from '@/components/ui/button';
|
||||||
import {
|
import {
|
||||||
DropdownMenu,
|
DropdownMenu,
|
||||||
DropdownMenuContent,
|
DropdownMenuContent,
|
||||||
|
|
@ -8,7 +8,7 @@ import {
|
||||||
DropdownMenuItem,
|
DropdownMenuItem,
|
||||||
DropdownMenuSeparator,
|
DropdownMenuSeparator,
|
||||||
DropdownMenuTrigger,
|
DropdownMenuTrigger,
|
||||||
} from "@/components/ui/dropdown-menu";
|
} from '@/components/ui/dropdown-menu';
|
||||||
import {
|
import {
|
||||||
Table,
|
Table,
|
||||||
TableBody,
|
TableBody,
|
||||||
|
|
@ -16,10 +16,10 @@ import {
|
||||||
TableHead,
|
TableHead,
|
||||||
TableHeader,
|
TableHeader,
|
||||||
TableRow,
|
TableRow,
|
||||||
} from "@/components/ui/table";
|
} from '@/components/ui/table';
|
||||||
|
|
||||||
import { EllipsisIcon, PencilIcon, Trash2Icon } from "lucide-react";
|
import { EllipsisIcon, PencilIcon, Trash2Icon } from 'lucide-react';
|
||||||
import GTBProfissaoInterface from "../../_interfaces/GTBProfissaoInterface";
|
import GTBProfissaoInterface from '../../_interfaces/GTBProfissaoInterface';
|
||||||
|
|
||||||
interface GTBProfissaoTableProps {
|
interface GTBProfissaoTableProps {
|
||||||
data: GTBProfissaoInterface[];
|
data: GTBProfissaoInterface[];
|
||||||
|
|
@ -31,30 +31,22 @@ interface GTBProfissaoTableProps {
|
||||||
* Renderiza o badge de situação
|
* Renderiza o badge de situação
|
||||||
*/
|
*/
|
||||||
function StatusBadge({ situacao }: { situacao: string }) {
|
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 =
|
const activeClasses = 'bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-300';
|
||||||
"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-300";
|
|
||||||
|
|
||||||
const inactiveClasses =
|
const inactiveClasses = 'bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300';
|
||||||
"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300";
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<span
|
<span className={`${baseClasses} ${isActive ? activeClasses : inactiveClasses}`}>
|
||||||
className={`${baseClasses} ${isActive ? activeClasses : inactiveClasses}`}
|
{isActive ? 'Ativo' : 'Inativo'}
|
||||||
>
|
|
||||||
{isActive ? "Ativo" : "Inativo"}
|
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function GTBProfissaoTable({
|
export default function GTBProfissaoTable({ data, onEdit, onDelete }: GTBProfissaoTableProps) {
|
||||||
data,
|
|
||||||
onEdit,
|
|
||||||
onDelete,
|
|
||||||
}: GTBProfissaoTableProps) {
|
|
||||||
return (
|
return (
|
||||||
<Table>
|
<Table>
|
||||||
<TableHeader>
|
<TableHeader>
|
||||||
|
|
@ -70,9 +62,7 @@ export default function GTBProfissaoTable({
|
||||||
<TableBody>
|
<TableBody>
|
||||||
{data.map((item) => (
|
{data.map((item) => (
|
||||||
<TableRow key={item.tb_profissao_id} className="cursor-pointer">
|
<TableRow key={item.tb_profissao_id} className="cursor-pointer">
|
||||||
<TableCell className="font-medium">
|
<TableCell className="font-medium">{item.tb_profissao_id}</TableCell>
|
||||||
{item.tb_profissao_id}
|
|
||||||
</TableCell>
|
|
||||||
|
|
||||||
<TableCell>
|
<TableCell>
|
||||||
<StatusBadge situacao={item.situacao} />
|
<StatusBadge situacao={item.situacao} />
|
||||||
|
|
@ -85,11 +75,7 @@ export default function GTBProfissaoTable({
|
||||||
<TableCell className="text-right">
|
<TableCell className="text-right">
|
||||||
<DropdownMenu>
|
<DropdownMenu>
|
||||||
<DropdownMenuTrigger asChild>
|
<DropdownMenuTrigger asChild>
|
||||||
<Button
|
<Button variant="outline" size="icon" className="cursor-pointer">
|
||||||
variant="outline"
|
|
||||||
size="icon"
|
|
||||||
className="cursor-pointer"
|
|
||||||
>
|
|
||||||
<EllipsisIcon />
|
<EllipsisIcon />
|
||||||
</Button>
|
</Button>
|
||||||
</DropdownMenuTrigger>
|
</DropdownMenuTrigger>
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
"use client";
|
'use client';
|
||||||
|
|
||||||
import z from "zod";
|
import z from 'zod';
|
||||||
import { useForm, Controller } from "react-hook-form";
|
import { useForm, Controller } from 'react-hook-form';
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from '@hookform/resolvers/zod';
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from '@/components/ui/button';
|
||||||
import { Checkbox } from "@/components/ui/checkbox";
|
import { Checkbox } from '@/components/ui/checkbox';
|
||||||
import {
|
import {
|
||||||
Dialog,
|
Dialog,
|
||||||
DialogClose,
|
DialogClose,
|
||||||
|
|
@ -14,7 +14,7 @@ import {
|
||||||
DialogFooter,
|
DialogFooter,
|
||||||
DialogHeader,
|
DialogHeader,
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
} from "@/components/ui/dialog";
|
} from '@/components/ui/dialog';
|
||||||
import {
|
import {
|
||||||
Form,
|
Form,
|
||||||
FormControl,
|
FormControl,
|
||||||
|
|
@ -22,12 +22,12 @@ import {
|
||||||
FormItem,
|
FormItem,
|
||||||
FormLabel,
|
FormLabel,
|
||||||
FormMessage,
|
FormMessage,
|
||||||
} from "@/components/ui/form";
|
} from '@/components/ui/form';
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from '@/components/ui/input';
|
||||||
import { Label } from "@/components/ui/label";
|
import { Label } from '@/components/ui/label';
|
||||||
|
|
||||||
import { GTBRegimeBensSchema } from "../../_schemas/GTBRegimeBensSchema";
|
import { GTBRegimeBensSchema } from '../../_schemas/GTBRegimeBensSchema';
|
||||||
import { useEffect } from "react";
|
import { useEffect } from 'react';
|
||||||
|
|
||||||
type FormValues = z.infer<typeof GTBRegimeBensSchema>;
|
type FormValues = z.infer<typeof GTBRegimeBensSchema>;
|
||||||
|
|
||||||
|
|
@ -38,19 +38,14 @@ interface Props {
|
||||||
onSave: (data: FormValues) => void;
|
onSave: (data: FormValues) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function GTBRegimeComunhaoForm({
|
export default function GTBRegimeComunhaoForm({ isOpen, data, onClose, onSave }: Props) {
|
||||||
isOpen,
|
|
||||||
data,
|
|
||||||
onClose,
|
|
||||||
onSave,
|
|
||||||
}: Props) {
|
|
||||||
// Inicializa o react-hook-form com schema zod
|
// Inicializa o react-hook-form com schema zod
|
||||||
const form = useForm<FormValues>({
|
const form = useForm<FormValues>({
|
||||||
resolver: zodResolver(GTBRegimeBensSchema),
|
resolver: zodResolver(GTBRegimeBensSchema),
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
tb_regimebens_id: 0,
|
tb_regimebens_id: 0,
|
||||||
descricao: "",
|
descricao: '',
|
||||||
situacao: "",
|
situacao: '',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -96,10 +91,8 @@ export default function GTBRegimeComunhaoForm({
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<div className="flex items-center space-x-2">
|
<div className="flex items-center space-x-2">
|
||||||
<Checkbox
|
<Checkbox
|
||||||
checked={field.value === "A"}
|
checked={field.value === 'A'}
|
||||||
onCheckedChange={(checked) =>
|
onCheckedChange={(checked) => field.onChange(checked ? 'A' : 'I')}
|
||||||
field.onChange(checked ? "A" : "I")
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
<Label>Ativo</Label>
|
<Label>Ativo</Label>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -124,7 +117,7 @@ export default function GTBRegimeComunhaoForm({
|
||||||
</DialogFooter>
|
</DialogFooter>
|
||||||
|
|
||||||
{/* Campo oculto */}
|
{/* Campo oculto */}
|
||||||
<input type="hidden" {...form.register("tb_regimebens_id")} />
|
<input type="hidden" {...form.register('tb_regimebens_id')} />
|
||||||
</form>
|
</form>
|
||||||
</Form>
|
</Form>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
"use client";
|
'use client';
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from '@/components/ui/button';
|
||||||
import {
|
import {
|
||||||
DropdownMenu,
|
DropdownMenu,
|
||||||
DropdownMenuContent,
|
DropdownMenuContent,
|
||||||
|
|
@ -8,7 +8,7 @@ import {
|
||||||
DropdownMenuItem,
|
DropdownMenuItem,
|
||||||
DropdownMenuSeparator,
|
DropdownMenuSeparator,
|
||||||
DropdownMenuTrigger,
|
DropdownMenuTrigger,
|
||||||
} from "@/components/ui/dropdown-menu";
|
} from '@/components/ui/dropdown-menu';
|
||||||
import {
|
import {
|
||||||
Table,
|
Table,
|
||||||
TableBody,
|
TableBody,
|
||||||
|
|
@ -16,48 +16,37 @@ import {
|
||||||
TableHead,
|
TableHead,
|
||||||
TableHeader,
|
TableHeader,
|
||||||
TableRow,
|
TableRow,
|
||||||
} from "@/components/ui/table";
|
} from '@/components/ui/table';
|
||||||
|
|
||||||
import { EllipsisIcon, PencilIcon, Trash2Icon } from "lucide-react";
|
import { EllipsisIcon, PencilIcon, Trash2Icon } from 'lucide-react';
|
||||||
import GTBRegimeBensInterface from "../../_interfaces/GTBRegimeBensInterface";
|
import GTBRegimeBensInterface from '../../_interfaces/GTBRegimeBensInterface';
|
||||||
|
|
||||||
interface GTBRegimeBensTableProps {
|
interface GTBRegimeBensTableProps {
|
||||||
data: GTBRegimeBensInterface[];
|
data: GTBRegimeBensInterface[];
|
||||||
onEdit: (item: GTBRegimeBensInterface, isEditingFormStatus: boolean) => void;
|
onEdit: (item: GTBRegimeBensInterface, isEditingFormStatus: boolean) => void;
|
||||||
onDelete: (
|
onDelete: (item: GTBRegimeBensInterface, isEditingFormStatus: boolean) => void;
|
||||||
item: GTBRegimeBensInterface,
|
|
||||||
isEditingFormStatus: boolean,
|
|
||||||
) => void;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renderiza o badge de situação
|
* Renderiza o badge de situação
|
||||||
*/
|
*/
|
||||||
function StatusBadge({ situacao }: { situacao: string }) {
|
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 =
|
const activeClasses = 'bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-300';
|
||||||
"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-300";
|
|
||||||
|
|
||||||
const inactiveClasses =
|
const inactiveClasses = 'bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300';
|
||||||
"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300";
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<span
|
<span className={`${baseClasses} ${isActive ? activeClasses : inactiveClasses}`}>
|
||||||
className={`${baseClasses} ${isActive ? activeClasses : inactiveClasses}`}
|
{isActive ? 'Ativo' : 'Inativo'}
|
||||||
>
|
|
||||||
{isActive ? "Ativo" : "Inativo"}
|
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function GTBRegimeBensTable({
|
export default function GTBRegimeBensTable({ data, onEdit, onDelete }: GTBRegimeBensTableProps) {
|
||||||
data,
|
|
||||||
onEdit,
|
|
||||||
onDelete,
|
|
||||||
}: GTBRegimeBensTableProps) {
|
|
||||||
return (
|
return (
|
||||||
<Table>
|
<Table>
|
||||||
<TableHeader>
|
<TableHeader>
|
||||||
|
|
@ -72,9 +61,7 @@ export default function GTBRegimeBensTable({
|
||||||
<TableBody>
|
<TableBody>
|
||||||
{data.map((item) => (
|
{data.map((item) => (
|
||||||
<TableRow key={item.tb_regimebens_id} className="cursor-pointer">
|
<TableRow key={item.tb_regimebens_id} className="cursor-pointer">
|
||||||
<TableCell className="font-medium">
|
<TableCell className="font-medium">{item.tb_regimebens_id}</TableCell>
|
||||||
{item.tb_regimebens_id}
|
|
||||||
</TableCell>
|
|
||||||
|
|
||||||
<TableCell>
|
<TableCell>
|
||||||
<StatusBadge situacao={item.situacao} />
|
<StatusBadge situacao={item.situacao} />
|
||||||
|
|
@ -85,11 +72,7 @@ export default function GTBRegimeBensTable({
|
||||||
<TableCell className="text-right">
|
<TableCell className="text-right">
|
||||||
<DropdownMenu>
|
<DropdownMenu>
|
||||||
<DropdownMenuTrigger asChild>
|
<DropdownMenuTrigger asChild>
|
||||||
<Button
|
<Button variant="outline" size="icon" className="cursor-pointer">
|
||||||
variant="outline"
|
|
||||||
size="icon"
|
|
||||||
className="cursor-pointer"
|
|
||||||
>
|
|
||||||
<EllipsisIcon />
|
<EllipsisIcon />
|
||||||
</Button>
|
</Button>
|
||||||
</DropdownMenuTrigger>
|
</DropdownMenuTrigger>
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
"use client";
|
'use client';
|
||||||
|
|
||||||
import z from "zod";
|
import z from 'zod';
|
||||||
import { useEffect } from "react";
|
import { useEffect } from 'react';
|
||||||
import { useForm, Controller } from "react-hook-form";
|
import { useForm, Controller } from 'react-hook-form';
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from '@hookform/resolvers/zod';
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from '@/components/ui/button';
|
||||||
import { Checkbox } from "@/components/ui/checkbox";
|
import { Checkbox } from '@/components/ui/checkbox';
|
||||||
import {
|
import {
|
||||||
Dialog,
|
Dialog,
|
||||||
DialogClose,
|
DialogClose,
|
||||||
|
|
@ -15,7 +15,7 @@ import {
|
||||||
DialogFooter,
|
DialogFooter,
|
||||||
DialogHeader,
|
DialogHeader,
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
} from "@/components/ui/dialog";
|
} from '@/components/ui/dialog';
|
||||||
import {
|
import {
|
||||||
Form,
|
Form,
|
||||||
FormControl,
|
FormControl,
|
||||||
|
|
@ -23,19 +23,19 @@ import {
|
||||||
FormItem,
|
FormItem,
|
||||||
FormLabel,
|
FormLabel,
|
||||||
FormMessage,
|
FormMessage,
|
||||||
} from "@/components/ui/form";
|
} from '@/components/ui/form';
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from '@/components/ui/input';
|
||||||
import { Label } from "@/components/ui/label";
|
import { Label } from '@/components/ui/label';
|
||||||
|
|
||||||
import { GTBRegimeComunhaoSchema } from "../../_schemas/GTBRegimeComunhaoSchema";
|
import { GTBRegimeComunhaoSchema } from '../../_schemas/GTBRegimeComunhaoSchema';
|
||||||
import {
|
import {
|
||||||
Select,
|
Select,
|
||||||
SelectContent,
|
SelectContent,
|
||||||
SelectItem,
|
SelectItem,
|
||||||
SelectTrigger,
|
SelectTrigger,
|
||||||
SelectValue,
|
SelectValue,
|
||||||
} from "@/components/ui/select";
|
} from '@/components/ui/select';
|
||||||
import { useGTBRegimeBensReadHook } from "../../_hooks/g_tb_regimebens/useGTBRegimeBensReadHook";
|
import { useGTBRegimeBensReadHook } from '../../_hooks/g_tb_regimebens/useGTBRegimeBensReadHook';
|
||||||
|
|
||||||
type FormValues = z.infer<typeof GTBRegimeComunhaoSchema>;
|
type FormValues = z.infer<typeof GTBRegimeComunhaoSchema>;
|
||||||
|
|
||||||
|
|
@ -46,12 +46,7 @@ interface Props {
|
||||||
onSave: (data: FormValues) => void;
|
onSave: (data: FormValues) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function GTBRegimeComunhaoForm({
|
export default function GTBRegimeComunhaoForm({ isOpen, data, onClose, onSave }: Props) {
|
||||||
isOpen,
|
|
||||||
data,
|
|
||||||
onClose,
|
|
||||||
onSave,
|
|
||||||
}: Props) {
|
|
||||||
const { gTBRegimeBens, fetchGTBRegimeBens } = useGTBRegimeBensReadHook();
|
const { gTBRegimeBens, fetchGTBRegimeBens } = useGTBRegimeBensReadHook();
|
||||||
|
|
||||||
// Inicializa o react-hook-form com schema zod
|
// Inicializa o react-hook-form com schema zod
|
||||||
|
|
@ -60,9 +55,9 @@ export default function GTBRegimeComunhaoForm({
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
tb_regimecomunhao_id: 0,
|
tb_regimecomunhao_id: 0,
|
||||||
tb_regimebens_id: 0,
|
tb_regimebens_id: 0,
|
||||||
descricao: "",
|
descricao: '',
|
||||||
texto: "",
|
texto: '',
|
||||||
situacao: "",
|
situacao: '',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -165,10 +160,8 @@ export default function GTBRegimeComunhaoForm({
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<div className="flex items-center space-x-2">
|
<div className="flex items-center space-x-2">
|
||||||
<Checkbox
|
<Checkbox
|
||||||
checked={field.value === "A"}
|
checked={field.value === 'A'}
|
||||||
onCheckedChange={(checked) =>
|
onCheckedChange={(checked) => field.onChange(checked ? 'A' : 'I')}
|
||||||
field.onChange(checked ? "A" : "I")
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
<Label>Ativo</Label>
|
<Label>Ativo</Label>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -193,7 +186,7 @@ export default function GTBRegimeComunhaoForm({
|
||||||
</DialogFooter>
|
</DialogFooter>
|
||||||
|
|
||||||
{/* Campo oculto */}
|
{/* Campo oculto */}
|
||||||
<input type="hidden" {...form.register("tb_regimecomunhao_id")} />
|
<input type="hidden" {...form.register('tb_regimecomunhao_id')} />
|
||||||
</form>
|
</form>
|
||||||
</Form>
|
</Form>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
"use client";
|
'use client';
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from '@/components/ui/button';
|
||||||
import {
|
import {
|
||||||
DropdownMenu,
|
DropdownMenu,
|
||||||
DropdownMenuContent,
|
DropdownMenuContent,
|
||||||
|
|
@ -8,7 +8,7 @@ import {
|
||||||
DropdownMenuItem,
|
DropdownMenuItem,
|
||||||
DropdownMenuSeparator,
|
DropdownMenuSeparator,
|
||||||
DropdownMenuTrigger,
|
DropdownMenuTrigger,
|
||||||
} from "@/components/ui/dropdown-menu";
|
} from '@/components/ui/dropdown-menu';
|
||||||
import {
|
import {
|
||||||
Table,
|
Table,
|
||||||
TableBody,
|
TableBody,
|
||||||
|
|
@ -16,42 +16,32 @@ import {
|
||||||
TableHead,
|
TableHead,
|
||||||
TableHeader,
|
TableHeader,
|
||||||
TableRow,
|
TableRow,
|
||||||
} from "@/components/ui/table";
|
} from '@/components/ui/table';
|
||||||
|
|
||||||
import { EllipsisIcon, PencilIcon, Trash2Icon } from "lucide-react";
|
import { EllipsisIcon, PencilIcon, Trash2Icon } from 'lucide-react';
|
||||||
import GTBRegimeComunhaoInterface from "../../_interfaces/GTBRegimeComunhaoInterface";
|
import GTBRegimeComunhaoInterface from '../../_interfaces/GTBRegimeComunhaoInterface';
|
||||||
|
|
||||||
interface GTBRegimeComunhaoTableProps {
|
interface GTBRegimeComunhaoTableProps {
|
||||||
data: GTBRegimeComunhaoInterface[];
|
data: GTBRegimeComunhaoInterface[];
|
||||||
onEdit: (
|
onEdit: (item: GTBRegimeComunhaoInterface, isEditingFormStatus: boolean) => void;
|
||||||
item: GTBRegimeComunhaoInterface,
|
onDelete: (item: GTBRegimeComunhaoInterface, isEditingFormStatus: boolean) => void;
|
||||||
isEditingFormStatus: boolean,
|
|
||||||
) => void;
|
|
||||||
onDelete: (
|
|
||||||
item: GTBRegimeComunhaoInterface,
|
|
||||||
isEditingFormStatus: boolean,
|
|
||||||
) => void;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renderiza o badge de situação
|
* Renderiza o badge de situação
|
||||||
*/
|
*/
|
||||||
function StatusBadge({ situacao }: { situacao: string }) {
|
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 =
|
const activeClasses = 'bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-300';
|
||||||
"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-300";
|
|
||||||
|
|
||||||
const inactiveClasses =
|
const inactiveClasses = 'bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300';
|
||||||
"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300";
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<span
|
<span className={`${baseClasses} ${isActive ? activeClasses : inactiveClasses}`}>
|
||||||
className={`${baseClasses} ${isActive ? activeClasses : inactiveClasses}`}
|
{isActive ? 'Ativo' : 'Inativo'}
|
||||||
>
|
|
||||||
{isActive ? "Ativo" : "Inativo"}
|
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -75,9 +65,7 @@ export default function GTBRegimeComunhaoTable({
|
||||||
<TableBody>
|
<TableBody>
|
||||||
{data.map((item) => (
|
{data.map((item) => (
|
||||||
<TableRow key={item.tb_regimecomunhao_id} className="cursor-pointer">
|
<TableRow key={item.tb_regimecomunhao_id} className="cursor-pointer">
|
||||||
<TableCell className="font-medium">
|
<TableCell className="font-medium">{item.tb_regimecomunhao_id}</TableCell>
|
||||||
{item.tb_regimecomunhao_id}
|
|
||||||
</TableCell>
|
|
||||||
|
|
||||||
<TableCell>
|
<TableCell>
|
||||||
<StatusBadge situacao={item.situacao} />
|
<StatusBadge situacao={item.situacao} />
|
||||||
|
|
@ -88,11 +76,7 @@ export default function GTBRegimeComunhaoTable({
|
||||||
<TableCell className="text-right">
|
<TableCell className="text-right">
|
||||||
<DropdownMenu>
|
<DropdownMenu>
|
||||||
<DropdownMenuTrigger asChild>
|
<DropdownMenuTrigger asChild>
|
||||||
<Button
|
<Button variant="outline" size="icon" className="cursor-pointer">
|
||||||
variant="outline"
|
|
||||||
size="icon"
|
|
||||||
className="cursor-pointer"
|
|
||||||
>
|
|
||||||
<EllipsisIcon />
|
<EllipsisIcon />
|
||||||
</Button>
|
</Button>
|
||||||
</DropdownMenuTrigger>
|
</DropdownMenuTrigger>
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
"use client";
|
'use client';
|
||||||
|
|
||||||
import z from "zod";
|
import z from 'zod';
|
||||||
import { useEffect } from "react";
|
import { useEffect } from 'react';
|
||||||
import { useForm, Controller } from "react-hook-form";
|
import { useForm, Controller } from 'react-hook-form';
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from '@hookform/resolvers/zod';
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from '@/components/ui/button';
|
||||||
import { Checkbox } from "@/components/ui/checkbox";
|
import { Checkbox } from '@/components/ui/checkbox';
|
||||||
import {
|
import {
|
||||||
Dialog,
|
Dialog,
|
||||||
DialogClose,
|
DialogClose,
|
||||||
|
|
@ -15,7 +15,7 @@ import {
|
||||||
DialogFooter,
|
DialogFooter,
|
||||||
DialogHeader,
|
DialogHeader,
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
} from "@/components/ui/dialog";
|
} from '@/components/ui/dialog';
|
||||||
import {
|
import {
|
||||||
Form,
|
Form,
|
||||||
FormControl,
|
FormControl,
|
||||||
|
|
@ -23,14 +23,14 @@ import {
|
||||||
FormItem,
|
FormItem,
|
||||||
FormLabel,
|
FormLabel,
|
||||||
FormMessage,
|
FormMessage,
|
||||||
} from "@/components/ui/form";
|
} from '@/components/ui/form';
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from '@/components/ui/input';
|
||||||
import { Label } from "@/components/ui/label";
|
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 { GTBTipoLogradouroSchema } from '../../_schemas/GTBTipoLogradouroSchema';
|
||||||
import { GTBTipoLogradouroInterface } from "../../_interfaces/GTBTipoLogradouroInterface";
|
import { GTBTipoLogradouroInterface } from '../../_interfaces/GTBTipoLogradouroInterface';
|
||||||
|
|
||||||
type FormValues = z.infer<typeof GTBTipoLogradouroSchema>;
|
type FormValues = z.infer<typeof GTBTipoLogradouroSchema>;
|
||||||
|
|
||||||
|
|
@ -56,8 +56,8 @@ export default function GTBTipoLogradouroForm({
|
||||||
sistema_id: null,
|
sistema_id: null,
|
||||||
tb_tipologradouro_id: 0,
|
tb_tipologradouro_id: 0,
|
||||||
situacao_id: null,
|
situacao_id: null,
|
||||||
descricao: "",
|
descricao: '',
|
||||||
situacao: "A",
|
situacao: 'A',
|
||||||
onr_tipo_logradouro_id: 0,
|
onr_tipo_logradouro_id: 0,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
@ -77,9 +77,7 @@ export default function GTBTipoLogradouroForm({
|
||||||
<DialogContent className="sm:max-w-[425px]">
|
<DialogContent className="sm:max-w-[425px]">
|
||||||
<DialogHeader>
|
<DialogHeader>
|
||||||
<DialogTitle>Tipo de Logradouro</DialogTitle>
|
<DialogTitle>Tipo de Logradouro</DialogTitle>
|
||||||
<DialogDescription>
|
<DialogDescription>Crie ou edite um tipo de logradouro</DialogDescription>
|
||||||
Crie ou edite um tipo de logradouro
|
|
||||||
</DialogDescription>
|
|
||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
|
|
||||||
<Form {...form}>
|
<Form {...form}>
|
||||||
|
|
@ -121,10 +119,8 @@ export default function GTBTipoLogradouroForm({
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<div className="flex items-center space-x-2">
|
<div className="flex items-center space-x-2">
|
||||||
<Checkbox
|
<Checkbox
|
||||||
checked={field.value === "A"}
|
checked={field.value === 'A'}
|
||||||
onCheckedChange={(checked) =>
|
onCheckedChange={(checked) => field.onChange(checked ? 'A' : 'I')}
|
||||||
field.onChange(checked ? "A" : "I")
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
<Label>Ativo</Label>
|
<Label>Ativo</Label>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -153,10 +149,10 @@ export default function GTBTipoLogradouroForm({
|
||||||
</DialogFooter>
|
</DialogFooter>
|
||||||
|
|
||||||
{/* Campos ocultos */}
|
{/* Campos ocultos */}
|
||||||
<input type="hidden" {...form.register("tb_tipologradouro_id")} />
|
<input type="hidden" {...form.register('tb_tipologradouro_id')} />
|
||||||
<input type="hidden" {...form.register("sistema_id")} />
|
<input type="hidden" {...form.register('sistema_id')} />
|
||||||
<input type="hidden" {...form.register("situacao_id")} />
|
<input type="hidden" {...form.register('situacao_id')} />
|
||||||
<input type="hidden" {...form.register("onr_tipo_logradouro_id")} />
|
<input type="hidden" {...form.register('onr_tipo_logradouro_id')} />
|
||||||
</form>
|
</form>
|
||||||
</Form>
|
</Form>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
"use client";
|
'use client';
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from '@/components/ui/button';
|
||||||
import {
|
import {
|
||||||
DropdownMenu,
|
DropdownMenu,
|
||||||
DropdownMenuContent,
|
DropdownMenuContent,
|
||||||
|
|
@ -8,7 +8,7 @@ import {
|
||||||
DropdownMenuItem,
|
DropdownMenuItem,
|
||||||
DropdownMenuSeparator,
|
DropdownMenuSeparator,
|
||||||
DropdownMenuTrigger,
|
DropdownMenuTrigger,
|
||||||
} from "@/components/ui/dropdown-menu";
|
} from '@/components/ui/dropdown-menu';
|
||||||
import {
|
import {
|
||||||
Table,
|
Table,
|
||||||
TableBody,
|
TableBody,
|
||||||
|
|
@ -16,41 +16,31 @@ import {
|
||||||
TableHead,
|
TableHead,
|
||||||
TableHeader,
|
TableHeader,
|
||||||
TableRow,
|
TableRow,
|
||||||
} from "@/components/ui/table";
|
} from '@/components/ui/table';
|
||||||
import { EllipsisIcon, PencilIcon, Trash2Icon } from "lucide-react";
|
import { EllipsisIcon, PencilIcon, Trash2Icon } from 'lucide-react';
|
||||||
import { GTBTipoLogradouroInterface } from "../../_interfaces/GTBTipoLogradouroInterface";
|
import { GTBTipoLogradouroInterface } from '../../_interfaces/GTBTipoLogradouroInterface';
|
||||||
|
|
||||||
interface GTBTipoLogradouroTableProps {
|
interface GTBTipoLogradouroTableProps {
|
||||||
data: GTBTipoLogradouroInterface[];
|
data: GTBTipoLogradouroInterface[];
|
||||||
onEdit: (
|
onEdit: (item: GTBTipoLogradouroInterface, isEditingFormStatus: boolean) => void;
|
||||||
item: GTBTipoLogradouroInterface,
|
onDelete: (item: GTBTipoLogradouroInterface, isEditingFormStatus: boolean) => void;
|
||||||
isEditingFormStatus: boolean,
|
|
||||||
) => void;
|
|
||||||
onDelete: (
|
|
||||||
item: GTBTipoLogradouroInterface,
|
|
||||||
isEditingFormStatus: boolean,
|
|
||||||
) => void;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renderiza o badge de situação
|
* Renderiza o badge de situação
|
||||||
*/
|
*/
|
||||||
function StatusBadge({ situacao }: { situacao: "A" | "I" }) {
|
function StatusBadge({ situacao }: { situacao: 'A' | 'I' }) {
|
||||||
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 =
|
const activeClasses = 'bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-300';
|
||||||
"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-300";
|
|
||||||
|
|
||||||
const inactiveClasses =
|
const inactiveClasses = 'bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300';
|
||||||
"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300";
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<span
|
<span className={`${baseClasses} ${isActive ? activeClasses : inactiveClasses}`}>
|
||||||
className={`${baseClasses} ${isActive ? activeClasses : inactiveClasses}`}
|
{isActive ? 'Ativo' : 'Inativo'}
|
||||||
>
|
|
||||||
{isActive ? "Ativo" : "Inativo"}
|
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -74,9 +64,7 @@ export default function GTBTipoLogradouroTable({
|
||||||
<TableBody>
|
<TableBody>
|
||||||
{data.map((item) => (
|
{data.map((item) => (
|
||||||
<TableRow key={item.tb_tipologradouro_id} className="cursor-pointer">
|
<TableRow key={item.tb_tipologradouro_id} className="cursor-pointer">
|
||||||
<TableCell className="font-medium">
|
<TableCell className="font-medium">{item.tb_tipologradouro_id}</TableCell>
|
||||||
{item.tb_tipologradouro_id}
|
|
||||||
</TableCell>
|
|
||||||
|
|
||||||
<TableCell>
|
<TableCell>
|
||||||
<StatusBadge situacao={item.situacao} />
|
<StatusBadge situacao={item.situacao} />
|
||||||
|
|
@ -87,11 +75,7 @@ export default function GTBTipoLogradouroTable({
|
||||||
<TableCell className="text-right">
|
<TableCell className="text-right">
|
||||||
<DropdownMenu>
|
<DropdownMenu>
|
||||||
<DropdownMenuTrigger asChild>
|
<DropdownMenuTrigger asChild>
|
||||||
<Button
|
<Button variant="outline" size="icon" className="cursor-pointer">
|
||||||
variant="outline"
|
|
||||||
size="icon"
|
|
||||||
className="cursor-pointer"
|
|
||||||
>
|
|
||||||
<EllipsisIcon />
|
<EllipsisIcon />
|
||||||
</Button>
|
</Button>
|
||||||
</DropdownMenuTrigger>
|
</DropdownMenuTrigger>
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
"use client";
|
'use client';
|
||||||
|
|
||||||
import z from "zod";
|
import z from 'zod';
|
||||||
import { useEffect } from "react";
|
import { useEffect } from 'react';
|
||||||
import { useForm, Controller } from "react-hook-form";
|
import { useForm, Controller } from 'react-hook-form';
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from '@hookform/resolvers/zod';
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from '@/components/ui/button';
|
||||||
import { Checkbox } from "@/components/ui/checkbox";
|
import { Checkbox } from '@/components/ui/checkbox';
|
||||||
import {
|
import {
|
||||||
Dialog,
|
Dialog,
|
||||||
DialogClose,
|
DialogClose,
|
||||||
|
|
@ -15,7 +15,7 @@ import {
|
||||||
DialogFooter,
|
DialogFooter,
|
||||||
DialogHeader,
|
DialogHeader,
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
} from "@/components/ui/dialog";
|
} from '@/components/ui/dialog';
|
||||||
import {
|
import {
|
||||||
Form,
|
Form,
|
||||||
FormControl,
|
FormControl,
|
||||||
|
|
@ -23,13 +23,13 @@ import {
|
||||||
FormItem,
|
FormItem,
|
||||||
FormLabel,
|
FormLabel,
|
||||||
FormMessage,
|
FormMessage,
|
||||||
} from "@/components/ui/form";
|
} from '@/components/ui/form';
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from '@/components/ui/input';
|
||||||
import { Label } from "@/components/ui/label";
|
import { Label } from '@/components/ui/label';
|
||||||
|
|
||||||
import { TCensecSchema } from "../../_schemas/TCensecSchema";
|
import { TCensecSchema } from '../../_schemas/TCensecSchema';
|
||||||
import { SituacoesEnum } from "@/enums/SituacoesEnum";
|
import { SituacoesEnum } from '@/enums/SituacoesEnum';
|
||||||
import LoadingButton from "@/app/_components/loadingButton/LoadingButton";
|
import LoadingButton from '@/app/_components/loadingButton/LoadingButton';
|
||||||
|
|
||||||
type FormValues = z.infer<typeof TCensecSchema>;
|
type FormValues = z.infer<typeof TCensecSchema>;
|
||||||
|
|
||||||
|
|
@ -41,18 +41,12 @@ interface Props {
|
||||||
buttonIsLoading: boolean;
|
buttonIsLoading: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function TCensecForm({
|
export default function TCensecForm({ isOpen, data, onClose, onSave, buttonIsLoading }: Props) {
|
||||||
isOpen,
|
|
||||||
data,
|
|
||||||
onClose,
|
|
||||||
onSave,
|
|
||||||
buttonIsLoading,
|
|
||||||
}: Props) {
|
|
||||||
// Inicializa o react-hook-form com schema zod
|
// Inicializa o react-hook-form com schema zod
|
||||||
const form = useForm<FormValues>({
|
const form = useForm<FormValues>({
|
||||||
resolver: zodResolver(TCensecSchema),
|
resolver: zodResolver(TCensecSchema),
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
descricao: "",
|
descricao: '',
|
||||||
situacao: SituacoesEnum.A,
|
situacao: SituacoesEnum.A,
|
||||||
censec_id: 0,
|
censec_id: 0,
|
||||||
},
|
},
|
||||||
|
|
@ -86,11 +80,7 @@ export default function TCensecForm({
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>Descrição</FormLabel>
|
<FormLabel>Descrição</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input
|
<Input type="text" {...field} placeholder="Digite a descrição" />
|
||||||
type="text"
|
|
||||||
{...field}
|
|
||||||
placeholder="Digite a descrição"
|
|
||||||
/>
|
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
|
@ -104,10 +94,8 @@ export default function TCensecForm({
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<div className="flex items-center space-x-2">
|
<div className="flex items-center space-x-2">
|
||||||
<Checkbox
|
<Checkbox
|
||||||
checked={field.value === "A"}
|
checked={field.value === 'A'}
|
||||||
onCheckedChange={(checked) =>
|
onCheckedChange={(checked) => field.onChange(checked ? 'A' : 'I')}
|
||||||
field.onChange(checked ? "A" : "I")
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
<Label>Ativo</Label>
|
<Label>Ativo</Label>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -136,7 +124,7 @@ export default function TCensecForm({
|
||||||
</DialogFooter>
|
</DialogFooter>
|
||||||
|
|
||||||
{/* Campo oculto */}
|
{/* Campo oculto */}
|
||||||
<input type="hidden" {...form.register("censec_id")} />
|
<input type="hidden" {...form.register('censec_id')} />
|
||||||
</form>
|
</form>
|
||||||
</Form>
|
</Form>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
"use client";
|
'use client';
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from '@/components/ui/button';
|
||||||
import {
|
import {
|
||||||
DropdownMenu,
|
DropdownMenu,
|
||||||
DropdownMenuContent,
|
DropdownMenuContent,
|
||||||
|
|
@ -8,7 +8,7 @@ import {
|
||||||
DropdownMenuItem,
|
DropdownMenuItem,
|
||||||
DropdownMenuSeparator,
|
DropdownMenuSeparator,
|
||||||
DropdownMenuTrigger,
|
DropdownMenuTrigger,
|
||||||
} from "@/components/ui/dropdown-menu";
|
} from '@/components/ui/dropdown-menu';
|
||||||
import {
|
import {
|
||||||
Table,
|
Table,
|
||||||
TableBody,
|
TableBody,
|
||||||
|
|
@ -16,10 +16,10 @@ import {
|
||||||
TableHead,
|
TableHead,
|
||||||
TableHeader,
|
TableHeader,
|
||||||
TableRow,
|
TableRow,
|
||||||
} from "@/components/ui/table";
|
} from '@/components/ui/table';
|
||||||
|
|
||||||
import { EllipsisIcon, PencilIcon, Trash2Icon } from "lucide-react";
|
import { EllipsisIcon, PencilIcon, Trash2Icon } from 'lucide-react';
|
||||||
import TCensecInterface from "../../_interfaces/TCensecInterface";
|
import TCensecInterface from '../../_interfaces/TCensecInterface';
|
||||||
|
|
||||||
interface TCensecTableProps {
|
interface TCensecTableProps {
|
||||||
data: TCensecInterface[];
|
data: TCensecInterface[];
|
||||||
|
|
@ -31,30 +31,22 @@ interface TCensecTableProps {
|
||||||
* Renderiza o badge de situação
|
* Renderiza o badge de situação
|
||||||
*/
|
*/
|
||||||
function StatusBadge({ situacao }: { situacao: string }) {
|
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 =
|
const activeClasses = 'bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-300';
|
||||||
"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-300";
|
|
||||||
|
|
||||||
const inactiveClasses =
|
const inactiveClasses = 'bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300';
|
||||||
"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300";
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<span
|
<span className={`${baseClasses} ${isActive ? activeClasses : inactiveClasses}`}>
|
||||||
className={`${baseClasses} ${isActive ? activeClasses : inactiveClasses}`}
|
{isActive ? 'Ativo' : 'Inativo'}
|
||||||
>
|
|
||||||
{isActive ? "Ativo" : "Inativo"}
|
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function TCensecTable({
|
export default function TCensecTable({ data, onEdit, onDelete }: TCensecTableProps) {
|
||||||
data,
|
|
||||||
onEdit,
|
|
||||||
onDelete,
|
|
||||||
}: TCensecTableProps) {
|
|
||||||
return (
|
return (
|
||||||
<Table>
|
<Table>
|
||||||
<TableHeader>
|
<TableHeader>
|
||||||
|
|
@ -81,11 +73,7 @@ export default function TCensecTable({
|
||||||
<TableCell className="text-right">
|
<TableCell className="text-right">
|
||||||
<DropdownMenu>
|
<DropdownMenu>
|
||||||
<DropdownMenuTrigger asChild>
|
<DropdownMenuTrigger asChild>
|
||||||
<Button
|
<Button variant="outline" size="icon" className="cursor-pointer">
|
||||||
variant="outline"
|
|
||||||
size="icon"
|
|
||||||
className="cursor-pointer"
|
|
||||||
>
|
|
||||||
<EllipsisIcon />
|
<EllipsisIcon />
|
||||||
</Button>
|
</Button>
|
||||||
</DropdownMenuTrigger>
|
</DropdownMenuTrigger>
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
"use client";
|
'use client';
|
||||||
|
|
||||||
import z from "zod";
|
import z from 'zod';
|
||||||
import { useEffect } from "react";
|
import { useEffect } from 'react';
|
||||||
import { useForm, Controller } from "react-hook-form";
|
import { useForm, Controller } from 'react-hook-form';
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from '@hookform/resolvers/zod';
|
||||||
|
|
||||||
import LoadingButton from "@/app/_components/loadingButton/LoadingButton";
|
import LoadingButton from '@/app/_components/loadingButton/LoadingButton';
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from '@/components/ui/button';
|
||||||
import { Checkbox } from "@/components/ui/checkbox";
|
import { Checkbox } from '@/components/ui/checkbox';
|
||||||
import {
|
import {
|
||||||
Dialog,
|
Dialog,
|
||||||
DialogClose,
|
DialogClose,
|
||||||
|
|
@ -16,7 +16,7 @@ import {
|
||||||
DialogFooter,
|
DialogFooter,
|
||||||
DialogHeader,
|
DialogHeader,
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
} from "@/components/ui/dialog";
|
} from '@/components/ui/dialog';
|
||||||
import {
|
import {
|
||||||
Form,
|
Form,
|
||||||
FormControl,
|
FormControl,
|
||||||
|
|
@ -24,11 +24,11 @@ import {
|
||||||
FormItem,
|
FormItem,
|
||||||
FormLabel,
|
FormLabel,
|
||||||
FormMessage,
|
FormMessage,
|
||||||
} from "@/components/ui/form";
|
} from '@/components/ui/form';
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from '@/components/ui/input';
|
||||||
import { Label } from "@/components/ui/label";
|
import { Label } from '@/components/ui/label';
|
||||||
|
|
||||||
import { TCensecNaturezaLitigioSchema } from "../../_schemas/TCensecNaturezaLitigioSchema";
|
import { TCensecNaturezaLitigioSchema } from '../../_schemas/TCensecNaturezaLitigioSchema';
|
||||||
|
|
||||||
type FormValues = z.infer<typeof TCensecNaturezaLitigioSchema>;
|
type FormValues = z.infer<typeof TCensecNaturezaLitigioSchema>;
|
||||||
|
|
||||||
|
|
@ -51,8 +51,8 @@ export default function TCensecNaturezaLitigioForm({
|
||||||
resolver: zodResolver(TCensecNaturezaLitigioSchema),
|
resolver: zodResolver(TCensecNaturezaLitigioSchema),
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
censec_naturezalitigio_id: 0,
|
censec_naturezalitigio_id: 0,
|
||||||
descricao: "",
|
descricao: '',
|
||||||
situacao: "A",
|
situacao: 'A',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -70,9 +70,7 @@ export default function TCensecNaturezaLitigioForm({
|
||||||
<DialogContent className="sm:max-w-[425px]">
|
<DialogContent className="sm:max-w-[425px]">
|
||||||
<DialogHeader>
|
<DialogHeader>
|
||||||
<DialogTitle>Natureza do Litígio</DialogTitle>
|
<DialogTitle>Natureza do Litígio</DialogTitle>
|
||||||
<DialogDescription>
|
<DialogDescription>Crie ou edite uma natureza do litígio</DialogDescription>
|
||||||
Crie ou edite uma natureza do litígio
|
|
||||||
</DialogDescription>
|
|
||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
|
|
||||||
<Form {...form}>
|
<Form {...form}>
|
||||||
|
|
@ -99,10 +97,8 @@ export default function TCensecNaturezaLitigioForm({
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<div className="flex items-center space-x-2">
|
<div className="flex items-center space-x-2">
|
||||||
<Checkbox
|
<Checkbox
|
||||||
checked={field.value === "A"}
|
checked={field.value === 'A'}
|
||||||
onCheckedChange={(checked) =>
|
onCheckedChange={(checked) => field.onChange(checked ? 'A' : 'I')}
|
||||||
field.onChange(checked ? "A" : "I")
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
<Label>Ativo</Label>
|
<Label>Ativo</Label>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -112,11 +108,7 @@ export default function TCensecNaturezaLitigioForm({
|
||||||
{/* Rodapé */}
|
{/* Rodapé */}
|
||||||
<DialogFooter className="mt-4">
|
<DialogFooter className="mt-4">
|
||||||
<DialogClose asChild>
|
<DialogClose asChild>
|
||||||
<Button
|
<Button variant="outline" type="button" onClick={() => onClose(null, false)}>
|
||||||
variant="outline"
|
|
||||||
type="button"
|
|
||||||
onClick={() => onClose(null, false)}
|
|
||||||
>
|
|
||||||
Cancelar
|
Cancelar
|
||||||
</Button>
|
</Button>
|
||||||
</DialogClose>
|
</DialogClose>
|
||||||
|
|
@ -130,10 +122,7 @@ export default function TCensecNaturezaLitigioForm({
|
||||||
</DialogFooter>
|
</DialogFooter>
|
||||||
|
|
||||||
{/* Campo oculto */}
|
{/* Campo oculto */}
|
||||||
<input
|
<input type="hidden" {...form.register('censec_naturezalitigio_id')} />
|
||||||
type="hidden"
|
|
||||||
{...form.register("censec_naturezalitigio_id")}
|
|
||||||
/>
|
|
||||||
</form>
|
</form>
|
||||||
</Form>
|
</Form>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
"use client";
|
'use client';
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from '@/components/ui/button';
|
||||||
import {
|
import {
|
||||||
DropdownMenu,
|
DropdownMenu,
|
||||||
DropdownMenuContent,
|
DropdownMenuContent,
|
||||||
|
|
@ -8,7 +8,7 @@ import {
|
||||||
DropdownMenuItem,
|
DropdownMenuItem,
|
||||||
DropdownMenuSeparator,
|
DropdownMenuSeparator,
|
||||||
DropdownMenuTrigger,
|
DropdownMenuTrigger,
|
||||||
} from "@/components/ui/dropdown-menu";
|
} from '@/components/ui/dropdown-menu';
|
||||||
import {
|
import {
|
||||||
Table,
|
Table,
|
||||||
TableBody,
|
TableBody,
|
||||||
|
|
@ -16,41 +16,31 @@ import {
|
||||||
TableHead,
|
TableHead,
|
||||||
TableHeader,
|
TableHeader,
|
||||||
TableRow,
|
TableRow,
|
||||||
} from "@/components/ui/table";
|
} from '@/components/ui/table';
|
||||||
import { EllipsisIcon, PencilIcon, Trash2Icon } from "lucide-react";
|
import { EllipsisIcon, PencilIcon, Trash2Icon } from 'lucide-react';
|
||||||
import { TCensecNaturezaLitigioInterface } from "../../_interfaces/TCensecNaturezaLitigioInterface";
|
import { TCensecNaturezaLitigioInterface } from '../../_interfaces/TCensecNaturezaLitigioInterface';
|
||||||
|
|
||||||
interface TCensecNaturezaLitigioTableProps {
|
interface TCensecNaturezaLitigioTableProps {
|
||||||
data: TCensecNaturezaLitigioInterface[];
|
data: TCensecNaturezaLitigioInterface[];
|
||||||
onEdit: (
|
onEdit: (item: TCensecNaturezaLitigioInterface, isEditingFormStatus: boolean) => void;
|
||||||
item: TCensecNaturezaLitigioInterface,
|
onDelete: (item: TCensecNaturezaLitigioInterface, isEditingFormStatus: boolean) => void;
|
||||||
isEditingFormStatus: boolean,
|
|
||||||
) => void;
|
|
||||||
onDelete: (
|
|
||||||
item: TCensecNaturezaLitigioInterface,
|
|
||||||
isEditingFormStatus: boolean,
|
|
||||||
) => void;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renderiza o badge de situação
|
* Renderiza o badge de situação
|
||||||
*/
|
*/
|
||||||
function StatusBadge({ situacao }: { situacao: "A" | "I" }) {
|
function StatusBadge({ situacao }: { situacao: 'A' | 'I' }) {
|
||||||
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 =
|
const activeClasses = 'bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-300';
|
||||||
"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-300";
|
|
||||||
|
|
||||||
const inactiveClasses =
|
const inactiveClasses = 'bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300';
|
||||||
"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300";
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<span
|
<span className={`${baseClasses} ${isActive ? activeClasses : inactiveClasses}`}>
|
||||||
className={`${baseClasses} ${isActive ? activeClasses : inactiveClasses}`}
|
{isActive ? 'Ativo' : 'Inativo'}
|
||||||
>
|
|
||||||
{isActive ? "Ativo" : "Inativo"}
|
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -73,13 +63,8 @@ export default function TCensecNaturezaLitigioTable({
|
||||||
|
|
||||||
<TableBody>
|
<TableBody>
|
||||||
{data.map((item) => (
|
{data.map((item) => (
|
||||||
<TableRow
|
<TableRow key={item.censec_naturezalitigio_id} className="cursor-pointer">
|
||||||
key={item.censec_naturezalitigio_id}
|
<TableCell className="font-medium">{item.censec_naturezalitigio_id}</TableCell>
|
||||||
className="cursor-pointer"
|
|
||||||
>
|
|
||||||
<TableCell className="font-medium">
|
|
||||||
{item.censec_naturezalitigio_id}
|
|
||||||
</TableCell>
|
|
||||||
|
|
||||||
<TableCell>
|
<TableCell>
|
||||||
<StatusBadge situacao={item.situacao} />
|
<StatusBadge situacao={item.situacao} />
|
||||||
|
|
@ -90,11 +75,7 @@ export default function TCensecNaturezaLitigioTable({
|
||||||
<TableCell className="text-right">
|
<TableCell className="text-right">
|
||||||
<DropdownMenu>
|
<DropdownMenu>
|
||||||
<DropdownMenuTrigger asChild>
|
<DropdownMenuTrigger asChild>
|
||||||
<Button
|
<Button variant="outline" size="icon" className="cursor-pointer">
|
||||||
variant="outline"
|
|
||||||
size="icon"
|
|
||||||
className="cursor-pointer"
|
|
||||||
>
|
|
||||||
<EllipsisIcon />
|
<EllipsisIcon />
|
||||||
</Button>
|
</Button>
|
||||||
</DropdownMenuTrigger>
|
</DropdownMenuTrigger>
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
"use client";
|
'use client';
|
||||||
|
|
||||||
import z from "zod";
|
import z from 'zod';
|
||||||
import { useEffect } from "react";
|
import { useEffect } from 'react';
|
||||||
import { useForm, Controller } from "react-hook-form";
|
import { useForm, Controller } from 'react-hook-form';
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from '@hookform/resolvers/zod';
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from '@/components/ui/button';
|
||||||
import { Checkbox } from "@/components/ui/checkbox";
|
import { Checkbox } from '@/components/ui/checkbox';
|
||||||
import {
|
import {
|
||||||
Dialog,
|
Dialog,
|
||||||
DialogClose,
|
DialogClose,
|
||||||
|
|
@ -15,7 +15,7 @@ import {
|
||||||
DialogFooter,
|
DialogFooter,
|
||||||
DialogHeader,
|
DialogHeader,
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
} from "@/components/ui/dialog";
|
} from '@/components/ui/dialog';
|
||||||
import {
|
import {
|
||||||
Form,
|
Form,
|
||||||
FormControl,
|
FormControl,
|
||||||
|
|
@ -23,13 +23,13 @@ import {
|
||||||
FormItem,
|
FormItem,
|
||||||
FormLabel,
|
FormLabel,
|
||||||
FormMessage,
|
FormMessage,
|
||||||
} from "@/components/ui/form";
|
} from '@/components/ui/form';
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from '@/components/ui/input';
|
||||||
import { Label } from "@/components/ui/label";
|
import { Label } from '@/components/ui/label';
|
||||||
|
|
||||||
import MainEditor from "@/components/MainEditor";
|
import MainEditor from '@/components/MainEditor';
|
||||||
import { TMinutaInterface } from "../../_interfaces/TMinutaInterface";
|
import { TMinutaInterface } from '../../_interfaces/TMinutaInterface';
|
||||||
import { TMinutaSchema } from "../../_schemas/TMinutaSchema";
|
import { TMinutaSchema } from '../../_schemas/TMinutaSchema';
|
||||||
|
|
||||||
type FormValues = z.infer<typeof TMinutaSchema>;
|
type FormValues = z.infer<typeof TMinutaSchema>;
|
||||||
|
|
||||||
|
|
@ -40,20 +40,15 @@ interface TMinutaFormProps {
|
||||||
onSave: (data: FormValues) => void;
|
onSave: (data: FormValues) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function TMinutaForm({
|
export default function TMinutaForm({ isOpen, data, onClose, onSave }: TMinutaFormProps) {
|
||||||
isOpen,
|
|
||||||
data,
|
|
||||||
onClose,
|
|
||||||
onSave,
|
|
||||||
}: TMinutaFormProps) {
|
|
||||||
const form = useForm<FormValues>({
|
const form = useForm<FormValues>({
|
||||||
resolver: zodResolver(TMinutaSchema),
|
resolver: zodResolver(TMinutaSchema),
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
minuta_id: 0,
|
minuta_id: 0,
|
||||||
natureza_id: undefined,
|
natureza_id: undefined,
|
||||||
descricao: "",
|
descricao: '',
|
||||||
situacao: "A",
|
situacao: 'A',
|
||||||
texto: "",
|
texto: '',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -69,13 +64,11 @@ export default function TMinutaForm({
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<DialogContent className="mx-auto">
|
<DialogContent className="mx-auto">
|
||||||
{" "}
|
{' '}
|
||||||
{/* tamanho maior para comportar o editor */}
|
{/* tamanho maior para comportar o editor */}
|
||||||
<DialogHeader>
|
<DialogHeader>
|
||||||
<DialogTitle>Minuta</DialogTitle>
|
<DialogTitle>Minuta</DialogTitle>
|
||||||
<DialogDescription>
|
<DialogDescription>Crie ou edite uma minuta de ato notarial.</DialogDescription>
|
||||||
Crie ou edite uma minuta de ato notarial.
|
|
||||||
</DialogDescription>
|
|
||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
<Form {...form}>
|
<Form {...form}>
|
||||||
<form onSubmit={form.handleSubmit(onSave)} className="space-y-6">
|
<form onSubmit={form.handleSubmit(onSave)} className="space-y-6">
|
||||||
|
|
@ -87,10 +80,7 @@ export default function TMinutaForm({
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>Descrição</FormLabel>
|
<FormLabel>Descrição</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input
|
<Input {...field} placeholder="Digite a descrição da minuta" />
|
||||||
{...field}
|
|
||||||
placeholder="Digite a descrição da minuta"
|
|
||||||
/>
|
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
|
@ -104,12 +94,10 @@ export default function TMinutaForm({
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<div className="flex items-center space-x-2">
|
<div className="flex items-center space-x-2">
|
||||||
<Checkbox
|
<Checkbox
|
||||||
checked={field.value === "A"}
|
checked={field.value === 'A'}
|
||||||
onCheckedChange={(checked) =>
|
onCheckedChange={(checked) => field.onChange(checked ? 'A' : 'I')}
|
||||||
field.onChange(checked ? "A" : "I")
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
<Label>{field.value === "A" ? "Ativo" : "Inativo"}</Label>
|
<Label>{field.value === 'A' ? 'Ativo' : 'Inativo'}</Label>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|
@ -121,13 +109,13 @@ export default function TMinutaForm({
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<div>
|
<div>
|
||||||
<MainEditor
|
<MainEditor
|
||||||
initialValue={field.value || ""}
|
initialValue={field.value || ''}
|
||||||
onEditorChange={field.onChange}
|
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 }}
|
size={{ width: 800, height: 500 }}
|
||||||
/>
|
/>
|
||||||
{form.formState.errors.texto && (
|
{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}
|
{form.formState.errors.texto.message}
|
||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
|
|
@ -138,22 +126,18 @@ export default function TMinutaForm({
|
||||||
{/* Rodapé do Dialog */}
|
{/* Rodapé do Dialog */}
|
||||||
<DialogFooter className="mt-4">
|
<DialogFooter className="mt-4">
|
||||||
<DialogClose asChild>
|
<DialogClose asChild>
|
||||||
<Button
|
<Button variant="outline" type="button" onClick={() => onClose(null, false)}>
|
||||||
variant="outline"
|
|
||||||
type="button"
|
|
||||||
onClick={() => onClose(null, false)}
|
|
||||||
>
|
|
||||||
Cancelar
|
Cancelar
|
||||||
</Button>
|
</Button>
|
||||||
</DialogClose>
|
</DialogClose>
|
||||||
<Button type="submit" disabled={form.formState.isSubmitting}>
|
<Button type="submit" disabled={form.formState.isSubmitting}>
|
||||||
{form.formState.isSubmitting ? "Salvando..." : "Salvar"}
|
{form.formState.isSubmitting ? 'Salvando...' : 'Salvar'}
|
||||||
</Button>
|
</Button>
|
||||||
</DialogFooter>
|
</DialogFooter>
|
||||||
|
|
||||||
{/* Campos ocultos */}
|
{/* Campos ocultos */}
|
||||||
<input type="hidden" {...form.register("minuta_id")} />
|
<input type="hidden" {...form.register('minuta_id')} />
|
||||||
<input type="hidden" {...form.register("natureza_id")} />
|
<input type="hidden" {...form.register('natureza_id')} />
|
||||||
</form>
|
</form>
|
||||||
</Form>
|
</Form>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
"use client";
|
'use client';
|
||||||
|
|
||||||
import Link from "next/link";
|
import Link from 'next/link';
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from '@/components/ui/button';
|
||||||
import {
|
import {
|
||||||
DropdownMenu,
|
DropdownMenu,
|
||||||
DropdownMenuContent,
|
DropdownMenuContent,
|
||||||
|
|
@ -9,7 +9,7 @@ import {
|
||||||
DropdownMenuItem,
|
DropdownMenuItem,
|
||||||
DropdownMenuSeparator,
|
DropdownMenuSeparator,
|
||||||
DropdownMenuTrigger,
|
DropdownMenuTrigger,
|
||||||
} from "@/components/ui/dropdown-menu";
|
} from '@/components/ui/dropdown-menu';
|
||||||
import {
|
import {
|
||||||
Table,
|
Table,
|
||||||
TableBody,
|
TableBody,
|
||||||
|
|
@ -17,9 +17,9 @@ import {
|
||||||
TableHead,
|
TableHead,
|
||||||
TableHeader,
|
TableHeader,
|
||||||
TableRow,
|
TableRow,
|
||||||
} from "@/components/ui/table";
|
} from '@/components/ui/table';
|
||||||
import { EllipsisIcon, PencilIcon, Trash2Icon } from "lucide-react";
|
import { EllipsisIcon, PencilIcon, Trash2Icon } from 'lucide-react';
|
||||||
import { TMinutaInterface } from "../../_interfaces/TMinutaInterface";
|
import { TMinutaInterface } from '../../_interfaces/TMinutaInterface';
|
||||||
|
|
||||||
interface TMinutaTableProps {
|
interface TMinutaTableProps {
|
||||||
data: TMinutaInterface[];
|
data: TMinutaInterface[];
|
||||||
|
|
@ -30,22 +30,18 @@ interface TMinutaTableProps {
|
||||||
/**
|
/**
|
||||||
* Renderiza o badge de situação
|
* Renderiza o badge de situação
|
||||||
*/
|
*/
|
||||||
function StatusBadge({ situacao }: { situacao: "A" | "I" }) {
|
function StatusBadge({ situacao }: { situacao: 'A' | 'I' }) {
|
||||||
const isActive = situacao === "A";
|
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 =
|
const activeClasses = 'bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-300';
|
||||||
"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-300";
|
|
||||||
|
|
||||||
const inactiveClasses =
|
const inactiveClasses = 'bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300';
|
||||||
"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300";
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<span
|
<span className={`${baseClasses} ${isActive ? activeClasses : inactiveClasses}`}>
|
||||||
className={`${baseClasses} ${isActive ? activeClasses : inactiveClasses}`}
|
{isActive ? 'Ativo' : 'Inativo'}
|
||||||
>
|
|
||||||
{isActive ? "Ativo" : "Inativo"}
|
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -64,10 +60,7 @@ export default function TMinutaTable({ data }: TMinutaTableProps) {
|
||||||
<TableBody>
|
<TableBody>
|
||||||
{data.length === 0 ? (
|
{data.length === 0 ? (
|
||||||
<TableRow>
|
<TableRow>
|
||||||
<TableCell
|
<TableCell colSpan={4} className="text-muted-foreground text-center">
|
||||||
colSpan={4}
|
|
||||||
className="text-center text-muted-foreground"
|
|
||||||
>
|
|
||||||
Nenhuma minuta encontrada.
|
Nenhuma minuta encontrada.
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
|
@ -84,9 +77,7 @@ export default function TMinutaTable({ data }: TMinutaTableProps) {
|
||||||
|
|
||||||
<TableCell className="text-right">
|
<TableCell className="text-right">
|
||||||
<Button asChild>
|
<Button asChild>
|
||||||
<Link href={`/cadastros/minuta/${item.t_minuta_id}/detalhes`}>
|
<Link href={`/cadastros/minuta/${item.t_minuta_id}/detalhes`}>Detalhes</Link>
|
||||||
Detalhes
|
|
||||||
</Link>
|
|
||||||
</Button>
|
</Button>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
"use client";
|
'use client';
|
||||||
|
|
||||||
import z from "zod";
|
import z from 'zod';
|
||||||
import React, { useEffect } from "react";
|
import React, { useEffect } from 'react';
|
||||||
import { useForm, Controller } from "react-hook-form";
|
import { useForm, Controller } from 'react-hook-form';
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from '@hookform/resolvers/zod';
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from '@/components/ui/button';
|
||||||
import {
|
import {
|
||||||
Dialog,
|
Dialog,
|
||||||
DialogClose,
|
DialogClose,
|
||||||
|
|
@ -14,7 +14,7 @@ import {
|
||||||
DialogFooter,
|
DialogFooter,
|
||||||
DialogHeader,
|
DialogHeader,
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
} from "@/components/ui/dialog";
|
} from '@/components/ui/dialog';
|
||||||
import {
|
import {
|
||||||
Form,
|
Form,
|
||||||
FormControl,
|
FormControl,
|
||||||
|
|
@ -22,36 +22,26 @@ import {
|
||||||
FormItem,
|
FormItem,
|
||||||
FormLabel,
|
FormLabel,
|
||||||
FormMessage,
|
FormMessage,
|
||||||
} from "@/components/ui/form";
|
} from '@/components/ui/form';
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from '@/components/ui/input';
|
||||||
|
|
||||||
import { TPessoaSchema } from "../../_schemas/TPessoaSchema";
|
import { TPessoaSchema } from '../../_schemas/TPessoaSchema';
|
||||||
import LoadingButton from "@/app/_components/loadingButton/LoadingButton";
|
import LoadingButton from '@/app/_components/loadingButton/LoadingButton';
|
||||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
|
||||||
import {
|
import {
|
||||||
Select,
|
Select,
|
||||||
SelectContent,
|
SelectContent,
|
||||||
SelectItem,
|
SelectItem,
|
||||||
SelectTrigger,
|
SelectTrigger,
|
||||||
SelectValue,
|
SelectValue,
|
||||||
} from "@/components/ui/select";
|
} from '@/components/ui/select';
|
||||||
import {
|
import { CheckIcon, ChevronsUpDownIcon, HouseIcon, IdCardIcon, UserIcon } from 'lucide-react';
|
||||||
CheckIcon,
|
import { Sexo } from '@/enums/SexoEnum';
|
||||||
ChevronsUpDownIcon,
|
import { useGTBEstadoCivilReadHook } from '../../_hooks/g_tb_estadocivil/useGTBEstadoCivilReadHook';
|
||||||
HouseIcon,
|
import GetCapitalize from '@/actions/text/GetCapitalize';
|
||||||
IdCardIcon,
|
import { useGTBRegimeComunhaoReadHook } from '../../_hooks/g_tb_regimecomunhao/useGTBRegimeComunhaoReadHook';
|
||||||
UserIcon,
|
import { useGTBProfissaoReadHook } from '../../_hooks/g_tb_profissao/useGTBProfissaoReadHook';
|
||||||
} from "lucide-react";
|
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';
|
||||||
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 {
|
import {
|
||||||
Command,
|
Command,
|
||||||
CommandEmpty,
|
CommandEmpty,
|
||||||
|
|
@ -59,8 +49,8 @@ import {
|
||||||
CommandInput,
|
CommandInput,
|
||||||
CommandItem,
|
CommandItem,
|
||||||
CommandList,
|
CommandList,
|
||||||
} from "@/components/ui/command";
|
} from '@/components/ui/command';
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from '@/lib/utils';
|
||||||
|
|
||||||
type FormValues = z.infer<typeof TPessoaSchema>;
|
type FormValues = z.infer<typeof TPessoaSchema>;
|
||||||
|
|
||||||
|
|
@ -81,14 +71,13 @@ export default function TCensecForm({
|
||||||
}: TPessoaFormProps) {
|
}: TPessoaFormProps) {
|
||||||
const { gTBProfissao, fetchGTBProfissao } = useGTBProfissaoReadHook();
|
const { gTBProfissao, fetchGTBProfissao } = useGTBProfissaoReadHook();
|
||||||
const { gTBEstadoCivil, fetchGTBEstadoCivil } = useGTBEstadoCivilReadHook();
|
const { gTBEstadoCivil, fetchGTBEstadoCivil } = useGTBEstadoCivilReadHook();
|
||||||
const { gTBRegimeComunhao, fetchGTBRegimeComunhao } =
|
const { gTBRegimeComunhao, fetchGTBRegimeComunhao } = useGTBRegimeComunhaoReadHook();
|
||||||
useGTBRegimeComunhaoReadHook();
|
|
||||||
|
|
||||||
// Inicializa o react-hook-form com schema zod
|
// Inicializa o react-hook-form com schema zod
|
||||||
const form = useForm<FormValues>({
|
const form = useForm<FormValues>({
|
||||||
resolver: zodResolver(TPessoaSchema),
|
resolver: zodResolver(TPessoaSchema),
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
nome: "",
|
nome: '',
|
||||||
pessoa_id: 0,
|
pessoa_id: 0,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
@ -117,7 +106,7 @@ export default function TCensecForm({
|
||||||
if (!open) onClose(null, false);
|
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>
|
<DialogHeader>
|
||||||
<DialogTitle>Pessoa</DialogTitle>
|
<DialogTitle>Pessoa</DialogTitle>
|
||||||
<DialogDescription>Preencha os dados da pessoa</DialogDescription>
|
<DialogDescription>Preencha os dados da pessoa</DialogDescription>
|
||||||
|
|
@ -127,31 +116,22 @@ export default function TCensecForm({
|
||||||
<form onSubmit={form.handleSubmit(onSave)} className="space-y-6">
|
<form onSubmit={form.handleSubmit(onSave)} className="space-y-6">
|
||||||
{/* Tabs */}
|
{/* Tabs */}
|
||||||
<Tabs defaultValue="dadosPessoais" className="space-y-4">
|
<Tabs defaultValue="dadosPessoais" className="space-y-4">
|
||||||
<TabsList className="w-full flex">
|
<TabsList className="flex w-full">
|
||||||
<TabsTrigger
|
<TabsTrigger className="flex-1 cursor-pointer text-center" value="dadosPessoais">
|
||||||
className="flex-1 text-center cursor-pointer"
|
|
||||||
value="dadosPessoais"
|
|
||||||
>
|
|
||||||
<UserIcon className="me-1" />
|
<UserIcon className="me-1" />
|
||||||
Dados Pessoais
|
Dados Pessoais
|
||||||
</TabsTrigger>
|
</TabsTrigger>
|
||||||
<TabsTrigger
|
<TabsTrigger className="flex-1 cursor-pointer text-center" value="endereco">
|
||||||
className="flex-1 text-center cursor-pointer"
|
|
||||||
value="endereco"
|
|
||||||
>
|
|
||||||
<HouseIcon /> Endereço
|
<HouseIcon /> Endereço
|
||||||
</TabsTrigger>
|
</TabsTrigger>
|
||||||
<TabsTrigger
|
<TabsTrigger className="flex-1 cursor-pointer text-center" value="documentos">
|
||||||
className="flex-1 text-center cursor-pointer"
|
|
||||||
value="documentos"
|
|
||||||
>
|
|
||||||
<IdCardIcon /> Documentos
|
<IdCardIcon /> Documentos
|
||||||
</TabsTrigger>
|
</TabsTrigger>
|
||||||
</TabsList>
|
</TabsList>
|
||||||
|
|
||||||
{/* Dados Pessoais */}
|
{/* Dados Pessoais */}
|
||||||
<TabsContent value="dadosPessoais" className="space-y-4">
|
<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 */}
|
{/* Nome */}
|
||||||
<div className="col-span-12 sm:col-span-12 md:col-span-6">
|
<div className="col-span-12 sm:col-span-12 md:col-span-6">
|
||||||
<FormField
|
<FormField
|
||||||
|
|
@ -161,11 +141,7 @@ export default function TCensecForm({
|
||||||
<FormItem className="w-full">
|
<FormItem className="w-full">
|
||||||
<FormLabel>Nome</FormLabel>
|
<FormLabel>Nome</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input
|
<Input {...field} placeholder="Digite o nome" className="w-full" />
|
||||||
{...field}
|
|
||||||
placeholder="Digite o nome"
|
|
||||||
className="w-full"
|
|
||||||
/>
|
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
|
@ -197,22 +173,13 @@ export default function TCensecForm({
|
||||||
<FormItem className="w-full">
|
<FormItem className="w-full">
|
||||||
<FormLabel>Sexo</FormLabel>
|
<FormLabel>Sexo</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Select
|
<Select value={field.value} onValueChange={field.onChange}>
|
||||||
value={field.value}
|
|
||||||
onValueChange={field.onChange}
|
|
||||||
>
|
|
||||||
<SelectTrigger className="w-full">
|
<SelectTrigger className="w-full">
|
||||||
{field.value
|
{field.value ? Sexo[field.value as keyof typeof Sexo] : 'Selecione'}
|
||||||
? Sexo[field.value as keyof typeof Sexo]
|
|
||||||
: "Selecione"}
|
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
{Object.entries(Sexo).map(([key, label]) => (
|
{Object.entries(Sexo).map(([key, label]) => (
|
||||||
<SelectItem
|
<SelectItem key={key} value={key} className="cursor-pointer">
|
||||||
key={key}
|
|
||||||
value={key}
|
|
||||||
className="cursor-pointer"
|
|
||||||
>
|
|
||||||
{label}
|
{label}
|
||||||
</SelectItem>
|
</SelectItem>
|
||||||
))}
|
))}
|
||||||
|
|
@ -347,10 +314,9 @@ export default function TCensecForm({
|
||||||
{field.value
|
{field.value
|
||||||
? gTBEstadoCivil.find(
|
? gTBEstadoCivil.find(
|
||||||
(item) =>
|
(item) =>
|
||||||
String(item.tb_estadocivil_id) ===
|
String(item.tb_estadocivil_id) === String(field.value),
|
||||||
String(field.value),
|
|
||||||
)?.descricao
|
)?.descricao
|
||||||
: "Escolha o estado civil"}
|
: 'Escolha o estado civil'}
|
||||||
<ChevronsUpDownIcon className="ml-2 h-4 w-4 shrink-0 opacity-50" />
|
<ChevronsUpDownIcon className="ml-2 h-4 w-4 shrink-0 opacity-50" />
|
||||||
</Button>
|
</Button>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
|
|
@ -359,30 +325,23 @@ export default function TCensecForm({
|
||||||
<Command>
|
<Command>
|
||||||
<CommandInput placeholder="Buscar estado civil..." />
|
<CommandInput placeholder="Buscar estado civil..." />
|
||||||
<CommandList>
|
<CommandList>
|
||||||
<CommandEmpty>
|
<CommandEmpty>Nenhum resultado encontrado.</CommandEmpty>
|
||||||
Nenhum resultado encontrado.
|
|
||||||
</CommandEmpty>
|
|
||||||
<CommandGroup>
|
<CommandGroup>
|
||||||
{gTBEstadoCivil?.map((item) => (
|
{gTBEstadoCivil?.map((item) => (
|
||||||
<CommandItem
|
<CommandItem
|
||||||
key={item.tb_estadocivil_id}
|
key={item.tb_estadocivil_id}
|
||||||
value={(
|
value={(item.descricao ?? '').toLowerCase()}
|
||||||
item.descricao ?? ""
|
|
||||||
).toLowerCase()}
|
|
||||||
onSelect={() => {
|
onSelect={() => {
|
||||||
field.onChange(
|
field.onChange(Number(item.tb_estadocivil_id));
|
||||||
Number(item.tb_estadocivil_id),
|
|
||||||
);
|
|
||||||
setOpen(false);
|
setOpen(false);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<CheckIcon
|
<CheckIcon
|
||||||
className={cn(
|
className={cn(
|
||||||
"mr-2 h-4 w-4",
|
'mr-2 h-4 w-4',
|
||||||
String(field.value) ===
|
String(field.value) === String(item.tb_estadocivil_id)
|
||||||
String(item.tb_estadocivil_id)
|
? 'opacity-100'
|
||||||
? "opacity-100"
|
: 'opacity-0',
|
||||||
: "opacity-0",
|
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
{GetCapitalize(item.descricao)}
|
{GetCapitalize(item.descricao)}
|
||||||
|
|
@ -421,11 +380,10 @@ export default function TCensecForm({
|
||||||
{field.value
|
{field.value
|
||||||
? gTBRegimeComunhao.find(
|
? gTBRegimeComunhao.find(
|
||||||
(item) =>
|
(item) =>
|
||||||
String(
|
String(item.tb_regimecomunhao_id) ===
|
||||||
item.tb_regimecomunhao_id,
|
String(field.value),
|
||||||
) === String(field.value),
|
|
||||||
)?.descricao
|
)?.descricao
|
||||||
: "Escolha o regime"}
|
: 'Escolha o regime'}
|
||||||
<ChevronsUpDownIcon className="ml-2 h-4 w-4 shrink-0 opacity-50" />
|
<ChevronsUpDownIcon className="ml-2 h-4 w-4 shrink-0 opacity-50" />
|
||||||
</Button>
|
</Button>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
|
|
@ -434,32 +392,24 @@ export default function TCensecForm({
|
||||||
<Command>
|
<Command>
|
||||||
<CommandInput placeholder="Buscar estado civil..." />
|
<CommandInput placeholder="Buscar estado civil..." />
|
||||||
<CommandList>
|
<CommandList>
|
||||||
<CommandEmpty>
|
<CommandEmpty>Nenhum regime encontrado.</CommandEmpty>
|
||||||
Nenhum regime encontrado.
|
|
||||||
</CommandEmpty>
|
|
||||||
<CommandGroup>
|
<CommandGroup>
|
||||||
{gTBRegimeComunhao?.map((item) => (
|
{gTBRegimeComunhao?.map((item) => (
|
||||||
<CommandItem
|
<CommandItem
|
||||||
key={item.tb_regimecomunhao_id}
|
key={item.tb_regimecomunhao_id}
|
||||||
value={(
|
value={(item.descricao ?? '').toLowerCase()}
|
||||||
item.descricao ?? ""
|
|
||||||
).toLowerCase()}
|
|
||||||
onSelect={() => {
|
onSelect={() => {
|
||||||
field.onChange(
|
field.onChange(Number(item.tb_regimecomunhao_id));
|
||||||
Number(item.tb_regimecomunhao_id),
|
|
||||||
);
|
|
||||||
setOpen(false);
|
setOpen(false);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<CheckIcon
|
<CheckIcon
|
||||||
className={cn(
|
className={cn(
|
||||||
"mr-2 h-4 w-4",
|
'mr-2 h-4 w-4',
|
||||||
String(field.value) ===
|
String(field.value) ===
|
||||||
String(
|
String(item.tb_regimecomunhao_id)
|
||||||
item.tb_regimecomunhao_id,
|
? 'opacity-100'
|
||||||
)
|
: 'opacity-0',
|
||||||
? "opacity-100"
|
|
||||||
: "opacity-0",
|
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
{GetCapitalize(item.descricao)}
|
{GetCapitalize(item.descricao)}
|
||||||
|
|
@ -498,10 +448,9 @@ export default function TCensecForm({
|
||||||
{field.value
|
{field.value
|
||||||
? gTBProfissao.find(
|
? gTBProfissao.find(
|
||||||
(item) =>
|
(item) =>
|
||||||
String(item.tb_profissao_id) ===
|
String(item.tb_profissao_id) === String(field.value),
|
||||||
String(field.value),
|
|
||||||
)?.descricao
|
)?.descricao
|
||||||
: "Escolha a profissão"}
|
: 'Escolha a profissão'}
|
||||||
<ChevronsUpDownIcon className="ml-2 h-4 w-4 shrink-0 opacity-50" />
|
<ChevronsUpDownIcon className="ml-2 h-4 w-4 shrink-0 opacity-50" />
|
||||||
</Button>
|
</Button>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
|
|
@ -510,30 +459,23 @@ export default function TCensecForm({
|
||||||
<Command>
|
<Command>
|
||||||
<CommandInput placeholder="Buscar profissão..." />
|
<CommandInput placeholder="Buscar profissão..." />
|
||||||
<CommandList>
|
<CommandList>
|
||||||
<CommandEmpty>
|
<CommandEmpty>Nenhuma profissão encontrado.</CommandEmpty>
|
||||||
Nenhuma profissão encontrado.
|
|
||||||
</CommandEmpty>
|
|
||||||
<CommandGroup>
|
<CommandGroup>
|
||||||
{gTBProfissao?.map((item) => (
|
{gTBProfissao?.map((item) => (
|
||||||
<CommandItem
|
<CommandItem
|
||||||
key={item.tb_profissao_id}
|
key={item.tb_profissao_id}
|
||||||
value={(
|
value={(item.descricao ?? '').toLowerCase()}
|
||||||
item.descricao ?? ""
|
|
||||||
).toLowerCase()}
|
|
||||||
onSelect={() => {
|
onSelect={() => {
|
||||||
field.onChange(
|
field.onChange(Number(item.tb_profissao_id));
|
||||||
Number(item.tb_profissao_id),
|
|
||||||
);
|
|
||||||
setOpen(false);
|
setOpen(false);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<CheckIcon
|
<CheckIcon
|
||||||
className={cn(
|
className={cn(
|
||||||
"mr-2 h-4 w-4",
|
'mr-2 h-4 w-4',
|
||||||
String(field.value) ===
|
String(field.value) === String(item.tb_profissao_id)
|
||||||
String(item.tb_profissao_id)
|
? 'opacity-100'
|
||||||
? "opacity-100"
|
: 'opacity-0',
|
||||||
: "opacity-0",
|
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
{GetCapitalize(item.descricao)}
|
{GetCapitalize(item.descricao)}
|
||||||
|
|
@ -595,7 +537,7 @@ export default function TCensecForm({
|
||||||
|
|
||||||
{/* Endereço */}
|
{/* Endereço */}
|
||||||
<TabsContent value="endereco" className="space-y-4">
|
<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 */}
|
{/* País */}
|
||||||
<div className="col-span-12 sm:col-span-12 md:col-span-6">
|
<div className="col-span-12 sm:col-span-12 md:col-span-6">
|
||||||
<FormField
|
<FormField
|
||||||
|
|
@ -605,11 +547,7 @@ export default function TCensecForm({
|
||||||
<FormItem className="w-full">
|
<FormItem className="w-full">
|
||||||
<FormLabel>País</FormLabel>
|
<FormLabel>País</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input
|
<Input {...field} placeholder="Digite o nome" className="w-full" />
|
||||||
{...field}
|
|
||||||
placeholder="Digite o nome"
|
|
||||||
className="w-full"
|
|
||||||
/>
|
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
|
@ -625,11 +563,7 @@ export default function TCensecForm({
|
||||||
<FormItem className="w-full">
|
<FormItem className="w-full">
|
||||||
<FormLabel>UF</FormLabel>
|
<FormLabel>UF</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input
|
<Input {...field} placeholder="Digite o nome" className="w-full" />
|
||||||
{...field}
|
|
||||||
placeholder="Digite o nome"
|
|
||||||
className="w-full"
|
|
||||||
/>
|
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
|
@ -645,11 +579,7 @@ export default function TCensecForm({
|
||||||
<FormItem className="w-full">
|
<FormItem className="w-full">
|
||||||
<FormLabel>CEP</FormLabel>
|
<FormLabel>CEP</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input
|
<Input {...field} placeholder="Digite o nome" className="w-full" />
|
||||||
{...field}
|
|
||||||
placeholder="Digite o nome"
|
|
||||||
className="w-full"
|
|
||||||
/>
|
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
|
@ -665,11 +595,7 @@ export default function TCensecForm({
|
||||||
<FormItem className="w-full">
|
<FormItem className="w-full">
|
||||||
<FormLabel>Cidade</FormLabel>
|
<FormLabel>Cidade</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input
|
<Input {...field} placeholder="Digite o nome" className="w-full" />
|
||||||
{...field}
|
|
||||||
placeholder="Digite o nome"
|
|
||||||
className="w-full"
|
|
||||||
/>
|
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
|
@ -685,11 +611,7 @@ export default function TCensecForm({
|
||||||
<FormItem className="w-full">
|
<FormItem className="w-full">
|
||||||
<FormLabel>Município</FormLabel>
|
<FormLabel>Município</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input
|
<Input {...field} placeholder="Digite o nome" className="w-full" />
|
||||||
{...field}
|
|
||||||
placeholder="Digite o nome"
|
|
||||||
className="w-full"
|
|
||||||
/>
|
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
|
@ -705,11 +627,7 @@ export default function TCensecForm({
|
||||||
<FormItem className="w-full">
|
<FormItem className="w-full">
|
||||||
<FormLabel>Bairro</FormLabel>
|
<FormLabel>Bairro</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input
|
<Input {...field} placeholder="Digite o nome" className="w-full" />
|
||||||
{...field}
|
|
||||||
placeholder="Digite o nome"
|
|
||||||
className="w-full"
|
|
||||||
/>
|
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
|
@ -725,11 +643,7 @@ export default function TCensecForm({
|
||||||
<FormItem className="w-full">
|
<FormItem className="w-full">
|
||||||
<FormLabel>Logradouro</FormLabel>
|
<FormLabel>Logradouro</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input
|
<Input {...field} placeholder="Digite o nome" className="w-full" />
|
||||||
{...field}
|
|
||||||
placeholder="Digite o nome"
|
|
||||||
className="w-full"
|
|
||||||
/>
|
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
|
@ -745,11 +659,7 @@ export default function TCensecForm({
|
||||||
<FormItem className="w-full">
|
<FormItem className="w-full">
|
||||||
<FormLabel>Número</FormLabel>
|
<FormLabel>Número</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input
|
<Input {...field} placeholder="Digite o nome" className="w-full" />
|
||||||
{...field}
|
|
||||||
placeholder="Digite o nome"
|
|
||||||
className="w-full"
|
|
||||||
/>
|
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
|
@ -765,11 +675,7 @@ export default function TCensecForm({
|
||||||
<FormItem className="w-full">
|
<FormItem className="w-full">
|
||||||
<FormLabel>Unidade</FormLabel>
|
<FormLabel>Unidade</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input
|
<Input {...field} placeholder="Digite o nome" className="w-full" />
|
||||||
{...field}
|
|
||||||
placeholder="Digite o nome"
|
|
||||||
className="w-full"
|
|
||||||
/>
|
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
|
@ -785,11 +691,7 @@ export default function TCensecForm({
|
||||||
<FormItem className="w-full">
|
<FormItem className="w-full">
|
||||||
<FormLabel>Cidade não encontrada</FormLabel>
|
<FormLabel>Cidade não encontrada</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input
|
<Input {...field} placeholder="Digite o nome" className="w-full" />
|
||||||
{...field}
|
|
||||||
placeholder="Digite o nome"
|
|
||||||
className="w-full"
|
|
||||||
/>
|
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
|
@ -801,7 +703,7 @@ export default function TCensecForm({
|
||||||
|
|
||||||
{/* Documentos */}
|
{/* Documentos */}
|
||||||
<TabsContent value="documentos" className="space-y-4">
|
<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 */}
|
{/* Tipo */}
|
||||||
<div className="col-span-12 sm:col-span-12 md:col-span-3">
|
<div className="col-span-12 sm:col-span-12 md:col-span-3">
|
||||||
<FormField
|
<FormField
|
||||||
|
|
@ -811,11 +713,7 @@ export default function TCensecForm({
|
||||||
<FormItem className="w-full">
|
<FormItem className="w-full">
|
||||||
<FormLabel>Tipo</FormLabel>
|
<FormLabel>Tipo</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input
|
<Input {...field} placeholder="Digite o tipo" className="w-full" />
|
||||||
{...field}
|
|
||||||
placeholder="Digite o tipo"
|
|
||||||
className="w-full"
|
|
||||||
/>
|
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
|
@ -832,11 +730,7 @@ export default function TCensecForm({
|
||||||
<FormItem className="w-full">
|
<FormItem className="w-full">
|
||||||
<FormLabel>Número</FormLabel>
|
<FormLabel>Número</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input
|
<Input {...field} placeholder="Digite o número" className="w-full" />
|
||||||
{...field}
|
|
||||||
placeholder="Digite o número"
|
|
||||||
className="w-full"
|
|
||||||
/>
|
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
|
@ -853,11 +747,7 @@ export default function TCensecForm({
|
||||||
<FormItem className="w-full">
|
<FormItem className="w-full">
|
||||||
<FormLabel>CPF</FormLabel>
|
<FormLabel>CPF</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input
|
<Input {...field} placeholder="Digite o CPF" className="w-full" />
|
||||||
{...field}
|
|
||||||
placeholder="Digite o CPF"
|
|
||||||
className="w-full"
|
|
||||||
/>
|
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
|
@ -895,11 +785,7 @@ export default function TCensecForm({
|
||||||
<FormItem className="w-full">
|
<FormItem className="w-full">
|
||||||
<FormLabel>UF</FormLabel>
|
<FormLabel>UF</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input
|
<Input {...field} placeholder="UF" className="w-full" />
|
||||||
{...field}
|
|
||||||
placeholder="UF"
|
|
||||||
className="w-full"
|
|
||||||
/>
|
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
|
@ -965,7 +851,7 @@ export default function TCensecForm({
|
||||||
</DialogFooter>
|
</DialogFooter>
|
||||||
|
|
||||||
{/* Campo oculto */}
|
{/* Campo oculto */}
|
||||||
<input type="hidden" {...form.register("pessoa_id")} />
|
<input type="hidden" {...form.register('pessoa_id')} />
|
||||||
</form>
|
</form>
|
||||||
</Form>
|
</Form>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
"use client";
|
'use client';
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from '@/components/ui/button';
|
||||||
import {
|
import {
|
||||||
DropdownMenu,
|
DropdownMenu,
|
||||||
DropdownMenuContent,
|
DropdownMenuContent,
|
||||||
|
|
@ -8,24 +8,19 @@ import {
|
||||||
DropdownMenuItem,
|
DropdownMenuItem,
|
||||||
DropdownMenuSeparator,
|
DropdownMenuSeparator,
|
||||||
DropdownMenuTrigger,
|
DropdownMenuTrigger,
|
||||||
} from "@/components/ui/dropdown-menu";
|
} from '@/components/ui/dropdown-menu';
|
||||||
|
|
||||||
import {
|
import { ArrowUpDownIcon, EllipsisIcon, PencilIcon, Trash2Icon } from 'lucide-react';
|
||||||
ArrowUpDownIcon,
|
import { ColumnDef } from '@tanstack/react-table';
|
||||||
EllipsisIcon,
|
|
||||||
PencilIcon,
|
|
||||||
Trash2Icon,
|
|
||||||
} from "lucide-react";
|
|
||||||
import { ColumnDef } from "@tanstack/react-table";
|
|
||||||
|
|
||||||
import GetNameInitials from "@/actions/text/GetNameInitials";
|
import GetNameInitials from '@/actions/text/GetNameInitials';
|
||||||
import { DataTable } from "@/app/_components/dataTable/DataTable";
|
import { DataTable } from '@/app/_components/dataTable/DataTable';
|
||||||
|
|
||||||
import TPessoaInterface from "../../_interfaces/TPessoaInterface";
|
import TPessoaInterface from '../../_interfaces/TPessoaInterface';
|
||||||
import { FormatCPF } from "@/actions/CPF/FormatCPF";
|
import { FormatCPF } from '@/actions/CPF/FormatCPF';
|
||||||
import { FormatPhone } from "@/actions/phone/FormatPhone";
|
import { FormatPhone } from '@/actions/phone/FormatPhone';
|
||||||
import { FormatDateTime } from "@/actions/dateTime/FormatDateTime";
|
import { FormatDateTime } from '@/actions/dateTime/FormatDateTime';
|
||||||
import empty from "@/actions/validations/empty";
|
import empty from '@/actions/validations/empty';
|
||||||
|
|
||||||
// Tipagem das props
|
// Tipagem das props
|
||||||
interface TPessoaTableProps {
|
interface TPessoaTableProps {
|
||||||
|
|
@ -44,30 +39,29 @@ function createPessoaColumns(
|
||||||
return [
|
return [
|
||||||
// ID
|
// ID
|
||||||
{
|
{
|
||||||
accessorKey: "pessoa_id",
|
accessorKey: 'pessoa_id',
|
||||||
header: ({ column }) => (
|
header: ({ column }) => (
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")}
|
onClick={() => column.toggleSorting(column.getIsSorted() === 'asc')}
|
||||||
>
|
>
|
||||||
# <ArrowUpDownIcon className="ml-1 h-4 w-4" />
|
# <ArrowUpDownIcon className="ml-1 h-4 w-4" />
|
||||||
</Button>
|
</Button>
|
||||||
),
|
),
|
||||||
cell: ({ row }) => Number(row.getValue("pessoa_id")),
|
cell: ({ row }) => Number(row.getValue('pessoa_id')),
|
||||||
enableSorting: false,
|
enableSorting: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
// Nome / Email / Foto
|
// Nome / Email / Foto
|
||||||
{
|
{
|
||||||
id: "nome_completo",
|
id: 'nome_completo',
|
||||||
accessorFn: (row) => row,
|
accessorFn: (row) => row,
|
||||||
header: ({ column }) => (
|
header: ({ column }) => (
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")}
|
onClick={() => column.toggleSorting(column.getIsSorted() === 'asc')}
|
||||||
>
|
>
|
||||||
Nome / Email{" "}
|
Nome / Email <ArrowUpDownIcon className="ml-1 h-4 w-4 cursor-pointer" />
|
||||||
<ArrowUpDownIcon className="ml-1 h-4 w-4 cursor-pointer" />
|
|
||||||
</Button>
|
</Button>
|
||||||
),
|
),
|
||||||
cell: ({ row }) => {
|
cell: ({ row }) => {
|
||||||
|
|
@ -76,12 +70,12 @@ function createPessoaColumns(
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center gap-3">
|
<div className="flex items-center gap-3">
|
||||||
{/* Foto ou Iniciais */}
|
{/* 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 ? (
|
{pessoa.foto ? (
|
||||||
<img
|
<img
|
||||||
src={pessoa.foto}
|
src={pessoa.foto}
|
||||||
alt={pessoa.nome || "Avatar"}
|
alt={pessoa.nome || 'Avatar'}
|
||||||
className="w-full h-full object-cover"
|
className="h-full w-full object-cover"
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<span className="text-sm font-medium text-gray-700">
|
<span className="text-sm font-medium text-gray-700">
|
||||||
|
|
@ -92,63 +86,59 @@ function createPessoaColumns(
|
||||||
|
|
||||||
{/* Nome e Email */}
|
{/* Nome e Email */}
|
||||||
<div>
|
<div>
|
||||||
<div className="font-semibold text-gray-900 capitalize">
|
<div className="font-semibold text-gray-900 capitalize">{pessoa.nome || '-'}</div>
|
||||||
{pessoa.nome || "-"}
|
|
||||||
</div>
|
|
||||||
<div className="text-sm text-gray-500">
|
<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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
sortingFn: (a, b) =>
|
sortingFn: (a, b) =>
|
||||||
(a.original.nome?.toLowerCase() || "").localeCompare(
|
(a.original.nome?.toLowerCase() || '').localeCompare(b.original.nome?.toLowerCase() || ''),
|
||||||
b.original.nome?.toLowerCase() || "",
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// CPF
|
// CPF
|
||||||
{
|
{
|
||||||
accessorKey: "cpf_cnpj",
|
accessorKey: 'cpf_cnpj',
|
||||||
header: ({ column }) => (
|
header: ({ column }) => (
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
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" />
|
CPF <ArrowUpDownIcon className="ml-1 h-4 w-4 cursor-pointer" />
|
||||||
</Button>
|
</Button>
|
||||||
),
|
),
|
||||||
cell: ({ row }) => FormatCPF(row.getValue("cpf_cnpj")),
|
cell: ({ row }) => FormatCPF(row.getValue('cpf_cnpj')),
|
||||||
},
|
},
|
||||||
|
|
||||||
// Telefone
|
// Telefone
|
||||||
{
|
{
|
||||||
accessorKey: "telefone",
|
accessorKey: 'telefone',
|
||||||
header: ({ column }) => (
|
header: ({ column }) => (
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
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" />
|
Telefone <ArrowUpDownIcon className="ml-1 h-4 w-4 cursor-pointer" />
|
||||||
</Button>
|
</Button>
|
||||||
),
|
),
|
||||||
cell: ({ row }) => FormatPhone(row.getValue("telefone")),
|
cell: ({ row }) => FormatPhone(row.getValue('telefone')),
|
||||||
},
|
},
|
||||||
|
|
||||||
// Cidade / UF
|
// Cidade / UF
|
||||||
{
|
{
|
||||||
id: "cidade_uf",
|
id: 'cidade_uf',
|
||||||
accessorFn: (row) => `${row.cidade}/${row.uf}`,
|
accessorFn: (row) => `${row.cidade}/${row.uf}`,
|
||||||
header: ({ column }) => (
|
header: ({ column }) => (
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
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" />
|
Cidade/UF <ArrowUpDownIcon className="ml-1 h-4 w-4 cursor-pointer" />
|
||||||
</Button>
|
</Button>
|
||||||
),
|
),
|
||||||
cell: ({ row }) => <span>{row.getValue("cidade_uf") || "-"}</span>,
|
cell: ({ row }) => <span>{row.getValue('cidade_uf') || '-'}</span>,
|
||||||
sortingFn: (a, b) =>
|
sortingFn: (a, b) =>
|
||||||
`${a.original.cidade}/${a.original.uf}`
|
`${a.original.cidade}/${a.original.uf}`
|
||||||
.toLowerCase()
|
.toLowerCase()
|
||||||
|
|
@ -157,23 +147,23 @@ function createPessoaColumns(
|
||||||
|
|
||||||
// Data de cadastro
|
// Data de cadastro
|
||||||
{
|
{
|
||||||
accessorKey: "data_cadastro",
|
accessorKey: 'data_cadastro',
|
||||||
header: ({ column }) => (
|
header: ({ column }) => (
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
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" />
|
Cadastro <ArrowUpDownIcon className="ml-1 h-4 w-4 cursor-pointer" />
|
||||||
</Button>
|
</Button>
|
||||||
),
|
),
|
||||||
cell: ({ row }) => FormatDateTime(row.getValue("data_cadastro")),
|
cell: ({ row }) => FormatDateTime(row.getValue('data_cadastro')),
|
||||||
sortingFn: "datetime",
|
sortingFn: 'datetime',
|
||||||
},
|
},
|
||||||
|
|
||||||
// Ações
|
// Ações
|
||||||
{
|
{
|
||||||
id: "actions",
|
id: 'actions',
|
||||||
header: "Ações",
|
header: 'Ações',
|
||||||
cell: ({ row }) => {
|
cell: ({ row }) => {
|
||||||
const pessoa = row.original;
|
const pessoa = row.original;
|
||||||
return (
|
return (
|
||||||
|
|
@ -185,10 +175,7 @@ function createPessoaColumns(
|
||||||
</DropdownMenuTrigger>
|
</DropdownMenuTrigger>
|
||||||
<DropdownMenuContent side="left" align="start">
|
<DropdownMenuContent side="left" align="start">
|
||||||
<DropdownMenuGroup>
|
<DropdownMenuGroup>
|
||||||
<DropdownMenuItem
|
<DropdownMenuItem className="cursor-pointer" onSelect={() => onEdit(pessoa, true)}>
|
||||||
className="cursor-pointer"
|
|
||||||
onSelect={() => onEdit(pessoa, true)}
|
|
||||||
>
|
|
||||||
<PencilIcon className="mr-2 h-4 w-4" />
|
<PencilIcon className="mr-2 h-4 w-4" />
|
||||||
Editar
|
Editar
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
|
|
@ -214,11 +201,7 @@ function createPessoaColumns(
|
||||||
/**
|
/**
|
||||||
* Componente principal da tabela
|
* Componente principal da tabela
|
||||||
*/
|
*/
|
||||||
export default function TPessoaTable({
|
export default function TPessoaTable({ data, onEdit, onDelete }: TPessoaTableProps) {
|
||||||
data,
|
|
||||||
onEdit,
|
|
||||||
onDelete,
|
|
||||||
}: TPessoaTableProps) {
|
|
||||||
const columns = createPessoaColumns(onEdit, onDelete);
|
const columns = createPessoaColumns(onEdit, onDelete);
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
"use client";
|
'use client';
|
||||||
|
|
||||||
import z from "zod";
|
import z from 'zod';
|
||||||
import React, { useEffect } from "react";
|
import React, { useEffect } from 'react';
|
||||||
import { useForm, Controller } from "react-hook-form";
|
import { useForm, Controller } from 'react-hook-form';
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from '@hookform/resolvers/zod';
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from '@/components/ui/button';
|
||||||
import {
|
import {
|
||||||
Dialog,
|
Dialog,
|
||||||
DialogClose,
|
DialogClose,
|
||||||
|
|
@ -14,7 +14,7 @@ import {
|
||||||
DialogFooter,
|
DialogFooter,
|
||||||
DialogHeader,
|
DialogHeader,
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
} from "@/components/ui/dialog";
|
} from '@/components/ui/dialog';
|
||||||
import {
|
import {
|
||||||
Form,
|
Form,
|
||||||
FormControl,
|
FormControl,
|
||||||
|
|
@ -22,16 +22,16 @@ import {
|
||||||
FormItem,
|
FormItem,
|
||||||
FormLabel,
|
FormLabel,
|
||||||
FormMessage,
|
FormMessage,
|
||||||
} from "@/components/ui/form";
|
} from '@/components/ui/form';
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from '@/components/ui/input';
|
||||||
|
|
||||||
import { TPessoaSchema } from "../../../_schemas/TPessoaSchema";
|
import { TPessoaSchema } from '../../../_schemas/TPessoaSchema';
|
||||||
import LoadingButton from "@/app/_components/loadingButton/LoadingButton";
|
import LoadingButton from '@/app/_components/loadingButton/LoadingButton';
|
||||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
|
||||||
import { HouseIcon, IdCardIcon, UserIcon } from "lucide-react";
|
import { HouseIcon, IdCardIcon, UserIcon } from 'lucide-react';
|
||||||
import { Textarea } from "@/components/ui/textarea";
|
import { Textarea } from '@/components/ui/textarea';
|
||||||
import { useTPessoaRepresentanteIndexHook } from "../../../_hooks/t_pessoa_representante/useTPessoaRepresentanteIndexHook";
|
import { useTPessoaRepresentanteIndexHook } from '../../../_hooks/t_pessoa_representante/useTPessoaRepresentanteIndexHook';
|
||||||
import TPessoaRepresentantePage from "../../t_pessoa_representante/TPessoaRepresentantePage";
|
import TPessoaRepresentantePage from '../../t_pessoa_representante/TPessoaRepresentantePage';
|
||||||
|
|
||||||
type FormValues = z.infer<typeof TPessoaSchema>;
|
type FormValues = z.infer<typeof TPessoaSchema>;
|
||||||
|
|
||||||
|
|
@ -50,14 +50,13 @@ export default function TPessoaJuridicaForm({
|
||||||
onSave,
|
onSave,
|
||||||
buttonIsLoading,
|
buttonIsLoading,
|
||||||
}: TPessoaFormProps) {
|
}: TPessoaFormProps) {
|
||||||
const { tPessoaRepresentante, fetchTPessoaRepresentante } =
|
const { tPessoaRepresentante, fetchTPessoaRepresentante } = useTPessoaRepresentanteIndexHook();
|
||||||
useTPessoaRepresentanteIndexHook();
|
|
||||||
|
|
||||||
// Inicializa o react-hook-form com schema zod
|
// Inicializa o react-hook-form com schema zod
|
||||||
const form = useForm<FormValues>({
|
const form = useForm<FormValues>({
|
||||||
resolver: zodResolver(TPessoaSchema),
|
resolver: zodResolver(TPessoaSchema),
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
nome: "",
|
nome: '',
|
||||||
pessoa_id: 0,
|
pessoa_id: 0,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
@ -84,7 +83,7 @@ export default function TPessoaJuridicaForm({
|
||||||
if (!open) onClose(null, false);
|
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>
|
<DialogHeader>
|
||||||
<DialogTitle>Pessoa</DialogTitle>
|
<DialogTitle>Pessoa</DialogTitle>
|
||||||
<DialogDescription>Preencha os dados da pessoa</DialogDescription>
|
<DialogDescription>Preencha os dados da pessoa</DialogDescription>
|
||||||
|
|
@ -93,24 +92,15 @@ export default function TPessoaJuridicaForm({
|
||||||
<form onSubmit={form.handleSubmit(onSave)} className="space-y-6">
|
<form onSubmit={form.handleSubmit(onSave)} className="space-y-6">
|
||||||
{/* Tabs */}
|
{/* Tabs */}
|
||||||
<Tabs defaultValue="dadosPessoais" className="space-y-4">
|
<Tabs defaultValue="dadosPessoais" className="space-y-4">
|
||||||
<TabsList className="w-full flex">
|
<TabsList className="flex w-full">
|
||||||
<TabsTrigger
|
<TabsTrigger className="flex-1 cursor-pointer text-center" value="dadosPessoais">
|
||||||
className="flex-1 text-center cursor-pointer"
|
|
||||||
value="dadosPessoais"
|
|
||||||
>
|
|
||||||
<UserIcon className="me-1" />
|
<UserIcon className="me-1" />
|
||||||
Dados Pessoais
|
Dados Pessoais
|
||||||
</TabsTrigger>
|
</TabsTrigger>
|
||||||
<TabsTrigger
|
<TabsTrigger className="flex-1 cursor-pointer text-center" value="endereco">
|
||||||
className="flex-1 text-center cursor-pointer"
|
|
||||||
value="endereco"
|
|
||||||
>
|
|
||||||
<HouseIcon /> Endereço
|
<HouseIcon /> Endereço
|
||||||
</TabsTrigger>
|
</TabsTrigger>
|
||||||
<TabsTrigger
|
<TabsTrigger className="flex-1 cursor-pointer text-center" value="documentos">
|
||||||
className="flex-1 text-center cursor-pointer"
|
|
||||||
value="documentos"
|
|
||||||
>
|
|
||||||
<IdCardIcon /> Representantes
|
<IdCardIcon /> Representantes
|
||||||
</TabsTrigger>
|
</TabsTrigger>
|
||||||
</TabsList>
|
</TabsList>
|
||||||
|
|
@ -190,11 +180,7 @@ export default function TPessoaJuridicaForm({
|
||||||
<FormItem className="w-full">
|
<FormItem className="w-full">
|
||||||
<FormLabel>CNPJ</FormLabel>
|
<FormLabel>CNPJ</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input
|
<Input {...field} placeholder="Digite o CNPJ" className="w-full" />
|
||||||
{...field}
|
|
||||||
placeholder="Digite o CNPJ"
|
|
||||||
className="w-full"
|
|
||||||
/>
|
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
|
@ -226,7 +212,7 @@ export default function TPessoaJuridicaForm({
|
||||||
</TabsContent>
|
</TabsContent>
|
||||||
{/* Endereço */}
|
{/* Endereço */}
|
||||||
<TabsContent value="endereco" className="space-y-4">
|
<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 */}
|
{/* País */}
|
||||||
<div className="col-span-12 sm:col-span-12 md:col-span-6">
|
<div className="col-span-12 sm:col-span-12 md:col-span-6">
|
||||||
<FormField
|
<FormField
|
||||||
|
|
@ -236,11 +222,7 @@ export default function TPessoaJuridicaForm({
|
||||||
<FormItem className="w-full">
|
<FormItem className="w-full">
|
||||||
<FormLabel>País</FormLabel>
|
<FormLabel>País</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input
|
<Input {...field} placeholder="Digite o nome" className="w-full" />
|
||||||
{...field}
|
|
||||||
placeholder="Digite o nome"
|
|
||||||
className="w-full"
|
|
||||||
/>
|
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
|
@ -256,11 +238,7 @@ export default function TPessoaJuridicaForm({
|
||||||
<FormItem className="w-full">
|
<FormItem className="w-full">
|
||||||
<FormLabel>UF</FormLabel>
|
<FormLabel>UF</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input
|
<Input {...field} placeholder="Digite o nome" className="w-full" />
|
||||||
{...field}
|
|
||||||
placeholder="Digite o nome"
|
|
||||||
className="w-full"
|
|
||||||
/>
|
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
|
@ -276,11 +254,7 @@ export default function TPessoaJuridicaForm({
|
||||||
<FormItem className="w-full">
|
<FormItem className="w-full">
|
||||||
<FormLabel>CEP</FormLabel>
|
<FormLabel>CEP</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input
|
<Input {...field} placeholder="Digite o nome" className="w-full" />
|
||||||
{...field}
|
|
||||||
placeholder="Digite o nome"
|
|
||||||
className="w-full"
|
|
||||||
/>
|
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
|
@ -296,11 +270,7 @@ export default function TPessoaJuridicaForm({
|
||||||
<FormItem className="w-full">
|
<FormItem className="w-full">
|
||||||
<FormLabel>Cidade</FormLabel>
|
<FormLabel>Cidade</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input
|
<Input {...field} placeholder="Digite o nome" className="w-full" />
|
||||||
{...field}
|
|
||||||
placeholder="Digite o nome"
|
|
||||||
className="w-full"
|
|
||||||
/>
|
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
|
@ -316,11 +286,7 @@ export default function TPessoaJuridicaForm({
|
||||||
<FormItem className="w-full">
|
<FormItem className="w-full">
|
||||||
<FormLabel>Município</FormLabel>
|
<FormLabel>Município</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input
|
<Input {...field} placeholder="Digite o nome" className="w-full" />
|
||||||
{...field}
|
|
||||||
placeholder="Digite o nome"
|
|
||||||
className="w-full"
|
|
||||||
/>
|
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
|
@ -336,11 +302,7 @@ export default function TPessoaJuridicaForm({
|
||||||
<FormItem className="w-full">
|
<FormItem className="w-full">
|
||||||
<FormLabel>Bairro</FormLabel>
|
<FormLabel>Bairro</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input
|
<Input {...field} placeholder="Digite o nome" className="w-full" />
|
||||||
{...field}
|
|
||||||
placeholder="Digite o nome"
|
|
||||||
className="w-full"
|
|
||||||
/>
|
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
|
@ -356,11 +318,7 @@ export default function TPessoaJuridicaForm({
|
||||||
<FormItem className="w-full">
|
<FormItem className="w-full">
|
||||||
<FormLabel>Logradouro</FormLabel>
|
<FormLabel>Logradouro</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input
|
<Input {...field} placeholder="Digite o nome" className="w-full" />
|
||||||
{...field}
|
|
||||||
placeholder="Digite o nome"
|
|
||||||
className="w-full"
|
|
||||||
/>
|
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
|
@ -376,11 +334,7 @@ export default function TPessoaJuridicaForm({
|
||||||
<FormItem className="w-full">
|
<FormItem className="w-full">
|
||||||
<FormLabel>Número</FormLabel>
|
<FormLabel>Número</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input
|
<Input {...field} placeholder="Digite o nome" className="w-full" />
|
||||||
{...field}
|
|
||||||
placeholder="Digite o nome"
|
|
||||||
className="w-full"
|
|
||||||
/>
|
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
|
@ -396,11 +350,7 @@ export default function TPessoaJuridicaForm({
|
||||||
<FormItem className="w-full">
|
<FormItem className="w-full">
|
||||||
<FormLabel>Unidade</FormLabel>
|
<FormLabel>Unidade</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input
|
<Input {...field} placeholder="Digite o nome" className="w-full" />
|
||||||
{...field}
|
|
||||||
placeholder="Digite o nome"
|
|
||||||
className="w-full"
|
|
||||||
/>
|
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
|
@ -416,11 +366,7 @@ export default function TPessoaJuridicaForm({
|
||||||
<FormItem className="w-full">
|
<FormItem className="w-full">
|
||||||
<FormLabel>Cidade não encontrada</FormLabel>
|
<FormLabel>Cidade não encontrada</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input
|
<Input {...field} placeholder="Digite o nome" className="w-full" />
|
||||||
{...field}
|
|
||||||
placeholder="Digite o nome"
|
|
||||||
className="w-full"
|
|
||||||
/>
|
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
|
@ -455,7 +401,7 @@ export default function TPessoaJuridicaForm({
|
||||||
/>
|
/>
|
||||||
</DialogFooter>
|
</DialogFooter>
|
||||||
{/* Campo oculto */}
|
{/* Campo oculto */}
|
||||||
<input type="hidden" {...form.register("pessoa_id")} />
|
<input type="hidden" {...form.register('pessoa_id')} />
|
||||||
</form>
|
</form>
|
||||||
</Form>
|
</Form>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
"use client";
|
'use client';
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from '@/components/ui/button';
|
||||||
import {
|
import {
|
||||||
DropdownMenu,
|
DropdownMenu,
|
||||||
DropdownMenuContent,
|
DropdownMenuContent,
|
||||||
|
|
@ -8,25 +8,20 @@ import {
|
||||||
DropdownMenuItem,
|
DropdownMenuItem,
|
||||||
DropdownMenuSeparator,
|
DropdownMenuSeparator,
|
||||||
DropdownMenuTrigger,
|
DropdownMenuTrigger,
|
||||||
} from "@/components/ui/dropdown-menu";
|
} from '@/components/ui/dropdown-menu';
|
||||||
|
|
||||||
import {
|
import { ArrowUpDownIcon, EllipsisIcon, PencilIcon, Trash2Icon } from 'lucide-react';
|
||||||
ArrowUpDownIcon,
|
import { ColumnDef } from '@tanstack/react-table';
|
||||||
EllipsisIcon,
|
|
||||||
PencilIcon,
|
|
||||||
Trash2Icon,
|
|
||||||
} from "lucide-react";
|
|
||||||
import { ColumnDef } from "@tanstack/react-table";
|
|
||||||
|
|
||||||
import GetNameInitials from "@/actions/text/GetNameInitials";
|
import GetNameInitials from '@/actions/text/GetNameInitials';
|
||||||
import { DataTable } from "@/app/_components/dataTable/DataTable";
|
import { DataTable } from '@/app/_components/dataTable/DataTable';
|
||||||
|
|
||||||
import TPessoaInterface from "../../../_interfaces/TPessoaInterface";
|
import TPessoaInterface from '../../../_interfaces/TPessoaInterface';
|
||||||
import { FormatCPF } from "@/actions/CPF/FormatCPF";
|
import { FormatCPF } from '@/actions/CPF/FormatCPF';
|
||||||
import { FormatPhone } from "@/actions/phone/FormatPhone";
|
import { FormatPhone } from '@/actions/phone/FormatPhone';
|
||||||
import { FormatDateTime } from "@/actions/dateTime/FormatDateTime";
|
import { FormatDateTime } from '@/actions/dateTime/FormatDateTime';
|
||||||
import empty from "@/actions/validations/empty";
|
import empty from '@/actions/validations/empty';
|
||||||
import { FormatCNPJ } from "@/actions/CNPJ/FormatCNPJ";
|
import { FormatCNPJ } from '@/actions/CNPJ/FormatCNPJ';
|
||||||
|
|
||||||
// Tipagem das props
|
// Tipagem das props
|
||||||
interface TPessoaJuridicaTableProps {
|
interface TPessoaJuridicaTableProps {
|
||||||
|
|
@ -45,30 +40,29 @@ function createPessoaColumns(
|
||||||
return [
|
return [
|
||||||
// ID
|
// ID
|
||||||
{
|
{
|
||||||
accessorKey: "pessoa_id",
|
accessorKey: 'pessoa_id',
|
||||||
header: ({ column }) => (
|
header: ({ column }) => (
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")}
|
onClick={() => column.toggleSorting(column.getIsSorted() === 'asc')}
|
||||||
>
|
>
|
||||||
# <ArrowUpDownIcon className="ml-1 h-4 w-4" />
|
# <ArrowUpDownIcon className="ml-1 h-4 w-4" />
|
||||||
</Button>
|
</Button>
|
||||||
),
|
),
|
||||||
cell: ({ row }) => Number(row.getValue("pessoa_id")),
|
cell: ({ row }) => Number(row.getValue('pessoa_id')),
|
||||||
enableSorting: false,
|
enableSorting: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
// Nome / Email / Foto
|
// Nome / Email / Foto
|
||||||
{
|
{
|
||||||
id: "nome_completo",
|
id: 'nome_completo',
|
||||||
accessorFn: (row) => row,
|
accessorFn: (row) => row,
|
||||||
header: ({ column }) => (
|
header: ({ column }) => (
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")}
|
onClick={() => column.toggleSorting(column.getIsSorted() === 'asc')}
|
||||||
>
|
>
|
||||||
Nome / Email{" "}
|
Nome / Email <ArrowUpDownIcon className="ml-1 h-4 w-4 cursor-pointer" />
|
||||||
<ArrowUpDownIcon className="ml-1 h-4 w-4 cursor-pointer" />
|
|
||||||
</Button>
|
</Button>
|
||||||
),
|
),
|
||||||
cell: ({ row }) => {
|
cell: ({ row }) => {
|
||||||
|
|
@ -77,63 +71,59 @@ function createPessoaColumns(
|
||||||
<div className="flex items-center gap-3">
|
<div className="flex items-center gap-3">
|
||||||
{/* Nome e Email */}
|
{/* Nome e Email */}
|
||||||
<div>
|
<div>
|
||||||
<div className="font-semibold text-gray-900 capitalize">
|
<div className="font-semibold text-gray-900 capitalize">{pessoa.nome || '-'}</div>
|
||||||
{pessoa.nome || "-"}
|
|
||||||
</div>
|
|
||||||
<div className="text-sm text-gray-500">
|
<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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
sortingFn: (a, b) =>
|
sortingFn: (a, b) =>
|
||||||
(a.original.nome?.toLowerCase() || "").localeCompare(
|
(a.original.nome?.toLowerCase() || '').localeCompare(b.original.nome?.toLowerCase() || ''),
|
||||||
b.original.nome?.toLowerCase() || "",
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// CPF
|
// CPF
|
||||||
{
|
{
|
||||||
accessorKey: "cpf_cnpj",
|
accessorKey: 'cpf_cnpj',
|
||||||
header: ({ column }) => (
|
header: ({ column }) => (
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
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" />
|
CNPJ <ArrowUpDownIcon className="ml-1 h-4 w-4 cursor-pointer" />
|
||||||
</Button>
|
</Button>
|
||||||
),
|
),
|
||||||
cell: ({ row }) => FormatCNPJ(row.getValue("cpf_cnpj")),
|
cell: ({ row }) => FormatCNPJ(row.getValue('cpf_cnpj')),
|
||||||
},
|
},
|
||||||
|
|
||||||
// Telefone
|
// Telefone
|
||||||
{
|
{
|
||||||
accessorKey: "telefone",
|
accessorKey: 'telefone',
|
||||||
header: ({ column }) => (
|
header: ({ column }) => (
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
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" />
|
Telefone <ArrowUpDownIcon className="ml-1 h-4 w-4 cursor-pointer" />
|
||||||
</Button>
|
</Button>
|
||||||
),
|
),
|
||||||
cell: ({ row }) => FormatPhone(row.getValue("telefone")),
|
cell: ({ row }) => FormatPhone(row.getValue('telefone')),
|
||||||
},
|
},
|
||||||
|
|
||||||
// Cidade / UF
|
// Cidade / UF
|
||||||
{
|
{
|
||||||
id: "cidade_uf",
|
id: 'cidade_uf',
|
||||||
accessorFn: (row) => `${row.cidade}/${row.uf}`,
|
accessorFn: (row) => `${row.cidade}/${row.uf}`,
|
||||||
header: ({ column }) => (
|
header: ({ column }) => (
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
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" />
|
Cidade/UF <ArrowUpDownIcon className="ml-1 h-4 w-4 cursor-pointer" />
|
||||||
</Button>
|
</Button>
|
||||||
),
|
),
|
||||||
cell: ({ row }) => <span>{row.getValue("cidade_uf") || "-"}</span>,
|
cell: ({ row }) => <span>{row.getValue('cidade_uf') || '-'}</span>,
|
||||||
sortingFn: (a, b) =>
|
sortingFn: (a, b) =>
|
||||||
`${a.original.cidade}/${a.original.uf}`
|
`${a.original.cidade}/${a.original.uf}`
|
||||||
.toLowerCase()
|
.toLowerCase()
|
||||||
|
|
@ -142,23 +132,23 @@ function createPessoaColumns(
|
||||||
|
|
||||||
// Data de cadastro
|
// Data de cadastro
|
||||||
{
|
{
|
||||||
accessorKey: "data_cadastro",
|
accessorKey: 'data_cadastro',
|
||||||
header: ({ column }) => (
|
header: ({ column }) => (
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
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" />
|
Cadastro <ArrowUpDownIcon className="ml-1 h-4 w-4 cursor-pointer" />
|
||||||
</Button>
|
</Button>
|
||||||
),
|
),
|
||||||
cell: ({ row }) => FormatDateTime(row.getValue("data_cadastro")),
|
cell: ({ row }) => FormatDateTime(row.getValue('data_cadastro')),
|
||||||
sortingFn: "datetime",
|
sortingFn: 'datetime',
|
||||||
},
|
},
|
||||||
|
|
||||||
// Ações
|
// Ações
|
||||||
{
|
{
|
||||||
id: "actions",
|
id: 'actions',
|
||||||
header: "Ações",
|
header: 'Ações',
|
||||||
cell: ({ row }) => {
|
cell: ({ row }) => {
|
||||||
const pessoa = row.original;
|
const pessoa = row.original;
|
||||||
return (
|
return (
|
||||||
|
|
@ -170,10 +160,7 @@ function createPessoaColumns(
|
||||||
</DropdownMenuTrigger>
|
</DropdownMenuTrigger>
|
||||||
<DropdownMenuContent side="left" align="start">
|
<DropdownMenuContent side="left" align="start">
|
||||||
<DropdownMenuGroup>
|
<DropdownMenuGroup>
|
||||||
<DropdownMenuItem
|
<DropdownMenuItem className="cursor-pointer" onSelect={() => onEdit(pessoa, true)}>
|
||||||
className="cursor-pointer"
|
|
||||||
onSelect={() => onEdit(pessoa, true)}
|
|
||||||
>
|
|
||||||
<PencilIcon className="mr-2 h-4 w-4" />
|
<PencilIcon className="mr-2 h-4 w-4" />
|
||||||
Editar
|
Editar
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
"use client";
|
'use client';
|
||||||
|
|
||||||
import z from "zod";
|
import z from 'zod';
|
||||||
import React, { useEffect } from "react";
|
import React, { useEffect } from 'react';
|
||||||
import { useForm, Controller } from "react-hook-form";
|
import { useForm, Controller } from 'react-hook-form';
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from '@hookform/resolvers/zod';
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from '@/components/ui/button';
|
||||||
import {
|
import {
|
||||||
Dialog,
|
Dialog,
|
||||||
DialogClose,
|
DialogClose,
|
||||||
|
|
@ -14,7 +14,7 @@ import {
|
||||||
DialogFooter,
|
DialogFooter,
|
||||||
DialogHeader,
|
DialogHeader,
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
} from "@/components/ui/dialog";
|
} from '@/components/ui/dialog';
|
||||||
import {
|
import {
|
||||||
Form,
|
Form,
|
||||||
FormControl,
|
FormControl,
|
||||||
|
|
@ -22,19 +22,19 @@ import {
|
||||||
FormItem,
|
FormItem,
|
||||||
FormLabel,
|
FormLabel,
|
||||||
FormMessage,
|
FormMessage,
|
||||||
} from "@/components/ui/form";
|
} from '@/components/ui/form';
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from '@/components/ui/input';
|
||||||
|
|
||||||
import { TPessoaSchema } from "../../_schemas/TPessoaSchema";
|
import { TPessoaSchema } from '../../_schemas/TPessoaSchema';
|
||||||
import LoadingButton from "@/app/_components/loadingButton/LoadingButton";
|
import LoadingButton from '@/app/_components/loadingButton/LoadingButton';
|
||||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
|
||||||
import {
|
import {
|
||||||
Select,
|
Select,
|
||||||
SelectContent,
|
SelectContent,
|
||||||
SelectItem,
|
SelectItem,
|
||||||
SelectTrigger,
|
SelectTrigger,
|
||||||
SelectValue,
|
SelectValue,
|
||||||
} from "@/components/ui/select";
|
} from '@/components/ui/select';
|
||||||
import {
|
import {
|
||||||
ArrowUpDownIcon,
|
ArrowUpDownIcon,
|
||||||
CheckIcon,
|
CheckIcon,
|
||||||
|
|
@ -45,17 +45,13 @@ import {
|
||||||
PencilIcon,
|
PencilIcon,
|
||||||
Trash2Icon,
|
Trash2Icon,
|
||||||
UserIcon,
|
UserIcon,
|
||||||
} from "lucide-react";
|
} from 'lucide-react';
|
||||||
import { Sexo } from "@/enums/SexoEnum";
|
import { Sexo } from '@/enums/SexoEnum';
|
||||||
import { useGTBEstadoCivilReadHook } from "../../_hooks/g_tb_estadocivil/useGTBEstadoCivilReadHook";
|
import { useGTBEstadoCivilReadHook } from '../../_hooks/g_tb_estadocivil/useGTBEstadoCivilReadHook';
|
||||||
import GetCapitalize from "@/actions/text/GetCapitalize";
|
import GetCapitalize from '@/actions/text/GetCapitalize';
|
||||||
import { useGTBRegimeComunhaoReadHook } from "../../_hooks/g_tb_regimecomunhao/useGTBRegimeComunhaoReadHook";
|
import { useGTBRegimeComunhaoReadHook } from '../../_hooks/g_tb_regimecomunhao/useGTBRegimeComunhaoReadHook';
|
||||||
import { useGTBProfissaoReadHook } from "../../_hooks/g_tb_profissao/useGTBProfissaoReadHook";
|
import { useGTBProfissaoReadHook } from '../../_hooks/g_tb_profissao/useGTBProfissaoReadHook';
|
||||||
import {
|
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';
|
||||||
Popover,
|
|
||||||
PopoverContent,
|
|
||||||
PopoverTrigger,
|
|
||||||
} from "@/components/ui/popover";
|
|
||||||
import {
|
import {
|
||||||
Command,
|
Command,
|
||||||
CommandEmpty,
|
CommandEmpty,
|
||||||
|
|
@ -63,26 +59,26 @@ import {
|
||||||
CommandInput,
|
CommandInput,
|
||||||
CommandItem,
|
CommandItem,
|
||||||
CommandList,
|
CommandList,
|
||||||
} from "@/components/ui/command";
|
} from '@/components/ui/command';
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from '@/lib/utils';
|
||||||
import { useTPessoaIndexHook } from "../../_hooks/t_pessoa/useTPessoaIndexHook";
|
import { useTPessoaIndexHook } from '../../_hooks/t_pessoa/useTPessoaIndexHook';
|
||||||
import TPessoaTable from "../t_pessoa/TPessoaTable";
|
import TPessoaTable from '../t_pessoa/TPessoaTable';
|
||||||
import TPessoaInterface from "../../_interfaces/TPessoaInterface";
|
import TPessoaInterface from '../../_interfaces/TPessoaInterface';
|
||||||
import { ColumnDef } from "@tanstack/react-table";
|
import { ColumnDef } from '@tanstack/react-table';
|
||||||
import GetNameInitials from "@/actions/text/GetNameInitials";
|
import GetNameInitials from '@/actions/text/GetNameInitials';
|
||||||
import empty from "@/actions/validations/empty";
|
import empty from '@/actions/validations/empty';
|
||||||
import { FormatCPF } from "@/actions/CPF/FormatCPF";
|
import { FormatCPF } from '@/actions/CPF/FormatCPF';
|
||||||
import { FormatPhone } from "@/actions/phone/FormatPhone";
|
import { FormatPhone } from '@/actions/phone/FormatPhone';
|
||||||
import {
|
import {
|
||||||
DropdownMenu,
|
DropdownMenu,
|
||||||
DropdownMenuGroup,
|
DropdownMenuGroup,
|
||||||
DropdownMenuItem,
|
DropdownMenuItem,
|
||||||
DropdownMenuSeparator,
|
DropdownMenuSeparator,
|
||||||
DropdownMenuTrigger,
|
DropdownMenuTrigger,
|
||||||
} from "@/components/ui/dropdown-menu";
|
} from '@/components/ui/dropdown-menu';
|
||||||
import { DropdownMenuContent } from "@radix-ui/react-dropdown-menu";
|
import { DropdownMenuContent } from '@radix-ui/react-dropdown-menu';
|
||||||
import { DataTable } from "@/app/_components/dataTable/DataTable";
|
import { DataTable } from '@/app/_components/dataTable/DataTable';
|
||||||
import { Checkbox } from "@/components/ui/checkbox";
|
import { Checkbox } from '@/components/ui/checkbox';
|
||||||
|
|
||||||
type FormValues = z.infer<typeof TPessoaSchema>;
|
type FormValues = z.infer<typeof TPessoaSchema>;
|
||||||
|
|
||||||
|
|
@ -103,12 +99,12 @@ function createPessoaColumns(
|
||||||
): ColumnDef<TPessoaInterface>[] {
|
): ColumnDef<TPessoaInterface>[] {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
id: "select",
|
id: 'select',
|
||||||
header: ({ table }) => (
|
header: ({ table }) => (
|
||||||
<Checkbox
|
<Checkbox
|
||||||
checked={
|
checked={
|
||||||
table.getIsAllPageRowsSelected() ||
|
table.getIsAllPageRowsSelected() ||
|
||||||
(table.getIsSomePageRowsSelected() && "indeterminate")
|
(table.getIsSomePageRowsSelected() && 'indeterminate')
|
||||||
}
|
}
|
||||||
onCheckedChange={(value) => table.toggleAllPageRowsSelected(!!value)}
|
onCheckedChange={(value) => table.toggleAllPageRowsSelected(!!value)}
|
||||||
aria-label="Select all"
|
aria-label="Select all"
|
||||||
|
|
@ -126,30 +122,29 @@ function createPessoaColumns(
|
||||||
},
|
},
|
||||||
// ID
|
// ID
|
||||||
{
|
{
|
||||||
accessorKey: "pessoa_representante_id",
|
accessorKey: 'pessoa_representante_id',
|
||||||
header: ({ column }) => (
|
header: ({ column }) => (
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")}
|
onClick={() => column.toggleSorting(column.getIsSorted() === 'asc')}
|
||||||
>
|
>
|
||||||
# <ArrowUpDownIcon className="ml-1 h-4 w-4" />
|
# <ArrowUpDownIcon className="ml-1 h-4 w-4" />
|
||||||
</Button>
|
</Button>
|
||||||
),
|
),
|
||||||
cell: ({ row }) => Number(row.getValue("pessoa_representante_id")),
|
cell: ({ row }) => Number(row.getValue('pessoa_representante_id')),
|
||||||
enableSorting: false,
|
enableSorting: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
// Nome / Email / Foto
|
// Nome / Email / Foto
|
||||||
{
|
{
|
||||||
id: "nome_completo",
|
id: 'nome_completo',
|
||||||
accessorFn: (row) => row,
|
accessorFn: (row) => row,
|
||||||
header: ({ column }) => (
|
header: ({ column }) => (
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")}
|
onClick={() => column.toggleSorting(column.getIsSorted() === 'asc')}
|
||||||
>
|
>
|
||||||
Nome / Email{" "}
|
Nome / Email <ArrowUpDownIcon className="ml-1 h-4 w-4 cursor-pointer" />
|
||||||
<ArrowUpDownIcon className="ml-1 h-4 w-4 cursor-pointer" />
|
|
||||||
</Button>
|
</Button>
|
||||||
),
|
),
|
||||||
cell: ({ row }) => {
|
cell: ({ row }) => {
|
||||||
|
|
@ -158,12 +153,12 @@ function createPessoaColumns(
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center gap-3">
|
<div className="flex items-center gap-3">
|
||||||
{/* Foto ou Iniciais */}
|
{/* 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 ? (
|
{pessoa.foto ? (
|
||||||
<img
|
<img
|
||||||
src={pessoa.foto}
|
src={pessoa.foto}
|
||||||
alt={pessoa.nome || "Avatar"}
|
alt={pessoa.nome || 'Avatar'}
|
||||||
className="w-full h-full object-cover"
|
className="h-full w-full object-cover"
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<span className="text-sm font-medium text-gray-700">
|
<span className="text-sm font-medium text-gray-700">
|
||||||
|
|
@ -174,54 +169,50 @@ function createPessoaColumns(
|
||||||
|
|
||||||
{/* Nome e Email */}
|
{/* Nome e Email */}
|
||||||
<div>
|
<div>
|
||||||
<div className="font-semibold text-gray-900 capitalize">
|
<div className="font-semibold text-gray-900 capitalize">{pessoa.nome || '-'}</div>
|
||||||
{pessoa.nome || "-"}
|
|
||||||
</div>
|
|
||||||
<div className="text-sm text-gray-500">
|
<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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
sortingFn: (a, b) =>
|
sortingFn: (a, b) =>
|
||||||
(a.original.nome?.toLowerCase() || "").localeCompare(
|
(a.original.nome?.toLowerCase() || '').localeCompare(b.original.nome?.toLowerCase() || ''),
|
||||||
b.original.nome?.toLowerCase() || "",
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// CPF
|
// CPF
|
||||||
{
|
{
|
||||||
accessorKey: "cpf_cnpj",
|
accessorKey: 'cpf_cnpj',
|
||||||
header: ({ column }) => (
|
header: ({ column }) => (
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
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" />
|
CPF <ArrowUpDownIcon className="ml-1 h-4 w-4 cursor-pointer" />
|
||||||
</Button>
|
</Button>
|
||||||
),
|
),
|
||||||
cell: ({ row }) => FormatCPF(row.getValue("cpf_cnpj")),
|
cell: ({ row }) => FormatCPF(row.getValue('cpf_cnpj')),
|
||||||
},
|
},
|
||||||
|
|
||||||
// Telefone
|
// Telefone
|
||||||
{
|
{
|
||||||
accessorKey: "telefone",
|
accessorKey: 'telefone',
|
||||||
header: ({ column }) => (
|
header: ({ column }) => (
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
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" />
|
Telefone <ArrowUpDownIcon className="ml-1 h-4 w-4 cursor-pointer" />
|
||||||
</Button>
|
</Button>
|
||||||
),
|
),
|
||||||
cell: ({ row }) => FormatPhone(row.getValue("telefone")),
|
cell: ({ row }) => FormatPhone(row.getValue('telefone')),
|
||||||
},
|
},
|
||||||
|
|
||||||
// Ações
|
// Ações
|
||||||
{
|
{
|
||||||
id: "actions",
|
id: 'actions',
|
||||||
header: "Ações",
|
header: 'Ações',
|
||||||
cell: ({ row }) => {
|
cell: ({ row }) => {
|
||||||
const pessoa = row.original;
|
const pessoa = row.original;
|
||||||
return (
|
return (
|
||||||
|
|
@ -233,10 +224,7 @@ function createPessoaColumns(
|
||||||
</DropdownMenuTrigger>
|
</DropdownMenuTrigger>
|
||||||
<DropdownMenuContent side="left" align="start">
|
<DropdownMenuContent side="left" align="start">
|
||||||
<DropdownMenuGroup>
|
<DropdownMenuGroup>
|
||||||
<DropdownMenuItem
|
<DropdownMenuItem className="cursor-pointer" onSelect={() => onEdit(pessoa, true)}>
|
||||||
className="cursor-pointer"
|
|
||||||
onSelect={() => onEdit(pessoa, true)}
|
|
||||||
>
|
|
||||||
<PencilIcon className="mr-2 h-4 w-4" />
|
<PencilIcon className="mr-2 h-4 w-4" />
|
||||||
Editar
|
Editar
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
|
|
@ -272,7 +260,7 @@ export default function TPessoaRepresentanteForm({
|
||||||
const form = useForm<FormValues>({
|
const form = useForm<FormValues>({
|
||||||
resolver: zodResolver(TPessoaSchema),
|
resolver: zodResolver(TPessoaSchema),
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
nome: "",
|
nome: '',
|
||||||
pessoa_id: 0,
|
pessoa_id: 0,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
@ -302,7 +290,7 @@ export default function TPessoaRepresentanteForm({
|
||||||
if (!open) onClose(null, false);
|
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>
|
<DialogHeader>
|
||||||
<DialogTitle>Representante</DialogTitle>
|
<DialogTitle>Representante</DialogTitle>
|
||||||
<DialogDescription>Busque o representante desejado</DialogDescription>
|
<DialogDescription>Busque o representante desejado</DialogDescription>
|
||||||
|
|
@ -337,7 +325,7 @@ export default function TPessoaRepresentanteForm({
|
||||||
/>
|
/>
|
||||||
</DialogFooter>
|
</DialogFooter>
|
||||||
{/* Campo oculto */}
|
{/* Campo oculto */}
|
||||||
<input type="hidden" {...form.register("pessoa_id")} />
|
<input type="hidden" {...form.register('pessoa_id')} />
|
||||||
</form>
|
</form>
|
||||||
</Form>
|
</Form>
|
||||||
</DialogContent>
|
</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 Loading from '@/app/_components/loading/loading';
|
||||||
import TPessoaForm from "../../_components/t_pessoa/TPessoaForm";
|
import TPessoaForm from '../../_components/t_pessoa/TPessoaForm';
|
||||||
|
|
||||||
import { useTPessoaIndexHook } from "../../_hooks/t_pessoa/useTPessoaIndexHook";
|
import { useTPessoaIndexHook } from '../../_hooks/t_pessoa/useTPessoaIndexHook';
|
||||||
import { useTPessoaSaveHook } from "../../_hooks/t_pessoa/useTPessoaSaveHook";
|
import { useTPessoaSaveHook } from '../../_hooks/t_pessoa/useTPessoaSaveHook';
|
||||||
import { useTPessoaDeleteHook } from "../../_hooks/t_pessoa/useTPessoaDeleteHook";
|
import { useTPessoaDeleteHook } from '../../_hooks/t_pessoa/useTPessoaDeleteHook';
|
||||||
|
|
||||||
import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog";
|
import ConfirmDialog from '@/app/_components/confirm_dialog/ConfirmDialog';
|
||||||
import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDialog";
|
import { useConfirmDialog } from '@/app/_components/confirm_dialog/useConfirmDialog';
|
||||||
|
|
||||||
import TPessoaInterface from "../../_interfaces/TPessoaInterface";
|
import TPessoaInterface from '../../_interfaces/TPessoaInterface';
|
||||||
import TPessoaRepresentanteTable from "./TPessoaRepresentanteTable";
|
import TPessoaRepresentanteTable from './TPessoaRepresentanteTable';
|
||||||
import { useTPessoaRepresentanteIndexHook } from "../../_hooks/t_pessoa_representante/useTPessoaRepresentanteIndexHook";
|
import { useTPessoaRepresentanteIndexHook } from '../../_hooks/t_pessoa_representante/useTPessoaRepresentanteIndexHook';
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from '@/components/ui/button';
|
||||||
import Header from "@/app/_components/structure/Header";
|
import Header from '@/app/_components/structure/Header';
|
||||||
import TPessoaRepresentanteForm from "./TPessoaRepresentanteForm";
|
import TPessoaRepresentanteForm from './TPessoaRepresentanteForm';
|
||||||
|
|
||||||
export default function TPessoaRepresentantePage() {
|
export default function TPessoaRepresentantePage() {
|
||||||
// Controle de estado do botão
|
// Controle de estado do botão
|
||||||
const [buttonIsLoading, setButtonIsLoading] = useState(false);
|
const [buttonIsLoading, setButtonIsLoading] = useState(false);
|
||||||
|
|
||||||
// Hooks para leitura e salvamento
|
// Hooks para leitura e salvamento
|
||||||
const { tPessoaRepresentante, fetchTPessoaRepresentante } =
|
const { tPessoaRepresentante, fetchTPessoaRepresentante } = useTPessoaRepresentanteIndexHook();
|
||||||
useTPessoaRepresentanteIndexHook();
|
|
||||||
const { saveTCensec } = useTPessoaSaveHook();
|
const { saveTCensec } = useTPessoaSaveHook();
|
||||||
const { deleteTCensec } = useTPessoaDeleteHook();
|
const { deleteTCensec } = useTPessoaDeleteHook();
|
||||||
|
|
||||||
// Estados
|
// Estados
|
||||||
const [selectedAndamento, setSelectedAndamento] =
|
const [selectedAndamento, setSelectedAndamento] = useState<TPessoaInterface | null>(null);
|
||||||
useState<TPessoaInterface | null>(null);
|
|
||||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||||
|
|
||||||
// Estado para saber qual item será deletado
|
// Estado para saber qual item será deletado
|
||||||
const [itemToDelete, setItemToDelete] = useState<TPessoaInterface | null>(
|
const [itemToDelete, setItemToDelete] = useState<TPessoaInterface | null>(null);
|
||||||
null,
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hook do modal de confirmação
|
* Hook do modal de confirmação
|
||||||
|
|
@ -137,9 +133,9 @@ export default function TPessoaRepresentantePage() {
|
||||||
<div>
|
<div>
|
||||||
{/* Cabeçalho */}
|
{/* Cabeçalho */}
|
||||||
<Header
|
<Header
|
||||||
title={"Representantes"}
|
title={'Representantes'}
|
||||||
description={"Gerenciamento de representantes"}
|
description={'Gerenciamento de representantes'}
|
||||||
buttonText={"Novo representante"}
|
buttonText={'Novo representante'}
|
||||||
buttonAction={() => {
|
buttonAction={() => {
|
||||||
handleOpenForm(null);
|
handleOpenForm(null);
|
||||||
}}
|
}}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
"use client";
|
'use client';
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from '@/components/ui/button';
|
||||||
import {
|
import {
|
||||||
DropdownMenu,
|
DropdownMenu,
|
||||||
DropdownMenuContent,
|
DropdownMenuContent,
|
||||||
|
|
@ -8,24 +8,19 @@ import {
|
||||||
DropdownMenuItem,
|
DropdownMenuItem,
|
||||||
DropdownMenuSeparator,
|
DropdownMenuSeparator,
|
||||||
DropdownMenuTrigger,
|
DropdownMenuTrigger,
|
||||||
} from "@/components/ui/dropdown-menu";
|
} from '@/components/ui/dropdown-menu';
|
||||||
|
|
||||||
import {
|
import { ArrowUpDownIcon, EllipsisIcon, PencilIcon, Trash2Icon } from 'lucide-react';
|
||||||
ArrowUpDownIcon,
|
import { ColumnDef } from '@tanstack/react-table';
|
||||||
EllipsisIcon,
|
|
||||||
PencilIcon,
|
|
||||||
Trash2Icon,
|
|
||||||
} from "lucide-react";
|
|
||||||
import { ColumnDef } from "@tanstack/react-table";
|
|
||||||
|
|
||||||
import GetNameInitials from "@/actions/text/GetNameInitials";
|
import GetNameInitials from '@/actions/text/GetNameInitials';
|
||||||
import { DataTable } from "@/app/_components/dataTable/DataTable";
|
import { DataTable } from '@/app/_components/dataTable/DataTable';
|
||||||
|
|
||||||
import TPessoaInterface from "../../_interfaces/TPessoaInterface";
|
import TPessoaInterface from '../../_interfaces/TPessoaInterface';
|
||||||
import { FormatCPF } from "@/actions/CPF/FormatCPF";
|
import { FormatCPF } from '@/actions/CPF/FormatCPF';
|
||||||
import { FormatPhone } from "@/actions/phone/FormatPhone";
|
import { FormatPhone } from '@/actions/phone/FormatPhone';
|
||||||
import empty from "@/actions/validations/empty";
|
import empty from '@/actions/validations/empty';
|
||||||
import { Checkbox } from "@/components/ui/checkbox";
|
import { Checkbox } from '@/components/ui/checkbox';
|
||||||
|
|
||||||
// Tipagem das props
|
// Tipagem das props
|
||||||
interface TPessoaRepresentanteTableProps {
|
interface TPessoaRepresentanteTableProps {
|
||||||
|
|
@ -44,30 +39,29 @@ function createPessoaColumns(
|
||||||
return [
|
return [
|
||||||
// ID
|
// ID
|
||||||
{
|
{
|
||||||
accessorKey: "pessoa_representante_id",
|
accessorKey: 'pessoa_representante_id',
|
||||||
header: ({ column }) => (
|
header: ({ column }) => (
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")}
|
onClick={() => column.toggleSorting(column.getIsSorted() === 'asc')}
|
||||||
>
|
>
|
||||||
# <ArrowUpDownIcon className="ml-1 h-4 w-4" />
|
# <ArrowUpDownIcon className="ml-1 h-4 w-4" />
|
||||||
</Button>
|
</Button>
|
||||||
),
|
),
|
||||||
cell: ({ row }) => Number(row.getValue("pessoa_representante_id")),
|
cell: ({ row }) => Number(row.getValue('pessoa_representante_id')),
|
||||||
enableSorting: false,
|
enableSorting: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
// Nome / Email / Foto
|
// Nome / Email / Foto
|
||||||
{
|
{
|
||||||
id: "nome_completo",
|
id: 'nome_completo',
|
||||||
accessorFn: (row) => row,
|
accessorFn: (row) => row,
|
||||||
header: ({ column }) => (
|
header: ({ column }) => (
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")}
|
onClick={() => column.toggleSorting(column.getIsSorted() === 'asc')}
|
||||||
>
|
>
|
||||||
Nome / Email{" "}
|
Nome / Email <ArrowUpDownIcon className="ml-1 h-4 w-4 cursor-pointer" />
|
||||||
<ArrowUpDownIcon className="ml-1 h-4 w-4 cursor-pointer" />
|
|
||||||
</Button>
|
</Button>
|
||||||
),
|
),
|
||||||
cell: ({ row }) => {
|
cell: ({ row }) => {
|
||||||
|
|
@ -76,12 +70,12 @@ function createPessoaColumns(
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center gap-3">
|
<div className="flex items-center gap-3">
|
||||||
{/* Foto ou Iniciais */}
|
{/* 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 ? (
|
{pessoa.foto ? (
|
||||||
<img
|
<img
|
||||||
src={pessoa.foto}
|
src={pessoa.foto}
|
||||||
alt={pessoa.nome || "Avatar"}
|
alt={pessoa.nome || 'Avatar'}
|
||||||
className="w-full h-full object-cover"
|
className="h-full w-full object-cover"
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<span className="text-sm font-medium text-gray-700">
|
<span className="text-sm font-medium text-gray-700">
|
||||||
|
|
@ -92,54 +86,50 @@ function createPessoaColumns(
|
||||||
|
|
||||||
{/* Nome e Email */}
|
{/* Nome e Email */}
|
||||||
<div>
|
<div>
|
||||||
<div className="font-semibold text-gray-900 capitalize">
|
<div className="font-semibold text-gray-900 capitalize">{pessoa.nome || '-'}</div>
|
||||||
{pessoa.nome || "-"}
|
|
||||||
</div>
|
|
||||||
<div className="text-sm text-gray-500">
|
<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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
sortingFn: (a, b) =>
|
sortingFn: (a, b) =>
|
||||||
(a.original.nome?.toLowerCase() || "").localeCompare(
|
(a.original.nome?.toLowerCase() || '').localeCompare(b.original.nome?.toLowerCase() || ''),
|
||||||
b.original.nome?.toLowerCase() || "",
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// CPF
|
// CPF
|
||||||
{
|
{
|
||||||
accessorKey: "cpf_cnpj",
|
accessorKey: 'cpf_cnpj',
|
||||||
header: ({ column }) => (
|
header: ({ column }) => (
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
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" />
|
CPF <ArrowUpDownIcon className="ml-1 h-4 w-4 cursor-pointer" />
|
||||||
</Button>
|
</Button>
|
||||||
),
|
),
|
||||||
cell: ({ row }) => FormatCPF(row.getValue("cpf_cnpj")),
|
cell: ({ row }) => FormatCPF(row.getValue('cpf_cnpj')),
|
||||||
},
|
},
|
||||||
|
|
||||||
// Telefone
|
// Telefone
|
||||||
{
|
{
|
||||||
accessorKey: "telefone",
|
accessorKey: 'telefone',
|
||||||
header: ({ column }) => (
|
header: ({ column }) => (
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
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" />
|
Telefone <ArrowUpDownIcon className="ml-1 h-4 w-4 cursor-pointer" />
|
||||||
</Button>
|
</Button>
|
||||||
),
|
),
|
||||||
cell: ({ row }) => FormatPhone(row.getValue("telefone")),
|
cell: ({ row }) => FormatPhone(row.getValue('telefone')),
|
||||||
},
|
},
|
||||||
|
|
||||||
// Ações
|
// Ações
|
||||||
{
|
{
|
||||||
id: "actions",
|
id: 'actions',
|
||||||
header: "Ações",
|
header: 'Ações',
|
||||||
cell: ({ row }) => {
|
cell: ({ row }) => {
|
||||||
const pessoa = row.original;
|
const pessoa = row.original;
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
"use client";
|
'use client';
|
||||||
|
|
||||||
import z from "zod";
|
import z from 'zod';
|
||||||
import { useEffect } from "react";
|
import { useEffect } from 'react';
|
||||||
import { useForm, Controller } from "react-hook-form";
|
import { useForm, Controller } from 'react-hook-form';
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from '@hookform/resolvers/zod';
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from '@/components/ui/button';
|
||||||
import { Checkbox } from "@/components/ui/checkbox";
|
import { Checkbox } from '@/components/ui/checkbox';
|
||||||
import {
|
import {
|
||||||
Dialog,
|
Dialog,
|
||||||
DialogClose,
|
DialogClose,
|
||||||
|
|
@ -15,7 +15,7 @@ import {
|
||||||
DialogFooter,
|
DialogFooter,
|
||||||
DialogHeader,
|
DialogHeader,
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
} from "@/components/ui/dialog";
|
} from '@/components/ui/dialog';
|
||||||
import {
|
import {
|
||||||
Form,
|
Form,
|
||||||
FormControl,
|
FormControl,
|
||||||
|
|
@ -23,19 +23,19 @@ import {
|
||||||
FormItem,
|
FormItem,
|
||||||
FormLabel,
|
FormLabel,
|
||||||
FormMessage,
|
FormMessage,
|
||||||
} from "@/components/ui/form";
|
} from '@/components/ui/form';
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from '@/components/ui/input';
|
||||||
import { Label } from "@/components/ui/label";
|
import { Label } from '@/components/ui/label';
|
||||||
import {
|
import {
|
||||||
Select,
|
Select,
|
||||||
SelectContent,
|
SelectContent,
|
||||||
SelectItem,
|
SelectItem,
|
||||||
SelectTrigger,
|
SelectTrigger,
|
||||||
SelectValue,
|
SelectValue,
|
||||||
} from "@/components/ui/select";
|
} from '@/components/ui/select';
|
||||||
|
|
||||||
import { TTBAndamentoServicoSchema } from "../../_schemas/TTBAndamentoServicoSchema";
|
import { TTBAndamentoServicoSchema } from '../../_schemas/TTBAndamentoServicoSchema';
|
||||||
import { tipoEnum } from "../../_interfaces/TTBAndamentoServicoInterface";
|
import { tipoEnum } from '../../_interfaces/TTBAndamentoServicoInterface';
|
||||||
|
|
||||||
type FormValues = z.infer<typeof TTBAndamentoServicoSchema>;
|
type FormValues = z.infer<typeof TTBAndamentoServicoSchema>;
|
||||||
|
|
||||||
|
|
@ -46,20 +46,15 @@ interface Props {
|
||||||
onSave: (data: FormValues) => void;
|
onSave: (data: FormValues) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function TTBAndamentoServicoForm({
|
export default function TTBAndamentoServicoForm({ isOpen, data, onClose, onSave }: Props) {
|
||||||
isOpen,
|
|
||||||
data,
|
|
||||||
onClose,
|
|
||||||
onSave,
|
|
||||||
}: Props) {
|
|
||||||
// Inicializa o react-hook-form com schema zod
|
// Inicializa o react-hook-form com schema zod
|
||||||
const form = useForm<FormValues>({
|
const form = useForm<FormValues>({
|
||||||
resolver: zodResolver(TTBAndamentoServicoSchema),
|
resolver: zodResolver(TTBAndamentoServicoSchema),
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
descricao: "",
|
descricao: '',
|
||||||
tipo: tipoEnum.OUTROS,
|
tipo: tipoEnum.OUTROS,
|
||||||
situacao: "A",
|
situacao: 'A',
|
||||||
usa_email: "I",
|
usa_email: 'I',
|
||||||
tb_andamentoservico_id: 0,
|
tb_andamentoservico_id: 0,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
@ -68,17 +63,17 @@ export default function TTBAndamentoServicoForm({
|
||||||
const tipoOptions = Object.values(tipoEnum).map((value) => ({
|
const tipoOptions = Object.values(tipoEnum).map((value) => ({
|
||||||
value,
|
value,
|
||||||
label:
|
label:
|
||||||
value === "C"
|
value === 'C'
|
||||||
? "Cancelado"
|
? 'Cancelado'
|
||||||
: value === "E"
|
: value === 'E'
|
||||||
? "Estornado"
|
? 'Estornado'
|
||||||
: value === "PT"
|
: value === 'PT'
|
||||||
? "Protocolado"
|
? 'Protocolado'
|
||||||
: value === "PD"
|
: value === 'PD'
|
||||||
? "Pedido"
|
? 'Pedido'
|
||||||
: value === "NC"
|
: value === 'NC'
|
||||||
? "Não Consta"
|
? 'Não Consta'
|
||||||
: "Outros",
|
: 'Outros',
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Atualiza o formulário quando recebe dados para edição
|
// Atualiza o formulário quando recebe dados para edição
|
||||||
|
|
@ -149,10 +144,8 @@ export default function TTBAndamentoServicoForm({
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<div className="flex items-center space-x-2">
|
<div className="flex items-center space-x-2">
|
||||||
<Checkbox
|
<Checkbox
|
||||||
checked={field.value === "A"}
|
checked={field.value === 'A'}
|
||||||
onCheckedChange={(checked) =>
|
onCheckedChange={(checked) => field.onChange(checked ? 'A' : 'I')}
|
||||||
field.onChange(checked ? "A" : "I")
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
<Label>Ativo</Label>
|
<Label>Ativo</Label>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -166,10 +159,8 @@ export default function TTBAndamentoServicoForm({
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<div className="flex items-center space-x-2">
|
<div className="flex items-center space-x-2">
|
||||||
<Checkbox
|
<Checkbox
|
||||||
checked={field.value === "A"}
|
checked={field.value === 'A'}
|
||||||
onCheckedChange={(checked) =>
|
onCheckedChange={(checked) => field.onChange(checked ? 'A' : 'I')}
|
||||||
field.onChange(checked ? "A" : "I")
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
<Label>Usar e-mail</Label>
|
<Label>Usar e-mail</Label>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -194,7 +185,7 @@ export default function TTBAndamentoServicoForm({
|
||||||
</DialogFooter>
|
</DialogFooter>
|
||||||
|
|
||||||
{/* Campo oculto */}
|
{/* Campo oculto */}
|
||||||
<input type="hidden" {...form.register("tb_andamentoservico_id")} />
|
<input type="hidden" {...form.register('tb_andamentoservico_id')} />
|
||||||
</form>
|
</form>
|
||||||
</Form>
|
</Form>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
"use client";
|
'use client';
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from '@/components/ui/button';
|
||||||
import {
|
import {
|
||||||
DropdownMenu,
|
DropdownMenu,
|
||||||
DropdownMenuContent,
|
DropdownMenuContent,
|
||||||
|
|
@ -8,7 +8,7 @@ import {
|
||||||
DropdownMenuItem,
|
DropdownMenuItem,
|
||||||
DropdownMenuSeparator,
|
DropdownMenuSeparator,
|
||||||
DropdownMenuTrigger,
|
DropdownMenuTrigger,
|
||||||
} from "@/components/ui/dropdown-menu";
|
} from '@/components/ui/dropdown-menu';
|
||||||
import {
|
import {
|
||||||
Table,
|
Table,
|
||||||
TableBody,
|
TableBody,
|
||||||
|
|
@ -16,42 +16,32 @@ import {
|
||||||
TableHead,
|
TableHead,
|
||||||
TableHeader,
|
TableHeader,
|
||||||
TableRow,
|
TableRow,
|
||||||
} from "@/components/ui/table";
|
} from '@/components/ui/table';
|
||||||
|
|
||||||
import { EllipsisIcon, PencilIcon, Trash2Icon } from "lucide-react";
|
import { EllipsisIcon, PencilIcon, Trash2Icon } from 'lucide-react';
|
||||||
import TTBAndamentoServicoInteface from "../../_interfaces/TTBAndamentoServicoInterface";
|
import TTBAndamentoServicoInteface from '../../_interfaces/TTBAndamentoServicoInterface';
|
||||||
|
|
||||||
interface TTBAndamentoServicoTableProps {
|
interface TTBAndamentoServicoTableProps {
|
||||||
data: TTBAndamentoServicoInteface[];
|
data: TTBAndamentoServicoInteface[];
|
||||||
onEdit: (
|
onEdit: (item: TTBAndamentoServicoInteface, isEditingFormStatus: boolean) => void;
|
||||||
item: TTBAndamentoServicoInteface,
|
onDelete: (item: TTBAndamentoServicoInteface, isEditingFormStatus: boolean) => void;
|
||||||
isEditingFormStatus: boolean,
|
|
||||||
) => void;
|
|
||||||
onDelete: (
|
|
||||||
item: TTBAndamentoServicoInteface,
|
|
||||||
isEditingFormStatus: boolean,
|
|
||||||
) => void;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renderiza o badge de situação
|
* Renderiza o badge de situação
|
||||||
*/
|
*/
|
||||||
function StatusBadge({ situacao }: { situacao: string }) {
|
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 =
|
const activeClasses = 'bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-300';
|
||||||
"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-300";
|
|
||||||
|
|
||||||
const inactiveClasses =
|
const inactiveClasses = 'bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300';
|
||||||
"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300";
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<span
|
<span className={`${baseClasses} ${isActive ? activeClasses : inactiveClasses}`}>
|
||||||
className={`${baseClasses} ${isActive ? activeClasses : inactiveClasses}`}
|
{isActive ? 'Ativo' : 'Inativo'}
|
||||||
>
|
|
||||||
{isActive ? "Ativo" : "Inativo"}
|
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -74,13 +64,8 @@ export default function TTBAndamentoServicoTable({
|
||||||
|
|
||||||
<TableBody>
|
<TableBody>
|
||||||
{data.map((item) => (
|
{data.map((item) => (
|
||||||
<TableRow
|
<TableRow key={item.tb_andamentoservico_id} className="cursor-pointer">
|
||||||
key={item.tb_andamentoservico_id}
|
<TableCell className="font-medium">{item.tb_andamentoservico_id}</TableCell>
|
||||||
className="cursor-pointer"
|
|
||||||
>
|
|
||||||
<TableCell className="font-medium">
|
|
||||||
{item.tb_andamentoservico_id}
|
|
||||||
</TableCell>
|
|
||||||
|
|
||||||
<TableCell>
|
<TableCell>
|
||||||
<StatusBadge situacao={item.situacao} />
|
<StatusBadge situacao={item.situacao} />
|
||||||
|
|
@ -91,11 +76,7 @@ export default function TTBAndamentoServicoTable({
|
||||||
<TableCell className="text-right">
|
<TableCell className="text-right">
|
||||||
<DropdownMenu>
|
<DropdownMenu>
|
||||||
<DropdownMenuTrigger asChild>
|
<DropdownMenuTrigger asChild>
|
||||||
<Button
|
<Button variant="outline" size="icon" className="cursor-pointer">
|
||||||
variant="outline"
|
|
||||||
size="icon"
|
|
||||||
className="cursor-pointer"
|
|
||||||
>
|
|
||||||
<EllipsisIcon />
|
<EllipsisIcon />
|
||||||
</Button>
|
</Button>
|
||||||
</DropdownMenuTrigger>
|
</DropdownMenuTrigger>
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
"use client";
|
'use client';
|
||||||
|
|
||||||
import z from "zod";
|
import z from 'zod';
|
||||||
import { useEffect } from "react";
|
import { useEffect } from 'react';
|
||||||
import { useForm, Controller } from "react-hook-form";
|
import { useForm, Controller } from 'react-hook-form';
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from '@hookform/resolvers/zod';
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from '@/components/ui/button';
|
||||||
import { Checkbox } from "@/components/ui/checkbox";
|
import { Checkbox } from '@/components/ui/checkbox';
|
||||||
import {
|
import {
|
||||||
Dialog,
|
Dialog,
|
||||||
DialogClose,
|
DialogClose,
|
||||||
|
|
@ -15,7 +15,7 @@ import {
|
||||||
DialogFooter,
|
DialogFooter,
|
||||||
DialogHeader,
|
DialogHeader,
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
} from "@/components/ui/dialog";
|
} from '@/components/ui/dialog';
|
||||||
import {
|
import {
|
||||||
Form,
|
Form,
|
||||||
FormControl,
|
FormControl,
|
||||||
|
|
@ -23,12 +23,12 @@ import {
|
||||||
FormItem,
|
FormItem,
|
||||||
FormLabel,
|
FormLabel,
|
||||||
FormMessage,
|
FormMessage,
|
||||||
} from "@/components/ui/form";
|
} from '@/components/ui/form';
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from '@/components/ui/input';
|
||||||
import { Label } from "@/components/ui/label";
|
import { Label } from '@/components/ui/label';
|
||||||
|
|
||||||
import { TTBReconhecimentoTipoSchema } from "../../_schemas/TTBReconhecimentoTipoSchema";
|
import { TTBReconhecimentoTipoSchema } from '../../_schemas/TTBReconhecimentoTipoSchema';
|
||||||
import { situacaoEnum } from "../../_interfaces/TTBReconhecimentoTipoInterface";
|
import { situacaoEnum } from '../../_interfaces/TTBReconhecimentoTipoInterface';
|
||||||
|
|
||||||
type FormValues = z.infer<typeof TTBReconhecimentoTipoSchema>;
|
type FormValues = z.infer<typeof TTBReconhecimentoTipoSchema>;
|
||||||
|
|
||||||
|
|
@ -50,7 +50,7 @@ export default function TTBReconhecimentoTipoForm({
|
||||||
resolver: zodResolver(TTBReconhecimentoTipoSchema),
|
resolver: zodResolver(TTBReconhecimentoTipoSchema),
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
tb_reconhecimentotipo_id: 0,
|
tb_reconhecimentotipo_id: 0,
|
||||||
descricao: "",
|
descricao: '',
|
||||||
situacao: situacaoEnum.ATIVO,
|
situacao: situacaoEnum.ATIVO,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
@ -97,10 +97,8 @@ export default function TTBReconhecimentoTipoForm({
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<div className="flex items-center space-x-2">
|
<div className="flex items-center space-x-2">
|
||||||
<Checkbox
|
<Checkbox
|
||||||
checked={field.value === "A"}
|
checked={field.value === 'A'}
|
||||||
onCheckedChange={(checked) =>
|
onCheckedChange={(checked) => field.onChange(checked ? 'A' : 'I')}
|
||||||
field.onChange(checked ? "A" : "I")
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
<Label>Ativo</Label>
|
<Label>Ativo</Label>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -125,10 +123,7 @@ export default function TTBReconhecimentoTipoForm({
|
||||||
</DialogFooter>
|
</DialogFooter>
|
||||||
|
|
||||||
{/* Campo oculto */}
|
{/* Campo oculto */}
|
||||||
<input
|
<input type="hidden" {...form.register('tb_reconhecimentotipo_id')} />
|
||||||
type="hidden"
|
|
||||||
{...form.register("tb_reconhecimentotipo_id")}
|
|
||||||
/>
|
|
||||||
</form>
|
</form>
|
||||||
</Form>
|
</Form>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
"use client";
|
'use client';
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from '@/components/ui/button';
|
||||||
import {
|
import {
|
||||||
DropdownMenu,
|
DropdownMenu,
|
||||||
DropdownMenuContent,
|
DropdownMenuContent,
|
||||||
|
|
@ -8,7 +8,7 @@ import {
|
||||||
DropdownMenuItem,
|
DropdownMenuItem,
|
||||||
DropdownMenuSeparator,
|
DropdownMenuSeparator,
|
||||||
DropdownMenuTrigger,
|
DropdownMenuTrigger,
|
||||||
} from "@/components/ui/dropdown-menu";
|
} from '@/components/ui/dropdown-menu';
|
||||||
import {
|
import {
|
||||||
Table,
|
Table,
|
||||||
TableBody,
|
TableBody,
|
||||||
|
|
@ -16,42 +16,32 @@ import {
|
||||||
TableHead,
|
TableHead,
|
||||||
TableHeader,
|
TableHeader,
|
||||||
TableRow,
|
TableRow,
|
||||||
} from "@/components/ui/table";
|
} from '@/components/ui/table';
|
||||||
|
|
||||||
import { EllipsisIcon, PencilIcon, Trash2Icon } from "lucide-react";
|
import { EllipsisIcon, PencilIcon, Trash2Icon } from 'lucide-react';
|
||||||
import TTBReconhecimentoTipoInterface from "../../_interfaces/TTBReconhecimentoTipoInterface";
|
import TTBReconhecimentoTipoInterface from '../../_interfaces/TTBReconhecimentoTipoInterface';
|
||||||
|
|
||||||
interface TTBReconhecimentoTipoTableProps {
|
interface TTBReconhecimentoTipoTableProps {
|
||||||
data: TTBReconhecimentoTipoInterface[];
|
data: TTBReconhecimentoTipoInterface[];
|
||||||
onEdit: (
|
onEdit: (item: TTBReconhecimentoTipoInterface, isEditingFormStatus: boolean) => void;
|
||||||
item: TTBReconhecimentoTipoInterface,
|
onDelete: (item: TTBReconhecimentoTipoInterface, isEditingFormStatus: boolean) => void;
|
||||||
isEditingFormStatus: boolean,
|
|
||||||
) => void;
|
|
||||||
onDelete: (
|
|
||||||
item: TTBReconhecimentoTipoInterface,
|
|
||||||
isEditingFormStatus: boolean,
|
|
||||||
) => void;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renderiza o badge de situação
|
* Renderiza o badge de situação
|
||||||
*/
|
*/
|
||||||
function StatusBadge({ situacao }: { situacao: string }) {
|
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 =
|
const activeClasses = 'bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-300';
|
||||||
"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-300";
|
|
||||||
|
|
||||||
const inactiveClasses =
|
const inactiveClasses = 'bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300';
|
||||||
"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300";
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<span
|
<span className={`${baseClasses} ${isActive ? activeClasses : inactiveClasses}`}>
|
||||||
className={`${baseClasses} ${isActive ? activeClasses : inactiveClasses}`}
|
{isActive ? 'Ativo' : 'Inativo'}
|
||||||
>
|
|
||||||
{isActive ? "Ativo" : "Inativo"}
|
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -74,13 +64,8 @@ export default function TTBReconhecimentoTipoTable({
|
||||||
|
|
||||||
<TableBody>
|
<TableBody>
|
||||||
{data.map((item) => (
|
{data.map((item) => (
|
||||||
<TableRow
|
<TableRow key={item.tb_reconhecimentotipo_id} className="cursor-pointer">
|
||||||
key={item.tb_reconhecimentotipo_id}
|
<TableCell className="font-medium">{item.tb_reconhecimentotipo_id}</TableCell>
|
||||||
className="cursor-pointer"
|
|
||||||
>
|
|
||||||
<TableCell className="font-medium">
|
|
||||||
{item.tb_reconhecimentotipo_id}
|
|
||||||
</TableCell>
|
|
||||||
|
|
||||||
<TableCell>
|
<TableCell>
|
||||||
<StatusBadge situacao={item.situacao} />
|
<StatusBadge situacao={item.situacao} />
|
||||||
|
|
@ -91,11 +76,7 @@ export default function TTBReconhecimentoTipoTable({
|
||||||
<TableCell className="text-right">
|
<TableCell className="text-right">
|
||||||
<DropdownMenu>
|
<DropdownMenu>
|
||||||
<DropdownMenuTrigger asChild>
|
<DropdownMenuTrigger asChild>
|
||||||
<Button
|
<Button variant="outline" size="icon" className="cursor-pointer">
|
||||||
variant="outline"
|
|
||||||
size="icon"
|
|
||||||
className="cursor-pointer"
|
|
||||||
>
|
|
||||||
<EllipsisIcon />
|
<EllipsisIcon />
|
||||||
</Button>
|
</Button>
|
||||||
</DropdownMenuTrigger>
|
</DropdownMenuTrigger>
|
||||||
|
|
|
||||||
|
|
@ -1,78 +1,78 @@
|
||||||
import API from "@/services/api/Api";
|
import API from '@/services/api/Api';
|
||||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
import { Methods } from '@/services/api/enums/ApiMethodEnum';
|
||||||
|
|
||||||
export default async function GCidadeIndexData() {
|
export default async function GCidadeIndexData() {
|
||||||
return Promise.resolve({
|
return Promise.resolve({
|
||||||
status: 200,
|
status: 200,
|
||||||
message: "Dados localizados",
|
message: 'Dados localizados',
|
||||||
data: [
|
data: [
|
||||||
{
|
{
|
||||||
cidade_id: 1,
|
cidade_id: 1,
|
||||||
uf: "AC",
|
uf: 'AC',
|
||||||
cidade_nome: "Acrelândia",
|
cidade_nome: 'Acrelândia',
|
||||||
codigo_ibge: null,
|
codigo_ibge: null,
|
||||||
codigo_gyn: null,
|
codigo_gyn: null,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
cidade_id: 2,
|
cidade_id: 2,
|
||||||
uf: "AC",
|
uf: 'AC',
|
||||||
cidade_nome: "Assis Brasil",
|
cidade_nome: 'Assis Brasil',
|
||||||
codigo_ibge: null,
|
codigo_ibge: null,
|
||||||
codigo_gyn: null,
|
codigo_gyn: null,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
cidade_id: 3,
|
cidade_id: 3,
|
||||||
uf: "AC",
|
uf: 'AC',
|
||||||
cidade_nome: "Brasiléia",
|
cidade_nome: 'Brasiléia',
|
||||||
codigo_ibge: null,
|
codigo_ibge: null,
|
||||||
codigo_gyn: null,
|
codigo_gyn: null,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
cidade_id: 4,
|
cidade_id: 4,
|
||||||
uf: "AC",
|
uf: 'AC',
|
||||||
cidade_nome: "Bujari",
|
cidade_nome: 'Bujari',
|
||||||
codigo_ibge: null,
|
codigo_ibge: null,
|
||||||
codigo_gyn: null,
|
codigo_gyn: null,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
cidade_id: 5,
|
cidade_id: 5,
|
||||||
uf: "AC",
|
uf: 'AC',
|
||||||
cidade_nome: "Capixaba",
|
cidade_nome: 'Capixaba',
|
||||||
codigo_ibge: null,
|
codigo_ibge: null,
|
||||||
codigo_gyn: null,
|
codigo_gyn: null,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
cidade_id: 6,
|
cidade_id: 6,
|
||||||
uf: "AC",
|
uf: 'AC',
|
||||||
cidade_nome: "Cruzeiro do Sul",
|
cidade_nome: 'Cruzeiro do Sul',
|
||||||
codigo_ibge: null,
|
codigo_ibge: null,
|
||||||
codigo_gyn: null,
|
codigo_gyn: null,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
cidade_id: 7,
|
cidade_id: 7,
|
||||||
uf: "AC",
|
uf: 'AC',
|
||||||
cidade_nome: "Epitaciolândia",
|
cidade_nome: 'Epitaciolândia',
|
||||||
codigo_ibge: null,
|
codigo_ibge: null,
|
||||||
codigo_gyn: null,
|
codigo_gyn: null,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
cidade_id: 8,
|
cidade_id: 8,
|
||||||
uf: "AC",
|
uf: 'AC',
|
||||||
cidade_nome: "Feijó",
|
cidade_nome: 'Feijó',
|
||||||
codigo_ibge: null,
|
codigo_ibge: null,
|
||||||
codigo_gyn: null,
|
codigo_gyn: null,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
cidade_id: 9,
|
cidade_id: 9,
|
||||||
uf: "AC",
|
uf: 'AC',
|
||||||
cidade_nome: "Jordão",
|
cidade_nome: 'Jordão',
|
||||||
codigo_ibge: null,
|
codigo_ibge: null,
|
||||||
codigo_gyn: null,
|
codigo_gyn: null,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
cidade_id: 10,
|
cidade_id: 10,
|
||||||
uf: "AC",
|
uf: 'AC',
|
||||||
cidade_nome: "Mâncio Lima",
|
cidade_nome: 'Mâncio Lima',
|
||||||
codigo_ibge: null,
|
codigo_ibge: null,
|
||||||
codigo_gyn: null,
|
codigo_gyn: null,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
import API from "@/services/api/Api";
|
import API from '@/services/api/Api';
|
||||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
import { Methods } from '@/services/api/enums/ApiMethodEnum';
|
||||||
import GCidadeInterface from "../../_interfaces/GCidadeInterface";
|
import GCidadeInterface from '../../_interfaces/GCidadeInterface';
|
||||||
|
|
||||||
export default async function GCidadeRemoveData(data: GCidadeInterface) {
|
export default async function GCidadeRemoveData(data: GCidadeInterface) {
|
||||||
return Promise.resolve({
|
return Promise.resolve({
|
||||||
status: 200,
|
status: 200,
|
||||||
message: "Dados removidos",
|
message: 'Dados removidos',
|
||||||
data: null,
|
data: null,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
// Importa o serviço de API que será utilizado para realizar requisições HTTP
|
// 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)
|
// 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
|
// 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
|
// 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
|
// Função assíncrona que implementa a lógica de salvar (criar/atualizar) uma cidade
|
||||||
async function executeGcidadeSaveData(data: GCidadeInterface) {
|
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
|
// Executa a requisição para a API com o método apropriado e envia os dados no corpo
|
||||||
return await api.send({
|
return await api.send({
|
||||||
method: isUpdate ? Methods.PUT : Methods.POST, // PUT se atualizar, POST se criar
|
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
|
body: data, // payload enviado para a API
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { withClientErrorHandler } from "@/actions/withClientErrorHandler/withClientErrorHandler";
|
import { withClientErrorHandler } from '@/actions/withClientErrorHandler/withClientErrorHandler';
|
||||||
import API from "@/services/api/Api";
|
import API from '@/services/api/Api';
|
||||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
import { Methods } from '@/services/api/enums/ApiMethodEnum';
|
||||||
|
|
||||||
async function executeGMedidaTipoIndexData() {
|
async function executeGMedidaTipoIndexData() {
|
||||||
const api = new API();
|
const api = new API();
|
||||||
|
|
@ -10,6 +10,4 @@ async function executeGMedidaTipoIndexData() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export const GMedidaTipoIndexData = withClientErrorHandler(
|
export const GMedidaTipoIndexData = withClientErrorHandler(executeGMedidaTipoIndexData);
|
||||||
executeGMedidaTipoIndexData,
|
|
||||||
);
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import API from "@/services/api/Api";
|
import API from '@/services/api/Api';
|
||||||
import { GMedidaTipoInterface } from "../../_interfaces/GMedidaTipoInterface";
|
import { GMedidaTipoInterface } from '../../_interfaces/GMedidaTipoInterface';
|
||||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
import { Methods } from '@/services/api/enums/ApiMethodEnum';
|
||||||
import { withClientErrorHandler } from "@/actions/withClientErrorHandler/withClientErrorHandler";
|
import { withClientErrorHandler } from '@/actions/withClientErrorHandler/withClientErrorHandler';
|
||||||
|
|
||||||
async function executeGMedidaTipoRemoveData(data: GMedidaTipoInterface) {
|
async function executeGMedidaTipoRemoveData(data: GMedidaTipoInterface) {
|
||||||
const api = new API();
|
const api = new API();
|
||||||
|
|
@ -12,6 +12,4 @@ async function executeGMedidaTipoRemoveData(data: GMedidaTipoInterface) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export const GMedidaTipoRemoveData = withClientErrorHandler(
|
export const GMedidaTipoRemoveData = withClientErrorHandler(executeGMedidaTipoRemoveData);
|
||||||
executeGMedidaTipoRemoveData,
|
|
||||||
);
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import API from "@/services/api/Api";
|
import API from '@/services/api/Api';
|
||||||
import { GMedidaTipoInterface } from "../../_interfaces/GMedidaTipoInterface";
|
import { GMedidaTipoInterface } from '../../_interfaces/GMedidaTipoInterface';
|
||||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
import { Methods } from '@/services/api/enums/ApiMethodEnum';
|
||||||
import { withClientErrorHandler } from "@/actions/withClientErrorHandler/withClientErrorHandler";
|
import { withClientErrorHandler } from '@/actions/withClientErrorHandler/withClientErrorHandler';
|
||||||
|
|
||||||
async function executeGMedidaTipoSaveData(data: GMedidaTipoInterface) {
|
async function executeGMedidaTipoSaveData(data: GMedidaTipoInterface) {
|
||||||
const isUpdate = Boolean(data.medida_tipo_id);
|
const isUpdate = Boolean(data.medida_tipo_id);
|
||||||
|
|
@ -10,11 +10,9 @@ async function executeGMedidaTipoSaveData(data: GMedidaTipoInterface) {
|
||||||
|
|
||||||
return await api.send({
|
return await api.send({
|
||||||
method: isUpdate ? Methods.PUT : Methods.POST,
|
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,
|
body: data,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export const GMedidaTipoSaveData = withClientErrorHandler(
|
export const GMedidaTipoSaveData = withClientErrorHandler(executeGMedidaTipoSaveData);
|
||||||
executeGMedidaTipoSaveData,
|
|
||||||
);
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { withClientErrorHandler } from "@/actions/withClientErrorHandler/withClientErrorHandler";
|
import { withClientErrorHandler } from '@/actions/withClientErrorHandler/withClientErrorHandler';
|
||||||
import API from "@/services/api/Api";
|
import API from '@/services/api/Api';
|
||||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
import { Methods } from '@/services/api/enums/ApiMethodEnum';
|
||||||
|
|
||||||
async function executeGTBBairroIndexData() {
|
async function executeGTBBairroIndexData() {
|
||||||
const api = new API();
|
const api = new API();
|
||||||
|
|
@ -13,6 +13,4 @@ async function executeGTBBairroIndexData() {
|
||||||
return dados;
|
return dados;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const GTBBairroIndexData = withClientErrorHandler(
|
export const GTBBairroIndexData = withClientErrorHandler(executeGTBBairroIndexData);
|
||||||
executeGTBBairroIndexData,
|
|
||||||
);
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import API from "@/services/api/Api";
|
import API from '@/services/api/Api';
|
||||||
import { GTBBairroInterface } from "../../_interfaces/GTBBairroInterface";
|
import { GTBBairroInterface } from '../../_interfaces/GTBBairroInterface';
|
||||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
import { Methods } from '@/services/api/enums/ApiMethodEnum';
|
||||||
import { withClientErrorHandler } from "@/actions/withClientErrorHandler/withClientErrorHandler";
|
import { withClientErrorHandler } from '@/actions/withClientErrorHandler/withClientErrorHandler';
|
||||||
|
|
||||||
async function executeGTBBairroRemoveData(data: GTBBairroInterface) {
|
async function executeGTBBairroRemoveData(data: GTBBairroInterface) {
|
||||||
const api = new API();
|
const api = new API();
|
||||||
|
|
@ -12,6 +12,4 @@ async function executeGTBBairroRemoveData(data: GTBBairroInterface) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export const GTBBairroRemoveData = withClientErrorHandler(
|
export const GTBBairroRemoveData = withClientErrorHandler(executeGTBBairroRemoveData);
|
||||||
executeGTBBairroRemoveData,
|
|
||||||
);
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import API from "@/services/api/Api";
|
import API from '@/services/api/Api';
|
||||||
import { GTBBairroInterface } from "../../_interfaces/GTBBairroInterface";
|
import { GTBBairroInterface } from '../../_interfaces/GTBBairroInterface';
|
||||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
import { Methods } from '@/services/api/enums/ApiMethodEnum';
|
||||||
import { withClientErrorHandler } from "@/actions/withClientErrorHandler/withClientErrorHandler";
|
import { withClientErrorHandler } from '@/actions/withClientErrorHandler/withClientErrorHandler';
|
||||||
|
|
||||||
async function executeGTBBairroSaveData(data: GTBBairroInterface) {
|
async function executeGTBBairroSaveData(data: GTBBairroInterface) {
|
||||||
const isUpdate = Boolean(data.tb_bairro_id);
|
const isUpdate = Boolean(data.tb_bairro_id);
|
||||||
|
|
@ -10,11 +10,9 @@ async function executeGTBBairroSaveData(data: GTBBairroInterface) {
|
||||||
|
|
||||||
return await api.send({
|
return await api.send({
|
||||||
method: isUpdate ? Methods.PUT : Methods.POST,
|
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,
|
body: data,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export const GTBBairroSaveData = withClientErrorHandler(
|
export const GTBBairroSaveData = withClientErrorHandler(executeGTBBairroSaveData);
|
||||||
executeGTBBairroSaveData,
|
|
||||||
);
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { withClientErrorHandler } from "@/actions/withClientErrorHandler/withClientErrorHandler";
|
import { withClientErrorHandler } from '@/actions/withClientErrorHandler/withClientErrorHandler';
|
||||||
import API from "@/services/api/Api";
|
import API from '@/services/api/Api';
|
||||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
import { Methods } from '@/services/api/enums/ApiMethodEnum';
|
||||||
|
|
||||||
async function executeGTBEstadoCivilIndexData() {
|
async function executeGTBEstadoCivilIndexData() {
|
||||||
const api = new API();
|
const api = new API();
|
||||||
|
|
@ -11,6 +11,4 @@ async function executeGTBEstadoCivilIndexData() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export const GTBEstadoCivilIndexData = withClientErrorHandler(
|
export const GTBEstadoCivilIndexData = withClientErrorHandler(executeGTBEstadoCivilIndexData);
|
||||||
executeGTBEstadoCivilIndexData,
|
|
||||||
);
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import API from "@/services/api/Api";
|
import API from '@/services/api/Api';
|
||||||
import { GTBEstadoCivilInterface } from "../../_interfaces/GTBEstadoCivilInterface";
|
import { GTBEstadoCivilInterface } from '../../_interfaces/GTBEstadoCivilInterface';
|
||||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
import { Methods } from '@/services/api/enums/ApiMethodEnum';
|
||||||
import { withClientErrorHandler } from "@/actions/withClientErrorHandler/withClientErrorHandler";
|
import { withClientErrorHandler } from '@/actions/withClientErrorHandler/withClientErrorHandler';
|
||||||
|
|
||||||
async function executeGTBEstadoCivilRemoveData(data: GTBEstadoCivilInterface) {
|
async function executeGTBEstadoCivilRemoveData(data: GTBEstadoCivilInterface) {
|
||||||
const api = new API();
|
const api = new API();
|
||||||
|
|
@ -12,6 +12,4 @@ async function executeGTBEstadoCivilRemoveData(data: GTBEstadoCivilInterface) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export const GTBEstadoCivilRemoveData = withClientErrorHandler(
|
export const GTBEstadoCivilRemoveData = withClientErrorHandler(executeGTBEstadoCivilRemoveData);
|
||||||
executeGTBEstadoCivilRemoveData,
|
|
||||||
);
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import API from "@/services/api/Api";
|
import API from '@/services/api/Api';
|
||||||
import { GTBEstadoCivilInterface } from "../../_interfaces/GTBEstadoCivilInterface";
|
import { GTBEstadoCivilInterface } from '../../_interfaces/GTBEstadoCivilInterface';
|
||||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
import { Methods } from '@/services/api/enums/ApiMethodEnum';
|
||||||
import { withClientErrorHandler } from "@/actions/withClientErrorHandler/withClientErrorHandler";
|
import { withClientErrorHandler } from '@/actions/withClientErrorHandler/withClientErrorHandler';
|
||||||
|
|
||||||
async function executeGTBEstadoCivilSaveData(data: GTBEstadoCivilInterface) {
|
async function executeGTBEstadoCivilSaveData(data: GTBEstadoCivilInterface) {
|
||||||
const isUpdate = Boolean(data.tb_estadocivil_id);
|
const isUpdate = Boolean(data.tb_estadocivil_id);
|
||||||
|
|
@ -10,11 +10,9 @@ async function executeGTBEstadoCivilSaveData(data: GTBEstadoCivilInterface) {
|
||||||
|
|
||||||
return await api.send({
|
return await api.send({
|
||||||
method: isUpdate ? Methods.PUT : Methods.POST,
|
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,
|
body: data,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export const GTBEstadoCivilSaveData = withClientErrorHandler(
|
export const GTBEstadoCivilSaveData = withClientErrorHandler(executeGTBEstadoCivilSaveData);
|
||||||
executeGTBEstadoCivilSaveData,
|
|
||||||
);
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import API from "@/services/api/Api";
|
import API from '@/services/api/Api';
|
||||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
import { Methods } from '@/services/api/enums/ApiMethodEnum';
|
||||||
|
|
||||||
export default async function GTBProfissoesIndexData() {
|
export default async function GTBProfissoesIndexData() {
|
||||||
const api = new API();
|
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