Merge branch 'release(MVP)' into MVPTN-88
This commit is contained in:
commit
f7ac0eb9df
229 changed files with 10026 additions and 271 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -39,3 +39,5 @@ yarn-error.log*
|
|||
# typescript
|
||||
*.tsbuildinfo
|
||||
next-env.d.ts
|
||||
|
||||
/src/config/app.json
|
||||
|
|
|
|||
22
Dockerfile
Normal file
22
Dockerfile
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
# Use uma imagem Node.js completa para o desenvolvimento
|
||||
FROM node:20-alpine
|
||||
|
||||
# Define o diretório de trabalho no container
|
||||
WORKDIR /app
|
||||
|
||||
# Copia os arquivos de configuração do projeto
|
||||
COPY package.json package-lock.json ./
|
||||
|
||||
# Instala todas as dependências do projeto
|
||||
# Isso é necessário para o modo de desenvolvimento, pois o build não pré-compila os arquivos.
|
||||
RUN npm install
|
||||
|
||||
# Copia o restante do código da sua aplicação
|
||||
COPY . .
|
||||
|
||||
# Expõe a porta de desenvolvimento padrão do Next.js
|
||||
EXPOSE 3000
|
||||
|
||||
# Define o comando para iniciar a aplicação em modo de desenvolvimento
|
||||
# Isso ativará o servidor de desenvolvimento e a recarga automática
|
||||
CMD ["npm", "run", "dev"]
|
||||
41
Dockerfile-homologacao
Normal file
41
Dockerfile-homologacao
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
# Etapa 1: Construir a aplicação
|
||||
FROM node:20-alpine AS builder
|
||||
|
||||
# Define o diretório de trabalho
|
||||
WORKDIR /app
|
||||
|
||||
# Copia os arquivos de configuração do pacote
|
||||
COPY package.json package-lock.json ./
|
||||
|
||||
# Instala as dependências do projeto
|
||||
RUN npm install
|
||||
|
||||
# Copia todo o código da aplicação para o container
|
||||
COPY . .
|
||||
|
||||
# Constrói a aplicação com o output 'standalone'
|
||||
RUN npm run build
|
||||
|
||||
# Etapa 2: Executar a aplicação
|
||||
# Usa uma imagem Node.js leve
|
||||
FROM node:20-alpine AS runner
|
||||
|
||||
# Define o diretório de trabalho
|
||||
WORKDIR /app
|
||||
|
||||
# Copia o diretório 'standalone' da etapa de build, que já contém o servidor e as dependências
|
||||
# O diretório 'standalone' é a pasta .next/standalone gerada pela configuração 'output: standalone'
|
||||
COPY --from=builder /app/.next/standalone ./
|
||||
|
||||
# Copia os arquivos públicos
|
||||
COPY --from=builder /app/public ./public
|
||||
|
||||
# Copia os arquivos estáticos gerados pelo build. É aqui que os arquivos CSS e JS ficam.
|
||||
COPY --from=builder /app/.next/static ./.next/static
|
||||
|
||||
# Expõe a porta padrão do Next.js
|
||||
EXPOSE 3000
|
||||
|
||||
# Define o comando para iniciar a aplicação
|
||||
# O 'start' do package.json não é necessário, o próprio servidor standalone já está no container
|
||||
CMD ["node", "server.js"]
|
||||
|
|
@ -1,7 +1,8 @@
|
|||
import type { NextConfig } from "next";
|
||||
|
||||
const nextConfig: NextConfig = {
|
||||
/* config options here */
|
||||
// Isso gera um diretório otimizado que inclui tudo o que a aplicação precisa para rodar
|
||||
output: 'standalone',
|
||||
};
|
||||
|
||||
export default nextConfig;
|
||||
|
|
|
|||
370
package-lock.json
generated
370
package-lock.json
generated
|
|
@ -1,39 +1,50 @@
|
|||
{
|
||||
"name": "app",
|
||||
"version": "0.1.0",
|
||||
"version": "25.9.1",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "app",
|
||||
"version": "0.1.0",
|
||||
"version": "25.9.1",
|
||||
"dependencies": {
|
||||
"@faker-js/faker": "^10.0.0",
|
||||
"@hookform/resolvers": "^5.2.1",
|
||||
"@radix-ui/react-alert-dialog": "^1.1.15",
|
||||
"@radix-ui/react-avatar": "^1.1.10",
|
||||
"@radix-ui/react-checkbox": "^1.3.3",
|
||||
"@radix-ui/react-collapsible": "^1.1.12",
|
||||
"@radix-ui/react-dialog": "^1.1.15",
|
||||
"@radix-ui/react-dropdown-menu": "^2.1.16",
|
||||
"@radix-ui/react-label": "^2.1.7",
|
||||
"@radix-ui/react-popover": "^1.1.15",
|
||||
"@radix-ui/react-select": "^2.2.6",
|
||||
"@radix-ui/react-separator": "^1.1.7",
|
||||
"@radix-ui/react-slot": "^1.2.3",
|
||||
"@radix-ui/react-tabs": "^1.1.13",
|
||||
"@radix-ui/react-tooltip": "^1.2.8",
|
||||
"@tinymce/tinymce-react": "^6.3.0",
|
||||
"class-variance-authority": "^0.7.1",
|
||||
"clsx": "^2.1.1",
|
||||
"cookies-next": "^6.1.0",
|
||||
"faker-js": "^1.0.0",
|
||||
"js-cookie": "^3.0.5",
|
||||
"jsonwebtoken": "^9.0.2",
|
||||
"jwt-decode": "^4.0.0",
|
||||
"lucide-react": "^0.540.0",
|
||||
"next": "15.4.6",
|
||||
"next": "^15.5.3",
|
||||
"next-themes": "^0.4.6",
|
||||
"react": "19.1.0",
|
||||
"react-dom": "19.1.0",
|
||||
"react-hook-form": "^7.62.0",
|
||||
"sonner": "^2.0.7",
|
||||
"tailwind-merge": "^3.3.1",
|
||||
"tinymce": "^8.1.2",
|
||||
"zod": "^4.0.17"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tailwindcss/postcss": "^4",
|
||||
"@types/js-cookie": "^3.0.6",
|
||||
"@types/jsonwebtoken": "^9.0.10",
|
||||
"@types/node": "^20",
|
||||
"@types/react": "^19",
|
||||
|
|
@ -66,6 +77,22 @@
|
|||
"tslib": "^2.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@faker-js/faker": {
|
||||
"version": "10.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@faker-js/faker/-/faker-10.0.0.tgz",
|
||||
"integrity": "sha512-UollFEUkVXutsaP+Vndjxar40Gs5JL2HeLcl8xO1QAjJgOdhc3OmBFWyEylS+RddWaaBiAzH+5/17PLQJwDiLw==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/fakerjs"
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": "^20.19.0 || ^22.13.0 || ^23.5.0 || >=24.0.0",
|
||||
"npm": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/@floating-ui/core": {
|
||||
"version": "1.7.3",
|
||||
"resolved": "https://registry.npmjs.org/@floating-ui/core/-/core-1.7.3.tgz",
|
||||
|
|
@ -598,15 +625,15 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@next/env": {
|
||||
"version": "15.4.6",
|
||||
"resolved": "https://registry.npmjs.org/@next/env/-/env-15.4.6.tgz",
|
||||
"integrity": "sha512-yHDKVTcHrZy/8TWhj0B23ylKv5ypocuCwey9ZqPyv4rPdUdRzpGCkSi03t04KBPyU96kxVtUqx6O3nE1kpxASQ==",
|
||||
"version": "15.5.3",
|
||||
"resolved": "https://registry.npmjs.org/@next/env/-/env-15.5.3.tgz",
|
||||
"integrity": "sha512-RSEDTRqyihYXygx/OJXwvVupfr9m04+0vH8vyy0HfZ7keRto6VX9BbEk0J2PUk0VGy6YhklJUSrgForov5F9pw==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@next/swc-darwin-arm64": {
|
||||
"version": "15.4.6",
|
||||
"resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-15.4.6.tgz",
|
||||
"integrity": "sha512-667R0RTP4DwxzmrqTs4Lr5dcEda9OxuZsVFsjVtxVMVhzSpo6nLclXejJVfQo2/g7/Z9qF3ETDmN3h65mTjpTQ==",
|
||||
"version": "15.5.3",
|
||||
"resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-15.5.3.tgz",
|
||||
"integrity": "sha512-nzbHQo69+au9wJkGKTU9lP7PXv0d1J5ljFpvb+LnEomLtSbJkbZyEs6sbF3plQmiOB2l9OBtN2tNSvCH1nQ9Jg==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
|
|
@ -620,9 +647,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@next/swc-darwin-x64": {
|
||||
"version": "15.4.6",
|
||||
"resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-15.4.6.tgz",
|
||||
"integrity": "sha512-KMSFoistFkaiQYVQQnaU9MPWtp/3m0kn2Xed1Ces5ll+ag1+rlac20sxG+MqhH2qYWX1O2GFOATQXEyxKiIscg==",
|
||||
"version": "15.5.3",
|
||||
"resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-15.5.3.tgz",
|
||||
"integrity": "sha512-w83w4SkOOhekJOcA5HBvHyGzgV1W/XvOfpkrxIse4uPWhYTTRwtGEM4v/jiXwNSJvfRvah0H8/uTLBKRXlef8g==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
|
|
@ -636,9 +663,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@next/swc-linux-arm64-gnu": {
|
||||
"version": "15.4.6",
|
||||
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-15.4.6.tgz",
|
||||
"integrity": "sha512-PnOx1YdO0W7m/HWFeYd2A6JtBO8O8Eb9h6nfJia2Dw1sRHoHpNf6lN1U4GKFRzRDBi9Nq2GrHk9PF3Vmwf7XVw==",
|
||||
"version": "15.5.3",
|
||||
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-15.5.3.tgz",
|
||||
"integrity": "sha512-+m7pfIs0/yvgVu26ieaKrifV8C8yiLe7jVp9SpcIzg7XmyyNE7toC1fy5IOQozmr6kWl/JONC51osih2RyoXRw==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
|
|
@ -652,9 +679,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@next/swc-linux-arm64-musl": {
|
||||
"version": "15.4.6",
|
||||
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-15.4.6.tgz",
|
||||
"integrity": "sha512-XBbuQddtY1p5FGPc2naMO0kqs4YYtLYK/8aPausI5lyOjr4J77KTG9mtlU4P3NwkLI1+OjsPzKVvSJdMs3cFaw==",
|
||||
"version": "15.5.3",
|
||||
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-15.5.3.tgz",
|
||||
"integrity": "sha512-u3PEIzuguSenoZviZJahNLgCexGFhso5mxWCrrIMdvpZn6lkME5vc/ADZG8UUk5K1uWRy4hqSFECrON6UKQBbQ==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
|
|
@ -668,9 +695,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@next/swc-linux-x64-gnu": {
|
||||
"version": "15.4.6",
|
||||
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-15.4.6.tgz",
|
||||
"integrity": "sha512-+WTeK7Qdw82ez3U9JgD+igBAP75gqZ1vbK6R8PlEEuY0OIe5FuYXA4aTjL811kWPf7hNeslD4hHK2WoM9W0IgA==",
|
||||
"version": "15.5.3",
|
||||
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-15.5.3.tgz",
|
||||
"integrity": "sha512-lDtOOScYDZxI2BENN9m0pfVPJDSuUkAD1YXSvlJF0DKwZt0WlA7T7o3wrcEr4Q+iHYGzEaVuZcsIbCps4K27sA==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
|
|
@ -684,9 +711,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@next/swc-linux-x64-musl": {
|
||||
"version": "15.4.6",
|
||||
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-15.4.6.tgz",
|
||||
"integrity": "sha512-XP824mCbgQsK20jlXKrUpZoh/iO3vUWhMpxCz8oYeagoiZ4V0TQiKy0ASji1KK6IAe3DYGfj5RfKP6+L2020OQ==",
|
||||
"version": "15.5.3",
|
||||
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-15.5.3.tgz",
|
||||
"integrity": "sha512-9vWVUnsx9PrY2NwdVRJ4dUURAQ8Su0sLRPqcCCxtX5zIQUBES12eRVHq6b70bbfaVaxIDGJN2afHui0eDm+cLg==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
|
|
@ -700,9 +727,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@next/swc-win32-arm64-msvc": {
|
||||
"version": "15.4.6",
|
||||
"resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-15.4.6.tgz",
|
||||
"integrity": "sha512-FxrsenhUz0LbgRkNWx6FRRJIPe/MI1JRA4W4EPd5leXO00AZ6YU8v5vfx4MDXTvN77lM/EqsE3+6d2CIeF5NYg==",
|
||||
"version": "15.5.3",
|
||||
"resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-15.5.3.tgz",
|
||||
"integrity": "sha512-1CU20FZzY9LFQigRi6jM45oJMU3KziA5/sSG+dXeVaTm661snQP6xu3ykGxxwU5sLG3sh14teO/IOEPVsQMRfA==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
|
|
@ -716,9 +743,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@next/swc-win32-x64-msvc": {
|
||||
"version": "15.4.6",
|
||||
"resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-15.4.6.tgz",
|
||||
"integrity": "sha512-T4ufqnZ4u88ZheczkBTtOF+eKaM14V8kbjud/XrAakoM5DKQWjW09vD6B9fsdsWS2T7D5EY31hRHdta7QKWOng==",
|
||||
"version": "15.5.3",
|
||||
"resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-15.5.3.tgz",
|
||||
"integrity": "sha512-JMoLAq3n3y5tKXPQwCK5c+6tmwkuFDa2XAxz8Wm4+IVthdBZdZGh+lmiLUHg9f9IDwIQpUjp+ysd6OkYTyZRZw==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
|
|
@ -731,12 +758,46 @@
|
|||
"node": ">= 10"
|
||||
}
|
||||
},
|
||||
"node_modules/@radix-ui/number": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/@radix-ui/number/-/number-1.1.1.tgz",
|
||||
"integrity": "sha512-MkKCwxlXTgz6CFoJx3pCwn07GKp36+aZyu/u2Ln2VrA5DcdyCZkASEDBTd8x5whTQQL5CiYf4prXKLcgQdv29g==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@radix-ui/primitive": {
|
||||
"version": "1.1.3",
|
||||
"resolved": "https://registry.npmjs.org/@radix-ui/primitive/-/primitive-1.1.3.tgz",
|
||||
"integrity": "sha512-JTF99U/6XIjCBo0wqkU5sK10glYe27MRRsfwoiq5zzOEZLHU3A3KCMa5X/azekYRCJ0HlwI0crAXS/5dEHTzDg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@radix-ui/react-alert-dialog": {
|
||||
"version": "1.1.15",
|
||||
"resolved": "https://registry.npmjs.org/@radix-ui/react-alert-dialog/-/react-alert-dialog-1.1.15.tgz",
|
||||
"integrity": "sha512-oTVLkEw5GpdRe29BqJ0LSDFWI3qu0vR1M0mUkOQWDIUnY/QIkLpgDMWuKxP94c2NAC2LGcgVhG1ImF3jkZ5wXw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@radix-ui/primitive": "1.1.3",
|
||||
"@radix-ui/react-compose-refs": "1.1.2",
|
||||
"@radix-ui/react-context": "1.1.2",
|
||||
"@radix-ui/react-dialog": "1.1.15",
|
||||
"@radix-ui/react-primitive": "2.1.3",
|
||||
"@radix-ui/react-slot": "1.2.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@types/react": "*",
|
||||
"@types/react-dom": "*",
|
||||
"react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
|
||||
"react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@types/react": {
|
||||
"optional": true
|
||||
},
|
||||
"@types/react-dom": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@radix-ui/react-arrow": {
|
||||
"version": "1.1.7",
|
||||
"resolved": "https://registry.npmjs.org/@radix-ui/react-arrow/-/react-arrow-1.1.7.tgz",
|
||||
|
|
@ -787,6 +848,36 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@radix-ui/react-checkbox": {
|
||||
"version": "1.3.3",
|
||||
"resolved": "https://registry.npmjs.org/@radix-ui/react-checkbox/-/react-checkbox-1.3.3.tgz",
|
||||
"integrity": "sha512-wBbpv+NQftHDdG86Qc0pIyXk5IR3tM8Vd0nWLKDcX8nNn4nXFOFwsKuqw2okA/1D/mpaAkmuyndrPJTYDNZtFw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@radix-ui/primitive": "1.1.3",
|
||||
"@radix-ui/react-compose-refs": "1.1.2",
|
||||
"@radix-ui/react-context": "1.1.2",
|
||||
"@radix-ui/react-presence": "1.1.5",
|
||||
"@radix-ui/react-primitive": "2.1.3",
|
||||
"@radix-ui/react-use-controllable-state": "1.2.2",
|
||||
"@radix-ui/react-use-previous": "1.1.1",
|
||||
"@radix-ui/react-use-size": "1.1.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@types/react": "*",
|
||||
"@types/react-dom": "*",
|
||||
"react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
|
||||
"react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@types/react": {
|
||||
"optional": true
|
||||
},
|
||||
"@types/react-dom": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@radix-ui/react-collapsible": {
|
||||
"version": "1.1.12",
|
||||
"resolved": "https://registry.npmjs.org/@radix-ui/react-collapsible/-/react-collapsible-1.1.12.tgz",
|
||||
|
|
@ -1101,6 +1192,43 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@radix-ui/react-popover": {
|
||||
"version": "1.1.15",
|
||||
"resolved": "https://registry.npmjs.org/@radix-ui/react-popover/-/react-popover-1.1.15.tgz",
|
||||
"integrity": "sha512-kr0X2+6Yy/vJzLYJUPCZEc8SfQcf+1COFoAqauJm74umQhta9M7lNJHP7QQS3vkvcGLQUbWpMzwrXYwrYztHKA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@radix-ui/primitive": "1.1.3",
|
||||
"@radix-ui/react-compose-refs": "1.1.2",
|
||||
"@radix-ui/react-context": "1.1.2",
|
||||
"@radix-ui/react-dismissable-layer": "1.1.11",
|
||||
"@radix-ui/react-focus-guards": "1.1.3",
|
||||
"@radix-ui/react-focus-scope": "1.1.7",
|
||||
"@radix-ui/react-id": "1.1.1",
|
||||
"@radix-ui/react-popper": "1.2.8",
|
||||
"@radix-ui/react-portal": "1.1.9",
|
||||
"@radix-ui/react-presence": "1.1.5",
|
||||
"@radix-ui/react-primitive": "2.1.3",
|
||||
"@radix-ui/react-slot": "1.2.3",
|
||||
"@radix-ui/react-use-controllable-state": "1.2.2",
|
||||
"aria-hidden": "^1.2.4",
|
||||
"react-remove-scroll": "^2.6.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@types/react": "*",
|
||||
"@types/react-dom": "*",
|
||||
"react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
|
||||
"react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@types/react": {
|
||||
"optional": true
|
||||
},
|
||||
"@types/react-dom": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@radix-ui/react-popper": {
|
||||
"version": "1.2.8",
|
||||
"resolved": "https://registry.npmjs.org/@radix-ui/react-popper/-/react-popper-1.2.8.tgz",
|
||||
|
|
@ -1235,6 +1363,49 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@radix-ui/react-select": {
|
||||
"version": "2.2.6",
|
||||
"resolved": "https://registry.npmjs.org/@radix-ui/react-select/-/react-select-2.2.6.tgz",
|
||||
"integrity": "sha512-I30RydO+bnn2PQztvo25tswPH+wFBjehVGtmagkU78yMdwTwVf12wnAOF+AeP8S2N8xD+5UPbGhkUfPyvT+mwQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@radix-ui/number": "1.1.1",
|
||||
"@radix-ui/primitive": "1.1.3",
|
||||
"@radix-ui/react-collection": "1.1.7",
|
||||
"@radix-ui/react-compose-refs": "1.1.2",
|
||||
"@radix-ui/react-context": "1.1.2",
|
||||
"@radix-ui/react-direction": "1.1.1",
|
||||
"@radix-ui/react-dismissable-layer": "1.1.11",
|
||||
"@radix-ui/react-focus-guards": "1.1.3",
|
||||
"@radix-ui/react-focus-scope": "1.1.7",
|
||||
"@radix-ui/react-id": "1.1.1",
|
||||
"@radix-ui/react-popper": "1.2.8",
|
||||
"@radix-ui/react-portal": "1.1.9",
|
||||
"@radix-ui/react-primitive": "2.1.3",
|
||||
"@radix-ui/react-slot": "1.2.3",
|
||||
"@radix-ui/react-use-callback-ref": "1.1.1",
|
||||
"@radix-ui/react-use-controllable-state": "1.2.2",
|
||||
"@radix-ui/react-use-layout-effect": "1.1.1",
|
||||
"@radix-ui/react-use-previous": "1.1.1",
|
||||
"@radix-ui/react-visually-hidden": "1.2.3",
|
||||
"aria-hidden": "^1.2.4",
|
||||
"react-remove-scroll": "^2.6.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@types/react": "*",
|
||||
"@types/react-dom": "*",
|
||||
"react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
|
||||
"react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@types/react": {
|
||||
"optional": true
|
||||
},
|
||||
"@types/react-dom": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@radix-ui/react-separator": {
|
||||
"version": "1.1.7",
|
||||
"resolved": "https://registry.npmjs.org/@radix-ui/react-separator/-/react-separator-1.1.7.tgz",
|
||||
|
|
@ -1443,6 +1614,21 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@radix-ui/react-use-previous": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/@radix-ui/react-use-previous/-/react-use-previous-1.1.1.tgz",
|
||||
"integrity": "sha512-2dHfToCj/pzca2Ck724OZ5L0EVrr3eHRNsG/b3xQJLA2hZpVCS99bLAX+hm1IHXDEnzU6by5z/5MIY794/a8NQ==",
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"@types/react": "*",
|
||||
"react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@types/react": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@radix-ui/react-use-rect": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/@radix-ui/react-use-rect/-/react-use-rect-1.1.1.tgz",
|
||||
|
|
@ -1799,6 +1985,32 @@
|
|||
"tailwindcss": "4.1.12"
|
||||
}
|
||||
},
|
||||
"node_modules/@tinymce/tinymce-react": {
|
||||
"version": "6.3.0",
|
||||
"resolved": "https://registry.npmjs.org/@tinymce/tinymce-react/-/tinymce-react-6.3.0.tgz",
|
||||
"integrity": "sha512-E++xnn0XzDzpKr40jno2Kj7umfAE6XfINZULEBBeNjTMvbACWzA6CjiR6V8eTDc9yVmdVhIPqVzV4PqD5TZ/4g==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"prop-types": "^15.6.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": "^19.0.0 || ^18.0.0 || ^17.0.1 || ^16.7.0",
|
||||
"react-dom": "^19.0.0 || ^18.0.0 || ^17.0.1 || ^16.7.0",
|
||||
"tinymce": "^8.0.0 || ^7.0.0 || ^6.0.0 || ^5.5.1"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"tinymce": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@types/js-cookie": {
|
||||
"version": "3.0.6",
|
||||
"resolved": "https://registry.npmjs.org/@types/js-cookie/-/js-cookie-3.0.6.tgz",
|
||||
"integrity": "sha512-wkw9yd1kEXOPnvEeEV1Go1MmxtBJL0RR79aOTAApecWFVu7w0NNXNqhcWgvw2YgZDYadliXkl14pa3WXw5jlCQ==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/jsonwebtoken": {
|
||||
"version": "9.0.10",
|
||||
"resolved": "https://registry.npmjs.org/@types/jsonwebtoken/-/jsonwebtoken-9.0.10.tgz",
|
||||
|
|
@ -2035,6 +2247,12 @@
|
|||
"node": ">=10.13.0"
|
||||
}
|
||||
},
|
||||
"node_modules/faker-js": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/faker-js/-/faker-js-1.0.0.tgz",
|
||||
"integrity": "sha512-kaToadbN63LWhHjl69pqG+YHlxAK0aZAPhQDUpVP7v7+RG//ZpK0OzXjCwaAQq98awOii0WSHxtJmIz0X7/UqQ==",
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/get-nonce": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/get-nonce/-/get-nonce-1.0.1.tgz",
|
||||
|
|
@ -2068,6 +2286,21 @@
|
|||
"jiti": "lib/jiti-cli.mjs"
|
||||
}
|
||||
},
|
||||
"node_modules/js-tokens": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
|
||||
"integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/js-cookie": {
|
||||
"version": "3.0.5",
|
||||
"resolved": "https://registry.npmjs.org/js-cookie/-/js-cookie-3.0.5.tgz",
|
||||
"integrity": "sha512-cEiJEAEoIbWfCZYKWhVwFuvPX1gETRYPw6LlaTKoxD3s2AkXzkCjnp6h0V77ozyqj0jakteJ4YqDJT830+lVGw==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=14"
|
||||
}
|
||||
},
|
||||
"node_modules/jsonwebtoken": {
|
||||
"version": "9.0.2",
|
||||
"resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-9.0.2.tgz",
|
||||
|
|
@ -2111,6 +2344,15 @@
|
|||
"safe-buffer": "^5.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/jwt-decode": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/jwt-decode/-/jwt-decode-4.0.0.tgz",
|
||||
"integrity": "sha512-+KJGIyHgkGuIq3IEBNftfhW/LfWhXUIY6OmyVWjliu5KH1y0fw7VQ8YndE2O4qZdMSd9SqbnC8GOcZEy0Om7sA==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/lightningcss": {
|
||||
"version": "1.30.1",
|
||||
"resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.30.1.tgz",
|
||||
|
|
@ -2392,6 +2634,18 @@
|
|||
"integrity": "sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/loose-envify": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz",
|
||||
"integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"js-tokens": "^3.0.0 || ^4.0.0"
|
||||
},
|
||||
"bin": {
|
||||
"loose-envify": "cli.js"
|
||||
}
|
||||
},
|
||||
"node_modules/lucide-react": {
|
||||
"version": "0.540.0",
|
||||
"resolved": "https://registry.npmjs.org/lucide-react/-/lucide-react-0.540.0.tgz",
|
||||
|
|
@ -2475,12 +2729,12 @@
|
|||
}
|
||||
},
|
||||
"node_modules/next": {
|
||||
"version": "15.4.6",
|
||||
"resolved": "https://registry.npmjs.org/next/-/next-15.4.6.tgz",
|
||||
"integrity": "sha512-us++E/Q80/8+UekzB3SAGs71AlLDsadpFMXVNM/uQ0BMwsh9m3mr0UNQIfjKed8vpWXsASe+Qifrnu1oLIcKEQ==",
|
||||
"version": "15.5.3",
|
||||
"resolved": "https://registry.npmjs.org/next/-/next-15.5.3.tgz",
|
||||
"integrity": "sha512-r/liNAx16SQj4D+XH/oI1dlpv9tdKJ6cONYPwwcCC46f2NjpaRWY+EKCzULfgQYV6YKXjHBchff2IZBSlZmJNw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@next/env": "15.4.6",
|
||||
"@next/env": "15.5.3",
|
||||
"@swc/helpers": "0.5.15",
|
||||
"caniuse-lite": "^1.0.30001579",
|
||||
"postcss": "8.4.31",
|
||||
|
|
@ -2493,14 +2747,14 @@
|
|||
"node": "^18.18.0 || ^19.8.0 || >= 20.0.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@next/swc-darwin-arm64": "15.4.6",
|
||||
"@next/swc-darwin-x64": "15.4.6",
|
||||
"@next/swc-linux-arm64-gnu": "15.4.6",
|
||||
"@next/swc-linux-arm64-musl": "15.4.6",
|
||||
"@next/swc-linux-x64-gnu": "15.4.6",
|
||||
"@next/swc-linux-x64-musl": "15.4.6",
|
||||
"@next/swc-win32-arm64-msvc": "15.4.6",
|
||||
"@next/swc-win32-x64-msvc": "15.4.6",
|
||||
"@next/swc-darwin-arm64": "15.5.3",
|
||||
"@next/swc-darwin-x64": "15.5.3",
|
||||
"@next/swc-linux-arm64-gnu": "15.5.3",
|
||||
"@next/swc-linux-arm64-musl": "15.5.3",
|
||||
"@next/swc-linux-x64-gnu": "15.5.3",
|
||||
"@next/swc-linux-x64-musl": "15.5.3",
|
||||
"@next/swc-win32-arm64-msvc": "15.5.3",
|
||||
"@next/swc-win32-x64-msvc": "15.5.3",
|
||||
"sharp": "^0.34.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
|
|
@ -2564,6 +2818,15 @@
|
|||
"node": "^10 || ^12 || >=14"
|
||||
}
|
||||
},
|
||||
"node_modules/object-assign": {
|
||||
"version": "4.1.1",
|
||||
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
|
||||
"integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/picocolors": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",
|
||||
|
|
@ -2599,6 +2862,17 @@
|
|||
"node": "^10 || ^12 || >=14"
|
||||
}
|
||||
},
|
||||
"node_modules/prop-types": {
|
||||
"version": "15.8.1",
|
||||
"resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz",
|
||||
"integrity": "sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"loose-envify": "^1.4.0",
|
||||
"object-assign": "^4.1.1",
|
||||
"react-is": "^16.13.1"
|
||||
}
|
||||
},
|
||||
"node_modules/react": {
|
||||
"version": "19.1.0",
|
||||
"resolved": "https://registry.npmjs.org/react/-/react-19.1.0.tgz",
|
||||
|
|
@ -2636,6 +2910,12 @@
|
|||
"react": "^16.8.0 || ^17 || ^18 || ^19"
|
||||
}
|
||||
},
|
||||
"node_modules/react-is": {
|
||||
"version": "16.13.1",
|
||||
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz",
|
||||
"integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/react-remove-scroll": {
|
||||
"version": "2.7.1",
|
||||
"resolved": "https://registry.npmjs.org/react-remove-scroll/-/react-remove-scroll-2.7.1.tgz",
|
||||
|
|
@ -2883,6 +3163,12 @@
|
|||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/tinymce": {
|
||||
"version": "8.1.2",
|
||||
"resolved": "https://registry.npmjs.org/tinymce/-/tinymce-8.1.2.tgz",
|
||||
"integrity": "sha512-KITxHEEHRlxC5xOnxA123eAJ67NgsWxNphtItWt9TRu07DiTZrWIqJeIKRX9euE51/l3kJO4WQiqoBXKTJJGsA==",
|
||||
"license": "GPL-2.0-or-later"
|
||||
},
|
||||
"node_modules/tslib": {
|
||||
"version": "2.8.1",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz",
|
||||
|
|
|
|||
17
package.json
17
package.json
|
|
@ -1,40 +1,51 @@
|
|||
{
|
||||
"name": "app",
|
||||
"version": "0.1.0",
|
||||
"version": "25.9.1",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
"dev": "next dev --turbopack",
|
||||
"build": "next build",
|
||||
"start": "next start",
|
||||
"lint": "next lint"
|
||||
},
|
||||
"dependencies": {
|
||||
"@faker-js/faker": "^10.0.0",
|
||||
"@hookform/resolvers": "^5.2.1",
|
||||
"@radix-ui/react-alert-dialog": "^1.1.15",
|
||||
"@radix-ui/react-avatar": "^1.1.10",
|
||||
"@radix-ui/react-checkbox": "^1.3.3",
|
||||
"@radix-ui/react-collapsible": "^1.1.12",
|
||||
"@radix-ui/react-dialog": "^1.1.15",
|
||||
"@radix-ui/react-dropdown-menu": "^2.1.16",
|
||||
"@radix-ui/react-label": "^2.1.7",
|
||||
"@radix-ui/react-popover": "^1.1.15",
|
||||
"@radix-ui/react-select": "^2.2.6",
|
||||
"@radix-ui/react-separator": "^1.1.7",
|
||||
"@radix-ui/react-slot": "^1.2.3",
|
||||
"@radix-ui/react-tabs": "^1.1.13",
|
||||
"@radix-ui/react-tooltip": "^1.2.8",
|
||||
"@tinymce/tinymce-react": "^6.3.0",
|
||||
"class-variance-authority": "^0.7.1",
|
||||
"clsx": "^2.1.1",
|
||||
"cookies-next": "^6.1.0",
|
||||
"faker-js": "^1.0.0",
|
||||
"js-cookie": "^3.0.5",
|
||||
"jsonwebtoken": "^9.0.2",
|
||||
"jwt-decode": "^4.0.0",
|
||||
"lucide-react": "^0.540.0",
|
||||
"next": "15.4.6",
|
||||
"next": "^15.5.3",
|
||||
"next-themes": "^0.4.6",
|
||||
"react": "19.1.0",
|
||||
"react-dom": "19.1.0",
|
||||
"react-hook-form": "^7.62.0",
|
||||
"sonner": "^2.0.7",
|
||||
"tailwind-merge": "^3.3.1",
|
||||
"tinymce": "^8.1.2",
|
||||
"zod": "^4.0.17"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tailwindcss/postcss": "^4",
|
||||
"@types/js-cookie": "^3.0.6",
|
||||
"@types/jsonwebtoken": "^9.0.10",
|
||||
"@types/node": "^20",
|
||||
"@types/react": "^19",
|
||||
|
|
|
|||
27
public/images/logo.svg
Normal file
27
public/images/logo.svg
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<!-- Creator: CorelDRAW 2018 (64 Bit) -->
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" width="109.504mm" height="32.45mm" version="1.1" style="shape-rendering:geometricPrecision; text-rendering:geometricPrecision; image-rendering:optimizeQuality; fill-rule:evenodd; clip-rule:evenodd"
|
||||
viewBox="0 0 4674.85 1385.32"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<defs>
|
||||
<style type="text/css">
|
||||
<![CDATA[
|
||||
.fil0 {fill:#FF6600}
|
||||
.fil1 {fill:white;fill-rule:nonzero}
|
||||
]]>
|
||||
</style>
|
||||
</defs>
|
||||
<g id="Camada_x0020_1">
|
||||
<metadata id="CorelCorpID_0Corel-Layer"/>
|
||||
<g id="_2536796572048">
|
||||
<path class="fil0" d="M444.51 337.84c440.36,-70.7 476.63,243.79 383.3,374.93 -121.36,170.53 -504.61,132.14 -589.48,-37.21 -31.1,-62.05 -10.18,-188.76 23.33,-238.81 35.98,-53.73 97.41,-85.19 182.85,-98.91zm-444.51 192.86c0,156.21 12.26,277.5 171.92,375.2 214.59,131.32 589.63,134.32 795.72,-31.29 174.6,-140.3 173.88,-487.9 -30.87,-624.12 -52.36,-34.83 -93.57,-53.67 -162.11,-73.16 -236.65,-67.31 -582.01,-30.52 -720.03,178.21 -25.47,38.51 -54.62,111.65 -54.62,175.17z"/>
|
||||
<path class="fil0" d="M3818.84 393.91c0,148.34 145.5,201.77 263.73,234.14 93.01,25.46 365.44,57.71 365.44,126.96 0,66.65 -152.26,76.59 -224.32,76.59 -221.11,0 -348.08,-81.05 -399.39,-93.01l0 196.95 192.2 43.05c87.27,14.66 138.58,22.6 234.54,22.6 441.47,0 507.61,-275.63 337.69,-419.75 -140.93,-119.53 -545.59,-120.82 -545.59,-203.95 0,-95.45 359.81,-45.21 409.3,-31.8l154.22 53.68 0 -186.02 -176.42 -42.42c-214.47,-43.37 -611.42,-48.39 -611.42,222.96z"/>
|
||||
<path class="fil0" d="M2631.61 755.01c0,86.12 62.34,149.87 115.84,185.07 127.76,84.05 323.75,68.39 463.32,16.58 29.5,-10.95 61.1,-25 91.99,-39.32 39.53,-18.31 67.28,-41.35 94.8,-41.97l0 103.95 218.85 0 0 -809.72 -218.85 0 0 492.39c0,18.46 -54.62,47.33 -68.92,56.91 -26.89,18 -50.44,32.94 -78.73,47.11 -130.98,65.59 -399.45,116.59 -399.45,-114.96l0 -481.45 -218.85 0 0 585.41z"/>
|
||||
<path class="fil0" d="M1515.5 289.97c0,-46.34 -5.47,-72.07 -5.47,-120.37l-218.84 0 0 809.72 218.84 0 0 -475.99c0,-25.16 113.08,-106.37 136.96,-120.18 84.99,-49.19 220.78,-69.84 320.2,-46.99 23.36,5.37 43.45,15 62.61,19.46l0 -186.02c-126.58,-10.54 -178.34,-55.19 -359.3,29.15 -83.29,38.81 -108.59,66.67 -154.99,91.22z"/>
|
||||
<polygon class="fil0" points="2166.56,979.32 2385.41,979.32 2385.41,169.6 2166.56,169.6 "/>
|
||||
<path class="fil0" d="M2172.04 131.3l218.85 0 0 -131.3c-30.09,7.01 -146.3,65.43 -180.57,82.04 -33.64,16.3 -38.27,6.4 -38.27,49.26z"/>
|
||||
</g>
|
||||
<path class="fil1" d="M99.26 1380.26l0 -225.54 -81.33 0 0 -27.47 193.01 0 0 27.47 -81.33 0 0 225.54 -30.36 0zm433.68 0l0 -253.02 155.79 0 0 27.47 -125.43 0 0 84.58 115.3 0 0 27.47 -115.3 0 0 86.02 127.23 0 0 27.47 -157.59 0zm578.27 5.06c-30.12,0 -54.1,-8.73 -71.93,-26.2 -17.83,-17.47 -26.75,-42.95 -26.75,-76.45l0 -57.83c0,-33.5 8.91,-58.98 26.75,-76.45 17.83,-17.47 41.81,-26.2 71.93,-26.2 29.88,0 52.83,8.31 68.86,24.94 16.03,16.62 24.04,39.4 24.04,68.31l0 1.81 -30 0 0 -2.89c0,-19.04 -5.12,-34.64 -15.36,-46.81 -10.24,-12.17 -26.08,-18.25 -47.53,-18.25 -21.44,0 -38.19,6.57 -50.24,19.7 -12.05,13.13 -18.07,31.51 -18.07,55.12l0 59.28c0,23.62 6.02,41.99 18.07,55.12 12.05,13.13 28.8,19.7 50.24,19.7 21.45,0 37.29,-6.08 47.53,-18.25 10.24,-12.17 15.36,-27.77 15.36,-46.81l0 -5.78 30 0 0 4.7c0,28.92 -8.01,51.69 -24.04,68.31 -16.02,16.63 -38.98,24.94 -68.86,24.94zm423.92 -5.06l0 -253.02 58.92 0 88.2 233.86 4.7 0 0 -233.86 30 0 0 253.02 -58.92 0 -87.83 -234.22 -5.06 0 0 234.22 -30 0zm615.13 5.06c-30.12,0 -54.16,-8.73 -72.11,-26.2 -17.95,-17.47 -26.93,-42.95 -26.93,-76.45l0 -57.83c0,-33.5 8.98,-58.98 26.93,-76.45 17.95,-17.47 41.99,-26.2 72.11,-26.2 30.36,0 54.52,8.73 72.47,26.2 17.95,17.47 26.93,42.95 26.93,76.45l0 57.83c0,33.5 -8.97,58.98 -26.93,76.45 -17.96,17.47 -42.11,26.2 -72.47,26.2zm0 -27.11c21.93,0 38.92,-6.57 50.96,-19.7 12.05,-13.13 18.07,-31.39 18.07,-54.76l0 -60c0,-23.37 -6.02,-41.63 -18.07,-54.76 -12.05,-13.13 -29.04,-19.7 -50.96,-19.7 -21.69,0 -38.55,6.57 -50.61,19.7 -12.05,13.13 -18.07,31.39 -18.07,54.76l0 60c0,23.37 6.02,41.63 18.07,54.76 12.05,13.13 28.92,19.7 50.61,19.7zm433.32 22.05l0 -253.02 30.36 0 0 225.54 127.96 0 0 27.47 -158.32 0zm565.25 5.06c-30.12,0 -54.16,-8.73 -72.11,-26.2 -17.95,-17.47 -26.93,-42.95 -26.93,-76.45l0 -57.83c0,-33.5 8.98,-58.98 26.93,-76.45 17.95,-17.47 41.99,-26.2 72.11,-26.2 30.36,0 54.52,8.73 72.47,26.2 17.95,17.47 26.93,42.95 26.93,76.45l0 57.83c0,33.5 -8.97,58.98 -26.93,76.45 -17.96,17.47 -42.11,26.2 -72.47,26.2zm0 -27.11c21.93,0 38.92,-6.57 50.96,-19.7 12.05,-13.13 18.07,-31.39 18.07,-54.76l0 -60c0,-23.37 -6.02,-41.63 -18.07,-54.76 -12.05,-13.13 -29.04,-19.7 -50.96,-19.7 -21.69,0 -38.55,6.57 -50.61,19.7 -12.05,13.13 -18.07,31.39 -18.07,54.76l0 60c0,23.37 6.02,41.63 18.07,54.76 12.05,13.13 28.92,19.7 50.61,19.7zm521.51 27.11c-18.8,0 -35.36,-3.91 -49.7,-11.74 -14.34,-7.83 -25.54,-19.34 -33.61,-34.52 -8.07,-15.18 -12.11,-33.98 -12.11,-56.39l0 -57.83c0,-33.5 8.91,-58.98 26.75,-76.45 17.83,-17.47 41.81,-26.2 71.93,-26.2 29.88,0 52.65,8.19 68.31,24.58 15.66,16.38 23.5,38.32 23.5,65.79l0 1.81 -30 0 0 -2.53c0,-12.05 -2.17,-22.77 -6.51,-32.17 -4.34,-9.4 -11.08,-16.81 -20.24,-22.23 -9.16,-5.42 -20.85,-8.13 -35.06,-8.13 -21.44,0 -38.19,6.57 -50.24,19.7 -12.05,13.13 -18.07,31.51 -18.07,55.12l0 59.28c0,23.62 6.02,41.99 18.07,55.12 12.05,13.13 28.92,19.7 50.61,19.7 21.2,0 36.81,-6.02 46.81,-18.07 10,-12.05 15,-28.07 15,-48.07l0 -6.14 -76.63 0 0 -26.02 106.27 0 0 120.36 -27.47 0 0 -27.47 -5.06 0c-2.65,5.3 -6.38,10.48 -11.2,15.54 -4.82,5.06 -11.33,9.16 -19.52,12.29 -8.19,3.13 -18.8,4.7 -31.81,4.7zm433.68 -5.06l0 -253.02 30.36 0 0 253.02 -30.36 0zm351.64 0l78.07 -253.02 53.49 0 78.08 253.02 -31.45 0 -19.52 -63.98 -107.71 0 -19.52 63.98 -31.45 0zm58.55 -91.45l92.17 0 -43.37 -143.13 -5.06 0 -43.73 143.13z"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 5.8 KiB |
|
|
@ -1,11 +1,19 @@
|
|||
'use client'
|
||||
'use server'
|
||||
|
||||
import { cookies } from "next/headers";
|
||||
|
||||
export default async function CookiesGet() {
|
||||
/**
|
||||
* 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();
|
||||
const token = cookieStore.get('access_token');
|
||||
return token?.value;
|
||||
|
||||
// Obtem um token em especifico
|
||||
const data = cookieStore.get(token);
|
||||
|
||||
// Retorna nulo ou o valor do token desejado
|
||||
return data?.value;
|
||||
|
||||
}
|
||||
|
|
@ -1,16 +1,6 @@
|
|||
import appConfig from '../../config/app.json';
|
||||
export default class Json {
|
||||
|
||||
static execute(path: string) {
|
||||
|
||||
return {
|
||||
"state": "go",
|
||||
"api": {
|
||||
"url": "http://localhost:8000/",
|
||||
"prefix": "api/v1",
|
||||
"content_type": "application/json"
|
||||
}
|
||||
}
|
||||
|
||||
static execute() {
|
||||
return appConfig;
|
||||
}
|
||||
|
||||
}
|
||||
15
src/actions/text/GetSigla.ts
Normal file
15
src/actions/text/GetSigla.ts
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
export default function GetSigla(data: string): string {
|
||||
|
||||
if (!data) return "";
|
||||
|
||||
// Remove espaços extras no início e no fim e divide em palavras
|
||||
const palavras = data.trim().split(/\s+/);
|
||||
|
||||
if (palavras.length === 1) {
|
||||
// Apenas uma palavra → retorna as duas primeiras letras
|
||||
return palavras[0].substring(0, 2).toUpperCase();
|
||||
}
|
||||
|
||||
// Duas ou mais palavras → retorna a primeira letra de cada
|
||||
return palavras.map(palavra => palavra.charAt(0).toUpperCase()).join('');
|
||||
}
|
||||
32
src/actions/withClientErrorHandler/withClientErrorHandler.ts
Normal file
32
src/actions/withClientErrorHandler/withClientErrorHandler.ts
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
import withClientErrorHandlerInterface from "./withClientErrorHandlerInterface";
|
||||
|
||||
/**
|
||||
* Códigos de erro que começam com 6, são do front entd, na ordem do alfabeto o F de frontend é a sexta letra
|
||||
*/
|
||||
export function withClientErrorHandler<T extends (...args: any[]) => Promise<any>>(
|
||||
action: T
|
||||
) {
|
||||
return async (...args: Parameters<T>): Promise<withClientErrorHandlerInterface> => {
|
||||
|
||||
try {
|
||||
|
||||
// Executa a função definida
|
||||
const data = await action(...args);
|
||||
|
||||
// Retorna exatamente a mesma resposta retornada pela função
|
||||
return data;
|
||||
|
||||
} catch (error: any) {
|
||||
|
||||
// Retorna o erro de execuçãformatado
|
||||
return {
|
||||
status: 600,
|
||||
message: error?.message || "Erro interno do servidor",
|
||||
data: error
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
export default interface withClientErrorHandlerInterface<T = any> {
|
||||
|
||||
status: number;
|
||||
data?: T;
|
||||
message?: string;
|
||||
|
||||
}
|
||||
|
|
@ -8,7 +8,7 @@ import {
|
|||
CardContent
|
||||
} from "@/components/ui/card";
|
||||
import { useGUsuarioReadHooks } from "@/app/(protected)/(administrativo)/_hooks/g_usuario/useGUsuarioReadHooks";
|
||||
import Usuario from "@/app/(protected)/(administrativo)/_interfaces/IGUsuario";
|
||||
import Usuario from "@/app/(protected)/(administrativo)/_interfaces/GUsuarioInterface";
|
||||
import Loading from "@/app/_components/loading/loading";
|
||||
|
||||
export default function UsuarioDetalhes() {
|
||||
|
|
@ -22,6 +22,7 @@ export default function UsuarioDetalhes() {
|
|||
if (params.id) {
|
||||
fetchUsuario({ usuario_id: Number(params.id) } as Usuario);
|
||||
}
|
||||
console.log("pagina",usuario)
|
||||
}, []);
|
||||
|
||||
if (!usuario) return <Loading type={1} />;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import { zodResolver } from "@hookform/resolvers/zod"
|
|||
import { useForm } from "react-hook-form"
|
||||
import { z } from "zod"
|
||||
import { Input } from "@/components/ui/input"
|
||||
import { UsuarioFormSchema } from "../../../_schemas/GUsuarioSchema"
|
||||
import { GUsuarioSchema } from "../../../_schemas/GUsuarioSchema"
|
||||
|
||||
import {
|
||||
Button
|
||||
|
|
@ -26,14 +26,14 @@ import {
|
|||
|
||||
import { useGUsuarioSaveHook } from "../../../_hooks/g_usuario/useGUsuarioSaveHook"
|
||||
|
||||
type FormValues = z.infer<typeof UsuarioFormSchema>
|
||||
type FormValues = z.infer<typeof GUsuarioSchema>
|
||||
|
||||
export default function UsuarioFormularioPage() {
|
||||
|
||||
const { usuario, saveUsuario } = useGUsuarioSaveHook();
|
||||
|
||||
const form = useForm<FormValues>({
|
||||
resolver: zodResolver(UsuarioFormSchema),
|
||||
resolver: zodResolver(GUsuarioSchema),
|
||||
defaultValues: {
|
||||
login: '',
|
||||
nome_completo: '',
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import {
|
|||
TableRow,
|
||||
} from "@/components/ui/table"
|
||||
|
||||
import Usuario from "../../_interfaces/IGUsuario";
|
||||
import Usuario from "../../_interfaces/GUsuarioInterface";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import Link from "next/link";
|
||||
import { useGUsuarioIndexHook } from "../../_hooks/g_usuario/useGUsuarioIndexHook";
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ export default async function GUsuarioDeleteData(usuarioId: number) {
|
|||
|
||||
const response = await api.send({
|
||||
'method': Methods.DELETE,
|
||||
'endpoint': `administrativo/usuarios/${usuarioId}`
|
||||
'endpoint': `administrativo/g_usuario/${usuarioId}`
|
||||
});
|
||||
|
||||
return response;
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ export default async function GUsuarioIndexData() {
|
|||
|
||||
const response = await api.send({
|
||||
'method': Methods.GET,
|
||||
'endpoint': `administrativo/usuarios/`
|
||||
'endpoint': `administrativo/g_usuario/`
|
||||
});
|
||||
|
||||
return response;
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ export default async function GUsuarioLoginData(form: any) {
|
|||
// Realiza o envio dos dados
|
||||
const response = await api.send({
|
||||
method: Methods.POST,
|
||||
endpoint: `administrativo/usuarios/login`,
|
||||
endpoint: `administrativo/g_usuario/authenticate`,
|
||||
body: form
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ export default async function GUsuarioReadData(usuarioId: number) {
|
|||
|
||||
const response = await api.send({
|
||||
'method': Methods.GET,
|
||||
'endpoint': `administrativo/usuarios/${usuarioId}`
|
||||
'endpoint': `administrativo/g_usuario/${usuarioId}`
|
||||
});
|
||||
|
||||
return response
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ export default async function GUsuarioSaveData(form: any) {
|
|||
|
||||
const response = await api.send({
|
||||
'method': Methods.POST,
|
||||
'endpoint': `administrativo/usuarios/`,
|
||||
'endpoint': `administrativo/g_usuario/`,
|
||||
'body': form
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use client'
|
||||
|
||||
import { useState } from "react"
|
||||
import Usuario from "../../_interfaces/IGUsuario"
|
||||
import Usuario from "../../_interfaces/GUsuarioInterface"
|
||||
import GUsuarioIndex from "../../_services/g_usuario/GUsuarioIndex";
|
||||
import { useResponse } from "@/app/_response/ResponseContext";
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
'use client'
|
||||
|
||||
import GUsuarioLogoutService from "../../_services/g_usuario/GUsuarioLogoutService";
|
||||
|
||||
export const useGUsuarioLogoutHook = () => {
|
||||
|
||||
const logoutUsuario = async () => {
|
||||
|
||||
await GUsuarioLogoutService('access_token')
|
||||
|
||||
}
|
||||
|
||||
return { logoutUsuario }
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
'use client'
|
||||
|
||||
import { useState } from "react"
|
||||
import Usuario from "../../_interfaces/IGUsuario"
|
||||
import Usuario from "../../_interfaces/GUsuarioInterface"
|
||||
import GUsuarioRead from "../../_services/g_usuario/GUsuarioRead";
|
||||
import { useResponse } from "@/app/_response/ResponseContext";
|
||||
|
||||
|
|
@ -14,6 +14,7 @@ export const useGUsuarioReadHooks = () => {
|
|||
const fetchUsuario = async (Usuario: Usuario) => {
|
||||
|
||||
const response = await GUsuarioRead(Usuario.usuario_id);
|
||||
console.log("hook",response.data)
|
||||
|
||||
setUsuario(response.data);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use client'
|
||||
|
||||
import { useState } from "react"
|
||||
import Usuario from "../../_interfaces/IGUsuario"
|
||||
import Usuario from "../../_interfaces/GUsuarioInterface"
|
||||
import GUsuarioSave from "../../_services/g_usuario/GUsuarioSave";
|
||||
import { useResponse } from "@/app/_response/ResponseContext";
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
export default interface Usuario {
|
||||
export default interface GUsuario {
|
||||
usuario_id: number,
|
||||
trocarsenha: string,
|
||||
login: string,
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
import { z } from "zod";
|
||||
|
||||
export const UsuarioFormSchema = z.object({
|
||||
export const GUsuarioSchema = z.object({
|
||||
trocarsenha: z.string().optional(),
|
||||
login: z.string().optional(),
|
||||
senha: z.string().optional(),
|
||||
|
|
|
|||
|
|
@ -8,4 +8,4 @@ export default async function GUsuarioIndex() {
|
|||
|
||||
return response;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -6,10 +6,11 @@ import {
|
|||
|
||||
import GUsuarioLoginData from "../../_data/g_usuario/GUsuarioLoginData"
|
||||
import { redirect } from "next/navigation";
|
||||
import empty from "@/actions/validations/empty";
|
||||
import { withClientErrorHandler } from "@/actions/withClientErrorHandler/withClientErrorHandler";
|
||||
|
||||
export default async function GUsuarioLoginService(form: any) {
|
||||
async function executeGUsuarioLoginService(form: any) {
|
||||
|
||||
// Obtem a resposta da requisição
|
||||
const response = await GUsuarioLoginData(form);
|
||||
|
||||
// Verifica se localizou o usuário
|
||||
|
|
@ -22,7 +23,10 @@ export default async function GUsuarioLoginService(form: any) {
|
|||
|
||||
}
|
||||
|
||||
// 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",
|
||||
|
|
@ -31,6 +35,10 @@ export default async function GUsuarioLoginService(form: any) {
|
|||
maxAge: 60 * 60 * 24,
|
||||
});
|
||||
|
||||
// Redireciona para a págian desejada
|
||||
redirect("/usuarios");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Exporta função encapsulada
|
||||
export const GUsuarioLoginService = withClientErrorHandler(executeGUsuarioLoginService);
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
'use server'
|
||||
|
||||
import {
|
||||
cookies
|
||||
} from "next/headers";
|
||||
|
||||
import { redirect } from "next/navigation";
|
||||
|
||||
export default async function GUsuarioLogoutService(token: string) {
|
||||
|
||||
const cookieStore = await cookies();
|
||||
cookieStore.set(token, '', {
|
||||
expires: new Date(0),
|
||||
path: '/',
|
||||
});
|
||||
|
||||
redirect('/login');
|
||||
|
||||
}
|
||||
|
|
@ -12,6 +12,14 @@ export default async function GUsuarioRead(usuarioId: number) {
|
|||
}
|
||||
}
|
||||
|
||||
return await GUsuarioReadData(usuarioId);
|
||||
try {
|
||||
const response = await GUsuarioReadData(usuarioId);
|
||||
console.log("service",response)
|
||||
return response
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
return error
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,128 @@
|
|||
'use client';
|
||||
|
||||
import { useEffect, useState, useCallback } from "react";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDialog";
|
||||
|
||||
import Header from "@/app/_components/structure/Header";
|
||||
import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog";
|
||||
import Loading from "@/app/_components/loading/loading";
|
||||
import GMedidaTipoTable from "../../_components/g_medidatipo/GMedidaTipoTable";
|
||||
import GMedidaTipoForm from "../../_components/g_medidatipo/GMedidaTipoForm";
|
||||
|
||||
import { useGMedidaTipoReadHook } from "../../_hooks/g_medidatipo/useGMedidaTipoReadHook";
|
||||
import { useGMedidaTipoSaveHook } from "../../_hooks/g_medidatipo/useGMedidaTipoSaveHook";
|
||||
import { useGMedidaTipoRemoveHook } from "../../_hooks/g_medidatipo/useGMedidaTipoRemoveHook";
|
||||
|
||||
import { GMedidaTipoInterface } from "../../_interfaces/GMedidaTipoInterface";
|
||||
|
||||
const initialMedidaTipo: GMedidaTipoInterface = {
|
||||
medida_tipo_id: 0,
|
||||
sigla: '',
|
||||
descricao: ''
|
||||
}
|
||||
|
||||
export default function GMedidaTipoPage() {
|
||||
|
||||
// Hooks para leitura, salvamento e remoção
|
||||
const { gMedidaTipo, fetchGMedidaTipo } = useGMedidaTipoReadHook();
|
||||
const { saveGMedidaTipo } = useGMedidaTipoSaveHook();
|
||||
const { removeGMedidaTipo } = useGMedidaTipoRemoveHook();
|
||||
|
||||
// Estado para controlar o formulário e o item selecionado
|
||||
const [selectedMedidaTipo, setSelectedMedidaTipo] = useState<GMedidaTipoInterface | null>(null);
|
||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||
const [itemToDelete, setItemToDelete] = useState<GMedidaTipoInterface | null>(null);
|
||||
|
||||
// Hook para o modal de confirmação
|
||||
const {
|
||||
isOpen: isConfirmOpen,
|
||||
openDialog: openConfirmDialog,
|
||||
handleConfirm,
|
||||
handleCancel,
|
||||
} = useConfirmDialog();
|
||||
|
||||
// Ações do formulário
|
||||
const handleOpenForm = useCallback((data: GMedidaTipoInterface | null) => {
|
||||
setSelectedMedidaTipo(data);
|
||||
setIsFormOpen(true);
|
||||
}, []);
|
||||
|
||||
const handleCloseForm = useCallback(() => {
|
||||
setIsFormOpen(false);
|
||||
setSelectedMedidaTipo(null);
|
||||
}, []);
|
||||
|
||||
const handleSave = useCallback(async (data: GMedidaTipoInterface) => {
|
||||
await saveGMedidaTipo(data);
|
||||
await fetchGMedidaTipo(); // Atualiza a tabela após salvar
|
||||
handleCloseForm();
|
||||
}, [saveGMedidaTipo, fetchGMedidaTipo]);
|
||||
|
||||
// Ações de deleção
|
||||
const handleConfirmDelete = useCallback((item: GMedidaTipoInterface) => {
|
||||
setItemToDelete(item);
|
||||
openConfirmDialog();
|
||||
}, [openConfirmDialog]);
|
||||
|
||||
const handleDelete = useCallback(async () => {
|
||||
if (itemToDelete) {
|
||||
await removeGMedidaTipo(itemToDelete);
|
||||
await fetchGMedidaTipo(); // Atualiza a tabela após remover
|
||||
}
|
||||
handleCancel();
|
||||
}, [itemToDelete, fetchGMedidaTipo, handleCancel]);
|
||||
|
||||
// Efeito para carregar os dados na montagem do componente
|
||||
useEffect(() => {
|
||||
fetchGMedidaTipo();
|
||||
}, []);
|
||||
|
||||
// Mostra tela de loading enquanto os dados não são carregados
|
||||
if (!gMedidaTipo) {
|
||||
return <Loading type={2} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
{/* Cabeçalho */}
|
||||
<Header
|
||||
title={"Tipos de Medida"}
|
||||
description={"Gerenciamento de tipos de medida"}
|
||||
buttonText={"Novo Tipo de Medida"}
|
||||
buttonAction={(data) => { handleOpenForm(data = initialMedidaTipo) }}
|
||||
/>
|
||||
|
||||
{/* Tabela de Tipos de Medida */}
|
||||
<Card>
|
||||
<CardContent>
|
||||
<GMedidaTipoTable
|
||||
data={gMedidaTipo}
|
||||
onEdit={handleOpenForm}
|
||||
onDelete={handleConfirmDelete}
|
||||
/>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Modal de confirmação */}
|
||||
<ConfirmDialog
|
||||
isOpen={isConfirmOpen}
|
||||
title="Confirmar exclusão"
|
||||
description="Atenção"
|
||||
message={`Deseja realmente excluir o tipo de medida "${itemToDelete?.descricao}"?`}
|
||||
confirmText="Sim, excluir"
|
||||
cancelText="Cancelar"
|
||||
onConfirm={handleDelete}
|
||||
onCancel={handleCancel}
|
||||
/>
|
||||
|
||||
{/* Formulário de criação/edição */}
|
||||
<GMedidaTipoForm
|
||||
isOpen={isFormOpen}
|
||||
data={selectedMedidaTipo}
|
||||
onClose={handleCloseForm}
|
||||
onSave={handleSave}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,167 @@
|
|||
'use client';
|
||||
|
||||
import { useEffect, useState, useCallback } from "react";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDialog";
|
||||
import { useResponse } from "@/app/_response/ResponseContext"
|
||||
|
||||
import Header from "@/app/_components/structure/Header";
|
||||
import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog";
|
||||
import Loading from "@/app/_components/loading/loading";
|
||||
import GTBBairroTable from "../../_components/g_tb_bairro/GTBBairroTable";
|
||||
import GTBBairroForm from "../../_components/g_tb_bairro/GTBBairroForm";
|
||||
|
||||
import { useGTBBairroReadHook } from "../../_hooks/g_tb_bairro/useGTBBairroReadHook";
|
||||
import { useGTBBairroSaveHook } from "../../_hooks/g_tb_bairro/useGTBBairroSaveHook";
|
||||
import { useGTBBairroRemoveHook } from "../../_hooks/g_tb_bairro/useGTBBairroRemoveHook";
|
||||
|
||||
import { GTBBairroInterface } from "../../_interfaces/GTBBairroInterface";
|
||||
import { SituacoesEnum } from "@/enums/SituacoesEnum";
|
||||
|
||||
const initialBairro: GTBBairroInterface = {
|
||||
sistema_id: null,
|
||||
tb_bairro_id: 0,
|
||||
descricao: '',
|
||||
situacao: SituacoesEnum.A
|
||||
}
|
||||
|
||||
export default function GTBBairroPage() {
|
||||
|
||||
// Controle de exibição de respostas
|
||||
const { setResponse } = useResponse();
|
||||
|
||||
// Controle de estado do botão
|
||||
const [buttonIsLoading, setButtonIsLoading] = useState(false);
|
||||
|
||||
// Hooks para leitura e salvamento
|
||||
const { gTBBairro, fetchGTBBairro } = useGTBBairroReadHook();
|
||||
const { saveGTBBairro } = useGTBBairroSaveHook();
|
||||
const { removeGTBBairro } = useGTBBairroRemoveHook();
|
||||
|
||||
// Estado para controlar o formulário e item selecionado
|
||||
const [selectedBairro, setBairro] = useState<GTBBairroInterface | null>(null);
|
||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||
const [itemToDelete, setItemToDelete] = useState<GTBBairroInterface | null>(null);
|
||||
|
||||
// Hook para o modal de confirmação
|
||||
const {
|
||||
isOpen: isConfirmOpen,
|
||||
openDialog: openConfirmDialog,
|
||||
handleCancel,
|
||||
} = useConfirmDialog();
|
||||
|
||||
// Ações do formulário
|
||||
const handleOpenForm = useCallback((data: GTBBairroInterface | null) => {
|
||||
setBairro(data);
|
||||
setIsFormOpen(true);
|
||||
}, []);
|
||||
|
||||
const handleCloseForm = useCallback(() => {
|
||||
setBairro(null);
|
||||
setIsFormOpen(false);
|
||||
}, []);
|
||||
|
||||
const handleSave = useCallback(async (data: GTBBairroInterface) => {
|
||||
|
||||
// Coloca o botão em estado de loading
|
||||
setButtonIsLoading(true);
|
||||
|
||||
// Realiza o procedimento desejado
|
||||
await saveGTBBairro(data);
|
||||
|
||||
// Remove o botão do estado de loading
|
||||
setButtonIsLoading(false);
|
||||
|
||||
// Atualiza a tabela após salvar
|
||||
fetchGTBBairro();
|
||||
|
||||
}, [saveGTBBairro, fetchGTBBairro]);
|
||||
|
||||
// Ações de deleção
|
||||
const handleConfirmDelete = useCallback((item: GTBBairroInterface) => {
|
||||
setItemToDelete(item);
|
||||
openConfirmDialog();
|
||||
}, [openConfirmDialog]);
|
||||
|
||||
const handleDelete = useCallback(async () => {
|
||||
|
||||
// Verifica se existe item para remoção
|
||||
if (!itemToDelete) {
|
||||
|
||||
// Define os dados da resposta visual
|
||||
setResponse({
|
||||
status: 400,
|
||||
message: 'Não foi informado um registro para exclusão'
|
||||
});
|
||||
return;
|
||||
};
|
||||
|
||||
// Executa o hook de remoção
|
||||
await removeGTBBairro(itemToDelete);
|
||||
|
||||
// Atualiza a tabela após remover
|
||||
await fetchGTBBairro();
|
||||
|
||||
// Limpa o item para remoção
|
||||
setItemToDelete(null)
|
||||
|
||||
handleCancel();
|
||||
|
||||
}, [itemToDelete, fetchGTBBairro, handleCancel]);
|
||||
|
||||
// Efeito para carregar os dados na montagem do componente
|
||||
useEffect(() => {
|
||||
fetchGTBBairro();
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Tela de loading enquanto carrega os dados
|
||||
*/
|
||||
if (gTBBairro.length == 0) {
|
||||
return <Loading type={2} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
{/* Cabeçalho */}
|
||||
<Header
|
||||
title={"Bairros"}
|
||||
description={"Gerenciamento de Bairros"}
|
||||
buttonText={"Novo Bairro"}
|
||||
buttonAction={(data) => { handleOpenForm(data = initialBairro) }}
|
||||
/>
|
||||
|
||||
{/* Tabela de Bairros */}
|
||||
<Card>
|
||||
<CardContent>
|
||||
<GTBBairroTable
|
||||
data={gTBBairro}
|
||||
onEdit={handleOpenForm}
|
||||
onDelete={handleConfirmDelete}
|
||||
/>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Modal de confirmação */}
|
||||
<ConfirmDialog
|
||||
isOpen={isConfirmOpen}
|
||||
title="Confirmar exclusão"
|
||||
description="Atenção"
|
||||
message={`Deseja realmente excluir o bairro "${itemToDelete?.descricao}"?`}
|
||||
confirmText="Sim, excluir"
|
||||
cancelText="Cancelar"
|
||||
onConfirm={handleDelete}
|
||||
onCancel={handleCancel}
|
||||
/>
|
||||
|
||||
{/* Formulário de criação/edição */}
|
||||
<GTBBairroForm
|
||||
isOpen={isFormOpen}
|
||||
data={selectedBairro}
|
||||
onClose={handleCloseForm}
|
||||
onSave={handleSave}
|
||||
buttonIsLoading={buttonIsLoading}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,129 @@
|
|||
'use client';
|
||||
|
||||
import { useEffect, useState, useCallback } from "react";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDialog";
|
||||
|
||||
import Header from "@/app/_components/structure/Header";
|
||||
import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog";
|
||||
import Loading from "@/app/_components/loading/loading";
|
||||
import GTBEstadoCivilTable from "../../_components/g_tb_estadocivil/GTBEstadoCivilTable";
|
||||
import GTBEstadoCivilForm from "../../_components/g_tb_estadocivil/GTBEstadoCivilForm";
|
||||
|
||||
import { useGTBEstadoCivilReadHook } from "../../_hooks/g_tb_estadocivil/useGTBEstadoCivilReadHook";
|
||||
import { useGTBEstadoCivilSaveHook } from "../../_hooks/g_tb_estadocivil/useGTBEstadoCivilSaveHook";
|
||||
import { useGTBEstadoCivilRemoveHook } from "../../_hooks/g_tb_estadocivil/useGTBEstadoCivilRemoveHook";
|
||||
|
||||
import { GTBEstadoCivilInterface } from "../../_interfaces/GTBEstadoCivilInterface";
|
||||
|
||||
const initalEstadoCivil: GTBEstadoCivilInterface = {
|
||||
tb_estadocivil_id: 0,
|
||||
sistema_id: 0,
|
||||
descricao: '',
|
||||
situacao: 'A',
|
||||
}
|
||||
|
||||
export default function TBEstadoCivilPage() {
|
||||
|
||||
// Hooks para leitura e salvamento
|
||||
const { gTBEstadoCivil, fetchGTBEstadoCivil } = useGTBEstadoCivilReadHook();
|
||||
const { saveGTBEstadoCivil } = useGTBEstadoCivilSaveHook();
|
||||
const { removeGTBEstadoCivil } = useGTBEstadoCivilRemoveHook();
|
||||
|
||||
// Estado para controlar o formulário e item selecionado
|
||||
const [selectedEstadoCivil, setSelectedEstadoCivil] = useState<GTBEstadoCivilInterface | null>(null);
|
||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||
const [itemToDelete, setItemToDelete] = useState<GTBEstadoCivilInterface | null>(null);
|
||||
|
||||
// Hook para o modal de confirmação
|
||||
const {
|
||||
isOpen: isConfirmOpen,
|
||||
openDialog: openConfirmDialog,
|
||||
handleConfirm,
|
||||
handleCancel,
|
||||
} = useConfirmDialog();
|
||||
|
||||
// Ações do formulário
|
||||
const handleOpenForm = useCallback((data: GTBEstadoCivilInterface | null) => {
|
||||
setSelectedEstadoCivil(data);
|
||||
setIsFormOpen(true);
|
||||
}, []);
|
||||
|
||||
const handleCloseForm = useCallback(() => {
|
||||
setIsFormOpen(false);
|
||||
setSelectedEstadoCivil(null);
|
||||
}, []);
|
||||
|
||||
const handleSave = useCallback(async (data: GTBEstadoCivilInterface) => {
|
||||
await saveGTBEstadoCivil(data);
|
||||
await fetchGTBEstadoCivil(); // Atualiza a tabela após salvar
|
||||
handleCloseForm();
|
||||
}, [saveGTBEstadoCivil, fetchGTBEstadoCivil]);
|
||||
|
||||
// Ações de deleção
|
||||
const handleConfirmDelete = useCallback((item: GTBEstadoCivilInterface) => {
|
||||
setItemToDelete(item);
|
||||
openConfirmDialog();
|
||||
}, [openConfirmDialog]);
|
||||
|
||||
const handleDelete = useCallback(async () => {
|
||||
if (itemToDelete) {
|
||||
await removeGTBEstadoCivil(itemToDelete);
|
||||
await fetchGTBEstadoCivil(); // Atualiza a tabela após remover
|
||||
}
|
||||
handleCancel();
|
||||
}, [itemToDelete, fetchGTBEstadoCivil, handleCancel]);
|
||||
|
||||
// Efeito para carregar os dados na montagem do componente
|
||||
useEffect(() => {
|
||||
fetchGTBEstadoCivil();
|
||||
}, []);
|
||||
|
||||
// Mostra tela de loading enquanto os dados não são carregados
|
||||
if (!gTBEstadoCivil) {
|
||||
return <Loading type={2} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
{/* Cabeçalho */}
|
||||
<Header
|
||||
title={"Estados Civis"}
|
||||
description={"Gerenciamento de Estados Civis"}
|
||||
buttonText={"Novo Estado Civil"}
|
||||
buttonAction={(data) => { handleOpenForm(data = initalEstadoCivil) }}
|
||||
/>
|
||||
|
||||
{/* Tabela de Estados Civis */}
|
||||
<Card>
|
||||
<CardContent>
|
||||
<GTBEstadoCivilTable
|
||||
data={gTBEstadoCivil}
|
||||
onEdit={handleOpenForm}
|
||||
onDelete={handleConfirmDelete}
|
||||
/>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Modal de confirmação */}
|
||||
<ConfirmDialog
|
||||
isOpen={isConfirmOpen}
|
||||
title="Confirmar exclusão"
|
||||
description="Atenção"
|
||||
message={`Deseja realmente excluir o estado civil "${itemToDelete?.descricao}"?`}
|
||||
confirmText="Sim, excluir"
|
||||
cancelText="Cancelar"
|
||||
onConfirm={handleDelete}
|
||||
onCancel={handleCancel}
|
||||
/>
|
||||
|
||||
{/* Formulário de criação/edição */}
|
||||
<GTBEstadoCivilForm
|
||||
isOpen={isFormOpen}
|
||||
data={selectedEstadoCivil}
|
||||
onClose={handleCloseForm}
|
||||
onSave={handleSave}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,163 @@
|
|||
'use client';
|
||||
|
||||
import { useEffect, useState, useCallback } from "react";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
|
||||
import Loading from "@/app/_components/loading/loading";
|
||||
import GTBProfissaoTable from "../../_components/g_tb_profissao/GTBProfissaoTable";
|
||||
import GTBProfissaoForm from "../../_components/g_tb_profissao/GTBProfissaoForm";
|
||||
|
||||
import { useGTBProfissaoReadHook } from "../../_hooks/g_tb_profissao/useGTBProfissaoReadHook";
|
||||
import { useGTBProfissaoSaveHook } from "../../_hooks/g_tb_profissao/useGTBProfissaoSaveHook";
|
||||
import { useGTBProfissaoRemoveHook } from "../../_hooks/g_tb_profissao/useGTBProfissaoRemoveHook";
|
||||
|
||||
import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog";
|
||||
import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDialog";
|
||||
|
||||
import GTBProfissaoInterface from "../../_interfaces/GTBProfissaoInterface";
|
||||
import Header from "@/app/_components/structure/Header";
|
||||
|
||||
export default function TTBAndamentoServico() {
|
||||
// Hooks para leitura e salvamento
|
||||
const { gTBProfissao, fetchGTBProfissao } = useGTBProfissaoReadHook();
|
||||
const { saveGTBProfissao } = useGTBProfissaoSaveHook();
|
||||
const { removeGTBProfissao } = useGTBProfissaoRemoveHook();
|
||||
|
||||
// Estados
|
||||
const [selectedAndamento, setSelectedAndamento] = useState<GTBProfissaoInterface | null>(null);
|
||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||
|
||||
// Estado para saber qual item será deletado
|
||||
const [itemToDelete, setItemToDelete] = useState<GTBProfissaoInterface | null>(null);
|
||||
|
||||
/**
|
||||
* Hook do modal de confirmação
|
||||
*/
|
||||
const {
|
||||
isOpen: isConfirmOpen,
|
||||
openDialog: openConfirmDialog,
|
||||
handleConfirm,
|
||||
handleCancel,
|
||||
} = useConfirmDialog();
|
||||
|
||||
/**
|
||||
* Abre o formulário no modo de edição ou criação
|
||||
*/
|
||||
const handleOpenForm = useCallback((data: GTBProfissaoInterface | null) => {
|
||||
setSelectedAndamento(data);
|
||||
setIsFormOpen(true);
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Fecha o formulário e limpa o andamento selecionado
|
||||
*/
|
||||
const handleCloseForm = useCallback(() => {
|
||||
setSelectedAndamento(null);
|
||||
setIsFormOpen(false);
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Salva os dados do formulário
|
||||
*/
|
||||
const handleSave = useCallback(async (formData: GTBProfissaoInterface) => {
|
||||
|
||||
// Aguarda salvar o registro
|
||||
await saveGTBProfissao(formData);
|
||||
|
||||
// Atualiza a lista de dados
|
||||
fetchGTBProfissao();
|
||||
|
||||
}, [saveGTBProfissao, fetchGTBProfissao, handleCloseForm]);
|
||||
|
||||
/**
|
||||
* Quando o usuário clica em "remover" na tabela
|
||||
*/
|
||||
const handleConfirmDelete = useCallback((item: GTBProfissaoInterface) => {
|
||||
|
||||
// Define o item atual para remoção
|
||||
setItemToDelete(item);
|
||||
|
||||
// Abre o modal de confirmação
|
||||
openConfirmDialog();
|
||||
|
||||
}, [openConfirmDialog]);
|
||||
|
||||
/**
|
||||
* Executa a exclusão de fato quando o usuário confirma
|
||||
*/
|
||||
const handleDelete = useCallback(async () => {
|
||||
|
||||
// Protege contra null
|
||||
if (!itemToDelete) return;
|
||||
|
||||
// Executa o Hook de remoção
|
||||
await removeGTBProfissao(itemToDelete);
|
||||
|
||||
// Atualiza a lista
|
||||
await fetchGTBProfissao();
|
||||
|
||||
// Limpa o item selecionado
|
||||
setItemToDelete(null);
|
||||
|
||||
// Fecha o modal
|
||||
handleCancel();
|
||||
|
||||
}, [itemToDelete, fetchGTBProfissao, handleCancel]);
|
||||
|
||||
/**
|
||||
* Busca inicial dos dados
|
||||
*/
|
||||
useEffect(() => {
|
||||
fetchGTBProfissao();
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Tela de loading enquanto carrega os dados
|
||||
*/
|
||||
if (!gTBProfissao) {
|
||||
return <Loading type={2} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
{/* Cabeçalho */}
|
||||
<Header
|
||||
title={"Profissões"}
|
||||
description={"Gerenciamento de Profissões"}
|
||||
buttonText={"Nova Profissão"}
|
||||
buttonAction={() => { handleOpenForm(null) }}
|
||||
/>
|
||||
|
||||
{/* Tabela de andamentos */}
|
||||
<Card>
|
||||
<CardContent>
|
||||
<GTBProfissaoTable
|
||||
data={gTBProfissao}
|
||||
onEdit={handleOpenForm}
|
||||
onDelete={handleConfirmDelete}
|
||||
/>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Modal de confirmação */}
|
||||
<ConfirmDialog
|
||||
isOpen={isConfirmOpen}
|
||||
title="Confirmar exclusão"
|
||||
description="Atenção"
|
||||
message={`Deseja realmente excluir o andamento "${itemToDelete?.descricao}"?`}
|
||||
confirmText="Sim, excluir"
|
||||
cancelText="Cancelar"
|
||||
onConfirm={handleDelete}
|
||||
onCancel={handleCancel}
|
||||
/>
|
||||
|
||||
{/* Formulário de criação/edição */}
|
||||
<GTBProfissaoForm
|
||||
isOpen={isFormOpen}
|
||||
data={selectedAndamento}
|
||||
onClose={handleCloseForm}
|
||||
onSave={handleSave}
|
||||
/>
|
||||
</div>
|
||||
); 4
|
||||
}
|
||||
|
|
@ -0,0 +1,163 @@
|
|||
'use client';
|
||||
|
||||
import { useEffect, useState, useCallback } from "react";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
|
||||
import Loading from "@/app/_components/loading/loading";
|
||||
import GTBRegimeBensTable from "../../_components/g_tb_regimebens/GTBRegimeBensTable";
|
||||
import GTBRegimeBensForm from "../../_components/g_tb_regimebens/GTBRegimeBensForm";
|
||||
|
||||
import { useGTBRegimeBensReadHook } from "../../_hooks/g_tb_regimebens/useGTBRegimeBensReadHook";
|
||||
import { useGTBRegimeBensSaveHook } from "../../_hooks/g_tb_regimebens/useGTBRegimeBensSaveHook";
|
||||
import { useGTBRegimeBensRemoveHook } from "../../_hooks/g_tb_regimebens/useGTBRegimeBensRemoveHook";
|
||||
|
||||
import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog";
|
||||
import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDialog";
|
||||
|
||||
import GTBRegimeBensInterface from "../../_interfaces/GTBRegimeBensInterface";
|
||||
import Header from "@/app/_components/structure/Header";
|
||||
|
||||
export default function TTBAndamentoServico() {
|
||||
// Hooks para leitura e salvamento
|
||||
const { gTBRegimeBens, fetchGTBRegimeBens } = useGTBRegimeBensReadHook();
|
||||
const { saveGTBRegimeComunhao } = useGTBRegimeBensSaveHook();
|
||||
const { removeGTBRegimeComunhao } = useGTBRegimeBensRemoveHook();
|
||||
|
||||
// Estados
|
||||
const [selectedAndamento, setSelectedAndamento] = useState<GTBRegimeBensInterface | null>(null);
|
||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||
|
||||
// Estado para saber qual item será deletado
|
||||
const [itemToDelete, setItemToDelete] = useState<GTBRegimeBensInterface | null>(null);
|
||||
|
||||
/**
|
||||
* Hook do modal de confirmação
|
||||
*/
|
||||
const {
|
||||
isOpen: isConfirmOpen,
|
||||
openDialog: openConfirmDialog,
|
||||
handleConfirm,
|
||||
handleCancel,
|
||||
} = useConfirmDialog();
|
||||
|
||||
/**
|
||||
* Abre o formulário no modo de edição ou criação
|
||||
*/
|
||||
const handleOpenForm = useCallback((data: GTBRegimeBensInterface | null) => {
|
||||
setSelectedAndamento(data);
|
||||
setIsFormOpen(true);
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Fecha o formulário e limpa o andamento selecionado
|
||||
*/
|
||||
const handleCloseForm = useCallback(() => {
|
||||
setSelectedAndamento(null);
|
||||
setIsFormOpen(false);
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Salva os dados do formulário
|
||||
*/
|
||||
const handleSave = useCallback(async (formData: GTBRegimeBensInterface) => {
|
||||
|
||||
// Aguarda salvar o registro
|
||||
await saveGTBRegimeComunhao(formData);
|
||||
|
||||
// Atualiza a lista de dados
|
||||
fetchGTBRegimeBens();
|
||||
|
||||
}, [saveGTBRegimeComunhao, fetchGTBRegimeBens]);
|
||||
|
||||
/**
|
||||
* Quando o usuário clica em "remover" na tabela
|
||||
*/
|
||||
const handleConfirmDelete = useCallback((item: GTBRegimeBensInterface) => {
|
||||
|
||||
// Define o item atual para remoção
|
||||
setItemToDelete(item);
|
||||
|
||||
// Abre o modal de confirmação
|
||||
openConfirmDialog();
|
||||
|
||||
}, [openConfirmDialog]);
|
||||
|
||||
/**
|
||||
* Executa a exclusão de fato quando o usuário confirma
|
||||
*/
|
||||
const handleDelete = useCallback(async () => {
|
||||
|
||||
// Protege contra null
|
||||
if (!itemToDelete) return;
|
||||
|
||||
// Executa o Hook de remoção
|
||||
await removeGTBRegimeComunhao(itemToDelete);
|
||||
|
||||
// Atualiza a lista
|
||||
await fetchGTBRegimeBens();
|
||||
|
||||
// Limpa o item selecionado
|
||||
setItemToDelete(null);
|
||||
|
||||
// Fecha o modal
|
||||
handleCancel();
|
||||
|
||||
}, [itemToDelete, fetchGTBRegimeBens, handleCancel]);
|
||||
|
||||
/**
|
||||
* Busca inicial dos dados
|
||||
*/
|
||||
useEffect(() => {
|
||||
fetchGTBRegimeBens();
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Tela de loading enquanto carrega os dados
|
||||
*/
|
||||
if (!gTBRegimeBens) {
|
||||
return <Loading type={2} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
{/* Cabeçalho */}
|
||||
<Header
|
||||
title={"Regimes de Bens"}
|
||||
description={"Gerenciamento de Regimes de Bens"}
|
||||
buttonText={"Novo Regime"}
|
||||
buttonAction={() => { handleOpenForm(null) }}
|
||||
/>
|
||||
|
||||
{/* Tabela de andamentos */}
|
||||
<Card>
|
||||
<CardContent>
|
||||
<GTBRegimeBensTable
|
||||
data={gTBRegimeBens}
|
||||
onEdit={handleOpenForm}
|
||||
onDelete={handleConfirmDelete}
|
||||
/>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Modal de confirmação */}
|
||||
<ConfirmDialog
|
||||
isOpen={isConfirmOpen}
|
||||
title="Confirmar exclusão"
|
||||
description="Atenção"
|
||||
message={`Deseja realmente excluir o regime de bens "${itemToDelete?.descricao}"?`}
|
||||
confirmText="Sim, excluir"
|
||||
cancelText="Cancelar"
|
||||
onConfirm={handleDelete}
|
||||
onCancel={handleCancel}
|
||||
/>
|
||||
|
||||
{/* Formulário de criação/edição */}
|
||||
<GTBRegimeBensForm
|
||||
isOpen={isFormOpen}
|
||||
data={selectedAndamento}
|
||||
onClose={handleCloseForm}
|
||||
onSave={handleSave}
|
||||
/>
|
||||
</div>
|
||||
); 4
|
||||
}
|
||||
|
|
@ -0,0 +1,163 @@
|
|||
'use client';
|
||||
|
||||
import { useEffect, useState, useCallback } from "react";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
|
||||
import Loading from "@/app/_components/loading/loading";
|
||||
import GTBRegimeComunhaoTable from "../../_components/g_tb_regimecomunhao/GTBRegimeComunhaoTable";
|
||||
import GTBRegimeComunhaoForm from "../../_components/g_tb_regimecomunhao/GTBRegimeComunhaoForm";
|
||||
|
||||
import { useGTBRegimeComunhaoReadHook } from "../../_hooks/g_tb_regimecomunhao/useGTBRegimeComunhaoReadHook";
|
||||
import { useGTBRegimeComunhaoSaveHook } from "../../_hooks/g_tb_regimecomunhao/useGTBRegimeComunhaoSaveHook";
|
||||
import { useGTBRegimeComunhaoRemoveHook } from "../../_hooks/g_tb_regimecomunhao/useGTBRegimeComunhaoRemoveHook";
|
||||
|
||||
import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog";
|
||||
import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDialog";
|
||||
|
||||
import GTBRegimeComunhaoInterface from "../../_interfaces/GTBRegimeComunhaoInterface";
|
||||
import Header from "@/app/_components/structure/Header";
|
||||
|
||||
export default function TTBAndamentoServico() {
|
||||
// Hooks para leitura e salvamento
|
||||
const { gTBRegimeComunhao, fetchGTBRegimeComunhao } = useGTBRegimeComunhaoReadHook();
|
||||
const { saveGTBRegimeComunhao } = useGTBRegimeComunhaoSaveHook();
|
||||
const { removeGTBRegimeComunhao } = useGTBRegimeComunhaoRemoveHook();
|
||||
|
||||
// Estados
|
||||
const [selectedAndamento, setSelectedAndamento] = useState<GTBRegimeComunhaoInterface | null>(null);
|
||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||
|
||||
// Estado para saber qual item será deletado
|
||||
const [itemToDelete, setItemToDelete] = useState<GTBRegimeComunhaoInterface | null>(null);
|
||||
|
||||
/**
|
||||
* Hook do modal de confirmação
|
||||
*/
|
||||
const {
|
||||
isOpen: isConfirmOpen,
|
||||
openDialog: openConfirmDialog,
|
||||
handleConfirm,
|
||||
handleCancel,
|
||||
} = useConfirmDialog();
|
||||
|
||||
/**
|
||||
* Abre o formulário no modo de edição ou criação
|
||||
*/
|
||||
const handleOpenForm = useCallback((data: GTBRegimeComunhaoInterface | null) => {
|
||||
setSelectedAndamento(data);
|
||||
setIsFormOpen(true);
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Fecha o formulário e limpa o andamento selecionado
|
||||
*/
|
||||
const handleCloseForm = useCallback(() => {
|
||||
setSelectedAndamento(null);
|
||||
setIsFormOpen(false);
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Salva os dados do formulário
|
||||
*/
|
||||
const handleSave = useCallback(async (formData: GTBRegimeComunhaoInterface) => {
|
||||
|
||||
// Aguarda salvar o registro
|
||||
await saveGTBRegimeComunhao(formData);
|
||||
|
||||
// Atualiza a lista de dados
|
||||
fetchGTBRegimeComunhao();
|
||||
|
||||
}, [saveGTBRegimeComunhao, fetchGTBRegimeComunhao]);
|
||||
|
||||
/**
|
||||
* Quando o usuário clica em "remover" na tabela
|
||||
*/
|
||||
const handleConfirmDelete = useCallback((item: GTBRegimeComunhaoInterface) => {
|
||||
|
||||
// Define o item atual para remoção
|
||||
setItemToDelete(item);
|
||||
|
||||
// Abre o modal de confirmação
|
||||
openConfirmDialog();
|
||||
|
||||
}, [openConfirmDialog]);
|
||||
|
||||
/**
|
||||
* Executa a exclusão de fato quando o usuário confirma
|
||||
*/
|
||||
const handleDelete = useCallback(async () => {
|
||||
|
||||
// Protege contra null
|
||||
if (!itemToDelete) return;
|
||||
|
||||
// Executa o Hook de remoção
|
||||
await removeGTBRegimeComunhao(itemToDelete);
|
||||
|
||||
// Atualiza a lista
|
||||
await fetchGTBRegimeComunhao();
|
||||
|
||||
// Limpa o item selecionado
|
||||
setItemToDelete(null);
|
||||
|
||||
// Fecha o modal
|
||||
handleCancel();
|
||||
|
||||
}, [itemToDelete, fetchGTBRegimeComunhao, handleCancel]);
|
||||
|
||||
/**
|
||||
* Busca inicial dos dados
|
||||
*/
|
||||
useEffect(() => {
|
||||
fetchGTBRegimeComunhao();
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Tela de loading enquanto carrega os dados
|
||||
*/
|
||||
if (!gTBRegimeComunhao) {
|
||||
return <Loading type={2} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
{/* Cabeçalho */}
|
||||
<Header
|
||||
title={"Regimes de Comunhão"}
|
||||
description={"Gerenciamento de Regimes de Comunhão"}
|
||||
buttonText={"Novo Regime"}
|
||||
buttonAction={() => { handleOpenForm(null) }}
|
||||
/>
|
||||
|
||||
{/* Tabela de andamentos */}
|
||||
<Card>
|
||||
<CardContent>
|
||||
<GTBRegimeComunhaoTable
|
||||
data={gTBRegimeComunhao}
|
||||
onEdit={handleOpenForm}
|
||||
onDelete={handleConfirmDelete}
|
||||
/>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Modal de confirmação */}
|
||||
<ConfirmDialog
|
||||
isOpen={isConfirmOpen}
|
||||
title="Confirmar exclusão"
|
||||
description="Atenção"
|
||||
message={`Deseja realmente excluir o andamento "${itemToDelete?.descricao}"?`}
|
||||
confirmText="Sim, excluir"
|
||||
cancelText="Cancelar"
|
||||
onConfirm={handleDelete}
|
||||
onCancel={handleCancel}
|
||||
/>
|
||||
|
||||
{/* Formulário de criação/edição */}
|
||||
<GTBRegimeComunhaoForm
|
||||
isOpen={isFormOpen}
|
||||
data={selectedAndamento}
|
||||
onClose={handleCloseForm}
|
||||
onSave={handleSave}
|
||||
/>
|
||||
</div>
|
||||
); 4
|
||||
}
|
||||
|
|
@ -0,0 +1,163 @@
|
|||
'use client';
|
||||
|
||||
import { useEffect, useState, useCallback } from "react";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDialog";
|
||||
|
||||
import Header from "@/app/_components/structure/Header";
|
||||
import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog";
|
||||
import Loading from "@/app/_components/loading/loading";
|
||||
import GTBTipoLogradouroTable from "../../_components/g_tb_tipologradouro/GTBTipoLogradouroTable";
|
||||
import GTBTipoLogradouroForm from "../../_components/g_tb_tipologradouro/GTBTipoLogradouroForm";
|
||||
|
||||
import { useGTBTipoLogradouroReadHook } from "../../_hooks/g_tb_tipologradouro/useGTBTipoLogradouroReadHook";
|
||||
import { useGTBTipoLogradouroSaveHook } from "../../_hooks/g_tb_tipologradouro/useGTBTipoLogradouroSaveHook";
|
||||
import { useGTBTipoLogradouroRemoveHook } from "../../_hooks/g_tb_tipologradouro/useGTBTipoLogradouroRemoveHook";
|
||||
|
||||
import { GTBTipoLogradouroInterface } from "../../_interfaces/GTBTipoLogradouroInterface";
|
||||
|
||||
export default function TTBAndamentoServico() {
|
||||
|
||||
// Hooks para leitura e salvamento
|
||||
const { gTBTipoLogradouro, fetchGTBTipoLogradouro } = useGTBTipoLogradouroReadHook();
|
||||
const { saveGTBTipoLogradouro } = useGTBTipoLogradouroSaveHook();
|
||||
const { removeGTBTipoLogradouro } = useGTBTipoLogradouroRemoveHook();
|
||||
|
||||
// Estados
|
||||
const [selectedTipoLogradouro, setTipoLogradouro] = useState<GTBTipoLogradouroInterface | null>(null);
|
||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||
|
||||
// Estado para saber qual item será deletado
|
||||
const [itemToDelete, setItemToDelete] = useState<GTBTipoLogradouroInterface | null>(null);
|
||||
|
||||
/**
|
||||
* Hook do modal de confirmação
|
||||
*/
|
||||
const {
|
||||
isOpen: isConfirmOpen,
|
||||
openDialog: openConfirmDialog,
|
||||
handleConfirm,
|
||||
handleCancel,
|
||||
} = useConfirmDialog();
|
||||
|
||||
/**
|
||||
* Abre o formulário no modo de edição ou criação
|
||||
*/
|
||||
const handleOpenForm = useCallback((data: GTBTipoLogradouroInterface | null) => {
|
||||
setTipoLogradouro(data);
|
||||
setIsFormOpen(true);
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Fecha o formulário e limpa o andamento selecionado
|
||||
*/
|
||||
const handleCloseForm = useCallback(() => {
|
||||
setTipoLogradouro(null);
|
||||
setIsFormOpen(false);
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Salva os dados do formulário
|
||||
*/
|
||||
const handleSave = useCallback(async (formData: GTBTipoLogradouroInterface) => {
|
||||
|
||||
// Aguarda salvar o registro
|
||||
await saveGTBTipoLogradouro(formData);
|
||||
|
||||
// Atualiza a lista de dados
|
||||
fetchGTBTipoLogradouro();
|
||||
|
||||
}, [saveGTBTipoLogradouro, fetchGTBTipoLogradouro]);
|
||||
|
||||
/**
|
||||
* Quando o usuário clica em "remover" na tabela
|
||||
*/
|
||||
const handleConfirmDelete = useCallback((item: GTBTipoLogradouroInterface) => {
|
||||
|
||||
// Define o item atual para remoção
|
||||
setItemToDelete(item);
|
||||
|
||||
// Abre o modal de confirmação
|
||||
openConfirmDialog();
|
||||
|
||||
}, [openConfirmDialog]);
|
||||
|
||||
/**
|
||||
* Executa a exclusão de fato quando o usuário confirma
|
||||
*/
|
||||
const handleDelete = useCallback(async () => {
|
||||
|
||||
// Protege contra null
|
||||
if (!itemToDelete) return;
|
||||
|
||||
// Executa o Hook de remoção
|
||||
await removeGTBTipoLogradouro(itemToDelete);
|
||||
|
||||
// Atualiza a lista
|
||||
await fetchGTBTipoLogradouro();
|
||||
|
||||
// Limpa o item selecionado
|
||||
setItemToDelete(null);
|
||||
|
||||
// Fecha o modal
|
||||
handleCancel();
|
||||
|
||||
}, [itemToDelete, fetchGTBTipoLogradouro, handleCancel]);
|
||||
|
||||
/**
|
||||
* Busca inicial dos dados
|
||||
*/
|
||||
useEffect(() => {
|
||||
fetchGTBTipoLogradouro();
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Tela de loading enquanto carrega os dados
|
||||
*/
|
||||
if (!gTBTipoLogradouro) {
|
||||
return <Loading type={2} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
{/* Cabeçalho */}
|
||||
<Header
|
||||
title={"Tipos de Logradouros"}
|
||||
description={"Gerenciamento de tipos de Logradouros"}
|
||||
buttonText={"Novo Tipo"}
|
||||
buttonAction={() => { handleOpenForm(null) }}
|
||||
/>
|
||||
|
||||
{/* Tabela de andamentos */}
|
||||
<Card>
|
||||
<CardContent>
|
||||
<GTBTipoLogradouroTable
|
||||
data={gTBTipoLogradouro}
|
||||
onEdit={handleOpenForm}
|
||||
onDelete={handleConfirmDelete}
|
||||
/>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Modal de confirmação */}
|
||||
<ConfirmDialog
|
||||
isOpen={isConfirmOpen}
|
||||
title="Confirmar exclusão"
|
||||
description="Atenção"
|
||||
message={`Deseja realmente excluir o andamento "${itemToDelete?.descricao}"?`}
|
||||
confirmText="Sim, excluir"
|
||||
cancelText="Cancelar"
|
||||
onConfirm={handleDelete}
|
||||
onCancel={handleCancel}
|
||||
/>
|
||||
|
||||
{/* Formulário de criação/edição */}
|
||||
<GTBTipoLogradouroForm
|
||||
isOpen={isFormOpen}
|
||||
data={selectedTipoLogradouro}
|
||||
onClose={handleCloseForm}
|
||||
onSave={handleSave}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,174 @@
|
|||
'use client';
|
||||
|
||||
import { useEffect, useState, useCallback } from "react";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
|
||||
import Loading from "@/app/_components/loading/loading";
|
||||
import TCensecTable from "../../_components/t_censec/TCensecTable";
|
||||
import TCensecForm from "../../_components/t_censec/TCensecForm";
|
||||
|
||||
import { useTCensecReadHook } from "../../_hooks/t_censec/useTCensecReadHook";
|
||||
import { useTCensecSaveHook } from "../../_hooks/t_censec/useTCensecSaveHook";
|
||||
import { useTCensecDeleteHook } from "../../_hooks/t_censec/useTCensecDeleteHook";
|
||||
|
||||
import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog";
|
||||
import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDialog";
|
||||
|
||||
import TCensecInterface from "../../_interfaces/TCensecInterface";
|
||||
import Header from "@/app/_components/structure/Header";
|
||||
|
||||
export default function TTBAndamentoServico() {
|
||||
|
||||
// Controle de estado do botão
|
||||
const [buttonIsLoading, setButtonIsLoading] = useState(false);
|
||||
|
||||
// Hooks para leitura e salvamento
|
||||
const { tCensec, fetchTCensec } = useTCensecReadHook();
|
||||
const { saveTCensec } = useTCensecSaveHook();
|
||||
const { deleteTCensec } = useTCensecDeleteHook();
|
||||
|
||||
// Estados
|
||||
const [selectedAndamento, setSelectedAndamento] = useState<TCensecInterface | null>(null);
|
||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||
|
||||
// Estado para saber qual item será deletado
|
||||
const [itemToDelete, setItemToDelete] = useState<TCensecInterface | null>(null);
|
||||
|
||||
/**
|
||||
* Hook do modal de confirmação
|
||||
*/
|
||||
const {
|
||||
isOpen: isConfirmOpen,
|
||||
openDialog: openConfirmDialog,
|
||||
handleConfirm,
|
||||
handleCancel,
|
||||
} = useConfirmDialog();
|
||||
|
||||
/**
|
||||
* Abre o formulário no modo de edição ou criação
|
||||
*/
|
||||
const handleOpenForm = useCallback((data: TCensecInterface | null) => {
|
||||
setSelectedAndamento(data);
|
||||
setIsFormOpen(true);
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Fecha o formulário e limpa o andamento selecionado
|
||||
*/
|
||||
const handleCloseForm = useCallback(() => {
|
||||
setSelectedAndamento(null);
|
||||
setIsFormOpen(false);
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Salva os dados do formulário
|
||||
*/
|
||||
const handleSave = useCallback(async (formData: TCensecInterface) => {
|
||||
|
||||
// Coloca o botão em estado de loading
|
||||
setButtonIsLoading(true);
|
||||
|
||||
// Aguarda salvar o registro
|
||||
await saveTCensec(formData);
|
||||
|
||||
// Remove o botão em estado de loading
|
||||
setButtonIsLoading(false);
|
||||
|
||||
// Atualiza a lista de dados
|
||||
fetchTCensec();
|
||||
|
||||
}, [saveTCensec, fetchTCensec, handleCloseForm]);
|
||||
|
||||
/**
|
||||
* Quando o usuário clica em "remover" na tabela
|
||||
*/
|
||||
const handleConfirmDelete = useCallback((item: TCensecInterface) => {
|
||||
|
||||
// Define o item atual para remoção
|
||||
setItemToDelete(item);
|
||||
|
||||
// Abre o modal de confirmação
|
||||
openConfirmDialog();
|
||||
|
||||
}, [openConfirmDialog]);
|
||||
|
||||
/**
|
||||
* Executa a exclusão de fato quando o usuário confirma
|
||||
*/
|
||||
const handleDelete = useCallback(async () => {
|
||||
|
||||
// Protege contra null
|
||||
if (!itemToDelete) return;
|
||||
|
||||
// Executa o Hook de remoção
|
||||
await deleteTCensec(itemToDelete);
|
||||
|
||||
// Atualiza a lista
|
||||
await fetchTCensec();
|
||||
|
||||
// Limpa o item selecionado
|
||||
setItemToDelete(null);
|
||||
|
||||
// Fecha o modal
|
||||
handleCancel();
|
||||
|
||||
}, [itemToDelete, fetchTCensec, handleCancel]);
|
||||
|
||||
/**
|
||||
* Busca inicial dos dados
|
||||
*/
|
||||
useEffect(() => {
|
||||
fetchTCensec();
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Tela de loading enquanto carrega os dados
|
||||
*/
|
||||
if (tCensec.length == 0) {
|
||||
return <Loading type={2} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
{/* Cabeçalho */}
|
||||
<Header
|
||||
title={"CENSEC"}
|
||||
description={"Gerenciamento de Centrais"}
|
||||
buttonText={"Nova Central"}
|
||||
buttonAction={() => { handleOpenForm(null) }}
|
||||
/>
|
||||
|
||||
{/* Tabela de andamentos */}
|
||||
<Card>
|
||||
<CardContent>
|
||||
<TCensecTable
|
||||
data={tCensec}
|
||||
onEdit={handleOpenForm}
|
||||
onDelete={handleConfirmDelete}
|
||||
/>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Modal de confirmação */}
|
||||
<ConfirmDialog
|
||||
isOpen={isConfirmOpen}
|
||||
title="Confirmar exclusão"
|
||||
description="Atenção"
|
||||
message={`Deseja realmente excluir o andamento "${itemToDelete?.descricao}"?`}
|
||||
confirmText="Sim, excluir"
|
||||
cancelText="Cancelar"
|
||||
onConfirm={handleDelete}
|
||||
onCancel={handleCancel}
|
||||
/>
|
||||
|
||||
{/* Formulário de criação/edição */}
|
||||
<TCensecForm
|
||||
isOpen={isFormOpen}
|
||||
data={selectedAndamento}
|
||||
onClose={handleCloseForm}
|
||||
onSave={handleSave}
|
||||
buttonIsLoading={buttonIsLoading}
|
||||
/>
|
||||
</div>
|
||||
); 4
|
||||
}
|
||||
|
|
@ -0,0 +1,134 @@
|
|||
'use client';
|
||||
|
||||
import { useEffect, useState, useCallback } from "react";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDialog";
|
||||
|
||||
import Header from "@/app/_components/structure/Header";
|
||||
import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog";
|
||||
import Loading from "@/app/_components/loading/loading";
|
||||
|
||||
import TCensecNaturezaLitigioTable from "../../_components/t_censecnaturezalitigio/TCensecNaturezaLitigioTable";
|
||||
import TCensecNaturezaLitigioForm from "../../_components/t_censecnaturezalitigio/TCensecNaturezaLitigioForm";
|
||||
|
||||
import { useTCensecNaturezaLitigioReadHook } from "../../_hooks/t_censecnaturezalitigio/useTCensecNaturezaLitigioReadHook";
|
||||
import { useTCensecNaturezaLitigioSaveHook } from "../../_hooks/t_censecnaturezalitigio/useTCensecNaturezaLitigioSaveHook";
|
||||
import { useTCensecNaturezaLitigioRemoveHook } from "../../_hooks/t_censecnaturezalitigio/useTCensecNaturezaLitigioRemoveHook";
|
||||
|
||||
import { TCensecNaturezaLitigioInterface } from "../../_interfaces/TCensecNaturezaLitigioInterface";
|
||||
|
||||
const initialCensecNaturezaLitigio: TCensecNaturezaLitigioInterface = {
|
||||
censec_naturezalitigio_id: 0,
|
||||
descricao: "",
|
||||
situacao: 'A'
|
||||
}
|
||||
|
||||
export default function TCensecNaturezaLitigioPage() {
|
||||
|
||||
// Hooks
|
||||
const { tCensecNaturezaLitigio, fetchTCensecNaturezaLitigio } = useTCensecNaturezaLitigioReadHook();
|
||||
const { saveTCensecNaturezaLitigio } = useTCensecNaturezaLitigioSaveHook();
|
||||
const { removeTCensecNaturezaLitigio } = useTCensecNaturezaLitigioRemoveHook();
|
||||
|
||||
// Estados
|
||||
const [selectedItem, setSelectedItem] = useState<TCensecNaturezaLitigioInterface | null>(null);
|
||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||
const [itemToDelete, setItemToDelete] = useState<TCensecNaturezaLitigioInterface | null>(null);
|
||||
|
||||
// Modal de confirmação
|
||||
const {
|
||||
isOpen: isConfirmOpen,
|
||||
openDialog: openConfirmDialog,
|
||||
handleConfirm,
|
||||
handleCancel,
|
||||
} = useConfirmDialog();
|
||||
|
||||
// Abrir formulário (criação ou edição)
|
||||
const handleOpenForm = useCallback((item: TCensecNaturezaLitigioInterface | null) => {
|
||||
setSelectedItem(item);
|
||||
setIsFormOpen(true);
|
||||
}, []);
|
||||
|
||||
// Fechar formulário
|
||||
const handleCloseForm = useCallback(() => {
|
||||
setSelectedItem(null);
|
||||
setIsFormOpen(false);
|
||||
}, []);
|
||||
|
||||
// Salvar item
|
||||
const handleSave = useCallback(async (formData: TCensecNaturezaLitigioInterface) => {
|
||||
await saveTCensecNaturezaLitigio(formData);
|
||||
console.log(formData)
|
||||
await fetchTCensecNaturezaLitigio();
|
||||
}, [saveTCensecNaturezaLitigio, fetchTCensecNaturezaLitigio]);
|
||||
|
||||
// Confirmar remoção
|
||||
const handleConfirmDelete = useCallback((item: TCensecNaturezaLitigioInterface) => {
|
||||
console.log("item", item)
|
||||
setItemToDelete(item);
|
||||
openConfirmDialog();
|
||||
}, [openConfirmDialog]);
|
||||
|
||||
// Executar remoção
|
||||
const handleDelete = useCallback(async () => {
|
||||
if (!itemToDelete) return;
|
||||
console.log("item to delete",itemToDelete)
|
||||
await removeTCensecNaturezaLitigio(itemToDelete);
|
||||
await fetchTCensecNaturezaLitigio();
|
||||
setItemToDelete(null);
|
||||
handleCancel();
|
||||
}, [itemToDelete, fetchTCensecNaturezaLitigio, handleCancel]);
|
||||
|
||||
// Fetch inicial
|
||||
useEffect(() => {
|
||||
fetchTCensecNaturezaLitigio();
|
||||
}, []);
|
||||
|
||||
// Loading enquanto carrega
|
||||
if (!tCensecNaturezaLitigio) {
|
||||
return <Loading type={2} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
{/* Cabeçalho */}
|
||||
<Header
|
||||
title={"Natureza do Litígio"}
|
||||
description={"Gerenciamento de Naturezas do Litígio"}
|
||||
buttonText={"Nova Natureza"}
|
||||
buttonAction={(data) => handleOpenForm(data = initialCensecNaturezaLitigio)}
|
||||
/>
|
||||
|
||||
{/* Tabela */}
|
||||
<Card>
|
||||
<CardContent>
|
||||
<TCensecNaturezaLitigioTable
|
||||
data={tCensecNaturezaLitigio}
|
||||
onEdit={handleOpenForm}
|
||||
onDelete={handleConfirmDelete}
|
||||
/>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Modal de confirmação */}
|
||||
<ConfirmDialog
|
||||
isOpen={isConfirmOpen}
|
||||
title="Confirmar exclusão"
|
||||
description="Atenção"
|
||||
message={`Deseja realmente excluir a natureza "${itemToDelete?.descricao}"?`}
|
||||
confirmText="Sim, excluir"
|
||||
cancelText="Cancelar"
|
||||
onConfirm={handleDelete}
|
||||
onCancel={handleCancel}
|
||||
/>
|
||||
|
||||
{/* Formulário */}
|
||||
<TCensecNaturezaLitigioForm
|
||||
isOpen={isFormOpen}
|
||||
data={selectedItem}
|
||||
onClose={handleCloseForm}
|
||||
onSave={handleSave}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,83 @@
|
|||
'use client'
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import { useParams } from "next/navigation";
|
||||
|
||||
import {
|
||||
Card,
|
||||
CardContent
|
||||
} from "@/components/ui/card";
|
||||
import MainEditor from "@/components/MainEditor";
|
||||
|
||||
import Loading from "@/app/_components/loading/loading";
|
||||
import { useTMinutaReadHook } from '../../../../_hooks/t_minuta/useTMinutaReadHook';
|
||||
import { TMinutaInterface } from '../../../../_interfaces/TMinutaInterface';
|
||||
|
||||
export default function TMinutaDetalhes() {
|
||||
const params = useParams();
|
||||
const { tMinuta, fetchTMinuta } = useTMinutaReadHook();
|
||||
const [editorContent, setEditorContent] = useState<string | null>(null); // Inicialmente nulo até o texto ser carregado
|
||||
|
||||
useEffect(() => {
|
||||
if (params.id) {
|
||||
fetchTMinuta({ t_minuta_id: Number(params.id) } as TMinutaInterface);
|
||||
}
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (tMinuta?.texto) {
|
||||
setEditorContent(tMinuta.texto); // Atualiza o conteúdo assim que estiver disponível
|
||||
}
|
||||
}, [tMinuta]); // Dependência de `tMinuta` para que a atualização aconteça quando os dados chegarem
|
||||
|
||||
const handleEditorChange = (content: string) => {
|
||||
setEditorContent(content); // Atualiza o estado com o conteúdo do editor
|
||||
};
|
||||
|
||||
if (!tMinuta) return <Loading type={1} />;
|
||||
|
||||
// Renderiza o editor apenas se o texto foi carregado
|
||||
if (editorContent === null) {
|
||||
return <Loading type={1} />; // Pode mostrar um carregando ou qualquer outra coisa enquanto o conteúdo não está disponível
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Card>
|
||||
<CardContent>
|
||||
<div className="mb-4 grid gap-4 grid-cols-2">
|
||||
<div>
|
||||
<div className="text-2xl font-semibold">
|
||||
Descrição
|
||||
</div>
|
||||
<div className="text-xl">
|
||||
{tMinuta.descricao}
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div className="text-2xl font-semibold">
|
||||
Situação
|
||||
</div>
|
||||
<div className="text-xl">
|
||||
{tMinuta.situacao === "A" ? "Ativo" : "Inativo"}
|
||||
</div>
|
||||
</div>
|
||||
<div className="col-span-2">
|
||||
<div className="text-2xl font-semibold">
|
||||
Texto
|
||||
</div>
|
||||
<MainEditor
|
||||
initialValue={editorContent} // Passa o conteúdo do editor
|
||||
onEditorChange={handleEditorChange} // Função que atualiza o estado
|
||||
margins={{
|
||||
top: "2", bottom: "2", left: "2", right: "2"
|
||||
}}
|
||||
size={{ width: 794, height: 1123 }} // Você pode ajustar o tamanho aqui
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,113 @@
|
|||
'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 {
|
||||
Form,
|
||||
FormControl,
|
||||
FormField,
|
||||
FormItem,
|
||||
FormLabel,
|
||||
FormMessage
|
||||
} from '@/components/ui/form';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Label } from '@/components/ui/label';
|
||||
|
||||
import MainEditor from '@/components/MainEditor';
|
||||
import { TMinutaSchema } from '../../../_schemas/TMinutaSchema';
|
||||
import { useTMinutaSaveHook } from '../../../_hooks/t_minuta/useTMinutaSaveHook';
|
||||
import { Card, CardContent } from '@/components/ui/card';
|
||||
|
||||
type FormValues = z.infer<typeof TMinutaSchema>;
|
||||
|
||||
export default function TMinutaForm() {
|
||||
|
||||
const { tMinuta, saveTMinuta } = useTMinutaSaveHook();
|
||||
|
||||
const form = useForm<FormValues>({
|
||||
resolver: zodResolver(TMinutaSchema),
|
||||
defaultValues: {
|
||||
natureza_id: undefined,
|
||||
descricao: '',
|
||||
situacao: 'A',
|
||||
texto: '',
|
||||
}
|
||||
});
|
||||
|
||||
async function onSubmit(values: FormValues) {
|
||||
saveTMinuta(values);
|
||||
}
|
||||
|
||||
return (
|
||||
<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>
|
||||
)}
|
||||
/>
|
||||
|
||||
{/* 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>{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>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,107 @@
|
|||
'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 TMinutaTable from "../../_components/t_minuta/TMinutaTable";
|
||||
import TMinutaForm from "../../_components/t_minuta/TMinutaForm";
|
||||
|
||||
import { useTMinutaReadHook } from "../../_hooks/t_minuta/useTMinutaReadHook";
|
||||
import { useTMinutaSaveHook } from "../../_hooks/t_minuta/useTMinutaSaveHook";
|
||||
import { useTMinutaRemoveHook } from "../../_hooks/t_minuta/useTMinutaRemoveHook";
|
||||
|
||||
import { TMinutaInterface } from "../../_interfaces/TMinutaInterface";
|
||||
import { useTMinutaIndexHook } from "../../_hooks/t_minuta/useTMinutaIndexHook";
|
||||
|
||||
export default function TMinutaPage() {
|
||||
|
||||
// Hooks de leitura e escrita
|
||||
const { tMinuta, fetchTMinuta } = useTMinutaIndexHook();
|
||||
const { saveTMinuta } = useTMinutaSaveHook();
|
||||
const { removeTMinuta } = useTMinutaRemoveHook();
|
||||
|
||||
// Estados
|
||||
const [selectedMinuta, setSelectedMinuta] = useState<TMinutaInterface | null>(null);
|
||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||
const [itemToDelete, setItemToDelete] = useState<TMinutaInterface | null>(null);
|
||||
|
||||
// Hook de confirmação
|
||||
const {
|
||||
isOpen: isConfirmOpen,
|
||||
openDialog: openConfirmDialog,
|
||||
handleConfirm,
|
||||
handleCancel
|
||||
} = useConfirmDialog();
|
||||
|
||||
// Abertura do formulário
|
||||
const handleOpenForm = useCallback((data: TMinutaInterface | null) => {
|
||||
setSelectedMinuta(data);
|
||||
setIsFormOpen(true);
|
||||
}, []);
|
||||
|
||||
// Ação de clique em remover
|
||||
const handleConfirmDelete = useCallback((item: TMinutaInterface) => {
|
||||
setItemToDelete(item);
|
||||
openConfirmDialog();
|
||||
}, [openConfirmDialog]);
|
||||
|
||||
// Remoção da minuta após confirmação
|
||||
const handleDelete = useCallback(async () => {
|
||||
if (!itemToDelete) return;
|
||||
|
||||
await removeTMinuta(itemToDelete);
|
||||
await fetchTMinuta();
|
||||
setItemToDelete(null);
|
||||
handleCancel();
|
||||
}, [itemToDelete, removeTMinuta, fetchTMinuta, handleCancel]);
|
||||
|
||||
// Fetch inicial
|
||||
useEffect(() => {
|
||||
fetchTMinuta();
|
||||
}, []);
|
||||
|
||||
// Loading enquanto carrega
|
||||
if (tMinuta === undefined) {
|
||||
return <Loading type={2} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
{/* Cabeçalho */}
|
||||
<Header
|
||||
title="Minutas"
|
||||
description="Gerenciamento de minutas de atos notariais"
|
||||
buttonText="Nova Minuta"
|
||||
buttonAction={() => handleOpenForm(null)}
|
||||
/>
|
||||
|
||||
{/* Tabela */}
|
||||
<Card>
|
||||
<CardContent>
|
||||
<TMinutaTable
|
||||
data={tMinuta}
|
||||
onEdit={handleOpenForm}
|
||||
onDelete={handleConfirmDelete}
|
||||
/>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Diálogo de confirmação */}
|
||||
<ConfirmDialog
|
||||
isOpen={isConfirmOpen}
|
||||
title="Confirmar exclusão"
|
||||
description="Atenção"
|
||||
message={`Deseja realmente excluir a minuta "${itemToDelete?.descricao}"?`}
|
||||
confirmText="Sim, excluir"
|
||||
cancelText="Cancelar"
|
||||
onConfirm={handleDelete}
|
||||
onCancel={handleCancel}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,160 @@
|
|||
'use client';
|
||||
|
||||
import { useEffect, useState, useCallback } from "react";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
|
||||
import Loading from "@/app/_components/loading/loading";
|
||||
import TTBAndamentoServicoTable from "../../_components/t_tb_andamentoservico/TTBAndamentoServicoTable";
|
||||
import TTBAndamentoServicoForm from "../../_components/t_tb_andamentoservico/TTBAndamentoServicoForm";
|
||||
|
||||
import { useTTBAndamentoServicoReadHook } from "../../_hooks/t_tb_andamentoservico/useTTBAndamentoServicoReadHook";
|
||||
import { useTTBAndamentoServicoSaveHook } from "../../_hooks/t_tb_andamentoservico/useTTBAndamentoServicoSaveHook";
|
||||
|
||||
import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog";
|
||||
import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDialog";
|
||||
|
||||
import TTBAndamentoServicoInterface from "../../_interfaces/TTBAndamentoServicoInterface";
|
||||
import { useTTBAndamentoServicoDeleteHook } from "../../_hooks/t_tb_andamentoservico/useTTBAndamentoServicoDeleteHook";
|
||||
import Header from "@/app/_components/structure/Header";
|
||||
|
||||
export default function TTBAndamentoServico() {
|
||||
|
||||
// Hooks para leitura e salvamento
|
||||
const { tTBAndamentosServicos, fetchTTBAndamentoServico } = useTTBAndamentoServicoReadHook();
|
||||
const { saveTTBAndamentoServico } = useTTBAndamentoServicoSaveHook();
|
||||
const { deleteTTBAndamentoServico } = useTTBAndamentoServicoDeleteHook();
|
||||
|
||||
// Estados
|
||||
const [selectedAndamento, setSelectedAndamento] = useState<TTBAndamentoServicoInterface | null>(null);
|
||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||
|
||||
// Estado para saber qual item será deletado
|
||||
const [itemToDelete, setItemToDelete] = useState<TTBAndamentoServicoInterface | null>(null);
|
||||
|
||||
/**
|
||||
* Hook do modal de confirmação
|
||||
*/
|
||||
const {
|
||||
isOpen: isConfirmOpen,
|
||||
openDialog: openConfirmDialog,
|
||||
handleConfirm,
|
||||
handleCancel,
|
||||
} = useConfirmDialog();
|
||||
|
||||
/**
|
||||
* Abre o formulário no modo de edição ou criação
|
||||
*/
|
||||
const handleOpenForm = useCallback((data: TTBAndamentoServicoInterface | null) => {
|
||||
setSelectedAndamento(data);
|
||||
setIsFormOpen(true);
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Fecha o formulário e limpa o andamento selecionado
|
||||
*/
|
||||
const handleCloseForm = useCallback(() => {
|
||||
setSelectedAndamento(null);
|
||||
setIsFormOpen(false);
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Salva os dados do formulário
|
||||
*/
|
||||
const handleSave = useCallback(async (formData: TTBAndamentoServicoInterface) => {
|
||||
|
||||
// Aguarda salvar o registro
|
||||
await saveTTBAndamentoServico(formData);
|
||||
|
||||
// Atualiza a lista de dados
|
||||
fetchTTBAndamentoServico();
|
||||
|
||||
}, [saveTTBAndamentoServico, fetchTTBAndamentoServico]);
|
||||
|
||||
/**
|
||||
* Quando o usuário clica em "remover" na tabela
|
||||
*/
|
||||
const handleConfirmDelete = useCallback((item: TTBAndamentoServicoInterface) => {
|
||||
setItemToDelete(item);
|
||||
openConfirmDialog();
|
||||
}, [openConfirmDialog]);
|
||||
|
||||
/**
|
||||
* Executa a exclusão de fato quando o usuário confirma
|
||||
*/
|
||||
const handleDelete = useCallback(async () => {
|
||||
|
||||
// Protege contra null
|
||||
if (!itemToDelete) return;
|
||||
|
||||
|
||||
// Executa o Hook de remoção
|
||||
await deleteTTBAndamentoServico(itemToDelete);
|
||||
|
||||
// Atualiza a lista
|
||||
await fetchTTBAndamentoServico();
|
||||
|
||||
// Limpa o item selecionado
|
||||
setItemToDelete(null);
|
||||
|
||||
// Fecha o modal
|
||||
handleCancel();
|
||||
|
||||
}, [itemToDelete, fetchTTBAndamentoServico, handleCancel]);
|
||||
|
||||
/**
|
||||
* Busca inicial dos dados
|
||||
*/
|
||||
useEffect(() => {
|
||||
fetchTTBAndamentoServico();
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Tela de loading enquanto carrega os dados
|
||||
*/
|
||||
if (!tTBAndamentosServicos) {
|
||||
return <Loading type={2} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
{/* Cabeçalho */}
|
||||
<Header
|
||||
title={"Andamentos"}
|
||||
description={"Gerenciamento de Andamentos de Atos"}
|
||||
buttonText={"Novo Andamento"}
|
||||
buttonAction={() => { handleOpenForm(null) }}
|
||||
/>
|
||||
|
||||
{/* Tabela de andamentos */}
|
||||
<Card>
|
||||
<CardContent>
|
||||
<TTBAndamentoServicoTable
|
||||
data={tTBAndamentosServicos}
|
||||
onEdit={handleOpenForm}
|
||||
onDelete={handleConfirmDelete}
|
||||
/>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Modal de confirmação */}
|
||||
<ConfirmDialog
|
||||
isOpen={isConfirmOpen}
|
||||
title="Confirmar exclusão"
|
||||
description="Atenção"
|
||||
message={`Deseja realmente excluir o andamento "${itemToDelete?.descricao}"?`}
|
||||
confirmText="Sim, excluir"
|
||||
cancelText="Cancelar"
|
||||
onConfirm={handleDelete}
|
||||
onCancel={handleCancel}
|
||||
/>
|
||||
|
||||
{/* Formulário de criação/edição */}
|
||||
<TTBAndamentoServicoForm
|
||||
isOpen={isFormOpen}
|
||||
data={selectedAndamento}
|
||||
onClose={handleCloseForm}
|
||||
onSave={handleSave}
|
||||
/>
|
||||
</div>
|
||||
); 4
|
||||
}
|
||||
|
|
@ -0,0 +1,164 @@
|
|||
'use client';
|
||||
|
||||
import { useEffect, useState, useCallback } from "react";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
|
||||
import Loading from "@/app/_components/loading/loading";
|
||||
import Header from "@/app/_components/structure/Header";
|
||||
import TTBReconhecimentoTipoTable from "../../_components/t_tb_reconhecimentotipo/TTBReconhecimentoTipoTable";
|
||||
import TTBReconhecimentoTipoForm from "../../_components/t_tb_reconhecimentotipo/TTBReconhecimentoTipoForm";
|
||||
|
||||
import { useTTBReconhecimentoTipoReadHook } from "../../_hooks/t_tb_reconhecimentotipo/useTTBReconhecimentoTipoReadHook";
|
||||
import { useTTBReconhecimentoTipoSaveHook } from "../../_hooks/t_tb_reconhecimentotipo/useTTBReconhecimentoTipoSaveHook";
|
||||
import { useTTBReconhecimentoTipoDeleteHook } from "../../_hooks/t_tb_reconhecimentotipo/useTTBReconhecimentoTipoDeleteHook";
|
||||
|
||||
import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog";
|
||||
import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDialog";
|
||||
|
||||
import TTBReconhecimentoTipoInterface from "../../_interfaces/TTBReconhecimentoTipoInterface";
|
||||
|
||||
export default function TTBAndamentoServico() {
|
||||
|
||||
// Hooks para leitura e salvamento
|
||||
const { tTBReconhecimentosTipos, fetchTTBReconhecimentosTipos } = useTTBReconhecimentoTipoReadHook();
|
||||
const { saveTTBReconhecimentoTipo } = useTTBReconhecimentoTipoSaveHook();
|
||||
const { deleteTTBReconhecimentoTipo } = useTTBReconhecimentoTipoDeleteHook();
|
||||
|
||||
// Estados
|
||||
const [selectedReconhecimentoTipo, setReconhecimentoTipo] = useState<TTBReconhecimentoTipoInterface | null>(null);
|
||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||
|
||||
// Estado para saber qual item será deletado
|
||||
const [itemToDelete, setItemToDelete] = useState<TTBReconhecimentoTipoInterface | null>(null);
|
||||
|
||||
/**
|
||||
* Hook do modal de confirmação
|
||||
*/
|
||||
const {
|
||||
isOpen: isConfirmOpen,
|
||||
openDialog: openConfirmDialog,
|
||||
handleConfirm,
|
||||
handleCancel,
|
||||
} = useConfirmDialog();
|
||||
|
||||
/**
|
||||
* Abre o formulário no modo de edição ou criação
|
||||
*/
|
||||
const handleOpenForm = useCallback((data: TTBReconhecimentoTipoInterface | null) => {
|
||||
setReconhecimentoTipo(data);
|
||||
setIsFormOpen(true);
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Fecha o formulário e limpa o andamento selecionado
|
||||
*/
|
||||
const handleCloseForm = useCallback(() => {
|
||||
setReconhecimentoTipo(null);
|
||||
setIsFormOpen(false);
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Salva os dados do formulário
|
||||
*/
|
||||
const handleSave = useCallback(async (formData: TTBReconhecimentoTipoInterface) => {
|
||||
|
||||
// Aguarda salvar o registro
|
||||
await saveTTBReconhecimentoTipo(formData);
|
||||
|
||||
// Atualiza a lista de dados
|
||||
fetchTTBReconhecimentosTipos();
|
||||
|
||||
}, [saveTTBReconhecimentoTipo, fetchTTBReconhecimentosTipos]);
|
||||
|
||||
/**
|
||||
* Quando o usuário clica em "remover" na tabela
|
||||
*/
|
||||
const handleConfirmDelete = useCallback((item: TTBReconhecimentoTipoInterface) => {
|
||||
|
||||
// Define o item atual para remoção
|
||||
setItemToDelete(item);
|
||||
|
||||
// Abre o modal de confirmação
|
||||
openConfirmDialog();
|
||||
|
||||
}, [openConfirmDialog]);
|
||||
|
||||
/**
|
||||
* Executa a exclusão de fato quando o usuário confirma
|
||||
*/
|
||||
const handleDelete = useCallback(async () => {
|
||||
|
||||
// Protege contra null
|
||||
if (!itemToDelete) return;
|
||||
|
||||
// Executa o Hook de remoção
|
||||
await deleteTTBReconhecimentoTipo(itemToDelete);
|
||||
|
||||
// Atualiza a lista
|
||||
await fetchTTBReconhecimentosTipos();
|
||||
|
||||
// Limpa o item selecionado
|
||||
setItemToDelete(null);
|
||||
|
||||
// Fecha o modal
|
||||
handleCancel();
|
||||
|
||||
}, [itemToDelete, fetchTTBReconhecimentosTipos, handleCancel]);
|
||||
|
||||
/**
|
||||
* Busca inicial dos dados
|
||||
*/
|
||||
useEffect(() => {
|
||||
fetchTTBReconhecimentosTipos();
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Tela de loading enquanto carrega os dados
|
||||
*/
|
||||
if (!tTBReconhecimentosTipos) {
|
||||
return <Loading type={2} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
{/* Cabeçalho */}
|
||||
<Header
|
||||
title={"Reconhecimentos"}
|
||||
description={"Gerenciamento de tipos de reconhecimentos"}
|
||||
buttonText={"Novo Tipo"}
|
||||
buttonAction={() => { handleOpenForm(null) }}
|
||||
/>
|
||||
|
||||
{/* Tabela de andamentos */}
|
||||
<Card>
|
||||
<CardContent>
|
||||
<TTBReconhecimentoTipoTable
|
||||
data={tTBReconhecimentosTipos}
|
||||
onEdit={handleOpenForm}
|
||||
onDelete={handleConfirmDelete}
|
||||
/>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Modal de confirmação */}
|
||||
<ConfirmDialog
|
||||
isOpen={isConfirmOpen}
|
||||
title="Confirmar exclusão"
|
||||
description="Atenção"
|
||||
message={`Deseja realmente excluir o andamento "${itemToDelete?.descricao}"?`}
|
||||
confirmText="Sim, excluir"
|
||||
cancelText="Cancelar"
|
||||
onConfirm={handleDelete}
|
||||
onCancel={handleCancel}
|
||||
/>
|
||||
|
||||
{/* Formulário de criação/edição */}
|
||||
<TTBReconhecimentoTipoForm
|
||||
isOpen={isFormOpen}
|
||||
data={selectedReconhecimentoTipo}
|
||||
onClose={handleCloseForm}
|
||||
onSave={handleSave}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,125 @@
|
|||
'use client';
|
||||
|
||||
import z from "zod";
|
||||
import { useEffect } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
Dialog,
|
||||
DialogClose,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle
|
||||
} from "@/components/ui/dialog";
|
||||
import {
|
||||
Form,
|
||||
FormControl,
|
||||
FormField,
|
||||
FormItem,
|
||||
FormLabel,
|
||||
FormMessage
|
||||
} from "@/components/ui/form";
|
||||
import { Input } from "@/components/ui/input";
|
||||
|
||||
import { GMedidaTipoSchema } from "../../_schemas/GMedidaTipoSchema";
|
||||
import { GMedidaTipoInterface } from "../../_interfaces/GMedidaTipoInterface";
|
||||
|
||||
type FormValues = z.infer<typeof GMedidaTipoSchema>;
|
||||
|
||||
interface GMedidaTipoFormProps {
|
||||
isOpen: boolean;
|
||||
data: FormValues | null;
|
||||
onClose: (item: null, isFormStatus: boolean) => void;
|
||||
onSave: (data: FormValues) => void;
|
||||
}
|
||||
|
||||
export default function GMedidaTipoForm({ isOpen, data, onClose, onSave }: GMedidaTipoFormProps) {
|
||||
// Inicializa o react-hook-form com o schema Zod
|
||||
const form = useForm<FormValues>({
|
||||
resolver: zodResolver(GMedidaTipoSchema),
|
||||
defaultValues: {
|
||||
medida_tipo_id: 0,
|
||||
sigla: "",
|
||||
descricao: "",
|
||||
},
|
||||
});
|
||||
|
||||
// Atualiza o formulário quando recebe dados para edição
|
||||
useEffect(() => {
|
||||
if (data) form.reset(data);
|
||||
}, [data, form]);
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
open={isOpen}
|
||||
onOpenChange={(open) => {
|
||||
if (!open) onClose(null, false);
|
||||
}}
|
||||
>
|
||||
<DialogContent className="sm:max-w-[425px]">
|
||||
<DialogHeader>
|
||||
<DialogTitle>
|
||||
Tipo de Medida
|
||||
</DialogTitle>
|
||||
<DialogDescription>
|
||||
Crie ou edite um tipo de medida
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
|
||||
<Form {...form}>
|
||||
<form onSubmit={form.handleSubmit(onSave)} className="space-y-6">
|
||||
|
||||
{/* Descrição */}
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="descricao"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Descrição</FormLabel>
|
||||
<FormControl>
|
||||
<Input {...field} placeholder="Digite a descrição" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
{/* Sigla */}
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="sigla"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Sigla</FormLabel>
|
||||
<FormControl>
|
||||
<Input {...field} placeholder="Digite a sigla" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
{/* Rodapé do Dialog */}
|
||||
<DialogFooter className="mt-4">
|
||||
<DialogClose asChild>
|
||||
<Button variant="outline" type="button" onClick={() => onClose(null, false)} className="cursor-pointer">
|
||||
Cancelar
|
||||
</Button>
|
||||
</DialogClose>
|
||||
<Button type="submit" className="cursor-pointer">
|
||||
Salvar
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
|
||||
{/* Campo oculto */}
|
||||
<input type="hidden" {...form.register("medida_tipo_id")} />
|
||||
</form>
|
||||
</Form>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,96 @@
|
|||
'use client';
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuGroup,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableHead,
|
||||
TableHeader,
|
||||
TableRow
|
||||
} from "@/components/ui/table";
|
||||
import { EllipsisIcon, PencilIcon, Trash2Icon } from "lucide-react";
|
||||
import { GMedidaTipoInterface } from "../../_interfaces/GMedidaTipoInterface";
|
||||
|
||||
interface GMedidaTipoTableProps {
|
||||
data: GMedidaTipoInterface[];
|
||||
onEdit: (item: GMedidaTipoInterface, isEditingFormStatus: boolean) => void;
|
||||
onDelete: (item: GMedidaTipoInterface, isEditingFormStatus: boolean) => void;
|
||||
}
|
||||
|
||||
export default function GMedidaTipoTable({
|
||||
data,
|
||||
onEdit,
|
||||
onDelete
|
||||
}: GMedidaTipoTableProps) {
|
||||
return (
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>#</TableHead>
|
||||
<TableHead>Descrição</TableHead>
|
||||
<TableHead>Sigla</TableHead>
|
||||
<TableHead className="text-right">Ações</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
|
||||
<TableBody>
|
||||
{data.map((item) => (
|
||||
<TableRow
|
||||
key={item.medida_tipo_id}
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<TableCell className="font-medium">
|
||||
{item.medida_tipo_id}
|
||||
</TableCell>
|
||||
<TableCell>{item.descricao}</TableCell>
|
||||
<TableCell>{item.sigla}</TableCell>
|
||||
<TableCell className="text-right">
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<EllipsisIcon />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
|
||||
<DropdownMenuContent side="left" align="start">
|
||||
<DropdownMenuGroup>
|
||||
<DropdownMenuItem
|
||||
className="cursor-pointer"
|
||||
onSelect={() => onEdit(item, true)}
|
||||
>
|
||||
<PencilIcon className="mr-2 h-4 w-4" />
|
||||
Editar
|
||||
</DropdownMenuItem>
|
||||
|
||||
<DropdownMenuSeparator />
|
||||
|
||||
<DropdownMenuItem
|
||||
className="cursor-pointer"
|
||||
onSelect={() => onDelete(item, true)}
|
||||
>
|
||||
<Trash2Icon className="mr-2 h-4 w-4" />
|
||||
Remover
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuGroup>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,132 @@
|
|||
'use client';
|
||||
|
||||
import z from "zod";
|
||||
import { useEffect, useState } from "react";
|
||||
import { useForm, Controller } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Checkbox } from "@/components/ui/checkbox";
|
||||
import {
|
||||
Dialog,
|
||||
DialogClose,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle
|
||||
} from "@/components/ui/dialog";
|
||||
import {
|
||||
Form,
|
||||
FormControl,
|
||||
FormField,
|
||||
FormItem,
|
||||
FormLabel,
|
||||
FormMessage
|
||||
} from "@/components/ui/form";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
|
||||
import { GTBBairroSchema } from "../../_schemas/GTBBairroSchema";
|
||||
import LoadingButton from "@/app/_components/loadingButton/LoadingButton";
|
||||
import { SituacoesEnum } from "@/enums/SituacoesEnum";
|
||||
|
||||
type FormValues = z.infer<typeof GTBBairroSchema>;
|
||||
|
||||
interface GTBBairroFormProps {
|
||||
isOpen: boolean;
|
||||
data: FormValues | null;
|
||||
onClose: (item: null, isFormStatus: boolean) => void;
|
||||
onSave: (data: FormValues) => void;
|
||||
buttonIsLoading: boolean;
|
||||
}
|
||||
|
||||
export default function GTBBairroForm({ isOpen, data, onClose, onSave, buttonIsLoading }: GTBBairroFormProps) {
|
||||
|
||||
// Inicializa o react-hook-form com o schema Zod
|
||||
const form = useForm<FormValues>({
|
||||
resolver: zodResolver(GTBBairroSchema),
|
||||
defaultValues: {
|
||||
sistema_id: null,
|
||||
tb_bairro_id: 0,
|
||||
descricao: "",
|
||||
situacao: SituacoesEnum.A,
|
||||
},
|
||||
});
|
||||
|
||||
// Atualiza o formulário quando recebe dados para edição
|
||||
useEffect(() => {
|
||||
if (data) form.reset(data);
|
||||
}, [data, form]);
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
open={isOpen}
|
||||
onOpenChange={(open) => {
|
||||
if (!open) onClose(null, false);
|
||||
}}
|
||||
>
|
||||
<DialogContent className="sm:max-w-[425px]">
|
||||
<DialogHeader>
|
||||
<DialogTitle>
|
||||
Bairro
|
||||
</DialogTitle>
|
||||
<DialogDescription>
|
||||
Crie ou edite um bairro
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
|
||||
<Form {...form}>
|
||||
<form onSubmit={form.handleSubmit(onSave)} className="space-y-6">
|
||||
|
||||
{/* Descrição */}
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="descricao"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Descrição</FormLabel>
|
||||
<FormControl>
|
||||
<Input {...field} placeholder="Digite a descrição do bairro" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
{/* Situação */}
|
||||
<Controller
|
||||
name="situacao"
|
||||
control={form.control}
|
||||
render={({ field }) => (
|
||||
<div className="flex items-center space-x-2">
|
||||
<Checkbox
|
||||
checked={field.value === "A"}
|
||||
onCheckedChange={(checked) => field.onChange(checked ? "A" : "I")}
|
||||
/>
|
||||
<Label>Ativo</Label>
|
||||
</div>
|
||||
)}
|
||||
/>
|
||||
|
||||
{/* Rodapé do Dialog */}
|
||||
<DialogFooter className="mt-4">
|
||||
<DialogClose asChild>
|
||||
<Button variant="outline" type="button" onClick={() => onClose(null, false)} className="cursor-pointer">
|
||||
Cancelar
|
||||
</Button>
|
||||
</DialogClose>
|
||||
{/* Botão de loading */}
|
||||
<LoadingButton text="Salvar" textLoading="Aguarde..." type="submit" loading={buttonIsLoading} />
|
||||
</DialogFooter>
|
||||
|
||||
{/* Campos ocultos */}
|
||||
<input type="hidden" {...form.register("tb_bairro_id")} />
|
||||
<input type="hidden" {...form.register("sistema_id")} />
|
||||
|
||||
</form>
|
||||
</Form>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,123 @@
|
|||
'use client';
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuGroup,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableHead,
|
||||
TableHeader,
|
||||
TableRow
|
||||
} from "@/components/ui/table";
|
||||
import { EllipsisIcon, PencilIcon, Trash2Icon } from "lucide-react";
|
||||
import { GTBBairroInterface } from "../../_interfaces/GTBBairroInterface";
|
||||
|
||||
interface GTBBairroTableProps {
|
||||
data: GTBBairroInterface[];
|
||||
onEdit: (item: GTBBairroInterface, isEditingFormStatus: boolean) => void;
|
||||
onDelete: (item: GTBBairroInterface, isEditingFormStatus: boolean) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renderiza o badge de situação
|
||||
*/
|
||||
function StatusBadge({ situacao }: { situacao: 'A' | 'I' }) {
|
||||
const isActive = situacao === "A";
|
||||
|
||||
const baseClasses =
|
||||
"text-xs font-medium px-2.5 py-0.5 rounded-sm me-2";
|
||||
|
||||
const activeClasses =
|
||||
"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-300";
|
||||
|
||||
const inactiveClasses =
|
||||
"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300";
|
||||
|
||||
return (
|
||||
<span className={`${baseClasses} ${isActive ? activeClasses : inactiveClasses}`}>
|
||||
{isActive ? "Ativo" : "Inativo"}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
export default function GTBBairroTable({
|
||||
data,
|
||||
onEdit,
|
||||
onDelete
|
||||
}: GTBBairroTableProps) {
|
||||
return (
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>#</TableHead>
|
||||
<TableHead>Situação</TableHead>
|
||||
<TableHead>Descrição</TableHead>
|
||||
<TableHead className="text-right">Ações</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
|
||||
<TableBody>
|
||||
{data.map((item) => (
|
||||
<TableRow
|
||||
key={item.tb_bairro_id}
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<TableCell className="font-medium">
|
||||
{item.tb_bairro_id}
|
||||
</TableCell>
|
||||
|
||||
<TableCell>
|
||||
<StatusBadge situacao={item.situacao} />
|
||||
</TableCell>
|
||||
|
||||
<TableCell>{item.descricao}</TableCell>
|
||||
|
||||
<TableCell className="text-right">
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<EllipsisIcon />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
|
||||
<DropdownMenuContent side="left" align="start">
|
||||
<DropdownMenuGroup>
|
||||
<DropdownMenuItem
|
||||
className="cursor-pointer"
|
||||
onSelect={() => onEdit(item, true)}
|
||||
>
|
||||
<PencilIcon className="mr-2 h-4 w-4" />
|
||||
Editar
|
||||
</DropdownMenuItem>
|
||||
|
||||
<DropdownMenuSeparator />
|
||||
|
||||
<DropdownMenuItem
|
||||
className="cursor-pointer"
|
||||
onSelect={() => onDelete(item, true)}
|
||||
>
|
||||
<Trash2Icon className="mr-2 h-4 w-4" />
|
||||
Remover
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuGroup>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,129 @@
|
|||
'use client';
|
||||
|
||||
import z from "zod";
|
||||
import { useEffect } from "react";
|
||||
import { useForm, Controller } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Checkbox } from "@/components/ui/checkbox";
|
||||
import {
|
||||
Dialog,
|
||||
DialogClose,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle
|
||||
} from "@/components/ui/dialog";
|
||||
import {
|
||||
Form,
|
||||
FormControl,
|
||||
FormField,
|
||||
FormItem,
|
||||
FormLabel,
|
||||
FormMessage
|
||||
} from "@/components/ui/form";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
|
||||
import { GTBEstadoCivilSchema } from "../../_schemas/GTBEstadoCivilSchema";
|
||||
import { GTBEstadoCivilInterface } from "../../_interfaces/GTBEstadoCivilInterface";
|
||||
|
||||
type FormValues = z.infer<typeof GTBEstadoCivilSchema>;
|
||||
|
||||
interface TBEstadoCivilFormProps {
|
||||
isOpen: boolean;
|
||||
data: FormValues | null;
|
||||
onClose: (item: null, isFormStatus: boolean) => void;
|
||||
onSave: (data: FormValues) => void;
|
||||
}
|
||||
|
||||
export default function GTBEstadoCivilForm({ isOpen, data, onClose, onSave }: TBEstadoCivilFormProps) {
|
||||
// Inicializa o react-hook-form com o schema Zod
|
||||
const form = useForm<FormValues>({
|
||||
resolver: zodResolver(GTBEstadoCivilSchema),
|
||||
defaultValues: {
|
||||
tb_estadocivil_id: 0,
|
||||
sistema_id: 0,
|
||||
descricao: "",
|
||||
situacao: "A",
|
||||
},
|
||||
});
|
||||
|
||||
// Atualiza o formulário quando recebe dados para edição
|
||||
useEffect(() => {
|
||||
if (data) form.reset(data);
|
||||
}, [data, form]);
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
open={isOpen}
|
||||
onOpenChange={(open) => {
|
||||
if (!open) onClose(null, false);
|
||||
}}
|
||||
>
|
||||
<DialogContent className="sm:max-w-[425px]">
|
||||
<DialogHeader>
|
||||
<DialogTitle>
|
||||
Estado Civil
|
||||
</DialogTitle>
|
||||
<DialogDescription>
|
||||
Crie ou edite um estado civil
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
|
||||
<Form {...form}>
|
||||
<form onSubmit={form.handleSubmit(onSave)} className="space-y-6">
|
||||
|
||||
{/* Descrição */}
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="descricao"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Descrição</FormLabel>
|
||||
<FormControl>
|
||||
<Input {...field} placeholder="Digite a descrição" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
{/* Situação */}
|
||||
<Controller
|
||||
name="situacao"
|
||||
control={form.control}
|
||||
render={({ field }) => (
|
||||
<div className="flex items-center space-x-2">
|
||||
<Checkbox
|
||||
checked={field.value === "A"}
|
||||
onCheckedChange={(checked) => field.onChange(checked ? "A" : "I")}
|
||||
/>
|
||||
<Label>Ativo</Label>
|
||||
</div>
|
||||
)}
|
||||
/>
|
||||
|
||||
{/* Rodapé do Dialog */}
|
||||
<DialogFooter className="mt-4">
|
||||
<DialogClose asChild>
|
||||
<Button variant="outline" type="button" onClick={() => onClose(null, false)} className="cursor-pointer">
|
||||
Cancelar
|
||||
</Button>
|
||||
</DialogClose>
|
||||
<Button type="submit" className="cursor-pointer">
|
||||
Salvar
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
|
||||
{/* Campos ocultos */}
|
||||
<input type="hidden" {...form.register("tb_estadocivil_id", { valueAsNumber: true })} />
|
||||
<input type="hidden" {...form.register("sistema_id", { valueAsNumber: true })} />
|
||||
</form>
|
||||
</Form>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,123 @@
|
|||
'use client';
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuGroup,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableHead,
|
||||
TableHeader,
|
||||
TableRow
|
||||
} from "@/components/ui/table";
|
||||
import { EllipsisIcon, PencilIcon, Trash2Icon } from "lucide-react";
|
||||
import { GTBEstadoCivilInterface } from "../../_interfaces/GTBEstadoCivilInterface";
|
||||
|
||||
interface TBEstadoCivilTableProps {
|
||||
data: GTBEstadoCivilInterface[];
|
||||
onEdit: (item: GTBEstadoCivilInterface, isEditingFormStatus: boolean) => void;
|
||||
onDelete: (item: GTBEstadoCivilInterface, isEditingFormStatus: boolean) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renderiza o badge de situação
|
||||
*/
|
||||
function StatusBadge({ situacao }: { situacao: 'A' | 'I' }) {
|
||||
const isActive = situacao === "A";
|
||||
|
||||
const baseClasses =
|
||||
"text-xs font-medium px-2.5 py-0.5 rounded-sm me-2";
|
||||
|
||||
const activeClasses =
|
||||
"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-300";
|
||||
|
||||
const inactiveClasses =
|
||||
"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300";
|
||||
|
||||
return (
|
||||
<span className={`${baseClasses} ${isActive ? activeClasses : inactiveClasses}`}>
|
||||
{isActive ? "Ativo" : "Inativo"}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
export default function GTBEstadoCivilTable({
|
||||
data,
|
||||
onEdit,
|
||||
onDelete
|
||||
}: TBEstadoCivilTableProps) {
|
||||
return (
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>#</TableHead>
|
||||
<TableHead>Situação</TableHead>
|
||||
<TableHead>Descrição</TableHead>
|
||||
<TableHead className="text-right">Ações</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
|
||||
<TableBody>
|
||||
{data.map((item) => (
|
||||
<TableRow
|
||||
key={item.tb_estadocivil_id}
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<TableCell className="font-medium">
|
||||
{item.tb_estadocivil_id}
|
||||
</TableCell>
|
||||
|
||||
<TableCell>
|
||||
<StatusBadge situacao={item.situacao} />
|
||||
</TableCell>
|
||||
|
||||
<TableCell>{item.descricao}</TableCell>
|
||||
|
||||
<TableCell className="text-right">
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<EllipsisIcon />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
|
||||
<DropdownMenuContent side="left" align="start">
|
||||
<DropdownMenuGroup>
|
||||
<DropdownMenuItem
|
||||
className="cursor-pointer"
|
||||
onSelect={() => onEdit(item, true)}
|
||||
>
|
||||
<PencilIcon className="mr-2 h-4 w-4" />
|
||||
Editar
|
||||
</DropdownMenuItem>
|
||||
|
||||
<DropdownMenuSeparator />
|
||||
|
||||
<DropdownMenuItem
|
||||
className="cursor-pointer"
|
||||
onSelect={() => onDelete(item, true)}
|
||||
>
|
||||
<Trash2Icon className="mr-2 h-4 w-4" />
|
||||
Remover
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuGroup>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,143 @@
|
|||
'use client';
|
||||
|
||||
import z from "zod";
|
||||
import { useEffect } from "react";
|
||||
import { useForm, Controller } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Checkbox } from "@/components/ui/checkbox";
|
||||
import {
|
||||
Dialog,
|
||||
DialogClose,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle
|
||||
} from "@/components/ui/dialog";
|
||||
import {
|
||||
Form,
|
||||
FormControl,
|
||||
FormField,
|
||||
FormItem,
|
||||
FormLabel,
|
||||
FormMessage
|
||||
} from "@/components/ui/form";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
|
||||
import { GTBProfissaoSchema } from "../../_schemas/GTBProfissaoSchema";
|
||||
|
||||
type FormValues = z.infer<typeof GTBProfissaoSchema>;
|
||||
|
||||
interface Props {
|
||||
isOpen: boolean;
|
||||
data: FormValues | null;
|
||||
onClose: (item: null, isFormStatus: boolean) => void;
|
||||
onSave: (data: FormValues) => void;
|
||||
}
|
||||
|
||||
export default function GTBProfissaoForm({ isOpen, data, onClose, onSave }: Props) {
|
||||
// Inicializa o react-hook-form com schema zod
|
||||
const form = useForm<FormValues>({
|
||||
resolver: zodResolver(GTBProfissaoSchema),
|
||||
defaultValues: {
|
||||
descricao: "",
|
||||
cod_cbo: "",
|
||||
situacao: "A",
|
||||
tb_profissao_id: 0,
|
||||
},
|
||||
});
|
||||
|
||||
// Atualiza o formulário quando recebe dados para edição
|
||||
useEffect(() => {
|
||||
if (data) form.reset(data);
|
||||
}, [data, form]);
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
open={isOpen}
|
||||
onOpenChange={(open) => {
|
||||
if (!open) onClose(null, false);
|
||||
}}
|
||||
>
|
||||
<DialogContent className="sm:max-w-[425px]">
|
||||
|
||||
<DialogHeader>
|
||||
<DialogTitle>
|
||||
Profissões
|
||||
</DialogTitle>
|
||||
<DialogDescription>
|
||||
Controle de profissões
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
|
||||
<Form {...form}>
|
||||
<form onSubmit={form.handleSubmit(onSave)} className="space-y-6">
|
||||
|
||||
{/* Descrição */}
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="descricao"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Descrição</FormLabel>
|
||||
<FormControl>
|
||||
<Input type="text" {...field} placeholder="Digite a descrição" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
{/* CBO */}
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="cod_cbo"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>CBO</FormLabel>
|
||||
<FormControl>
|
||||
<Input type="nubmer" {...field} placeholder="Digite o código" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
{/* Situação */}
|
||||
<Controller
|
||||
name="situacao"
|
||||
control={form.control}
|
||||
render={({ field }) => (
|
||||
<div className="flex items-center space-x-2">
|
||||
<Checkbox
|
||||
checked={field.value === "A"}
|
||||
onCheckedChange={(checked) => field.onChange(checked ? "A" : "I")}
|
||||
/>
|
||||
<Label>Ativo</Label>
|
||||
</div>
|
||||
)}
|
||||
/>
|
||||
|
||||
{/* Rodapé do Dialog */}
|
||||
<DialogFooter className="mt-4">
|
||||
<DialogClose asChild>
|
||||
<Button variant="outline" type="button" onClick={() => onClose(null, false)} className="cursor-pointer">
|
||||
Cancelar
|
||||
</Button>
|
||||
</DialogClose>
|
||||
<Button type="submit" className="cursor-pointer">
|
||||
Salvar
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
|
||||
{/* Campo oculto */}
|
||||
<input type="hidden" {...form.register("tb_profissao_id")} />
|
||||
</form>
|
||||
</Form>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,129 @@
|
|||
'use client';
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuGroup,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableHead,
|
||||
TableHeader,
|
||||
TableRow
|
||||
} from "@/components/ui/table";
|
||||
|
||||
import { EllipsisIcon, PencilIcon, Trash2Icon } from "lucide-react";
|
||||
import GTBProfissaoInterface from "../../_interfaces/GTBProfissaoInterface";
|
||||
|
||||
interface GTBProfissaoTableProps {
|
||||
data: GTBProfissaoInterface[];
|
||||
onEdit: (item: GTBProfissaoInterface, isEditingFormStatus: boolean) => void;
|
||||
onDelete: (item: GTBProfissaoInterface, isEditingFormStatus: boolean) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renderiza o badge de situação
|
||||
*/
|
||||
function StatusBadge({ situacao }: { situacao: string }) {
|
||||
const isActive = situacao === "A";
|
||||
|
||||
const baseClasses =
|
||||
"text-xs font-medium px-2.5 py-0.5 rounded-sm me-2";
|
||||
|
||||
const activeClasses =
|
||||
"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-300";
|
||||
|
||||
const inactiveClasses =
|
||||
"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300";
|
||||
|
||||
return (
|
||||
<span className={`${baseClasses} ${isActive ? activeClasses : inactiveClasses}`}>
|
||||
{isActive ? "Ativo" : "Inativo"}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
export default function GTBProfissaoTable({
|
||||
data,
|
||||
onEdit,
|
||||
onDelete
|
||||
}: GTBProfissaoTableProps) {
|
||||
return (
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>#</TableHead>
|
||||
<TableHead>Situação</TableHead>
|
||||
<TableHead>CBO</TableHead>
|
||||
<TableHead>Descrição</TableHead>
|
||||
<TableHead className="text-right">Ações</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
|
||||
<TableBody>
|
||||
{data.map((item) => (
|
||||
<TableRow
|
||||
key={item.tb_profissao_id}
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<TableCell className="font-medium">
|
||||
{item.tb_profissao_id}
|
||||
</TableCell>
|
||||
|
||||
<TableCell>
|
||||
<StatusBadge situacao={item.situacao} />
|
||||
</TableCell>
|
||||
|
||||
<TableCell className="font-medium">
|
||||
{item.cod_cbo}
|
||||
</TableCell>
|
||||
|
||||
<TableCell>{item.descricao}</TableCell>
|
||||
|
||||
<TableCell className="text-right">
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<EllipsisIcon />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
|
||||
<DropdownMenuContent side="left" align="start">
|
||||
<DropdownMenuGroup>
|
||||
<DropdownMenuItem
|
||||
className="cursor-pointer"
|
||||
onSelect={() => onEdit(item, true)}
|
||||
>
|
||||
<PencilIcon className="mr-2 h-4 w-4" />
|
||||
Editar
|
||||
</DropdownMenuItem>
|
||||
|
||||
<DropdownMenuSeparator />
|
||||
|
||||
<DropdownMenuItem
|
||||
className="cursor-pointer"
|
||||
onSelect={() => onDelete(item, true)}
|
||||
>
|
||||
<Trash2Icon className="mr-2 h-4 w-4" />
|
||||
Remover
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuGroup>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,127 @@
|
|||
'use client';
|
||||
|
||||
import z from "zod";
|
||||
import { useForm, Controller } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Checkbox } from "@/components/ui/checkbox";
|
||||
import {
|
||||
Dialog,
|
||||
DialogClose,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle
|
||||
} from "@/components/ui/dialog";
|
||||
import {
|
||||
Form,
|
||||
FormControl,
|
||||
FormField,
|
||||
FormItem,
|
||||
FormLabel,
|
||||
FormMessage
|
||||
} from "@/components/ui/form";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
|
||||
import { GTBRegimeBensSchema } from "../../_schemas/GTBRegimeBensSchema";
|
||||
import { useEffect } from "react";
|
||||
|
||||
type FormValues = z.infer<typeof GTBRegimeBensSchema>;
|
||||
|
||||
interface Props {
|
||||
isOpen: boolean;
|
||||
data: FormValues | null;
|
||||
onClose: (item: null, isFormStatus: boolean) => void;
|
||||
onSave: (data: FormValues) => void;
|
||||
}
|
||||
|
||||
export default function GTBRegimeComunhaoForm({ isOpen, data, onClose, onSave }: Props) {
|
||||
|
||||
// Inicializa o react-hook-form com schema zod
|
||||
const form = useForm<FormValues>({
|
||||
resolver: zodResolver(GTBRegimeBensSchema),
|
||||
defaultValues: {
|
||||
tb_regimebens_id: 0,
|
||||
descricao: "",
|
||||
situacao: "",
|
||||
},
|
||||
});
|
||||
|
||||
// Atualiza o formulário quando recebe dados para edição
|
||||
useEffect(() => {
|
||||
if (data) form.reset(data);
|
||||
}, [data, form]);
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
open={isOpen}
|
||||
onOpenChange={(open) => {
|
||||
if (!open) onClose(null, false);
|
||||
}}
|
||||
>
|
||||
<DialogContent className="sm:max-w-[425px]">
|
||||
<DialogHeader>
|
||||
<DialogTitle>
|
||||
Regimes de Bens
|
||||
</DialogTitle>
|
||||
<DialogDescription>
|
||||
Controle de Regimes de Vens
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
|
||||
<Form {...form}>
|
||||
<form onSubmit={form.handleSubmit(onSave)} className="space-y-6">
|
||||
|
||||
{/* Descrição */}
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="descricao"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Descrição</FormLabel>
|
||||
<FormControl>
|
||||
<Input {...field} placeholder="Digite a descrição" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
{/* Situação */}
|
||||
<Controller
|
||||
name="situacao"
|
||||
control={form.control}
|
||||
render={({ field }) => (
|
||||
<div className="flex items-center space-x-2">
|
||||
<Checkbox
|
||||
checked={field.value === "A"}
|
||||
onCheckedChange={(checked) => field.onChange(checked ? "A" : "I")}
|
||||
/>
|
||||
<Label>Ativo</Label>
|
||||
</div>
|
||||
)}
|
||||
/>
|
||||
|
||||
{/* Rodapé do Dialog */}
|
||||
<DialogFooter className="mt-4">
|
||||
<DialogClose asChild>
|
||||
<Button variant="outline" type="button" onClick={() => onClose(null, false)} className="cursor-pointer">
|
||||
Cancelar
|
||||
</Button>
|
||||
</DialogClose>
|
||||
<Button type="submit" className="cursor-pointer">
|
||||
Salvar
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
|
||||
{/* Campo oculto */}
|
||||
<input type="hidden" {...form.register("tb_regimebens_id")} />
|
||||
</form>
|
||||
</Form>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,126 @@
|
|||
'use client';
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuGroup,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableHead,
|
||||
TableHeader,
|
||||
TableRow
|
||||
} from "@/components/ui/table";
|
||||
|
||||
import { EllipsisIcon, PencilIcon, Trash2Icon } from "lucide-react";
|
||||
import GTBRegimeBensInterface from "../../_interfaces/GTBRegimeBensInterface";
|
||||
|
||||
interface GTBRegimeBensTableProps {
|
||||
data: GTBRegimeBensInterface[];
|
||||
onEdit: (item: GTBRegimeBensInterface, isEditingFormStatus: boolean) => void;
|
||||
onDelete: (item: GTBRegimeBensInterface, isEditingFormStatus: boolean) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renderiza o badge de situação
|
||||
*/
|
||||
function StatusBadge({ situacao }: { situacao: string }) {
|
||||
const isActive = situacao === "A";
|
||||
|
||||
const baseClasses =
|
||||
"text-xs font-medium px-2.5 py-0.5 rounded-sm me-2";
|
||||
|
||||
const activeClasses =
|
||||
"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-300";
|
||||
|
||||
const inactiveClasses =
|
||||
"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300";
|
||||
|
||||
return (
|
||||
<span className={`${baseClasses} ${isActive ? activeClasses : inactiveClasses}`}>
|
||||
{isActive ? "Ativo" : "Inativo"}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
export default function GTBRegimeBensTable({
|
||||
data,
|
||||
onEdit,
|
||||
onDelete
|
||||
}: GTBRegimeBensTableProps) {
|
||||
return (
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>#</TableHead>
|
||||
<TableHead>Situação</TableHead>
|
||||
<TableHead>Descrição</TableHead>
|
||||
<TableHead className="text-right">Ações</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
|
||||
<TableBody>
|
||||
{data.map((item) => (
|
||||
<TableRow
|
||||
key={item.tb_regimebens_id}
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<TableCell className="font-medium">
|
||||
{item.tb_regimebens_id}
|
||||
</TableCell>
|
||||
|
||||
<TableCell>
|
||||
<StatusBadge situacao={item.situacao} />
|
||||
</TableCell>
|
||||
|
||||
<TableCell>
|
||||
{item.descricao}
|
||||
</TableCell>
|
||||
|
||||
<TableCell className="text-right">
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<EllipsisIcon />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
|
||||
<DropdownMenuContent side="left" align="start">
|
||||
<DropdownMenuGroup>
|
||||
<DropdownMenuItem
|
||||
className="cursor-pointer"
|
||||
onSelect={() => onEdit(item, true)}
|
||||
>
|
||||
<PencilIcon className="mr-2 h-4 w-4" />
|
||||
Editar
|
||||
</DropdownMenuItem>
|
||||
|
||||
<DropdownMenuSeparator />
|
||||
|
||||
<DropdownMenuItem
|
||||
className="cursor-pointer"
|
||||
onSelect={() => onDelete(item, true)}
|
||||
>
|
||||
<Trash2Icon className="mr-2 h-4 w-4" />
|
||||
Remover
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuGroup>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,189 @@
|
|||
'use client';
|
||||
|
||||
import z from "zod";
|
||||
import { useEffect } from "react";
|
||||
import { useForm, Controller } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Checkbox } from "@/components/ui/checkbox";
|
||||
import {
|
||||
Dialog,
|
||||
DialogClose,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle
|
||||
} from "@/components/ui/dialog";
|
||||
import {
|
||||
Form,
|
||||
FormControl,
|
||||
FormField,
|
||||
FormItem,
|
||||
FormLabel,
|
||||
FormMessage
|
||||
} from "@/components/ui/form";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
|
||||
import { GTBRegimeComunhaoSchema } from "../../_schemas/GTBRegimeComunhaoSchema";
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
||||
import { useGTBRegimeBensReadHook } from "../../_hooks/g_tb_regimebens/useGTBRegimeBensReadHook";
|
||||
|
||||
type FormValues = z.infer<typeof GTBRegimeComunhaoSchema>;
|
||||
|
||||
interface Props {
|
||||
isOpen: boolean;
|
||||
data: FormValues | null;
|
||||
onClose: (item: null, isFormStatus: boolean) => void;
|
||||
onSave: (data: FormValues) => void;
|
||||
}
|
||||
|
||||
export default function GTBRegimeComunhaoForm({ isOpen, data, onClose, onSave }: Props) {
|
||||
|
||||
const { gTBRegimeBens, fetchGTBRegimeBens } = useGTBRegimeBensReadHook();
|
||||
|
||||
// Inicializa o react-hook-form com schema zod
|
||||
const form = useForm<FormValues>({
|
||||
resolver: zodResolver(GTBRegimeComunhaoSchema),
|
||||
defaultValues: {
|
||||
tb_regimecomunhao_id: 0,
|
||||
tb_regimebens_id: 0,
|
||||
descricao: "",
|
||||
texto: "",
|
||||
situacao: "",
|
||||
},
|
||||
});
|
||||
|
||||
// Atualiza o formulário quando recebe dados para edição
|
||||
useEffect(() => {
|
||||
|
||||
const loadData = async () => {
|
||||
// Se existir dados, reseta o formulário com os dados informados
|
||||
if (data) form.reset(data);
|
||||
|
||||
// Aguarda a busca terminar
|
||||
await fetchGTBRegimeBens();
|
||||
};
|
||||
|
||||
// Dispara a função
|
||||
loadData();
|
||||
|
||||
}, [data, form]);
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
open={isOpen}
|
||||
onOpenChange={(open) => {
|
||||
if (!open) onClose(null, false);
|
||||
}}
|
||||
>
|
||||
<DialogContent className="sm:max-w-[425px]">
|
||||
<DialogHeader>
|
||||
<DialogTitle>
|
||||
Regimes de Comunhão
|
||||
</DialogTitle>
|
||||
<DialogDescription>
|
||||
Controle de Regimes de Comunhão
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
|
||||
<Form {...form}>
|
||||
<form onSubmit={form.handleSubmit(onSave)} className="space-y-6">
|
||||
|
||||
{/* Descrição */}
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="descricao"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Descrição</FormLabel>
|
||||
<FormControl>
|
||||
<Input {...field} placeholder="Digite a descrição" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
{/* Texto */}
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="texto"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Texto</FormLabel>
|
||||
<FormControl>
|
||||
<Input {...field} placeholder="Digite o texto" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
{/* Tipo */}
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="tb_regimebens_id"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Tipo</FormLabel>
|
||||
<Select
|
||||
value={String(field.value)}
|
||||
// Converter o valor inteiro para ser aceito pelo zod
|
||||
onValueChange={(val) => field.onChange(Number(val))}
|
||||
>
|
||||
<FormControl className="w-full">
|
||||
<SelectTrigger>
|
||||
<SelectValue placeholder="Escolha o tipo do andamento" />
|
||||
</SelectTrigger>
|
||||
</FormControl>
|
||||
<SelectContent>
|
||||
{gTBRegimeBens.map((item) => (
|
||||
<SelectItem key={item.tb_regimebens_id} value={String(item.tb_regimebens_id)}>
|
||||
{item.descricao}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
{/* Situação */}
|
||||
<Controller
|
||||
name="situacao"
|
||||
control={form.control}
|
||||
render={({ field }) => (
|
||||
<div className="flex items-center space-x-2">
|
||||
<Checkbox
|
||||
checked={field.value === "A"}
|
||||
onCheckedChange={(checked) => field.onChange(checked ? "A" : "I")}
|
||||
/>
|
||||
<Label>Ativo</Label>
|
||||
</div>
|
||||
)}
|
||||
/>
|
||||
|
||||
{/* Rodapé do Dialog */}
|
||||
<DialogFooter className="mt-4">
|
||||
<DialogClose asChild>
|
||||
<Button variant="outline" type="button" onClick={() => onClose(null, false)} className="cursor-pointer">
|
||||
Cancelar
|
||||
</Button>
|
||||
</DialogClose>
|
||||
<Button type="submit" className="cursor-pointer">
|
||||
Salvar
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
|
||||
{/* Campo oculto */}
|
||||
<input type="hidden" {...form.register("tb_regimecomunhao_id")} />
|
||||
</form>
|
||||
</Form>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,126 @@
|
|||
'use client';
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuGroup,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableHead,
|
||||
TableHeader,
|
||||
TableRow
|
||||
} from "@/components/ui/table";
|
||||
|
||||
import { EllipsisIcon, PencilIcon, Trash2Icon } from "lucide-react";
|
||||
import GTBRegimeComunhaoInterface from "../../_interfaces/GTBRegimeComunhaoInterface";
|
||||
|
||||
interface GTBRegimeComunhaoTableProps {
|
||||
data: GTBRegimeComunhaoInterface[];
|
||||
onEdit: (item: GTBRegimeComunhaoInterface, isEditingFormStatus: boolean) => void;
|
||||
onDelete: (item: GTBRegimeComunhaoInterface, isEditingFormStatus: boolean) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renderiza o badge de situação
|
||||
*/
|
||||
function StatusBadge({ situacao }: { situacao: string }) {
|
||||
const isActive = situacao === "A";
|
||||
|
||||
const 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 GTBRegimeComunhaoTable({
|
||||
data,
|
||||
onEdit,
|
||||
onDelete
|
||||
}: GTBRegimeComunhaoTableProps) {
|
||||
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_regimecomunhao_id}
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<TableCell className="font-medium">
|
||||
{item.tb_regimecomunhao_id}
|
||||
</TableCell>
|
||||
|
||||
<TableCell>
|
||||
<StatusBadge situacao={item.situacao} />
|
||||
</TableCell>
|
||||
|
||||
<TableCell>
|
||||
{item.descricao}
|
||||
</TableCell>
|
||||
|
||||
<TableCell className="text-right">
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<EllipsisIcon />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
|
||||
<DropdownMenuContent side="left" align="start">
|
||||
<DropdownMenuGroup>
|
||||
<DropdownMenuItem
|
||||
className="cursor-pointer"
|
||||
onSelect={() => onEdit(item, true)}
|
||||
>
|
||||
<PencilIcon className="mr-2 h-4 w-4" />
|
||||
Editar
|
||||
</DropdownMenuItem>
|
||||
|
||||
<DropdownMenuSeparator />
|
||||
|
||||
<DropdownMenuItem
|
||||
className="cursor-pointer"
|
||||
onSelect={() => onDelete(item, true)}
|
||||
>
|
||||
<Trash2Icon className="mr-2 h-4 w-4" />
|
||||
Remover
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuGroup>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,148 @@
|
|||
'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 { GTBTipoLogradouroSchema } from "../../_schemas/GTBTipoLogradouroSchema";
|
||||
import { GTBTipoLogradouroInterface } from "../../_interfaces/GTBTipoLogradouroInterface";
|
||||
|
||||
type FormValues = z.infer<typeof GTBTipoLogradouroSchema>;
|
||||
|
||||
interface GTBTipoLogradouroFormProps {
|
||||
isOpen: boolean;
|
||||
data: FormValues | null;
|
||||
onClose: (item: null, isFormStatus: boolean) => void;
|
||||
onSave: (data: FormValues) => void;
|
||||
}
|
||||
|
||||
export default function GTBTipoLogradouroForm({ isOpen, data, onClose, onSave }: GTBTipoLogradouroFormProps) {
|
||||
// Inicializa o react-hook-form com schema zod
|
||||
const form = useForm<FormValues>({
|
||||
resolver: zodResolver(GTBTipoLogradouroSchema),
|
||||
defaultValues: {
|
||||
sistema_id: null,
|
||||
tb_tipologradouro_id: 0,
|
||||
situacao_id: null,
|
||||
descricao: "",
|
||||
situacao: "A",
|
||||
onr_tipo_logradouro_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>
|
||||
Tipo de Logradouro
|
||||
</DialogTitle>
|
||||
<DialogDescription>
|
||||
Crie ou edite um tipo de logradouro
|
||||
</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>
|
||||
)}
|
||||
/>
|
||||
|
||||
{/* ID do tipo logradouro na ONR */}
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="onr_tipo_logradouro_id"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>ID do tipo logradouro na ONR</FormLabel>
|
||||
<FormControl>
|
||||
<Input {...field} placeholder="Digite o valor" />
|
||||
</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_tipologradouro_id")} />
|
||||
<input type="hidden" {...form.register("sistema_id")} />
|
||||
<input type="hidden" {...form.register("situacao_id")} />
|
||||
<input type="hidden" {...form.register("onr_tipo_logradouro_id")} />
|
||||
</form>
|
||||
</Form>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,123 @@
|
|||
'use client';
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuGroup,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableHead,
|
||||
TableHeader,
|
||||
TableRow
|
||||
} from "@/components/ui/table";
|
||||
import { EllipsisIcon, PencilIcon, Trash2Icon } from "lucide-react";
|
||||
import { GTBTipoLogradouroInterface } from "../../_interfaces/GTBTipoLogradouroInterface";
|
||||
|
||||
interface GTBTipoLogradouroTableProps {
|
||||
data: GTBTipoLogradouroInterface[];
|
||||
onEdit: (item: GTBTipoLogradouroInterface, isEditingFormStatus: boolean) => void;
|
||||
onDelete: (item: GTBTipoLogradouroInterface, isEditingFormStatus: boolean) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renderiza o badge de situação
|
||||
*/
|
||||
function StatusBadge({ situacao }: { situacao: 'A' | 'I' }) {
|
||||
const isActive = situacao === "A";
|
||||
|
||||
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 GTBTipoLogradouroTable({
|
||||
data,
|
||||
onEdit,
|
||||
onDelete
|
||||
}: GTBTipoLogradouroTableProps) {
|
||||
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_tipologradouro_id}
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<TableCell className="font-medium">
|
||||
{item.tb_tipologradouro_id}
|
||||
</TableCell>
|
||||
|
||||
<TableCell>
|
||||
<StatusBadge situacao={item.situacao} />
|
||||
</TableCell>
|
||||
|
||||
<TableCell>{item.descricao}</TableCell>
|
||||
|
||||
<TableCell className="text-right">
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<EllipsisIcon />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
|
||||
<DropdownMenuContent side="left" align="start">
|
||||
<DropdownMenuGroup>
|
||||
<DropdownMenuItem
|
||||
className="cursor-pointer"
|
||||
onSelect={() => onEdit(item, true)}
|
||||
>
|
||||
<PencilIcon className="mr-2 h-4 w-4" />
|
||||
Editar
|
||||
</DropdownMenuItem>
|
||||
|
||||
<DropdownMenuSeparator />
|
||||
|
||||
<DropdownMenuItem
|
||||
className="cursor-pointer"
|
||||
onSelect={() => onDelete(item, true)}
|
||||
>
|
||||
<Trash2Icon className="mr-2 h-4 w-4" />
|
||||
Remover
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuGroup>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,129 @@
|
|||
'use client';
|
||||
|
||||
import z from "zod";
|
||||
import { useEffect } from "react";
|
||||
import { useForm, Controller } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Checkbox } from "@/components/ui/checkbox";
|
||||
import {
|
||||
Dialog,
|
||||
DialogClose,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle
|
||||
} from "@/components/ui/dialog";
|
||||
import {
|
||||
Form,
|
||||
FormControl,
|
||||
FormField,
|
||||
FormItem,
|
||||
FormLabel,
|
||||
FormMessage
|
||||
} from "@/components/ui/form";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
|
||||
import { TCensecSchema } from "../../_schemas/TCensecSchema";
|
||||
import { SituacoesEnum } from "@/enums/SituacoesEnum";
|
||||
import LoadingButton from "@/app/_components/loadingButton/LoadingButton";
|
||||
|
||||
type FormValues = z.infer<typeof TCensecSchema>;
|
||||
|
||||
interface Props {
|
||||
isOpen: boolean;
|
||||
data: FormValues | null;
|
||||
onClose: (item: null, isFormStatus: boolean) => void;
|
||||
onSave: (data: FormValues) => void;
|
||||
buttonIsLoading: boolean;
|
||||
}
|
||||
|
||||
export default function TCensecForm({ isOpen, data, onClose, onSave, buttonIsLoading }: Props) {
|
||||
// Inicializa o react-hook-form com schema zod
|
||||
const form = useForm<FormValues>({
|
||||
resolver: zodResolver(TCensecSchema),
|
||||
defaultValues: {
|
||||
descricao: "",
|
||||
situacao: SituacoesEnum.A,
|
||||
censec_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>
|
||||
Censec
|
||||
</DialogTitle>
|
||||
<DialogDescription>
|
||||
Tipos de Centrais
|
||||
</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>
|
||||
)}
|
||||
/>
|
||||
|
||||
{/* 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>
|
||||
|
||||
{/* Campo oculto */}
|
||||
<input type="hidden" {...form.register("censec_id")} />
|
||||
</form>
|
||||
</Form>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,125 @@
|
|||
'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 TCensecInterface from "../../_interfaces/TCensecInterface";
|
||||
|
||||
interface TCensecTableProps {
|
||||
data: TCensecInterface[];
|
||||
onEdit: (item: TCensecInterface, isEditingFormStatus: boolean) => void;
|
||||
onDelete: (item: TCensecInterface, 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 TCensecTable({
|
||||
data,
|
||||
onEdit,
|
||||
onDelete
|
||||
}: TCensecTableProps) {
|
||||
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.censec_id}
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<TableCell className="font-medium">
|
||||
{item.censec_id}
|
||||
</TableCell>
|
||||
|
||||
<TableCell>
|
||||
<StatusBadge situacao={item.situacao} />
|
||||
</TableCell>
|
||||
|
||||
<TableCell>{item.descricao}</TableCell>
|
||||
|
||||
<TableCell className="text-right">
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<EllipsisIcon />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
|
||||
<DropdownMenuContent side="left" align="start">
|
||||
<DropdownMenuGroup>
|
||||
<DropdownMenuItem
|
||||
className="cursor-pointer"
|
||||
onSelect={() => onEdit(item, true)}
|
||||
>
|
||||
<PencilIcon className="mr-2 h-4 w-4" />
|
||||
Editar
|
||||
</DropdownMenuItem>
|
||||
|
||||
<DropdownMenuSeparator />
|
||||
|
||||
<DropdownMenuItem
|
||||
className="cursor-pointer"
|
||||
onSelect={() => onDelete(item, true)}
|
||||
>
|
||||
<Trash2Icon className="mr-2 h-4 w-4" />
|
||||
Remover
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuGroup>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,128 @@
|
|||
'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 { TCensecNaturezaLitigioSchema } from '../../_schemas/TCensecNaturezaLitigioSchema';
|
||||
|
||||
type FormValues = z.infer<typeof TCensecNaturezaLitigioSchema>;
|
||||
|
||||
interface TCensecNaturezaLitigioFormProps {
|
||||
isOpen: boolean;
|
||||
data: FormValues | null;
|
||||
onClose: (item: null, isFormStatus: boolean) => void;
|
||||
onSave: (data: FormValues) => void;
|
||||
}
|
||||
|
||||
export default function TCensecNaturezaLitigioForm({
|
||||
isOpen,
|
||||
data,
|
||||
onClose,
|
||||
onSave
|
||||
}: TCensecNaturezaLitigioFormProps) {
|
||||
const form = useForm<FormValues>({
|
||||
resolver: zodResolver(TCensecNaturezaLitigioSchema),
|
||||
defaultValues: {
|
||||
censec_naturezalitigio_id: 0,
|
||||
descricao: "",
|
||||
situacao: "A"
|
||||
}
|
||||
});
|
||||
|
||||
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>Natureza do Litígio</DialogTitle>
|
||||
<DialogDescription>
|
||||
Crie ou edite uma natureza do litígio
|
||||
</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é */}
|
||||
<DialogFooter className="mt-4">
|
||||
<DialogClose asChild>
|
||||
<Button variant="outline" type="button" onClick={() => onClose(null, false)}>
|
||||
Cancelar
|
||||
</Button>
|
||||
</DialogClose>
|
||||
<Button type="submit">
|
||||
Salvar
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
|
||||
{/* Campo oculto */}
|
||||
<input type="hidden" {...form.register('censec_naturezalitigio_id')} />
|
||||
</form>
|
||||
</Form>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,123 @@
|
|||
'use client';
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuGroup,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableHead,
|
||||
TableHeader,
|
||||
TableRow
|
||||
} from "@/components/ui/table";
|
||||
import { EllipsisIcon, PencilIcon, Trash2Icon } from "lucide-react";
|
||||
import { TCensecNaturezaLitigioInterface } from "../../_interfaces/TCensecNaturezaLitigioInterface";
|
||||
|
||||
interface TCensecNaturezaLitigioTableProps {
|
||||
data: TCensecNaturezaLitigioInterface[];
|
||||
onEdit: (item: TCensecNaturezaLitigioInterface, isEditingFormStatus: boolean) => void;
|
||||
onDelete: (item: TCensecNaturezaLitigioInterface, isEditingFormStatus: boolean) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renderiza o badge de situação
|
||||
*/
|
||||
function StatusBadge({ situacao }: { situacao: 'A' | 'I' }) {
|
||||
const isActive = situacao === 'A';
|
||||
|
||||
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 TCensecNaturezaLitigioTable({
|
||||
data,
|
||||
onEdit,
|
||||
onDelete
|
||||
}: TCensecNaturezaLitigioTableProps) {
|
||||
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.censec_naturezalitigio_id}
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<TableCell className="font-medium">
|
||||
{item.censec_naturezalitigio_id}
|
||||
</TableCell>
|
||||
|
||||
<TableCell>
|
||||
<StatusBadge situacao={item.situacao} />
|
||||
</TableCell>
|
||||
|
||||
<TableCell>{item.descricao}</TableCell>
|
||||
|
||||
<TableCell className="text-right">
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<EllipsisIcon />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
|
||||
<DropdownMenuContent side="left" align="start">
|
||||
<DropdownMenuGroup>
|
||||
<DropdownMenuItem
|
||||
className="cursor-pointer"
|
||||
onSelect={() => onEdit(item, true)}
|
||||
>
|
||||
<PencilIcon className="mr-2 h-4 w-4" />
|
||||
Editar
|
||||
</DropdownMenuItem>
|
||||
|
||||
<DropdownMenuSeparator />
|
||||
|
||||
<DropdownMenuItem
|
||||
className="cursor-pointer"
|
||||
onSelect={() => onDelete(item, true)}
|
||||
>
|
||||
<Trash2Icon className="mr-2 h-4 w-4" />
|
||||
Remover
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuGroup>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,155 @@
|
|||
'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 MainEditor from '@/components/MainEditor';
|
||||
import { TMinutaInterface } from '../../_interfaces/TMinutaInterface';
|
||||
import { TMinutaSchema } from '../../_schemas/TMinutaSchema';
|
||||
|
||||
type FormValues = z.infer<typeof TMinutaSchema>;
|
||||
|
||||
interface TMinutaFormProps {
|
||||
isOpen: boolean;
|
||||
data: FormValues | null;
|
||||
onClose: (item: null, isFormStatus: boolean) => void;
|
||||
onSave: (data: FormValues) => void;
|
||||
}
|
||||
|
||||
export default function TMinutaForm({
|
||||
isOpen,
|
||||
data,
|
||||
onClose,
|
||||
onSave
|
||||
}: TMinutaFormProps) {
|
||||
|
||||
const form = useForm<FormValues>({
|
||||
resolver: zodResolver(TMinutaSchema),
|
||||
defaultValues: {
|
||||
minuta_id: 0,
|
||||
natureza_id: undefined,
|
||||
descricao: '',
|
||||
situacao: 'A',
|
||||
texto: '',
|
||||
}
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (data) form.reset(data);
|
||||
}, [data, form]);
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
open={isOpen}
|
||||
onOpenChange={(open) => {
|
||||
if (!open) onClose(null, false);
|
||||
}}
|
||||
>
|
||||
<DialogContent className="mx-auto"> {/* tamanho maior para comportar o editor */}
|
||||
<DialogHeader>
|
||||
<DialogTitle>Minuta</DialogTitle>
|
||||
<DialogDescription>
|
||||
Crie ou edite uma minuta de ato notarial.
|
||||
</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 da minuta" />
|
||||
</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>{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: '2', bottom: '2', left: '3', right: '3' }}
|
||||
size={{ width: 800, height: 500 }}
|
||||
/>
|
||||
{form.formState.errors.texto && (
|
||||
<p className="text-sm text-red-500 mt-2">
|
||||
{form.formState.errors.texto.message}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
/>
|
||||
|
||||
{/* Rodapé do Dialog */}
|
||||
<DialogFooter className="mt-4">
|
||||
<DialogClose asChild>
|
||||
<Button variant="outline" type="button" onClick={() => onClose(null, false)}>
|
||||
Cancelar
|
||||
</Button>
|
||||
</DialogClose>
|
||||
<Button type="submit" disabled={form.formState.isSubmitting}>
|
||||
{form.formState.isSubmitting ? "Salvando..." : "Salvar"}
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
|
||||
{/* Campos ocultos */}
|
||||
<input type="hidden" {...form.register("minuta_id")} />
|
||||
<input type="hidden" {...form.register("natureza_id")} />
|
||||
|
||||
</form>
|
||||
</Form>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,97 @@
|
|||
'use client';
|
||||
|
||||
import Link from "next/link";
|
||||
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 { TMinutaInterface } from "../../_interfaces/TMinutaInterface";
|
||||
|
||||
interface TMinutaTableProps {
|
||||
data: TMinutaInterface[];
|
||||
onEdit: (item: TMinutaInterface, isEditing: boolean) => void;
|
||||
onDelete: (item: TMinutaInterface, isEditing: 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 mr-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 TMinutaTable({
|
||||
data,
|
||||
}: TMinutaTableProps) {
|
||||
return (
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>#</TableHead>
|
||||
<TableHead>Situação</TableHead>
|
||||
<TableHead>Descrição</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
|
||||
<TableBody>
|
||||
{data.length === 0 ? (
|
||||
<TableRow>
|
||||
<TableCell colSpan={4} className="text-center text-muted-foreground">
|
||||
Nenhuma minuta encontrada.
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
) : (
|
||||
data.map((item) => (
|
||||
<TableRow key={item.t_minuta_id} className="cursor-pointer">
|
||||
<TableCell className="font-medium">
|
||||
{item.t_minuta_id}
|
||||
</TableCell>
|
||||
|
||||
<TableCell>
|
||||
<StatusBadge situacao={item.situacao} />
|
||||
</TableCell>
|
||||
|
||||
<TableCell>{item.descricao}</TableCell>
|
||||
|
||||
<TableCell className="text-right">
|
||||
<Button asChild>
|
||||
<Link href={`/cadastros/minuta/${item.t_minuta_id}/detalhes`}>
|
||||
Detalhes
|
||||
</Link>
|
||||
</Button>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))
|
||||
)}
|
||||
</TableBody>
|
||||
</Table>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,189 @@
|
|||
'use client';
|
||||
|
||||
import z from "zod";
|
||||
import { useEffect } from "react";
|
||||
import { useForm, Controller } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Checkbox } from "@/components/ui/checkbox";
|
||||
import {
|
||||
Dialog,
|
||||
DialogClose,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle
|
||||
} from "@/components/ui/dialog";
|
||||
import {
|
||||
Form,
|
||||
FormControl,
|
||||
FormField,
|
||||
FormItem,
|
||||
FormLabel,
|
||||
FormMessage
|
||||
} from "@/components/ui/form";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue
|
||||
} from "@/components/ui/select";
|
||||
|
||||
import { TTBAndamentoServicoSchema } from "../../_schemas/TTBAndamentoServicoSchema";
|
||||
import { tipoEnum } from "../../_interfaces/TTBAndamentoServicoInterface";
|
||||
|
||||
type FormValues = z.infer<typeof TTBAndamentoServicoSchema>;
|
||||
|
||||
interface Props {
|
||||
isOpen: boolean;
|
||||
data: FormValues | null;
|
||||
onClose: (item: null, isFormStatus: boolean) => void;
|
||||
onSave: (data: FormValues) => void;
|
||||
}
|
||||
|
||||
export default function TTBAndamentoServicoForm({ isOpen, data, onClose, onSave }: Props) {
|
||||
// Inicializa o react-hook-form com schema zod
|
||||
const form = useForm<FormValues>({
|
||||
resolver: zodResolver(TTBAndamentoServicoSchema),
|
||||
defaultValues: {
|
||||
descricao: "",
|
||||
tipo: tipoEnum.OUTROS,
|
||||
situacao: "A",
|
||||
usa_email: "I",
|
||||
tb_andamentoservico_id: 0,
|
||||
},
|
||||
});
|
||||
|
||||
// Opções do Select mapeadas a partir do enum
|
||||
const tipoOptions = Object.values(tipoEnum).map((value) => ({
|
||||
value,
|
||||
label:
|
||||
value === "C" ? "Cancelado" :
|
||||
value === "E" ? "Estornado" :
|
||||
value === "PT" ? "Protocolado" :
|
||||
value === "PD" ? "Pedido" :
|
||||
value === "NC" ? "Não Consta" :
|
||||
"Outros"
|
||||
}));
|
||||
|
||||
// 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>
|
||||
Andamentos
|
||||
</DialogTitle>
|
||||
<DialogDescription>
|
||||
Controle de andamentos de atos
|
||||
</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>
|
||||
)}
|
||||
/>
|
||||
|
||||
{/* Tipo */}
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="tipo"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Tipo</FormLabel>
|
||||
<Select value={field.value} onValueChange={field.onChange}>
|
||||
<FormControl className="w-full">
|
||||
<SelectTrigger>
|
||||
<SelectValue placeholder="Escolha o tipo do andamento" />
|
||||
</SelectTrigger>
|
||||
</FormControl>
|
||||
<SelectContent>
|
||||
{tipoOptions.map((option) => (
|
||||
<SelectItem key={option.value} value={option.value}>
|
||||
{option.label}
|
||||
</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>
|
||||
)}
|
||||
/>
|
||||
|
||||
{/* Usar e-mail */}
|
||||
<Controller
|
||||
name="usa_email"
|
||||
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>Usar e-mail</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_andamentoservico_id")} />
|
||||
</form>
|
||||
</Form>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,124 @@
|
|||
'use client';
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuGroup,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableHead,
|
||||
TableHeader,
|
||||
TableRow
|
||||
} from "@/components/ui/table";
|
||||
|
||||
import { EllipsisIcon, PencilIcon, Trash2Icon } from "lucide-react";
|
||||
import TTBAndamentoServicoInteface from "../../_interfaces/TTBAndamentoServicoInterface";
|
||||
|
||||
interface TTBAndamentoServicoTableProps {
|
||||
data: TTBAndamentoServicoInteface[];
|
||||
onEdit: (item: TTBAndamentoServicoInteface, isEditingFormStatus: boolean) => void;
|
||||
onDelete: (item: TTBAndamentoServicoInteface, isEditingFormStatus: boolean) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renderiza o badge de situação
|
||||
*/
|
||||
function StatusBadge({ situacao }: { situacao: string }) {
|
||||
const isActive = situacao === "A";
|
||||
|
||||
const 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 TTBAndamentoServicoTable({
|
||||
data,
|
||||
onEdit,
|
||||
onDelete
|
||||
}: TTBAndamentoServicoTableProps) {
|
||||
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_andamentoservico_id}
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<TableCell className="font-medium">
|
||||
{item.tb_andamentoservico_id}
|
||||
</TableCell>
|
||||
|
||||
<TableCell>
|
||||
<StatusBadge situacao={item.situacao} />
|
||||
</TableCell>
|
||||
|
||||
<TableCell>{item.descricao}</TableCell>
|
||||
|
||||
<TableCell className="text-right">
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<EllipsisIcon />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
|
||||
<DropdownMenuContent side="left" align="start">
|
||||
<DropdownMenuGroup>
|
||||
<DropdownMenuItem
|
||||
className="cursor-pointer"
|
||||
onSelect={() => onEdit(item, true)}
|
||||
>
|
||||
<PencilIcon className="mr-2 h-4 w-4" />
|
||||
Editar
|
||||
</DropdownMenuItem>
|
||||
|
||||
<DropdownMenuSeparator />
|
||||
|
||||
<DropdownMenuItem
|
||||
className="cursor-pointer"
|
||||
onSelect={() => onDelete(item, true)}
|
||||
>
|
||||
<Trash2Icon className="mr-2 h-4 w-4" />
|
||||
Remover
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuGroup>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,127 @@
|
|||
'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 { TTBReconhecimentoTipoSchema } from "../../_schemas/TTBReconhecimentoTipoSchema";
|
||||
import { situacaoEnum } from "../../_interfaces/TTBReconhecimentoTipoInterface";
|
||||
|
||||
type FormValues = z.infer<typeof TTBReconhecimentoTipoSchema>;
|
||||
|
||||
interface TTBReconhecimentoTipoFormProps {
|
||||
isOpen: boolean;
|
||||
data: FormValues | null;
|
||||
onClose: (item: null, isFormStatus: boolean) => void;
|
||||
onSave: (data: FormValues) => void;
|
||||
}
|
||||
|
||||
export default function TTBReconhecimentoTipoForm({ isOpen, data, onClose, onSave }: TTBReconhecimentoTipoFormProps) {
|
||||
// Inicializa o react-hook-form com schema zod
|
||||
const form = useForm<FormValues>({
|
||||
resolver: zodResolver(TTBReconhecimentoTipoSchema),
|
||||
defaultValues: {
|
||||
tb_reconhecimentotipo_id: 0,
|
||||
descricao: "",
|
||||
situacao: situacaoEnum.ATIVO,
|
||||
},
|
||||
});
|
||||
|
||||
// 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>
|
||||
Reconhecimentos
|
||||
</DialogTitle>
|
||||
<DialogDescription>
|
||||
Tipos de Reconhecimentos
|
||||
</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_reconhecimentotipo_id")} />
|
||||
</form>
|
||||
</Form>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,124 @@
|
|||
'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 TTBReconhecimentoTipoInterface from "../../_interfaces/TTBReconhecimentoTipoInterface";
|
||||
|
||||
interface TTBReconhecimentoTipoTableProps {
|
||||
data: TTBReconhecimentoTipoInterface[];
|
||||
onEdit: (item: TTBReconhecimentoTipoInterface, isEditingFormStatus: boolean) => void;
|
||||
onDelete: (item: TTBReconhecimentoTipoInterface, isEditingFormStatus: boolean) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renderiza o badge de situação
|
||||
*/
|
||||
function StatusBadge({ situacao }: { situacao: string }) {
|
||||
const isActive = situacao === "A";
|
||||
|
||||
const 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 TTBReconhecimentoTipoTable({
|
||||
data,
|
||||
onEdit,
|
||||
onDelete
|
||||
}: TTBReconhecimentoTipoTableProps) {
|
||||
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_reconhecimentotipo_id}
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<TableCell className="font-medium">
|
||||
{item.tb_reconhecimentotipo_id}
|
||||
</TableCell>
|
||||
|
||||
<TableCell>
|
||||
<StatusBadge situacao={item.situacao} />
|
||||
</TableCell>
|
||||
|
||||
<TableCell>{item.descricao}</TableCell>
|
||||
|
||||
<TableCell className="text-right">
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<EllipsisIcon />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
|
||||
<DropdownMenuContent side="left" align="start">
|
||||
<DropdownMenuGroup>
|
||||
<DropdownMenuItem
|
||||
className="cursor-pointer"
|
||||
onSelect={() => onEdit(item, true)}
|
||||
>
|
||||
<PencilIcon className="mr-2 h-4 w-4" />
|
||||
Editar
|
||||
</DropdownMenuItem>
|
||||
|
||||
<DropdownMenuSeparator />
|
||||
|
||||
<DropdownMenuItem
|
||||
className="cursor-pointer"
|
||||
onSelect={() => onDelete(item, true)}
|
||||
>
|
||||
<Trash2Icon className="mr-2 h-4 w-4" />
|
||||
Remover
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuGroup>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
import API from "@/services/api/Api";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
import MedidaTipoMockDeDados from "./mockMedidaTipo";
|
||||
|
||||
const useMock = true
|
||||
|
||||
export default async function GMedidaTipoIndexData() {
|
||||
if (useMock) {
|
||||
console.log(MedidaTipoMockDeDados())
|
||||
return await MedidaTipoMockDeDados();
|
||||
}
|
||||
|
||||
const api = new API();
|
||||
try {
|
||||
const dados = await api.send({
|
||||
method: Methods.GET,
|
||||
endpoint: `administrativo/g_medida_tipo/`
|
||||
});
|
||||
return dados
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
return error
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
import API from "@/services/api/Api";
|
||||
import { GMedidaTipoInterface } from "../../_interfaces/GMedidaTipoInterface";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
|
||||
export default async function GMedidaTipoRemoveData(data: GMedidaTipoInterface) {
|
||||
|
||||
const api = new API();
|
||||
|
||||
return await api.send({
|
||||
method: Methods.DELETE,
|
||||
endpoint: `administrativo/g_medida_tipo/${data.medida_tipo_id}`
|
||||
});
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
import API from "@/services/api/Api";
|
||||
import { GMedidaTipoInterface } from "../../_interfaces/GMedidaTipoInterface";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
|
||||
export default async function GMedidaTipoSaveData(data: GMedidaTipoInterface) {
|
||||
|
||||
const isUpdate = Boolean(data.medida_tipo_id);
|
||||
|
||||
const api = new API();
|
||||
|
||||
return await api.send({
|
||||
method: isUpdate ? Methods.PUT : Methods.POST,
|
||||
endpoint: `administrativo/g_medida_tipo/${data.medida_tipo_id || ''}`,
|
||||
body: data
|
||||
});
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
export default async function MedidaTipoMockDeDados() {
|
||||
return Promise.resolve({
|
||||
status: 200,
|
||||
message: 'Dados localizados',
|
||||
data: [
|
||||
{
|
||||
medida_tipo_id: 1.00,
|
||||
sigla: "Alqueire",
|
||||
descricao: "Alqueire"
|
||||
},
|
||||
{
|
||||
medida_tipo_id: 2.00,
|
||||
sigla: "ha",
|
||||
descricao: "Hectare"
|
||||
},
|
||||
{
|
||||
medida_tipo_id: 3.00,
|
||||
sigla: "m2",
|
||||
descricao: "Metros Quadrados"
|
||||
},
|
||||
{
|
||||
medida_tipo_id: 4.00,
|
||||
sigla: "braça",
|
||||
descricao: "Braça"
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
import API from "@/services/api/Api";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
|
||||
export default async function GTBBairroIndexData() {
|
||||
|
||||
const api = new API();
|
||||
|
||||
const dados = await api.send({
|
||||
method: Methods.GET,
|
||||
endpoint: `administrativo/g_tb_bairro/`
|
||||
});
|
||||
|
||||
return dados
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
import API from "@/services/api/Api";
|
||||
import { GTBBairroInterface } from "../../_interfaces/GTBBairroInterface";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
|
||||
export default async function GTBBairroRemoveData(data: GTBBairroInterface) {
|
||||
|
||||
const api = new API();
|
||||
|
||||
return await api.send({
|
||||
method: Methods.DELETE,
|
||||
endpoint: `administrativo/g_tb_bairro/${data.tb_bairro_id}`
|
||||
});
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
import API from "@/services/api/Api";
|
||||
import { GTBBairroInterface } from "../../_interfaces/GTBBairroInterface";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
|
||||
export default async function GTBBairroSaveData(data: GTBBairroInterface) {
|
||||
|
||||
const isUpdate = Boolean(data.tb_bairro_id);
|
||||
|
||||
const api = new API();
|
||||
|
||||
return await api.send({
|
||||
method: isUpdate ? Methods.PUT : Methods.POST,
|
||||
endpoint: `administrativo/g_tb_bairro/${data.tb_bairro_id || ''}`,
|
||||
body: data
|
||||
});
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
import { GTBBairroInterface } from "../../_interfaces/GTBBairroInterface";
|
||||
|
||||
export default async function BairroMockDeDados() {
|
||||
return Promise.resolve({
|
||||
status: 200,
|
||||
message: 'Dados localizados',
|
||||
data: [
|
||||
{
|
||||
sistema_id: 1.00,
|
||||
tb_bairro_id: 390.00,
|
||||
descricao: "AV. RUI BARBOSA",
|
||||
situacao: "A"
|
||||
},
|
||||
{
|
||||
sistema_id: 1.00,
|
||||
tb_bairro_id: 391.00,
|
||||
descricao: "AV. PRESIDENTE DUTRA",
|
||||
situacao: "A"
|
||||
},
|
||||
{
|
||||
sistema_id: 1.00,
|
||||
tb_bairro_id: 392.00,
|
||||
descricao: "LOTEAMENTO CIDADE MARA ROSA",
|
||||
situacao: "A"
|
||||
},
|
||||
{
|
||||
sistema_id: 1.00,
|
||||
tb_bairro_id: 393.00,
|
||||
descricao: "LOTEAMENTO BENEDITO COELHO FURTADO",
|
||||
situacao: "A"
|
||||
},
|
||||
{
|
||||
sistema_id: 1.00,
|
||||
tb_bairro_id: 394.00,
|
||||
descricao: "RUA 15 DE NOVEMBRO",
|
||||
situacao: "A"
|
||||
},
|
||||
{
|
||||
sistema_id: 1.00,
|
||||
tb_bairro_id: 395.00,
|
||||
descricao: "PRACA JOSÉ MAURICIO DE MOURA",
|
||||
situacao: "A"
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
import API from "@/services/api/Api";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
import EstadoCivilMockDeDados from "./mockEstadoCivil";
|
||||
|
||||
const useMock = true
|
||||
|
||||
export default async function GTBEstadoCivilIndexData() {
|
||||
if (useMock) {
|
||||
console.log(EstadoCivilMockDeDados())
|
||||
return await EstadoCivilMockDeDados();
|
||||
}
|
||||
|
||||
const api = new API();
|
||||
try {
|
||||
const dados = await api.send({
|
||||
method: Methods.GET,
|
||||
endpoint: `administrativo/g_tb_estado_civil/`
|
||||
});
|
||||
return dados
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
return error
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
import API from "@/services/api/Api";
|
||||
import { GTBEstadoCivilInterface } from "../../_interfaces/GTBEstadoCivilInterface";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
|
||||
export default async function GTBEstadoCivilRemoveData(data: GTBEstadoCivilInterface) {
|
||||
|
||||
const api = new API();
|
||||
|
||||
return await api.send({
|
||||
method: Methods.DELETE,
|
||||
endpoint: `administrativo/g_tb_bairro/${data.tb_estadocivil_id}`
|
||||
});
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
import API from "@/services/api/Api";
|
||||
import { GTBEstadoCivilInterface } from "../../_interfaces/GTBEstadoCivilInterface";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
|
||||
export default async function GTBEstadoCivilSaveData(data: GTBEstadoCivilInterface) {
|
||||
|
||||
const isUpdate = Boolean(data.tb_estadocivil_id);
|
||||
|
||||
const api = new API();
|
||||
|
||||
return await api.send({
|
||||
method: isUpdate ? Methods.PUT : Methods.POST,
|
||||
endpoint: `administrativo/g_tb_bairro/${data.tb_estadocivil_id || ''}`,
|
||||
body: data
|
||||
});
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
import { GTBBairroInterface } from "../../_interfaces/GTBBairroInterface";
|
||||
|
||||
export default async function EstadoCivilMockDeDados() {
|
||||
return Promise.resolve({
|
||||
status: 200,
|
||||
message: 'Dados localizados',
|
||||
data: [
|
||||
{
|
||||
tb_estadocivil_id: 26.00,
|
||||
sistema_id: 2.00,
|
||||
descricao: "casado",
|
||||
situacao: "A",
|
||||
},
|
||||
{
|
||||
tb_estadocivil_id: 27.00,
|
||||
sistema_id: 2.00,
|
||||
descricao: "solteiro(a)",
|
||||
situacao: "A",
|
||||
},
|
||||
{
|
||||
tb_estadocivil_id: 28.00,
|
||||
sistema_id: 2.00,
|
||||
descricao: "desquitado(a)",
|
||||
situacao: "A",
|
||||
},
|
||||
{
|
||||
tb_estadocivil_id: 29.00,
|
||||
sistema_id: 2.00,
|
||||
descricao: "divorciado(a)",
|
||||
situacao: "A",
|
||||
},
|
||||
{
|
||||
tb_estadocivil_id: 30.00,
|
||||
sistema_id: 2.00,
|
||||
descricao: "espólio",
|
||||
situacao: "A",
|
||||
},
|
||||
{
|
||||
tb_estadocivil_id: 31.00,
|
||||
sistema_id: 2.00,
|
||||
descricao: "menor impúbere",
|
||||
situacao: "A",
|
||||
},
|
||||
{
|
||||
tb_estadocivil_id: 32.00,
|
||||
sistema_id: 2.00,
|
||||
descricao: "menor púbere",
|
||||
situacao: "A",
|
||||
},
|
||||
{
|
||||
tb_estadocivil_id: 33.00,
|
||||
sistema_id: 2.00,
|
||||
descricao: "não consta",
|
||||
situacao: "A",
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
import API from "@/services/api/Api";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
|
||||
export default async function GTBProfissoesIndexData() {
|
||||
|
||||
const api = new API();
|
||||
|
||||
return await api.send({
|
||||
method: Methods.GET,
|
||||
endpoint: `administrativo/g_tb_profissao/`
|
||||
});
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
import API from "@/services/api/Api";
|
||||
import GTBProfissaoInterface from "../../_interfaces/GTBProfissaoInterface";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
|
||||
export default async function GTBProfissaoRemoveData(data: GTBProfissaoInterface) {
|
||||
|
||||
const api = new API();
|
||||
|
||||
return await api.send({
|
||||
method: Methods.DELETE,
|
||||
endpoint: `administrativo/g_tb_profissao/${data.tb_profissao_id}`
|
||||
});
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
import API from "@/services/api/Api";
|
||||
import GTBProfissaoInterface from "../../_interfaces/GTBProfissaoInterface";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
|
||||
export default async function GTBProfissaoSaveData(data: GTBProfissaoInterface) {
|
||||
|
||||
const isUpdate = Boolean(data.tb_profissao_id);
|
||||
|
||||
const api = new API();
|
||||
|
||||
return await api.send({
|
||||
method: isUpdate ? Methods.PUT : Methods.POST,
|
||||
endpoint: `administrativo/g_tb_profissao/${data.tb_profissao_id || ''}`,
|
||||
body: data
|
||||
});
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
import API from "@/services/api/Api";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
|
||||
export default async function GTBRegimeBensIndexData() {
|
||||
|
||||
const api = new API();
|
||||
|
||||
return await api.send({
|
||||
method: Methods.GET,
|
||||
endpoint: `administrativo/g_tb_regimebens/`
|
||||
});
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
import API from "@/services/api/Api";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
import GTBRegimeBensInterface from "../../_interfaces/GTBRegimeBensInterface";
|
||||
|
||||
export default async function GTBRegimeBensRemoveData(data: GTBRegimeBensInterface) {
|
||||
|
||||
const api = new API();
|
||||
|
||||
return await api.send({
|
||||
method: Methods.DELETE,
|
||||
endpoint: `administrativo/g_tb_regimebens/${data.tb_regimebens_id}`
|
||||
});
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
import API from "@/services/api/Api";
|
||||
import GTBRegimeBensInterface from "../../_interfaces/GTBRegimeBensInterface";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
import { withClientErrorHandler } from "@/actions/withClientErrorHandler/withClientErrorHandler";
|
||||
|
||||
async function executeGTBRegimeBensSaveData(data: GTBRegimeBensInterface) {
|
||||
|
||||
throw new Error("Nome e email são obrigatórios");
|
||||
|
||||
const isUpdate = Boolean(data.tb_regimebens_id);
|
||||
|
||||
const api = new API();
|
||||
|
||||
return await api.send({
|
||||
method: isUpdate ? Methods.PUT : Methods.POST,
|
||||
endpoint: `administrativo/g_tb_regimebens/${data.tb_regimebens_id || ''}`,
|
||||
body: data
|
||||
});
|
||||
}
|
||||
|
||||
export const GTBRegimeBensSaveData = withClientErrorHandler(executeGTBRegimeBensSaveData);
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
import API from "@/services/api/Api";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
import TipoLogradouroMockDeDados from "./mockTipoLogradouro";
|
||||
|
||||
const useMock = false
|
||||
|
||||
export default async function GTBTipoLogradouroIndexData() {
|
||||
if (useMock) {
|
||||
console.log(TipoLogradouroMockDeDados())
|
||||
return await TipoLogradouroMockDeDados();
|
||||
}
|
||||
|
||||
const api = new API();
|
||||
try {
|
||||
const dados = await api.send({
|
||||
method: Methods.GET,
|
||||
endpoint: `administrativo/g_tb_tipologradouro/`
|
||||
});
|
||||
return dados
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
return error
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
import API from "@/services/api/Api";
|
||||
import { GTBTipoLogradouroInterface } from "../../_interfaces/GTBTipoLogradouroInterface";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
|
||||
export default async function GTBTipoLogradouroRemoveData(data: GTBTipoLogradouroInterface) {
|
||||
|
||||
const api = new API();
|
||||
|
||||
return await api.send({
|
||||
method: Methods.DELETE,
|
||||
endpoint: `administrativo/g_tb_tipologradouro/${data.tb_tipologradouro_id}`
|
||||
});
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
import API from "@/services/api/Api";
|
||||
import { GTBTipoLogradouroInterface } from "../../_interfaces/GTBTipoLogradouroInterface";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
|
||||
export default async function GTBTipoLogradouroSaveData(data: GTBTipoLogradouroInterface) {
|
||||
|
||||
const isUpdate = Boolean(data.tb_tipologradouro_id);
|
||||
|
||||
const api = new API();
|
||||
|
||||
return await api.send({
|
||||
method: isUpdate ? Methods.PUT : Methods.POST,
|
||||
endpoint: `administrativo/g_tb_tipologradouro/${data.tb_tipologradouro_id || ''}`,
|
||||
body: data
|
||||
});
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,98 @@
|
|||
import { GTBTipoLogradouroInterface } from "../../_interfaces/GTBTipoLogradouroInterface";
|
||||
|
||||
export default async function TipoLogradouroMockDeDados(){
|
||||
return Promise.resolve({
|
||||
status: 200,
|
||||
message: 'Dados localizados',
|
||||
data: [
|
||||
{
|
||||
sistema_id: null,
|
||||
tb_tipologradouro_id: 1,
|
||||
situacao_id: null,
|
||||
descricao: "Rua",
|
||||
situacao: "A",
|
||||
onr_tipo_logradouro_id: 250
|
||||
},
|
||||
{
|
||||
sistema_id: null,
|
||||
tb_tipologradouro_id: 2,
|
||||
situacao_id: null,
|
||||
descricao: "Avenida",
|
||||
situacao: "A",
|
||||
onr_tipo_logradouro_id: 26
|
||||
},
|
||||
{
|
||||
sistema_id: null,
|
||||
tb_tipologradouro_id: 3,
|
||||
situacao_id: null,
|
||||
descricao: "Alameda",
|
||||
situacao: "A",
|
||||
onr_tipo_logradouro_id: 10
|
||||
},
|
||||
{
|
||||
sistema_id: null,
|
||||
tb_tipologradouro_id: 4,
|
||||
situacao_id: null,
|
||||
descricao: "Praça",
|
||||
situacao: "A",
|
||||
onr_tipo_logradouro_id: 215
|
||||
},
|
||||
{
|
||||
sistema_id: null,
|
||||
tb_tipologradouro_id: 5,
|
||||
situacao_id: null,
|
||||
descricao: "Via",
|
||||
situacao: "A",
|
||||
onr_tipo_logradouro_id: 294
|
||||
},
|
||||
{
|
||||
sistema_id: null,
|
||||
tb_tipologradouro_id: 6,
|
||||
situacao_id: null,
|
||||
descricao: "Viela",
|
||||
situacao: "A",
|
||||
onr_tipo_logradouro_id: 297
|
||||
},
|
||||
{
|
||||
sistema_id: null,
|
||||
tb_tipologradouro_id: 7,
|
||||
situacao_id: null,
|
||||
descricao: "Travessa",
|
||||
situacao: "A",
|
||||
onr_tipo_logradouro_id: 273
|
||||
},
|
||||
{
|
||||
sistema_id: null,
|
||||
tb_tipologradouro_id: 8,
|
||||
situacao_id: null,
|
||||
descricao: "Rodovia",
|
||||
situacao: "A",
|
||||
onr_tipo_logradouro_id: 247
|
||||
},
|
||||
{
|
||||
sistema_id: null,
|
||||
tb_tipologradouro_id: 9,
|
||||
situacao_id: null,
|
||||
descricao: "Sítios",
|
||||
situacao: "A",
|
||||
onr_tipo_logradouro_id: 263
|
||||
},
|
||||
{
|
||||
sistema_id: null,
|
||||
tb_tipologradouro_id: 10,
|
||||
situacao_id: null,
|
||||
descricao: "Córrego",
|
||||
situacao: "A",
|
||||
onr_tipo_logradouro_id: 86
|
||||
},
|
||||
{
|
||||
sistema_id: null,
|
||||
tb_tipologradouro_id: 11,
|
||||
situacao_id: null,
|
||||
descricao: "Estrada",
|
||||
situacao: "A",
|
||||
onr_tipo_logradouro_id: 117
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
import API from "@/services/api/Api";
|
||||
import GTBRegimeComunhaoInterface from "../../_interfaces/GTBRegimeComunhaoInterface";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
|
||||
export default async function GTBRegimeComunhaoIndexData() {
|
||||
|
||||
const api = new API();
|
||||
|
||||
return await api.send({
|
||||
method: Methods.GET,
|
||||
endpoint: `administrativo/g_tb_regimecomunhao/`
|
||||
});
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
import API from "@/services/api/Api";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
import GTBRegimeComunhaoInterface from "../../_interfaces/GTBRegimeComunhaoInterface";
|
||||
|
||||
export default async function GTBRegimeComunhaoRemoveData(data: GTBRegimeComunhaoInterface) {
|
||||
|
||||
const api = new API();
|
||||
|
||||
return await api.send({
|
||||
method: Methods.DELETE,
|
||||
endpoint: `administrativo/g_tb_regimecomunhao/${data.tb_regimecomunhao_id}`
|
||||
});
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
import API from "@/services/api/Api";
|
||||
import GTBRegimeComunhaoInterface from "../../_interfaces/GTBRegimeComunhaoInterface";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
|
||||
export default async function GTBRegimeComunhaoSaveData(data: GTBRegimeComunhaoInterface) {
|
||||
|
||||
const isUpdate = Boolean(data.tb_regimecomunhao_id);
|
||||
|
||||
const api = new API();
|
||||
|
||||
return await api.send({
|
||||
method: isUpdate ? Methods.PUT : Methods.POST,
|
||||
endpoint: `administrativo/g_tb_regimecomunhao/${data.tb_regimecomunhao_id || ''}`,
|
||||
body: data
|
||||
});
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
import API from "@/services/api/Api";
|
||||
import TCensecInterface from "../../_interfaces/TCensecInterface";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
import { withClientErrorHandler } from "@/actions/withClientErrorHandler/withClientErrorHandler";
|
||||
|
||||
async function executeTCensecDeleteData(data: TCensecInterface) {
|
||||
|
||||
const api = new API();
|
||||
|
||||
return await api.send({
|
||||
method: Methods.DELETE,
|
||||
endpoint: `administrativo/t_censec/${data.censec_id}`,
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
export const TCensecDeleteData = withClientErrorHandler(executeTCensecDeleteData);
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
import { withClientErrorHandler } from "@/actions/withClientErrorHandler/withClientErrorHandler";
|
||||
import API from "@/services/api/Api";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
|
||||
async function executeTCensecIndexData() {
|
||||
|
||||
const api = new API();
|
||||
|
||||
return await api.send({
|
||||
method: Methods.GET,
|
||||
endpoint: `administrativo/t_censec/`,
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
export const TCensecIndexData = withClientErrorHandler(executeTCensecIndexData);
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
import API from "@/services/api/Api";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
import TCensecInterface from "../../_interfaces/TCensecInterface";
|
||||
import { withClientErrorHandler } from "@/actions/withClientErrorHandler/withClientErrorHandler";
|
||||
|
||||
async function executeTCensecSaveData(data: TCensecInterface) {
|
||||
|
||||
const isUpdate = Boolean(data.censec_id);
|
||||
|
||||
const api = new API();
|
||||
|
||||
return await api.send({
|
||||
method: isUpdate ? Methods.PUT : Methods.POST,
|
||||
endpoint: `administrativo/t_censec/${data.censec_id || ''}`,
|
||||
body: data
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
export const TCensecSaveData = withClientErrorHandler(executeTCensecSaveData);
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
import API from "@/services/api/Api";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
import CensecNaturezaLitigioMockDeDados from "./mockCensecNaturezaLitigio";
|
||||
|
||||
const useMock = false
|
||||
|
||||
export default async function TCensecNaturezaLitigioIndexData() {
|
||||
|
||||
if (useMock) {
|
||||
return await CensecNaturezaLitigioMockDeDados();
|
||||
}
|
||||
|
||||
const api = new API();
|
||||
try {
|
||||
const dados = await api.send({
|
||||
method: Methods.GET,
|
||||
endpoint: `administrativo/t_censec_naturezalitigio/`
|
||||
});
|
||||
return dados
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
return error
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
import API from "@/services/api/Api";
|
||||
import { TCensecNaturezaLitigioInterface } from "../../_interfaces/TCensecNaturezaLitigioInterface";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
|
||||
export default async function TCensecNaturezaLitigioRemoveData(data: TCensecNaturezaLitigioInterface) {
|
||||
|
||||
const api = new API();
|
||||
|
||||
console.log(typeof(data.censec_naturezalitigio_id))
|
||||
|
||||
return await api.send({
|
||||
method: Methods.DELETE,
|
||||
endpoint: `administrativo/t_censec_naturezalitigio/${data.censec_naturezalitigio_id}`
|
||||
});
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
import API from "@/services/api/Api";
|
||||
import { TCensecNaturezaLitigioInterface } from "../../_interfaces/TCensecNaturezaLitigioInterface";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
|
||||
export default async function TCensecNaturezaLitigioTipoSaveData(data: TCensecNaturezaLitigioInterface) {
|
||||
|
||||
const api = new API();
|
||||
|
||||
return await api.send({
|
||||
method: data.censec_naturezalitigio_id ? Methods.PUT : Methods.POST,
|
||||
endpoint: `administrativo/t_censec_naturezalitigio/${data.censec_naturezalitigio_id ? data.censec_naturezalitigio_id : ''}`,
|
||||
body: data
|
||||
});
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,113 @@
|
|||
export default async function CensecNaturezaLitigioMockDeDados() {
|
||||
return Promise.resolve({
|
||||
status: 200,
|
||||
message: 'Dados localizados',
|
||||
data: [
|
||||
{
|
||||
censec_naturezaltigio_id: 1,
|
||||
descricao: "Bancário",
|
||||
situacao: "A"
|
||||
},
|
||||
{
|
||||
censec_naturezaltigio_id: 2,
|
||||
descricao: "Concessionária de Água",
|
||||
situacao: "A"
|
||||
},
|
||||
{
|
||||
censec_naturezaltigio_id: 3,
|
||||
descricao: "Concessionária de Gás",
|
||||
situacao: "A"
|
||||
},
|
||||
{
|
||||
censec_naturezaltigio_id: 4,
|
||||
descricao: "Concessionária de Luz",
|
||||
situacao: "A"
|
||||
},
|
||||
{
|
||||
censec_naturezaltigio_id: 5,
|
||||
descricao: "Consumidor",
|
||||
situacao: "A"
|
||||
},
|
||||
{
|
||||
censec_naturezaltigio_id: 6,
|
||||
descricao: "Contrato",
|
||||
situacao: "A"
|
||||
},
|
||||
{
|
||||
censec_naturezaltigio_id: 7,
|
||||
descricao: "Empresarial",
|
||||
situacao: "A"
|
||||
},
|
||||
{
|
||||
censec_naturezaltigio_id: 8,
|
||||
descricao: "Família",
|
||||
situacao: "A"
|
||||
},
|
||||
{
|
||||
censec_naturezaltigio_id: 9,
|
||||
descricao: "Locação",
|
||||
situacao: "A"
|
||||
},
|
||||
{
|
||||
censec_naturezaltigio_id: 10,
|
||||
descricao: "Mobiliário",
|
||||
situacao: "A"
|
||||
},
|
||||
{
|
||||
censec_naturezaltigio_id: 11,
|
||||
descricao: "Previdência",
|
||||
situacao: "A"
|
||||
},
|
||||
{
|
||||
censec_naturezaltigio_id: 12,
|
||||
descricao: "Saúde",
|
||||
situacao: "A"
|
||||
},
|
||||
{
|
||||
censec_naturezaltigio_id: 13,
|
||||
descricao: "Seguro",
|
||||
situacao: "A"
|
||||
},
|
||||
{
|
||||
censec_naturezaltigio_id: 14,
|
||||
descricao: "Serviço Público",
|
||||
situacao: "A"
|
||||
},
|
||||
{
|
||||
censec_naturezaltigio_id: 15,
|
||||
descricao: "Sucessões",
|
||||
situacao: "A"
|
||||
},
|
||||
{
|
||||
censec_naturezaltigio_id: 16,
|
||||
descricao: "Telefonia",
|
||||
situacao: "A"
|
||||
},
|
||||
{
|
||||
censec_naturezaltigio_id: 17,
|
||||
descricao: "Transporte",
|
||||
situacao: "A"
|
||||
},
|
||||
{
|
||||
censec_naturezaltigio_id: 18,
|
||||
descricao: "Transporte - Avião",
|
||||
situacao: "A"
|
||||
},
|
||||
{
|
||||
censec_naturezaltigio_id: 19,
|
||||
descricao: "Transporte - Barco",
|
||||
situacao: "A"
|
||||
},
|
||||
{
|
||||
censec_naturezaltigio_id: 20,
|
||||
descricao: "Transporte Metrô",
|
||||
situacao: "A"
|
||||
},
|
||||
{
|
||||
censec_naturezaltigio_id: 21,
|
||||
descricao: "Transporte - Ônibus",
|
||||
situacao: "A"
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue