Compare commits
1 commit
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ac49c86f53 |
1196 changed files with 10956 additions and 48866 deletions
117
.code-workspace
117
.code-workspace
|
|
@ -1,117 +0,0 @@
|
|||
{
|
||||
"folders": [{ "path": "D:/IIS/Orius/app" }],
|
||||
"settings": {
|
||||
// === GERAL ===
|
||||
"editor.formatOnSave": true,
|
||||
"editor.codeActionsOnSave": {
|
||||
"source.fixAll": "explicit",
|
||||
"source.organizeImports": "explicit",
|
||||
},
|
||||
"editor.formatOnPaste": false,
|
||||
"editor.formatOnType": false,
|
||||
"editor.minimap.enabled": false,
|
||||
"files.trimTrailingWhitespace": true,
|
||||
"files.autoSave": "onFocusChange",
|
||||
"telemetry.telemetryLevel": "off",
|
||||
"update.mode": "manual",
|
||||
|
||||
// === PERFORMANCE ===
|
||||
"files.watcherExclude": {
|
||||
"**/node_modules/**": true,
|
||||
"**/dist/**": true,
|
||||
"**/build/**": true,
|
||||
"**/.next/**": true,
|
||||
"**/.git/**": true,
|
||||
},
|
||||
"search.exclude": {
|
||||
"**/node_modules": true,
|
||||
"**/dist": true,
|
||||
"**/.next": true,
|
||||
"**/.git": true,
|
||||
},
|
||||
|
||||
// === FRONTEND ===
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||
"eslint.validate": ["javascript", "javascriptreact", "typescript", "typescriptreact"],
|
||||
"[typescript]": {
|
||||
"editor.defaultFormatter": "vscode.typescript-language-features",
|
||||
},
|
||||
"[typescriptreact]": {
|
||||
"editor.defaultFormatter": "vscode.typescript-language-features",
|
||||
},
|
||||
|
||||
// === TAILWIND ===
|
||||
"files.associations": {
|
||||
"*.css": "tailwindcss",
|
||||
},
|
||||
"tailwindCSS.includeLanguages": {
|
||||
"plaintext": "html",
|
||||
"javascript": "javascript",
|
||||
"typescriptreact": "typescriptreact",
|
||||
},
|
||||
|
||||
// === TERMINAIS ===
|
||||
"terminal.integrated.profiles.windows": {
|
||||
"Next.js Dev": {
|
||||
"path": "cmd.exe",
|
||||
"args": ["/k", "cd D:\\IIS\\Orius\\app && npm run dev"],
|
||||
},
|
||||
"Build & Preview": {
|
||||
"path": "cmd.exe",
|
||||
"args": ["/k", "cd D:\\IIS\\Orius\\app && npm run build && npm run start"],
|
||||
},
|
||||
"Git Bash": {
|
||||
"path": "C:\\Program Files\\Git\\bin\\bash.exe",
|
||||
},
|
||||
},
|
||||
"terminal.integrated.defaultProfile.windows": "Git Bash",
|
||||
|
||||
// === GIT ===
|
||||
"git.enabled": true,
|
||||
"git.autorefresh": false,
|
||||
"git.fetchOnPull": true,
|
||||
"git.confirmSync": false,
|
||||
|
||||
// === VISUAL ===
|
||||
"workbench.colorTheme": "Default Dark Modern",
|
||||
"window.zoomLevel": 0,
|
||||
"breadcrumbs.enabled": true,
|
||||
"explorer.compactFolders": false,
|
||||
|
||||
// === MISC ===
|
||||
"files.exclude": {
|
||||
"**/.DS_Store": true,
|
||||
"**/*.log": true,
|
||||
},
|
||||
},
|
||||
"launch": {
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Next.js: Debug Development Server",
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"runtimeExecutable": "npm",
|
||||
"runtimeArgs": ["run", "dev"],
|
||||
"cwd": "${workspaceFolder}",
|
||||
"port": 9229,
|
||||
},
|
||||
],
|
||||
},
|
||||
"extensions": {
|
||||
"recommendations": [
|
||||
// === FRONTEND CORE ===
|
||||
"dbaeumer.vscode-eslint",
|
||||
"esbenp.prettier-vscode",
|
||||
"bradlc.vscode-tailwindcss",
|
||||
"ms-vscode.vscode-typescript-next",
|
||||
|
||||
// === DEV EXPERIENCE ===
|
||||
"formulahendry.code-runner",
|
||||
"streetsidesoftware.code-spell-checker",
|
||||
"eamodio.gitlens",
|
||||
"mhutchie.git-graph",
|
||||
"donjayamanne.githistory",
|
||||
],
|
||||
},
|
||||
}
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
{
|
||||
"semi": true,
|
||||
"trailingComma": "all",
|
||||
"singleQuote": true,
|
||||
"printWidth": 100,
|
||||
"tabWidth": 2,
|
||||
"arrowParens": "always",
|
||||
"plugins": ["prettier-plugin-tailwindcss"]
|
||||
}
|
||||
65
Dockerfile
65
Dockerfile
|
|
@ -1,59 +1,22 @@
|
|||
# ============================
|
||||
# STAGE 1 – Build
|
||||
# ============================
|
||||
FROM node:20-alpine AS builder
|
||||
# Use uma imagem Node.js completa para o desenvolvimento
|
||||
FROM node:20-alpine
|
||||
|
||||
# Define o diretório de trabalho no container
|
||||
WORKDIR /app
|
||||
|
||||
# Copia pacotes e instala dependências
|
||||
COPY package*.json ./
|
||||
RUN npm ci
|
||||
# Copia os arquivos de configuração do projeto
|
||||
COPY package.json package-lock.json ./
|
||||
|
||||
# Copia o restante do código
|
||||
# Instala todas as dependências do projeto
|
||||
# Isso é necessário para o modo de desenvolvimento, pois o build não pré-compila os arquivos.
|
||||
RUN npm install
|
||||
|
||||
# Copia o restante do código da sua aplicação
|
||||
COPY . .
|
||||
|
||||
# ---------- Variáveis de build ----------
|
||||
# Estas variáveis são usadas pelo Next.js durante o "build"
|
||||
# para embutir no bundle do frontend.
|
||||
ARG NEXT_PUBLIC_ORIUS_APP_STATE
|
||||
ARG NEXT_PUBLIC_ORIUS_APP_API_URL
|
||||
ARG NEXT_PUBLIC_ORIUS_APP_API_PREFIX
|
||||
ARG NEXT_PUBLIC_ORIUS_APP_API_CONTENT_TYPE
|
||||
|
||||
ENV NEXT_PUBLIC_ORIUS_APP_STATE=$NEXT_PUBLIC_ORIUS_APP_STATE
|
||||
ENV NEXT_PUBLIC_ORIUS_APP_API_URL=$NEXT_PUBLIC_ORIUS_APP_API_URL
|
||||
ENV NEXT_PUBLIC_ORIUS_APP_API_PREFIX=$NEXT_PUBLIC_ORIUS_APP_API_PREFIX
|
||||
ENV NEXT_PUBLIC_ORIUS_APP_API_CONTENT_TYPE=$NEXT_PUBLIC_ORIUS_APP_API_CONTENT_TYPE
|
||||
|
||||
# ---------- Build ----------
|
||||
ENV NODE_ENV=production
|
||||
RUN npm run build
|
||||
|
||||
# ============================
|
||||
# STAGE 2 – Runner (standalone)
|
||||
# ============================
|
||||
FROM node:20-alpine AS runner
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# ---------- Variáveis em runtime ----------
|
||||
ENV NODE_ENV=production
|
||||
ENV NEXT_TELEMETRY_DISABLED=1
|
||||
|
||||
# Copia apenas o necessário do build
|
||||
COPY --from=builder /app/.next/standalone ./
|
||||
COPY --from=builder /app/.next/static ./.next/static
|
||||
COPY --from=builder /app/public ./public
|
||||
COPY --from=builder /app/package*.json ./
|
||||
|
||||
# ---------- Corrige permissões ----------
|
||||
RUN addgroup -S nodejs && adduser -S nextjs -G nodejs \
|
||||
&& mkdir -p .next/cache/images \
|
||||
&& chown -R nextjs:nodejs /app
|
||||
|
||||
USER nextjs
|
||||
|
||||
# Expõe a porta de desenvolvimento padrão do Next.js
|
||||
EXPOSE 3000
|
||||
|
||||
# ---------- Executa o servidor ----------
|
||||
CMD ["node", "server.js"]
|
||||
# Define o comando para iniciar a aplicação em modo de desenvolvimento
|
||||
# Isso ativará o servidor de desenvolvimento e a recarga automática
|
||||
CMD ["npm", "run", "dev"]
|
||||
|
|
|
|||
41
Dockerfile-homologacao
Normal file
41
Dockerfile-homologacao
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
# Etapa 1: Construir a aplicação
|
||||
FROM node:20-alpine AS builder
|
||||
|
||||
# Define o diretório de trabalho
|
||||
WORKDIR /app
|
||||
|
||||
# Copia os arquivos de configuração do pacote
|
||||
COPY package.json package-lock.json ./
|
||||
|
||||
# Instala as dependências do projeto
|
||||
RUN npm install
|
||||
|
||||
# Copia todo o código da aplicação para o container
|
||||
COPY . .
|
||||
|
||||
# Constrói a aplicação com o output 'standalone'
|
||||
RUN npm run build
|
||||
|
||||
# Etapa 2: Executar a aplicação
|
||||
# Usa uma imagem Node.js leve
|
||||
FROM node:20-alpine AS runner
|
||||
|
||||
# Define o diretório de trabalho
|
||||
WORKDIR /app
|
||||
|
||||
# Copia o diretório 'standalone' da etapa de build, que já contém o servidor e as dependências
|
||||
# O diretório 'standalone' é a pasta .next/standalone gerada pela configuração 'output: standalone'
|
||||
COPY --from=builder /app/.next/standalone ./
|
||||
|
||||
# Copia os arquivos públicos
|
||||
COPY --from=builder /app/public ./public
|
||||
|
||||
# Copia os arquivos estáticos gerados pelo build. É aqui que os arquivos CSS e JS ficam.
|
||||
COPY --from=builder /app/.next/static ./.next/static
|
||||
|
||||
# Expõe a porta padrão do Next.js
|
||||
EXPOSE 3000
|
||||
|
||||
# Define o comando para iniciar a aplicação
|
||||
# O 'start' do package.json não é necessário, o próprio servidor standalone já está no container
|
||||
CMD ["node", "server.js"]
|
||||
56
README.md
56
README.md
|
|
@ -1,58 +1,2 @@
|
|||
# saas_app
|
||||
|
||||
Criar envlocal para usar variaveis de ambiente no em desenvolvimento
|
||||
NEXT_PUBLIC_ORIUS_APP_STATE=GO
|
||||
NEXT_PUBLIC_ORIUS_APP_API_URL=<http://localhost:8000/>
|
||||
NEXT_PUBLIC_ORIUS_APP_API_PREFIX=api/v1/
|
||||
NEXT_PUBLIC_ORIUS_APP_API_CONTENT_TYPE=application/json
|
||||
|
||||
## Modo Debug
|
||||
|
||||
Abra Run → Add Configuration… → Attach to Node.js
|
||||
|
||||
Configure:
|
||||
|
||||
{
|
||||
"name": "Attach Next.js (9230)",
|
||||
"type": "node",
|
||||
"request": "attach",
|
||||
"port": 9230,
|
||||
"restart": true,
|
||||
"smartStep": true,
|
||||
"skipFiles": ["<node_internals>/**"]
|
||||
}
|
||||
|
||||
npm run dev:debug
|
||||
|
||||
## onlyoffice
|
||||
|
||||
docker run -i -t -d -p 8081:80 --restart=always -e JWT_ENABLED=false onlyoffice/documentserver
|
||||
|
||||
## next em rede
|
||||
|
||||
```
|
||||
npx next dev -H 0.0.0.0
|
||||
```
|
||||
|
||||
```
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
"build": "next build",
|
||||
"start": "next start",
|
||||
"dev:lan": "next dev -H 0.0.0.0" <-- Adicione esta linha
|
||||
},
|
||||
```
|
||||
|
||||
Como acessar no outro dispositivo
|
||||
Descubra seu IP Local:
|
||||
|
||||
No Windows (seu caso), abra um terminal (CMD ou PowerShell) e digite:
|
||||
|
||||
Bash
|
||||
|
||||
ipconfig
|
||||
Procure por Endereço IPv4 (geralmente começa com 192.168.x.x ou 10.0.x.x).
|
||||
|
||||
Acesse no navegador: No celular ou outro computador, digite: http://SEU_IP_AQUI:3000
|
||||
|
||||
Exemplo: <http://192.168.0.15:3000>
|
||||
|
|
|
|||
|
|
@ -1,70 +0,0 @@
|
|||
import js from '@eslint/js';
|
||||
import reactPlugin from 'eslint-plugin-react';
|
||||
import reactHooks from 'eslint-plugin-react-hooks';
|
||||
import jsxA11y from 'eslint-plugin-jsx-a11y';
|
||||
import importPlugin from 'eslint-plugin-import';
|
||||
import tseslint from 'typescript-eslint';
|
||||
|
||||
export default [
|
||||
js.configs.recommended,
|
||||
...tseslint.configs.recommended,
|
||||
{
|
||||
files: ['**/*.ts', '**/*.tsx'],
|
||||
ignores: ['node_modules/**', '.next/**', 'out/**', 'dist/**'],
|
||||
languageOptions: {
|
||||
ecmaVersion: 'latest',
|
||||
sourceType: 'module',
|
||||
parser: tseslint.parser,
|
||||
parserOptions: {
|
||||
project: './tsconfig.json',
|
||||
},
|
||||
globals: {
|
||||
React: true,
|
||||
JSX: true,
|
||||
},
|
||||
},
|
||||
plugins: {
|
||||
react: reactPlugin,
|
||||
'react-hooks': reactHooks,
|
||||
'jsx-a11y': jsxA11y,
|
||||
import: importPlugin,
|
||||
},
|
||||
settings: {
|
||||
react: { version: 'detect' },
|
||||
'import/resolver': {
|
||||
typescript: {
|
||||
alwaysTryTypes: true,
|
||||
project: './tsconfig.json',
|
||||
},
|
||||
node: {
|
||||
extensions: ['.js', '.jsx', '.ts', '.tsx'],
|
||||
},
|
||||
},
|
||||
},
|
||||
rules: {
|
||||
'react/react-in-jsx-scope': 'off',
|
||||
'react/jsx-uses-react': 'off',
|
||||
'react/jsx-uses-vars': 'warn',
|
||||
'react-hooks/rules-of-hooks': 'error',
|
||||
'react-hooks/exhaustive-deps': 'warn',
|
||||
'import/order': [
|
||||
'error',
|
||||
{
|
||||
groups: [['builtin', 'external'], ['internal'], ['parent', 'sibling', 'index']],
|
||||
pathGroups: [
|
||||
{
|
||||
pattern: '@/**',
|
||||
group: 'internal',
|
||||
position: 'after',
|
||||
},
|
||||
],
|
||||
alphabetize: { order: 'asc', caseInsensitive: true },
|
||||
'newlines-between': 'always',
|
||||
},
|
||||
],
|
||||
'import/no-duplicates': 'error',
|
||||
'import/newline-after-import': ['error', { count: 1 }],
|
||||
'no-unused-vars': 'warn',
|
||||
},
|
||||
},
|
||||
];
|
||||
|
|
@ -1,17 +1,8 @@
|
|||
/** @type {import('next').NextConfig} */
|
||||
const nextConfig = {
|
||||
// Gera build autônomo para rodar com "node server.js"
|
||||
import type { NextConfig } from "next";
|
||||
|
||||
const nextConfig: NextConfig = {
|
||||
// Isso gera um diretório otimizado que inclui tudo o que a aplicação precisa para rodar
|
||||
output: 'standalone',
|
||||
|
||||
// Configurações gerais
|
||||
reactStrictMode: true,
|
||||
poweredByHeader: false,
|
||||
compress: true,
|
||||
|
||||
// Desativa verificações no build de produção
|
||||
eslint: { ignoreDuringBuilds: true },
|
||||
typescript: { ignoreBuildErrors: true },
|
||||
|
||||
};
|
||||
|
||||
module.exports = nextConfig;
|
||||
export default nextConfig;
|
||||
|
|
|
|||
6967
package-lock.json
generated
6967
package-lock.json
generated
File diff suppressed because it is too large
Load diff
45
package.json
45
package.json
|
|
@ -1,20 +1,16 @@
|
|||
{
|
||||
"type": "module",
|
||||
"name": "saas",
|
||||
"name": "app",
|
||||
"version": "25.9.1",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
"dev:debug": "cross-env NEXT_USE_TURBOPACK=0 NODE_OPTIONS=\"--inspect=9230\" next dev",
|
||||
"dev": "next dev --turbopack",
|
||||
"build": "next build",
|
||||
"start": "next start",
|
||||
"lint": "next lint",
|
||||
"postinstall": "shx mkdir -p public/libs && shx cp -r node_modules/tinymce public/libs/tinymce"
|
||||
"lint": "next lint"
|
||||
},
|
||||
"dependencies": {
|
||||
"@faker-js/faker": "^10.0.0",
|
||||
"@hookform/resolvers": "^5.2.1",
|
||||
"@onlyoffice/document-editor-react": "^2.1.1",
|
||||
"@radix-ui/react-alert-dialog": "^1.1.15",
|
||||
"@radix-ui/react-avatar": "^1.1.10",
|
||||
"@radix-ui/react-checkbox": "^1.3.3",
|
||||
|
|
@ -23,25 +19,15 @@
|
|||
"@radix-ui/react-dropdown-menu": "^2.1.16",
|
||||
"@radix-ui/react-label": "^2.1.7",
|
||||
"@radix-ui/react-popover": "^1.1.15",
|
||||
"@radix-ui/react-progress": "^1.1.7",
|
||||
"@radix-ui/react-radio-group": "^1.3.8",
|
||||
"@radix-ui/react-scroll-area": "^1.2.10",
|
||||
"@radix-ui/react-select": "^2.2.6",
|
||||
"@radix-ui/react-separator": "^1.1.8",
|
||||
"@radix-ui/react-slot": "^1.2.4",
|
||||
"@radix-ui/react-switch": "^1.2.6",
|
||||
"@radix-ui/react-tabs": "^1.1.13",
|
||||
"@radix-ui/react-separator": "^1.1.7",
|
||||
"@radix-ui/react-slot": "^1.2.3",
|
||||
"@radix-ui/react-tooltip": "^1.2.8",
|
||||
"@tanstack/react-table": "^8.21.3",
|
||||
"@tinymce/tinymce-react": "^6.3.0",
|
||||
"class-variance-authority": "^0.7.1",
|
||||
"clsx": "^2.1.1",
|
||||
"cmdk": "^1.1.1",
|
||||
"cookies-next": "^6.1.0",
|
||||
"date-fns": "^3.6.0",
|
||||
"faker-js": "^1.0.0",
|
||||
"framer-motion": "^12.23.24",
|
||||
"input-otp": "^1.4.2",
|
||||
"js-cookie": "^3.0.5",
|
||||
"jsonwebtoken": "^9.0.2",
|
||||
"jwt-decode": "^4.0.0",
|
||||
|
|
@ -51,8 +37,6 @@
|
|||
"react": "19.1.0",
|
||||
"react-dom": "19.1.0",
|
||||
"react-hook-form": "^7.62.0",
|
||||
"react-masked-text": "^1.0.5",
|
||||
"recharts": "^3.3.0",
|
||||
"sonner": "^2.0.7",
|
||||
"tailwind-merge": "^3.3.1",
|
||||
"tinymce": "^8.1.2",
|
||||
|
|
@ -60,30 +44,13 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"@tailwindcss/postcss": "^4",
|
||||
"@types/date-fns": "^2.5.3",
|
||||
"@types/js-cookie": "^3.0.6",
|
||||
"@types/jsonwebtoken": "^9.0.10",
|
||||
"@types/node": "^20",
|
||||
"@types/react": "^19",
|
||||
"@types/react-dom": "^19",
|
||||
"@typescript-eslint/eslint-plugin": "^8.46.1",
|
||||
"@typescript-eslint/parser": "^8.46.1",
|
||||
"cross-env": "^10.1.0",
|
||||
"eslint": "^9.38.0",
|
||||
"eslint-config-prettier": "^10.1.8",
|
||||
"eslint-import-resolver-typescript": "^4.4.4",
|
||||
"eslint-plugin-import": "^2.32.0",
|
||||
"eslint-plugin-jsx-a11y": "^6.10.2",
|
||||
"eslint-plugin-prettier": "^5.5.4",
|
||||
"eslint-plugin-react": "^7.37.5",
|
||||
"eslint-plugin-react-hooks": "^7.0.0",
|
||||
"eslint-plugin-unused-imports": "^4.2.0",
|
||||
"prettier": "^3.6.2",
|
||||
"prettier-plugin-tailwindcss": "^0.6.14",
|
||||
"shx": "^0.4.0",
|
||||
"tailwindcss": "^4",
|
||||
"tw-animate-css": "^1.3.7",
|
||||
"typescript": "5.9.3",
|
||||
"typescript-eslint": "^8.46.1"
|
||||
"typescript": "^5"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
const config = {
|
||||
plugins: ['@tailwindcss/postcss'],
|
||||
plugins: ["@tailwindcss/postcss"],
|
||||
};
|
||||
|
||||
export default config;
|
||||
|
|
|
|||
Binary file not shown.
|
Before Width: | Height: | Size: 41 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 2.8 KiB |
Binary file not shown.
Binary file not shown.
14
src/abstracts/Schema.ts
Normal file
14
src/abstracts/Schema.ts
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
|
||||
export default class Schema {
|
||||
|
||||
private _errors: any[] = []
|
||||
|
||||
get errors(): any {
|
||||
return this._errors;
|
||||
}
|
||||
|
||||
set errors(value: any) {
|
||||
this._errors.push(value);
|
||||
}
|
||||
|
||||
}
|
||||
19
src/actions/cookies/CookiesGet.ts
Normal file
19
src/actions/cookies/CookiesGet.ts
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
'use server'
|
||||
|
||||
import { cookies } from "next/headers";
|
||||
|
||||
/**
|
||||
* Função para obter tokens do lado servidorde acordo com o nome informado
|
||||
*/
|
||||
export default async function CookiesGet(token: string) {
|
||||
|
||||
// Obtem a lista de Tokens
|
||||
const cookieStore = await cookies();
|
||||
|
||||
// Obtem um token em especifico
|
||||
const data = cookieStore.get(token);
|
||||
|
||||
// Retorna nulo ou o valor do token desejado
|
||||
return data?.value;
|
||||
|
||||
}
|
||||
6
src/actions/json/Json.ts
Normal file
6
src/actions/json/Json.ts
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
import appConfig from '../../config/app.json';
|
||||
export default class Json {
|
||||
static execute() {
|
||||
return appConfig;
|
||||
}
|
||||
}
|
||||
15
src/actions/text/GetSigla.ts
Normal file
15
src/actions/text/GetSigla.ts
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
export default function GetSigla(data: string): string {
|
||||
|
||||
if (!data) return "";
|
||||
|
||||
// Remove espaços extras no início e no fim e divide em palavras
|
||||
const palavras = data.trim().split(/\s+/);
|
||||
|
||||
if (palavras.length === 1) {
|
||||
// Apenas uma palavra → retorna as duas primeiras letras
|
||||
return palavras[0].substring(0, 2).toUpperCase();
|
||||
}
|
||||
|
||||
// Duas ou mais palavras → retorna a primeira letra de cada
|
||||
return palavras.map(palavra => palavra.charAt(0).toUpperCase()).join('');
|
||||
}
|
||||
11
src/actions/token/TokenGet.ts
Normal file
11
src/actions/token/TokenGet.ts
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
'use server'
|
||||
|
||||
import { cookies } from "next/headers";
|
||||
|
||||
export default async function TokenGet() {
|
||||
|
||||
const cookieStore = await cookies();
|
||||
const token = cookieStore.get('access_token');
|
||||
return token?.value;
|
||||
|
||||
}
|
||||
9
src/actions/validations/empty.ts
Normal file
9
src/actions/validations/empty.ts
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
|
||||
export default function empty(data: any) {
|
||||
if (!data || !data === null || !data === undefined) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
32
src/actions/withClientErrorHandler/withClientErrorHandler.ts
Normal file
32
src/actions/withClientErrorHandler/withClientErrorHandler.ts
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
import withClientErrorHandlerInterface from "./withClientErrorHandlerInterface";
|
||||
|
||||
/**
|
||||
* Códigos de erro que começam com 6, são do front entd, na ordem do alfabeto o F de frontend é a sexta letra
|
||||
*/
|
||||
export function withClientErrorHandler<T extends (...args: any[]) => Promise<any>>(
|
||||
action: T
|
||||
) {
|
||||
return async (...args: Parameters<T>): Promise<withClientErrorHandlerInterface> => {
|
||||
|
||||
try {
|
||||
|
||||
// Executa a função definida
|
||||
const data = await action(...args);
|
||||
|
||||
// Retorna exatamente a mesma resposta retornada pela função
|
||||
return data;
|
||||
|
||||
} catch (error: any) {
|
||||
|
||||
// Retorna o erro de execuçãformatado
|
||||
return {
|
||||
status: 600,
|
||||
message: error?.message || "Erro interno do servidor",
|
||||
data: error
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
export default interface withClientErrorHandlerInterface<T = any> {
|
||||
|
||||
status: number;
|
||||
data?: T;
|
||||
message?: string;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,73 @@
|
|||
'use client'
|
||||
|
||||
import { useEffect } from "react";
|
||||
import { useParams } from "next/navigation";
|
||||
|
||||
import {
|
||||
Card,
|
||||
CardContent
|
||||
} from "@/components/ui/card";
|
||||
import { useGUsuarioReadHooks } from "@/app/(protected)/(administrativo)/_hooks/g_usuario/useGUsuarioReadHooks";
|
||||
import Usuario from "@/app/(protected)/(administrativo)/_interfaces/GUsuarioInterface";
|
||||
import Loading from "@/app/_components/loading/loading";
|
||||
|
||||
export default function UsuarioDetalhes() {
|
||||
|
||||
const params = useParams();
|
||||
|
||||
const { usuario, fetchUsuario } = useGUsuarioReadHooks();
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
if (params.id) {
|
||||
fetchUsuario({ usuario_id: Number(params.id) } as Usuario);
|
||||
}
|
||||
console.log("pagina",usuario)
|
||||
}, []);
|
||||
|
||||
if (!usuario) return <Loading type={1} />;
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Card>
|
||||
<CardContent>
|
||||
<div className="mb-4 grid gap-4 grid-cols-4">
|
||||
<div>
|
||||
<div className="text-2xl font-semibold">
|
||||
Nome
|
||||
</div>
|
||||
<div className="text-xl">
|
||||
{usuario?.nome_completo}
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div className="text-2xl font-semibold">
|
||||
CPF
|
||||
</div>
|
||||
<div className="text-xl">
|
||||
{usuario?.cpf}
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div className="text-2xl font-semibold">
|
||||
Função
|
||||
</div>
|
||||
<div className="text-xl">
|
||||
{usuario?.funcao}
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div className="text-2xl font-semibold">
|
||||
Email
|
||||
</div>
|
||||
<div className="text-xl">
|
||||
{usuario?.email}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,136 @@
|
|||
'use client'
|
||||
|
||||
import { zodResolver } from "@hookform/resolvers/zod"
|
||||
import { useForm } from "react-hook-form"
|
||||
import { z } from "zod"
|
||||
import { Input } from "@/components/ui/input"
|
||||
import { GUsuarioSchema } from "../../../_schemas/GUsuarioSchema"
|
||||
|
||||
import {
|
||||
Button
|
||||
} from "@/components/ui/button"
|
||||
|
||||
import {
|
||||
Card,
|
||||
CardContent
|
||||
} from "@/components/ui/card";
|
||||
|
||||
import {
|
||||
Form,
|
||||
FormControl,
|
||||
FormField,
|
||||
FormItem,
|
||||
FormLabel,
|
||||
FormMessage,
|
||||
} from "@/components/ui/form"
|
||||
|
||||
import { useGUsuarioSaveHook } from "../../../_hooks/g_usuario/useGUsuarioSaveHook"
|
||||
|
||||
type FormValues = z.infer<typeof GUsuarioSchema>
|
||||
|
||||
export default function UsuarioFormularioPage() {
|
||||
|
||||
const { usuario, saveUsuario } = useGUsuarioSaveHook();
|
||||
|
||||
const form = useForm<FormValues>({
|
||||
resolver: zodResolver(GUsuarioSchema),
|
||||
defaultValues: {
|
||||
login: '',
|
||||
nome_completo: '',
|
||||
funcao: '',
|
||||
email: '',
|
||||
cpf: ''
|
||||
},
|
||||
});
|
||||
|
||||
async function onSubmit(values: FormValues) {
|
||||
saveUsuario(values);
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Card>
|
||||
<CardContent>
|
||||
<Form {...form}>
|
||||
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-8">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="login"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Login</FormLabel>
|
||||
<FormControl>
|
||||
<Input {...field} />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="nome_completo"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Nome Completo</FormLabel>
|
||||
<FormControl>
|
||||
<Input {...field} />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="funcao"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Função</FormLabel>
|
||||
<FormControl>
|
||||
<Input {...field} />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="email"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Email</FormLabel>
|
||||
<FormControl>
|
||||
<Input {...field} />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="cpf"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Cpf</FormLabel>
|
||||
<FormControl>
|
||||
<Input {...field} />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
<Button type="submit">
|
||||
Salvar
|
||||
</Button>
|
||||
</form>
|
||||
</Form>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,112 @@
|
|||
'use client'
|
||||
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
} from "@/components/ui/card"
|
||||
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableHead,
|
||||
TableHeader,
|
||||
TableRow,
|
||||
} from "@/components/ui/table"
|
||||
|
||||
import Usuario from "../../_interfaces/GUsuarioInterface";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import Link from "next/link";
|
||||
import { useGUsuarioIndexHook } from "../../_hooks/g_usuario/useGUsuarioIndexHook";
|
||||
import { useEffect } from "react";
|
||||
import Loading from "@/app/_components/loading/loading";
|
||||
|
||||
export default function UsuarioPage() {
|
||||
|
||||
const { usuarios, fetchUsuarios } = useGUsuarioIndexHook();
|
||||
|
||||
useEffect(() => {
|
||||
fetchUsuarios();
|
||||
}, []);
|
||||
|
||||
if (!usuarios) return <Loading type={2} />;
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Card>
|
||||
<CardContent>
|
||||
<div className="grid grid-cols-2">
|
||||
<div className="text-2xl font-semibold">
|
||||
Usuarios
|
||||
</div>
|
||||
<div className="text-right">
|
||||
<Button asChild>
|
||||
<Link href="/usuarios/formulario">
|
||||
+ Usuário
|
||||
</Link>
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead className="text-center">
|
||||
#
|
||||
</TableHead>
|
||||
<TableHead>
|
||||
Situação
|
||||
</TableHead>
|
||||
<TableHead>
|
||||
CPF
|
||||
</TableHead>
|
||||
<TableHead>
|
||||
Login / Sigla / Nome
|
||||
</TableHead>
|
||||
<TableHead>
|
||||
Função
|
||||
</TableHead>
|
||||
<TableHead></TableHead>
|
||||
<TableHead></TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{usuarios.map((usuario: Usuario) => (
|
||||
<TableRow key={usuario.usuario_id} className="cursor-pointer">
|
||||
<TableCell className="text-center">
|
||||
{usuario.usuario_id}
|
||||
</TableCell>
|
||||
<TableCell className="font-medium">
|
||||
{usuario.situacao}
|
||||
</TableCell>
|
||||
<TableCell className="font-medium">
|
||||
{usuario.cpf}
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<div className="font-semibold text-xs">
|
||||
{usuario.login} - {usuario.sigla}
|
||||
</div>
|
||||
<div className="text-base">
|
||||
{usuario.nome_completo}
|
||||
</div>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<div className="text-base">
|
||||
{usuario.funcao}
|
||||
</div>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<Button asChild>
|
||||
<Link href={`/usuarios/${usuario.usuario_id}/detalhes`}>
|
||||
Detalhes
|
||||
</Link>
|
||||
</Button>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
'use server'
|
||||
|
||||
import API from "@/services/api/Api";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
|
||||
export default async function GUsuarioDeleteData(usuarioId: number) {
|
||||
|
||||
const api = new API();
|
||||
|
||||
const response = await api.send({
|
||||
'method': Methods.DELETE,
|
||||
'endpoint': `administrativo/g_usuario/${usuarioId}`
|
||||
});
|
||||
|
||||
return response;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
'use server'
|
||||
|
||||
import API from "@/services/api/Api";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
|
||||
export default async function GUsuarioIndexData() {
|
||||
|
||||
const api = new API();
|
||||
|
||||
const response = await api.send({
|
||||
'method': Methods.GET,
|
||||
'endpoint': `administrativo/g_usuario/`
|
||||
});
|
||||
|
||||
return response;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
'use server'
|
||||
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
import API from "@/services/api/Api";
|
||||
|
||||
export default async function GUsuarioLoginData(form: any) {
|
||||
|
||||
const api = new API();
|
||||
|
||||
// Realiza o envio dos dados
|
||||
const response = await api.send({
|
||||
method: Methods.POST,
|
||||
endpoint: `administrativo/g_usuario/authenticate`,
|
||||
body: form
|
||||
});
|
||||
|
||||
return response;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
'use server'
|
||||
|
||||
import API from "@/services/api/Api";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
|
||||
export default async function GUsuarioReadData(usuarioId: number) {
|
||||
|
||||
const api = new API();
|
||||
|
||||
const response = await api.send({
|
||||
'method': Methods.GET,
|
||||
'endpoint': `administrativo/g_usuario/${usuarioId}`
|
||||
});
|
||||
|
||||
return response
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
'use server'
|
||||
|
||||
import API from "@/services/api/Api";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
|
||||
export default async function GUsuarioSaveData(form: any) {
|
||||
|
||||
const api = new API();
|
||||
|
||||
const response = await api.send({
|
||||
'method': Methods.POST,
|
||||
'endpoint': `administrativo/g_usuario/`,
|
||||
'body': form
|
||||
});
|
||||
|
||||
return response;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
'use client'
|
||||
|
||||
import { useState } from "react"
|
||||
import Usuario from "../../_interfaces/GUsuarioInterface"
|
||||
import GUsuarioIndex from "../../_services/g_usuario/GUsuarioIndex";
|
||||
import { useResponse } from "@/app/_response/ResponseContext";
|
||||
|
||||
export const useGUsuarioIndexHook = () => {
|
||||
|
||||
const { setResponse } = useResponse();
|
||||
|
||||
const [usuarios, setUsuarios] = useState<Usuario[] | null>(null);
|
||||
|
||||
const fetchUsuarios = async () => {
|
||||
|
||||
const response = await GUsuarioIndex();
|
||||
|
||||
setUsuarios(response.data);
|
||||
|
||||
// Define os dados do componente de resposta (toast, modal, etc)
|
||||
setResponse(response);
|
||||
|
||||
}
|
||||
|
||||
return { usuarios, fetchUsuarios }
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
'use client'
|
||||
|
||||
import GUsuarioLogoutService from "../../_services/g_usuario/GUsuarioLogoutService";
|
||||
|
||||
export const useGUsuarioLogoutHook = () => {
|
||||
|
||||
const logoutUsuario = async () => {
|
||||
|
||||
await GUsuarioLogoutService('access_token')
|
||||
|
||||
}
|
||||
|
||||
return { logoutUsuario }
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
'use client'
|
||||
|
||||
import { useState } from "react"
|
||||
import Usuario from "../../_interfaces/GUsuarioInterface"
|
||||
import GUsuarioRead from "../../_services/g_usuario/GUsuarioRead";
|
||||
import { useResponse } from "@/app/_response/ResponseContext";
|
||||
|
||||
export const useGUsuarioReadHooks = () => {
|
||||
|
||||
const { setResponse } = useResponse();
|
||||
|
||||
const [usuario, setUsuario] = useState<Usuario>();
|
||||
|
||||
const fetchUsuario = async (Usuario: Usuario) => {
|
||||
|
||||
const response = await GUsuarioRead(Usuario.usuario_id);
|
||||
console.log("hook",response.data)
|
||||
|
||||
setUsuario(response.data);
|
||||
|
||||
setResponse(response);
|
||||
|
||||
}
|
||||
|
||||
return { usuario, fetchUsuario }
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
'use client'
|
||||
|
||||
import { useState } from "react"
|
||||
import Usuario from "../../_interfaces/GUsuarioInterface"
|
||||
import GUsuarioSave from "../../_services/g_usuario/GUsuarioSave";
|
||||
import { useResponse } from "@/app/_response/ResponseContext";
|
||||
|
||||
export const useGUsuarioSaveHook = () => {
|
||||
|
||||
const { setResponse } = useResponse();
|
||||
|
||||
const [usuario, setUsuario] = useState<Usuario>();
|
||||
|
||||
const saveUsuario = async (Usuario: any) => {
|
||||
|
||||
const response = await GUsuarioSave(Usuario);
|
||||
|
||||
setUsuario(response.data);
|
||||
|
||||
setResponse(response);
|
||||
|
||||
}
|
||||
|
||||
return { usuario, saveUsuario }
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
export default interface GUsuario {
|
||||
usuario_id: number,
|
||||
trocarsenha: string,
|
||||
login: string,
|
||||
senha: string,
|
||||
situacao: string,
|
||||
nome_completo: string,
|
||||
funcao: string,
|
||||
assina: string,
|
||||
sigla: string,
|
||||
usuario_tab: string,
|
||||
ultimo_login: string,
|
||||
ultimo_login_regs: string,
|
||||
data_expiracao: string,
|
||||
senha_anterior: string,
|
||||
andamento_padrao: string,
|
||||
lembrete_pergunta: string,
|
||||
lembrete_resposta: string,
|
||||
andamento_padrao2: string,
|
||||
receber_mensagem_arrolamento: string,
|
||||
email: string,
|
||||
assina_certidao: string,
|
||||
receber_email_penhora: string,
|
||||
foto: string,
|
||||
nao_receber_chat_todos: string,
|
||||
pode_alterar_caixa: string,
|
||||
receber_chat_certidao_online: string,
|
||||
receber_chat_cancelamento: string,
|
||||
cpf: string,
|
||||
somente_leitura: string,
|
||||
receber_chat_envio_onr: string,
|
||||
tipo_usuario: string,
|
||||
senha_api: string,
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
import { z } from "zod";
|
||||
|
||||
export const GUsuarioSchema = z.object({
|
||||
trocarsenha: z.string().optional(),
|
||||
login: z.string().optional(),
|
||||
senha: z.string().optional(),
|
||||
situacao: z.string().optional(),
|
||||
nome_completo: z.string().optional(),
|
||||
funcao: z.string().optional(),
|
||||
assina: z.string().optional(),
|
||||
sigla: z.string().optional(),
|
||||
usuario_tab: z.string().optional(),
|
||||
ultimo_login: z.string().optional(),
|
||||
ultimo_login_regs: z.string().optional(),
|
||||
data_expiracao: z.string().optional(),
|
||||
senha_anterior: z.string().optional(),
|
||||
andamento_padrao: z.string().optional(),
|
||||
lembrete_pergunta: z.string().optional(),
|
||||
lembrete_resposta: z.string().optional(),
|
||||
andamento_padrao2: z.string().optional(),
|
||||
receber_mensagem_arrolamento: z.string().optional(),
|
||||
email: z.string().optional(),
|
||||
assina_certidao: z.string().optional(),
|
||||
receber_email_penhora: z.string().optional(),
|
||||
foto: z.string().optional(),
|
||||
nao_receber_chat_todos: z.string().optional(),
|
||||
pode_alterar_caixa: z.string().optional(),
|
||||
receber_chat_certidao_online: z.string().optional(),
|
||||
receber_chat_cancelamento: z.string().optional(),
|
||||
cpf: z.string().optional(),
|
||||
somente_leitura: z.string().optional(),
|
||||
receber_chat_envio_onr: z.string().optional(),
|
||||
tipo_usuario: z.string().optional(),
|
||||
senha_api: z.string().optional(),
|
||||
});
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
'use server'
|
||||
|
||||
import GUsuarioIndexData from "../../_data/g_usuario/GUsuarioIndexData"
|
||||
|
||||
export default async function GUsuarioIndex() {
|
||||
|
||||
const response = await GUsuarioIndexData();
|
||||
|
||||
return response;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
'use server'
|
||||
|
||||
import {
|
||||
cookies
|
||||
} from "next/headers";
|
||||
|
||||
import GUsuarioLoginData from "../../_data/g_usuario/GUsuarioLoginData"
|
||||
import { redirect } from "next/navigation";
|
||||
import { withClientErrorHandler } from "@/actions/withClientErrorHandler/withClientErrorHandler";
|
||||
|
||||
async function executeGUsuarioLoginService(form: any) {
|
||||
|
||||
// Obtem a resposta da requisição
|
||||
const response = await GUsuarioLoginData(form);
|
||||
|
||||
// Verifica se localizou o usuário
|
||||
if (response.data.usuario_id <= 0) {
|
||||
|
||||
return {
|
||||
'code': 404,
|
||||
'message': 'Não foi localizado o usuário'
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Importação do manipulador de cookies
|
||||
const cookieStore = await cookies();
|
||||
|
||||
// Cria um novo cookie
|
||||
cookieStore.set("access_token", response.data.token, {
|
||||
httpOnly: true,
|
||||
secure: process.env.NODE_ENV === "production",
|
||||
sameSite: "strict",
|
||||
path: "/",
|
||||
maxAge: 60 * 60 * 24,
|
||||
});
|
||||
|
||||
// Redireciona para a págian desejada
|
||||
redirect("/usuarios");
|
||||
|
||||
}
|
||||
|
||||
// Exporta função encapsulada
|
||||
export const GUsuarioLoginService = withClientErrorHandler(executeGUsuarioLoginService);
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
'use server'
|
||||
|
||||
import {
|
||||
cookies
|
||||
} from "next/headers";
|
||||
|
||||
import { redirect } from "next/navigation";
|
||||
|
||||
export default async function GUsuarioLogoutService(token: string) {
|
||||
|
||||
const cookieStore = await cookies();
|
||||
cookieStore.set(token, '', {
|
||||
expires: new Date(0),
|
||||
path: '/',
|
||||
});
|
||||
|
||||
redirect('/login');
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
'use server'
|
||||
|
||||
import GUsuarioReadData from "../../_data/g_usuario/GUsuarioReadData";
|
||||
|
||||
export default async function GUsuarioRead(usuarioId: number) {
|
||||
|
||||
// Verifica se o id informado é válido
|
||||
if (usuarioId <= 0) {
|
||||
return {
|
||||
'code': 400,
|
||||
'message': 'Usuário informado inválido',
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await GUsuarioReadData(usuarioId);
|
||||
console.log("service",response)
|
||||
return response
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
return error
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
'use server'
|
||||
|
||||
import GUsuarioSaveData from "../../_data/g_usuario/GUsuarioSaveData";
|
||||
|
||||
export default async function GUsuarioSave(form: any) {
|
||||
|
||||
return await GUsuarioSaveData(form);
|
||||
|
||||
}
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
import TTBAndamentoServicoIndex from '@/packages/administrativo/components/TTBAndamentoServico/TTBAndamentoServicoIndex';
|
||||
|
||||
export default function TAtoParteTipo() {
|
||||
return <TTBAndamentoServicoIndex />;
|
||||
}
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
import TAtoParteTipoIndex from '@/packages/administrativo/components/TAtoParteTipo/TAtoParteTipoIndex';
|
||||
|
||||
export default function TAtoParteTipo() {
|
||||
return <TAtoParteTipoIndex />;
|
||||
}
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
'use client';
|
||||
|
||||
import GTBBairroIndex from '@/packages/administrativo/components/GTBBairro/GTBBairroIndex';
|
||||
|
||||
export default function GCidadePage() {
|
||||
return <GTBBairroIndex />;
|
||||
}
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
'use client';
|
||||
|
||||
import GCartorioIndex from '@/packages/administrativo/components/GCartorio/GCartorioIndex';
|
||||
|
||||
export default function GCartorioPage() {
|
||||
return <GCartorioIndex />;
|
||||
}
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
'use client';
|
||||
|
||||
import TCensecTipoNaturezaIndex from '@/packages/administrativo/components/TCensecTipoNatureza/TCensecTipoNaturezaIndex';
|
||||
|
||||
export default function TCensecTipoNaturezaPage() {
|
||||
return <TCensecTipoNaturezaIndex />;
|
||||
}
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
export default function TCensecPage() {
|
||||
return <div></div>;
|
||||
}
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
'use client';
|
||||
|
||||
import TCensecQualidadeIndex from '@/packages/administrativo/components/TCensecQualidade/TCensecQualidadeIndex';
|
||||
|
||||
export default function TCensecQualidadePage() {
|
||||
return <TCensecQualidadeIndex />;
|
||||
}
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
'use client';
|
||||
|
||||
import TCensecIndex from '@/packages/administrativo/components/TCensec/TCensecIndex';
|
||||
|
||||
export default function GTBEstadoCivilPage() {
|
||||
return <TCensecIndex />;
|
||||
}
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
'use client';
|
||||
|
||||
import TCensecNaturezaLitigioIndex from '@/packages/administrativo/components/TCensecNaturezaLitigio/TCensecNaturezaLitigioIndex';
|
||||
|
||||
export default function GCidadePage() {
|
||||
return <TCensecNaturezaLitigioIndex />;
|
||||
}
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
'use client';
|
||||
|
||||
import TCensecQualidadeIndex from '@/packages/administrativo/components/TCensecQualidade/TCensecQualidadeIndex';
|
||||
|
||||
export default function GTBEstadoCivilPage() {
|
||||
return <TCensecQualidadeIndex />;
|
||||
}
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
'use client';
|
||||
|
||||
import TCensecTipoAtoIndex from '@/packages/administrativo/components/TCensecTipoAto/TCensecTipoAtoIndex';
|
||||
|
||||
export default function GTBEstadoCivilPage() {
|
||||
return <TCensecTipoAtoIndex />;
|
||||
}
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
'use client';
|
||||
|
||||
import GCidadeIndex from '@/packages/administrativo/components/GCidade/GCidadeIndex';
|
||||
|
||||
export default function GCidadePage() {
|
||||
return <GCidadeIndex />;
|
||||
}
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
import GCalculoIndex from '@/packages/administrativo/components/GCalculo/GCalculoIndex';
|
||||
|
||||
export default function GEmolumentoPeriodoPage() {
|
||||
return <GCalculoIndex />;
|
||||
}
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
'use client';
|
||||
|
||||
import { useParams } from 'next/navigation';
|
||||
|
||||
import GEmolumentoItemIndex from '@/packages/administrativo/components/GEmolumentoItem/GEmolumentoItemIndex';
|
||||
|
||||
export default function GGramaticaPage() {
|
||||
const params = useParams();
|
||||
|
||||
return (
|
||||
<GEmolumentoItemIndex
|
||||
emolumento_id={Number(params.emolumentoId)}
|
||||
emolumento_periodo_id={Number(params.emolumentoPeriodoId)}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
import GEmolumentoIndex from '@/packages/administrativo/components/GEmolumento/GEmolumentoIndex';
|
||||
|
||||
export default function GEmolumentoPeriodoPage() {
|
||||
return <GEmolumentoIndex />;
|
||||
}
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
import GEmolumentoPeriodoIndex from '@/packages/administrativo/components/GEmolumentoPeriodo/GEmolumentoPeriodoIndex';
|
||||
|
||||
export default function GEmolumentoPeriodoPage() {
|
||||
return <GEmolumentoPeriodoIndex />;
|
||||
}
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
import GGramaticaIndex from '@/packages/administrativo/components/GGramatica/GGramaticaIndex';
|
||||
|
||||
export default function GGramaticaPage() {
|
||||
return <GGramaticaIndex />;
|
||||
}
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
'use client';
|
||||
|
||||
import TImovelDashboard from '@/packages/administrativo/components/TImovel/TImovelDashboard';
|
||||
|
||||
export default function TImovelDashboardPage() {
|
||||
return <TImovelDashboard />;
|
||||
}
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
'use client';
|
||||
|
||||
import TImovelIndex from '@/packages/administrativo/components/TImovel/TImovelIndex';
|
||||
|
||||
export default function TImovelRuralPage() {
|
||||
return (
|
||||
<TImovelIndex
|
||||
pageTitle="Imóveis Rurais"
|
||||
pageDescription="Gerenciamento de imóveis rurais"
|
||||
tipoClasse={3}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
'use client';
|
||||
|
||||
import GTBTipoLogradouroIndex from '@/packages/administrativo/components/GTBTipoLogradouro/GTBTipoLogradouroIndex';
|
||||
|
||||
export default function GMedidaTipoPage() {
|
||||
return <GTBTipoLogradouroIndex />;
|
||||
}
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
'use client';
|
||||
|
||||
import TImovelIndex from '@/packages/administrativo/components/TImovel/TImovelIndex';
|
||||
|
||||
export default function TImovelUrbanoPage() {
|
||||
return (
|
||||
<TImovelIndex
|
||||
pageTitle="Imóveis Urbanos"
|
||||
pageDescription="Gerenciamento de imóveis urbanos"
|
||||
tipoClasse={1}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
'use client';
|
||||
|
||||
import GMedidaTipoIndex from '@/packages/administrativo/components/GMedidaTipo/GMedidaTipoIndex';
|
||||
|
||||
export default function GMedidaTipoPage() {
|
||||
return <GMedidaTipoIndex />;
|
||||
}
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
import GNaturezaIndex from '@/packages/administrativo/components/GNatureza/GNaturezaIndex';
|
||||
|
||||
export default function GNaturezaPage() {
|
||||
return <GNaturezaIndex sistema_id={2} />;
|
||||
}
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
'use client';
|
||||
|
||||
import TPessoaDashboard from '@/packages/administrativo/components/TPessoa/TPessoaDashboard';
|
||||
|
||||
export default function TPessoaDashboardPage() {
|
||||
return <TPessoaDashboard />;
|
||||
}
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
'use client';
|
||||
|
||||
import GTBEstadoCivilIndex from '@/packages/administrativo/components/GTBEstadoCivil/GTBEstadoCivilIndex';
|
||||
|
||||
export default function GTBEstadoCivilPage() {
|
||||
return <GTBEstadoCivilIndex />;
|
||||
}
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
'use client';
|
||||
|
||||
import TPessoaFisicaIndex from '@/packages/administrativo/components/TPessoa/TPessoaFisica/TPessoaFisicaIndex';
|
||||
|
||||
export default function TPessoaFisica() {
|
||||
return <TPessoaFisicaIndex />;
|
||||
}
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
'use client';
|
||||
|
||||
import TPessoaJuridicaIndex from '@/packages/administrativo/components/TPessoa/TPessoaJuridica/TPessoaJuridicaIndex';
|
||||
|
||||
export default function TPessoaFisica() {
|
||||
return <TPessoaJuridicaIndex />;
|
||||
}
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
'use client';
|
||||
|
||||
import GTBProfissaoIndex from '@/packages/administrativo/components/GTBProfissao/GTBProfissaoIndex';
|
||||
|
||||
export default function GTBEstadoCivilPage() {
|
||||
return <GTBProfissaoIndex />;
|
||||
}
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
'use client';
|
||||
|
||||
import GTBRegimeBensIndex from '@/packages/administrativo/components/GTBRegimeBens/GTBRegimeBensIndex';
|
||||
|
||||
export default function GTBRegimeBensPage() {
|
||||
return <GTBRegimeBensIndex />;
|
||||
}
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
'use client';
|
||||
|
||||
import GTBRegimeComunhaoIndex from '@/packages/administrativo/components/GTBRegimeComunhao/GTBRegimeComunhaoIndex';
|
||||
|
||||
export default function GTBRegimeBensPage() {
|
||||
return <GTBRegimeComunhaoIndex />;
|
||||
}
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
import TTBReconhecimentoTipoIndex from '@/packages/administrativo/components/TTBReconhecimentoTipo/TTBReconhecimentoTipoIndex';
|
||||
|
||||
export default function TAtoParteTipo() {
|
||||
return <TTBReconhecimentoTipoIndex />;
|
||||
}
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
import GSeloGrupoIndex from '@/packages/administrativo/components/GSeloGrupo/GSeloGrupoIndex';
|
||||
|
||||
export default function GSeloGrupoPage() {
|
||||
return <GSeloGrupoIndex />;
|
||||
}
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
import TServicoTipoIndex from '@/packages/administrativo/components/TServicoTipo/TServicoTipoIndex';
|
||||
|
||||
export default function TServicoTipoPage() {
|
||||
return <TServicoTipoIndex />;
|
||||
}
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
import GNaturezaTituloIndex from '@/packages/administrativo/components/GNaturezaTitulo/GNaturezaTituloIndex';
|
||||
|
||||
export default function GNaturezaPage() {
|
||||
return <GNaturezaTituloIndex sistema_id={2} />;
|
||||
}
|
||||
|
|
@ -0,0 +1,128 @@
|
|||
'use client';
|
||||
|
||||
import { useEffect, useState, useCallback } from "react";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDialog";
|
||||
|
||||
import Header from "@/app/_components/structure/Header";
|
||||
import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog";
|
||||
import Loading from "@/app/_components/loading/loading";
|
||||
import GMedidaTipoTable from "../../_components/g_medidatipo/GMedidaTipoTable";
|
||||
import GMedidaTipoForm from "../../_components/g_medidatipo/GMedidaTipoForm";
|
||||
|
||||
import { useGMedidaTipoReadHook } from "../../_hooks/g_medidatipo/useGMedidaTipoReadHook";
|
||||
import { useGMedidaTipoSaveHook } from "../../_hooks/g_medidatipo/useGMedidaTipoSaveHook";
|
||||
import { useGMedidaTipoRemoveHook } from "../../_hooks/g_medidatipo/useGMedidaTipoRemoveHook";
|
||||
|
||||
import { GMedidaTipoInterface } from "../../_interfaces/GMedidaTipoInterface";
|
||||
|
||||
const initialMedidaTipo: GMedidaTipoInterface = {
|
||||
medida_tipo_id: 0,
|
||||
sigla: '',
|
||||
descricao: ''
|
||||
}
|
||||
|
||||
export default function GMedidaTipoPage() {
|
||||
|
||||
// Hooks para leitura, salvamento e remoção
|
||||
const { gMedidaTipo, fetchGMedidaTipo } = useGMedidaTipoReadHook();
|
||||
const { saveGMedidaTipo } = useGMedidaTipoSaveHook();
|
||||
const { removeGMedidaTipo } = useGMedidaTipoRemoveHook();
|
||||
|
||||
// Estado para controlar o formulário e o item selecionado
|
||||
const [selectedMedidaTipo, setSelectedMedidaTipo] = useState<GMedidaTipoInterface | null>(null);
|
||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||
const [itemToDelete, setItemToDelete] = useState<GMedidaTipoInterface | null>(null);
|
||||
|
||||
// Hook para o modal de confirmação
|
||||
const {
|
||||
isOpen: isConfirmOpen,
|
||||
openDialog: openConfirmDialog,
|
||||
handleConfirm,
|
||||
handleCancel,
|
||||
} = useConfirmDialog();
|
||||
|
||||
// Ações do formulário
|
||||
const handleOpenForm = useCallback((data: GMedidaTipoInterface | null) => {
|
||||
setSelectedMedidaTipo(data);
|
||||
setIsFormOpen(true);
|
||||
}, []);
|
||||
|
||||
const handleCloseForm = useCallback(() => {
|
||||
setIsFormOpen(false);
|
||||
setSelectedMedidaTipo(null);
|
||||
}, []);
|
||||
|
||||
const handleSave = useCallback(async (data: GMedidaTipoInterface) => {
|
||||
await saveGMedidaTipo(data);
|
||||
await fetchGMedidaTipo(); // Atualiza a tabela após salvar
|
||||
handleCloseForm();
|
||||
}, [saveGMedidaTipo, fetchGMedidaTipo]);
|
||||
|
||||
// Ações de deleção
|
||||
const handleConfirmDelete = useCallback((item: GMedidaTipoInterface) => {
|
||||
setItemToDelete(item);
|
||||
openConfirmDialog();
|
||||
}, [openConfirmDialog]);
|
||||
|
||||
const handleDelete = useCallback(async () => {
|
||||
if (itemToDelete) {
|
||||
await removeGMedidaTipo(itemToDelete);
|
||||
await fetchGMedidaTipo(); // Atualiza a tabela após remover
|
||||
}
|
||||
handleCancel();
|
||||
}, [itemToDelete, fetchGMedidaTipo, handleCancel]);
|
||||
|
||||
// Efeito para carregar os dados na montagem do componente
|
||||
useEffect(() => {
|
||||
fetchGMedidaTipo();
|
||||
}, []);
|
||||
|
||||
// Mostra tela de loading enquanto os dados não são carregados
|
||||
if (!gMedidaTipo) {
|
||||
return <Loading type={2} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
{/* Cabeçalho */}
|
||||
<Header
|
||||
title={"Tipos de Medida"}
|
||||
description={"Gerenciamento de tipos de medida"}
|
||||
buttonText={"Novo Tipo de Medida"}
|
||||
buttonAction={(data) => { handleOpenForm(data = initialMedidaTipo) }}
|
||||
/>
|
||||
|
||||
{/* Tabela de Tipos de Medida */}
|
||||
<Card>
|
||||
<CardContent>
|
||||
<GMedidaTipoTable
|
||||
data={gMedidaTipo}
|
||||
onEdit={handleOpenForm}
|
||||
onDelete={handleConfirmDelete}
|
||||
/>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Modal de confirmação */}
|
||||
<ConfirmDialog
|
||||
isOpen={isConfirmOpen}
|
||||
title="Confirmar exclusão"
|
||||
description="Atenção"
|
||||
message={`Deseja realmente excluir o tipo de medida "${itemToDelete?.descricao}"?`}
|
||||
confirmText="Sim, excluir"
|
||||
cancelText="Cancelar"
|
||||
onConfirm={handleDelete}
|
||||
onCancel={handleCancel}
|
||||
/>
|
||||
|
||||
{/* Formulário de criação/edição */}
|
||||
<GMedidaTipoForm
|
||||
isOpen={isFormOpen}
|
||||
data={selectedMedidaTipo}
|
||||
onClose={handleCloseForm}
|
||||
onSave={handleSave}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,167 @@
|
|||
'use client';
|
||||
|
||||
import { useEffect, useState, useCallback } from "react";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDialog";
|
||||
import { useResponse } from "@/app/_response/ResponseContext"
|
||||
|
||||
import Header from "@/app/_components/structure/Header";
|
||||
import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog";
|
||||
import Loading from "@/app/_components/loading/loading";
|
||||
import GTBBairroTable from "../../_components/g_tb_bairro/GTBBairroTable";
|
||||
import GTBBairroForm from "../../_components/g_tb_bairro/GTBBairroForm";
|
||||
|
||||
import { useGTBBairroReadHook } from "../../_hooks/g_tb_bairro/useGTBBairroReadHook";
|
||||
import { useGTBBairroSaveHook } from "../../_hooks/g_tb_bairro/useGTBBairroSaveHook";
|
||||
import { useGTBBairroRemoveHook } from "../../_hooks/g_tb_bairro/useGTBBairroRemoveHook";
|
||||
|
||||
import { GTBBairroInterface } from "../../_interfaces/GTBBairroInterface";
|
||||
import { SituacoesEnum } from "@/enums/SituacoesEnum";
|
||||
|
||||
const initialBairro: GTBBairroInterface = {
|
||||
sistema_id: null,
|
||||
tb_bairro_id: 0,
|
||||
descricao: '',
|
||||
situacao: SituacoesEnum.A
|
||||
}
|
||||
|
||||
export default function GTBBairroPage() {
|
||||
|
||||
// Controle de exibição de respostas
|
||||
const { setResponse } = useResponse();
|
||||
|
||||
// Controle de estado do botão
|
||||
const [buttonIsLoading, setButtonIsLoading] = useState(false);
|
||||
|
||||
// Hooks para leitura e salvamento
|
||||
const { gTBBairro, fetchGTBBairro } = useGTBBairroReadHook();
|
||||
const { saveGTBBairro } = useGTBBairroSaveHook();
|
||||
const { removeGTBBairro } = useGTBBairroRemoveHook();
|
||||
|
||||
// Estado para controlar o formulário e item selecionado
|
||||
const [selectedBairro, setBairro] = useState<GTBBairroInterface | null>(null);
|
||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||
const [itemToDelete, setItemToDelete] = useState<GTBBairroInterface | null>(null);
|
||||
|
||||
// Hook para o modal de confirmação
|
||||
const {
|
||||
isOpen: isConfirmOpen,
|
||||
openDialog: openConfirmDialog,
|
||||
handleCancel,
|
||||
} = useConfirmDialog();
|
||||
|
||||
// Ações do formulário
|
||||
const handleOpenForm = useCallback((data: GTBBairroInterface | null) => {
|
||||
setBairro(data);
|
||||
setIsFormOpen(true);
|
||||
}, []);
|
||||
|
||||
const handleCloseForm = useCallback(() => {
|
||||
setBairro(null);
|
||||
setIsFormOpen(false);
|
||||
}, []);
|
||||
|
||||
const handleSave = useCallback(async (data: GTBBairroInterface) => {
|
||||
|
||||
// Coloca o botão em estado de loading
|
||||
setButtonIsLoading(true);
|
||||
|
||||
// Realiza o procedimento desejado
|
||||
await saveGTBBairro(data);
|
||||
|
||||
// Remove o botão do estado de loading
|
||||
setButtonIsLoading(false);
|
||||
|
||||
// Atualiza a tabela após salvar
|
||||
fetchGTBBairro();
|
||||
|
||||
}, [saveGTBBairro, fetchGTBBairro]);
|
||||
|
||||
// Ações de deleção
|
||||
const handleConfirmDelete = useCallback((item: GTBBairroInterface) => {
|
||||
setItemToDelete(item);
|
||||
openConfirmDialog();
|
||||
}, [openConfirmDialog]);
|
||||
|
||||
const handleDelete = useCallback(async () => {
|
||||
|
||||
// Verifica se existe item para remoção
|
||||
if (!itemToDelete) {
|
||||
|
||||
// Define os dados da resposta visual
|
||||
setResponse({
|
||||
status: 400,
|
||||
message: 'Não foi informado um registro para exclusão'
|
||||
});
|
||||
return;
|
||||
};
|
||||
|
||||
// Executa o hook de remoção
|
||||
await removeGTBBairro(itemToDelete);
|
||||
|
||||
// Atualiza a tabela após remover
|
||||
await fetchGTBBairro();
|
||||
|
||||
// Limpa o item para remoção
|
||||
setItemToDelete(null)
|
||||
|
||||
handleCancel();
|
||||
|
||||
}, [itemToDelete, fetchGTBBairro, handleCancel]);
|
||||
|
||||
// Efeito para carregar os dados na montagem do componente
|
||||
useEffect(() => {
|
||||
fetchGTBBairro();
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Tela de loading enquanto carrega os dados
|
||||
*/
|
||||
if (gTBBairro.length == 0) {
|
||||
return <Loading type={2} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
{/* Cabeçalho */}
|
||||
<Header
|
||||
title={"Bairros"}
|
||||
description={"Gerenciamento de Bairros"}
|
||||
buttonText={"Novo Bairro"}
|
||||
buttonAction={(data) => { handleOpenForm(data = initialBairro) }}
|
||||
/>
|
||||
|
||||
{/* Tabela de Bairros */}
|
||||
<Card>
|
||||
<CardContent>
|
||||
<GTBBairroTable
|
||||
data={gTBBairro}
|
||||
onEdit={handleOpenForm}
|
||||
onDelete={handleConfirmDelete}
|
||||
/>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Modal de confirmação */}
|
||||
<ConfirmDialog
|
||||
isOpen={isConfirmOpen}
|
||||
title="Confirmar exclusão"
|
||||
description="Atenção"
|
||||
message={`Deseja realmente excluir o bairro "${itemToDelete?.descricao}"?`}
|
||||
confirmText="Sim, excluir"
|
||||
cancelText="Cancelar"
|
||||
onConfirm={handleDelete}
|
||||
onCancel={handleCancel}
|
||||
/>
|
||||
|
||||
{/* Formulário de criação/edição */}
|
||||
<GTBBairroForm
|
||||
isOpen={isFormOpen}
|
||||
data={selectedBairro}
|
||||
onClose={handleCloseForm}
|
||||
onSave={handleSave}
|
||||
buttonIsLoading={buttonIsLoading}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,129 @@
|
|||
'use client';
|
||||
|
||||
import { useEffect, useState, useCallback } from "react";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDialog";
|
||||
|
||||
import Header from "@/app/_components/structure/Header";
|
||||
import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog";
|
||||
import Loading from "@/app/_components/loading/loading";
|
||||
import GTBEstadoCivilTable from "../../_components/g_tb_estadocivil/GTBEstadoCivilTable";
|
||||
import GTBEstadoCivilForm from "../../_components/g_tb_estadocivil/GTBEstadoCivilForm";
|
||||
|
||||
import { useGTBEstadoCivilReadHook } from "../../_hooks/g_tb_estadocivil/useGTBEstadoCivilReadHook";
|
||||
import { useGTBEstadoCivilSaveHook } from "../../_hooks/g_tb_estadocivil/useGTBEstadoCivilSaveHook";
|
||||
import { useGTBEstadoCivilRemoveHook } from "../../_hooks/g_tb_estadocivil/useGTBEstadoCivilRemoveHook";
|
||||
|
||||
import { GTBEstadoCivilInterface } from "../../_interfaces/GTBEstadoCivilInterface";
|
||||
|
||||
const initalEstadoCivil: GTBEstadoCivilInterface = {
|
||||
tb_estadocivil_id: 0,
|
||||
sistema_id: 0,
|
||||
descricao: '',
|
||||
situacao: 'A',
|
||||
}
|
||||
|
||||
export default function TBEstadoCivilPage() {
|
||||
|
||||
// Hooks para leitura e salvamento
|
||||
const { gTBEstadoCivil, fetchGTBEstadoCivil } = useGTBEstadoCivilReadHook();
|
||||
const { saveGTBEstadoCivil } = useGTBEstadoCivilSaveHook();
|
||||
const { removeGTBEstadoCivil } = useGTBEstadoCivilRemoveHook();
|
||||
|
||||
// Estado para controlar o formulário e item selecionado
|
||||
const [selectedEstadoCivil, setSelectedEstadoCivil] = useState<GTBEstadoCivilInterface | null>(null);
|
||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||
const [itemToDelete, setItemToDelete] = useState<GTBEstadoCivilInterface | null>(null);
|
||||
|
||||
// Hook para o modal de confirmação
|
||||
const {
|
||||
isOpen: isConfirmOpen,
|
||||
openDialog: openConfirmDialog,
|
||||
handleConfirm,
|
||||
handleCancel,
|
||||
} = useConfirmDialog();
|
||||
|
||||
// Ações do formulário
|
||||
const handleOpenForm = useCallback((data: GTBEstadoCivilInterface | null) => {
|
||||
setSelectedEstadoCivil(data);
|
||||
setIsFormOpen(true);
|
||||
}, []);
|
||||
|
||||
const handleCloseForm = useCallback(() => {
|
||||
setIsFormOpen(false);
|
||||
setSelectedEstadoCivil(null);
|
||||
}, []);
|
||||
|
||||
const handleSave = useCallback(async (data: GTBEstadoCivilInterface) => {
|
||||
await saveGTBEstadoCivil(data);
|
||||
await fetchGTBEstadoCivil(); // Atualiza a tabela após salvar
|
||||
handleCloseForm();
|
||||
}, [saveGTBEstadoCivil, fetchGTBEstadoCivil]);
|
||||
|
||||
// Ações de deleção
|
||||
const handleConfirmDelete = useCallback((item: GTBEstadoCivilInterface) => {
|
||||
setItemToDelete(item);
|
||||
openConfirmDialog();
|
||||
}, [openConfirmDialog]);
|
||||
|
||||
const handleDelete = useCallback(async () => {
|
||||
if (itemToDelete) {
|
||||
await removeGTBEstadoCivil(itemToDelete);
|
||||
await fetchGTBEstadoCivil(); // Atualiza a tabela após remover
|
||||
}
|
||||
handleCancel();
|
||||
}, [itemToDelete, fetchGTBEstadoCivil, handleCancel]);
|
||||
|
||||
// Efeito para carregar os dados na montagem do componente
|
||||
useEffect(() => {
|
||||
fetchGTBEstadoCivil();
|
||||
}, []);
|
||||
|
||||
// Mostra tela de loading enquanto os dados não são carregados
|
||||
if (!gTBEstadoCivil) {
|
||||
return <Loading type={2} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
{/* Cabeçalho */}
|
||||
<Header
|
||||
title={"Estados Civis"}
|
||||
description={"Gerenciamento de Estados Civis"}
|
||||
buttonText={"Novo Estado Civil"}
|
||||
buttonAction={(data) => { handleOpenForm(data = initalEstadoCivil) }}
|
||||
/>
|
||||
|
||||
{/* Tabela de Estados Civis */}
|
||||
<Card>
|
||||
<CardContent>
|
||||
<GTBEstadoCivilTable
|
||||
data={gTBEstadoCivil}
|
||||
onEdit={handleOpenForm}
|
||||
onDelete={handleConfirmDelete}
|
||||
/>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Modal de confirmação */}
|
||||
<ConfirmDialog
|
||||
isOpen={isConfirmOpen}
|
||||
title="Confirmar exclusão"
|
||||
description="Atenção"
|
||||
message={`Deseja realmente excluir o estado civil "${itemToDelete?.descricao}"?`}
|
||||
confirmText="Sim, excluir"
|
||||
cancelText="Cancelar"
|
||||
onConfirm={handleDelete}
|
||||
onCancel={handleCancel}
|
||||
/>
|
||||
|
||||
{/* Formulário de criação/edição */}
|
||||
<GTBEstadoCivilForm
|
||||
isOpen={isFormOpen}
|
||||
data={selectedEstadoCivil}
|
||||
onClose={handleCloseForm}
|
||||
onSave={handleSave}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,163 @@
|
|||
'use client';
|
||||
|
||||
import { useEffect, useState, useCallback } from "react";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
|
||||
import Loading from "@/app/_components/loading/loading";
|
||||
import GTBProfissaoTable from "../../_components/g_tb_profissao/GTBProfissaoTable";
|
||||
import GTBProfissaoForm from "../../_components/g_tb_profissao/GTBProfissaoForm";
|
||||
|
||||
import { useGTBProfissaoReadHook } from "../../_hooks/g_tb_profissao/useGTBProfissaoReadHook";
|
||||
import { useGTBProfissaoSaveHook } from "../../_hooks/g_tb_profissao/useGTBProfissaoSaveHook";
|
||||
import { useGTBProfissaoRemoveHook } from "../../_hooks/g_tb_profissao/useGTBProfissaoRemoveHook";
|
||||
|
||||
import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog";
|
||||
import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDialog";
|
||||
|
||||
import GTBProfissaoInterface from "../../_interfaces/GTBProfissaoInterface";
|
||||
import Header from "@/app/_components/structure/Header";
|
||||
|
||||
export default function TTBAndamentoServico() {
|
||||
// Hooks para leitura e salvamento
|
||||
const { gTBProfissao, fetchGTBProfissao } = useGTBProfissaoReadHook();
|
||||
const { saveGTBProfissao } = useGTBProfissaoSaveHook();
|
||||
const { removeGTBProfissao } = useGTBProfissaoRemoveHook();
|
||||
|
||||
// Estados
|
||||
const [selectedAndamento, setSelectedAndamento] = useState<GTBProfissaoInterface | null>(null);
|
||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||
|
||||
// Estado para saber qual item será deletado
|
||||
const [itemToDelete, setItemToDelete] = useState<GTBProfissaoInterface | null>(null);
|
||||
|
||||
/**
|
||||
* Hook do modal de confirmação
|
||||
*/
|
||||
const {
|
||||
isOpen: isConfirmOpen,
|
||||
openDialog: openConfirmDialog,
|
||||
handleConfirm,
|
||||
handleCancel,
|
||||
} = useConfirmDialog();
|
||||
|
||||
/**
|
||||
* Abre o formulário no modo de edição ou criação
|
||||
*/
|
||||
const handleOpenForm = useCallback((data: GTBProfissaoInterface | null) => {
|
||||
setSelectedAndamento(data);
|
||||
setIsFormOpen(true);
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Fecha o formulário e limpa o andamento selecionado
|
||||
*/
|
||||
const handleCloseForm = useCallback(() => {
|
||||
setSelectedAndamento(null);
|
||||
setIsFormOpen(false);
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Salva os dados do formulário
|
||||
*/
|
||||
const handleSave = useCallback(async (formData: GTBProfissaoInterface) => {
|
||||
|
||||
// Aguarda salvar o registro
|
||||
await saveGTBProfissao(formData);
|
||||
|
||||
// Atualiza a lista de dados
|
||||
fetchGTBProfissao();
|
||||
|
||||
}, [saveGTBProfissao, fetchGTBProfissao, handleCloseForm]);
|
||||
|
||||
/**
|
||||
* Quando o usuário clica em "remover" na tabela
|
||||
*/
|
||||
const handleConfirmDelete = useCallback((item: GTBProfissaoInterface) => {
|
||||
|
||||
// Define o item atual para remoção
|
||||
setItemToDelete(item);
|
||||
|
||||
// Abre o modal de confirmação
|
||||
openConfirmDialog();
|
||||
|
||||
}, [openConfirmDialog]);
|
||||
|
||||
/**
|
||||
* Executa a exclusão de fato quando o usuário confirma
|
||||
*/
|
||||
const handleDelete = useCallback(async () => {
|
||||
|
||||
// Protege contra null
|
||||
if (!itemToDelete) return;
|
||||
|
||||
// Executa o Hook de remoção
|
||||
await removeGTBProfissao(itemToDelete);
|
||||
|
||||
// Atualiza a lista
|
||||
await fetchGTBProfissao();
|
||||
|
||||
// Limpa o item selecionado
|
||||
setItemToDelete(null);
|
||||
|
||||
// Fecha o modal
|
||||
handleCancel();
|
||||
|
||||
}, [itemToDelete, fetchGTBProfissao, handleCancel]);
|
||||
|
||||
/**
|
||||
* Busca inicial dos dados
|
||||
*/
|
||||
useEffect(() => {
|
||||
fetchGTBProfissao();
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Tela de loading enquanto carrega os dados
|
||||
*/
|
||||
if (!gTBProfissao) {
|
||||
return <Loading type={2} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
{/* Cabeçalho */}
|
||||
<Header
|
||||
title={"Profissões"}
|
||||
description={"Gerenciamento de Profissões"}
|
||||
buttonText={"Nova Profissão"}
|
||||
buttonAction={() => { handleOpenForm(null) }}
|
||||
/>
|
||||
|
||||
{/* Tabela de andamentos */}
|
||||
<Card>
|
||||
<CardContent>
|
||||
<GTBProfissaoTable
|
||||
data={gTBProfissao}
|
||||
onEdit={handleOpenForm}
|
||||
onDelete={handleConfirmDelete}
|
||||
/>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Modal de confirmação */}
|
||||
<ConfirmDialog
|
||||
isOpen={isConfirmOpen}
|
||||
title="Confirmar exclusão"
|
||||
description="Atenção"
|
||||
message={`Deseja realmente excluir o andamento "${itemToDelete?.descricao}"?`}
|
||||
confirmText="Sim, excluir"
|
||||
cancelText="Cancelar"
|
||||
onConfirm={handleDelete}
|
||||
onCancel={handleCancel}
|
||||
/>
|
||||
|
||||
{/* Formulário de criação/edição */}
|
||||
<GTBProfissaoForm
|
||||
isOpen={isFormOpen}
|
||||
data={selectedAndamento}
|
||||
onClose={handleCloseForm}
|
||||
onSave={handleSave}
|
||||
/>
|
||||
</div>
|
||||
); 4
|
||||
}
|
||||
|
|
@ -0,0 +1,163 @@
|
|||
'use client';
|
||||
|
||||
import { useEffect, useState, useCallback } from "react";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
|
||||
import Loading from "@/app/_components/loading/loading";
|
||||
import GTBRegimeBensTable from "../../_components/g_tb_regimebens/GTBRegimeBensTable";
|
||||
import GTBRegimeBensForm from "../../_components/g_tb_regimebens/GTBRegimeBensForm";
|
||||
|
||||
import { useGTBRegimeBensReadHook } from "../../_hooks/g_tb_regimebens/useGTBRegimeBensReadHook";
|
||||
import { useGTBRegimeBensSaveHook } from "../../_hooks/g_tb_regimebens/useGTBRegimeBensSaveHook";
|
||||
import { useGTBRegimeBensRemoveHook } from "../../_hooks/g_tb_regimebens/useGTBRegimeBensRemoveHook";
|
||||
|
||||
import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog";
|
||||
import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDialog";
|
||||
|
||||
import GTBRegimeBensInterface from "../../_interfaces/GTBRegimeBensInterface";
|
||||
import Header from "@/app/_components/structure/Header";
|
||||
|
||||
export default function TTBAndamentoServico() {
|
||||
// Hooks para leitura e salvamento
|
||||
const { gTBRegimeBens, fetchGTBRegimeBens } = useGTBRegimeBensReadHook();
|
||||
const { saveGTBRegimeComunhao } = useGTBRegimeBensSaveHook();
|
||||
const { removeGTBRegimeComunhao } = useGTBRegimeBensRemoveHook();
|
||||
|
||||
// Estados
|
||||
const [selectedAndamento, setSelectedAndamento] = useState<GTBRegimeBensInterface | null>(null);
|
||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||
|
||||
// Estado para saber qual item será deletado
|
||||
const [itemToDelete, setItemToDelete] = useState<GTBRegimeBensInterface | null>(null);
|
||||
|
||||
/**
|
||||
* Hook do modal de confirmação
|
||||
*/
|
||||
const {
|
||||
isOpen: isConfirmOpen,
|
||||
openDialog: openConfirmDialog,
|
||||
handleConfirm,
|
||||
handleCancel,
|
||||
} = useConfirmDialog();
|
||||
|
||||
/**
|
||||
* Abre o formulário no modo de edição ou criação
|
||||
*/
|
||||
const handleOpenForm = useCallback((data: GTBRegimeBensInterface | null) => {
|
||||
setSelectedAndamento(data);
|
||||
setIsFormOpen(true);
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Fecha o formulário e limpa o andamento selecionado
|
||||
*/
|
||||
const handleCloseForm = useCallback(() => {
|
||||
setSelectedAndamento(null);
|
||||
setIsFormOpen(false);
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Salva os dados do formulário
|
||||
*/
|
||||
const handleSave = useCallback(async (formData: GTBRegimeBensInterface) => {
|
||||
|
||||
// Aguarda salvar o registro
|
||||
await saveGTBRegimeComunhao(formData);
|
||||
|
||||
// Atualiza a lista de dados
|
||||
fetchGTBRegimeBens();
|
||||
|
||||
}, [saveGTBRegimeComunhao, fetchGTBRegimeBens]);
|
||||
|
||||
/**
|
||||
* Quando o usuário clica em "remover" na tabela
|
||||
*/
|
||||
const handleConfirmDelete = useCallback((item: GTBRegimeBensInterface) => {
|
||||
|
||||
// Define o item atual para remoção
|
||||
setItemToDelete(item);
|
||||
|
||||
// Abre o modal de confirmação
|
||||
openConfirmDialog();
|
||||
|
||||
}, [openConfirmDialog]);
|
||||
|
||||
/**
|
||||
* Executa a exclusão de fato quando o usuário confirma
|
||||
*/
|
||||
const handleDelete = useCallback(async () => {
|
||||
|
||||
// Protege contra null
|
||||
if (!itemToDelete) return;
|
||||
|
||||
// Executa o Hook de remoção
|
||||
await removeGTBRegimeComunhao(itemToDelete);
|
||||
|
||||
// Atualiza a lista
|
||||
await fetchGTBRegimeBens();
|
||||
|
||||
// Limpa o item selecionado
|
||||
setItemToDelete(null);
|
||||
|
||||
// Fecha o modal
|
||||
handleCancel();
|
||||
|
||||
}, [itemToDelete, fetchGTBRegimeBens, handleCancel]);
|
||||
|
||||
/**
|
||||
* Busca inicial dos dados
|
||||
*/
|
||||
useEffect(() => {
|
||||
fetchGTBRegimeBens();
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Tela de loading enquanto carrega os dados
|
||||
*/
|
||||
if (!gTBRegimeBens) {
|
||||
return <Loading type={2} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
{/* Cabeçalho */}
|
||||
<Header
|
||||
title={"Regimes de Bens"}
|
||||
description={"Gerenciamento de Regimes de Bens"}
|
||||
buttonText={"Novo Regime"}
|
||||
buttonAction={() => { handleOpenForm(null) }}
|
||||
/>
|
||||
|
||||
{/* Tabela de andamentos */}
|
||||
<Card>
|
||||
<CardContent>
|
||||
<GTBRegimeBensTable
|
||||
data={gTBRegimeBens}
|
||||
onEdit={handleOpenForm}
|
||||
onDelete={handleConfirmDelete}
|
||||
/>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Modal de confirmação */}
|
||||
<ConfirmDialog
|
||||
isOpen={isConfirmOpen}
|
||||
title="Confirmar exclusão"
|
||||
description="Atenção"
|
||||
message={`Deseja realmente excluir o regime de bens "${itemToDelete?.descricao}"?`}
|
||||
confirmText="Sim, excluir"
|
||||
cancelText="Cancelar"
|
||||
onConfirm={handleDelete}
|
||||
onCancel={handleCancel}
|
||||
/>
|
||||
|
||||
{/* Formulário de criação/edição */}
|
||||
<GTBRegimeBensForm
|
||||
isOpen={isFormOpen}
|
||||
data={selectedAndamento}
|
||||
onClose={handleCloseForm}
|
||||
onSave={handleSave}
|
||||
/>
|
||||
</div>
|
||||
); 4
|
||||
}
|
||||
|
|
@ -0,0 +1,163 @@
|
|||
'use client';
|
||||
|
||||
import { useEffect, useState, useCallback } from "react";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
|
||||
import Loading from "@/app/_components/loading/loading";
|
||||
import GTBRegimeComunhaoTable from "../../_components/g_tb_regimecomunhao/GTBRegimeComunhaoTable";
|
||||
import GTBRegimeComunhaoForm from "../../_components/g_tb_regimecomunhao/GTBRegimeComunhaoForm";
|
||||
|
||||
import { useGTBRegimeComunhaoReadHook } from "../../_hooks/g_tb_regimecomunhao/useGTBRegimeComunhaoReadHook";
|
||||
import { useGTBRegimeComunhaoSaveHook } from "../../_hooks/g_tb_regimecomunhao/useGTBRegimeComunhaoSaveHook";
|
||||
import { useGTBRegimeComunhaoRemoveHook } from "../../_hooks/g_tb_regimecomunhao/useGTBRegimeComunhaoRemoveHook";
|
||||
|
||||
import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog";
|
||||
import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDialog";
|
||||
|
||||
import GTBRegimeComunhaoInterface from "../../_interfaces/GTBRegimeComunhaoInterface";
|
||||
import Header from "@/app/_components/structure/Header";
|
||||
|
||||
export default function TTBAndamentoServico() {
|
||||
// Hooks para leitura e salvamento
|
||||
const { gTBRegimeComunhao, fetchGTBRegimeComunhao } = useGTBRegimeComunhaoReadHook();
|
||||
const { saveGTBRegimeComunhao } = useGTBRegimeComunhaoSaveHook();
|
||||
const { removeGTBRegimeComunhao } = useGTBRegimeComunhaoRemoveHook();
|
||||
|
||||
// Estados
|
||||
const [selectedAndamento, setSelectedAndamento] = useState<GTBRegimeComunhaoInterface | null>(null);
|
||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||
|
||||
// Estado para saber qual item será deletado
|
||||
const [itemToDelete, setItemToDelete] = useState<GTBRegimeComunhaoInterface | null>(null);
|
||||
|
||||
/**
|
||||
* Hook do modal de confirmação
|
||||
*/
|
||||
const {
|
||||
isOpen: isConfirmOpen,
|
||||
openDialog: openConfirmDialog,
|
||||
handleConfirm,
|
||||
handleCancel,
|
||||
} = useConfirmDialog();
|
||||
|
||||
/**
|
||||
* Abre o formulário no modo de edição ou criação
|
||||
*/
|
||||
const handleOpenForm = useCallback((data: GTBRegimeComunhaoInterface | null) => {
|
||||
setSelectedAndamento(data);
|
||||
setIsFormOpen(true);
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Fecha o formulário e limpa o andamento selecionado
|
||||
*/
|
||||
const handleCloseForm = useCallback(() => {
|
||||
setSelectedAndamento(null);
|
||||
setIsFormOpen(false);
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Salva os dados do formulário
|
||||
*/
|
||||
const handleSave = useCallback(async (formData: GTBRegimeComunhaoInterface) => {
|
||||
|
||||
// Aguarda salvar o registro
|
||||
await saveGTBRegimeComunhao(formData);
|
||||
|
||||
// Atualiza a lista de dados
|
||||
fetchGTBRegimeComunhao();
|
||||
|
||||
}, [saveGTBRegimeComunhao, fetchGTBRegimeComunhao]);
|
||||
|
||||
/**
|
||||
* Quando o usuário clica em "remover" na tabela
|
||||
*/
|
||||
const handleConfirmDelete = useCallback((item: GTBRegimeComunhaoInterface) => {
|
||||
|
||||
// Define o item atual para remoção
|
||||
setItemToDelete(item);
|
||||
|
||||
// Abre o modal de confirmação
|
||||
openConfirmDialog();
|
||||
|
||||
}, [openConfirmDialog]);
|
||||
|
||||
/**
|
||||
* Executa a exclusão de fato quando o usuário confirma
|
||||
*/
|
||||
const handleDelete = useCallback(async () => {
|
||||
|
||||
// Protege contra null
|
||||
if (!itemToDelete) return;
|
||||
|
||||
// Executa o Hook de remoção
|
||||
await removeGTBRegimeComunhao(itemToDelete);
|
||||
|
||||
// Atualiza a lista
|
||||
await fetchGTBRegimeComunhao();
|
||||
|
||||
// Limpa o item selecionado
|
||||
setItemToDelete(null);
|
||||
|
||||
// Fecha o modal
|
||||
handleCancel();
|
||||
|
||||
}, [itemToDelete, fetchGTBRegimeComunhao, handleCancel]);
|
||||
|
||||
/**
|
||||
* Busca inicial dos dados
|
||||
*/
|
||||
useEffect(() => {
|
||||
fetchGTBRegimeComunhao();
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Tela de loading enquanto carrega os dados
|
||||
*/
|
||||
if (!gTBRegimeComunhao) {
|
||||
return <Loading type={2} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
{/* Cabeçalho */}
|
||||
<Header
|
||||
title={"Regimes de Comunhão"}
|
||||
description={"Gerenciamento de Regimes de Comunhão"}
|
||||
buttonText={"Novo Regime"}
|
||||
buttonAction={() => { handleOpenForm(null) }}
|
||||
/>
|
||||
|
||||
{/* Tabela de andamentos */}
|
||||
<Card>
|
||||
<CardContent>
|
||||
<GTBRegimeComunhaoTable
|
||||
data={gTBRegimeComunhao}
|
||||
onEdit={handleOpenForm}
|
||||
onDelete={handleConfirmDelete}
|
||||
/>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Modal de confirmação */}
|
||||
<ConfirmDialog
|
||||
isOpen={isConfirmOpen}
|
||||
title="Confirmar exclusão"
|
||||
description="Atenção"
|
||||
message={`Deseja realmente excluir o andamento "${itemToDelete?.descricao}"?`}
|
||||
confirmText="Sim, excluir"
|
||||
cancelText="Cancelar"
|
||||
onConfirm={handleDelete}
|
||||
onCancel={handleCancel}
|
||||
/>
|
||||
|
||||
{/* Formulário de criação/edição */}
|
||||
<GTBRegimeComunhaoForm
|
||||
isOpen={isFormOpen}
|
||||
data={selectedAndamento}
|
||||
onClose={handleCloseForm}
|
||||
onSave={handleSave}
|
||||
/>
|
||||
</div>
|
||||
); 4
|
||||
}
|
||||
|
|
@ -0,0 +1,163 @@
|
|||
'use client';
|
||||
|
||||
import { useEffect, useState, useCallback } from "react";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDialog";
|
||||
|
||||
import Header from "@/app/_components/structure/Header";
|
||||
import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog";
|
||||
import Loading from "@/app/_components/loading/loading";
|
||||
import GTBTipoLogradouroTable from "../../_components/g_tb_tipologradouro/GTBTipoLogradouroTable";
|
||||
import GTBTipoLogradouroForm from "../../_components/g_tb_tipologradouro/GTBTipoLogradouroForm";
|
||||
|
||||
import { useGTBTipoLogradouroReadHook } from "../../_hooks/g_tb_tipologradouro/useGTBTipoLogradouroReadHook";
|
||||
import { useGTBTipoLogradouroSaveHook } from "../../_hooks/g_tb_tipologradouro/useGTBTipoLogradouroSaveHook";
|
||||
import { useGTBTipoLogradouroRemoveHook } from "../../_hooks/g_tb_tipologradouro/useGTBTipoLogradouroRemoveHook";
|
||||
|
||||
import { GTBTipoLogradouroInterface } from "../../_interfaces/GTBTipoLogradouroInterface";
|
||||
|
||||
export default function TTBAndamentoServico() {
|
||||
|
||||
// Hooks para leitura e salvamento
|
||||
const { gTBTipoLogradouro, fetchGTBTipoLogradouro } = useGTBTipoLogradouroReadHook();
|
||||
const { saveGTBTipoLogradouro } = useGTBTipoLogradouroSaveHook();
|
||||
const { removeGTBTipoLogradouro } = useGTBTipoLogradouroRemoveHook();
|
||||
|
||||
// Estados
|
||||
const [selectedTipoLogradouro, setTipoLogradouro] = useState<GTBTipoLogradouroInterface | null>(null);
|
||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||
|
||||
// Estado para saber qual item será deletado
|
||||
const [itemToDelete, setItemToDelete] = useState<GTBTipoLogradouroInterface | null>(null);
|
||||
|
||||
/**
|
||||
* Hook do modal de confirmação
|
||||
*/
|
||||
const {
|
||||
isOpen: isConfirmOpen,
|
||||
openDialog: openConfirmDialog,
|
||||
handleConfirm,
|
||||
handleCancel,
|
||||
} = useConfirmDialog();
|
||||
|
||||
/**
|
||||
* Abre o formulário no modo de edição ou criação
|
||||
*/
|
||||
const handleOpenForm = useCallback((data: GTBTipoLogradouroInterface | null) => {
|
||||
setTipoLogradouro(data);
|
||||
setIsFormOpen(true);
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Fecha o formulário e limpa o andamento selecionado
|
||||
*/
|
||||
const handleCloseForm = useCallback(() => {
|
||||
setTipoLogradouro(null);
|
||||
setIsFormOpen(false);
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Salva os dados do formulário
|
||||
*/
|
||||
const handleSave = useCallback(async (formData: GTBTipoLogradouroInterface) => {
|
||||
|
||||
// Aguarda salvar o registro
|
||||
await saveGTBTipoLogradouro(formData);
|
||||
|
||||
// Atualiza a lista de dados
|
||||
fetchGTBTipoLogradouro();
|
||||
|
||||
}, [saveGTBTipoLogradouro, fetchGTBTipoLogradouro]);
|
||||
|
||||
/**
|
||||
* Quando o usuário clica em "remover" na tabela
|
||||
*/
|
||||
const handleConfirmDelete = useCallback((item: GTBTipoLogradouroInterface) => {
|
||||
|
||||
// Define o item atual para remoção
|
||||
setItemToDelete(item);
|
||||
|
||||
// Abre o modal de confirmação
|
||||
openConfirmDialog();
|
||||
|
||||
}, [openConfirmDialog]);
|
||||
|
||||
/**
|
||||
* Executa a exclusão de fato quando o usuário confirma
|
||||
*/
|
||||
const handleDelete = useCallback(async () => {
|
||||
|
||||
// Protege contra null
|
||||
if (!itemToDelete) return;
|
||||
|
||||
// Executa o Hook de remoção
|
||||
await removeGTBTipoLogradouro(itemToDelete);
|
||||
|
||||
// Atualiza a lista
|
||||
await fetchGTBTipoLogradouro();
|
||||
|
||||
// Limpa o item selecionado
|
||||
setItemToDelete(null);
|
||||
|
||||
// Fecha o modal
|
||||
handleCancel();
|
||||
|
||||
}, [itemToDelete, fetchGTBTipoLogradouro, handleCancel]);
|
||||
|
||||
/**
|
||||
* Busca inicial dos dados
|
||||
*/
|
||||
useEffect(() => {
|
||||
fetchGTBTipoLogradouro();
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Tela de loading enquanto carrega os dados
|
||||
*/
|
||||
if (!gTBTipoLogradouro) {
|
||||
return <Loading type={2} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
{/* Cabeçalho */}
|
||||
<Header
|
||||
title={"Tipos de Logradouros"}
|
||||
description={"Gerenciamento de tipos de Logradouros"}
|
||||
buttonText={"Novo Tipo"}
|
||||
buttonAction={() => { handleOpenForm(null) }}
|
||||
/>
|
||||
|
||||
{/* Tabela de andamentos */}
|
||||
<Card>
|
||||
<CardContent>
|
||||
<GTBTipoLogradouroTable
|
||||
data={gTBTipoLogradouro}
|
||||
onEdit={handleOpenForm}
|
||||
onDelete={handleConfirmDelete}
|
||||
/>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Modal de confirmação */}
|
||||
<ConfirmDialog
|
||||
isOpen={isConfirmOpen}
|
||||
title="Confirmar exclusão"
|
||||
description="Atenção"
|
||||
message={`Deseja realmente excluir o andamento "${itemToDelete?.descricao}"?`}
|
||||
confirmText="Sim, excluir"
|
||||
cancelText="Cancelar"
|
||||
onConfirm={handleDelete}
|
||||
onCancel={handleCancel}
|
||||
/>
|
||||
|
||||
{/* Formulário de criação/edição */}
|
||||
<GTBTipoLogradouroForm
|
||||
isOpen={isFormOpen}
|
||||
data={selectedTipoLogradouro}
|
||||
onClose={handleCloseForm}
|
||||
onSave={handleSave}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,174 @@
|
|||
'use client';
|
||||
|
||||
import { useEffect, useState, useCallback } from "react";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
|
||||
import Loading from "@/app/_components/loading/loading";
|
||||
import TCensecTable from "../../_components/t_censec/TCensecTable";
|
||||
import TCensecForm from "../../_components/t_censec/TCensecForm";
|
||||
|
||||
import { useTCensecReadHook } from "../../_hooks/t_censec/useTCensecReadHook";
|
||||
import { useTCensecSaveHook } from "../../_hooks/t_censec/useTCensecSaveHook";
|
||||
import { useTCensecDeleteHook } from "../../_hooks/t_censec/useTCensecDeleteHook";
|
||||
|
||||
import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog";
|
||||
import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDialog";
|
||||
|
||||
import TCensecInterface from "../../_interfaces/TCensecInterface";
|
||||
import Header from "@/app/_components/structure/Header";
|
||||
|
||||
export default function TTBAndamentoServico() {
|
||||
|
||||
// Controle de estado do botão
|
||||
const [buttonIsLoading, setButtonIsLoading] = useState(false);
|
||||
|
||||
// Hooks para leitura e salvamento
|
||||
const { tCensec, fetchTCensec } = useTCensecReadHook();
|
||||
const { saveTCensec } = useTCensecSaveHook();
|
||||
const { deleteTCensec } = useTCensecDeleteHook();
|
||||
|
||||
// Estados
|
||||
const [selectedAndamento, setSelectedAndamento] = useState<TCensecInterface | null>(null);
|
||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||
|
||||
// Estado para saber qual item será deletado
|
||||
const [itemToDelete, setItemToDelete] = useState<TCensecInterface | null>(null);
|
||||
|
||||
/**
|
||||
* Hook do modal de confirmação
|
||||
*/
|
||||
const {
|
||||
isOpen: isConfirmOpen,
|
||||
openDialog: openConfirmDialog,
|
||||
handleConfirm,
|
||||
handleCancel,
|
||||
} = useConfirmDialog();
|
||||
|
||||
/**
|
||||
* Abre o formulário no modo de edição ou criação
|
||||
*/
|
||||
const handleOpenForm = useCallback((data: TCensecInterface | null) => {
|
||||
setSelectedAndamento(data);
|
||||
setIsFormOpen(true);
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Fecha o formulário e limpa o andamento selecionado
|
||||
*/
|
||||
const handleCloseForm = useCallback(() => {
|
||||
setSelectedAndamento(null);
|
||||
setIsFormOpen(false);
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Salva os dados do formulário
|
||||
*/
|
||||
const handleSave = useCallback(async (formData: TCensecInterface) => {
|
||||
|
||||
// Coloca o botão em estado de loading
|
||||
setButtonIsLoading(true);
|
||||
|
||||
// Aguarda salvar o registro
|
||||
await saveTCensec(formData);
|
||||
|
||||
// Remove o botão em estado de loading
|
||||
setButtonIsLoading(false);
|
||||
|
||||
// Atualiza a lista de dados
|
||||
fetchTCensec();
|
||||
|
||||
}, [saveTCensec, fetchTCensec, handleCloseForm]);
|
||||
|
||||
/**
|
||||
* Quando o usuário clica em "remover" na tabela
|
||||
*/
|
||||
const handleConfirmDelete = useCallback((item: TCensecInterface) => {
|
||||
|
||||
// Define o item atual para remoção
|
||||
setItemToDelete(item);
|
||||
|
||||
// Abre o modal de confirmação
|
||||
openConfirmDialog();
|
||||
|
||||
}, [openConfirmDialog]);
|
||||
|
||||
/**
|
||||
* Executa a exclusão de fato quando o usuário confirma
|
||||
*/
|
||||
const handleDelete = useCallback(async () => {
|
||||
|
||||
// Protege contra null
|
||||
if (!itemToDelete) return;
|
||||
|
||||
// Executa o Hook de remoção
|
||||
await deleteTCensec(itemToDelete);
|
||||
|
||||
// Atualiza a lista
|
||||
await fetchTCensec();
|
||||
|
||||
// Limpa o item selecionado
|
||||
setItemToDelete(null);
|
||||
|
||||
// Fecha o modal
|
||||
handleCancel();
|
||||
|
||||
}, [itemToDelete, fetchTCensec, handleCancel]);
|
||||
|
||||
/**
|
||||
* Busca inicial dos dados
|
||||
*/
|
||||
useEffect(() => {
|
||||
fetchTCensec();
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Tela de loading enquanto carrega os dados
|
||||
*/
|
||||
if (tCensec.length == 0) {
|
||||
return <Loading type={2} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
{/* Cabeçalho */}
|
||||
<Header
|
||||
title={"CENSEC"}
|
||||
description={"Gerenciamento de Centrais"}
|
||||
buttonText={"Nova Central"}
|
||||
buttonAction={() => { handleOpenForm(null) }}
|
||||
/>
|
||||
|
||||
{/* Tabela de andamentos */}
|
||||
<Card>
|
||||
<CardContent>
|
||||
<TCensecTable
|
||||
data={tCensec}
|
||||
onEdit={handleOpenForm}
|
||||
onDelete={handleConfirmDelete}
|
||||
/>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Modal de confirmação */}
|
||||
<ConfirmDialog
|
||||
isOpen={isConfirmOpen}
|
||||
title="Confirmar exclusão"
|
||||
description="Atenção"
|
||||
message={`Deseja realmente excluir o andamento "${itemToDelete?.descricao}"?`}
|
||||
confirmText="Sim, excluir"
|
||||
cancelText="Cancelar"
|
||||
onConfirm={handleDelete}
|
||||
onCancel={handleCancel}
|
||||
/>
|
||||
|
||||
{/* Formulário de criação/edição */}
|
||||
<TCensecForm
|
||||
isOpen={isFormOpen}
|
||||
data={selectedAndamento}
|
||||
onClose={handleCloseForm}
|
||||
onSave={handleSave}
|
||||
buttonIsLoading={buttonIsLoading}
|
||||
/>
|
||||
</div>
|
||||
); 4
|
||||
}
|
||||
|
|
@ -0,0 +1,134 @@
|
|||
'use client';
|
||||
|
||||
import { useEffect, useState, useCallback } from "react";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDialog";
|
||||
|
||||
import Header from "@/app/_components/structure/Header";
|
||||
import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog";
|
||||
import Loading from "@/app/_components/loading/loading";
|
||||
|
||||
import TCensecNaturezaLitigioTable from "../../_components/t_censecnaturezalitigio/TCensecNaturezaLitigioTable";
|
||||
import TCensecNaturezaLitigioForm from "../../_components/t_censecnaturezalitigio/TCensecNaturezaLitigioForm";
|
||||
|
||||
import { useTCensecNaturezaLitigioReadHook } from "../../_hooks/t_censecnaturezalitigio/useTCensecNaturezaLitigioReadHook";
|
||||
import { useTCensecNaturezaLitigioSaveHook } from "../../_hooks/t_censecnaturezalitigio/useTCensecNaturezaLitigioSaveHook";
|
||||
import { useTCensecNaturezaLitigioRemoveHook } from "../../_hooks/t_censecnaturezalitigio/useTCensecNaturezaLitigioRemoveHook";
|
||||
|
||||
import { TCensecNaturezaLitigioInterface } from "../../_interfaces/TCensecNaturezaLitigioInterface";
|
||||
|
||||
const initialCensecNaturezaLitigio: TCensecNaturezaLitigioInterface = {
|
||||
censec_naturezalitigio_id: 0,
|
||||
descricao: "",
|
||||
situacao: 'A'
|
||||
}
|
||||
|
||||
export default function TCensecNaturezaLitigioPage() {
|
||||
|
||||
// Hooks
|
||||
const { tCensecNaturezaLitigio, fetchTCensecNaturezaLitigio } = useTCensecNaturezaLitigioReadHook();
|
||||
const { saveTCensecNaturezaLitigio } = useTCensecNaturezaLitigioSaveHook();
|
||||
const { removeTCensecNaturezaLitigio } = useTCensecNaturezaLitigioRemoveHook();
|
||||
|
||||
// Estados
|
||||
const [selectedItem, setSelectedItem] = useState<TCensecNaturezaLitigioInterface | null>(null);
|
||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||
const [itemToDelete, setItemToDelete] = useState<TCensecNaturezaLitigioInterface | null>(null);
|
||||
|
||||
// Modal de confirmação
|
||||
const {
|
||||
isOpen: isConfirmOpen,
|
||||
openDialog: openConfirmDialog,
|
||||
handleConfirm,
|
||||
handleCancel,
|
||||
} = useConfirmDialog();
|
||||
|
||||
// Abrir formulário (criação ou edição)
|
||||
const handleOpenForm = useCallback((item: TCensecNaturezaLitigioInterface | null) => {
|
||||
setSelectedItem(item);
|
||||
setIsFormOpen(true);
|
||||
}, []);
|
||||
|
||||
// Fechar formulário
|
||||
const handleCloseForm = useCallback(() => {
|
||||
setSelectedItem(null);
|
||||
setIsFormOpen(false);
|
||||
}, []);
|
||||
|
||||
// Salvar item
|
||||
const handleSave = useCallback(async (formData: TCensecNaturezaLitigioInterface) => {
|
||||
await saveTCensecNaturezaLitigio(formData);
|
||||
console.log(formData)
|
||||
await fetchTCensecNaturezaLitigio();
|
||||
}, [saveTCensecNaturezaLitigio, fetchTCensecNaturezaLitigio]);
|
||||
|
||||
// Confirmar remoção
|
||||
const handleConfirmDelete = useCallback((item: TCensecNaturezaLitigioInterface) => {
|
||||
console.log("item", item)
|
||||
setItemToDelete(item);
|
||||
openConfirmDialog();
|
||||
}, [openConfirmDialog]);
|
||||
|
||||
// Executar remoção
|
||||
const handleDelete = useCallback(async () => {
|
||||
if (!itemToDelete) return;
|
||||
console.log("item to delete",itemToDelete)
|
||||
await removeTCensecNaturezaLitigio(itemToDelete);
|
||||
await fetchTCensecNaturezaLitigio();
|
||||
setItemToDelete(null);
|
||||
handleCancel();
|
||||
}, [itemToDelete, fetchTCensecNaturezaLitigio, handleCancel]);
|
||||
|
||||
// Fetch inicial
|
||||
useEffect(() => {
|
||||
fetchTCensecNaturezaLitigio();
|
||||
}, []);
|
||||
|
||||
// Loading enquanto carrega
|
||||
if (!tCensecNaturezaLitigio) {
|
||||
return <Loading type={2} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
{/* Cabeçalho */}
|
||||
<Header
|
||||
title={"Natureza do Litígio"}
|
||||
description={"Gerenciamento de Naturezas do Litígio"}
|
||||
buttonText={"Nova Natureza"}
|
||||
buttonAction={(data) => handleOpenForm(data = initialCensecNaturezaLitigio)}
|
||||
/>
|
||||
|
||||
{/* Tabela */}
|
||||
<Card>
|
||||
<CardContent>
|
||||
<TCensecNaturezaLitigioTable
|
||||
data={tCensecNaturezaLitigio}
|
||||
onEdit={handleOpenForm}
|
||||
onDelete={handleConfirmDelete}
|
||||
/>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Modal de confirmação */}
|
||||
<ConfirmDialog
|
||||
isOpen={isConfirmOpen}
|
||||
title="Confirmar exclusão"
|
||||
description="Atenção"
|
||||
message={`Deseja realmente excluir a natureza "${itemToDelete?.descricao}"?`}
|
||||
confirmText="Sim, excluir"
|
||||
cancelText="Cancelar"
|
||||
onConfirm={handleDelete}
|
||||
onCancel={handleCancel}
|
||||
/>
|
||||
|
||||
{/* Formulário */}
|
||||
<TCensecNaturezaLitigioForm
|
||||
isOpen={isFormOpen}
|
||||
data={selectedItem}
|
||||
onClose={handleCloseForm}
|
||||
onSave={handleSave}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,13 +1,17 @@
|
|||
'use client';
|
||||
'use client'
|
||||
|
||||
import { useParams } from 'next/navigation';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useEffect, useState } from "react";
|
||||
import { useParams } from "next/navigation";
|
||||
|
||||
import MainEditor from '@/components/MainEditor';
|
||||
import { Card, CardContent } from '@/components/ui/card';
|
||||
import { useTMinutaReadHook } from '@/packages/administrativo/hooks/TMinuta/useTMinutaReadHook';
|
||||
import { TMinutaInterface } from '@/packages/administrativo/interfaces/TMinuta/TMinutaInterface';
|
||||
import Loading from '@/shared/components/loading/loading';
|
||||
import {
|
||||
Card,
|
||||
CardContent
|
||||
} from "@/components/ui/card";
|
||||
import MainEditor from "@/components/MainEditor";
|
||||
|
||||
import Loading from "@/app/_components/loading/loading";
|
||||
import { useTMinutaReadHook } from '../../../../_hooks/t_minuta/useTMinutaReadHook';
|
||||
import { TMinutaInterface } from '../../../../_interfaces/TMinutaInterface';
|
||||
|
||||
export default function TMinutaDetalhes() {
|
||||
const params = useParams();
|
||||
|
|
@ -41,25 +45,32 @@ export default function TMinutaDetalhes() {
|
|||
<div>
|
||||
<Card>
|
||||
<CardContent>
|
||||
<div className="mb-4 grid grid-cols-2 gap-4">
|
||||
<div className="mb-4 grid gap-4 grid-cols-2">
|
||||
<div>
|
||||
<div className="text-2xl font-semibold">Descrição</div>
|
||||
<div className="text-xl">{tMinuta.descricao}</div>
|
||||
<div className="text-2xl font-semibold">
|
||||
Descrição
|
||||
</div>
|
||||
<div className="text-xl">
|
||||
{tMinuta.descricao}
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div className="text-2xl font-semibold">Situação</div>
|
||||
<div className="text-xl">{tMinuta.situacao === 'A' ? 'Ativo' : 'Inativo'}</div>
|
||||
<div className="text-2xl font-semibold">
|
||||
Situação
|
||||
</div>
|
||||
<div className="text-xl">
|
||||
{tMinuta.situacao === "A" ? "Ativo" : "Inativo"}
|
||||
</div>
|
||||
</div>
|
||||
<div className="col-span-2">
|
||||
<div className="text-2xl font-semibold">Texto</div>
|
||||
<div className="text-2xl font-semibold">
|
||||
Texto
|
||||
</div>
|
||||
<MainEditor
|
||||
initialValue={editorContent} // Passa o conteúdo do editor
|
||||
onEditorChange={handleEditorChange} // Função que atualiza o estado
|
||||
margins={{
|
||||
top: '2',
|
||||
bottom: '2',
|
||||
left: '2',
|
||||
right: '2',
|
||||
top: "2", bottom: "2", left: "2", right: "2"
|
||||
}}
|
||||
size={{ width: 794, height: 1123 }} // Você pode ajustar o tamanho aqui
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -1,13 +1,11 @@
|
|||
'use client';
|
||||
|
||||
import { zodResolver } from '@hookform/resolvers/zod';
|
||||
import z from 'zod';
|
||||
import { useEffect } from 'react';
|
||||
import { useForm, Controller } from 'react-hook-form';
|
||||
import z from 'zod';
|
||||
import { zodResolver } from '@hookform/resolvers/zod';
|
||||
|
||||
import MainEditor from '@/components/MainEditor';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Card, CardContent } from '@/components/ui/card';
|
||||
import { Checkbox } from '@/components/ui/checkbox';
|
||||
import {
|
||||
Form,
|
||||
|
|
@ -15,16 +13,20 @@ import {
|
|||
FormField,
|
||||
FormItem,
|
||||
FormLabel,
|
||||
FormMessage,
|
||||
FormMessage
|
||||
} from '@/components/ui/form';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Label } from '@/components/ui/label';
|
||||
import { useTMinutaSaveHook } from '@/packages/administrativo/hooks/TMinuta/useTMinutaSaveHook';
|
||||
import { TMinutaSchema } from '@/packages/administrativo/schemas/TMinuta/TMinutaSchema';
|
||||
|
||||
import MainEditor from '@/components/MainEditor';
|
||||
import { TMinutaSchema } from '../../../_schemas/TMinutaSchema';
|
||||
import { useTMinutaSaveHook } from '../../../_hooks/t_minuta/useTMinutaSaveHook';
|
||||
import { Card, CardContent } from '@/components/ui/card';
|
||||
|
||||
type FormValues = z.infer<typeof TMinutaSchema>;
|
||||
|
||||
export default function TMinutaForm() {
|
||||
|
||||
const { tMinuta, saveTMinuta } = useTMinutaSaveHook();
|
||||
|
||||
const form = useForm<FormValues>({
|
||||
|
|
@ -34,7 +36,7 @@ export default function TMinutaForm() {
|
|||
descricao: '',
|
||||
situacao: 'A',
|
||||
texto: '',
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
async function onSubmit(values: FormValues) {
|
||||
|
|
@ -45,8 +47,10 @@ export default function TMinutaForm() {
|
|||
<div>
|
||||
<Card>
|
||||
<CardContent>
|
||||
|
||||
<Form {...form}>
|
||||
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-6">
|
||||
|
||||
{/* Descrição */}
|
||||
<FormField
|
||||
control={form.control}
|
||||
|
|
@ -69,10 +73,10 @@ export default function TMinutaForm() {
|
|||
render={({ field }) => (
|
||||
<div className="flex items-center space-x-2">
|
||||
<Checkbox
|
||||
checked={field.value === 'A'}
|
||||
onCheckedChange={(checked) => field.onChange(checked ? 'A' : 'I')}
|
||||
checked={field.value === "A"}
|
||||
onCheckedChange={(checked) => field.onChange(checked ? "A" : "I")}
|
||||
/>
|
||||
<Label>{field.value === 'A' ? 'Ativo' : 'Inativo'}</Label>
|
||||
<Label>{field.value === "A" ? "Ativo" : "Inativo"}</Label>
|
||||
</div>
|
||||
)}
|
||||
/>
|
||||
|
|
@ -84,20 +88,22 @@ export default function TMinutaForm() {
|
|||
render={({ field }) => (
|
||||
<div>
|
||||
<MainEditor
|
||||
initialValue={field.value || ''}
|
||||
initialValue={field.value || ""}
|
||||
onEditorChange={field.onChange}
|
||||
margins={{ top: '0', bottom: '0', left: '0', right: '0' }}
|
||||
size={{ width: 794, height: 1123 }}
|
||||
/>
|
||||
{form.formState.errors.texto && (
|
||||
<p className="mt-2 text-sm text-red-500">
|
||||
<p className="text-sm text-red-500 mt-2">
|
||||
{form.formState.errors.texto.message}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
/>
|
||||
<Button type="submit">Salvar</Button>
|
||||
<Button type="submit">
|
||||
Salvar
|
||||
</Button>
|
||||
</form>
|
||||
</Form>
|
||||
</CardContent>
|
||||
|
|
|
|||
|
|
@ -1,21 +1,25 @@
|
|||
'use client';
|
||||
|
||||
import { useEffect, useState, useCallback } from 'react';
|
||||
import { useEffect, useState, useCallback } from "react";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDialog";
|
||||
|
||||
import { Card, CardContent } from '@/components/ui/card';
|
||||
import TMinutaForm from '@/packages/administrativo/components/TMinuta/TMinutaForm';
|
||||
import TMinutaTable from '@/packages/administrativo/components/TMinuta/TMinutaTable';
|
||||
import { useTMinutaIndexHook } from '@/packages/administrativo/hooks/TMinuta/useTMinutaIndexHook';
|
||||
import { useTMinutaReadHook } from '@/packages/administrativo/hooks/TMinuta/useTMinutaReadHook';
|
||||
import { useTMinutaRemoveHook } from '@/packages/administrativo/hooks/TMinuta/useTMinutaRemoveHook';
|
||||
import { useTMinutaSaveHook } from '@/packages/administrativo/hooks/TMinuta/useTMinutaSaveHook';
|
||||
import { TMinutaInterface } from '@/packages/administrativo/interfaces/TMinuta/TMinutaInterface';
|
||||
import ConfirmDialog from '@/shared/components/confirmDialog/ConfirmDialog';
|
||||
import { useConfirmDialog } from '@/shared/components/confirmDialog/useConfirmDialog';
|
||||
import Loading from '@/shared/components/loading/loading';
|
||||
import Header from '@/shared/components/structure/Header';
|
||||
import Header from "@/app/_components/structure/Header";
|
||||
import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog";
|
||||
import Loading from "@/app/_components/loading/loading";
|
||||
|
||||
import TMinutaTable from "../../_components/t_minuta/TMinutaTable";
|
||||
import TMinutaForm from "../../_components/t_minuta/TMinutaForm";
|
||||
|
||||
import { useTMinutaReadHook } from "../../_hooks/t_minuta/useTMinutaReadHook";
|
||||
import { useTMinutaSaveHook } from "../../_hooks/t_minuta/useTMinutaSaveHook";
|
||||
import { useTMinutaRemoveHook } from "../../_hooks/t_minuta/useTMinutaRemoveHook";
|
||||
|
||||
import { TMinutaInterface } from "../../_interfaces/TMinutaInterface";
|
||||
import { useTMinutaIndexHook } from "../../_hooks/t_minuta/useTMinutaIndexHook";
|
||||
|
||||
export default function TMinutaPage() {
|
||||
|
||||
// Hooks de leitura e escrita
|
||||
const { tMinuta, fetchTMinuta } = useTMinutaIndexHook();
|
||||
const { saveTMinuta } = useTMinutaSaveHook();
|
||||
|
|
@ -31,7 +35,7 @@ export default function TMinutaPage() {
|
|||
isOpen: isConfirmOpen,
|
||||
openDialog: openConfirmDialog,
|
||||
handleConfirm,
|
||||
handleCancel,
|
||||
handleCancel
|
||||
} = useConfirmDialog();
|
||||
|
||||
// Abertura do formulário
|
||||
|
|
@ -41,13 +45,10 @@ export default function TMinutaPage() {
|
|||
}, []);
|
||||
|
||||
// Ação de clique em remover
|
||||
const handleConfirmDelete = useCallback(
|
||||
(item: TMinutaInterface) => {
|
||||
const handleConfirmDelete = useCallback((item: TMinutaInterface) => {
|
||||
setItemToDelete(item);
|
||||
openConfirmDialog();
|
||||
},
|
||||
[openConfirmDialog],
|
||||
);
|
||||
}, [openConfirmDialog]);
|
||||
|
||||
// Remoção da minuta após confirmação
|
||||
const handleDelete = useCallback(async () => {
|
||||
|
|
@ -82,7 +83,11 @@ export default function TMinutaPage() {
|
|||
{/* Tabela */}
|
||||
<Card>
|
||||
<CardContent>
|
||||
<TMinutaTable data={tMinuta} onEdit={handleOpenForm} onDelete={handleConfirmDelete} />
|
||||
<TMinutaTable
|
||||
data={tMinuta}
|
||||
onEdit={handleOpenForm}
|
||||
onDelete={handleConfirmDelete}
|
||||
/>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,160 @@
|
|||
'use client';
|
||||
|
||||
import { useEffect, useState, useCallback } from "react";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
|
||||
import Loading from "@/app/_components/loading/loading";
|
||||
import TTBAndamentoServicoTable from "../../_components/t_tb_andamentoservico/TTBAndamentoServicoTable";
|
||||
import TTBAndamentoServicoForm from "../../_components/t_tb_andamentoservico/TTBAndamentoServicoForm";
|
||||
|
||||
import { useTTBAndamentoServicoReadHook } from "../../_hooks/t_tb_andamentoservico/useTTBAndamentoServicoReadHook";
|
||||
import { useTTBAndamentoServicoSaveHook } from "../../_hooks/t_tb_andamentoservico/useTTBAndamentoServicoSaveHook";
|
||||
|
||||
import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog";
|
||||
import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDialog";
|
||||
|
||||
import TTBAndamentoServicoInterface from "../../_interfaces/TTBAndamentoServicoInterface";
|
||||
import { useTTBAndamentoServicoDeleteHook } from "../../_hooks/t_tb_andamentoservico/useTTBAndamentoServicoDeleteHook";
|
||||
import Header from "@/app/_components/structure/Header";
|
||||
|
||||
export default function TTBAndamentoServico() {
|
||||
|
||||
// Hooks para leitura e salvamento
|
||||
const { tTBAndamentosServicos, fetchTTBAndamentoServico } = useTTBAndamentoServicoReadHook();
|
||||
const { saveTTBAndamentoServico } = useTTBAndamentoServicoSaveHook();
|
||||
const { deleteTTBAndamentoServico } = useTTBAndamentoServicoDeleteHook();
|
||||
|
||||
// Estados
|
||||
const [selectedAndamento, setSelectedAndamento] = useState<TTBAndamentoServicoInterface | null>(null);
|
||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||
|
||||
// Estado para saber qual item será deletado
|
||||
const [itemToDelete, setItemToDelete] = useState<TTBAndamentoServicoInterface | null>(null);
|
||||
|
||||
/**
|
||||
* Hook do modal de confirmação
|
||||
*/
|
||||
const {
|
||||
isOpen: isConfirmOpen,
|
||||
openDialog: openConfirmDialog,
|
||||
handleConfirm,
|
||||
handleCancel,
|
||||
} = useConfirmDialog();
|
||||
|
||||
/**
|
||||
* Abre o formulário no modo de edição ou criação
|
||||
*/
|
||||
const handleOpenForm = useCallback((data: TTBAndamentoServicoInterface | null) => {
|
||||
setSelectedAndamento(data);
|
||||
setIsFormOpen(true);
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Fecha o formulário e limpa o andamento selecionado
|
||||
*/
|
||||
const handleCloseForm = useCallback(() => {
|
||||
setSelectedAndamento(null);
|
||||
setIsFormOpen(false);
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Salva os dados do formulário
|
||||
*/
|
||||
const handleSave = useCallback(async (formData: TTBAndamentoServicoInterface) => {
|
||||
|
||||
// Aguarda salvar o registro
|
||||
await saveTTBAndamentoServico(formData);
|
||||
|
||||
// Atualiza a lista de dados
|
||||
fetchTTBAndamentoServico();
|
||||
|
||||
}, [saveTTBAndamentoServico, fetchTTBAndamentoServico]);
|
||||
|
||||
/**
|
||||
* Quando o usuário clica em "remover" na tabela
|
||||
*/
|
||||
const handleConfirmDelete = useCallback((item: TTBAndamentoServicoInterface) => {
|
||||
setItemToDelete(item);
|
||||
openConfirmDialog();
|
||||
}, [openConfirmDialog]);
|
||||
|
||||
/**
|
||||
* Executa a exclusão de fato quando o usuário confirma
|
||||
*/
|
||||
const handleDelete = useCallback(async () => {
|
||||
|
||||
// Protege contra null
|
||||
if (!itemToDelete) return;
|
||||
|
||||
|
||||
// Executa o Hook de remoção
|
||||
await deleteTTBAndamentoServico(itemToDelete);
|
||||
|
||||
// Atualiza a lista
|
||||
await fetchTTBAndamentoServico();
|
||||
|
||||
// Limpa o item selecionado
|
||||
setItemToDelete(null);
|
||||
|
||||
// Fecha o modal
|
||||
handleCancel();
|
||||
|
||||
}, [itemToDelete, fetchTTBAndamentoServico, handleCancel]);
|
||||
|
||||
/**
|
||||
* Busca inicial dos dados
|
||||
*/
|
||||
useEffect(() => {
|
||||
fetchTTBAndamentoServico();
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Tela de loading enquanto carrega os dados
|
||||
*/
|
||||
if (!tTBAndamentosServicos) {
|
||||
return <Loading type={2} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
{/* Cabeçalho */}
|
||||
<Header
|
||||
title={"Andamentos"}
|
||||
description={"Gerenciamento de Andamentos de Atos"}
|
||||
buttonText={"Novo Andamento"}
|
||||
buttonAction={() => { handleOpenForm(null) }}
|
||||
/>
|
||||
|
||||
{/* Tabela de andamentos */}
|
||||
<Card>
|
||||
<CardContent>
|
||||
<TTBAndamentoServicoTable
|
||||
data={tTBAndamentosServicos}
|
||||
onEdit={handleOpenForm}
|
||||
onDelete={handleConfirmDelete}
|
||||
/>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Modal de confirmação */}
|
||||
<ConfirmDialog
|
||||
isOpen={isConfirmOpen}
|
||||
title="Confirmar exclusão"
|
||||
description="Atenção"
|
||||
message={`Deseja realmente excluir o andamento "${itemToDelete?.descricao}"?`}
|
||||
confirmText="Sim, excluir"
|
||||
cancelText="Cancelar"
|
||||
onConfirm={handleDelete}
|
||||
onCancel={handleCancel}
|
||||
/>
|
||||
|
||||
{/* Formulário de criação/edição */}
|
||||
<TTBAndamentoServicoForm
|
||||
isOpen={isFormOpen}
|
||||
data={selectedAndamento}
|
||||
onClose={handleCloseForm}
|
||||
onSave={handleSave}
|
||||
/>
|
||||
</div>
|
||||
); 4
|
||||
}
|
||||
|
|
@ -0,0 +1,164 @@
|
|||
'use client';
|
||||
|
||||
import { useEffect, useState, useCallback } from "react";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
|
||||
import Loading from "@/app/_components/loading/loading";
|
||||
import Header from "@/app/_components/structure/Header";
|
||||
import TTBReconhecimentoTipoTable from "../../_components/t_tb_reconhecimentotipo/TTBReconhecimentoTipoTable";
|
||||
import TTBReconhecimentoTipoForm from "../../_components/t_tb_reconhecimentotipo/TTBReconhecimentoTipoForm";
|
||||
|
||||
import { useTTBReconhecimentoTipoReadHook } from "../../_hooks/t_tb_reconhecimentotipo/useTTBReconhecimentoTipoReadHook";
|
||||
import { useTTBReconhecimentoTipoSaveHook } from "../../_hooks/t_tb_reconhecimentotipo/useTTBReconhecimentoTipoSaveHook";
|
||||
import { useTTBReconhecimentoTipoDeleteHook } from "../../_hooks/t_tb_reconhecimentotipo/useTTBReconhecimentoTipoDeleteHook";
|
||||
|
||||
import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog";
|
||||
import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDialog";
|
||||
|
||||
import TTBReconhecimentoTipoInterface from "../../_interfaces/TTBReconhecimentoTipoInterface";
|
||||
|
||||
export default function TTBAndamentoServico() {
|
||||
|
||||
// Hooks para leitura e salvamento
|
||||
const { tTBReconhecimentosTipos, fetchTTBReconhecimentosTipos } = useTTBReconhecimentoTipoReadHook();
|
||||
const { saveTTBReconhecimentoTipo } = useTTBReconhecimentoTipoSaveHook();
|
||||
const { deleteTTBReconhecimentoTipo } = useTTBReconhecimentoTipoDeleteHook();
|
||||
|
||||
// Estados
|
||||
const [selectedReconhecimentoTipo, setReconhecimentoTipo] = useState<TTBReconhecimentoTipoInterface | null>(null);
|
||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||
|
||||
// Estado para saber qual item será deletado
|
||||
const [itemToDelete, setItemToDelete] = useState<TTBReconhecimentoTipoInterface | null>(null);
|
||||
|
||||
/**
|
||||
* Hook do modal de confirmação
|
||||
*/
|
||||
const {
|
||||
isOpen: isConfirmOpen,
|
||||
openDialog: openConfirmDialog,
|
||||
handleConfirm,
|
||||
handleCancel,
|
||||
} = useConfirmDialog();
|
||||
|
||||
/**
|
||||
* Abre o formulário no modo de edição ou criação
|
||||
*/
|
||||
const handleOpenForm = useCallback((data: TTBReconhecimentoTipoInterface | null) => {
|
||||
setReconhecimentoTipo(data);
|
||||
setIsFormOpen(true);
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Fecha o formulário e limpa o andamento selecionado
|
||||
*/
|
||||
const handleCloseForm = useCallback(() => {
|
||||
setReconhecimentoTipo(null);
|
||||
setIsFormOpen(false);
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Salva os dados do formulário
|
||||
*/
|
||||
const handleSave = useCallback(async (formData: TTBReconhecimentoTipoInterface) => {
|
||||
|
||||
// Aguarda salvar o registro
|
||||
await saveTTBReconhecimentoTipo(formData);
|
||||
|
||||
// Atualiza a lista de dados
|
||||
fetchTTBReconhecimentosTipos();
|
||||
|
||||
}, [saveTTBReconhecimentoTipo, fetchTTBReconhecimentosTipos]);
|
||||
|
||||
/**
|
||||
* Quando o usuário clica em "remover" na tabela
|
||||
*/
|
||||
const handleConfirmDelete = useCallback((item: TTBReconhecimentoTipoInterface) => {
|
||||
|
||||
// Define o item atual para remoção
|
||||
setItemToDelete(item);
|
||||
|
||||
// Abre o modal de confirmação
|
||||
openConfirmDialog();
|
||||
|
||||
}, [openConfirmDialog]);
|
||||
|
||||
/**
|
||||
* Executa a exclusão de fato quando o usuário confirma
|
||||
*/
|
||||
const handleDelete = useCallback(async () => {
|
||||
|
||||
// Protege contra null
|
||||
if (!itemToDelete) return;
|
||||
|
||||
// Executa o Hook de remoção
|
||||
await deleteTTBReconhecimentoTipo(itemToDelete);
|
||||
|
||||
// Atualiza a lista
|
||||
await fetchTTBReconhecimentosTipos();
|
||||
|
||||
// Limpa o item selecionado
|
||||
setItemToDelete(null);
|
||||
|
||||
// Fecha o modal
|
||||
handleCancel();
|
||||
|
||||
}, [itemToDelete, fetchTTBReconhecimentosTipos, handleCancel]);
|
||||
|
||||
/**
|
||||
* Busca inicial dos dados
|
||||
*/
|
||||
useEffect(() => {
|
||||
fetchTTBReconhecimentosTipos();
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Tela de loading enquanto carrega os dados
|
||||
*/
|
||||
if (!tTBReconhecimentosTipos) {
|
||||
return <Loading type={2} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
{/* Cabeçalho */}
|
||||
<Header
|
||||
title={"Reconhecimentos"}
|
||||
description={"Gerenciamento de tipos de reconhecimentos"}
|
||||
buttonText={"Novo Tipo"}
|
||||
buttonAction={() => { handleOpenForm(null) }}
|
||||
/>
|
||||
|
||||
{/* Tabela de andamentos */}
|
||||
<Card>
|
||||
<CardContent>
|
||||
<TTBReconhecimentoTipoTable
|
||||
data={tTBReconhecimentosTipos}
|
||||
onEdit={handleOpenForm}
|
||||
onDelete={handleConfirmDelete}
|
||||
/>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Modal de confirmação */}
|
||||
<ConfirmDialog
|
||||
isOpen={isConfirmOpen}
|
||||
title="Confirmar exclusão"
|
||||
description="Atenção"
|
||||
message={`Deseja realmente excluir o andamento "${itemToDelete?.descricao}"?`}
|
||||
confirmText="Sim, excluir"
|
||||
cancelText="Cancelar"
|
||||
onConfirm={handleDelete}
|
||||
onCancel={handleCancel}
|
||||
/>
|
||||
|
||||
{/* Formulário de criação/edição */}
|
||||
<TTBReconhecimentoTipoForm
|
||||
isOpen={isFormOpen}
|
||||
data={selectedReconhecimentoTipo}
|
||||
onClose={handleCloseForm}
|
||||
onSave={handleSave}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,125 @@
|
|||
'use client';
|
||||
|
||||
import z from "zod";
|
||||
import { useEffect } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
Dialog,
|
||||
DialogClose,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle
|
||||
} from "@/components/ui/dialog";
|
||||
import {
|
||||
Form,
|
||||
FormControl,
|
||||
FormField,
|
||||
FormItem,
|
||||
FormLabel,
|
||||
FormMessage
|
||||
} from "@/components/ui/form";
|
||||
import { Input } from "@/components/ui/input";
|
||||
|
||||
import { GMedidaTipoSchema } from "../../_schemas/GMedidaTipoSchema";
|
||||
import { GMedidaTipoInterface } from "../../_interfaces/GMedidaTipoInterface";
|
||||
|
||||
type FormValues = z.infer<typeof GMedidaTipoSchema>;
|
||||
|
||||
interface GMedidaTipoFormProps {
|
||||
isOpen: boolean;
|
||||
data: FormValues | null;
|
||||
onClose: (item: null, isFormStatus: boolean) => void;
|
||||
onSave: (data: FormValues) => void;
|
||||
}
|
||||
|
||||
export default function GMedidaTipoForm({ isOpen, data, onClose, onSave }: GMedidaTipoFormProps) {
|
||||
// Inicializa o react-hook-form com o schema Zod
|
||||
const form = useForm<FormValues>({
|
||||
resolver: zodResolver(GMedidaTipoSchema),
|
||||
defaultValues: {
|
||||
medida_tipo_id: 0,
|
||||
sigla: "",
|
||||
descricao: "",
|
||||
},
|
||||
});
|
||||
|
||||
// Atualiza o formulário quando recebe dados para edição
|
||||
useEffect(() => {
|
||||
if (data) form.reset(data);
|
||||
}, [data, form]);
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
open={isOpen}
|
||||
onOpenChange={(open) => {
|
||||
if (!open) onClose(null, false);
|
||||
}}
|
||||
>
|
||||
<DialogContent className="sm:max-w-[425px]">
|
||||
<DialogHeader>
|
||||
<DialogTitle>
|
||||
Tipo de Medida
|
||||
</DialogTitle>
|
||||
<DialogDescription>
|
||||
Crie ou edite um tipo de medida
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
|
||||
<Form {...form}>
|
||||
<form onSubmit={form.handleSubmit(onSave)} className="space-y-6">
|
||||
|
||||
{/* Descrição */}
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="descricao"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Descrição</FormLabel>
|
||||
<FormControl>
|
||||
<Input {...field} placeholder="Digite a descrição" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
{/* Sigla */}
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="sigla"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Sigla</FormLabel>
|
||||
<FormControl>
|
||||
<Input {...field} placeholder="Digite a sigla" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
{/* Rodapé do Dialog */}
|
||||
<DialogFooter className="mt-4">
|
||||
<DialogClose asChild>
|
||||
<Button variant="outline" type="button" onClick={() => onClose(null, false)} className="cursor-pointer">
|
||||
Cancelar
|
||||
</Button>
|
||||
</DialogClose>
|
||||
<Button type="submit" className="cursor-pointer">
|
||||
Salvar
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
|
||||
{/* Campo oculto */}
|
||||
<input type="hidden" {...form.register("medida_tipo_id")} />
|
||||
</form>
|
||||
</Form>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,96 @@
|
|||
'use client';
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuGroup,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableHead,
|
||||
TableHeader,
|
||||
TableRow
|
||||
} from "@/components/ui/table";
|
||||
import { EllipsisIcon, PencilIcon, Trash2Icon } from "lucide-react";
|
||||
import { GMedidaTipoInterface } from "../../_interfaces/GMedidaTipoInterface";
|
||||
|
||||
interface GMedidaTipoTableProps {
|
||||
data: GMedidaTipoInterface[];
|
||||
onEdit: (item: GMedidaTipoInterface, isEditingFormStatus: boolean) => void;
|
||||
onDelete: (item: GMedidaTipoInterface, isEditingFormStatus: boolean) => void;
|
||||
}
|
||||
|
||||
export default function GMedidaTipoTable({
|
||||
data,
|
||||
onEdit,
|
||||
onDelete
|
||||
}: GMedidaTipoTableProps) {
|
||||
return (
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>#</TableHead>
|
||||
<TableHead>Descrição</TableHead>
|
||||
<TableHead>Sigla</TableHead>
|
||||
<TableHead className="text-right">Ações</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
|
||||
<TableBody>
|
||||
{data.map((item) => (
|
||||
<TableRow
|
||||
key={item.medida_tipo_id}
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<TableCell className="font-medium">
|
||||
{item.medida_tipo_id}
|
||||
</TableCell>
|
||||
<TableCell>{item.descricao}</TableCell>
|
||||
<TableCell>{item.sigla}</TableCell>
|
||||
<TableCell className="text-right">
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<EllipsisIcon />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
|
||||
<DropdownMenuContent side="left" align="start">
|
||||
<DropdownMenuGroup>
|
||||
<DropdownMenuItem
|
||||
className="cursor-pointer"
|
||||
onSelect={() => onEdit(item, true)}
|
||||
>
|
||||
<PencilIcon className="mr-2 h-4 w-4" />
|
||||
Editar
|
||||
</DropdownMenuItem>
|
||||
|
||||
<DropdownMenuSeparator />
|
||||
|
||||
<DropdownMenuItem
|
||||
className="cursor-pointer"
|
||||
onSelect={() => onDelete(item, true)}
|
||||
>
|
||||
<Trash2Icon className="mr-2 h-4 w-4" />
|
||||
Remover
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuGroup>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,132 @@
|
|||
'use client';
|
||||
|
||||
import z from "zod";
|
||||
import { useEffect, useState } from "react";
|
||||
import { useForm, Controller } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Checkbox } from "@/components/ui/checkbox";
|
||||
import {
|
||||
Dialog,
|
||||
DialogClose,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle
|
||||
} from "@/components/ui/dialog";
|
||||
import {
|
||||
Form,
|
||||
FormControl,
|
||||
FormField,
|
||||
FormItem,
|
||||
FormLabel,
|
||||
FormMessage
|
||||
} from "@/components/ui/form";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
|
||||
import { GTBBairroSchema } from "../../_schemas/GTBBairroSchema";
|
||||
import LoadingButton from "@/app/_components/loadingButton/LoadingButton";
|
||||
import { SituacoesEnum } from "@/enums/SituacoesEnum";
|
||||
|
||||
type FormValues = z.infer<typeof GTBBairroSchema>;
|
||||
|
||||
interface GTBBairroFormProps {
|
||||
isOpen: boolean;
|
||||
data: FormValues | null;
|
||||
onClose: (item: null, isFormStatus: boolean) => void;
|
||||
onSave: (data: FormValues) => void;
|
||||
buttonIsLoading: boolean;
|
||||
}
|
||||
|
||||
export default function GTBBairroForm({ isOpen, data, onClose, onSave, buttonIsLoading }: GTBBairroFormProps) {
|
||||
|
||||
// Inicializa o react-hook-form com o schema Zod
|
||||
const form = useForm<FormValues>({
|
||||
resolver: zodResolver(GTBBairroSchema),
|
||||
defaultValues: {
|
||||
sistema_id: null,
|
||||
tb_bairro_id: 0,
|
||||
descricao: "",
|
||||
situacao: SituacoesEnum.A,
|
||||
},
|
||||
});
|
||||
|
||||
// Atualiza o formulário quando recebe dados para edição
|
||||
useEffect(() => {
|
||||
if (data) form.reset(data);
|
||||
}, [data, form]);
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
open={isOpen}
|
||||
onOpenChange={(open) => {
|
||||
if (!open) onClose(null, false);
|
||||
}}
|
||||
>
|
||||
<DialogContent className="sm:max-w-[425px]">
|
||||
<DialogHeader>
|
||||
<DialogTitle>
|
||||
Bairro
|
||||
</DialogTitle>
|
||||
<DialogDescription>
|
||||
Crie ou edite um bairro
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
|
||||
<Form {...form}>
|
||||
<form onSubmit={form.handleSubmit(onSave)} className="space-y-6">
|
||||
|
||||
{/* Descrição */}
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="descricao"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Descrição</FormLabel>
|
||||
<FormControl>
|
||||
<Input {...field} placeholder="Digite a descrição do bairro" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
{/* Situação */}
|
||||
<Controller
|
||||
name="situacao"
|
||||
control={form.control}
|
||||
render={({ field }) => (
|
||||
<div className="flex items-center space-x-2">
|
||||
<Checkbox
|
||||
checked={field.value === "A"}
|
||||
onCheckedChange={(checked) => field.onChange(checked ? "A" : "I")}
|
||||
/>
|
||||
<Label>Ativo</Label>
|
||||
</div>
|
||||
)}
|
||||
/>
|
||||
|
||||
{/* Rodapé do Dialog */}
|
||||
<DialogFooter className="mt-4">
|
||||
<DialogClose asChild>
|
||||
<Button variant="outline" type="button" onClick={() => onClose(null, false)} className="cursor-pointer">
|
||||
Cancelar
|
||||
</Button>
|
||||
</DialogClose>
|
||||
{/* Botão de loading */}
|
||||
<LoadingButton text="Salvar" textLoading="Aguarde..." type="submit" loading={buttonIsLoading} />
|
||||
</DialogFooter>
|
||||
|
||||
{/* Campos ocultos */}
|
||||
<input type="hidden" {...form.register("tb_bairro_id")} />
|
||||
<input type="hidden" {...form.register("sistema_id")} />
|
||||
|
||||
</form>
|
||||
</Form>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,123 @@
|
|||
'use client';
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuGroup,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableHead,
|
||||
TableHeader,
|
||||
TableRow
|
||||
} from "@/components/ui/table";
|
||||
import { EllipsisIcon, PencilIcon, Trash2Icon } from "lucide-react";
|
||||
import { GTBBairroInterface } from "../../_interfaces/GTBBairroInterface";
|
||||
|
||||
interface GTBBairroTableProps {
|
||||
data: GTBBairroInterface[];
|
||||
onEdit: (item: GTBBairroInterface, isEditingFormStatus: boolean) => void;
|
||||
onDelete: (item: GTBBairroInterface, isEditingFormStatus: boolean) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renderiza o badge de situação
|
||||
*/
|
||||
function StatusBadge({ situacao }: { situacao: 'A' | 'I' }) {
|
||||
const isActive = situacao === "A";
|
||||
|
||||
const baseClasses =
|
||||
"text-xs font-medium px-2.5 py-0.5 rounded-sm me-2";
|
||||
|
||||
const activeClasses =
|
||||
"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-300";
|
||||
|
||||
const inactiveClasses =
|
||||
"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300";
|
||||
|
||||
return (
|
||||
<span className={`${baseClasses} ${isActive ? activeClasses : inactiveClasses}`}>
|
||||
{isActive ? "Ativo" : "Inativo"}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
export default function GTBBairroTable({
|
||||
data,
|
||||
onEdit,
|
||||
onDelete
|
||||
}: GTBBairroTableProps) {
|
||||
return (
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>#</TableHead>
|
||||
<TableHead>Situação</TableHead>
|
||||
<TableHead>Descrição</TableHead>
|
||||
<TableHead className="text-right">Ações</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
|
||||
<TableBody>
|
||||
{data.map((item) => (
|
||||
<TableRow
|
||||
key={item.tb_bairro_id}
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<TableCell className="font-medium">
|
||||
{item.tb_bairro_id}
|
||||
</TableCell>
|
||||
|
||||
<TableCell>
|
||||
<StatusBadge situacao={item.situacao} />
|
||||
</TableCell>
|
||||
|
||||
<TableCell>{item.descricao}</TableCell>
|
||||
|
||||
<TableCell className="text-right">
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<EllipsisIcon />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
|
||||
<DropdownMenuContent side="left" align="start">
|
||||
<DropdownMenuGroup>
|
||||
<DropdownMenuItem
|
||||
className="cursor-pointer"
|
||||
onSelect={() => onEdit(item, true)}
|
||||
>
|
||||
<PencilIcon className="mr-2 h-4 w-4" />
|
||||
Editar
|
||||
</DropdownMenuItem>
|
||||
|
||||
<DropdownMenuSeparator />
|
||||
|
||||
<DropdownMenuItem
|
||||
className="cursor-pointer"
|
||||
onSelect={() => onDelete(item, true)}
|
||||
>
|
||||
<Trash2Icon className="mr-2 h-4 w-4" />
|
||||
Remover
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuGroup>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,129 @@
|
|||
'use client';
|
||||
|
||||
import z from "zod";
|
||||
import { useEffect } from "react";
|
||||
import { useForm, Controller } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Checkbox } from "@/components/ui/checkbox";
|
||||
import {
|
||||
Dialog,
|
||||
DialogClose,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle
|
||||
} from "@/components/ui/dialog";
|
||||
import {
|
||||
Form,
|
||||
FormControl,
|
||||
FormField,
|
||||
FormItem,
|
||||
FormLabel,
|
||||
FormMessage
|
||||
} from "@/components/ui/form";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
|
||||
import { GTBEstadoCivilSchema } from "../../_schemas/GTBEstadoCivilSchema";
|
||||
import { GTBEstadoCivilInterface } from "../../_interfaces/GTBEstadoCivilInterface";
|
||||
|
||||
type FormValues = z.infer<typeof GTBEstadoCivilSchema>;
|
||||
|
||||
interface TBEstadoCivilFormProps {
|
||||
isOpen: boolean;
|
||||
data: FormValues | null;
|
||||
onClose: (item: null, isFormStatus: boolean) => void;
|
||||
onSave: (data: FormValues) => void;
|
||||
}
|
||||
|
||||
export default function GTBEstadoCivilForm({ isOpen, data, onClose, onSave }: TBEstadoCivilFormProps) {
|
||||
// Inicializa o react-hook-form com o schema Zod
|
||||
const form = useForm<FormValues>({
|
||||
resolver: zodResolver(GTBEstadoCivilSchema),
|
||||
defaultValues: {
|
||||
tb_estadocivil_id: 0,
|
||||
sistema_id: 0,
|
||||
descricao: "",
|
||||
situacao: "A",
|
||||
},
|
||||
});
|
||||
|
||||
// Atualiza o formulário quando recebe dados para edição
|
||||
useEffect(() => {
|
||||
if (data) form.reset(data);
|
||||
}, [data, form]);
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
open={isOpen}
|
||||
onOpenChange={(open) => {
|
||||
if (!open) onClose(null, false);
|
||||
}}
|
||||
>
|
||||
<DialogContent className="sm:max-w-[425px]">
|
||||
<DialogHeader>
|
||||
<DialogTitle>
|
||||
Estado Civil
|
||||
</DialogTitle>
|
||||
<DialogDescription>
|
||||
Crie ou edite um estado civil
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
|
||||
<Form {...form}>
|
||||
<form onSubmit={form.handleSubmit(onSave)} className="space-y-6">
|
||||
|
||||
{/* Descrição */}
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="descricao"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Descrição</FormLabel>
|
||||
<FormControl>
|
||||
<Input {...field} placeholder="Digite a descrição" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
{/* Situação */}
|
||||
<Controller
|
||||
name="situacao"
|
||||
control={form.control}
|
||||
render={({ field }) => (
|
||||
<div className="flex items-center space-x-2">
|
||||
<Checkbox
|
||||
checked={field.value === "A"}
|
||||
onCheckedChange={(checked) => field.onChange(checked ? "A" : "I")}
|
||||
/>
|
||||
<Label>Ativo</Label>
|
||||
</div>
|
||||
)}
|
||||
/>
|
||||
|
||||
{/* Rodapé do Dialog */}
|
||||
<DialogFooter className="mt-4">
|
||||
<DialogClose asChild>
|
||||
<Button variant="outline" type="button" onClick={() => onClose(null, false)} className="cursor-pointer">
|
||||
Cancelar
|
||||
</Button>
|
||||
</DialogClose>
|
||||
<Button type="submit" className="cursor-pointer">
|
||||
Salvar
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
|
||||
{/* Campos ocultos */}
|
||||
<input type="hidden" {...form.register("tb_estadocivil_id", { valueAsNumber: true })} />
|
||||
<input type="hidden" {...form.register("sistema_id", { valueAsNumber: true })} />
|
||||
</form>
|
||||
</Form>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,123 @@
|
|||
'use client';
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuGroup,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableHead,
|
||||
TableHeader,
|
||||
TableRow
|
||||
} from "@/components/ui/table";
|
||||
import { EllipsisIcon, PencilIcon, Trash2Icon } from "lucide-react";
|
||||
import { GTBEstadoCivilInterface } from "../../_interfaces/GTBEstadoCivilInterface";
|
||||
|
||||
interface TBEstadoCivilTableProps {
|
||||
data: GTBEstadoCivilInterface[];
|
||||
onEdit: (item: GTBEstadoCivilInterface, isEditingFormStatus: boolean) => void;
|
||||
onDelete: (item: GTBEstadoCivilInterface, isEditingFormStatus: boolean) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renderiza o badge de situação
|
||||
*/
|
||||
function StatusBadge({ situacao }: { situacao: 'A' | 'I' }) {
|
||||
const isActive = situacao === "A";
|
||||
|
||||
const baseClasses =
|
||||
"text-xs font-medium px-2.5 py-0.5 rounded-sm me-2";
|
||||
|
||||
const activeClasses =
|
||||
"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-300";
|
||||
|
||||
const inactiveClasses =
|
||||
"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300";
|
||||
|
||||
return (
|
||||
<span className={`${baseClasses} ${isActive ? activeClasses : inactiveClasses}`}>
|
||||
{isActive ? "Ativo" : "Inativo"}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
export default function GTBEstadoCivilTable({
|
||||
data,
|
||||
onEdit,
|
||||
onDelete
|
||||
}: TBEstadoCivilTableProps) {
|
||||
return (
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>#</TableHead>
|
||||
<TableHead>Situação</TableHead>
|
||||
<TableHead>Descrição</TableHead>
|
||||
<TableHead className="text-right">Ações</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
|
||||
<TableBody>
|
||||
{data.map((item) => (
|
||||
<TableRow
|
||||
key={item.tb_estadocivil_id}
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<TableCell className="font-medium">
|
||||
{item.tb_estadocivil_id}
|
||||
</TableCell>
|
||||
|
||||
<TableCell>
|
||||
<StatusBadge situacao={item.situacao} />
|
||||
</TableCell>
|
||||
|
||||
<TableCell>{item.descricao}</TableCell>
|
||||
|
||||
<TableCell className="text-right">
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<EllipsisIcon />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
|
||||
<DropdownMenuContent side="left" align="start">
|
||||
<DropdownMenuGroup>
|
||||
<DropdownMenuItem
|
||||
className="cursor-pointer"
|
||||
onSelect={() => onEdit(item, true)}
|
||||
>
|
||||
<PencilIcon className="mr-2 h-4 w-4" />
|
||||
Editar
|
||||
</DropdownMenuItem>
|
||||
|
||||
<DropdownMenuSeparator />
|
||||
|
||||
<DropdownMenuItem
|
||||
className="cursor-pointer"
|
||||
onSelect={() => onDelete(item, true)}
|
||||
>
|
||||
<Trash2Icon className="mr-2 h-4 w-4" />
|
||||
Remover
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuGroup>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,143 @@
|
|||
'use client';
|
||||
|
||||
import z from "zod";
|
||||
import { useEffect } from "react";
|
||||
import { useForm, Controller } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Checkbox } from "@/components/ui/checkbox";
|
||||
import {
|
||||
Dialog,
|
||||
DialogClose,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle
|
||||
} from "@/components/ui/dialog";
|
||||
import {
|
||||
Form,
|
||||
FormControl,
|
||||
FormField,
|
||||
FormItem,
|
||||
FormLabel,
|
||||
FormMessage
|
||||
} from "@/components/ui/form";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
|
||||
import { GTBProfissaoSchema } from "../../_schemas/GTBProfissaoSchema";
|
||||
|
||||
type FormValues = z.infer<typeof GTBProfissaoSchema>;
|
||||
|
||||
interface Props {
|
||||
isOpen: boolean;
|
||||
data: FormValues | null;
|
||||
onClose: (item: null, isFormStatus: boolean) => void;
|
||||
onSave: (data: FormValues) => void;
|
||||
}
|
||||
|
||||
export default function GTBProfissaoForm({ isOpen, data, onClose, onSave }: Props) {
|
||||
// Inicializa o react-hook-form com schema zod
|
||||
const form = useForm<FormValues>({
|
||||
resolver: zodResolver(GTBProfissaoSchema),
|
||||
defaultValues: {
|
||||
descricao: "",
|
||||
cod_cbo: "",
|
||||
situacao: "A",
|
||||
tb_profissao_id: 0,
|
||||
},
|
||||
});
|
||||
|
||||
// Atualiza o formulário quando recebe dados para edição
|
||||
useEffect(() => {
|
||||
if (data) form.reset(data);
|
||||
}, [data, form]);
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
open={isOpen}
|
||||
onOpenChange={(open) => {
|
||||
if (!open) onClose(null, false);
|
||||
}}
|
||||
>
|
||||
<DialogContent className="sm:max-w-[425px]">
|
||||
|
||||
<DialogHeader>
|
||||
<DialogTitle>
|
||||
Profissões
|
||||
</DialogTitle>
|
||||
<DialogDescription>
|
||||
Controle de profissões
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
|
||||
<Form {...form}>
|
||||
<form onSubmit={form.handleSubmit(onSave)} className="space-y-6">
|
||||
|
||||
{/* Descrição */}
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="descricao"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Descrição</FormLabel>
|
||||
<FormControl>
|
||||
<Input type="text" {...field} placeholder="Digite a descrição" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
{/* CBO */}
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="cod_cbo"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>CBO</FormLabel>
|
||||
<FormControl>
|
||||
<Input type="nubmer" {...field} placeholder="Digite o código" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
{/* Situação */}
|
||||
<Controller
|
||||
name="situacao"
|
||||
control={form.control}
|
||||
render={({ field }) => (
|
||||
<div className="flex items-center space-x-2">
|
||||
<Checkbox
|
||||
checked={field.value === "A"}
|
||||
onCheckedChange={(checked) => field.onChange(checked ? "A" : "I")}
|
||||
/>
|
||||
<Label>Ativo</Label>
|
||||
</div>
|
||||
)}
|
||||
/>
|
||||
|
||||
{/* Rodapé do Dialog */}
|
||||
<DialogFooter className="mt-4">
|
||||
<DialogClose asChild>
|
||||
<Button variant="outline" type="button" onClick={() => onClose(null, false)} className="cursor-pointer">
|
||||
Cancelar
|
||||
</Button>
|
||||
</DialogClose>
|
||||
<Button type="submit" className="cursor-pointer">
|
||||
Salvar
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
|
||||
{/* Campo oculto */}
|
||||
<input type="hidden" {...form.register("tb_profissao_id")} />
|
||||
</form>
|
||||
</Form>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,129 @@
|
|||
'use client';
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuGroup,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableHead,
|
||||
TableHeader,
|
||||
TableRow
|
||||
} from "@/components/ui/table";
|
||||
|
||||
import { EllipsisIcon, PencilIcon, Trash2Icon } from "lucide-react";
|
||||
import GTBProfissaoInterface from "../../_interfaces/GTBProfissaoInterface";
|
||||
|
||||
interface GTBProfissaoTableProps {
|
||||
data: GTBProfissaoInterface[];
|
||||
onEdit: (item: GTBProfissaoInterface, isEditingFormStatus: boolean) => void;
|
||||
onDelete: (item: GTBProfissaoInterface, isEditingFormStatus: boolean) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renderiza o badge de situação
|
||||
*/
|
||||
function StatusBadge({ situacao }: { situacao: string }) {
|
||||
const isActive = situacao === "A";
|
||||
|
||||
const baseClasses =
|
||||
"text-xs font-medium px-2.5 py-0.5 rounded-sm me-2";
|
||||
|
||||
const activeClasses =
|
||||
"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-300";
|
||||
|
||||
const inactiveClasses =
|
||||
"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300";
|
||||
|
||||
return (
|
||||
<span className={`${baseClasses} ${isActive ? activeClasses : inactiveClasses}`}>
|
||||
{isActive ? "Ativo" : "Inativo"}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
export default function GTBProfissaoTable({
|
||||
data,
|
||||
onEdit,
|
||||
onDelete
|
||||
}: GTBProfissaoTableProps) {
|
||||
return (
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>#</TableHead>
|
||||
<TableHead>Situação</TableHead>
|
||||
<TableHead>CBO</TableHead>
|
||||
<TableHead>Descrição</TableHead>
|
||||
<TableHead className="text-right">Ações</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
|
||||
<TableBody>
|
||||
{data.map((item) => (
|
||||
<TableRow
|
||||
key={item.tb_profissao_id}
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<TableCell className="font-medium">
|
||||
{item.tb_profissao_id}
|
||||
</TableCell>
|
||||
|
||||
<TableCell>
|
||||
<StatusBadge situacao={item.situacao} />
|
||||
</TableCell>
|
||||
|
||||
<TableCell className="font-medium">
|
||||
{item.cod_cbo}
|
||||
</TableCell>
|
||||
|
||||
<TableCell>{item.descricao}</TableCell>
|
||||
|
||||
<TableCell className="text-right">
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<EllipsisIcon />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
|
||||
<DropdownMenuContent side="left" align="start">
|
||||
<DropdownMenuGroup>
|
||||
<DropdownMenuItem
|
||||
className="cursor-pointer"
|
||||
onSelect={() => onEdit(item, true)}
|
||||
>
|
||||
<PencilIcon className="mr-2 h-4 w-4" />
|
||||
Editar
|
||||
</DropdownMenuItem>
|
||||
|
||||
<DropdownMenuSeparator />
|
||||
|
||||
<DropdownMenuItem
|
||||
className="cursor-pointer"
|
||||
onSelect={() => onDelete(item, true)}
|
||||
>
|
||||
<Trash2Icon className="mr-2 h-4 w-4" />
|
||||
Remover
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuGroup>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,127 @@
|
|||
'use client';
|
||||
|
||||
import z from "zod";
|
||||
import { useForm, Controller } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Checkbox } from "@/components/ui/checkbox";
|
||||
import {
|
||||
Dialog,
|
||||
DialogClose,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle
|
||||
} from "@/components/ui/dialog";
|
||||
import {
|
||||
Form,
|
||||
FormControl,
|
||||
FormField,
|
||||
FormItem,
|
||||
FormLabel,
|
||||
FormMessage
|
||||
} from "@/components/ui/form";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
|
||||
import { GTBRegimeBensSchema } from "../../_schemas/GTBRegimeBensSchema";
|
||||
import { useEffect } from "react";
|
||||
|
||||
type FormValues = z.infer<typeof GTBRegimeBensSchema>;
|
||||
|
||||
interface Props {
|
||||
isOpen: boolean;
|
||||
data: FormValues | null;
|
||||
onClose: (item: null, isFormStatus: boolean) => void;
|
||||
onSave: (data: FormValues) => void;
|
||||
}
|
||||
|
||||
export default function GTBRegimeComunhaoForm({ isOpen, data, onClose, onSave }: Props) {
|
||||
|
||||
// Inicializa o react-hook-form com schema zod
|
||||
const form = useForm<FormValues>({
|
||||
resolver: zodResolver(GTBRegimeBensSchema),
|
||||
defaultValues: {
|
||||
tb_regimebens_id: 0,
|
||||
descricao: "",
|
||||
situacao: "",
|
||||
},
|
||||
});
|
||||
|
||||
// Atualiza o formulário quando recebe dados para edição
|
||||
useEffect(() => {
|
||||
if (data) form.reset(data);
|
||||
}, [data, form]);
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
open={isOpen}
|
||||
onOpenChange={(open) => {
|
||||
if (!open) onClose(null, false);
|
||||
}}
|
||||
>
|
||||
<DialogContent className="sm:max-w-[425px]">
|
||||
<DialogHeader>
|
||||
<DialogTitle>
|
||||
Regimes de Bens
|
||||
</DialogTitle>
|
||||
<DialogDescription>
|
||||
Controle de Regimes de Vens
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
|
||||
<Form {...form}>
|
||||
<form onSubmit={form.handleSubmit(onSave)} className="space-y-6">
|
||||
|
||||
{/* Descrição */}
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="descricao"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Descrição</FormLabel>
|
||||
<FormControl>
|
||||
<Input {...field} placeholder="Digite a descrição" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
{/* Situação */}
|
||||
<Controller
|
||||
name="situacao"
|
||||
control={form.control}
|
||||
render={({ field }) => (
|
||||
<div className="flex items-center space-x-2">
|
||||
<Checkbox
|
||||
checked={field.value === "A"}
|
||||
onCheckedChange={(checked) => field.onChange(checked ? "A" : "I")}
|
||||
/>
|
||||
<Label>Ativo</Label>
|
||||
</div>
|
||||
)}
|
||||
/>
|
||||
|
||||
{/* Rodapé do Dialog */}
|
||||
<DialogFooter className="mt-4">
|
||||
<DialogClose asChild>
|
||||
<Button variant="outline" type="button" onClick={() => onClose(null, false)} className="cursor-pointer">
|
||||
Cancelar
|
||||
</Button>
|
||||
</DialogClose>
|
||||
<Button type="submit" className="cursor-pointer">
|
||||
Salvar
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
|
||||
{/* Campo oculto */}
|
||||
<input type="hidden" {...form.register("tb_regimebens_id")} />
|
||||
</form>
|
||||
</Form>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,126 @@
|
|||
'use client';
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuGroup,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableHead,
|
||||
TableHeader,
|
||||
TableRow
|
||||
} from "@/components/ui/table";
|
||||
|
||||
import { EllipsisIcon, PencilIcon, Trash2Icon } from "lucide-react";
|
||||
import GTBRegimeBensInterface from "../../_interfaces/GTBRegimeBensInterface";
|
||||
|
||||
interface GTBRegimeBensTableProps {
|
||||
data: GTBRegimeBensInterface[];
|
||||
onEdit: (item: GTBRegimeBensInterface, isEditingFormStatus: boolean) => void;
|
||||
onDelete: (item: GTBRegimeBensInterface, isEditingFormStatus: boolean) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renderiza o badge de situação
|
||||
*/
|
||||
function StatusBadge({ situacao }: { situacao: string }) {
|
||||
const isActive = situacao === "A";
|
||||
|
||||
const baseClasses =
|
||||
"text-xs font-medium px-2.5 py-0.5 rounded-sm me-2";
|
||||
|
||||
const activeClasses =
|
||||
"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-300";
|
||||
|
||||
const inactiveClasses =
|
||||
"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300";
|
||||
|
||||
return (
|
||||
<span className={`${baseClasses} ${isActive ? activeClasses : inactiveClasses}`}>
|
||||
{isActive ? "Ativo" : "Inativo"}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
export default function GTBRegimeBensTable({
|
||||
data,
|
||||
onEdit,
|
||||
onDelete
|
||||
}: GTBRegimeBensTableProps) {
|
||||
return (
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>#</TableHead>
|
||||
<TableHead>Situação</TableHead>
|
||||
<TableHead>Descrição</TableHead>
|
||||
<TableHead className="text-right">Ações</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
|
||||
<TableBody>
|
||||
{data.map((item) => (
|
||||
<TableRow
|
||||
key={item.tb_regimebens_id}
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<TableCell className="font-medium">
|
||||
{item.tb_regimebens_id}
|
||||
</TableCell>
|
||||
|
||||
<TableCell>
|
||||
<StatusBadge situacao={item.situacao} />
|
||||
</TableCell>
|
||||
|
||||
<TableCell>
|
||||
{item.descricao}
|
||||
</TableCell>
|
||||
|
||||
<TableCell className="text-right">
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<EllipsisIcon />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
|
||||
<DropdownMenuContent side="left" align="start">
|
||||
<DropdownMenuGroup>
|
||||
<DropdownMenuItem
|
||||
className="cursor-pointer"
|
||||
onSelect={() => onEdit(item, true)}
|
||||
>
|
||||
<PencilIcon className="mr-2 h-4 w-4" />
|
||||
Editar
|
||||
</DropdownMenuItem>
|
||||
|
||||
<DropdownMenuSeparator />
|
||||
|
||||
<DropdownMenuItem
|
||||
className="cursor-pointer"
|
||||
onSelect={() => onDelete(item, true)}
|
||||
>
|
||||
<Trash2Icon className="mr-2 h-4 w-4" />
|
||||
Remover
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuGroup>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,189 @@
|
|||
'use client';
|
||||
|
||||
import z from "zod";
|
||||
import { useEffect } from "react";
|
||||
import { useForm, Controller } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Checkbox } from "@/components/ui/checkbox";
|
||||
import {
|
||||
Dialog,
|
||||
DialogClose,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle
|
||||
} from "@/components/ui/dialog";
|
||||
import {
|
||||
Form,
|
||||
FormControl,
|
||||
FormField,
|
||||
FormItem,
|
||||
FormLabel,
|
||||
FormMessage
|
||||
} from "@/components/ui/form";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
|
||||
import { GTBRegimeComunhaoSchema } from "../../_schemas/GTBRegimeComunhaoSchema";
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
||||
import { useGTBRegimeBensReadHook } from "../../_hooks/g_tb_regimebens/useGTBRegimeBensReadHook";
|
||||
|
||||
type FormValues = z.infer<typeof GTBRegimeComunhaoSchema>;
|
||||
|
||||
interface Props {
|
||||
isOpen: boolean;
|
||||
data: FormValues | null;
|
||||
onClose: (item: null, isFormStatus: boolean) => void;
|
||||
onSave: (data: FormValues) => void;
|
||||
}
|
||||
|
||||
export default function GTBRegimeComunhaoForm({ isOpen, data, onClose, onSave }: Props) {
|
||||
|
||||
const { gTBRegimeBens, fetchGTBRegimeBens } = useGTBRegimeBensReadHook();
|
||||
|
||||
// Inicializa o react-hook-form com schema zod
|
||||
const form = useForm<FormValues>({
|
||||
resolver: zodResolver(GTBRegimeComunhaoSchema),
|
||||
defaultValues: {
|
||||
tb_regimecomunhao_id: 0,
|
||||
tb_regimebens_id: 0,
|
||||
descricao: "",
|
||||
texto: "",
|
||||
situacao: "",
|
||||
},
|
||||
});
|
||||
|
||||
// Atualiza o formulário quando recebe dados para edição
|
||||
useEffect(() => {
|
||||
|
||||
const loadData = async () => {
|
||||
// Se existir dados, reseta o formulário com os dados informados
|
||||
if (data) form.reset(data);
|
||||
|
||||
// Aguarda a busca terminar
|
||||
await fetchGTBRegimeBens();
|
||||
};
|
||||
|
||||
// Dispara a função
|
||||
loadData();
|
||||
|
||||
}, [data, form]);
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
open={isOpen}
|
||||
onOpenChange={(open) => {
|
||||
if (!open) onClose(null, false);
|
||||
}}
|
||||
>
|
||||
<DialogContent className="sm:max-w-[425px]">
|
||||
<DialogHeader>
|
||||
<DialogTitle>
|
||||
Regimes de Comunhão
|
||||
</DialogTitle>
|
||||
<DialogDescription>
|
||||
Controle de Regimes de Comunhão
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
|
||||
<Form {...form}>
|
||||
<form onSubmit={form.handleSubmit(onSave)} className="space-y-6">
|
||||
|
||||
{/* Descrição */}
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="descricao"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Descrição</FormLabel>
|
||||
<FormControl>
|
||||
<Input {...field} placeholder="Digite a descrição" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
{/* Texto */}
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="texto"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Texto</FormLabel>
|
||||
<FormControl>
|
||||
<Input {...field} placeholder="Digite o texto" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
{/* Tipo */}
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="tb_regimebens_id"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Tipo</FormLabel>
|
||||
<Select
|
||||
value={String(field.value)}
|
||||
// Converter o valor inteiro para ser aceito pelo zod
|
||||
onValueChange={(val) => field.onChange(Number(val))}
|
||||
>
|
||||
<FormControl className="w-full">
|
||||
<SelectTrigger>
|
||||
<SelectValue placeholder="Escolha o tipo do andamento" />
|
||||
</SelectTrigger>
|
||||
</FormControl>
|
||||
<SelectContent>
|
||||
{gTBRegimeBens.map((item) => (
|
||||
<SelectItem key={item.tb_regimebens_id} value={String(item.tb_regimebens_id)}>
|
||||
{item.descricao}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
{/* Situação */}
|
||||
<Controller
|
||||
name="situacao"
|
||||
control={form.control}
|
||||
render={({ field }) => (
|
||||
<div className="flex items-center space-x-2">
|
||||
<Checkbox
|
||||
checked={field.value === "A"}
|
||||
onCheckedChange={(checked) => field.onChange(checked ? "A" : "I")}
|
||||
/>
|
||||
<Label>Ativo</Label>
|
||||
</div>
|
||||
)}
|
||||
/>
|
||||
|
||||
{/* Rodapé do Dialog */}
|
||||
<DialogFooter className="mt-4">
|
||||
<DialogClose asChild>
|
||||
<Button variant="outline" type="button" onClick={() => onClose(null, false)} className="cursor-pointer">
|
||||
Cancelar
|
||||
</Button>
|
||||
</DialogClose>
|
||||
<Button type="submit" className="cursor-pointer">
|
||||
Salvar
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
|
||||
{/* Campo oculto */}
|
||||
<input type="hidden" {...form.register("tb_regimecomunhao_id")} />
|
||||
</form>
|
||||
</Form>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue