Compare commits
200 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b664221d5d | ||
|
|
c3511a7065 | ||
|
|
5ef46780a5 | ||
|
|
fd79837fdc | ||
|
|
b5ea5a75a8 | ||
|
|
4561194b6b | ||
|
|
c8863e573f | ||
|
|
fca1d0c293 | ||
|
|
32937c9501 | ||
|
|
790dbe2df3 | ||
|
|
4770c42596 | ||
|
|
aceb17b235 | ||
|
|
21d5d94197 | ||
|
|
8f9659ea5b | ||
|
|
e39970587b | ||
|
|
bcbcc8557b | ||
|
|
f6f4892d09 | ||
|
|
1e9627e924 | ||
|
|
f23decf071 | ||
|
|
43d0863342 | ||
|
|
e24a35709b | ||
|
|
3eb0bd6f0e | ||
|
|
c6217b0520 | ||
|
|
7a2305c918 | ||
|
|
26f0016813 | ||
|
|
0ec57bd6f8 | ||
|
|
50814c9b14 | ||
|
|
2f891ffc38 | ||
|
|
52d16a1548 | ||
|
|
26df474611 | ||
|
|
cdc5e953a5 | ||
|
|
f1abddb383 | ||
|
|
824ac5da24 | ||
|
|
386b8b0307 | ||
|
|
a400bd233e | ||
|
|
60dce3876a | ||
|
|
7745961ff6 | ||
|
|
69d34c713e | ||
|
|
91346bfb19 | ||
|
|
d2494f20b7 | ||
|
|
4ef0517cb7 | ||
|
|
714a0e1f97 | ||
|
|
df46a60b81 | ||
|
|
0dc065d9bb | ||
|
|
99791bd06f | ||
|
|
5f8d2cf670 | ||
|
|
369dfcdfc3 | ||
|
|
f4b0118b36 | ||
|
|
053b86ee69 | ||
|
|
f7b13648a1 | ||
|
|
744e51d215 | ||
|
|
41f31ed2f1 | ||
|
|
0e3cb35309 | ||
|
|
24e259fc16 | ||
|
|
6fc76254c0 | ||
|
|
1c4d52ebe9 | ||
|
|
6e4646c96b | ||
|
|
f09b152192 | ||
|
|
ff3ff6c2e0 | ||
|
|
dfee9eb752 | ||
|
|
e01fa690a3 | ||
|
|
f9df3cd8a3 | ||
|
|
e98a293286 | ||
|
|
4c16b19184 | ||
|
|
de3a022800 | ||
|
|
4da16c3fe2 | ||
|
|
d1732558ff | ||
|
|
58630f8602 | ||
|
|
6b6f2e4fc8 | ||
|
|
2d37d4d421 | ||
|
|
fdd4cf7cfc | ||
|
|
bc2c2ef3dd | ||
|
|
b2e0d50dd6 | ||
|
|
97c958cb00 | ||
|
|
6fe6c86b5d | ||
|
|
b85cd6aeb9 | ||
|
|
88cb6f67c8 | ||
|
|
790c79ede6 | ||
|
|
06d55ec125 | ||
| e50818e52a | |||
| 79f2092882 | |||
| 8d44686717 | |||
| 7162a20d1f | |||
| b362968a4f | |||
| 23604033fe | |||
| 4b7afd6a8f | |||
| feab092f6e | |||
| e39422776e | |||
| 8e035546e9 | |||
| 6051afc3e0 | |||
| 9b9f8b9454 | |||
| 2340cee82a | |||
| 0e21ebfe5b | |||
| 3faf0ebe5e | |||
| b9318f1059 | |||
| 64b897e7e9 | |||
| 77ea800aaa | |||
| 2810abecf5 | |||
| 325ca69317 | |||
| d5b8aad221 | |||
| d3d8ac4a28 | |||
| 8d5e786f74 | |||
| 5297d6ab2e | |||
| 56bca3ba41 | |||
| ab45ac32bf | |||
| 36cbd43ee4 | |||
| b48ffc4bd5 | |||
| 3bd3134d33 | |||
| aaaa04975e | |||
| 519dbf969a | |||
| 4559de0187 | |||
| 6c7967587a | |||
| 742c9bc38f | |||
| a26fc881b2 | |||
| d3f8bebe1d | |||
| 11578438bf | |||
| cbaf19af0b | |||
| ff28fe1f58 | |||
| 9e37520615 | |||
| 79370f83f1 | |||
| cb3f1ffcba | |||
| 37f0f8713d | |||
| 0d5ee71975 | |||
| 27d0b7e2de | |||
| 3b38337358 | |||
| 36dba45995 | |||
|
|
7db6d27035 | ||
| aa8553b3fe | |||
| 75086c6103 | |||
| 3e68efe7ec | |||
| 847a1f0758 | |||
| 67453f1f99 | |||
| ae382f5399 | |||
| 4b0c7e651d | |||
| f2b2181136 | |||
| 8cb0de2928 | |||
| 89d12b26b5 | |||
| 8d9eed3c48 | |||
|
|
32924cd8da | ||
|
|
46d51e3316 | ||
|
|
66f285ba74 | ||
| 3633628bc5 | |||
| 8c5b847d37 | |||
| b3dc6c87f2 | |||
| f5ffe5739c | |||
| f6faae900d | |||
| 7f9b7944db | |||
| eed113590c | |||
| 3aa4c73453 | |||
| 1fcc5e442d | |||
| 7af4c82dd1 | |||
| 4eabe19ee3 | |||
| 1f8892e639 | |||
| 6f07d8493c | |||
| 8579387c53 | |||
| b91ce54475 | |||
|
|
727e665db4 | ||
|
|
ce6f6e3c59 | ||
| fb35c19a84 | |||
| 175dff5ded | |||
| 426a74f6f6 | |||
| 9b34ef16ac | |||
|
|
3df00e38bc | ||
|
|
7fe725bdeb | ||
| 47dfcf509f | |||
| de86ba1e7f | |||
| 931fb7e158 | |||
| b7f35889a6 | |||
| 3fe6ed8c08 | |||
| a045b3ca72 | |||
| 13aea0e161 | |||
| 8f8050ff09 | |||
| 127a8c235a | |||
| aa540f8fca | |||
| 595f690366 | |||
| 428322f32e | |||
| d801ef1a70 | |||
| 2c25f52994 | |||
| 94cc5d97aa | |||
| 920b9d8aa6 | |||
|
|
295b9b4d69 | ||
|
|
cc91b6a559 | ||
|
|
936ef7764e | ||
|
|
18c61c49e8 | ||
|
|
d3757c8ce3 | ||
|
|
04307a0aa4 | ||
| 1441789fe3 | |||
| fdec6a4768 | |||
| 7546ec90b3 | |||
| c7ff7f4aa4 | |||
| 2fd7af509f | |||
| f7ac0eb9df | |||
| 4ec2799fdc | |||
| af51c1b8d8 | |||
|
|
daeb956ef8 | ||
|
|
6c1e91035d | ||
|
|
46296ec8a9 | ||
|
|
6e80b5409a | ||
|
|
fefe94f7b1 | ||
|
|
0e35db30c0 |
1196 changed files with 48866 additions and 10949 deletions
117
.code-workspace
Normal file
117
.code-workspace
Normal file
|
|
@ -0,0 +1,117 @@
|
||||||
|
{
|
||||||
|
"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",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
}
|
||||||
9
.prettierrc
Normal file
9
.prettierrc
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
"semi": true,
|
||||||
|
"trailingComma": "all",
|
||||||
|
"singleQuote": true,
|
||||||
|
"printWidth": 100,
|
||||||
|
"tabWidth": 2,
|
||||||
|
"arrowParens": "always",
|
||||||
|
"plugins": ["prettier-plugin-tailwindcss"]
|
||||||
|
}
|
||||||
65
Dockerfile
65
Dockerfile
|
|
@ -1,22 +1,59 @@
|
||||||
# Use uma imagem Node.js completa para o desenvolvimento
|
# ============================
|
||||||
FROM node:20-alpine
|
# STAGE 1 – Build
|
||||||
|
# ============================
|
||||||
|
FROM node:20-alpine AS builder
|
||||||
|
|
||||||
# Define o diretório de trabalho no container
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Copia os arquivos de configuração do projeto
|
# Copia pacotes e instala dependências
|
||||||
COPY package.json package-lock.json ./
|
COPY package*.json ./
|
||||||
|
RUN npm ci
|
||||||
|
|
||||||
# Instala todas as dependências do projeto
|
# Copia o restante do código
|
||||||
# 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 . .
|
COPY . .
|
||||||
|
|
||||||
# Expõe a porta de desenvolvimento padrão do Next.js
|
# ---------- 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
|
||||||
|
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
|
|
||||||
# Define o comando para iniciar a aplicação em modo de desenvolvimento
|
# ---------- Executa o servidor ----------
|
||||||
# Isso ativará o servidor de desenvolvimento e a recarga automática
|
CMD ["node", "server.js"]
|
||||||
CMD ["npm", "run", "dev"]
|
|
||||||
|
|
|
||||||
|
|
@ -1,41 +0,0 @@
|
||||||
# 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,2 +1,58 @@
|
||||||
# saas_app
|
# 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>
|
||||||
|
|
|
||||||
|
|
@ -18,4 +18,4 @@
|
||||||
"hooks": "@/hooks"
|
"hooks": "@/hooks"
|
||||||
},
|
},
|
||||||
"iconLibrary": "lucide"
|
"iconLibrary": "lucide"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
70
eslint.config.mjs
Normal file
70
eslint.config.mjs
Normal file
|
|
@ -0,0 +1,70 @@
|
||||||
|
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,8 +1,17 @@
|
||||||
import type { NextConfig } from "next";
|
/** @type {import('next').NextConfig} */
|
||||||
|
const nextConfig = {
|
||||||
const nextConfig: NextConfig = {
|
// Gera build autônomo para rodar com "node server.js"
|
||||||
// Isso gera um diretório otimizado que inclui tudo o que a aplicação precisa para rodar
|
|
||||||
output: 'standalone',
|
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 },
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default nextConfig;
|
module.exports = nextConfig;
|
||||||
|
|
|
||||||
6975
package-lock.json
generated
6975
package-lock.json
generated
File diff suppressed because it is too large
Load diff
45
package.json
45
package.json
|
|
@ -1,16 +1,20 @@
|
||||||
{
|
{
|
||||||
"name": "app",
|
"type": "module",
|
||||||
|
"name": "saas",
|
||||||
"version": "25.9.1",
|
"version": "25.9.1",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "next dev --turbopack",
|
"dev": "next dev",
|
||||||
|
"dev:debug": "cross-env NEXT_USE_TURBOPACK=0 NODE_OPTIONS=\"--inspect=9230\" next dev",
|
||||||
"build": "next build",
|
"build": "next build",
|
||||||
"start": "next start",
|
"start": "next start",
|
||||||
"lint": "next lint"
|
"lint": "next lint",
|
||||||
|
"postinstall": "shx mkdir -p public/libs && shx cp -r node_modules/tinymce public/libs/tinymce"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@faker-js/faker": "^10.0.0",
|
"@faker-js/faker": "^10.0.0",
|
||||||
"@hookform/resolvers": "^5.2.1",
|
"@hookform/resolvers": "^5.2.1",
|
||||||
|
"@onlyoffice/document-editor-react": "^2.1.1",
|
||||||
"@radix-ui/react-alert-dialog": "^1.1.15",
|
"@radix-ui/react-alert-dialog": "^1.1.15",
|
||||||
"@radix-ui/react-avatar": "^1.1.10",
|
"@radix-ui/react-avatar": "^1.1.10",
|
||||||
"@radix-ui/react-checkbox": "^1.3.3",
|
"@radix-ui/react-checkbox": "^1.3.3",
|
||||||
|
|
@ -19,15 +23,25 @@
|
||||||
"@radix-ui/react-dropdown-menu": "^2.1.16",
|
"@radix-ui/react-dropdown-menu": "^2.1.16",
|
||||||
"@radix-ui/react-label": "^2.1.7",
|
"@radix-ui/react-label": "^2.1.7",
|
||||||
"@radix-ui/react-popover": "^1.1.15",
|
"@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-select": "^2.2.6",
|
||||||
"@radix-ui/react-separator": "^1.1.7",
|
"@radix-ui/react-separator": "^1.1.8",
|
||||||
"@radix-ui/react-slot": "^1.2.3",
|
"@radix-ui/react-slot": "^1.2.4",
|
||||||
|
"@radix-ui/react-switch": "^1.2.6",
|
||||||
|
"@radix-ui/react-tabs": "^1.1.13",
|
||||||
"@radix-ui/react-tooltip": "^1.2.8",
|
"@radix-ui/react-tooltip": "^1.2.8",
|
||||||
|
"@tanstack/react-table": "^8.21.3",
|
||||||
"@tinymce/tinymce-react": "^6.3.0",
|
"@tinymce/tinymce-react": "^6.3.0",
|
||||||
"class-variance-authority": "^0.7.1",
|
"class-variance-authority": "^0.7.1",
|
||||||
"clsx": "^2.1.1",
|
"clsx": "^2.1.1",
|
||||||
|
"cmdk": "^1.1.1",
|
||||||
"cookies-next": "^6.1.0",
|
"cookies-next": "^6.1.0",
|
||||||
|
"date-fns": "^3.6.0",
|
||||||
"faker-js": "^1.0.0",
|
"faker-js": "^1.0.0",
|
||||||
|
"framer-motion": "^12.23.24",
|
||||||
|
"input-otp": "^1.4.2",
|
||||||
"js-cookie": "^3.0.5",
|
"js-cookie": "^3.0.5",
|
||||||
"jsonwebtoken": "^9.0.2",
|
"jsonwebtoken": "^9.0.2",
|
||||||
"jwt-decode": "^4.0.0",
|
"jwt-decode": "^4.0.0",
|
||||||
|
|
@ -37,6 +51,8 @@
|
||||||
"react": "19.1.0",
|
"react": "19.1.0",
|
||||||
"react-dom": "19.1.0",
|
"react-dom": "19.1.0",
|
||||||
"react-hook-form": "^7.62.0",
|
"react-hook-form": "^7.62.0",
|
||||||
|
"react-masked-text": "^1.0.5",
|
||||||
|
"recharts": "^3.3.0",
|
||||||
"sonner": "^2.0.7",
|
"sonner": "^2.0.7",
|
||||||
"tailwind-merge": "^3.3.1",
|
"tailwind-merge": "^3.3.1",
|
||||||
"tinymce": "^8.1.2",
|
"tinymce": "^8.1.2",
|
||||||
|
|
@ -44,13 +60,30 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@tailwindcss/postcss": "^4",
|
"@tailwindcss/postcss": "^4",
|
||||||
|
"@types/date-fns": "^2.5.3",
|
||||||
"@types/js-cookie": "^3.0.6",
|
"@types/js-cookie": "^3.0.6",
|
||||||
"@types/jsonwebtoken": "^9.0.10",
|
"@types/jsonwebtoken": "^9.0.10",
|
||||||
"@types/node": "^20",
|
"@types/node": "^20",
|
||||||
"@types/react": "^19",
|
"@types/react": "^19",
|
||||||
"@types/react-dom": "^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",
|
"tailwindcss": "^4",
|
||||||
"tw-animate-css": "^1.3.7",
|
"tw-animate-css": "^1.3.7",
|
||||||
"typescript": "^5"
|
"typescript": "5.9.3",
|
||||||
|
"typescript-eslint": "^8.46.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
const config = {
|
const config = {
|
||||||
plugins: ["@tailwindcss/postcss"],
|
plugins: ['@tailwindcss/postcss'],
|
||||||
};
|
};
|
||||||
|
|
||||||
export default config;
|
export default config;
|
||||||
|
|
|
||||||
BIN
public/images/favicon.ico
Normal file
BIN
public/images/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 41 KiB |
BIN
public/images/logo-abb.png
Normal file
BIN
public/images/logo-abb.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.8 KiB |
BIN
public/modelo.docx
Normal file
BIN
public/modelo.docx
Normal file
Binary file not shown.
BIN
public/sounds/success.mp3
Normal file
BIN
public/sounds/success.mp3
Normal file
Binary file not shown.
|
|
@ -1,14 +0,0 @@
|
||||||
|
|
||||||
export default class Schema {
|
|
||||||
|
|
||||||
private _errors: any[] = []
|
|
||||||
|
|
||||||
get errors(): any {
|
|
||||||
return this._errors;
|
|
||||||
}
|
|
||||||
|
|
||||||
set errors(value: any) {
|
|
||||||
this._errors.push(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,19 +0,0 @@
|
||||||
'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;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
import appConfig from '../../config/app.json';
|
|
||||||
export default class Json {
|
|
||||||
static execute() {
|
|
||||||
return appConfig;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
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('');
|
|
||||||
}
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
'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;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
|
|
||||||
export default function empty(data: any) {
|
|
||||||
if (!data || !data === null || !data === undefined) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,32 +0,0 @@
|
||||||
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,73 +0,0 @@
|
||||||
'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>
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,136 +0,0 @@
|
||||||
'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>
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,112 +0,0 @@
|
||||||
'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>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
'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;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
'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;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,19 +0,0 @@
|
||||||
'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;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
'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
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
||||||
'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;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,27 +0,0 @@
|
||||||
'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 }
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
||||||
'use client'
|
|
||||||
|
|
||||||
import GUsuarioLogoutService from "../../_services/g_usuario/GUsuarioLogoutService";
|
|
||||||
|
|
||||||
export const useGUsuarioLogoutHook = () => {
|
|
||||||
|
|
||||||
const logoutUsuario = async () => {
|
|
||||||
|
|
||||||
await GUsuarioLogoutService('access_token')
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return { logoutUsuario }
|
|
||||||
}
|
|
||||||
|
|
@ -1,27 +0,0 @@
|
||||||
'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 }
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
||||||
'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 }
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
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,
|
|
||||||
}
|
|
||||||
|
|
@ -1,35 +0,0 @@
|
||||||
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(),
|
|
||||||
});
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
'use server'
|
|
||||||
|
|
||||||
import GUsuarioIndexData from "../../_data/g_usuario/GUsuarioIndexData"
|
|
||||||
|
|
||||||
export default async function GUsuarioIndex() {
|
|
||||||
|
|
||||||
const response = await GUsuarioIndexData();
|
|
||||||
|
|
||||||
return response;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,44 +0,0 @@
|
||||||
'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);
|
|
||||||
|
|
@ -1,19 +0,0 @@
|
||||||
'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');
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,25 +0,0 @@
|
||||||
'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
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
'use server'
|
|
||||||
|
|
||||||
import GUsuarioSaveData from "../../_data/g_usuario/GUsuarioSaveData";
|
|
||||||
|
|
||||||
export default async function GUsuarioSave(form: any) {
|
|
||||||
|
|
||||||
return await GUsuarioSaveData(form);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
import TTBAndamentoServicoIndex from '@/packages/administrativo/components/TTBAndamentoServico/TTBAndamentoServicoIndex';
|
||||||
|
|
||||||
|
export default function TAtoParteTipo() {
|
||||||
|
return <TTBAndamentoServicoIndex />;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
import TAtoParteTipoIndex from '@/packages/administrativo/components/TAtoParteTipo/TAtoParteTipoIndex';
|
||||||
|
|
||||||
|
export default function TAtoParteTipo() {
|
||||||
|
return <TAtoParteTipoIndex />;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
'use client';
|
||||||
|
|
||||||
|
import GTBBairroIndex from '@/packages/administrativo/components/GTBBairro/GTBBairroIndex';
|
||||||
|
|
||||||
|
export default function GCidadePage() {
|
||||||
|
return <GTBBairroIndex />;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
'use client';
|
||||||
|
|
||||||
|
import GCartorioIndex from '@/packages/administrativo/components/GCartorio/GCartorioIndex';
|
||||||
|
|
||||||
|
export default function GCartorioPage() {
|
||||||
|
return <GCartorioIndex />;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
'use client';
|
||||||
|
|
||||||
|
import TCensecTipoNaturezaIndex from '@/packages/administrativo/components/TCensecTipoNatureza/TCensecTipoNaturezaIndex';
|
||||||
|
|
||||||
|
export default function TCensecTipoNaturezaPage() {
|
||||||
|
return <TCensecTipoNaturezaIndex />;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
export default function TCensecPage() {
|
||||||
|
return <div></div>;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
'use client';
|
||||||
|
|
||||||
|
import TCensecQualidadeIndex from '@/packages/administrativo/components/TCensecQualidade/TCensecQualidadeIndex';
|
||||||
|
|
||||||
|
export default function TCensecQualidadePage() {
|
||||||
|
return <TCensecQualidadeIndex />;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
'use client';
|
||||||
|
|
||||||
|
import TCensecIndex from '@/packages/administrativo/components/TCensec/TCensecIndex';
|
||||||
|
|
||||||
|
export default function GTBEstadoCivilPage() {
|
||||||
|
return <TCensecIndex />;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
'use client';
|
||||||
|
|
||||||
|
import TCensecNaturezaLitigioIndex from '@/packages/administrativo/components/TCensecNaturezaLitigio/TCensecNaturezaLitigioIndex';
|
||||||
|
|
||||||
|
export default function GCidadePage() {
|
||||||
|
return <TCensecNaturezaLitigioIndex />;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
'use client';
|
||||||
|
|
||||||
|
import TCensecQualidadeIndex from '@/packages/administrativo/components/TCensecQualidade/TCensecQualidadeIndex';
|
||||||
|
|
||||||
|
export default function GTBEstadoCivilPage() {
|
||||||
|
return <TCensecQualidadeIndex />;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
'use client';
|
||||||
|
|
||||||
|
import TCensecTipoAtoIndex from '@/packages/administrativo/components/TCensecTipoAto/TCensecTipoAtoIndex';
|
||||||
|
|
||||||
|
export default function GTBEstadoCivilPage() {
|
||||||
|
return <TCensecTipoAtoIndex />;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
'use client';
|
||||||
|
|
||||||
|
import GCidadeIndex from '@/packages/administrativo/components/GCidade/GCidadeIndex';
|
||||||
|
|
||||||
|
export default function GCidadePage() {
|
||||||
|
return <GCidadeIndex />;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
import GCalculoIndex from '@/packages/administrativo/components/GCalculo/GCalculoIndex';
|
||||||
|
|
||||||
|
export default function GEmolumentoPeriodoPage() {
|
||||||
|
return <GCalculoIndex />;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
'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)}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
import GEmolumentoIndex from '@/packages/administrativo/components/GEmolumento/GEmolumentoIndex';
|
||||||
|
|
||||||
|
export default function GEmolumentoPeriodoPage() {
|
||||||
|
return <GEmolumentoIndex />;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
import GEmolumentoPeriodoIndex from '@/packages/administrativo/components/GEmolumentoPeriodo/GEmolumentoPeriodoIndex';
|
||||||
|
|
||||||
|
export default function GEmolumentoPeriodoPage() {
|
||||||
|
return <GEmolumentoPeriodoIndex />;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
import GGramaticaIndex from '@/packages/administrativo/components/GGramatica/GGramaticaIndex';
|
||||||
|
|
||||||
|
export default function GGramaticaPage() {
|
||||||
|
return <GGramaticaIndex />;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
'use client';
|
||||||
|
|
||||||
|
import TImovelDashboard from '@/packages/administrativo/components/TImovel/TImovelDashboard';
|
||||||
|
|
||||||
|
export default function TImovelDashboardPage() {
|
||||||
|
return <TImovelDashboard />;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
'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}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
'use client';
|
||||||
|
|
||||||
|
import GTBTipoLogradouroIndex from '@/packages/administrativo/components/GTBTipoLogradouro/GTBTipoLogradouroIndex';
|
||||||
|
|
||||||
|
export default function GMedidaTipoPage() {
|
||||||
|
return <GTBTipoLogradouroIndex />;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
'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}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
'use client';
|
||||||
|
|
||||||
|
import GMedidaTipoIndex from '@/packages/administrativo/components/GMedidaTipo/GMedidaTipoIndex';
|
||||||
|
|
||||||
|
export default function GMedidaTipoPage() {
|
||||||
|
return <GMedidaTipoIndex />;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
import GNaturezaIndex from '@/packages/administrativo/components/GNatureza/GNaturezaIndex';
|
||||||
|
|
||||||
|
export default function GNaturezaPage() {
|
||||||
|
return <GNaturezaIndex sistema_id={2} />;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
'use client';
|
||||||
|
|
||||||
|
import TPessoaDashboard from '@/packages/administrativo/components/TPessoa/TPessoaDashboard';
|
||||||
|
|
||||||
|
export default function TPessoaDashboardPage() {
|
||||||
|
return <TPessoaDashboard />;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
'use client';
|
||||||
|
|
||||||
|
import GTBEstadoCivilIndex from '@/packages/administrativo/components/GTBEstadoCivil/GTBEstadoCivilIndex';
|
||||||
|
|
||||||
|
export default function GTBEstadoCivilPage() {
|
||||||
|
return <GTBEstadoCivilIndex />;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
'use client';
|
||||||
|
|
||||||
|
import TPessoaFisicaIndex from '@/packages/administrativo/components/TPessoa/TPessoaFisica/TPessoaFisicaIndex';
|
||||||
|
|
||||||
|
export default function TPessoaFisica() {
|
||||||
|
return <TPessoaFisicaIndex />;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
'use client';
|
||||||
|
|
||||||
|
import TPessoaJuridicaIndex from '@/packages/administrativo/components/TPessoa/TPessoaJuridica/TPessoaJuridicaIndex';
|
||||||
|
|
||||||
|
export default function TPessoaFisica() {
|
||||||
|
return <TPessoaJuridicaIndex />;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
'use client';
|
||||||
|
|
||||||
|
import GTBProfissaoIndex from '@/packages/administrativo/components/GTBProfissao/GTBProfissaoIndex';
|
||||||
|
|
||||||
|
export default function GTBEstadoCivilPage() {
|
||||||
|
return <GTBProfissaoIndex />;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
'use client';
|
||||||
|
|
||||||
|
import GTBRegimeBensIndex from '@/packages/administrativo/components/GTBRegimeBens/GTBRegimeBensIndex';
|
||||||
|
|
||||||
|
export default function GTBRegimeBensPage() {
|
||||||
|
return <GTBRegimeBensIndex />;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
'use client';
|
||||||
|
|
||||||
|
import GTBRegimeComunhaoIndex from '@/packages/administrativo/components/GTBRegimeComunhao/GTBRegimeComunhaoIndex';
|
||||||
|
|
||||||
|
export default function GTBRegimeBensPage() {
|
||||||
|
return <GTBRegimeComunhaoIndex />;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
import TTBReconhecimentoTipoIndex from '@/packages/administrativo/components/TTBReconhecimentoTipo/TTBReconhecimentoTipoIndex';
|
||||||
|
|
||||||
|
export default function TAtoParteTipo() {
|
||||||
|
return <TTBReconhecimentoTipoIndex />;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
import GSeloGrupoIndex from '@/packages/administrativo/components/GSeloGrupo/GSeloGrupoIndex';
|
||||||
|
|
||||||
|
export default function GSeloGrupoPage() {
|
||||||
|
return <GSeloGrupoIndex />;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
import TServicoTipoIndex from '@/packages/administrativo/components/TServicoTipo/TServicoTipoIndex';
|
||||||
|
|
||||||
|
export default function TServicoTipoPage() {
|
||||||
|
return <TServicoTipoIndex />;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
import GNaturezaTituloIndex from '@/packages/administrativo/components/GNaturezaTitulo/GNaturezaTituloIndex';
|
||||||
|
|
||||||
|
export default function GNaturezaPage() {
|
||||||
|
return <GNaturezaTituloIndex sistema_id={2} />;
|
||||||
|
}
|
||||||
|
|
@ -1,128 +0,0 @@
|
||||||
'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>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,167 +0,0 @@
|
||||||
'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>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,129 +0,0 @@
|
||||||
'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>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,163 +0,0 @@
|
||||||
'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
|
|
||||||
}
|
|
||||||
|
|
@ -1,163 +0,0 @@
|
||||||
'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
|
|
||||||
}
|
|
||||||
|
|
@ -1,163 +0,0 @@
|
||||||
'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
|
|
||||||
}
|
|
||||||
|
|
@ -1,163 +0,0 @@
|
||||||
'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>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,174 +0,0 @@
|
||||||
'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
|
|
||||||
}
|
|
||||||
|
|
@ -1,134 +0,0 @@
|
||||||
'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,17 +1,13 @@
|
||||||
'use client'
|
'use client';
|
||||||
|
|
||||||
import { useEffect, useState } from "react";
|
import { useParams } from 'next/navigation';
|
||||||
import { useParams } from "next/navigation";
|
import { useEffect, useState } from 'react';
|
||||||
|
|
||||||
import {
|
import MainEditor from '@/components/MainEditor';
|
||||||
Card,
|
import { Card, CardContent } from '@/components/ui/card';
|
||||||
CardContent
|
import { useTMinutaReadHook } from '@/packages/administrativo/hooks/TMinuta/useTMinutaReadHook';
|
||||||
} from "@/components/ui/card";
|
import { TMinutaInterface } from '@/packages/administrativo/interfaces/TMinuta/TMinutaInterface';
|
||||||
import MainEditor from "@/components/MainEditor";
|
import Loading from '@/shared/components/loading/loading';
|
||||||
|
|
||||||
import Loading from "@/app/_components/loading/loading";
|
|
||||||
import { useTMinutaReadHook } from '../../../../_hooks/t_minuta/useTMinutaReadHook';
|
|
||||||
import { TMinutaInterface } from '../../../../_interfaces/TMinutaInterface';
|
|
||||||
|
|
||||||
export default function TMinutaDetalhes() {
|
export default function TMinutaDetalhes() {
|
||||||
const params = useParams();
|
const params = useParams();
|
||||||
|
|
@ -45,32 +41,25 @@ export default function TMinutaDetalhes() {
|
||||||
<div>
|
<div>
|
||||||
<Card>
|
<Card>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
<div className="mb-4 grid gap-4 grid-cols-2">
|
<div className="mb-4 grid grid-cols-2 gap-4">
|
||||||
<div>
|
<div>
|
||||||
<div className="text-2xl font-semibold">
|
<div className="text-2xl font-semibold">Descrição</div>
|
||||||
Descrição
|
<div className="text-xl">{tMinuta.descricao}</div>
|
||||||
</div>
|
|
||||||
<div className="text-xl">
|
|
||||||
{tMinuta.descricao}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<div className="text-2xl font-semibold">
|
<div className="text-2xl font-semibold">Situação</div>
|
||||||
Situação
|
<div className="text-xl">{tMinuta.situacao === 'A' ? 'Ativo' : 'Inativo'}</div>
|
||||||
</div>
|
|
||||||
<div className="text-xl">
|
|
||||||
{tMinuta.situacao === "A" ? "Ativo" : "Inativo"}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div className="col-span-2">
|
<div className="col-span-2">
|
||||||
<div className="text-2xl font-semibold">
|
<div className="text-2xl font-semibold">Texto</div>
|
||||||
Texto
|
|
||||||
</div>
|
|
||||||
<MainEditor
|
<MainEditor
|
||||||
initialValue={editorContent} // Passa o conteúdo do editor
|
initialValue={editorContent} // Passa o conteúdo do editor
|
||||||
onEditorChange={handleEditorChange} // Função que atualiza o estado
|
onEditorChange={handleEditorChange} // Função que atualiza o estado
|
||||||
margins={{
|
margins={{
|
||||||
top: "2", 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
|
size={{ width: 794, height: 1123 }} // Você pode ajustar o tamanho aqui
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
|
|
@ -1,113 +1,107 @@
|
||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import z from 'zod';
|
import { zodResolver } from '@hookform/resolvers/zod';
|
||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
import { useForm, Controller } from 'react-hook-form';
|
import { useForm, Controller } from 'react-hook-form';
|
||||||
import { zodResolver } from '@hookform/resolvers/zod';
|
import z from 'zod';
|
||||||
|
|
||||||
|
import MainEditor from '@/components/MainEditor';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
|
import { Card, CardContent } from '@/components/ui/card';
|
||||||
import { Checkbox } from '@/components/ui/checkbox';
|
import { Checkbox } from '@/components/ui/checkbox';
|
||||||
import {
|
import {
|
||||||
Form,
|
Form,
|
||||||
FormControl,
|
FormControl,
|
||||||
FormField,
|
FormField,
|
||||||
FormItem,
|
FormItem,
|
||||||
FormLabel,
|
FormLabel,
|
||||||
FormMessage
|
FormMessage,
|
||||||
} from '@/components/ui/form';
|
} from '@/components/ui/form';
|
||||||
import { Input } from '@/components/ui/input';
|
import { Input } from '@/components/ui/input';
|
||||||
import { Label } from '@/components/ui/label';
|
import { Label } from '@/components/ui/label';
|
||||||
|
import { useTMinutaSaveHook } from '@/packages/administrativo/hooks/TMinuta/useTMinutaSaveHook';
|
||||||
import MainEditor from '@/components/MainEditor';
|
import { TMinutaSchema } from '@/packages/administrativo/schemas/TMinuta/TMinutaSchema';
|
||||||
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>;
|
type FormValues = z.infer<typeof TMinutaSchema>;
|
||||||
|
|
||||||
export default function TMinutaForm() {
|
export default function TMinutaForm() {
|
||||||
|
const { tMinuta, saveTMinuta } = useTMinutaSaveHook();
|
||||||
|
|
||||||
const { tMinuta, saveTMinuta } = useTMinutaSaveHook();
|
const form = useForm<FormValues>({
|
||||||
|
resolver: zodResolver(TMinutaSchema),
|
||||||
|
defaultValues: {
|
||||||
|
natureza_id: undefined,
|
||||||
|
descricao: '',
|
||||||
|
situacao: 'A',
|
||||||
|
texto: '',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
const form = useForm<FormValues>({
|
async function onSubmit(values: FormValues) {
|
||||||
resolver: zodResolver(TMinutaSchema),
|
saveTMinuta(values);
|
||||||
defaultValues: {
|
}
|
||||||
natureza_id: undefined,
|
|
||||||
descricao: '',
|
|
||||||
situacao: 'A',
|
|
||||||
texto: '',
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
async function onSubmit(values: FormValues) {
|
return (
|
||||||
saveTMinuta(values);
|
<div>
|
||||||
}
|
<Card>
|
||||||
|
<CardContent>
|
||||||
|
<Form {...form}>
|
||||||
|
<form onSubmit={form.handleSubmit(onSubmit)} 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 da minuta" />
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
|
||||||
return (
|
{/* Situação */}
|
||||||
<div>
|
<Controller
|
||||||
<Card>
|
name="situacao"
|
||||||
<CardContent>
|
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>{field.value === 'A' ? 'Ativo' : 'Inativo'}</Label>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
|
||||||
<Form {...form}>
|
{/* Editor de Texto */}
|
||||||
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-6">
|
<Controller
|
||||||
|
name="texto"
|
||||||
{/* Descrição */}
|
control={form.control}
|
||||||
<FormField
|
render={({ field }) => (
|
||||||
control={form.control}
|
<div>
|
||||||
name="descricao"
|
<MainEditor
|
||||||
render={({ field }) => (
|
initialValue={field.value || ''}
|
||||||
<FormItem>
|
onEditorChange={field.onChange}
|
||||||
<FormLabel>Descrição</FormLabel>
|
margins={{ top: '0', bottom: '0', left: '0', right: '0' }}
|
||||||
<FormControl>
|
size={{ width: 794, height: 1123 }}
|
||||||
<Input {...field} placeholder="Digite a descrição da minuta" />
|
/>
|
||||||
</FormControl>
|
{form.formState.errors.texto && (
|
||||||
<FormMessage />
|
<p className="mt-2 text-sm text-red-500">
|
||||||
</FormItem>
|
{form.formState.errors.texto.message}
|
||||||
)}
|
</p>
|
||||||
/>
|
)}
|
||||||
|
</div>
|
||||||
{/* Situação */}
|
)}
|
||||||
<Controller
|
/>
|
||||||
name="situacao"
|
<Button type="submit">Salvar</Button>
|
||||||
control={form.control}
|
</form>
|
||||||
render={({ field }) => (
|
</Form>
|
||||||
<div className="flex items-center space-x-2">
|
</CardContent>
|
||||||
<Checkbox
|
</Card>
|
||||||
checked={field.value === "A"}
|
</div>
|
||||||
onCheckedChange={(checked) => field.onChange(checked ? "A" : "I")}
|
);
|
||||||
/>
|
|
||||||
<Label>{field.value === "A" ? "Ativo" : "Inativo"}</Label>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{/* Editor de Texto */}
|
|
||||||
<Controller
|
|
||||||
name="texto"
|
|
||||||
control={form.control}
|
|
||||||
render={({ field }) => (
|
|
||||||
<div>
|
|
||||||
<MainEditor
|
|
||||||
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="text-sm text-red-500 mt-2">
|
|
||||||
{form.formState.errors.texto.message}
|
|
||||||
</p>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
<Button type="submit">
|
|
||||||
Salvar
|
|
||||||
</Button>
|
|
||||||
</form>
|
|
||||||
</Form>
|
|
||||||
</CardContent>
|
|
||||||
</Card>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,25 +1,21 @@
|
||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { useEffect, useState, useCallback } from "react";
|
import { useEffect, useState, useCallback } from 'react';
|
||||||
import { Card, CardContent } from "@/components/ui/card";
|
|
||||||
import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDialog";
|
|
||||||
|
|
||||||
import Header from "@/app/_components/structure/Header";
|
import { Card, CardContent } from '@/components/ui/card';
|
||||||
import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog";
|
import TMinutaForm from '@/packages/administrativo/components/TMinuta/TMinutaForm';
|
||||||
import Loading from "@/app/_components/loading/loading";
|
import TMinutaTable from '@/packages/administrativo/components/TMinuta/TMinutaTable';
|
||||||
|
import { useTMinutaIndexHook } from '@/packages/administrativo/hooks/TMinuta/useTMinutaIndexHook';
|
||||||
import TMinutaTable from "../../_components/t_minuta/TMinutaTable";
|
import { useTMinutaReadHook } from '@/packages/administrativo/hooks/TMinuta/useTMinutaReadHook';
|
||||||
import TMinutaForm from "../../_components/t_minuta/TMinutaForm";
|
import { useTMinutaRemoveHook } from '@/packages/administrativo/hooks/TMinuta/useTMinutaRemoveHook';
|
||||||
|
import { useTMinutaSaveHook } from '@/packages/administrativo/hooks/TMinuta/useTMinutaSaveHook';
|
||||||
import { useTMinutaReadHook } from "../../_hooks/t_minuta/useTMinutaReadHook";
|
import { TMinutaInterface } from '@/packages/administrativo/interfaces/TMinuta/TMinutaInterface';
|
||||||
import { useTMinutaSaveHook } from "../../_hooks/t_minuta/useTMinutaSaveHook";
|
import ConfirmDialog from '@/shared/components/confirmDialog/ConfirmDialog';
|
||||||
import { useTMinutaRemoveHook } from "../../_hooks/t_minuta/useTMinutaRemoveHook";
|
import { useConfirmDialog } from '@/shared/components/confirmDialog/useConfirmDialog';
|
||||||
|
import Loading from '@/shared/components/loading/loading';
|
||||||
import { TMinutaInterface } from "../../_interfaces/TMinutaInterface";
|
import Header from '@/shared/components/structure/Header';
|
||||||
import { useTMinutaIndexHook } from "../../_hooks/t_minuta/useTMinutaIndexHook";
|
|
||||||
|
|
||||||
export default function TMinutaPage() {
|
export default function TMinutaPage() {
|
||||||
|
|
||||||
// Hooks de leitura e escrita
|
// Hooks de leitura e escrita
|
||||||
const { tMinuta, fetchTMinuta } = useTMinutaIndexHook();
|
const { tMinuta, fetchTMinuta } = useTMinutaIndexHook();
|
||||||
const { saveTMinuta } = useTMinutaSaveHook();
|
const { saveTMinuta } = useTMinutaSaveHook();
|
||||||
|
|
@ -35,7 +31,7 @@ export default function TMinutaPage() {
|
||||||
isOpen: isConfirmOpen,
|
isOpen: isConfirmOpen,
|
||||||
openDialog: openConfirmDialog,
|
openDialog: openConfirmDialog,
|
||||||
handleConfirm,
|
handleConfirm,
|
||||||
handleCancel
|
handleCancel,
|
||||||
} = useConfirmDialog();
|
} = useConfirmDialog();
|
||||||
|
|
||||||
// Abertura do formulário
|
// Abertura do formulário
|
||||||
|
|
@ -45,10 +41,13 @@ export default function TMinutaPage() {
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
// Ação de clique em remover
|
// Ação de clique em remover
|
||||||
const handleConfirmDelete = useCallback((item: TMinutaInterface) => {
|
const handleConfirmDelete = useCallback(
|
||||||
setItemToDelete(item);
|
(item: TMinutaInterface) => {
|
||||||
openConfirmDialog();
|
setItemToDelete(item);
|
||||||
}, [openConfirmDialog]);
|
openConfirmDialog();
|
||||||
|
},
|
||||||
|
[openConfirmDialog],
|
||||||
|
);
|
||||||
|
|
||||||
// Remoção da minuta após confirmação
|
// Remoção da minuta após confirmação
|
||||||
const handleDelete = useCallback(async () => {
|
const handleDelete = useCallback(async () => {
|
||||||
|
|
@ -83,11 +82,7 @@ export default function TMinutaPage() {
|
||||||
{/* Tabela */}
|
{/* Tabela */}
|
||||||
<Card>
|
<Card>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
<TMinutaTable
|
<TMinutaTable data={tMinuta} onEdit={handleOpenForm} onDelete={handleConfirmDelete} />
|
||||||
data={tMinuta}
|
|
||||||
onEdit={handleOpenForm}
|
|
||||||
onDelete={handleConfirmDelete}
|
|
||||||
/>
|
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,160 +0,0 @@
|
||||||
'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
|
|
||||||
}
|
|
||||||
|
|
@ -1,164 +0,0 @@
|
||||||
'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>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,125 +0,0 @@
|
||||||
'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>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,96 +0,0 @@
|
||||||
'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>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,132 +0,0 @@
|
||||||
'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>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,123 +0,0 @@
|
||||||
'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>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,129 +0,0 @@
|
||||||
'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>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,123 +0,0 @@
|
||||||
'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>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,143 +0,0 @@
|
||||||
'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>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,129 +0,0 @@
|
||||||
'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>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,127 +0,0 @@
|
||||||
'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>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,126 +0,0 @@
|
||||||
'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>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,189 +0,0 @@
|
||||||
'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