diff --git a/.gitignore b/.gitignore index 5ef6a52..674c347 100644 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,5 @@ yarn-error.log* # typescript *.tsbuildinfo next-env.d.ts + +/src/config/app.json diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6edcd97 --- /dev/null +++ b/Dockerfile @@ -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"] diff --git a/Dockerfile-homologacao b/Dockerfile-homologacao new file mode 100644 index 0000000..42d7e81 --- /dev/null +++ b/Dockerfile-homologacao @@ -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"] diff --git a/next.config.ts b/next.config.ts index e9ffa30..0a838ef 100644 --- a/next.config.ts +++ b/next.config.ts @@ -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; diff --git a/package-lock.json b/package-lock.json index 401a659..c13ef56 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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", diff --git a/package.json b/package.json index 30c0281..7e642c5 100644 --- a/package.json +++ b/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", diff --git a/public/images/logo.svg b/public/images/logo.svg new file mode 100644 index 0000000..6199398 --- /dev/null +++ b/public/images/logo.svg @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/src/actions/cookies/CookiesGet.ts b/src/actions/cookies/CookiesGet.ts index 238470d..194669f 100644 --- a/src/actions/cookies/CookiesGet.ts +++ b/src/actions/cookies/CookiesGet.ts @@ -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; } \ No newline at end of file diff --git a/src/actions/json/Json.ts b/src/actions/json/Json.ts index 92a1a18..b075b64 100644 --- a/src/actions/json/Json.ts +++ b/src/actions/json/Json.ts @@ -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; } - } \ No newline at end of file diff --git a/src/actions/text/GetSigla.ts b/src/actions/text/GetSigla.ts new file mode 100644 index 0000000..f6550ae --- /dev/null +++ b/src/actions/text/GetSigla.ts @@ -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(''); +} \ No newline at end of file diff --git a/src/actions/withClientErrorHandler/withClientErrorHandler.ts b/src/actions/withClientErrorHandler/withClientErrorHandler.ts new file mode 100644 index 0000000..b7cb4ff --- /dev/null +++ b/src/actions/withClientErrorHandler/withClientErrorHandler.ts @@ -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 Promise>( + action: T +) { + return async (...args: Parameters): Promise => { + + 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 + }; + + } + + }; + +} diff --git a/src/actions/withClientErrorHandler/withClientErrorHandlerInterface.ts b/src/actions/withClientErrorHandler/withClientErrorHandlerInterface.ts new file mode 100644 index 0000000..f27c593 --- /dev/null +++ b/src/actions/withClientErrorHandler/withClientErrorHandlerInterface.ts @@ -0,0 +1,7 @@ +export default interface withClientErrorHandlerInterface { + + status: number; + data?: T; + message?: string; + +} \ No newline at end of file diff --git a/src/app/(protected)/(administrativo)/(g_usuario)/usuarios/[id]/detalhes/page.tsx b/src/app/(protected)/(administrativo)/(g_usuario)/usuarios/[id]/detalhes/page.tsx index f48c529..125a254 100644 --- a/src/app/(protected)/(administrativo)/(g_usuario)/usuarios/[id]/detalhes/page.tsx +++ b/src/app/(protected)/(administrativo)/(g_usuario)/usuarios/[id]/detalhes/page.tsx @@ -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 ; diff --git a/src/app/(protected)/(administrativo)/(g_usuario)/usuarios/formulario/page.tsx b/src/app/(protected)/(administrativo)/(g_usuario)/usuarios/formulario/page.tsx index f4d153a..16c0a87 100644 --- a/src/app/(protected)/(administrativo)/(g_usuario)/usuarios/formulario/page.tsx +++ b/src/app/(protected)/(administrativo)/(g_usuario)/usuarios/formulario/page.tsx @@ -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 +type FormValues = z.infer export default function UsuarioFormularioPage() { const { usuario, saveUsuario } = useGUsuarioSaveHook(); const form = useForm({ - resolver: zodResolver(UsuarioFormSchema), + resolver: zodResolver(GUsuarioSchema), defaultValues: { login: '', nome_completo: '', diff --git a/src/app/(protected)/(administrativo)/(g_usuario)/usuarios/page.tsx b/src/app/(protected)/(administrativo)/(g_usuario)/usuarios/page.tsx index 77e4dc5..37344b1 100644 --- a/src/app/(protected)/(administrativo)/(g_usuario)/usuarios/page.tsx +++ b/src/app/(protected)/(administrativo)/(g_usuario)/usuarios/page.tsx @@ -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"; diff --git a/src/app/(protected)/(administrativo)/_data/g_usuario/GUsuarioDeleteData.ts b/src/app/(protected)/(administrativo)/_data/g_usuario/GUsuarioDeleteData.ts index 3313c91..1d1d6ba 100644 --- a/src/app/(protected)/(administrativo)/_data/g_usuario/GUsuarioDeleteData.ts +++ b/src/app/(protected)/(administrativo)/_data/g_usuario/GUsuarioDeleteData.ts @@ -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; diff --git a/src/app/(protected)/(administrativo)/_data/g_usuario/GUsuarioIndexData.ts b/src/app/(protected)/(administrativo)/_data/g_usuario/GUsuarioIndexData.ts index 8b6f66f..aaf6075 100644 --- a/src/app/(protected)/(administrativo)/_data/g_usuario/GUsuarioIndexData.ts +++ b/src/app/(protected)/(administrativo)/_data/g_usuario/GUsuarioIndexData.ts @@ -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; diff --git a/src/app/(protected)/(administrativo)/_data/g_usuario/GUsuarioLoginData.ts b/src/app/(protected)/(administrativo)/_data/g_usuario/GUsuarioLoginData.ts index 5602616..c6f7c46 100644 --- a/src/app/(protected)/(administrativo)/_data/g_usuario/GUsuarioLoginData.ts +++ b/src/app/(protected)/(administrativo)/_data/g_usuario/GUsuarioLoginData.ts @@ -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 }); diff --git a/src/app/(protected)/(administrativo)/_data/g_usuario/GUsuarioReadData.ts b/src/app/(protected)/(administrativo)/_data/g_usuario/GUsuarioReadData.ts index 872c948..afe73b3 100644 --- a/src/app/(protected)/(administrativo)/_data/g_usuario/GUsuarioReadData.ts +++ b/src/app/(protected)/(administrativo)/_data/g_usuario/GUsuarioReadData.ts @@ -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 diff --git a/src/app/(protected)/(administrativo)/_data/g_usuario/GUsuarioSaveData.ts b/src/app/(protected)/(administrativo)/_data/g_usuario/GUsuarioSaveData.ts index 2ee92e2..e6ce62c 100644 --- a/src/app/(protected)/(administrativo)/_data/g_usuario/GUsuarioSaveData.ts +++ b/src/app/(protected)/(administrativo)/_data/g_usuario/GUsuarioSaveData.ts @@ -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 }); diff --git a/src/app/(protected)/(administrativo)/_hooks/g_usuario/useGUsuarioIndexHook.ts b/src/app/(protected)/(administrativo)/_hooks/g_usuario/useGUsuarioIndexHook.ts index ce65a48..93ca26d 100644 --- a/src/app/(protected)/(administrativo)/_hooks/g_usuario/useGUsuarioIndexHook.ts +++ b/src/app/(protected)/(administrativo)/_hooks/g_usuario/useGUsuarioIndexHook.ts @@ -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"; diff --git a/src/app/(protected)/(administrativo)/_hooks/g_usuario/useGUsuarioLogoutHook.ts b/src/app/(protected)/(administrativo)/_hooks/g_usuario/useGUsuarioLogoutHook.ts new file mode 100644 index 0000000..7220189 --- /dev/null +++ b/src/app/(protected)/(administrativo)/_hooks/g_usuario/useGUsuarioLogoutHook.ts @@ -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 } +} \ No newline at end of file diff --git a/src/app/(protected)/(administrativo)/_hooks/g_usuario/useGUsuarioReadHooks.ts b/src/app/(protected)/(administrativo)/_hooks/g_usuario/useGUsuarioReadHooks.ts index 3283fa1..9f73250 100644 --- a/src/app/(protected)/(administrativo)/_hooks/g_usuario/useGUsuarioReadHooks.ts +++ b/src/app/(protected)/(administrativo)/_hooks/g_usuario/useGUsuarioReadHooks.ts @@ -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); diff --git a/src/app/(protected)/(administrativo)/_hooks/g_usuario/useGUsuarioSaveHook.ts b/src/app/(protected)/(administrativo)/_hooks/g_usuario/useGUsuarioSaveHook.ts index c6d1144..6519021 100644 --- a/src/app/(protected)/(administrativo)/_hooks/g_usuario/useGUsuarioSaveHook.ts +++ b/src/app/(protected)/(administrativo)/_hooks/g_usuario/useGUsuarioSaveHook.ts @@ -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"; diff --git a/src/app/(protected)/(administrativo)/_interfaces/IGUsuario.ts b/src/app/(protected)/(administrativo)/_interfaces/GUsuarioInterface.ts similarity index 96% rename from src/app/(protected)/(administrativo)/_interfaces/IGUsuario.ts rename to src/app/(protected)/(administrativo)/_interfaces/GUsuarioInterface.ts index bb299b4..13af8c1 100644 --- a/src/app/(protected)/(administrativo)/_interfaces/IGUsuario.ts +++ b/src/app/(protected)/(administrativo)/_interfaces/GUsuarioInterface.ts @@ -1,4 +1,4 @@ -export default interface Usuario { +export default interface GUsuario { usuario_id: number, trocarsenha: string, login: string, diff --git a/src/app/(protected)/(administrativo)/_schemas/GUsuarioSchema.ts b/src/app/(protected)/(administrativo)/_schemas/GUsuarioSchema.ts index c6b8831..c3942c2 100644 --- a/src/app/(protected)/(administrativo)/_schemas/GUsuarioSchema.ts +++ b/src/app/(protected)/(administrativo)/_schemas/GUsuarioSchema.ts @@ -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(), diff --git a/src/app/(protected)/(administrativo)/_services/g_usuario/GUsuarioIndex.ts b/src/app/(protected)/(administrativo)/_services/g_usuario/GUsuarioIndex.ts index 7447a94..b105740 100644 --- a/src/app/(protected)/(administrativo)/_services/g_usuario/GUsuarioIndex.ts +++ b/src/app/(protected)/(administrativo)/_services/g_usuario/GUsuarioIndex.ts @@ -8,4 +8,4 @@ export default async function GUsuarioIndex() { return response; -} \ No newline at end of file +} \ No newline at end of file diff --git a/src/app/(protected)/(administrativo)/_services/g_usuario/GUsuarioLogin.ts b/src/app/(protected)/(administrativo)/_services/g_usuario/GUsuarioLogin.ts index b2f5926..b71b1f2 100644 --- a/src/app/(protected)/(administrativo)/_services/g_usuario/GUsuarioLogin.ts +++ b/src/app/(protected)/(administrativo)/_services/g_usuario/GUsuarioLogin.ts @@ -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"); -} \ No newline at end of file +} + +// Exporta função encapsulada +export const GUsuarioLoginService = withClientErrorHandler(executeGUsuarioLoginService); \ No newline at end of file diff --git a/src/app/(protected)/(administrativo)/_services/g_usuario/GUsuarioLogoutService.ts b/src/app/(protected)/(administrativo)/_services/g_usuario/GUsuarioLogoutService.ts new file mode 100644 index 0000000..4747715 --- /dev/null +++ b/src/app/(protected)/(administrativo)/_services/g_usuario/GUsuarioLogoutService.ts @@ -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'); + +} \ No newline at end of file diff --git a/src/app/(protected)/(administrativo)/_services/g_usuario/GUsuarioRead.ts b/src/app/(protected)/(administrativo)/_services/g_usuario/GUsuarioRead.ts index 95ce84e..037a1ea 100644 --- a/src/app/(protected)/(administrativo)/_services/g_usuario/GUsuarioRead.ts +++ b/src/app/(protected)/(administrativo)/_services/g_usuario/GUsuarioRead.ts @@ -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 + } + } \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/(g_medidatipo)/medida-tipo/page.tsx b/src/app/(protected)/(cadastros)/cadastros/(g_medidatipo)/medida-tipo/page.tsx new file mode 100644 index 0000000..5b198ea --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/(g_medidatipo)/medida-tipo/page.tsx @@ -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(null); + const [isFormOpen, setIsFormOpen] = useState(false); + const [itemToDelete, setItemToDelete] = useState(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 ; + } + + return ( +
+ {/* Cabeçalho */} +
{ handleOpenForm(data = initialMedidaTipo) }} + /> + + {/* Tabela de Tipos de Medida */} + + + + + + + {/* Modal de confirmação */} + + + {/* Formulário de criação/edição */} + +
+ ); +} diff --git a/src/app/(protected)/(cadastros)/cadastros/(g_tb_bairro)/bairro/page.tsx b/src/app/(protected)/(cadastros)/cadastros/(g_tb_bairro)/bairro/page.tsx new file mode 100644 index 0000000..4cf949b --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/(g_tb_bairro)/bairro/page.tsx @@ -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(null); + const [isFormOpen, setIsFormOpen] = useState(false); + const [itemToDelete, setItemToDelete] = useState(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 ; + } + + return ( +
+ {/* Cabeçalho */} +
{ handleOpenForm(data = initialBairro) }} + /> + + {/* Tabela de Bairros */} + + + + + + + {/* Modal de confirmação */} + + + {/* Formulário de criação/edição */} + +
+ ); +} diff --git a/src/app/(protected)/(cadastros)/cadastros/(g_tb_estadocivil)/estado-civil/page.tsx b/src/app/(protected)/(cadastros)/cadastros/(g_tb_estadocivil)/estado-civil/page.tsx new file mode 100644 index 0000000..536b2be --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/(g_tb_estadocivil)/estado-civil/page.tsx @@ -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(null); + const [isFormOpen, setIsFormOpen] = useState(false); + const [itemToDelete, setItemToDelete] = useState(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 ; + } + + return ( +
+ {/* Cabeçalho */} +
{ handleOpenForm(data = initalEstadoCivil) }} + /> + + {/* Tabela de Estados Civis */} + + + + + + + {/* Modal de confirmação */} + + + {/* Formulário de criação/edição */} + +
+ ); +} diff --git a/src/app/(protected)/(cadastros)/cadastros/(g_tb_profissao)/profissoes/page.tsx b/src/app/(protected)/(cadastros)/cadastros/(g_tb_profissao)/profissoes/page.tsx new file mode 100644 index 0000000..cce2544 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/(g_tb_profissao)/profissoes/page.tsx @@ -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(null); + const [isFormOpen, setIsFormOpen] = useState(false); + + // Estado para saber qual item será deletado + const [itemToDelete, setItemToDelete] = useState(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 ; + } + + return ( +
+ {/* Cabeçalho */} +
{ handleOpenForm(null) }} + /> + + {/* Tabela de andamentos */} + + + + + + + {/* Modal de confirmação */} + + + {/* Formulário de criação/edição */} + +
+ ); 4 +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/(g_tb_regimebens)/regime-bens/page.tsx b/src/app/(protected)/(cadastros)/cadastros/(g_tb_regimebens)/regime-bens/page.tsx new file mode 100644 index 0000000..a241d19 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/(g_tb_regimebens)/regime-bens/page.tsx @@ -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(null); + const [isFormOpen, setIsFormOpen] = useState(false); + + // Estado para saber qual item será deletado + const [itemToDelete, setItemToDelete] = useState(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 ; + } + + return ( +
+ {/* Cabeçalho */} +
{ handleOpenForm(null) }} + /> + + {/* Tabela de andamentos */} + + + + + + + {/* Modal de confirmação */} + + + {/* Formulário de criação/edição */} + +
+ ); 4 +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/(g_tb_regimecomunhao)/regime-comunhao/page.tsx b/src/app/(protected)/(cadastros)/cadastros/(g_tb_regimecomunhao)/regime-comunhao/page.tsx new file mode 100644 index 0000000..55af3da --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/(g_tb_regimecomunhao)/regime-comunhao/page.tsx @@ -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(null); + const [isFormOpen, setIsFormOpen] = useState(false); + + // Estado para saber qual item será deletado + const [itemToDelete, setItemToDelete] = useState(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 ; + } + + return ( +
+ {/* Cabeçalho */} +
{ handleOpenForm(null) }} + /> + + {/* Tabela de andamentos */} + + + + + + + {/* Modal de confirmação */} + + + {/* Formulário de criação/edição */} + +
+ ); 4 +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/(g_tb_tipologradouro)/tipo-logradouro/page.tsx b/src/app/(protected)/(cadastros)/cadastros/(g_tb_tipologradouro)/tipo-logradouro/page.tsx new file mode 100644 index 0000000..aced899 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/(g_tb_tipologradouro)/tipo-logradouro/page.tsx @@ -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(null); + const [isFormOpen, setIsFormOpen] = useState(false); + + // Estado para saber qual item será deletado + const [itemToDelete, setItemToDelete] = useState(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 ; + } + + return ( +
+ {/* Cabeçalho */} +
{ handleOpenForm(null) }} + /> + + {/* Tabela de andamentos */} + + + + + + + {/* Modal de confirmação */} + + + {/* Formulário de criação/edição */} + +
+ ); +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/(t_censec)/censec/page.tsx b/src/app/(protected)/(cadastros)/cadastros/(t_censec)/censec/page.tsx new file mode 100644 index 0000000..24287f2 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/(t_censec)/censec/page.tsx @@ -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(null); + const [isFormOpen, setIsFormOpen] = useState(false); + + // Estado para saber qual item será deletado + const [itemToDelete, setItemToDelete] = useState(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 ; + } + + return ( +
+ {/* Cabeçalho */} +
{ handleOpenForm(null) }} + /> + + {/* Tabela de andamentos */} + + + + + + + {/* Modal de confirmação */} + + + {/* Formulário de criação/edição */} + +
+ ); 4 +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/(t_censecnaturezalitigio)/censec-natureza-litigio/page.tsx b/src/app/(protected)/(cadastros)/cadastros/(t_censecnaturezalitigio)/censec-natureza-litigio/page.tsx new file mode 100644 index 0000000..28cca94 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/(t_censecnaturezalitigio)/censec-natureza-litigio/page.tsx @@ -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(null); + const [isFormOpen, setIsFormOpen] = useState(false); + const [itemToDelete, setItemToDelete] = useState(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 ; + } + + return ( +
+ {/* Cabeçalho */} +
handleOpenForm(data = initialCensecNaturezaLitigio)} + /> + + {/* Tabela */} + + + + + + + {/* Modal de confirmação */} + + + {/* Formulário */} + +
+ ); +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/(t_minuta)/minuta/[id]/detalhes/page.tsx b/src/app/(protected)/(cadastros)/cadastros/(t_minuta)/minuta/[id]/detalhes/page.tsx new file mode 100644 index 0000000..402df0c --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/(t_minuta)/minuta/[id]/detalhes/page.tsx @@ -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(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 ; + + // Renderiza o editor apenas se o texto foi carregado + if (editorContent === null) { + return ; // Pode mostrar um carregando ou qualquer outra coisa enquanto o conteúdo não está disponível + } + + return ( +
+ + +
+
+
+ Descrição +
+
+ {tMinuta.descricao} +
+
+
+
+ Situação +
+
+ {tMinuta.situacao === "A" ? "Ativo" : "Inativo"} +
+
+
+
+ Texto +
+ +
+
+
+
+
+ ); +} diff --git a/src/app/(protected)/(cadastros)/cadastros/(t_minuta)/minuta/formulario/page.tsx b/src/app/(protected)/(cadastros)/cadastros/(t_minuta)/minuta/formulario/page.tsx new file mode 100644 index 0000000..9a18d59 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/(t_minuta)/minuta/formulario/page.tsx @@ -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; + +export default function TMinutaForm() { + + const { tMinuta, saveTMinuta } = useTMinutaSaveHook(); + + const form = useForm({ + resolver: zodResolver(TMinutaSchema), + defaultValues: { + natureza_id: undefined, + descricao: '', + situacao: 'A', + texto: '', + } + }); + + async function onSubmit(values: FormValues) { + saveTMinuta(values); + } + + return ( +
+ + + +
+ + + {/* Descrição */} + ( + + Descrição + + + + + + )} + /> + + {/* Situação */} + ( +
+ field.onChange(checked ? "A" : "I")} + /> + +
+ )} + /> + + {/* Editor de Texto */} + ( +
+ + {form.formState.errors.texto && ( +

+ {form.formState.errors.texto.message} +

+ )} +
+ )} + /> + + + +
+
+
+ ); +} diff --git a/src/app/(protected)/(cadastros)/cadastros/(t_minuta)/minuta/page.tsx b/src/app/(protected)/(cadastros)/cadastros/(t_minuta)/minuta/page.tsx new file mode 100644 index 0000000..691dc29 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/(t_minuta)/minuta/page.tsx @@ -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(null); + const [isFormOpen, setIsFormOpen] = useState(false); + const [itemToDelete, setItemToDelete] = useState(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 ; + } + + return ( +
+ {/* Cabeçalho */} +
handleOpenForm(null)} + /> + + {/* Tabela */} + + + + + + + {/* Diálogo de confirmação */} + +
+ ); +} diff --git a/src/app/(protected)/(cadastros)/cadastros/(t_tb_andamentoservico)/andamentos/page.tsx b/src/app/(protected)/(cadastros)/cadastros/(t_tb_andamentoservico)/andamentos/page.tsx new file mode 100644 index 0000000..f33c575 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/(t_tb_andamentoservico)/andamentos/page.tsx @@ -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(null); + const [isFormOpen, setIsFormOpen] = useState(false); + + // Estado para saber qual item será deletado + const [itemToDelete, setItemToDelete] = useState(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 ; + } + + return ( +
+ {/* Cabeçalho */} +
{ handleOpenForm(null) }} + /> + + {/* Tabela de andamentos */} + + + + + + + {/* Modal de confirmação */} + + + {/* Formulário de criação/edição */} + +
+ ); 4 +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/(t_tb_reconhecimentotipo)/reconhecimentos/page.tsx b/src/app/(protected)/(cadastros)/cadastros/(t_tb_reconhecimentotipo)/reconhecimentos/page.tsx new file mode 100644 index 0000000..8501ce9 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/(t_tb_reconhecimentotipo)/reconhecimentos/page.tsx @@ -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(null); + const [isFormOpen, setIsFormOpen] = useState(false); + + // Estado para saber qual item será deletado + const [itemToDelete, setItemToDelete] = useState(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 ; + } + + return ( +
+ {/* Cabeçalho */} +
{ handleOpenForm(null) }} + /> + + {/* Tabela de andamentos */} + + + + + + + {/* Modal de confirmação */} + + + {/* Formulário de criação/edição */} + +
+ ); +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_components/g_medidatipo/GMedidaTipoForm.tsx b/src/app/(protected)/(cadastros)/cadastros/_components/g_medidatipo/GMedidaTipoForm.tsx new file mode 100644 index 0000000..46b47a1 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_components/g_medidatipo/GMedidaTipoForm.tsx @@ -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; + +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({ + 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 ( + { + if (!open) onClose(null, false); + }} + > + + + + Tipo de Medida + + + Crie ou edite um tipo de medida + + + +
+ + + {/* Descrição */} + ( + + Descrição + + + + + + )} + /> + + {/* Sigla */} + ( + + Sigla + + + + + + )} + /> + + {/* Rodapé do Dialog */} + + + + + + + + {/* Campo oculto */} + + + +
+
+ ); +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_components/g_medidatipo/GMedidaTipoTable.tsx b/src/app/(protected)/(cadastros)/cadastros/_components/g_medidatipo/GMedidaTipoTable.tsx new file mode 100644 index 0000000..6005b84 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_components/g_medidatipo/GMedidaTipoTable.tsx @@ -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 ( + + + + # + Descrição + Sigla + Ações + + + + + {data.map((item) => ( + + + {item.medida_tipo_id} + + {item.descricao} + {item.sigla} + + + + + + + + + onEdit(item, true)} + > + + Editar + + + + + onDelete(item, true)} + > + + Remover + + + + + + + ))} + +
+ ); +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_components/g_tb_bairro/GTBBairroForm.tsx b/src/app/(protected)/(cadastros)/cadastros/_components/g_tb_bairro/GTBBairroForm.tsx new file mode 100644 index 0000000..4e465b4 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_components/g_tb_bairro/GTBBairroForm.tsx @@ -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; + +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({ + 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 ( + { + if (!open) onClose(null, false); + }} + > + + + + Bairro + + + Crie ou edite um bairro + + + +
+ + + {/* Descrição */} + ( + + Descrição + + + + + + )} + /> + + {/* Situação */} + ( +
+ field.onChange(checked ? "A" : "I")} + /> + +
+ )} + /> + + {/* Rodapé do Dialog */} + + + + + {/* Botão de loading */} + + + + {/* Campos ocultos */} + + + + + +
+
+ ); +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_components/g_tb_bairro/GTBBairroTable.tsx b/src/app/(protected)/(cadastros)/cadastros/_components/g_tb_bairro/GTBBairroTable.tsx new file mode 100644 index 0000000..7aeb15c --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_components/g_tb_bairro/GTBBairroTable.tsx @@ -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 ( + + {isActive ? "Ativo" : "Inativo"} + + ); +} + +export default function GTBBairroTable({ + data, + onEdit, + onDelete +}: GTBBairroTableProps) { + return ( + + + + # + Situação + Descrição + Ações + + + + + {data.map((item) => ( + + + {item.tb_bairro_id} + + + + + + + {item.descricao} + + + + + + + + + + onEdit(item, true)} + > + + Editar + + + + + onDelete(item, true)} + > + + Remover + + + + + + + ))} + +
+ ); +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_components/g_tb_estadocivil/GTBEstadoCivilForm.tsx b/src/app/(protected)/(cadastros)/cadastros/_components/g_tb_estadocivil/GTBEstadoCivilForm.tsx new file mode 100644 index 0000000..6e94347 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_components/g_tb_estadocivil/GTBEstadoCivilForm.tsx @@ -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; + +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({ + 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 ( + { + if (!open) onClose(null, false); + }} + > + + + + Estado Civil + + + Crie ou edite um estado civil + + + +
+ + + {/* Descrição */} + ( + + Descrição + + + + + + )} + /> + + {/* Situação */} + ( +
+ field.onChange(checked ? "A" : "I")} + /> + +
+ )} + /> + + {/* Rodapé do Dialog */} + + + + + + + + {/* Campos ocultos */} + + + + +
+
+ ); +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_components/g_tb_estadocivil/GTBEstadoCivilTable.tsx b/src/app/(protected)/(cadastros)/cadastros/_components/g_tb_estadocivil/GTBEstadoCivilTable.tsx new file mode 100644 index 0000000..1f3ba22 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_components/g_tb_estadocivil/GTBEstadoCivilTable.tsx @@ -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 ( + + {isActive ? "Ativo" : "Inativo"} + + ); +} + +export default function GTBEstadoCivilTable({ + data, + onEdit, + onDelete +}: TBEstadoCivilTableProps) { + return ( + + + + # + Situação + Descrição + Ações + + + + + {data.map((item) => ( + + + {item.tb_estadocivil_id} + + + + + + + {item.descricao} + + + + + + + + + + onEdit(item, true)} + > + + Editar + + + + + onDelete(item, true)} + > + + Remover + + + + + + + ))} + +
+ ); +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_components/g_tb_profissao/GTBProfissaoForm.tsx b/src/app/(protected)/(cadastros)/cadastros/_components/g_tb_profissao/GTBProfissaoForm.tsx new file mode 100644 index 0000000..ec7d5d1 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_components/g_tb_profissao/GTBProfissaoForm.tsx @@ -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; + +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({ + 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 ( + { + if (!open) onClose(null, false); + }} + > + + + + + Profissões + + + Controle de profissões + + + +
+ + + {/* Descrição */} + ( + + Descrição + + + + + + )} + /> + + {/* CBO */} + ( + + CBO + + + + + + )} + /> + + {/* Situação */} + ( +
+ field.onChange(checked ? "A" : "I")} + /> + +
+ )} + /> + + {/* Rodapé do Dialog */} + + + + + + + + {/* Campo oculto */} + + + +
+
+ ); +} diff --git a/src/app/(protected)/(cadastros)/cadastros/_components/g_tb_profissao/GTBProfissaoTable.tsx b/src/app/(protected)/(cadastros)/cadastros/_components/g_tb_profissao/GTBProfissaoTable.tsx new file mode 100644 index 0000000..295a003 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_components/g_tb_profissao/GTBProfissaoTable.tsx @@ -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 ( + + {isActive ? "Ativo" : "Inativo"} + + ); +} + +export default function GTBProfissaoTable({ + data, + onEdit, + onDelete +}: GTBProfissaoTableProps) { + return ( + + + + # + Situação + CBO + Descrição + Ações + + + + + {data.map((item) => ( + + + {item.tb_profissao_id} + + + + + + + + {item.cod_cbo} + + + {item.descricao} + + + + + + + + + + onEdit(item, true)} + > + + Editar + + + + + onDelete(item, true)} + > + + Remover + + + + + + + ))} + +
+ ); +} diff --git a/src/app/(protected)/(cadastros)/cadastros/_components/g_tb_regimebens/GTBRegimeBensForm.tsx b/src/app/(protected)/(cadastros)/cadastros/_components/g_tb_regimebens/GTBRegimeBensForm.tsx new file mode 100644 index 0000000..e535fd8 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_components/g_tb_regimebens/GTBRegimeBensForm.tsx @@ -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; + +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({ + 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 ( + { + if (!open) onClose(null, false); + }} + > + + + + Regimes de Bens + + + Controle de Regimes de Vens + + + +
+ + + {/* Descrição */} + ( + + Descrição + + + + + + )} + /> + + {/* Situação */} + ( +
+ field.onChange(checked ? "A" : "I")} + /> + +
+ )} + /> + + {/* Rodapé do Dialog */} + + + + + + + + {/* Campo oculto */} + + + +
+
+ ); +} diff --git a/src/app/(protected)/(cadastros)/cadastros/_components/g_tb_regimebens/GTBRegimeBensTable.tsx b/src/app/(protected)/(cadastros)/cadastros/_components/g_tb_regimebens/GTBRegimeBensTable.tsx new file mode 100644 index 0000000..364df88 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_components/g_tb_regimebens/GTBRegimeBensTable.tsx @@ -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 ( + + {isActive ? "Ativo" : "Inativo"} + + ); +} + +export default function GTBRegimeBensTable({ + data, + onEdit, + onDelete +}: GTBRegimeBensTableProps) { + return ( + + + + # + Situação + Descrição + Ações + + + + + {data.map((item) => ( + + + {item.tb_regimebens_id} + + + + + + + + {item.descricao} + + + + + + + + + + + onEdit(item, true)} + > + + Editar + + + + + onDelete(item, true)} + > + + Remover + + + + + + + ))} + +
+ ); +} diff --git a/src/app/(protected)/(cadastros)/cadastros/_components/g_tb_regimecomunhao/GTBRegimeComunhaoForm.tsx b/src/app/(protected)/(cadastros)/cadastros/_components/g_tb_regimecomunhao/GTBRegimeComunhaoForm.tsx new file mode 100644 index 0000000..9a8dc1f --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_components/g_tb_regimecomunhao/GTBRegimeComunhaoForm.tsx @@ -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; + +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({ + 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 ( + { + if (!open) onClose(null, false); + }} + > + + + + Regimes de Comunhão + + + Controle de Regimes de Comunhão + + + +
+ + + {/* Descrição */} + ( + + Descrição + + + + + + )} + /> + + {/* Texto */} + ( + + Texto + + + + + + )} + /> + + {/* Tipo */} + ( + + Tipo + + + + )} + /> + + {/* Situação */} + ( +
+ field.onChange(checked ? "A" : "I")} + /> + +
+ )} + /> + + {/* Rodapé do Dialog */} + + + + + + + + {/* Campo oculto */} + + + +
+
+ ); +} diff --git a/src/app/(protected)/(cadastros)/cadastros/_components/g_tb_regimecomunhao/GTBRegimeComunhaoTable.tsx b/src/app/(protected)/(cadastros)/cadastros/_components/g_tb_regimecomunhao/GTBRegimeComunhaoTable.tsx new file mode 100644 index 0000000..704c6d1 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_components/g_tb_regimecomunhao/GTBRegimeComunhaoTable.tsx @@ -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 ( + + {isActive ? "Ativo" : "Inativo"} + + ); +} + +export default function GTBRegimeComunhaoTable({ + data, + onEdit, + onDelete +}: GTBRegimeComunhaoTableProps) { + return ( + + + + # + Situação + Descrição + Ações + + + + + {data.map((item) => ( + + + {item.tb_regimecomunhao_id} + + + + + + + + {item.descricao} + + + + + + + + + + + onEdit(item, true)} + > + + Editar + + + + + onDelete(item, true)} + > + + Remover + + + + + + + ))} + +
+ ); +} diff --git a/src/app/(protected)/(cadastros)/cadastros/_components/g_tb_tipologradouro/GTBTipoLogradouroForm.tsx b/src/app/(protected)/(cadastros)/cadastros/_components/g_tb_tipologradouro/GTBTipoLogradouroForm.tsx new file mode 100644 index 0000000..30e26af --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_components/g_tb_tipologradouro/GTBTipoLogradouroForm.tsx @@ -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; + +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({ + 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 ( + { + if (!open) onClose(null, false); + }} + > + + + + Tipo de Logradouro + + + Crie ou edite um tipo de logradouro + + + +
+ + + {/* Descrição */} + ( + + Descrição + + + + + + )} + /> + + {/* ID do tipo logradouro na ONR */} + ( + + ID do tipo logradouro na ONR + + + + + + )} + /> + + {/* Situação */} + ( +
+ field.onChange(checked ? "A" : "I")} + /> + +
+ )} + /> + + {/* Rodapé do Dialog */} + + + + + + + + {/* Campos ocultos */} + + + + + + +
+
+ ); +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_components/g_tb_tipologradouro/GTBTipoLogradouroTable.tsx b/src/app/(protected)/(cadastros)/cadastros/_components/g_tb_tipologradouro/GTBTipoLogradouroTable.tsx new file mode 100644 index 0000000..acadbdc --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_components/g_tb_tipologradouro/GTBTipoLogradouroTable.tsx @@ -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 ( + + {isActive ? "Ativo" : "Inativo"} + + ); +} + +export default function GTBTipoLogradouroTable({ + data, + onEdit, + onDelete +}: GTBTipoLogradouroTableProps) { + return ( + + + + # + Situação + Descrição + Ações + + + + + {data.map((item) => ( + + + {item.tb_tipologradouro_id} + + + + + + + {item.descricao} + + + + + + + + + + onEdit(item, true)} + > + + Editar + + + + + onDelete(item, true)} + > + + Remover + + + + + + + ))} + +
+ ); +} diff --git a/src/app/(protected)/(cadastros)/cadastros/_components/t_censec/TCensecForm.tsx b/src/app/(protected)/(cadastros)/cadastros/_components/t_censec/TCensecForm.tsx new file mode 100644 index 0000000..a5e58fd --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_components/t_censec/TCensecForm.tsx @@ -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; + +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({ + 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 ( + { + if (!open) onClose(null, false); + }} + > + + + + + Censec + + + Tipos de Centrais + + + +
+ + + {/* Descrição */} + ( + + Descrição + + + + + + )} + /> + + {/* Situação */} + ( +
+ field.onChange(checked ? "A" : "I")} + /> + +
+ )} + /> + + {/* Rodapé do Dialog */} + + + + + {/* Botão de loading */} + + + + {/* Campo oculto */} + + + +
+
+ ); +} diff --git a/src/app/(protected)/(cadastros)/cadastros/_components/t_censec/TCensecTable.tsx b/src/app/(protected)/(cadastros)/cadastros/_components/t_censec/TCensecTable.tsx new file mode 100644 index 0000000..37df466 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_components/t_censec/TCensecTable.tsx @@ -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 ( + + {isActive ? "Ativo" : "Inativo"} + + ); +} + +export default function TCensecTable({ + data, + onEdit, + onDelete +}: TCensecTableProps) { + return ( + + + + # + Situação + CBO + Descrição + Ações + + + + + {data.map((item) => ( + + + {item.censec_id} + + + + + + + {item.descricao} + + + + + + + + + + onEdit(item, true)} + > + + Editar + + + + + onDelete(item, true)} + > + + Remover + + + + + + + ))} + +
+ ); +} diff --git a/src/app/(protected)/(cadastros)/cadastros/_components/t_censecnaturezalitigio/TCensecNaturezaLitigioForm.tsx b/src/app/(protected)/(cadastros)/cadastros/_components/t_censecnaturezalitigio/TCensecNaturezaLitigioForm.tsx new file mode 100644 index 0000000..434d9ff --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_components/t_censecnaturezalitigio/TCensecNaturezaLitigioForm.tsx @@ -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; + +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({ + resolver: zodResolver(TCensecNaturezaLitigioSchema), + defaultValues: { + censec_naturezalitigio_id: 0, + descricao: "", + situacao: "A" + } + }); + + useEffect(() => { + if (data) form.reset(data); + }, [data, form]); + + return ( + { + if (!open) onClose(null, false); + }} + > + + + Natureza do Litígio + + Crie ou edite uma natureza do litígio + + + +
+ + + {/* Descrição */} + ( + + Descrição + + + + + + )} + /> + + {/* Situação */} + ( +
+ field.onChange(checked ? "A" : "I")} + /> + +
+ )} + /> + + + {/* Rodapé */} + + + + + + + + {/* Campo oculto */} + + + +
+
+ ); +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_components/t_censecnaturezalitigio/TCensecNaturezaLitigioTable.tsx b/src/app/(protected)/(cadastros)/cadastros/_components/t_censecnaturezalitigio/TCensecNaturezaLitigioTable.tsx new file mode 100644 index 0000000..02f96a5 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_components/t_censecnaturezalitigio/TCensecNaturezaLitigioTable.tsx @@ -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 ( + + {isActive ? "Ativo" : "Inativo"} + + ); +} + +export default function TCensecNaturezaLitigioTable({ + data, + onEdit, + onDelete +}: TCensecNaturezaLitigioTableProps) { + return ( + + + + # + Situação + Descrição + Ações + + + + + {data.map((item) => ( + + + {item.censec_naturezalitigio_id} + + + + + + + {item.descricao} + + + + + + + + + + onEdit(item, true)} + > + + Editar + + + + + onDelete(item, true)} + > + + Remover + + + + + + + ))} + +
+ ); +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_components/t_minuta/TMinutaForm.tsx b/src/app/(protected)/(cadastros)/cadastros/_components/t_minuta/TMinutaForm.tsx new file mode 100644 index 0000000..2a05718 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_components/t_minuta/TMinutaForm.tsx @@ -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; + +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({ + resolver: zodResolver(TMinutaSchema), + defaultValues: { + minuta_id: 0, + natureza_id: undefined, + descricao: '', + situacao: 'A', + texto: '', + } + }); + + useEffect(() => { + if (data) form.reset(data); + }, [data, form]); + + return ( + { + if (!open) onClose(null, false); + }} + > + {/* tamanho maior para comportar o editor */} + + Minuta + + Crie ou edite uma minuta de ato notarial. + + + +
+ + + {/* Descrição */} + ( + + Descrição + + + + + + )} + /> + + {/* Situação */} + ( +
+ field.onChange(checked ? "A" : "I")} + /> + +
+ )} + /> + + {/* Editor de Texto */} + ( +
+ + {form.formState.errors.texto && ( +

+ {form.formState.errors.texto.message} +

+ )} +
+ )} + /> + + {/* Rodapé do Dialog */} + + + + + + + + {/* Campos ocultos */} + + + + + +
+
+ ); +} diff --git a/src/app/(protected)/(cadastros)/cadastros/_components/t_minuta/TMinutaTable.tsx b/src/app/(protected)/(cadastros)/cadastros/_components/t_minuta/TMinutaTable.tsx new file mode 100644 index 0000000..d7fabf9 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_components/t_minuta/TMinutaTable.tsx @@ -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 ( + + {isActive ? "Ativo" : "Inativo"} + + ); +} + +export default function TMinutaTable({ + data, +}: TMinutaTableProps) { + return ( + + + + # + Situação + Descrição + + + + + {data.length === 0 ? ( + + + Nenhuma minuta encontrada. + + + ) : ( + data.map((item) => ( + + + {item.t_minuta_id} + + + + + + + {item.descricao} + + + + + + )) + )} + +
+ ); +} diff --git a/src/app/(protected)/(cadastros)/cadastros/_components/t_tb_andamentoservico/TTBAndamentoServicoForm.tsx b/src/app/(protected)/(cadastros)/cadastros/_components/t_tb_andamentoservico/TTBAndamentoServicoForm.tsx new file mode 100644 index 0000000..6199024 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_components/t_tb_andamentoservico/TTBAndamentoServicoForm.tsx @@ -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; + +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({ + 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 ( + { + if (!open) onClose(null, false); + }} + > + + + + Andamentos + + + Controle de andamentos de atos + + + +
+ + + {/* Descrição */} + ( + + Descrição + + + + + + )} + /> + + {/* Tipo */} + ( + + Tipo + + + + )} + /> + + {/* Situação */} + ( +
+ field.onChange(checked ? "A" : "I")} + /> + +
+ )} + /> + + {/* Usar e-mail */} + ( +
+ field.onChange(checked ? "A" : "I")} + /> + +
+ )} + /> + + {/* Rodapé do Dialog */} + + + + + + + + {/* Campo oculto */} + + + +
+
+ ); +} diff --git a/src/app/(protected)/(cadastros)/cadastros/_components/t_tb_andamentoservico/TTBAndamentoServicoTable.tsx b/src/app/(protected)/(cadastros)/cadastros/_components/t_tb_andamentoservico/TTBAndamentoServicoTable.tsx new file mode 100644 index 0000000..1eada8f --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_components/t_tb_andamentoservico/TTBAndamentoServicoTable.tsx @@ -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 ( + + {isActive ? "Ativo" : "Inativo"} + + ); +} + +export default function TTBAndamentoServicoTable({ + data, + onEdit, + onDelete +}: TTBAndamentoServicoTableProps) { + return ( + + + + # + Situação + Descrição + Ações + + + + + {data.map((item) => ( + + + {item.tb_andamentoservico_id} + + + + + + + {item.descricao} + + + + + + + + + + onEdit(item, true)} + > + + Editar + + + + + onDelete(item, true)} + > + + Remover + + + + + + + ))} + +
+ ); +} diff --git a/src/app/(protected)/(cadastros)/cadastros/_components/t_tb_reconhecimentotipo/TTBReconhecimentoTipoForm.tsx b/src/app/(protected)/(cadastros)/cadastros/_components/t_tb_reconhecimentotipo/TTBReconhecimentoTipoForm.tsx new file mode 100644 index 0000000..83df3c3 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_components/t_tb_reconhecimentotipo/TTBReconhecimentoTipoForm.tsx @@ -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; + +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({ + 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 ( + { + if (!open) onClose(null, false); + }} + > + + + + Reconhecimentos + + + Tipos de Reconhecimentos + + + +
+ + + {/* Descrição */} + ( + + Descrição + + + + + + )} + /> + + {/* Situação */} + ( +
+ field.onChange(checked ? "A" : "I")} + /> + +
+ )} + /> + + {/* Rodapé do Dialog */} + + + + + + + + {/* Campo oculto */} + + + +
+
+ ); +} diff --git a/src/app/(protected)/(cadastros)/cadastros/_components/t_tb_reconhecimentotipo/TTBReconhecimentoTipoTable.tsx b/src/app/(protected)/(cadastros)/cadastros/_components/t_tb_reconhecimentotipo/TTBReconhecimentoTipoTable.tsx new file mode 100644 index 0000000..d8e1087 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_components/t_tb_reconhecimentotipo/TTBReconhecimentoTipoTable.tsx @@ -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 ( + + {isActive ? "Ativo" : "Inativo"} + + ); +} + +export default function TTBReconhecimentoTipoTable({ + data, + onEdit, + onDelete +}: TTBReconhecimentoTipoTableProps) { + return ( + + + + # + Situação + Descrição + Ações + + + + + {data.map((item) => ( + + + {item.tb_reconhecimentotipo_id} + + + + + + + {item.descricao} + + + + + + + + + + onEdit(item, true)} + > + + Editar + + + + + onDelete(item, true)} + > + + Remover + + + + + + + ))} + +
+ ); +} diff --git a/src/app/(protected)/(cadastros)/cadastros/_data/GMedidoTipo/GMedidaTipoIndexData.ts b/src/app/(protected)/(cadastros)/cadastros/_data/GMedidoTipo/GMedidaTipoIndexData.ts new file mode 100644 index 0000000..7767d4c --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_data/GMedidoTipo/GMedidaTipoIndexData.ts @@ -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 + } + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_data/GMedidoTipo/GMedidaTipoRemoveData.ts b/src/app/(protected)/(cadastros)/cadastros/_data/GMedidoTipo/GMedidaTipoRemoveData.ts new file mode 100644 index 0000000..7e7f4d3 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_data/GMedidoTipo/GMedidaTipoRemoveData.ts @@ -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}` + }); + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_data/GMedidoTipo/GMedidaTipoSaveData.ts b/src/app/(protected)/(cadastros)/cadastros/_data/GMedidoTipo/GMedidaTipoSaveData.ts new file mode 100644 index 0000000..deff26e --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_data/GMedidoTipo/GMedidaTipoSaveData.ts @@ -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 + }); + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_data/GMedidoTipo/mockMedidaTipo.ts b/src/app/(protected)/(cadastros)/cadastros/_data/GMedidoTipo/mockMedidaTipo.ts new file mode 100644 index 0000000..ae1eabf --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_data/GMedidoTipo/mockMedidaTipo.ts @@ -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" + } + ] + }); +} diff --git a/src/app/(protected)/(cadastros)/cadastros/_data/GTBBairro/GTBBairroIndexData.ts b/src/app/(protected)/(cadastros)/cadastros/_data/GTBBairro/GTBBairroIndexData.ts new file mode 100644 index 0000000..5506807 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_data/GTBBairro/GTBBairroIndexData.ts @@ -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 + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_data/GTBBairro/GTBBairroRemoveData.ts b/src/app/(protected)/(cadastros)/cadastros/_data/GTBBairro/GTBBairroRemoveData.ts new file mode 100644 index 0000000..58c0100 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_data/GTBBairro/GTBBairroRemoveData.ts @@ -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}` + }); + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_data/GTBBairro/GTBBairroSaveData.ts b/src/app/(protected)/(cadastros)/cadastros/_data/GTBBairro/GTBBairroSaveData.ts new file mode 100644 index 0000000..4951bb3 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_data/GTBBairro/GTBBairroSaveData.ts @@ -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 + }); + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_data/GTBBairro/mockBairro.ts b/src/app/(protected)/(cadastros)/cadastros/_data/GTBBairro/mockBairro.ts new file mode 100644 index 0000000..e19feed --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_data/GTBBairro/mockBairro.ts @@ -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" + } + ] + }); +} diff --git a/src/app/(protected)/(cadastros)/cadastros/_data/GTBEstadoCivil/GTBEstadoCivilIndexData.ts b/src/app/(protected)/(cadastros)/cadastros/_data/GTBEstadoCivil/GTBEstadoCivilIndexData.ts new file mode 100644 index 0000000..efa8787 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_data/GTBEstadoCivil/GTBEstadoCivilIndexData.ts @@ -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 + } + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_data/GTBEstadoCivil/GTBEstadoCivilRemoveData.ts b/src/app/(protected)/(cadastros)/cadastros/_data/GTBEstadoCivil/GTBEstadoCivilRemoveData.ts new file mode 100644 index 0000000..306b3c4 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_data/GTBEstadoCivil/GTBEstadoCivilRemoveData.ts @@ -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}` + }); + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_data/GTBEstadoCivil/GTBEstadoCivilSaveData.ts b/src/app/(protected)/(cadastros)/cadastros/_data/GTBEstadoCivil/GTBEstadoCivilSaveData.ts new file mode 100644 index 0000000..da800a6 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_data/GTBEstadoCivil/GTBEstadoCivilSaveData.ts @@ -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 + }); + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_data/GTBEstadoCivil/mockEstadoCivil.ts b/src/app/(protected)/(cadastros)/cadastros/_data/GTBEstadoCivil/mockEstadoCivil.ts new file mode 100644 index 0000000..04e8155 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_data/GTBEstadoCivil/mockEstadoCivil.ts @@ -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", + } + ] + }); +} diff --git a/src/app/(protected)/(cadastros)/cadastros/_data/GTBProfissao/GTBProfissaoIndexData.ts b/src/app/(protected)/(cadastros)/cadastros/_data/GTBProfissao/GTBProfissaoIndexData.ts new file mode 100644 index 0000000..b1fa9f0 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_data/GTBProfissao/GTBProfissaoIndexData.ts @@ -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/` + }); +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_data/GTBProfissao/GTBProfissaoRemoveData.ts b/src/app/(protected)/(cadastros)/cadastros/_data/GTBProfissao/GTBProfissaoRemoveData.ts new file mode 100644 index 0000000..61f3064 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_data/GTBProfissao/GTBProfissaoRemoveData.ts @@ -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}` + }); + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_data/GTBProfissao/GTBProfissaoSaveData.ts b/src/app/(protected)/(cadastros)/cadastros/_data/GTBProfissao/GTBProfissaoSaveData.ts new file mode 100644 index 0000000..de65818 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_data/GTBProfissao/GTBProfissaoSaveData.ts @@ -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 + }); + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_data/GTBRegimeBens/GTBRegimeBensIndexData.ts b/src/app/(protected)/(cadastros)/cadastros/_data/GTBRegimeBens/GTBRegimeBensIndexData.ts new file mode 100644 index 0000000..c7dda24 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_data/GTBRegimeBens/GTBRegimeBensIndexData.ts @@ -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/` + }); + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_data/GTBRegimeBens/GTBRegimeBensRemoveData.ts b/src/app/(protected)/(cadastros)/cadastros/_data/GTBRegimeBens/GTBRegimeBensRemoveData.ts new file mode 100644 index 0000000..ebbb985 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_data/GTBRegimeBens/GTBRegimeBensRemoveData.ts @@ -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}` + }); + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_data/GTBRegimeBens/GTBRegimeBensSaveData.ts b/src/app/(protected)/(cadastros)/cadastros/_data/GTBRegimeBens/GTBRegimeBensSaveData.ts new file mode 100644 index 0000000..b469f5b --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_data/GTBRegimeBens/GTBRegimeBensSaveData.ts @@ -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); \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_data/GTBTipoLogradouro/GTBTipoLogradouroIndexData.ts b/src/app/(protected)/(cadastros)/cadastros/_data/GTBTipoLogradouro/GTBTipoLogradouroIndexData.ts new file mode 100644 index 0000000..a9fa5ae --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_data/GTBTipoLogradouro/GTBTipoLogradouroIndexData.ts @@ -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 + } + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_data/GTBTipoLogradouro/GTBTipoLogradouroRemoveData.ts b/src/app/(protected)/(cadastros)/cadastros/_data/GTBTipoLogradouro/GTBTipoLogradouroRemoveData.ts new file mode 100644 index 0000000..9a1799e --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_data/GTBTipoLogradouro/GTBTipoLogradouroRemoveData.ts @@ -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}` + }); + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_data/GTBTipoLogradouro/GTBTipoLogradouroSaveData.ts b/src/app/(protected)/(cadastros)/cadastros/_data/GTBTipoLogradouro/GTBTipoLogradouroSaveData.ts new file mode 100644 index 0000000..5508890 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_data/GTBTipoLogradouro/GTBTipoLogradouroSaveData.ts @@ -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 + }); + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_data/GTBTipoLogradouro/mockTipoLogradouro.ts b/src/app/(protected)/(cadastros)/cadastros/_data/GTBTipoLogradouro/mockTipoLogradouro.ts new file mode 100644 index 0000000..d0ea84a --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_data/GTBTipoLogradouro/mockTipoLogradouro.ts @@ -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 + } + ] + }); +} diff --git a/src/app/(protected)/(cadastros)/cadastros/_data/GTRegimeComunhao/GTBRegimeComunhaoIndexData.ts b/src/app/(protected)/(cadastros)/cadastros/_data/GTRegimeComunhao/GTBRegimeComunhaoIndexData.ts new file mode 100644 index 0000000..4dd3d24 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_data/GTRegimeComunhao/GTBRegimeComunhaoIndexData.ts @@ -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/` + }); + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_data/GTRegimeComunhao/GTBRegimeComunhaoRemoveData.ts b/src/app/(protected)/(cadastros)/cadastros/_data/GTRegimeComunhao/GTBRegimeComunhaoRemoveData.ts new file mode 100644 index 0000000..c92cb66 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_data/GTRegimeComunhao/GTBRegimeComunhaoRemoveData.ts @@ -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}` + }); + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_data/GTRegimeComunhao/GTBRegimeComunhaoSaveData.ts b/src/app/(protected)/(cadastros)/cadastros/_data/GTRegimeComunhao/GTBRegimeComunhaoSaveData.ts new file mode 100644 index 0000000..51cf575 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_data/GTRegimeComunhao/GTBRegimeComunhaoSaveData.ts @@ -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 + }); +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_data/TCensec/TCensecDeleteData.ts b/src/app/(protected)/(cadastros)/cadastros/_data/TCensec/TCensecDeleteData.ts new file mode 100644 index 0000000..0a0dffe --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_data/TCensec/TCensecDeleteData.ts @@ -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); \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_data/TCensec/TCensecIndexData.ts b/src/app/(protected)/(cadastros)/cadastros/_data/TCensec/TCensecIndexData.ts new file mode 100644 index 0000000..d8a5896 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_data/TCensec/TCensecIndexData.ts @@ -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); \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_data/TCensec/TCensecSaveData.ts b/src/app/(protected)/(cadastros)/cadastros/_data/TCensec/TCensecSaveData.ts new file mode 100644 index 0000000..49804e5 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_data/TCensec/TCensecSaveData.ts @@ -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); \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_data/TCensecNaturezaLitigio/TCensecNaturezaLitigioIndexData.ts b/src/app/(protected)/(cadastros)/cadastros/_data/TCensecNaturezaLitigio/TCensecNaturezaLitigioIndexData.ts new file mode 100644 index 0000000..806f75f --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_data/TCensecNaturezaLitigio/TCensecNaturezaLitigioIndexData.ts @@ -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 + } + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_data/TCensecNaturezaLitigio/TCensecNaturezaLitigioRemoveData.ts b/src/app/(protected)/(cadastros)/cadastros/_data/TCensecNaturezaLitigio/TCensecNaturezaLitigioRemoveData.ts new file mode 100644 index 0000000..c12b863 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_data/TCensecNaturezaLitigio/TCensecNaturezaLitigioRemoveData.ts @@ -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}` + }); + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_data/TCensecNaturezaLitigio/TCensecNaturezaLitigioSaveData.ts b/src/app/(protected)/(cadastros)/cadastros/_data/TCensecNaturezaLitigio/TCensecNaturezaLitigioSaveData.ts new file mode 100644 index 0000000..8e2688b --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_data/TCensecNaturezaLitigio/TCensecNaturezaLitigioSaveData.ts @@ -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 + }); + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_data/TCensecNaturezaLitigio/mockCensecNaturezaLitigio.ts b/src/app/(protected)/(cadastros)/cadastros/_data/TCensecNaturezaLitigio/mockCensecNaturezaLitigio.ts new file mode 100644 index 0000000..ed360af --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_data/TCensecNaturezaLitigio/mockCensecNaturezaLitigio.ts @@ -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" + } +] + }); +} diff --git a/src/app/(protected)/(cadastros)/cadastros/_data/TMinuta/MinutaTexto.ts b/src/app/(protected)/(cadastros)/cadastros/_data/TMinuta/MinutaTexto.ts new file mode 100644 index 0000000..24e851f --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_data/TMinuta/MinutaTexto.ts @@ -0,0 +1,81 @@ +export const textoEscrituraCompraEVenda = ` +

ESCRITURA PÚBLICA DE COMPRA E VENDA

+ +

Saibam quantos este público instrumento virem que, aos [[dia]] dias do mês de [[mes]] do ano de [[ano]], nesta cidade de [[cidade]], Estado de [[estado]], neste Tabelionato de Notas, perante mim, [[tabeliao]], Tabelião de Notas, compareceram como partes entre si, de um lado como VENDEDOR(ES):

+ +

[[nome_completo_vendedor]], [[nacionalidade_vendedor]], [[estado_civil_vendedor]], [[profissao_vendedor]], portador da cédula de identidade RG nº [[rg_vendedor]] e inscrito no CPF/MF sob o nº [[cpf_vendedor]], residente e domiciliado à [[endereco_vendedor]];

+ +

E de outro lado como COMPRADOR(ES):

+ +

[[nome_completo_comprador]], [[nacionalidade_comprador]], [[estado_civil_comprador]], [[profissao_comprador]], portador da cédula de identidade RG nº [[rg_comprador]] e inscrito no CPF/MF sob o nº [[cpf_comprador]], residente e domiciliado à [[endereco_comprador]];

+ +

Entre as partes acima identificadas e qualificadas, justas e contratadas, foi ajustada, e por este público instrumento, lavrado na forma da lei, têm como certo e contratado a presente ESCRITURA PÚBLICA DE COMPRA E VENDA do imóvel situado à [[endereco_imovel]], com área de [[area_imovel]]m², registrado sob matrícula nº [[matricula_imovel]], no [[cartorio_registro]] Registro de Imóveis desta cidade.

+ +

O preço certo e ajustado para a presente transação é de R$ [[valor_venda]] ([[valor_extenso]]), que o(s) comprador(es) declara(m) ter pago ao(s) vendedor(es), neste ato, em moeda corrente nacional, dando-lhe(s) plena, geral e irrevogável quitação.

+ +

Assim, justos e contratados, requerem seja lavrada a presente escritura, que lida e achada conforme, vai assinada pelas partes e por mim, [[tabeliao]], que a subscrevo.

+ +

Dou fé.

+`; + +export const textoEscrituraPartilhaAmigavel = ` +

ESCRITURA PÚBLICA DE PARTILHA AMIGÁVEL

+ +

Saibam quantos este público instrumento virem que, aos [[dia]] dias do mês de [[mes]] do ano de [[ano]], nesta cidade de [[cidade]], Estado de [[estado]], neste Tabelionato de Notas, perante mim, [[tabeliao]], Tabelião de Notas, compareceram como partes entre si, de um lado como HERDEIROS(AS):

+ +

[[nome_herdeiro_1]], [[nacionalidade_herdeiro_1]], [[estado_civil_herdeiro_1]], [[profissao_herdeiro_1]], portador(a) do RG nº [[rg_herdeiro_1]] e CPF nº [[cpf_herdeiro_1]], residente e domiciliado(a) à [[endereco_herdeiro_1]];

+ +

[[nome_herdeiro_2]], [[nacionalidade_herdeiro_2]], [[estado_civil_herdeiro_2]], [[profissao_herdeiro_2]], portador(a) do RG nº [[rg_herdeiro_2]] e CPF nº [[cpf_herdeiro_2]], residente e domiciliado(a) à [[endereco_herdeiro_2]];

+ +

e assim por diante, se houver outros herdeiros.

+ +

Declararam os presentes que são únicos e legítimos herdeiros do(a) falecido(a) [[nome_falecido]], falecido(a) em [[data_obito]], na cidade de [[cidade_obito]], conforme certidão de óbito lavrada sob o nº [[numero_certidao_obito]], e que, por meio desta escritura, realizam entre si a PARTILHA AMIGÁVEL dos bens deixados pelo(a) de cujus, na forma seguinte:

+ +

Relação dos bens:

+ +
    +
  • [[descricao_bem_1]] - avaliado em R$ [[valor_bem_1]];
  • +
  • [[descricao_bem_2]] - avaliado em R$ [[valor_bem_2]];
  • +
  • ... (outros bens, se houver)
  • +
+ +

Partilha:

+ +
    +
  • Ao(à) herdeiro(a) [[nome_herdeiro_1]] caberá o(s) bem(ns): [[bens_herdeiro_1]];
  • +
  • Ao(à) herdeiro(a) [[nome_herdeiro_2]] caberá o(s) bem(ns): [[bens_herdeiro_2]];
  • +
  • ... (demais partilhas, se houver)
  • +
+ +

As partes declaram que a partilha foi realizada de comum acordo, de forma livre e consciente, não havendo vícios de consentimento, nem litígios entre os herdeiros.

+ +

Requerem que esta escritura seja registrada onde necessário, e produza todos os efeitos legais.

+ +

E por estarem assim justos e contratados, firmam o presente instrumento, que lido e achado conforme, vai por todos assinado e por mim, [[tabeliao]], que o lavrei e subscrevo.

+ +

Dou fé.

+`; + +export const textoProcuracaoAdJudicia = ` +

PROCURAÇÃO AD JUDICIA

+ +

Outorgante: [[nome_outorgante]], [[nacionalidade_outorgante]], [[estado_civil_outorgante]], [[profissao_outorgante]], portador(a) do RG nº [[rg_outorgante]] e CPF nº [[cpf_outorgante]], residente e domiciliado(a) à [[endereco_outorgante]].

+ +

Outorgado: [[nome_outorgado]], advogado inscrito na OAB/[[uf_oab]] sob o nº [[numero_oab]], com escritório profissional situado à [[endereco_escritorio]].

+ +

Por este instrumento particular, o outorgante nomeia e constitui seu bastante procurador o(a) outorgado(a), para o foro em geral, com poderes para o ajuizamento, defesa, acompanhamento, transação, conciliação, desistência, interposição e recebimento de recursos, substabelecer no todo ou em parte, e praticar todos os demais atos necessários ao fiel cumprimento deste mandato, especialmente para atuar em processos judiciais e administrativos, em todas as instâncias e tribunais, federais ou estaduais, inclusive para firmar compromisso, receber citações, intimações e notificações, assinar petições, requerimentos e demais documentos, e praticar todos os atos necessários para a defesa dos direitos do outorgante.

+ +

Esta procuração é válida por [[validade]] meses a contar da data de sua assinatura.

+ +

E, por assim estar justo e acordado, firma o presente instrumento em [[cidade]], aos [[dia]] dias do mês de [[mes]] do ano de [[ano]].

+ +

_______________________________

+

[[nome_outorgante]]

+ +

Testemunhas:

+

1. ___________________________

+

Nome: [[nome_testemunha_1]] - CPF: [[cpf_testemunha_1]]

+ +

2. ___________________________

+

Nome: [[nome_testemunha_2]] - CPF: [[cpf_testemunha_2]]

+`; diff --git a/src/app/(protected)/(cadastros)/cadastros/_data/TMinuta/TMinutaIndex.ts b/src/app/(protected)/(cadastros)/cadastros/_data/TMinuta/TMinutaIndex.ts new file mode 100644 index 0000000..943191c --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_data/TMinuta/TMinutaIndex.ts @@ -0,0 +1,24 @@ +import API from "@/services/api/Api"; +import { Methods } from "@/services/api/enums/ApiMethodEnum"; +import { MinutaMockDeDadosPorId } from "./mockMinuta"; + +const useMock = true; + +export default async function TMinutaIndex(t_minuta_id: number) { + if (useMock) { + console.log(await MinutaMockDeDadosPorId(t_minuta_id)); // Retorna o dado específico do mock + return await MinutaMockDeDadosPorId(t_minuta_id); // Retorna o dado específico do mock + } + + const api = new API(); + try { + const dados = await api.send({ + method: Methods.GET, + endpoint: `administrativo/t_minuta/${t_minuta_id}` + }); + return dados; + } catch (error) { + console.log(error); + return error; + } +} diff --git a/src/app/(protected)/(cadastros)/cadastros/_data/TMinuta/TMinutaIndexData.ts b/src/app/(protected)/(cadastros)/cadastros/_data/TMinuta/TMinutaIndexData.ts new file mode 100644 index 0000000..41908ad --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_data/TMinuta/TMinutaIndexData.ts @@ -0,0 +1,23 @@ +import API from "@/services/api/Api"; +import { Methods } from "@/services/api/enums/ApiMethodEnum"; +import MinutaMockDeDados from "./mockMinuta"; + +const useMock = true; + +export default async function TMinutaIndexData() { + if (useMock) { + return await MinutaMockDeDados(); // Retorna todos os dados mockados + } + + const api = new API(); + try { + const dados = await api.send({ + method: Methods.GET, + endpoint: `administrativo/t_minuta/` + }); + return dados; + } catch (error) { + console.log(error); + return error; + } +} diff --git a/src/app/(protected)/(cadastros)/cadastros/_data/TMinuta/TMinutaRemoveData.ts b/src/app/(protected)/(cadastros)/cadastros/_data/TMinuta/TMinutaRemoveData.ts new file mode 100644 index 0000000..8870452 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_data/TMinuta/TMinutaRemoveData.ts @@ -0,0 +1,14 @@ +import API from "@/services/api/Api"; +import { TMinutaInterface } from "../../_interfaces/TMinutaInterface"; +import { Methods } from "@/services/api/enums/ApiMethodEnum"; + +export default async function TMinutaRemoveData(data: TMinutaInterface) { + + const api = new API(); + + return await api.send({ + method: Methods.DELETE, + endpoint: `administrativo/t_minuta/${data.t_minuta_id}` + }); + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_data/TMinuta/TMinutaSaveData.ts b/src/app/(protected)/(cadastros)/cadastros/_data/TMinuta/TMinutaSaveData.ts new file mode 100644 index 0000000..c75171b --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_data/TMinuta/TMinutaSaveData.ts @@ -0,0 +1,17 @@ +import API from "@/services/api/Api"; +import { TMinutaInterface } from "../../_interfaces/TMinutaInterface"; +import { Methods } from "@/services/api/enums/ApiMethodEnum"; + +export default async function TMinutaSaveData(data: TMinutaInterface) { + + const isUpdate = Boolean(data.t_minuta_id); + + const api = new API(); + + return await api.send({ + method: isUpdate ? Methods.PUT : Methods.POST, + endpoint: `administrativo/t_minuta/${data.t_minuta_id || ''}`, + body: data + }); + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_data/TMinuta/mockMinuta.ts b/src/app/(protected)/(cadastros)/cadastros/_data/TMinuta/mockMinuta.ts new file mode 100644 index 0000000..88ae986 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_data/TMinuta/mockMinuta.ts @@ -0,0 +1,41 @@ +// Função para pegar todos os dados (usada em TMinutaIndexData) +import { textoEscrituraCompraEVenda, textoEscrituraPartilhaAmigavel, textoProcuracaoAdJudicia } from "./MinutaTexto"; + +export default async function MinutaMockDeDados() { + return Promise.resolve({ + status: 200, + message: 'Dados localizados', + data: [ + { + t_minuta_id: 1, + natureza_id: 1, + descricao: 'Escritura de Compra e Venda', + situacao: 'A', + texto: textoEscrituraCompraEVenda, + }, + { + t_minuta_id: 2, + natureza_id: 1, + descricao: 'Escritura de Partilha Amigável', + situacao: 'A', + texto: textoEscrituraPartilhaAmigavel, + }, + { + t_minuta_id: 3, + natureza_id: 2, + descricao: 'Procuração Ad Judicia', + situacao: 'A', + texto: textoProcuracaoAdJudicia, + }, + ] + }); +} + +export async function MinutaMockDeDadosPorId(t_minuta_id: number) { + const allData = await MinutaMockDeDados(); + return Promise.resolve({ + status: 200, + message: 'Dados localizados', + data: allData.data.find((item) => item.t_minuta_id === t_minuta_id) || null + }); +} diff --git a/src/app/(protected)/(cadastros)/cadastros/_data/TTBAndamentoServico/TTBAndamentoServicoIndexData.ts b/src/app/(protected)/(cadastros)/cadastros/_data/TTBAndamentoServico/TTBAndamentoServicoIndexData.ts new file mode 100644 index 0000000..3865338 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_data/TTBAndamentoServico/TTBAndamentoServicoIndexData.ts @@ -0,0 +1,17 @@ +'use server' + +import API from "@/services/api/Api"; +import { Methods } from "@/services/api/enums/ApiMethodEnum"; + +export default async function TTBAndamentoServicoIndexData() { + + const api = new API(); + + const response = await api.send({ + 'method': Methods.GET, + 'endpoint': `administrativo/t_tb_andamentoservico/` + }); + + return response; + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_data/TTBAndamentoServico/TTBAndamentoServicoRemoveData.ts b/src/app/(protected)/(cadastros)/cadastros/_data/TTBAndamentoServico/TTBAndamentoServicoRemoveData.ts new file mode 100644 index 0000000..5ad8fc9 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_data/TTBAndamentoServico/TTBAndamentoServicoRemoveData.ts @@ -0,0 +1,18 @@ +'use server' + +import API from "@/services/api/Api"; +import TTBAndamentoServicoInteface from "../../_interfaces/TTBAndamentoServicoInterface"; +import { Methods } from "@/services/api/enums/ApiMethodEnum"; + +export default async function TTBAndamentoServicoRemoveData(tTBAndamentoServico: TTBAndamentoServicoInteface) { + + const api = new API(); + + const response = await api.send({ + method: Methods.DELETE, + endpoint: `administrativo/t_tb_andamentoservico/${tTBAndamentoServico.tb_andamentoservico_id}` + }); + + return response; + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_data/TTBAndamentoServico/TTBAndamentoServicoSaveData.ts b/src/app/(protected)/(cadastros)/cadastros/_data/TTBAndamentoServico/TTBAndamentoServicoSaveData.ts new file mode 100644 index 0000000..589ec9b --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_data/TTBAndamentoServico/TTBAndamentoServicoSaveData.ts @@ -0,0 +1,23 @@ +'use server' + +import API from "@/services/api/Api"; +import TTBAndamentoServicoInteface from "../../_interfaces/TTBAndamentoServicoInterface"; +import { Methods } from "@/services/api/enums/ApiMethodEnum"; +import { withClientErrorHandler } from "@/actions/withClientErrorHandler/withClientErrorHandler"; + +async function executeTTBAndamentoServicoSaveData(data: TTBAndamentoServicoInteface) { + + const api = new API(); + + const response = await api.send({ + method: data.tb_andamentoservico_id ? Methods.PUT : Methods.POST, + endpoint: `administrativo/t_tb_andamentoservico/${data.tb_andamentoservico_id ? data.tb_andamentoservico_id : ''}`, + body: data + }); + + return response; + +} + +// Encapsula a execução da função +export const TTBAndamentoServicoSaveData = withClientErrorHandler(executeTTBAndamentoServicoSaveData); \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_data/TTBReconhecimentoTipo/TTBReconhecimentoTipoDeleteData.ts b/src/app/(protected)/(cadastros)/cadastros/_data/TTBReconhecimentoTipo/TTBReconhecimentoTipoDeleteData.ts new file mode 100644 index 0000000..5f279f9 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_data/TTBReconhecimentoTipo/TTBReconhecimentoTipoDeleteData.ts @@ -0,0 +1,16 @@ +import API from "@/services/api/Api"; +import TTBReconhecimentoTipoInterface from "../../_interfaces/TTBReconhecimentoTipoInterface"; +import { Methods } from "@/services/api/enums/ApiMethodEnum"; + +export default async function TTBReconhecimentoTipoDeleteData(data: TTBReconhecimentoTipoInterface) { + + const api = new API(); + + const response = await api.send({ + method: Methods.DELETE, + endpoint: `administrativo/t_tb_reconhecimentotipo/${data.tb_reconhecimentotipo_id}` + }); + + return response; + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_data/TTBReconhecimentoTipo/TTBReconhecimentoTipoIndexData.ts b/src/app/(protected)/(cadastros)/cadastros/_data/TTBReconhecimentoTipo/TTBReconhecimentoTipoIndexData.ts new file mode 100644 index 0000000..7d7995e --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_data/TTBReconhecimentoTipo/TTBReconhecimentoTipoIndexData.ts @@ -0,0 +1,17 @@ +'use server' + +import API from "@/services/api/Api" +import { Methods } from "@/services/api/enums/ApiMethodEnum"; + +export default async function TTBReconhecimentoTipoIndexData() { + + const api = new API(); + + const response = await api.send({ + method: Methods.GET, + endpoint: `administrativo/t_tb_reconhecimentotipo` + }); + + return response; + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_data/TTBReconhecimentoTipo/TTBReconhecimentoTipoSaveData.ts b/src/app/(protected)/(cadastros)/cadastros/_data/TTBReconhecimentoTipo/TTBReconhecimentoTipoSaveData.ts new file mode 100644 index 0000000..e045e65 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_data/TTBReconhecimentoTipo/TTBReconhecimentoTipoSaveData.ts @@ -0,0 +1,17 @@ +import API from "@/services/api/Api"; +import { Methods } from "@/services/api/enums/ApiMethodEnum"; +import TTBReconhecimentoTipoInterface from "../../_interfaces/TTBReconhecimentoTipoInterface"; + +export default async function TTBReconhecimentoTipoSaveData(data: TTBReconhecimentoTipoInterface) { + + const api = new API(); + + const response = await api.send({ + method: data.tb_reconhecimentotipo_id ? Methods.PUT : Methods.POST, + endpoint: `administrativo/t_tb_reconhecimentotipo/${data.tb_reconhecimentotipo_id ? data.tb_reconhecimentotipo_id : ''}`, + body: data + }); + + return response; + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_hooks/g_medidatipo/useGMedidaTipoReadHook.ts b/src/app/(protected)/(cadastros)/cadastros/_hooks/g_medidatipo/useGMedidaTipoReadHook.ts new file mode 100644 index 0000000..9ac7b2c --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_hooks/g_medidatipo/useGMedidaTipoReadHook.ts @@ -0,0 +1,27 @@ +import { useResponse } from "@/app/_response/ResponseContext" +import { useState } from "react"; +import { GMedidaTipoInterface } from "../../_interfaces/GMedidaTipoInterface"; +import GMedidaTipoIndexService from "../../_services/g_medidatipo/GMedidaTipoIndexService"; + +export const useGMedidaTipoReadHook = () => { + + const { setResponse } = useResponse(); + const [gMedidaTipo, setGMedidaTipo] = useState([]); + + const fetchGMedidaTipo = async () => { + + try { + const response = await GMedidaTipoIndexService(); + + setGMedidaTipo(response.data); + + setResponse(response); + } catch (error) { + console.log(error) + } + + } + + return { gMedidaTipo, fetchGMedidaTipo } + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_hooks/g_medidatipo/useGMedidaTipoRemoveHook.ts b/src/app/(protected)/(cadastros)/cadastros/_hooks/g_medidatipo/useGMedidaTipoRemoveHook.ts new file mode 100644 index 0000000..d19018a --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_hooks/g_medidatipo/useGMedidaTipoRemoveHook.ts @@ -0,0 +1,19 @@ +import { useResponse } from "@/app/_response/ResponseContext" +import { GMedidaTipoInterface } from "../../_interfaces/GMedidaTipoInterface"; +import GMedidaTipoRemoveService from "../../_services/g_medidatipo/GMedidaTipoRemoveService"; + +export const useGMedidaTipoRemoveHook = () => { + + const { setResponse } = useResponse(); + + const removeGMedidaTipo = async (data: GMedidaTipoInterface) => { + + const response = await GMedidaTipoRemoveService(data); + + setResponse(response); + + } + + return { removeGMedidaTipo } + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_hooks/g_medidatipo/useGMedidaTipoSaveHook.ts b/src/app/(protected)/(cadastros)/cadastros/_hooks/g_medidatipo/useGMedidaTipoSaveHook.ts new file mode 100644 index 0000000..8f70843 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_hooks/g_medidatipo/useGMedidaTipoSaveHook.ts @@ -0,0 +1,31 @@ +import { useResponse } from "@/app/_response/ResponseContext" +import { useState } from "react"; +import { GMedidaTipoInterface } from "../../_interfaces/GMedidaTipoInterface"; +import GMedidaTipoSaveService from "../../_services/g_medidatipo/GMedidaTipoSaveService"; + +export const useGMedidaTipoSaveHook = () => { + + const { setResponse } = useResponse(); + const [gMedidaTipo, setGMedidaTipo] = useState(null); + // controla se o formulário está aberto ou fechado + const [isOpen, setIsOpen] = useState(false); + + const saveGMedidaTipo = async (data: GMedidaTipoInterface) => { + + const response = await GMedidaTipoSaveService(data); + + setGMedidaTipo(response.data); + + setResponse(response); + + // Fecha o formulário automaticamente após salvar + setIsOpen(false); + + // Retorna os dados imediatamente + return response; + + } + + return { gMedidaTipo, saveGMedidaTipo } + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_hooks/g_tb_bairro/useGTBBairroReadHook.ts b/src/app/(protected)/(cadastros)/cadastros/_hooks/g_tb_bairro/useGTBBairroReadHook.ts new file mode 100644 index 0000000..2d4ebac --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_hooks/g_tb_bairro/useGTBBairroReadHook.ts @@ -0,0 +1,30 @@ +'use client' + +import { useResponse } from "@/app/_response/ResponseContext" +import { use, useState } from "react"; +import { GTBBairroInterface } from "../../_interfaces/GTBBairroInterface"; +import GTBBairroIndexService from "../../_services/g_tb_bairro/GTBBairroIndexService"; + +export const useGTBBairroReadHook = () => { + + const { setResponse } = useResponse(); + + // Controle dos dados obtidos via API + const [gTBBairro, setGTBBairro] = useState([]); + + const fetchGTBBairro = async () => { + + // Realiza a requisição para a api + const response = await GTBBairroIndexService(); + + // Armazena os dados da resposta + setGTBBairro(response.data); + + // Envia os dados da resposta para ser tratado + setResponse(response); + + } + + return { gTBBairro, fetchGTBBairro } + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_hooks/g_tb_bairro/useGTBBairroRemoveHook.ts b/src/app/(protected)/(cadastros)/cadastros/_hooks/g_tb_bairro/useGTBBairroRemoveHook.ts new file mode 100644 index 0000000..00ed2d0 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_hooks/g_tb_bairro/useGTBBairroRemoveHook.ts @@ -0,0 +1,19 @@ +import { useResponse } from "@/app/_response/ResponseContext" +import { GTBBairroInterface } from "../../_interfaces/GTBBairroInterface"; +import GTBBairroRemoveService from "../../_services/g_tb_bairro/GTBBairroRemoveService"; + +export const useGTBBairroRemoveHook = () => { + + const { setResponse } = useResponse(); + + const removeGTBBairro = async (data: GTBBairroInterface) => { + + const response = await GTBBairroRemoveService(data); + + setResponse(response); + + } + + return { removeGTBBairro } + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_hooks/g_tb_bairro/useGTBBairroSaveHook.ts b/src/app/(protected)/(cadastros)/cadastros/_hooks/g_tb_bairro/useGTBBairroSaveHook.ts new file mode 100644 index 0000000..ecd5d3f --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_hooks/g_tb_bairro/useGTBBairroSaveHook.ts @@ -0,0 +1,32 @@ +import { useResponse } from "@/app/_response/ResponseContext" +import { useState } from "react"; +import { GTBBairroInterface } from "../../_interfaces/GTBBairroInterface"; +import GTBBairroSaveService from "../../_services/g_tb_bairro/GTBBairroSaveService"; + +export const useGTBBairroSaveHook = () => { + + const { setResponse } = useResponse(); + const [gTBBairro, setGTBBairro] = useState(null); + + // controla se o formulário está aberto ou fechado + const [isOpen, setIsOpen] = useState(false); + + const saveGTBBairro = async (data: GTBBairroInterface) => { + + const response = await GTBBairroSaveService(data); + + setGTBBairro(response.data); + + setResponse(response); + + // Fecha o formulário automaticamente após salvar + setIsOpen(false); + + // Retorna os dados imediatamente + return response; + + } + + return { gTBBairro, saveGTBBairro } + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_hooks/g_tb_estadocivil/useGTBEstadoCivilReadHook.ts b/src/app/(protected)/(cadastros)/cadastros/_hooks/g_tb_estadocivil/useGTBEstadoCivilReadHook.ts new file mode 100644 index 0000000..4a7d31b --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_hooks/g_tb_estadocivil/useGTBEstadoCivilReadHook.ts @@ -0,0 +1,27 @@ +import { useResponse } from "@/app/_response/ResponseContext" +import { useState } from "react"; +import { GTBEstadoCivilInterface } from "../../_interfaces/GTBEstadoCivilInterface"; +import GTBEstadoCivilIndexService from "../../_services/g_tb_estadocivil/GTBEstadoCivilIndexService"; + +export const useGTBEstadoCivilReadHook = () => { + + const { setResponse } = useResponse(); + const [gTBEstadoCivil, setGTBEstadoCivil] = useState([]); + + const fetchGTBEstadoCivil = async () => { + + try { + const response = await GTBEstadoCivilIndexService(); + + setGTBEstadoCivil(response.data); + + setResponse(response); + } catch (error) { + console.log(error) + } + + } + + return { gTBEstadoCivil, fetchGTBEstadoCivil } + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_hooks/g_tb_estadocivil/useGTBEstadoCivilRemoveHook.ts b/src/app/(protected)/(cadastros)/cadastros/_hooks/g_tb_estadocivil/useGTBEstadoCivilRemoveHook.ts new file mode 100644 index 0000000..1cc29cf --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_hooks/g_tb_estadocivil/useGTBEstadoCivilRemoveHook.ts @@ -0,0 +1,19 @@ +import { useResponse } from "@/app/_response/ResponseContext" +import { GTBEstadoCivilInterface } from "../../_interfaces/GTBEstadoCivilInterface"; +import GTBEstadoCivilRemoveService from "../../_services/g_tb_estadocivil/GTBEstadoCivilRemoveService"; + +export const useGTBEstadoCivilRemoveHook = () => { + + const { setResponse } = useResponse(); + + const removeGTBEstadoCivil = async (data: GTBEstadoCivilInterface) => { + + const response = await GTBEstadoCivilRemoveService(data); + + setResponse(response); + + } + + return { removeGTBEstadoCivil } + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_hooks/g_tb_estadocivil/useGTBEstadoCivilSaveHook.ts b/src/app/(protected)/(cadastros)/cadastros/_hooks/g_tb_estadocivil/useGTBEstadoCivilSaveHook.ts new file mode 100644 index 0000000..63a0237 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_hooks/g_tb_estadocivil/useGTBEstadoCivilSaveHook.ts @@ -0,0 +1,31 @@ +import { useResponse } from "@/app/_response/ResponseContext" +import { useState } from "react"; +import { GTBEstadoCivilInterface } from "../../_interfaces/GTBEstadoCivilInterface"; +import GTBEstadoCivilSaveService from "../../_services/g_tb_estadocivil/GTBEstadoCivilSaveService"; + +export const useGTBEstadoCivilSaveHook = () => { + + const { setResponse } = useResponse(); + const [gTBEstadoCivil, setGTBEstadoCivil] = useState(null); + // controla se o formulário está aberto ou fechado + const [isOpen, setIsOpen] = useState(false); + + const saveGTBEstadoCivil = async (data: GTBEstadoCivilInterface) => { + + const response = await GTBEstadoCivilSaveService(data); + + setGTBEstadoCivil(response.data); + + setResponse(response); + + // Fecha o formulário automaticamente após salvar + setIsOpen(false); + + // Retorna os dados imediatamente + return response; + + } + + return { gTBEstadoCivil, saveGTBEstadoCivil } + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_hooks/g_tb_profissao/useGTBProfissaoReadHook.ts b/src/app/(protected)/(cadastros)/cadastros/_hooks/g_tb_profissao/useGTBProfissaoReadHook.ts new file mode 100644 index 0000000..6bd2c60 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_hooks/g_tb_profissao/useGTBProfissaoReadHook.ts @@ -0,0 +1,23 @@ +import { useResponse } from "@/app/_response/ResponseContext" +import { useState } from "react"; +import GTBProfissaoInterface from "../../_interfaces/GTBProfissaoInterface"; +import GTBProfissaoIndexService from "../../_services/g_tb_profissao/GTBProfissaoIndexService"; + +export const useGTBProfissaoReadHook = () => { + + const { setResponse } = useResponse(); + const [gTBProfissao, setGTBProfissao] = useState([]); + + const fetchGTBProfissao = async () => { + + const response = await GTBProfissaoIndexService(); + + setGTBProfissao(response.data); + + setResponse(response); + + } + + return { gTBProfissao, fetchGTBProfissao } + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_hooks/g_tb_profissao/useGTBProfissaoRemoveHook.ts b/src/app/(protected)/(cadastros)/cadastros/_hooks/g_tb_profissao/useGTBProfissaoRemoveHook.ts new file mode 100644 index 0000000..421c186 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_hooks/g_tb_profissao/useGTBProfissaoRemoveHook.ts @@ -0,0 +1,19 @@ +import { useResponse } from "@/app/_response/ResponseContext" +import GTBProfissaoInterface from "../../_interfaces/GTBProfissaoInterface"; +import GTBProfissaoRemoveService from "../../_services/g_tb_profissao/GTBProfissaoRemoveService"; + +export const useGTBProfissaoRemoveHook = () => { + + const { setResponse } = useResponse(); + + const removeGTBProfissao = async (data: GTBProfissaoInterface) => { + + const response = await GTBProfissaoRemoveService(data); + + setResponse(response); + + } + + return { removeGTBProfissao } + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_hooks/g_tb_profissao/useGTBProfissaoSaveHook.ts b/src/app/(protected)/(cadastros)/cadastros/_hooks/g_tb_profissao/useGTBProfissaoSaveHook.ts new file mode 100644 index 0000000..74b9dd5 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_hooks/g_tb_profissao/useGTBProfissaoSaveHook.ts @@ -0,0 +1,31 @@ +import { useResponse } from "@/app/_response/ResponseContext" +import { useState } from "react"; +import GTBProfissaoInterface from "../../_interfaces/GTBProfissaoInterface"; +import GTBProfissaoSaveService from "../../_services/g_tb_profissao/GTBProfissaoSaveService"; + +export const useGTBProfissaoSaveHook = () => { + + const { setResponse } = useResponse(); + const [gTBProfissao, setGTBProfissao] = useState(null); + // controla se o formulário está aberto ou fechado + const [isOpen, setIsOpen] = useState(false); + + const saveGTBProfissao = async (data: GTBProfissaoInterface) => { + + const response = await GTBProfissaoSaveService(data); + + setGTBProfissao(response.data); + + setResponse(response); + + // Fecha o formulário automaticamente após salvar + setIsOpen(false); + + // Retorna os dados imediatamente + return response; + + } + + return { gTBProfissao, saveGTBProfissao } + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_hooks/g_tb_regimebens/useGTBRegimeBensReadHook.ts b/src/app/(protected)/(cadastros)/cadastros/_hooks/g_tb_regimebens/useGTBRegimeBensReadHook.ts new file mode 100644 index 0000000..9294db5 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_hooks/g_tb_regimebens/useGTBRegimeBensReadHook.ts @@ -0,0 +1,25 @@ +import { useResponse } from "@/app/_response/ResponseContext" +import { useState } from "react"; +import GTBRegimeBensIndexService from "../../_services/g_tb_regimebens/GTBRegimeBensIndexService"; +import GTBRegimeBensInterface from "../../_interfaces/GTBRegimeBensInterface"; + +export const useGTBRegimeBensReadHook = () => { + + const { setResponse } = useResponse(); + const [gTBRegimeBens, setGTBRegimeBens] = useState([]); + + const fetchGTBRegimeBens = async () => { + + const response = await GTBRegimeBensIndexService(); + + setGTBRegimeBens(response.data); + + setResponse(response); + + return response; + + } + + return { gTBRegimeBens, fetchGTBRegimeBens } + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_hooks/g_tb_regimebens/useGTBRegimeBensRemoveHook.ts b/src/app/(protected)/(cadastros)/cadastros/_hooks/g_tb_regimebens/useGTBRegimeBensRemoveHook.ts new file mode 100644 index 0000000..748313e --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_hooks/g_tb_regimebens/useGTBRegimeBensRemoveHook.ts @@ -0,0 +1,19 @@ +import { useResponse } from "@/app/_response/ResponseContext" +import GTBRegimeBensInterface from "../../_interfaces/GTBRegimeBensInterface"; +import GTBRegimeBensRemoveData from "../../_data/GTBRegimeBens/GTBRegimeBensRemoveData"; + +export const useGTBRegimeBensRemoveHook = () => { + + const { setResponse } = useResponse(); + + const removeGTBRegimeComunhao = async (data: GTBRegimeBensInterface) => { + + const response = await GTBRegimeBensRemoveData(data); + + setResponse(response); + + } + + return { removeGTBRegimeComunhao } + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_hooks/g_tb_regimebens/useGTBRegimeBensSaveHook.ts b/src/app/(protected)/(cadastros)/cadastros/_hooks/g_tb_regimebens/useGTBRegimeBensSaveHook.ts new file mode 100644 index 0000000..4941f94 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_hooks/g_tb_regimebens/useGTBRegimeBensSaveHook.ts @@ -0,0 +1,34 @@ +import { useState } from "react"; +import { useResponse } from "@/app/_response/ResponseContext" +import GTBRegimeBensInterface from "../../_interfaces/GTBRegimeBensInterface"; +import { GTBRegimeBensSaveService } from "../../_services/g_tb_regimebens/GTBRegimeBensSaveService"; + +export const useGTBRegimeBensSaveHook = () => { + + const { setResponse } = useResponse(); + const [gTBRegimeComunhao, setGTBRegimeComunhao] = useState(null); + + // controla se o formulário está aberto ou fechado + const [isOpen, setIsOpen] = useState(false); + + const saveGTBRegimeComunhao = async (data: GTBRegimeBensInterface) => { + + const response = await GTBRegimeBensSaveService(data); + + // Guardar os dados localizados + setGTBRegimeComunhao(response.data); + + // Manda a resposta para o verificador de resposta + setResponse(response); + + // Fecha o formulário automaticamente após salvar + setIsOpen(false); + + // Retorna os dados imediatamente + return response; + + } + + return { gTBRegimeComunhao, saveGTBRegimeComunhao } + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_hooks/g_tb_regimecomunhao/useGTBRegimeComunhaoReadHook.ts b/src/app/(protected)/(cadastros)/cadastros/_hooks/g_tb_regimecomunhao/useGTBRegimeComunhaoReadHook.ts new file mode 100644 index 0000000..1d1ff3a --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_hooks/g_tb_regimecomunhao/useGTBRegimeComunhaoReadHook.ts @@ -0,0 +1,23 @@ +import { useResponse } from "@/app/_response/ResponseContext" +import { useState } from "react"; +import GTBRegimeComunhaoInterface from "../../_interfaces/GTBRegimeComunhaoInterface"; +import GTBRegimeComunhaoIndexService from "../../_services/g_tb_regimecomunhao/GTBRegimeComunhaoIndexService"; + +export const useGTBRegimeComunhaoReadHook = () => { + + const { setResponse } = useResponse(); + const [gTBRegimeComunhao, setGTBRegimeComunhao] = useState([]); + + const fetchGTBRegimeComunhao = async () => { + + const response = await GTBRegimeComunhaoIndexService(); + + setGTBRegimeComunhao(response.data); + + setResponse(response); + + } + + return { gTBRegimeComunhao, fetchGTBRegimeComunhao } + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_hooks/g_tb_regimecomunhao/useGTBRegimeComunhaoRemoveHook.ts b/src/app/(protected)/(cadastros)/cadastros/_hooks/g_tb_regimecomunhao/useGTBRegimeComunhaoRemoveHook.ts new file mode 100644 index 0000000..658231a --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_hooks/g_tb_regimecomunhao/useGTBRegimeComunhaoRemoveHook.ts @@ -0,0 +1,19 @@ +import { useResponse } from "@/app/_response/ResponseContext" +import GTBRegimeComunhaoInterface from "../../_interfaces/GTBRegimeComunhaoInterface"; +import GTBRegimeComunhaoRemoveService from "../../_services/g_tb_regimecomunhao/GTBRegimeComunhaoRemoveService"; + +export const useGTBRegimeComunhaoRemoveHook = () => { + + const { setResponse } = useResponse(); + + const removeGTBRegimeComunhao = async (data: GTBRegimeComunhaoInterface) => { + + const response = await GTBRegimeComunhaoRemoveService(data); + + setResponse(response); + + } + + return { removeGTBRegimeComunhao } + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_hooks/g_tb_regimecomunhao/useGTBRegimeComunhaoSaveHook.ts b/src/app/(protected)/(cadastros)/cadastros/_hooks/g_tb_regimecomunhao/useGTBRegimeComunhaoSaveHook.ts new file mode 100644 index 0000000..b67690e --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_hooks/g_tb_regimecomunhao/useGTBRegimeComunhaoSaveHook.ts @@ -0,0 +1,33 @@ +import { useState } from "react"; +import { useResponse } from "@/app/_response/ResponseContext" +import GTBRegimeComunhaoInterface from "../../_interfaces/GTBRegimeComunhaoInterface"; +import GTBRegimeComunhaoSaveService from "../../_services/g_tb_regimecomunhao/GTBRegimeComunhaoSaveService"; + +export const useGTBRegimeComunhaoSaveHook = () => { + + const { setResponse } = useResponse(); + const [gTBRegimeComunhao, setGTBRegimeComunhao] = useState(null); + // controla se o formulário está aberto ou fechado + const [isOpen, setIsOpen] = useState(false); + + const saveGTBRegimeComunhao = async (data: GTBRegimeComunhaoInterface) => { + + const response = await GTBRegimeComunhaoSaveService(data); + + // Guardar os dados localizados + setGTBRegimeComunhao(response.data); + + // Manda a resposta para o verificador de resposta + setResponse(response); + + // Fecha o formulário automaticamente após salvar + setIsOpen(false); + + // Retorna os dados imediatamente + return response; + + } + + return { gTBRegimeComunhao, saveGTBRegimeComunhao } + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_hooks/g_tb_tipologradouro/useGTBTipoLogradouroReadHook.ts b/src/app/(protected)/(cadastros)/cadastros/_hooks/g_tb_tipologradouro/useGTBTipoLogradouroReadHook.ts new file mode 100644 index 0000000..a452e29 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_hooks/g_tb_tipologradouro/useGTBTipoLogradouroReadHook.ts @@ -0,0 +1,27 @@ +import { useResponse } from "@/app/_response/ResponseContext" +import { useState } from "react"; +import { GTBTipoLogradouroInterface } from "../../_interfaces/GTBTipoLogradouroInterface"; +import GTBTipoLogradouroIndexService from "../../_services/g_tb_tipologradouro/GTBTipoLogradouroIndexService"; + +export const useGTBTipoLogradouroReadHook = () => { + + const { setResponse } = useResponse(); + const [gTBTipoLogradouro, setGTBTipoLogradouro] = useState([]); + + const fetchGTBTipoLogradouro = async () => { + + try { + const response = await GTBTipoLogradouroIndexService(); + + setGTBTipoLogradouro(response.data); + + setResponse(response); + } catch (error) { + console.log(error) + } + + } + + return { gTBTipoLogradouro, fetchGTBTipoLogradouro } + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_hooks/g_tb_tipologradouro/useGTBTipoLogradouroRemoveHook.ts b/src/app/(protected)/(cadastros)/cadastros/_hooks/g_tb_tipologradouro/useGTBTipoLogradouroRemoveHook.ts new file mode 100644 index 0000000..529ae61 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_hooks/g_tb_tipologradouro/useGTBTipoLogradouroRemoveHook.ts @@ -0,0 +1,19 @@ +import { useResponse } from "@/app/_response/ResponseContext" +import { GTBTipoLogradouroInterface } from "../../_interfaces/GTBTipoLogradouroInterface"; +import GTBTipoLogradouroRemoveService from "../../_services/g_tb_tipologradouro/GTBTipoLogradouroRemoveService"; + +export const useGTBTipoLogradouroRemoveHook = () => { + + const { setResponse } = useResponse(); + + const removeGTBTipoLogradouro = async (data: GTBTipoLogradouroInterface) => { + + const response = await GTBTipoLogradouroRemoveService(data); + + setResponse(response); + + } + + return { removeGTBTipoLogradouro } + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_hooks/g_tb_tipologradouro/useGTBTipoLogradouroSaveHook.ts b/src/app/(protected)/(cadastros)/cadastros/_hooks/g_tb_tipologradouro/useGTBTipoLogradouroSaveHook.ts new file mode 100644 index 0000000..668966d --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_hooks/g_tb_tipologradouro/useGTBTipoLogradouroSaveHook.ts @@ -0,0 +1,31 @@ +import { useResponse } from "@/app/_response/ResponseContext" +import { useState } from "react"; +import { GTBTipoLogradouroInterface } from "../../_interfaces/GTBTipoLogradouroInterface"; +import GTBTipoLogradouroSaveService from "../../_services/g_tb_tipologradouro/GTBTipoLogradouroSaveService"; + +export const useGTBTipoLogradouroSaveHook = () => { + + const { setResponse } = useResponse(); + const [gTBTipoLogradouro, setGTBTipoLogradouro] = useState(null); + // controla se o formulário está aberto ou fechado + const [isOpen, setIsOpen] = useState(false); + + const saveGTBTipoLogradouro = async (data: GTBTipoLogradouroInterface) => { + + const response = await GTBTipoLogradouroSaveService(data); + + setGTBTipoLogradouro(response.data); + + setResponse(response); + + // Fecha o formulário automaticamente após salvar + setIsOpen(false); + + // Retorna os dados imediatamente + return response; + + } + + return { gTBTipoLogradouro, saveGTBTipoLogradouro } + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_hooks/t_censec/useTCensecDeleteHook.ts b/src/app/(protected)/(cadastros)/cadastros/_hooks/t_censec/useTCensecDeleteHook.ts new file mode 100644 index 0000000..1ac288a --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_hooks/t_censec/useTCensecDeleteHook.ts @@ -0,0 +1,19 @@ +import { useResponse } from "@/app/_response/ResponseContext" +import TCensecInterface from "../../_interfaces/TCensecInterface"; +import { TCensecDeleteService } from "../../_services/t_censec/TCensecDeleteService"; + +export const useTCensecDeleteHook = () => { + + const { setResponse } = useResponse(); + + const deleteTCensec = async (data: TCensecInterface) => { + + const response = await TCensecDeleteService(data); + + setResponse(response); + + } + + return { deleteTCensec } + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_hooks/t_censec/useTCensecReadHook.ts b/src/app/(protected)/(cadastros)/cadastros/_hooks/t_censec/useTCensecReadHook.ts new file mode 100644 index 0000000..3fd4148 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_hooks/t_censec/useTCensecReadHook.ts @@ -0,0 +1,24 @@ +import { useResponse } from "@/app/_response/ResponseContext" +import { TCensecIndexService } from "../../_services/t_censec/TCensecIndexService"; +import { useState } from "react"; +import TCensecInterface from "../../_interfaces/TCensecInterface"; + +export const useTCensecReadHook = () => { + + const { setResponse } = useResponse(); + + const [tCensec, setTCensec] = useState([]); + + const fetchTCensec = async () => { + + const response = await TCensecIndexService(); + + setTCensec(response.data); + + setResponse(response); + + } + + return { tCensec, fetchTCensec } + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_hooks/t_censec/useTCensecSaveHook.ts b/src/app/(protected)/(cadastros)/cadastros/_hooks/t_censec/useTCensecSaveHook.ts new file mode 100644 index 0000000..7efbb56 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_hooks/t_censec/useTCensecSaveHook.ts @@ -0,0 +1,37 @@ +'use client' + +import { useResponse } from "@/app/_response/ResponseContext" +import { useState } from "react"; +import TCensecInterface from "../../_interfaces/TCensecInterface"; +import { TCensecSaveService } from "../../_services/t_censec/TCensecSaveService"; + +export const useTCensecSaveHook = () => { + + const { setResponse } = useResponse(); + + const [tCensec, setTCensec] = useState(); + + // controla se o formulário está aberto ou fechado + const [isOpen, setIsOpen] = useState(false); + + const saveTCensec = async (data: TCensecInterface) => { + + const response = await TCensecSaveService(data); + + // Armazena os dados da repsota + setTCensec(response.data); + + // Define os dados da respota(toast, modal, etc) + setResponse(response); + + // Fecha o formulário automaticamente após salvar + setIsOpen(false); + + // Retorna os valores de forma imediata + return response.data; + + } + + return { tCensec, saveTCensec } + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_hooks/t_censecnaturezalitigio/useTCensecNaturezaLitigioReadHook.ts b/src/app/(protected)/(cadastros)/cadastros/_hooks/t_censecnaturezalitigio/useTCensecNaturezaLitigioReadHook.ts new file mode 100644 index 0000000..b68ba6f --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_hooks/t_censecnaturezalitigio/useTCensecNaturezaLitigioReadHook.ts @@ -0,0 +1,29 @@ +import { useResponse } from "@/app/_response/ResponseContext" +import { useState } from "react"; +import { TCensecNaturezaLitigioInterface } from "../../_interfaces/TCensecNaturezaLitigioInterface"; +import TCensecNaturezaLitigioIndexService from "../../_services/t_censecnaturezalitigio/TCensecNaturezaLitigioIndexService"; + +export const useTCensecNaturezaLitigioReadHook = () => { + + const { setResponse } = useResponse(); + const [tCensecNaturezaLitigio, setTCensecNaturezaLitigio] = useState([]); + + const fetchTCensecNaturezaLitigio = async () => { + + try { + const response = await TCensecNaturezaLitigioIndexService(); + + setTCensecNaturezaLitigio(response.data); + + console.log(response) + + setResponse(response); + } catch (error) { + console.log(error) + } + + } + + return { tCensecNaturezaLitigio, fetchTCensecNaturezaLitigio } + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_hooks/t_censecnaturezalitigio/useTCensecNaturezaLitigioRemoveHook.ts b/src/app/(protected)/(cadastros)/cadastros/_hooks/t_censecnaturezalitigio/useTCensecNaturezaLitigioRemoveHook.ts new file mode 100644 index 0000000..bbf5cda --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_hooks/t_censecnaturezalitigio/useTCensecNaturezaLitigioRemoveHook.ts @@ -0,0 +1,24 @@ +import { useResponse } from "@/app/_response/ResponseContext" +import { TCensecNaturezaLitigioInterface } from "../../_interfaces/TCensecNaturezaLitigioInterface"; +import { useState } from "react"; +import TCensecNaturezaLitigioRemoveData from "../../_data/TCensecNaturezaLitigio/TCensecNaturezaLitigioRemoveData"; + +export const useTCensecNaturezaLitigioRemoveHook = () => { + + const { setResponse } = useResponse(); + + const [tCensecNaturezaLitigio, setTCensecNaturezaLitigio] = useState() + + const removeTCensecNaturezaLitigio = async (data: TCensecNaturezaLitigioInterface) => { + + const response = await TCensecNaturezaLitigioRemoveData(data); + + setTCensecNaturezaLitigio(data) + + setResponse(response); + + } + + return { tCensecNaturezaLitigio, removeTCensecNaturezaLitigio } + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_hooks/t_censecnaturezalitigio/useTCensecNaturezaLitigioSaveHook.ts b/src/app/(protected)/(cadastros)/cadastros/_hooks/t_censecnaturezalitigio/useTCensecNaturezaLitigioSaveHook.ts new file mode 100644 index 0000000..9ba939b --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_hooks/t_censecnaturezalitigio/useTCensecNaturezaLitigioSaveHook.ts @@ -0,0 +1,31 @@ +import { useResponse } from "@/app/_response/ResponseContext" +import { useState } from "react"; +import { TCensecNaturezaLitigioInterface } from "../../_interfaces/TCensecNaturezaLitigioInterface"; +import TCensecNaturezaLitigioSaveService from "../../_services/t_censecnaturezalitigio/TCensecNaturezaLitigioSaveService"; + +export const useTCensecNaturezaLitigioSaveHook = () => { + + const { setResponse } = useResponse(); + const [TCensecNaturezaLitigio, setTCensecNaturezaLitigio] = useState(null); + // controla se o formulário está aberto ou fechado + const [isOpen, setIsOpen] = useState(false); + + const saveTCensecNaturezaLitigio = async (data: TCensecNaturezaLitigioInterface) => { + + const response = await TCensecNaturezaLitigioSaveService(data); + + setTCensecNaturezaLitigio(response.data); + + setResponse(response); + + // Fecha o formulário automaticamente após salvar + setIsOpen(false); + + // Retorna os dados imediatamente + return response; + + } + + return { TCensecNaturezaLitigio, saveTCensecNaturezaLitigio } + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_hooks/t_minuta/useTMinutaIndexHook.ts b/src/app/(protected)/(cadastros)/cadastros/_hooks/t_minuta/useTMinutaIndexHook.ts new file mode 100644 index 0000000..2354ec6 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_hooks/t_minuta/useTMinutaIndexHook.ts @@ -0,0 +1,27 @@ +import { useResponse } from "@/app/_response/ResponseContext" +import { useState } from "react"; +import { TMinutaInterface } from "../../_interfaces/TMinutaInterface"; +import TMinutaIndex from "../../_services/t_minuta/TMinutaIndex"; + +export const useTMinutaIndexHook = () => { + + const { setResponse } = useResponse(); + const [tMinuta, setTMinuta] = useState([]); + + const fetchTMinuta = async () => { + + try { + const response = await TMinutaIndex(); + + setTMinuta(response.data); + + setResponse(response); + } catch (error) { + console.log(error) + } + + } + + return { tMinuta, fetchTMinuta } + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_hooks/t_minuta/useTMinutaReadHook.ts b/src/app/(protected)/(cadastros)/cadastros/_hooks/t_minuta/useTMinutaReadHook.ts new file mode 100644 index 0000000..dd8de75 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_hooks/t_minuta/useTMinutaReadHook.ts @@ -0,0 +1,28 @@ +import { useResponse } from "@/app/_response/ResponseContext" +import { useState } from "react"; +import { TMinutaInterface } from "../../_interfaces/TMinutaInterface"; +import TMinutaIndexService from "../../_services/t_minuta/TMinutaIndexService"; + +export const useTMinutaReadHook = () => { + + const { setResponse } = useResponse(); + const [tMinuta, setTMinuta] = useState(); + + const fetchTMinuta = async (tMinuta: TMinutaInterface) => { + + try { + const response = await TMinutaIndexService(tMinuta.t_minuta_id); + console.log("read hook",response.data) + + setTMinuta(response.data); + + setResponse(response); + } catch (error) { + console.log(error) + } + + } + + return { tMinuta, fetchTMinuta } + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_hooks/t_minuta/useTMinutaRemoveHook.ts b/src/app/(protected)/(cadastros)/cadastros/_hooks/t_minuta/useTMinutaRemoveHook.ts new file mode 100644 index 0000000..240a2a4 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_hooks/t_minuta/useTMinutaRemoveHook.ts @@ -0,0 +1,19 @@ +import { useResponse } from "@/app/_response/ResponseContext" +import { TMinutaInterface } from "../../_interfaces/TMinutaInterface"; +import TMinutaRemoveService from "../../_services/t_minuta/TMinutaRemoveService"; + +export const useTMinutaRemoveHook = () => { + + const { setResponse } = useResponse(); + + const removeTMinuta = async (data: TMinutaInterface) => { + + const response = await TMinutaRemoveService(data); + + setResponse(response); + + } + + return { removeTMinuta } + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_hooks/t_minuta/useTMinutaSaveHook.ts b/src/app/(protected)/(cadastros)/cadastros/_hooks/t_minuta/useTMinutaSaveHook.ts new file mode 100644 index 0000000..d1a817a --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_hooks/t_minuta/useTMinutaSaveHook.ts @@ -0,0 +1,31 @@ +import { useResponse } from "@/app/_response/ResponseContext" +import { useState } from "react"; +import { TMinutaInterface } from "../../_interfaces/TMinutaInterface"; +import TMinutaSaveService from "../../_services/t_minuta/TMinutaSaveService"; + +export const useTMinutaSaveHook = () => { + + const { setResponse } = useResponse(); + const [tMinuta, setTMinuta] = useState(); + // controla se o formulário está aberto ou fechado + const [isOpen, setIsOpen] = useState(false); + + const saveTMinuta = async (data: any) => { + + const response = await TMinutaSaveService(data); + + setTMinuta(response.data); + + setResponse(response); + + // Fecha o formulário automaticamente após salvar + setIsOpen(false); + + // Retorna os dados imediatamente + return response; + + } + + return { tMinuta, saveTMinuta } + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_andamentoservico/useTTBAndamentoServicoDeleteHook.ts b/src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_andamentoservico/useTTBAndamentoServicoDeleteHook.ts new file mode 100644 index 0000000..c3407ee --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_andamentoservico/useTTBAndamentoServicoDeleteHook.ts @@ -0,0 +1,24 @@ +import { useResponse } from "@/app/_response/ResponseContext" +import { useState } from "react"; +import TTBAndamentoServicoInteface from "../../_interfaces/TTBAndamentoServicoInterface"; +import TTBAndamentoServicoRemoveData from "../../_data/TTBAndamentoServico/TTBAndamentoServicoRemoveData"; + +export const useTTBAndamentoServicoDeleteHook = () => { + + const { setResponse } = useResponse(); + + const [tTBAndamentoServico, setTTBAndamentoServico] = useState(); + + const deleteTTBAndamentoServico = async (data: TTBAndamentoServicoInteface) => { + + const response = await TTBAndamentoServicoRemoveData(data); + + setTTBAndamentoServico(data); + + setResponse(response); + + } + + return { tTBAndamentoServico, deleteTTBAndamentoServico } + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_andamentoservico/useTTBAndamentoServicoReadHook.ts b/src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_andamentoservico/useTTBAndamentoServicoReadHook.ts new file mode 100644 index 0000000..bc0d99c --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_andamentoservico/useTTBAndamentoServicoReadHook.ts @@ -0,0 +1,36 @@ +'use client' + +import { useResponse } from "@/app/_response/ResponseContext" +import { useState } from "react"; +import TTBAndamentoServicoInteface from "../../_interfaces/TTBAndamentoServicoInterface"; +import TTBAndamentoServicoIndexData from "../../_data/TTBAndamentoServico/TTBAndamentoServicoIndexData"; + +export const useTTBAndamentoServicoReadHook = () => { + + const { setResponse } = useResponse(); + + const [tTBAndamentosServicos, setTTBAndamentosServicos] = useState(null); + + const fetchTTBAndamentoServico = async () => { + + const response = await TTBAndamentoServicoIndexData(); + + console.log(response) + + // Armazena os dados consultados + setTTBAndamentosServicos(response.data); + + // Define os dados do componente de resposta (toast, modal, etc) + setResponse(response); + + } + + function addTTBAndamentoServico(tTTBAndamentoServico: TTBAndamentoServicoInteface) { + + setTTBAndamentosServicos(prev => [...(prev || []), tTTBAndamentoServico]); + + } + + return { tTBAndamentosServicos, fetchTTBAndamentoServico, addTTBAndamentoServico } + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_andamentoservico/useTTBAndamentoServicoSaveHook.ts b/src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_andamentoservico/useTTBAndamentoServicoSaveHook.ts new file mode 100644 index 0000000..863b8d1 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_andamentoservico/useTTBAndamentoServicoSaveHook.ts @@ -0,0 +1,37 @@ +'use client' + +import { useResponse } from "@/app/_response/ResponseContext" +import { useState } from "react"; +import TTBAndamentoServicoInteface from "../../_interfaces/TTBAndamentoServicoInterface"; +import { TTBAndamentoServicoSaveData } from "../../_data/TTBAndamentoServico/TTBAndamentoServicoSaveData"; + +export const useTTBAndamentoServicoSaveHook = () => { + + const { setResponse } = useResponse(); + + const [tTBAndamentoServico, setTTBAndamentoServico] = useState(); + + // controla se o formulário está aberto ou fechado + const [isOpen, setIsOpen] = useState(false); + + const saveTTBAndamentoServico = async (data: TTBAndamentoServicoInteface) => { + + const response = await TTBAndamentoServicoSaveData(data); + + // Armazena os dados da repsota + setTTBAndamentoServico(response.data); + + // Define os dados da respota(toast, modal, etc) + setResponse(response); + + // Fecha o formulário automaticamente após salvar + setIsOpen(false); + + // Retorna os valores de forma imediata + return response.data; + + } + + return { tTBAndamentoServico, saveTTBAndamentoServico } + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_reconhecimentotipo/useTTBReconhecimentoTipoDeleteHook.ts b/src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_reconhecimentotipo/useTTBReconhecimentoTipoDeleteHook.ts new file mode 100644 index 0000000..eb926e7 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_reconhecimentotipo/useTTBReconhecimentoTipoDeleteHook.ts @@ -0,0 +1,19 @@ +import { useResponse } from "@/app/_response/ResponseContext" +import TTBReconhecimentoTipoInterface from "../../_interfaces/TTBReconhecimentoTipoInterface"; +import TTBReconhecimentoTipoDeleteData from "../../_data/TTBReconhecimentoTipo/TTBReconhecimentoTipoDeleteData"; + +export const useTTBReconhecimentoTipoDeleteHook = () => { + + const { setResponse } = useResponse(); + + const deleteTTBReconhecimentoTipo = async (data: TTBReconhecimentoTipoInterface) => { + + const response = await TTBReconhecimentoTipoDeleteData(data); + + setResponse(response); + + } + + return { deleteTTBReconhecimentoTipo } + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_reconhecimentotipo/useTTBReconhecimentoTipoReadHook.ts b/src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_reconhecimentotipo/useTTBReconhecimentoTipoReadHook.ts new file mode 100644 index 0000000..5817953 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_reconhecimentotipo/useTTBReconhecimentoTipoReadHook.ts @@ -0,0 +1,26 @@ +'use client' + +import ITTTBReconhecimentoTipo from '../../_interfaces/TTBReconhecimentoTipoInterface' +import { useResponse } from "@/app/_response/ResponseContext" +import { useState } from "react"; +import TTBReconhecimentoTipoIndexData from '../../_data/TTBReconhecimentoTipo/TTBReconhecimentoTipoIndexData'; + +export const useTTBReconhecimentoTipoReadHook = () => { + + const { setResponse } = useResponse(); + + const [tTBReconhecimentosTipos, setReconhecimenntosTipos] = useState([]); + + const fetchTTBReconhecimentosTipos = async () => { + + const response = await TTBReconhecimentoTipoIndexData(); + + setReconhecimenntosTipos(response.data); + + setResponse(response); + + } + + return { tTBReconhecimentosTipos, fetchTTBReconhecimentosTipos } + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_reconhecimentotipo/useTTBReconhecimentoTipoSaveHook.ts b/src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_reconhecimentotipo/useTTBReconhecimentoTipoSaveHook.ts new file mode 100644 index 0000000..88a88df --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_hooks/t_tb_reconhecimentotipo/useTTBReconhecimentoTipoSaveHook.ts @@ -0,0 +1,35 @@ +'use client' + +import { useResponse } from "@/app/_response/ResponseContext" +import { useState } from "react"; +import ITTTBReconhecimentoTipo from '../../_interfaces/TTBReconhecimentoTipoInterface' +import TTBReconhecimentoTipoSaveData from "../../_data/TTBReconhecimentoTipo/TTBReconhecimentoTipoSaveData"; + +export const useTTBReconhecimentoTipoSaveHook = () => { + + const { setResponse } = useResponse(); + + const [tTBReconhecimentoTipo, setTTBReconhcimentoTipo] = useState(); + + // controla se o formulário está aberto ou fechado + const [isOpen, setIsOpen] = useState(false); + + const saveTTBReconhecimentoTipo = async (reconhecimentoTipo: ITTTBReconhecimentoTipo) => { + + const response = await TTBReconhecimentoTipoSaveData(reconhecimentoTipo); + + saveTTBReconhecimentoTipo(response.data); + + setResponse(response); + + // Fecha o formulário automaticamente após salvar + setIsOpen(false); + + // Retorna os valores de forma imediata + return response.data; + + } + + return { tTBReconhecimentoTipo, saveTTBReconhecimentoTipo } + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_interfaces/GMedidaTipoInterface.ts b/src/app/(protected)/(cadastros)/cadastros/_interfaces/GMedidaTipoInterface.ts new file mode 100644 index 0000000..f351f54 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_interfaces/GMedidaTipoInterface.ts @@ -0,0 +1,5 @@ +export interface GMedidaTipoInterface { + medida_tipo_id: number; + sigla: string; + descricao: string; +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_interfaces/GTBBairroInterface.ts b/src/app/(protected)/(cadastros)/cadastros/_interfaces/GTBBairroInterface.ts new file mode 100644 index 0000000..10f70c9 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_interfaces/GTBBairroInterface.ts @@ -0,0 +1,8 @@ +import { SituacoesEnum } from "@/enums/SituacoesEnum"; + +export interface GTBBairroInterface { + sistema_id: number | null; + tb_bairro_id: number; + descricao: string; + situacao: SituacoesEnum; +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_interfaces/GTBEstadoCivilInterface.ts b/src/app/(protected)/(cadastros)/cadastros/_interfaces/GTBEstadoCivilInterface.ts new file mode 100644 index 0000000..12f1cf5 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_interfaces/GTBEstadoCivilInterface.ts @@ -0,0 +1,6 @@ +export interface GTBEstadoCivilInterface { + tb_estadocivil_id: number; + sistema_id: number; + descricao: string; + situacao: 'A' | 'I'; +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_interfaces/GTBProfissaoInterface.ts b/src/app/(protected)/(cadastros)/cadastros/_interfaces/GTBProfissaoInterface.ts new file mode 100644 index 0000000..0d86edf --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_interfaces/GTBProfissaoInterface.ts @@ -0,0 +1,9 @@ + +export default interface GTBProfissaoInterface { + + tb_profissao_id?: number, + descricao: string, + situacao: string, + cod_cbo?: string + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_interfaces/GTBRegimeBensInterface.ts b/src/app/(protected)/(cadastros)/cadastros/_interfaces/GTBRegimeBensInterface.ts new file mode 100644 index 0000000..767bc50 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_interfaces/GTBRegimeBensInterface.ts @@ -0,0 +1,6 @@ + +export default interface GTBRegimeBensInterface { + tb_regimebens_id?: number, + descricao: string, + situacao: string, +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_interfaces/GTBRegimeComunhaoInterface.ts b/src/app/(protected)/(cadastros)/cadastros/_interfaces/GTBRegimeComunhaoInterface.ts new file mode 100644 index 0000000..5d4a9be --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_interfaces/GTBRegimeComunhaoInterface.ts @@ -0,0 +1,7 @@ +export default interface GTBRegimeComunhaoInterface { + tb_regimecomunhao_id?: number, + tb_regimebens_id: number, + descricao: string, + texto: string, + situacao: string, +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_interfaces/GTBTipoLogradouroInterface.ts b/src/app/(protected)/(cadastros)/cadastros/_interfaces/GTBTipoLogradouroInterface.ts new file mode 100644 index 0000000..c7c3a80 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_interfaces/GTBTipoLogradouroInterface.ts @@ -0,0 +1,8 @@ +export interface GTBTipoLogradouroInterface { + sistema_id: number | null; + tb_tipologradouro_id: number; + situacao_id: number | null; + descricao: string; + situacao: 'A' | 'I'; + onr_tipo_logradouro_id: number; +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_interfaces/TCensecInterface.ts b/src/app/(protected)/(cadastros)/cadastros/_interfaces/TCensecInterface.ts new file mode 100644 index 0000000..2fbf58a --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_interfaces/TCensecInterface.ts @@ -0,0 +1,6 @@ + +export default interface TCensecInterface { + censec_id?: number + descricao: string + situacao: string +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_interfaces/TCensecNaturezaLitigioInterface.ts b/src/app/(protected)/(cadastros)/cadastros/_interfaces/TCensecNaturezaLitigioInterface.ts new file mode 100644 index 0000000..5190b85 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_interfaces/TCensecNaturezaLitigioInterface.ts @@ -0,0 +1,5 @@ +export interface TCensecNaturezaLitigioInterface { + censec_naturezalitigio_id?: number; + descricao: string; + situacao: 'A' | 'I'; +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_interfaces/TMinutaInterface.ts b/src/app/(protected)/(cadastros)/cadastros/_interfaces/TMinutaInterface.ts new file mode 100644 index 0000000..8c3ec07 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_interfaces/TMinutaInterface.ts @@ -0,0 +1,7 @@ +export interface TMinutaInterface { + t_minuta_id: number; + natureza_id: number; + descricao: string; + situacao: 'A' | 'I'; + texto: string; +} diff --git a/src/app/(protected)/(cadastros)/cadastros/_interfaces/TTBAndamentoServicoInterface.ts b/src/app/(protected)/(cadastros)/cadastros/_interfaces/TTBAndamentoServicoInterface.ts new file mode 100644 index 0000000..26ad9e2 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_interfaces/TTBAndamentoServicoInterface.ts @@ -0,0 +1,16 @@ +export default interface TTBAndamentoServicoInteface { + tb_andamentoservico_id?: number, + descricao: string, + situacao: string, + tipo: tipoEnum, + usa_email: string +} + +export enum tipoEnum { + CANCELADO = "C", + ESTORNADO = "E", + PROTOCOLADO = "PT", + PEDIDO = "PD", + NAO_CONSTA = "NC", + OUTROS = "O", +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_interfaces/TTBReconhecimentoTipoInterface.ts b/src/app/(protected)/(cadastros)/cadastros/_interfaces/TTBReconhecimentoTipoInterface.ts new file mode 100644 index 0000000..46daae9 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_interfaces/TTBReconhecimentoTipoInterface.ts @@ -0,0 +1,12 @@ +export default interface TTBReconhecimentoTipoInterface { + tb_reconhecimentotipo_id?: number, + descricao: string, + situacao: situacaoEnum, +} + +export enum situacaoEnum { + + ATIVO = 'A', + INATIVO = 'I', + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_schemas/GMedidaTipoSchema.ts b/src/app/(protected)/(cadastros)/cadastros/_schemas/GMedidaTipoSchema.ts new file mode 100644 index 0000000..12bc46e --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_schemas/GMedidaTipoSchema.ts @@ -0,0 +1,7 @@ +import { z } from 'zod'; + +export const GMedidaTipoSchema = z.object({ + medida_tipo_id: z.number(), + sigla: z.string(), + descricao: z.string(), +}); \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_schemas/GTBBairroSchema.ts b/src/app/(protected)/(cadastros)/cadastros/_schemas/GTBBairroSchema.ts new file mode 100644 index 0000000..c4a67d5 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_schemas/GTBBairroSchema.ts @@ -0,0 +1,9 @@ +import { SituacoesEnum } from '@/enums/SituacoesEnum'; +import { z } from 'zod'; + +export const GTBBairroSchema = z.object({ + tb_bairro_id: z.number(), + sistema_id: z.number().nullable(), + descricao: z.string().min(1, 'O campo deve ser preenchido'), + situacao: z.enum(SituacoesEnum), +}); \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_schemas/GTBEstadoCivilSchema.ts b/src/app/(protected)/(cadastros)/cadastros/_schemas/GTBEstadoCivilSchema.ts new file mode 100644 index 0000000..88cb617 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_schemas/GTBEstadoCivilSchema.ts @@ -0,0 +1,8 @@ +import { z } from 'zod'; + +export const GTBEstadoCivilSchema = z.object({ + tb_estadocivil_id: z.number(), + sistema_id: z.number(), + descricao: z.string(), + situacao: z.enum(['A', 'I']), +}); \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_schemas/GTBProfissaoSchema.ts b/src/app/(protected)/(cadastros)/cadastros/_schemas/GTBProfissaoSchema.ts new file mode 100644 index 0000000..9d11ff2 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_schemas/GTBProfissaoSchema.ts @@ -0,0 +1,8 @@ +import { z } from "zod"; + +export const GTBProfissaoSchema = z.object({ + tb_profissao_id: z.number().optional(), + descricao: z.string(), + situacao: z.string(), + cod_cbo: z.string().optional() +}); \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_schemas/GTBRegimeBensSchema.ts b/src/app/(protected)/(cadastros)/cadastros/_schemas/GTBRegimeBensSchema.ts new file mode 100644 index 0000000..49637f0 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_schemas/GTBRegimeBensSchema.ts @@ -0,0 +1,7 @@ +import z from "zod"; + +export const GTBRegimeBensSchema = z.object({ + tb_regimebens_id: z.number().optional(), + descricao: z.string(), + situacao: z.string(), +}); \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_schemas/GTBRegimeComunhaoSchema.ts b/src/app/(protected)/(cadastros)/cadastros/_schemas/GTBRegimeComunhaoSchema.ts new file mode 100644 index 0000000..e47c098 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_schemas/GTBRegimeComunhaoSchema.ts @@ -0,0 +1,9 @@ +import z from "zod"; + +export const GTBRegimeComunhaoSchema = z.object({ + tb_regimecomunhao_id: z.number().optional(), + tb_regimebens_id: z.number(), + descricao: z.string(), + texto: z.string(), + situacao: z.string(), +}); \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_schemas/GTBTipoLogradouroSchema.ts b/src/app/(protected)/(cadastros)/cadastros/_schemas/GTBTipoLogradouroSchema.ts new file mode 100644 index 0000000..92204bd --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_schemas/GTBTipoLogradouroSchema.ts @@ -0,0 +1,10 @@ +import { z } from 'zod'; + +export const GTBTipoLogradouroSchema = z.object({ + sistema_id: z.number().int().nullable(), + tb_tipologradouro_id: z.number().int(), + situacao_id: z.number().nullable(), + descricao: z.string(), + situacao: z.enum(['A', 'I']), + onr_tipo_logradouro_id: z.number(), +}); \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_schemas/TCensecNaturezaLitigioSchema.ts b/src/app/(protected)/(cadastros)/cadastros/_schemas/TCensecNaturezaLitigioSchema.ts new file mode 100644 index 0000000..b4a293d --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_schemas/TCensecNaturezaLitigioSchema.ts @@ -0,0 +1,7 @@ +import { z } from 'zod'; + +export const TCensecNaturezaLitigioSchema = z.object({ + censec_naturezalitigio_id: z.number().optional(), + descricao: z.string(), + situacao: z.enum(['A', 'I']), +}); \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_schemas/TCensecSchema.ts b/src/app/(protected)/(cadastros)/cadastros/_schemas/TCensecSchema.ts new file mode 100644 index 0000000..a9d0aa4 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_schemas/TCensecSchema.ts @@ -0,0 +1,7 @@ +import z from "zod"; + +export const TCensecSchema = z.object({ + censec_id: z.number().optional(), + descricao: z.string().min(1, "O campo deve ser preenchido").max(60, "O campo excedeu o limite de 60 caracteres"), + situacao: z.string().min(1, "O campo deve ser preenchido").max(10, "O campo excedeu o limite de 10 caracteres"), +}); \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_schemas/TMinutaSchema.ts b/src/app/(protected)/(cadastros)/cadastros/_schemas/TMinutaSchema.ts new file mode 100644 index 0000000..7177819 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_schemas/TMinutaSchema.ts @@ -0,0 +1,9 @@ +import { z } from "zod"; + +export const TMinutaSchema = z.object({ + minuta_id: z.number().optional(), + natureza_id: z.number().int(), + descricao: z.string().min(1, "Descrição é obrigatória"), + situacao: z.enum(["A", "I"]), + texto: z.string().min(1, "Texto é obrigatório"), +}); diff --git a/src/app/(protected)/(cadastros)/cadastros/_schemas/TTBAndamentoServicoSchema.ts b/src/app/(protected)/(cadastros)/cadastros/_schemas/TTBAndamentoServicoSchema.ts new file mode 100644 index 0000000..4677fdf --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_schemas/TTBAndamentoServicoSchema.ts @@ -0,0 +1,12 @@ +import { z } from 'zod'; +import { tipoEnum } from '../_interfaces/TTBAndamentoServicoInterface'; + +export const TTBAndamentoServicoSchema = z.object({ + + tb_andamentoservico_id: z.number().optional(), + descricao: z.string().min(1, "Descrição Obrigatória"), + situacao: z.string().min(1, "Situação Obrigatória"), + tipo: z.nativeEnum(tipoEnum, { message: "Tipo inválido" }), + usa_email: z.string().min(1, "Email Obrigatória"), + +}); \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_schemas/TTBReconhecimentoTipoSchema.ts b/src/app/(protected)/(cadastros)/cadastros/_schemas/TTBReconhecimentoTipoSchema.ts new file mode 100644 index 0000000..f9c8f27 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_schemas/TTBReconhecimentoTipoSchema.ts @@ -0,0 +1,8 @@ +import { z } from 'zod'; +import { situacaoEnum } from '../_interfaces/TTBReconhecimentoTipoInterface'; + +export const TTBReconhecimentoTipoSchema = z.object({ + tb_reconhecimentotipo_id: z.number().optional(), + descricao: z.string().min(1, "Campo descrição deve ser preenchido"), + situacao: z.nativeEnum(situacaoEnum, { message: "Tipo inválido" }), +}); \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_services/g_medidatipo/GMedidaTipoIndexService.ts b/src/app/(protected)/(cadastros)/cadastros/_services/g_medidatipo/GMedidaTipoIndexService.ts new file mode 100644 index 0000000..e12ceba --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_services/g_medidatipo/GMedidaTipoIndexService.ts @@ -0,0 +1,12 @@ +import GMedidaTipoIndexData from "../../_data/GMedidoTipo/GMedidaTipoIndexData"; + +export default async function GMedidaTipoIndexService() { + + try { + const response = await GMedidaTipoIndexData(); + return response; + } catch (error) { + console.log(error) + return error + } +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_services/g_medidatipo/GMedidaTipoRemoveService.ts b/src/app/(protected)/(cadastros)/cadastros/_services/g_medidatipo/GMedidaTipoRemoveService.ts new file mode 100644 index 0000000..2a98f69 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_services/g_medidatipo/GMedidaTipoRemoveService.ts @@ -0,0 +1,10 @@ +import GMedidaTipoRemoveData from "../../_data/GMedidoTipo/GMedidaTipoRemoveData"; +import { GMedidaTipoInterface } from "../../_interfaces/GMedidaTipoInterface"; + +export default async function GMedidaTipoRemoveService(data: GMedidaTipoInterface) { + + const response = await GMedidaTipoRemoveData(data); + + return response; + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_services/g_medidatipo/GMedidaTipoSaveService.ts b/src/app/(protected)/(cadastros)/cadastros/_services/g_medidatipo/GMedidaTipoSaveService.ts new file mode 100644 index 0000000..c6f3460 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_services/g_medidatipo/GMedidaTipoSaveService.ts @@ -0,0 +1,12 @@ +import GMedidaTipoSaveData from "../../_data/GMedidoTipo/GMedidaTipoSaveData"; +import { GMedidaTipoInterface } from "../../_interfaces/GMedidaTipoInterface"; + +export default async function GMedidaTipoSaveService(data: GMedidaTipoInterface) { + + const response = await GMedidaTipoSaveData(data); + + console.log('GTBRegimeComunhaoSaveData', response) + + return response; + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_services/g_tb_bairro/GTBBairroIndexService.ts b/src/app/(protected)/(cadastros)/cadastros/_services/g_tb_bairro/GTBBairroIndexService.ts new file mode 100644 index 0000000..a58e999 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_services/g_tb_bairro/GTBBairroIndexService.ts @@ -0,0 +1,8 @@ +import GTBBairroIndexData from "../../_data/GTBBairro/GTBBairroIndexData"; + +export default async function GTBBairroIndexService() { + + const response = await GTBBairroIndexData(); + return response; + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_services/g_tb_bairro/GTBBairroRemoveService.ts b/src/app/(protected)/(cadastros)/cadastros/_services/g_tb_bairro/GTBBairroRemoveService.ts new file mode 100644 index 0000000..59bbe42 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_services/g_tb_bairro/GTBBairroRemoveService.ts @@ -0,0 +1,10 @@ +import GTBBairroRemoveData from "../../_data/GTBBairro/GTBBairroRemoveData"; +import { GTBBairroInterface } from "../../_interfaces/GTBBairroInterface"; + +export default async function GTBBairroRemoveService(data: GTBBairroInterface) { + + const response = await GTBBairroRemoveData(data); + + return response; + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_services/g_tb_bairro/GTBBairroSaveService.ts b/src/app/(protected)/(cadastros)/cadastros/_services/g_tb_bairro/GTBBairroSaveService.ts new file mode 100644 index 0000000..d37c2a2 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_services/g_tb_bairro/GTBBairroSaveService.ts @@ -0,0 +1,10 @@ +import GTBBairroSaveData from "../../_data/GTBBairro/GTBBairroSaveData"; +import { GTBBairroInterface } from "../../_interfaces/GTBBairroInterface"; + +export default async function GTBBairroSaveService(data: GTBBairroInterface) { + + const response = await GTBBairroSaveData(data); + + return response; + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_services/g_tb_estadocivil/GTBEstadoCivilIndexService.ts b/src/app/(protected)/(cadastros)/cadastros/_services/g_tb_estadocivil/GTBEstadoCivilIndexService.ts new file mode 100644 index 0000000..11c0b1d --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_services/g_tb_estadocivil/GTBEstadoCivilIndexService.ts @@ -0,0 +1,12 @@ +import GTBEstadoCivilIndexData from "../../_data/GTBEstadoCivil/GTBEstadoCivilIndexData"; + +export default async function GTBEstadoCivilIndexService() { + + try { + const response = await GTBEstadoCivilIndexData(); + return response; + } catch (error) { + console.log(error) + return error + } +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_services/g_tb_estadocivil/GTBEstadoCivilRemoveService.ts b/src/app/(protected)/(cadastros)/cadastros/_services/g_tb_estadocivil/GTBEstadoCivilRemoveService.ts new file mode 100644 index 0000000..4c19f10 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_services/g_tb_estadocivil/GTBEstadoCivilRemoveService.ts @@ -0,0 +1,10 @@ +import GTBEstadoCivilSaveData from "../../_data/GTBEstadoCivil/GTBEstadoCivilSaveData"; +import { GTBEstadoCivilInterface } from "../../_interfaces/GTBEstadoCivilInterface"; + +export default async function GTBEstadoCivilRemoveService(data: GTBEstadoCivilInterface) { + + const response = await GTBEstadoCivilSaveData(data); + + return response; + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_services/g_tb_estadocivil/GTBEstadoCivilSaveService.ts b/src/app/(protected)/(cadastros)/cadastros/_services/g_tb_estadocivil/GTBEstadoCivilSaveService.ts new file mode 100644 index 0000000..0567d52 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_services/g_tb_estadocivil/GTBEstadoCivilSaveService.ts @@ -0,0 +1,12 @@ +import GTBEstadoCivilSaveData from "../../_data/GTBEstadoCivil/GTBEstadoCivilSaveData"; +import { GTBEstadoCivilInterface } from "../../_interfaces/GTBEstadoCivilInterface"; + +export default async function GTBEstadoCivilSaveService(data: GTBEstadoCivilInterface) { + + const response = await GTBEstadoCivilSaveData(data); + + console.log('GTBRegimeComunhaoSaveData', response) + + return response; + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_services/g_tb_profissao/GTBProfissaoIndexService.ts b/src/app/(protected)/(cadastros)/cadastros/_services/g_tb_profissao/GTBProfissaoIndexService.ts new file mode 100644 index 0000000..8170fd7 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_services/g_tb_profissao/GTBProfissaoIndexService.ts @@ -0,0 +1,9 @@ +import GTBProfissoesIndexData from "../../_data/GTBProfissao/GTBProfissaoIndexData"; + +export default async function GTBProfissaoIndexService() { + + const response = await GTBProfissoesIndexData(); + + return response; + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_services/g_tb_profissao/GTBProfissaoRemoveService.ts b/src/app/(protected)/(cadastros)/cadastros/_services/g_tb_profissao/GTBProfissaoRemoveService.ts new file mode 100644 index 0000000..8e2ebb0 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_services/g_tb_profissao/GTBProfissaoRemoveService.ts @@ -0,0 +1,10 @@ +import GTBProfissaoRemoveData from "../../_data/GTBProfissao/GTBProfissaoRemoveData"; +import GTBProfissaoInterface from "../../_interfaces/GTBProfissaoInterface"; + +export default async function GTBProfissaoRemoveService(data: GTBProfissaoInterface) { + + const response = await GTBProfissaoRemoveData(data); + + return response; + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_services/g_tb_profissao/GTBProfissaoSaveService.ts b/src/app/(protected)/(cadastros)/cadastros/_services/g_tb_profissao/GTBProfissaoSaveService.ts new file mode 100644 index 0000000..4d9e9b9 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_services/g_tb_profissao/GTBProfissaoSaveService.ts @@ -0,0 +1,12 @@ +import GTBProfissaoSaveData from "../../_data/GTBProfissao/GTBProfissaoSaveData"; +import GTBProfissaoInterface from "../../_interfaces/GTBProfissaoInterface"; + +export default async function GTProfissaoSaveService(data: GTBProfissaoInterface) { + + const response = await GTBProfissaoSaveData(data); + + console.log('GTBRegimeComunhaoSaveData', response) + + return response; + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_services/g_tb_regimebens/GTBRegimeBensIndexService.ts b/src/app/(protected)/(cadastros)/cadastros/_services/g_tb_regimebens/GTBRegimeBensIndexService.ts new file mode 100644 index 0000000..b57f1f1 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_services/g_tb_regimebens/GTBRegimeBensIndexService.ts @@ -0,0 +1,9 @@ +import GTBRegimeBensIndexData from "../../_data/GTBRegimeBens/GTBRegimeBensIndexData"; + +export default async function GTBRegimeBensIndexService() { + + const response = await GTBRegimeBensIndexData(); + + return response; + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_services/g_tb_regimebens/GTBRegimeBensRemoveService.ts b/src/app/(protected)/(cadastros)/cadastros/_services/g_tb_regimebens/GTBRegimeBensRemoveService.ts new file mode 100644 index 0000000..b194991 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_services/g_tb_regimebens/GTBRegimeBensRemoveService.ts @@ -0,0 +1,10 @@ +import GTBRegimeBensRemoveData from "../../_data/GTBRegimeBens/GTBRegimeBensRemoveData"; +import GTBRegimeBensInterface from "../../_interfaces/GTBRegimeBensInterface"; + +export default async function GTBRegimeBensRemoveService(data: GTBRegimeBensInterface) { + + const response = await GTBRegimeBensRemoveData(data); + + return response; + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_services/g_tb_regimebens/GTBRegimeBensSaveService.ts b/src/app/(protected)/(cadastros)/cadastros/_services/g_tb_regimebens/GTBRegimeBensSaveService.ts new file mode 100644 index 0000000..cf8cefa --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_services/g_tb_regimebens/GTBRegimeBensSaveService.ts @@ -0,0 +1,14 @@ +import { GTBRegimeBensSaveData } from "../../_data/GTBRegimeBens/GTBRegimeBensSaveData"; +import GTBRegimeBensInterface from "../../_interfaces/GTBRegimeBensInterface"; +import { withClientErrorHandler } from "@/actions/withClientErrorHandler/withClientErrorHandler"; + +async function executeGTBRegimeBensSaveService(data: GTBRegimeBensInterface) { + + const response = await GTBRegimeBensSaveData(data); + + return response; + +} + +// Executa a função de forma encapsulada +export const GTBRegimeBensSaveService = withClientErrorHandler(executeGTBRegimeBensSaveService); \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_services/g_tb_regimecomunhao/GTBRegimeComunhaoIndexService.ts b/src/app/(protected)/(cadastros)/cadastros/_services/g_tb_regimecomunhao/GTBRegimeComunhaoIndexService.ts new file mode 100644 index 0000000..f23ded7 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_services/g_tb_regimecomunhao/GTBRegimeComunhaoIndexService.ts @@ -0,0 +1,9 @@ +import GTBRegimeComunhaoIndexData from "../../_data/GTRegimeComunhao/GTBRegimeComunhaoIndexData"; + +export default async function GTBRegimeComunhaoIndexService() { + + const response = await GTBRegimeComunhaoIndexData(); + + return response; + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_services/g_tb_regimecomunhao/GTBRegimeComunhaoRemoveService.ts b/src/app/(protected)/(cadastros)/cadastros/_services/g_tb_regimecomunhao/GTBRegimeComunhaoRemoveService.ts new file mode 100644 index 0000000..06bec9b --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_services/g_tb_regimecomunhao/GTBRegimeComunhaoRemoveService.ts @@ -0,0 +1,10 @@ +import GTBRegimeComunhaoRemoveData from "../../_data/GTRegimeComunhao/GTBRegimeComunhaoRemoveData"; +import GTBRegimeComunhaoInterface from "../../_interfaces/GTBRegimeComunhaoInterface"; + +export default async function GTBRegimeComunhaoRemoveService(data: GTBRegimeComunhaoInterface) { + + const response = await GTBRegimeComunhaoRemoveData(data); + + return response; + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_services/g_tb_regimecomunhao/GTBRegimeComunhaoSaveService.ts b/src/app/(protected)/(cadastros)/cadastros/_services/g_tb_regimecomunhao/GTBRegimeComunhaoSaveService.ts new file mode 100644 index 0000000..f81e5c9 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_services/g_tb_regimecomunhao/GTBRegimeComunhaoSaveService.ts @@ -0,0 +1,10 @@ +import GTBRegimeComunhaoSaveData from "../../_data/GTRegimeComunhao/GTBRegimeComunhaoSaveData"; +import GTBRegimeComunhaoInterface from "../../_interfaces/GTBRegimeComunhaoInterface"; + +export default async function GTBRegimeComunhaoSaveService(data: GTBRegimeComunhaoInterface) { + + const response = await GTBRegimeComunhaoSaveData(data); + + return response; + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_services/g_tb_tipologradouro/GTBTipoLogradouroIndexService.ts b/src/app/(protected)/(cadastros)/cadastros/_services/g_tb_tipologradouro/GTBTipoLogradouroIndexService.ts new file mode 100644 index 0000000..1eb7666 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_services/g_tb_tipologradouro/GTBTipoLogradouroIndexService.ts @@ -0,0 +1,12 @@ +import GTBTipoLogradouroIndexData from "../../_data/GTBTipoLogradouro/GTBTipoLogradouroIndexData"; + +export default async function GTBTipoLogradouroIndexService() { + + try { + const response = await GTBTipoLogradouroIndexData(); + return response; + } catch (error) { + console.log(error) + return error + } +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_services/g_tb_tipologradouro/GTBTipoLogradouroRemoveService.ts b/src/app/(protected)/(cadastros)/cadastros/_services/g_tb_tipologradouro/GTBTipoLogradouroRemoveService.ts new file mode 100644 index 0000000..2fca163 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_services/g_tb_tipologradouro/GTBTipoLogradouroRemoveService.ts @@ -0,0 +1,10 @@ +import GTBTipoLogradouroRemoveData from "../../_data/GTBTipoLogradouro/GTBTipoLogradouroRemoveData"; +import { GTBTipoLogradouroInterface } from "../../_interfaces/GTBTipoLogradouroInterface"; + +export default async function GTBTipoLogradouroRemoveService(data: GTBTipoLogradouroInterface) { + + const response = await GTBTipoLogradouroRemoveData(data); + + return response; + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_services/g_tb_tipologradouro/GTBTipoLogradouroSaveService.ts b/src/app/(protected)/(cadastros)/cadastros/_services/g_tb_tipologradouro/GTBTipoLogradouroSaveService.ts new file mode 100644 index 0000000..ce514bc --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_services/g_tb_tipologradouro/GTBTipoLogradouroSaveService.ts @@ -0,0 +1,12 @@ +import GTBTipoLogradouroSaveData from "../../_data/GTBTipoLogradouro/GTBTipoLogradouroSaveData"; +import { GTBTipoLogradouroInterface } from "../../_interfaces/GTBTipoLogradouroInterface"; + +export default async function GTBTipoLogradouroSaveService(data: GTBTipoLogradouroInterface) { + + const response = await GTBTipoLogradouroSaveData(data); + + console.log('GTBTipoLogradouroSaveData', response) + + return response; + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_services/t_censec/TCensecDeleteService.ts b/src/app/(protected)/(cadastros)/cadastros/_services/t_censec/TCensecDeleteService.ts new file mode 100644 index 0000000..8a12cad --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_services/t_censec/TCensecDeleteService.ts @@ -0,0 +1,13 @@ +import { withClientErrorHandler } from "@/actions/withClientErrorHandler/withClientErrorHandler"; +import { TCensecDeleteData } from "../../_data/TCensec/TCensecDeleteData"; +import TCensecInterface from "../../_interfaces/TCensecInterface"; + +async function executeTCensecDeleteService(data: TCensecInterface) { + + const response = await TCensecDeleteData(data); + + return response; + +} + +export const TCensecDeleteService = withClientErrorHandler(executeTCensecDeleteService); \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_services/t_censec/TCensecIndexService.ts b/src/app/(protected)/(cadastros)/cadastros/_services/t_censec/TCensecIndexService.ts new file mode 100644 index 0000000..7909527 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_services/t_censec/TCensecIndexService.ts @@ -0,0 +1,12 @@ +import { withClientErrorHandler } from "@/actions/withClientErrorHandler/withClientErrorHandler"; +import { TCensecIndexData } from "../../_data/TCensec/TCensecIndexData"; + +export default async function executeTCensecIndexService() { + + const response = await TCensecIndexData(); + + return response; + +} + +export const TCensecIndexService = withClientErrorHandler(executeTCensecIndexService); \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_services/t_censec/TCensecSaveService.ts b/src/app/(protected)/(cadastros)/cadastros/_services/t_censec/TCensecSaveService.ts new file mode 100644 index 0000000..f7d1739 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_services/t_censec/TCensecSaveService.ts @@ -0,0 +1,13 @@ +import { withClientErrorHandler } from "@/actions/withClientErrorHandler/withClientErrorHandler"; +import { TCensecSaveData } from "../../_data/TCensec/TCensecSaveData"; +import TCensecInterface from "../../_interfaces/TCensecInterface"; + +async function executeTCensecSaveService(data: TCensecInterface) { + + const response = await TCensecSaveData(data); + + return response; + +} + +export const TCensecSaveService = withClientErrorHandler(executeTCensecSaveService); \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_services/t_censecnaturezalitigio/TCensecNaturezaLitigioIndexService.ts b/src/app/(protected)/(cadastros)/cadastros/_services/t_censecnaturezalitigio/TCensecNaturezaLitigioIndexService.ts new file mode 100644 index 0000000..2b6bacc --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_services/t_censecnaturezalitigio/TCensecNaturezaLitigioIndexService.ts @@ -0,0 +1,12 @@ +import TCensecNaturezaLitigioIndexData from "../../_data/TCensecNaturezaLitigio/TCensecNaturezaLitigioIndexData"; + +export default async function TCensecNaturezaLitigioIndexService() { + + try { + const response = await TCensecNaturezaLitigioIndexData(); + return response; + } catch (error) { + console.log(error) + return error + } +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_services/t_censecnaturezalitigio/TCensecNaturezaLitigioRemoveService.ts b/src/app/(protected)/(cadastros)/cadastros/_services/t_censecnaturezalitigio/TCensecNaturezaLitigioRemoveService.ts new file mode 100644 index 0000000..9530497 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_services/t_censecnaturezalitigio/TCensecNaturezaLitigioRemoveService.ts @@ -0,0 +1,10 @@ +import TCensecNaturezaLitigioRemoveData from "../../_data/TCensecNaturezaLitigio/TCensecNaturezaLitigioRemoveData"; +import { TCensecNaturezaLitigioInterface } from "../../_interfaces/TCensecNaturezaLitigioInterface"; + +export default async function TCensecNaturezaLitigioRemoveService(data: TCensecNaturezaLitigioInterface) { + + const response = await TCensecNaturezaLitigioRemoveData(data); + + return response; + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_services/t_censecnaturezalitigio/TCensecNaturezaLitigioSaveService.ts b/src/app/(protected)/(cadastros)/cadastros/_services/t_censecnaturezalitigio/TCensecNaturezaLitigioSaveService.ts new file mode 100644 index 0000000..1f063c2 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_services/t_censecnaturezalitigio/TCensecNaturezaLitigioSaveService.ts @@ -0,0 +1,10 @@ +import TCensecNaturezaLitigioSaveData from "../../_data/TCensecNaturezaLitigio/TCensecNaturezaLitigioSaveData"; +import { TCensecNaturezaLitigioInterface } from "../../_interfaces/TCensecNaturezaLitigioInterface"; + +export default async function TCensecNaturezaLitigioSaveService(data: TCensecNaturezaLitigioInterface) { + + const response = await TCensecNaturezaLitigioSaveData(data); + + return response; + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_services/t_minuta/TMinutaIndex.ts b/src/app/(protected)/(cadastros)/cadastros/_services/t_minuta/TMinutaIndex.ts new file mode 100644 index 0000000..5038a30 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_services/t_minuta/TMinutaIndex.ts @@ -0,0 +1,13 @@ +import TMinutaIndexData from "../../_data/TMinuta/TMinutaIndexData"; +import { TMinutaInterface } from "../../_interfaces/TMinutaInterface"; + +export default async function TMinutaIndex() { + + try { + const response = await TMinutaIndexData(); + return response; + } catch (error) { + console.log(error) + return error + } +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_services/t_minuta/TMinutaIndexService.ts b/src/app/(protected)/(cadastros)/cadastros/_services/t_minuta/TMinutaIndexService.ts new file mode 100644 index 0000000..00fe3d2 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_services/t_minuta/TMinutaIndexService.ts @@ -0,0 +1,21 @@ +import TMinutaIndex from "../../_data/TMinuta/TMinutaIndex"; +import { TMinutaInterface } from "../../_interfaces/TMinutaInterface"; + +export default async function TMinutaIndexService(t_minuta_id: number) { + + if (t_minuta_id <= 0) { + return { + 'code': 400, + 'message': 'Usuário informado inválido', + } + } + + try { + const response = await TMinutaIndex(t_minuta_id); + console.log("service",response) + return response; + } catch (error) { + console.log(error) + return error + } +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_services/t_minuta/TMinutaRemoveService.ts b/src/app/(protected)/(cadastros)/cadastros/_services/t_minuta/TMinutaRemoveService.ts new file mode 100644 index 0000000..12ed281 --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_services/t_minuta/TMinutaRemoveService.ts @@ -0,0 +1,10 @@ +import TMinutaRemoveData from "../../_data/TMinuta/TMinutaRemoveData"; +import { TMinutaInterface } from "../../_interfaces/TMinutaInterface"; + +export default async function TMinutaRemoveService(data: TMinutaInterface) { + + const response = await TMinutaRemoveData(data); + + return response; + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_services/t_minuta/TMinutaSaveService.ts b/src/app/(protected)/(cadastros)/cadastros/_services/t_minuta/TMinutaSaveService.ts new file mode 100644 index 0000000..5dfc53f --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/_services/t_minuta/TMinutaSaveService.ts @@ -0,0 +1,10 @@ +import TMinutaSaveData from "../../_data/TMinuta/TMinutaSaveData"; +import { TMinutaInterface } from "../../_interfaces/TMinutaInterface"; + +export default async function TMinutaSaveService(data: TMinutaInterface) { + + const response = await TMinutaSaveData(data); + + return response; + +} \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/pessoas/complementos/page.tsx b/src/app/(protected)/(cadastros)/cadastros/pessoas/complementos/page.tsx new file mode 100644 index 0000000..5dc31bb --- /dev/null +++ b/src/app/(protected)/(cadastros)/cadastros/pessoas/complementos/page.tsx @@ -0,0 +1,73 @@ +import { FileText, Heart, Briefcase, Scale, Link as LinkIcon, MapPin } from "lucide-react"; +import { Card, CardContent } from "@/components/ui/card"; +import Link from "next/link"; + +export default function CadastrosPage() { + + const items = [ + { + title: 'Documentos', + description: 'Gerencie os tipos de documentos aceitos e suas configurações no sistema.', + icon: FileText, + }, + { + title: 'Estado Civil', + description: 'Cadastre e mantenha os diferentes estados civis utilizados nos registros.', + icon: Heart, + }, + { + title: 'Profissão', + description: 'Gerencie a lista de profissões para utilização em cadastros e registros.', + icon: Briefcase, + }, + { + title: 'Regime de Comunhão', + description: 'Defina os regimes de comunhão aplicáveis em matrimônios e registros civis.', + icon: Scale, + }, + { + title: 'Vínculo de Sinal Público', + description: 'Controle e cadastre vínculos relacionados a sinais públicos para autenticações.', + icon: LinkIcon, + }, + { + title: 'Municípios', + description: 'Gerencie a base de municípios para utilização em endereços e cadastros.', + icon: MapPin, + }, + ]; + + return ( +
+
+
+

+ Complementos de Cadastro pessoal +

+

+ Gerencie os cadastros relacionados a regimes, como estado civil, regime de comunhão e outras informações complementares necessárias para o registro de pessoas. +

+
+
+
+ {items.map((item, key) => ( + + + + + + +

+ {item.title} +

+

+ {item.description} +

+
+
+ + ))} +
+
+ ); +} \ No newline at end of file diff --git a/src/app/(protected)/(servicos)/servicos/page.tsx b/src/app/(protected)/(servicos)/servicos/page.tsx new file mode 100644 index 0000000..ebfcd9d --- /dev/null +++ b/src/app/(protected)/(servicos)/servicos/page.tsx @@ -0,0 +1,88 @@ +'use client' + +import { Card, CardAction, CardContent, CardDescription, CardTitle } from "@/components/ui/card" +import { BabyIcon, CrossIcon, FileCheckIcon, FileTextIcon, GavelIcon, GlobeIcon, HeartIcon, PenIcon, ScrollIcon, UsersIcon } from "lucide-react"; + +const services = [ + { + title: 'Registro de Nascimento', + description: 'Emissão e registro de certidões de nascimento, garantindo a cidadania e identidade legal do recém-nascido.', + icon: BabyIcon + }, + { + title: 'Registro de Casamento', + description: 'Processo completo para habilitação, registro e emissão da certidão de casamento.', + icon: HeartIcon + }, + { + title: 'Registro de Óbito', + description: 'Lavratura do registro de óbito e emissão da certidão correspondente para fins legais.', + icon: CrossIcon + }, + { + title: 'Reconhecimento de Firma', + description: 'Autenticação da assinatura de documentos, garantindo sua validade jurídica.', + icon: PenIcon + }, + { + title: 'Autenticação de Documentos', + description: 'Confirmação de que cópias estão de acordo com o documento original apresentado.', + icon: FileCheckIcon + }, + { + title: 'Procurações', + description: 'Elaboração e registro de procurações públicas para representação legal de pessoas físicas ou jurídicas.', + icon: ScrollIcon + }, + { + title: 'Testamentos', + description: 'Lavratura e registro de testamentos públicos com segurança jurídica.', + icon: GavelIcon + }, + { + title: 'Divórcio Extrajudicial', + description: 'Formalização do divórcio por via administrativa, de forma rápida e sem processo judicial.', + icon: UsersIcon + }, + { + title: 'Apostilamento de Documentos', + description: 'Apostilamento conforme a Convenção da Haia para validade internacional de documentos.', + icon: GlobeIcon + }, + { + title: 'Certidões e Segunda Via', + description: 'Emissão de segundas vias e certidões de nascimento, casamento e óbito.', + icon: FileTextIcon + } +]; + +export default function ServicosPage() { + return ( +
+
+

Bem-vindo(a)!

+

+ Olá, Keven! É um prazer ter você conosco. +

+
+
+ {services.map((item: any, index) => ( + + +
+ +
+ + + {item.title} + + + {item.description} + +
+
+ ))} +
+
+ ) +} \ No newline at end of file diff --git a/src/app/(protected)/layout.tsx b/src/app/(protected)/layout.tsx index 0ca9fb4..982240e 100644 --- a/src/app/(protected)/layout.tsx +++ b/src/app/(protected)/layout.tsx @@ -49,7 +49,7 @@ export default function RootLayout({ -
+
{children} - +
diff --git a/src/app/_components/confirm_dialog/ConfirmDialog.tsx b/src/app/_components/confirm_dialog/ConfirmDialog.tsx new file mode 100644 index 0000000..e24cfd3 --- /dev/null +++ b/src/app/_components/confirm_dialog/ConfirmDialog.tsx @@ -0,0 +1,81 @@ +'use client'; + +import React from 'react'; + +// Shadcn UI components +import { + AlertDialog, + AlertDialogCancel, + AlertDialogContent, + AlertDialogDescription, + AlertDialogFooter, + AlertDialogHeader, + AlertDialogTitle, + AlertDialogAction, +} from '@/components/ui/alert-dialog'; + +interface AlertProps { + /** Controla a abertura do modal */ + isOpen: boolean; + + /** Título principal do alerta */ + title: string; + + /** Descrição adicional do alerta */ + description?: string; + + /** Mensagem do corpo do alerta */ + message: string; + + /** Texto do botão de confirmação */ + confirmText?: string; + + /** Texto do botão de cancelamento */ + cancelText?: string; + + /** Função executada ao confirmar */ + onConfirm: () => void; + + /** Função executada ao cancelar */ + onCancel: () => void; +} + +/** + * Componente de alerta genérico e reutilizável. + * Baseado no Radix e Shadcn UI, com suporte a título, descrição, + * mensagem e botões de ação customizáveis. + */ +export default function ConfirmDialog({ + isOpen, + title, + description, + message, + confirmText = 'Confirmar', + cancelText = 'Cancelar', + onConfirm, + onCancel, +}: AlertProps) { + return ( + + + + {title} + {description && ( + {description} + )} + +
+ {message} +
+ + + {cancelText} + + + {confirmText} + + +
+
+ ); +} diff --git a/src/app/_components/confirm_dialog/useConfirmDialog.ts b/src/app/_components/confirm_dialog/useConfirmDialog.ts new file mode 100644 index 0000000..55afbc6 --- /dev/null +++ b/src/app/_components/confirm_dialog/useConfirmDialog.ts @@ -0,0 +1,51 @@ +// Importa os hooks useCallback e useState do React +import { useCallback, useState } from "react"; + +// Define a interface para opções do hook +// Permite que o usuário passe callbacks opcionais para confirmação e cancelamento +interface UseConfirmDialogOptions { + onConfirm?: () => void; // Função chamada quando o usuário confirma a ação + onCancel?: () => void; // Função chamada quando o usuário cancela a ação +} + +// Declara o hook customizado useConfirmDialog +// Recebe um objeto de opções que contém os callbacks onConfirm e onCancel +export function useConfirmDialog({ onConfirm, onCancel }: UseConfirmDialogOptions = {}) { + // Estado interno que controla se o diálogo de confirmação está aberto + const [isOpen, setIsOpen] = useState(false); + + // Função para abrir o diálogo + // useCallback memoriza a função para que não seja recriada em cada renderização + const openDialog = useCallback(() => setIsOpen(true), []); + + // Função para fechar o diálogo + const closeDialog = useCallback(() => setIsOpen(false), []); + + // Função chamada quando o usuário confirma a ação + // Executa o callback onConfirm, se fornecido, e fecha o diálogo + const handleConfirm = useCallback(() => { + onConfirm?.(); // Chama onConfirm somente se ele existir + closeDialog(); // Fecha o diálogo após a confirmação + }, [onConfirm, closeDialog]); + + // Função chamada quando o usuário cancela a ação + // Executa o callback onCancel, se fornecido, e fecha o diálogo + const handleCancel = useCallback(() => { + onCancel?.(); // Chama onCancel somente se ele existir + closeDialog(); // Fecha o diálogo após o cancelamento + }, [onCancel, closeDialog]); + + // Retorna os valores e funções que serão usados pelo componente + // isOpen -> estado do modal + // openDialog -> função para abrir o modal + // closeDialog -> função para fechar o modal + // handleConfirm -> função para confirmar a ação + // handleCancel -> função para cancelar a ação + return { + isOpen, + openDialog, + closeDialog, + handleConfirm, + handleCancel, + }; +} diff --git a/src/app/_components/loadingButton/LoadingButton.tsx b/src/app/_components/loadingButton/LoadingButton.tsx index e334b8b..3c890c4 100644 --- a/src/app/_components/loadingButton/LoadingButton.tsx +++ b/src/app/_components/loadingButton/LoadingButton.tsx @@ -15,7 +15,7 @@ const LoadingButton = forwardRef( aria-busy={loading} aria-live="polite" className={clsx( - "flex items-center justify-center gap-2 w-full my-3 cursor-pointer", + "cursor-pointer", className )} {...props} diff --git a/src/app/_components/structure/Header.tsx b/src/app/_components/structure/Header.tsx new file mode 100644 index 0000000..c8c02e6 --- /dev/null +++ b/src/app/_components/structure/Header.tsx @@ -0,0 +1,33 @@ +import { Button } from "@/components/ui/button"; +import { PlusIcon } from "lucide-react"; + +interface HeaderProps { + + title: string, + description: string, + buttonText: string, + buttonAction: (...args: any[]) => void; +}; + +export default function Header({ title, description, buttonText, buttonAction }: HeaderProps) { + + return ( +
+
+
+

+ {title} +

+

+ {description} +

+
+ +
+
+ ); + +} \ No newline at end of file diff --git a/src/app/_response/ResponseContext.tsx b/src/app/_response/ResponseContext.tsx index f356b31..b387176 100644 --- a/src/app/_response/ResponseContext.tsx +++ b/src/app/_response/ResponseContext.tsx @@ -3,9 +3,11 @@ import React, { createContext, useContext, useState, ReactNode } from 'react'; interface ResponseState { - message: string; - type: 'toast' | 'modal' | 'alert' | null; - status: number; + message?: string; + type?: 'toast' | 'modal' | 'alert' | null; + status?: number; + error?: string; + detail?: string; } interface ResponseContextProps { @@ -17,10 +19,10 @@ interface ResponseContextProps { const ResponseContext = createContext(undefined); export const ResponseProvider: React.FC<{ children: ReactNode }> = ({ children }) => { - const [response, setResponseState] = useState({ message: '', type: null, status : 0}); + const [response, setResponseState] = useState({ message: '', type: null, status: 0 }); const setResponse = (value: ResponseState) => setResponseState(value); - const clearResponse = () => setResponseState({ message: '', type: null, status : 0}); + const clearResponse = () => setResponseState({ message: '', type: null, status: 0 }); return ( diff --git a/src/app/_response/response.tsx b/src/app/_response/response.tsx index 4a6e245..fad1bec 100644 --- a/src/app/_response/response.tsx +++ b/src/app/_response/response.tsx @@ -1,20 +1,54 @@ // app/src/app/_response/response.tsx "use client"; -import { useResponse } from "./ResponseContext"; -import { useEffect } from "react"; -import { toast } from "sonner"; +import { + useResponse +} from "./ResponseContext"; +import { + useEffect +} from "react"; +import { + toast +} from "sonner"; export default function Response() { - const { response, clearResponse } = useResponse(); + const { + response, + clearResponse + } = useResponse(); useEffect(() => { switch (Number(response?.status)) { - case 200: - toast(response.message); + + case 201: + toast.success(response.message); + break; + + case 422: + toast.error(response.error, { + description: response.detail + }); + break; + + case 400: + toast.error(response.error, { + description: response.message + }); + break; + + case 600: + toast.error(response.error, { + description: response.message + }); + break; + + default: + if (response.status !== 0 && response.status !== 200 && response.status !== 201) { + toast.warning(JSON.stringify(response)); + } break; } }, [response, clearResponse]); return
; -} +} \ No newline at end of file diff --git a/src/app/globals.css b/src/app/globals.css index 7be488e..2b6326b 100644 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -6,8 +6,8 @@ @theme inline { --color-background: var(--background); --color-foreground: var(--foreground); - --font-sans: var(--font-geist-sans); - --font-mono: var(--font-geist-mono); + --font-sans: Inter, sans-serif; + --font-mono: JetBrains Mono, monospace; --color-sidebar-ring: var(--sidebar-ring); --color-sidebar-border: var(--sidebar-border); --color-sidebar-accent-foreground: var(--sidebar-accent-foreground); @@ -41,75 +41,142 @@ --radius-md: calc(var(--radius) - 2px); --radius-lg: var(--radius); --radius-xl: calc(var(--radius) + 4px); + --font-serif: Source Serif 4, serif; + --radius: 0.375rem; + --tracking-tighter: calc(var(--tracking-normal) - 0.05em); + --tracking-tight: calc(var(--tracking-normal) - 0.025em); + --tracking-wide: calc(var(--tracking-normal) + 0.025em); + --tracking-wider: calc(var(--tracking-normal) + 0.05em); + --tracking-widest: calc(var(--tracking-normal) + 0.1em); + --tracking-normal: var(--tracking-normal); + --shadow-2xl: var(--shadow-2xl); + --shadow-xl: var(--shadow-xl); + --shadow-lg: var(--shadow-lg); + --shadow-md: var(--shadow-md); + --shadow: var(--shadow); + --shadow-sm: var(--shadow-sm); + --shadow-xs: var(--shadow-xs); + --shadow-2xs: var(--shadow-2xs); + --spacing: var(--spacing); + --letter-spacing: var(--letter-spacing); + --shadow-offset-y: var(--shadow-offset-y); + --shadow-offset-x: var(--shadow-offset-x); + --shadow-spread: var(--shadow-spread); + --shadow-blur: var(--shadow-blur); + --shadow-opacity: var(--shadow-opacity); + --color-shadow-color: var(--shadow-color); + --color-destructive-foreground: var(--destructive-foreground); } :root { - --radius: 0.625rem; - --background: oklch(1 0 0); - --foreground: oklch(0.145 0 0); - --card: oklch(1 0 0); - --card-foreground: oklch(0.145 0 0); - --popover: oklch(1 0 0); - --popover-foreground: oklch(0.145 0 0); - --primary: oklch(0.205 0 0); - --primary-foreground: oklch(0.985 0 0); - --secondary: oklch(0.97 0 0); - --secondary-foreground: oklch(0.205 0 0); - --muted: oklch(0.97 0 0); - --muted-foreground: oklch(0.556 0 0); - --accent: oklch(0.97 0 0); - --accent-foreground: oklch(0.205 0 0); - --destructive: oklch(0.577 0.245 27.325); - --border: oklch(0.922 0 0); - --input: oklch(0.922 0 0); - --ring: oklch(0.708 0 0); - --chart-1: oklch(0.646 0.222 41.116); - --chart-2: oklch(0.6 0.118 184.704); - --chart-3: oklch(0.398 0.07 227.392); - --chart-4: oklch(0.828 0.189 84.429); - --chart-5: oklch(0.769 0.188 70.08); - --sidebar: oklch(0.985 0 0); - --sidebar-foreground: oklch(0.145 0 0); - --sidebar-primary: oklch(0.205 0 0); - --sidebar-primary-foreground: oklch(0.985 0 0); - --sidebar-accent: oklch(0.97 0 0); - --sidebar-accent-foreground: oklch(0.205 0 0); - --sidebar-border: oklch(0.922 0 0); - --sidebar-ring: oklch(0.708 0 0); + --radius: 0.375rem; + --background: oklch(1.0000 0 0); + --foreground: oklch(0.2686 0 0); + --card: oklch(1.0000 0 0); + --card-foreground: oklch(0.2686 0 0); + --popover: oklch(1.0000 0 0); + --popover-foreground: oklch(0.2686 0 0); + --primary: oklch(0.7686 0.1647 70.0804); + --primary-foreground: oklch(0 0 0); + --secondary: oklch(0.9670 0.0029 264.5419); + --secondary-foreground: oklch(0.4461 0.0263 256.8018); + --muted: oklch(0.9846 0.0017 247.8389); + --muted-foreground: oklch(0.5510 0.0234 264.3637); + --accent: oklch(0.9869 0.0214 95.2774); + --accent-foreground: oklch(0.4732 0.1247 46.2007); + --destructive: oklch(0.6368 0.2078 25.3313); + --border: oklch(0.9276 0.0058 264.5313); + --input: oklch(0.9276 0.0058 264.5313); + --ring: oklch(0.7686 0.1647 70.0804); + --chart-1: oklch(0.7686 0.1647 70.0804); + --chart-2: oklch(0.6658 0.1574 58.3183); + --chart-3: oklch(0.5553 0.1455 48.9975); + --chart-4: oklch(0.4732 0.1247 46.2007); + --chart-5: oklch(0.4137 0.1054 45.9038); + --sidebar: oklch(0.9846 0.0017 247.8389); + --sidebar-foreground: oklch(0.2686 0 0); + --sidebar-primary: oklch(0.7686 0.1647 70.0804); + --sidebar-primary-foreground: oklch(1.0000 0 0); + --sidebar-accent: oklch(0.9869 0.0214 95.2774); + --sidebar-accent-foreground: oklch(0.4732 0.1247 46.2007); + --sidebar-border: oklch(0.9276 0.0058 264.5313); + --sidebar-ring: oklch(0.7686 0.1647 70.0804); + --destructive-foreground: oklch(1.0000 0 0); + --font-sans: Inter, sans-serif; + --font-serif: Source Serif 4, serif; + --font-mono: JetBrains Mono, monospace; + --shadow-color: hsl(0 0% 0%); + --shadow-opacity: 0.1; + --shadow-blur: 8px; + --shadow-spread: -1px; + --shadow-offset-x: 0px; + --shadow-offset-y: 4px; + --letter-spacing: 0em; + --spacing: 0.25rem; + --shadow-2xs: 0px 4px 8px -1px hsl(0 0% 0% / 0.05); + --shadow-xs: 0px 4px 8px -1px hsl(0 0% 0% / 0.05); + --shadow-sm: 0px 4px 8px -1px hsl(0 0% 0% / 0.10), 0px 1px 2px -2px hsl(0 0% 0% / 0.10); + --shadow: 0px 4px 8px -1px hsl(0 0% 0% / 0.10), 0px 1px 2px -2px hsl(0 0% 0% / 0.10); + --shadow-md: 0px 4px 8px -1px hsl(0 0% 0% / 0.10), 0px 2px 4px -2px hsl(0 0% 0% / 0.10); + --shadow-lg: 0px 4px 8px -1px hsl(0 0% 0% / 0.10), 0px 4px 6px -2px hsl(0 0% 0% / 0.10); + --shadow-xl: 0px 4px 8px -1px hsl(0 0% 0% / 0.10), 0px 8px 10px -2px hsl(0 0% 0% / 0.10); + --shadow-2xl: 0px 4px 8px -1px hsl(0 0% 0% / 0.25); + --tracking-normal: 0em; } .dark { - --background: oklch(0.145 0 0); - --foreground: oklch(0.985 0 0); - --card: oklch(0.205 0 0); - --card-foreground: oklch(0.985 0 0); - --popover: oklch(0.205 0 0); - --popover-foreground: oklch(0.985 0 0); - --primary: oklch(0.922 0 0); - --primary-foreground: oklch(0.205 0 0); - --secondary: oklch(0.269 0 0); - --secondary-foreground: oklch(0.985 0 0); - --muted: oklch(0.269 0 0); - --muted-foreground: oklch(0.708 0 0); - --accent: oklch(0.269 0 0); - --accent-foreground: oklch(0.985 0 0); - --destructive: oklch(0.704 0.191 22.216); - --border: oklch(1 0 0 / 10%); - --input: oklch(1 0 0 / 15%); - --ring: oklch(0.556 0 0); - --chart-1: oklch(0.488 0.243 264.376); - --chart-2: oklch(0.696 0.17 162.48); - --chart-3: oklch(0.769 0.188 70.08); - --chart-4: oklch(0.627 0.265 303.9); - --chart-5: oklch(0.645 0.246 16.439); - --sidebar: oklch(0.205 0 0); - --sidebar-foreground: oklch(0.985 0 0); - --sidebar-primary: oklch(0.488 0.243 264.376); - --sidebar-primary-foreground: oklch(0.985 0 0); - --sidebar-accent: oklch(0.269 0 0); - --sidebar-accent-foreground: oklch(0.985 0 0); - --sidebar-border: oklch(1 0 0 / 10%); - --sidebar-ring: oklch(0.556 0 0); + --background: oklch(0.2046 0 0); + --foreground: oklch(0.9219 0 0); + --card: oklch(0.2686 0 0); + --card-foreground: oklch(0.9219 0 0); + --popover: oklch(0.2686 0 0); + --popover-foreground: oklch(0.9219 0 0); + --primary: oklch(0.7686 0.1647 70.0804); + --primary-foreground: oklch(0 0 0); + --secondary: oklch(0.2686 0 0); + --secondary-foreground: oklch(0.9219 0 0); + --muted: oklch(0.2686 0 0); + --muted-foreground: oklch(0.7155 0 0); + --accent: oklch(0.4732 0.1247 46.2007); + --accent-foreground: oklch(0.9243 0.1151 95.7459); + --destructive: oklch(0.6368 0.2078 25.3313); + --border: oklch(0.3715 0 0); + --input: oklch(0.3715 0 0); + --ring: oklch(0.7686 0.1647 70.0804); + --chart-1: oklch(0.8369 0.1644 84.4286); + --chart-2: oklch(0.6658 0.1574 58.3183); + --chart-3: oklch(0.4732 0.1247 46.2007); + --chart-4: oklch(0.5553 0.1455 48.9975); + --chart-5: oklch(0.4732 0.1247 46.2007); + --sidebar: oklch(0.1684 0 0); + --sidebar-foreground: oklch(0.9219 0 0); + --sidebar-primary: oklch(0.7686 0.1647 70.0804); + --sidebar-primary-foreground: oklch(1.0000 0 0); + --sidebar-accent: oklch(0.4732 0.1247 46.2007); + --sidebar-accent-foreground: oklch(0.9243 0.1151 95.7459); + --sidebar-border: oklch(0.3715 0 0); + --sidebar-ring: oklch(0.7686 0.1647 70.0804); + --destructive-foreground: oklch(1.0000 0 0); + --radius: 0.375rem; + --font-sans: Inter, sans-serif; + --font-serif: Source Serif 4, serif; + --font-mono: JetBrains Mono, monospace; + --shadow-color: hsl(0 0% 0%); + --shadow-opacity: 0.1; + --shadow-blur: 8px; + --shadow-spread: -1px; + --shadow-offset-x: 0px; + --shadow-offset-y: 4px; + --letter-spacing: 0em; + --spacing: 0.25rem; + --shadow-2xs: 0px 4px 8px -1px hsl(0 0% 0% / 0.05); + --shadow-xs: 0px 4px 8px -1px hsl(0 0% 0% / 0.05); + --shadow-sm: 0px 4px 8px -1px hsl(0 0% 0% / 0.10), 0px 1px 2px -2px hsl(0 0% 0% / 0.10); + --shadow: 0px 4px 8px -1px hsl(0 0% 0% / 0.10), 0px 1px 2px -2px hsl(0 0% 0% / 0.10); + --shadow-md: 0px 4px 8px -1px hsl(0 0% 0% / 0.10), 0px 2px 4px -2px hsl(0 0% 0% / 0.10); + --shadow-lg: 0px 4px 8px -1px hsl(0 0% 0% / 0.10), 0px 4px 6px -2px hsl(0 0% 0% / 0.10); + --shadow-xl: 0px 4px 8px -1px hsl(0 0% 0% / 0.10), 0px 8px 10px -2px hsl(0 0% 0% / 0.10); + --shadow-2xl: 0px 4px 8px -1px hsl(0 0% 0% / 0.25); } @layer base { @@ -118,8 +185,9 @@ } body { @apply bg-background text-foreground; + letter-spacing: var(--tracking-normal); } .bg-brand{ background-color: #1A292F; } -} +} \ No newline at end of file diff --git a/src/components/MainEditor.tsx b/src/components/MainEditor.tsx new file mode 100644 index 0000000..ab19f59 --- /dev/null +++ b/src/components/MainEditor.tsx @@ -0,0 +1,132 @@ +import React from 'react'; +import { Editor } from '@tinymce/tinymce-react'; + +// 1. Define as propriedades que nosso componente vai receber +interface MainEditorProps { + initialValue: string; + onEditorChange: (content: string) => void; + margins: { + top: string; + bottom: string; + left: string; + right: string; + }; + size: { + width: number; + height: number; + } +} + +const MainEditor: React.FC = ({ initialValue, onEditorChange, margins, size }) => { + + + return ( +
+ { + const customTemplates = [ + { + title: 'Qualificação das Partes (Casamento)', + description: 'Insere o bloco de qualificação para contraentes.', + content: `

QUALIFICAÇÃO DOS CONTRAENTES: Ele, brasileiro, solteiro, maior, [Profissão], portador da CI nº [RG], inscrito no CPF sob o nº [CPF], residente e domiciliado em [Endereço]. Ela, brasileira, solteira, maior, [Profissão], portadora da CI nº [RG], inscrita no CPF sob o nº [CPF], residente e domiciliada em [Endereço].


` + }, + { + title: 'Cláusula de Regime de Bens', + description: 'Cláusula padrão de Comunhão Parcial de Bens.', + content: '

O regime de bens adotado é o da Comunhão Parcial de Bens, nos termos dos artigos 1.658 e seguintes do Código Civil brasileiro.


' + }, + { + title: 'Cláusula de Encerramento (Selo)', + description: 'Texto final com espaço para o selo digital.', + content: '

O referido é verdade e dou fé. Emitida nesta data. Selo Digital de Fiscalização: [Número do Selo]

' + } + ]; + editor.ui.registry.addMenuButton('customTemplates', { + text: 'Modelos', // O texto que aparecerá no botão + fetch: (callback: any) => { + const items = customTemplates.map(template => ({ + type: 'menuitem', + text: template.title, + onAction: () => { + // 3. Ação que acontece ao clicar no item do menu: insere o conteúdo + editor.insertContent(template.content); + } + })); + callback(items); + } + }); + }, + quickbars_selection_toolbar: 'bold italic underline | fontfamily | fontsize | quicklink blockquote | quicklink', + quickbars_insert_toolbar: 'bold italic underline fontfamily fontsize quicklink blockquote quicklink quickimage quicktable hr', + quickbars_image_toolbar: 'alignleft aligncenter alignright | rotateleft rotateright | imageoptions', + fontsize_formats: '4pt 5pt 6pt 7pt 8pt 9pt 10pt 12pt 14pt 16pt 18pt 20pt 22pt 24pt 26pt 28pt 30pt 32pt 34pt 36pt', + font_family_formats: ` Times New Roman=Times New Roman, Times, serif; Arial=Arial, Helvetica, sans-serif; Calibri=Calibri, sans-serif; Courier New=Courier New, Courier, monospace; Georgia=Georgia, serif; Verdana=Verdana, Geneva, sans-serif;`, + fullscreen_native: true, + content_style: ` + body { + font-family: 'Times New Roman', Times, serif; + font-size: 12pt; + background: #fff; + margin: ${margins.top}cm ${margins.right}cm ${margins.bottom}cm ${margins.left}cm; + } + .mce-pagebreak { /* Estiliza a linha da quebra de página no editor */ + border-top: 1px dashed #bbb; + width: 100%; + margin-top: 15px; + cursor: default; + } + + .borda-superior { + border-top: 1px solid #000; + padding-top: 5px; + margin-top: 5px; + } + .borda-inferior { + border-bottom: 1px solid #000; + padding-bottom: 5px; + margin-bottom: 5px; + } + ` + }} + /> +
+ ); +}; + +export default MainEditor; \ No newline at end of file diff --git a/src/components/app-sidebar.tsx b/src/components/app-sidebar.tsx index edf33f8..7d7b71d 100644 --- a/src/components/app-sidebar.tsx +++ b/src/components/app-sidebar.tsx @@ -8,6 +8,7 @@ import { Command, Frame, GalleryVerticalEnd, + House, Map, PieChart, Settings2, @@ -17,22 +18,21 @@ import { import { NavMain } from "@/components/nav-main" import { NavProjects } from "@/components/nav-projects" import { NavUser } from "@/components/nav-user" -import { TeamSwitcher } from "@/components/team-switcher" import { Sidebar, SidebarContent, SidebarFooter, SidebarHeader, + SidebarMenu, + SidebarMenuButton, + SidebarMenuItem, SidebarRail, } from "@/components/ui/sidebar" +import useGUsuarioGetJWTHook from "@/hooks/auth/useGUsuarioGetJWTHook" + // This is sample data. const data = { - user: { - name: "shadcn", - email: "m@example.com", - avatar: "/avatars/shadcn.jpg", - }, teams: [ { name: "Acme Inc", @@ -51,6 +51,18 @@ const data = { }, ], navMain: [ + { + title: "Início", + url: "#", + icon: House, + isActive: false, + items: [ + { + title: "Serviços", + url: "/servicos/", + }, + ], + }, { title: "Administrativo", url: "#", @@ -64,13 +76,33 @@ const data = { ], }, { - title: "Models", + title: "Cadastros", url: "#", icon: Bot, items: [ { - title: "Genesis", - url: "#", + title: "Reconhecimentos", + url: "/cadastros/reconhecimentos/", + }, + { + title: "Andamentos", + url: "/cadastros/andamentos/", + }, + { + title: "Profissões", + url: "/cadastros/profissoes/", + }, + { + title: "Regimes/Bens", + url: "/cadastros/regime-bens/", + }, + { + title: "Tipos de Logradouros", + url: "/cadastros/tipo-logradouro" + }, + { + title: "Bairro", + url: "/cadastros/bairro" }, { title: "Estado Civil", @@ -85,17 +117,33 @@ const data = { url: "/cadastros/censec-natureza-litigio" }, { - title: "Dados Pessoais", + title: "Pessoas", url: "/cadastros/pessoas/complementos/", }, { - title: "Quantum", - url: "#", + title: "Regimes/Bens", + url: "/cadastros/regime-bens/", }, { title: "Regimes/Comunhão", url: "/cadastros/regime-comunhao/", }, + { + title: "Minuta", + url: "/cadastros/minuta/", + }, + { + title: "Regimes/Comunhão", + url: "/cadastros/regime-comunhao/", + }, + { + title: "Censec/Centrais", + url: "/cadastros/censec/", + } + { + title: "Regimes/Comunhão", + url: "/cadastros/regime-comunhao/", + }, { title: "Censec/Centrais", url: "/cadastros/censec/", @@ -173,19 +221,75 @@ const data = { } export function AppSidebar({ ...props }: React.ComponentProps) { + + const { userAuthenticated } = useGUsuarioGetJWTHook(); + return ( + + - + + + + + + + + + +
+ + + +
+ +
+ + + + Orius Tecnologia + + + + + + 25.9.1 + + + +
+ +
+ +
+ +
+ +
+
+ + + + - + + {userAuthenticated?.data ? ( + + ) : ( + "Carregando..." + )} + + +
+ ) } diff --git a/src/components/login-form.tsx b/src/components/login-form.tsx index 0a78c5a..c1b7aeb 100644 --- a/src/components/login-form.tsx +++ b/src/components/login-form.tsx @@ -7,7 +7,7 @@ import { Input } from "@/components/ui/input" import { GUsuarioSchema } from "@/app/(protected)/(administrativo)/_schemas/GUsuarioSchema" import z from "zod" import { zodResolver } from "@hookform/resolvers/zod" -import GUsuarioLoginService from "@/app/(protected)/(administrativo)/_services/g_usuario/GUsuarioLogin" +import { GUsuarioLoginService } from "@/app/(protected)/(administrativo)/_services/g_usuario/GUsuarioLogin" import { useForm } from "react-hook-form" import { useState } from "react" import { @@ -24,7 +24,6 @@ import { Button } from "./ui/button"; type FormValues = z.infer export function LoginForm({ className, ...props }: React.ComponentProps<"div">) { - const [loading, setLoading] = useState(false); const form = useForm({ @@ -38,14 +37,8 @@ export function LoginForm({ className, ...props }: React.ComponentProps<"div">) // onSubmit agora recebe o evento do form através do handleSubmit const onSubmit = async (values: FormValues) => { setLoading(true); - try { - await GUsuarioLoginService(values); - // aqui você pode redirecionar ou mostrar mensagem de sucesso - } catch (error) { - console.error("Erro ao fazer login:", error); - } finally { - setLoading(false); - } + await GUsuarioLoginService(values); + setLoading(false); } return ( diff --git a/src/components/nav-main.tsx b/src/components/nav-main.tsx index 1d71af1..a622c89 100644 --- a/src/components/nav-main.tsx +++ b/src/components/nav-main.tsx @@ -1,6 +1,7 @@ "use client" import { ChevronRight, type LucideIcon } from "lucide-react" +import Link from "next/link"; import { Collapsible, @@ -33,41 +34,85 @@ export function NavMain({ }[] }) { return ( + - Platform + + + + Platform + + + + {items.map((item) => ( + + + + + {item.icon && } - {item.title} + + + + {item.title} + + + + + + + + {item.items?.map((subItem) => ( + + - - {subItem.title} - + + + + + + {subItem.title} + + + + + + + ))} + + + + + ))} + + + ) } diff --git a/src/components/nav-user.tsx b/src/components/nav-user.tsx index 3d6d9f8..6b16114 100644 --- a/src/components/nav-user.tsx +++ b/src/components/nav-user.tsx @@ -1,14 +1,10 @@ "use client" import { - BadgeCheck, - Bell, ChevronsUpDown, - CreditCard, LogOut, Sparkles, } from "lucide-react" - import { Avatar, AvatarFallback, @@ -30,85 +26,192 @@ import { useSidebar, } from "@/components/ui/sidebar" +import GUsuarioAuthenticatedInterface from "@/interfaces/GUsuarioAuthenticatedInterface" +import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog" +import { useGUsuarioLogoutHook } from "@/app/(protected)/(administrativo)/_hooks/g_usuario/useGUsuarioLogoutHook" +import { use, useCallback, useState } from "react" + export function NavUser({ - user, + + user + }: { - user: { - name: string - email: string - avatar: string - } + + user: GUsuarioAuthenticatedInterface + }) { - const { isMobile } = useSidebar() + + // Hook para encerrar sessão + const { logoutUsuario } = useGUsuarioLogoutHook(); + + // Controle de exibição do formulário de confirmação + const [isConfirmOpen, setIsConfirmOpen] = useState(false); + + const { isMobile } = useSidebar(); + + // Manipulação de formulário de confirmação + const handleConfirmOpen = useCallback(async () => { + + setIsConfirmOpen(true); + + }, []); + + const handleLogoutConfirm = useCallback(async () => { + + logoutUsuario(); + + }, []); + + const handleLogoutCancel = useCallback(async () => { + + setIsConfirmOpen(false); + + }, []) + + if (!user) { + + return 'Carregando...'; + + } return ( - - - - - - - - CN - -
- {user.name} - {user.email} -
- -
-
- - -
+ + <> + + + + + + + + + + - - CN + + + + + + {user.sigla} + + + +
- {user.name} - {user.email} + + + + {user.nome} + + + + + + {user.email} + + +
-
-
- - - - - Upgrade to Pro + + + + + + + + + + + +
+ + + + + + + + {user.sigla} + + + + + +
+ + + + {user.nome} + + + + + + {user.email} + + + +
+ +
+ +
+ + + + + + + + + + Configurações + + + + + + + + handleConfirmOpen()}> + + + + Log out + -
- - - - - Account - - - - Billing - - - - Notifications - - - - - - Log out - -
-
-
-
+ + + + + + + + + + {/* Modal de confirmação */} + handleLogoutConfirm()} + onCancel={() => handleLogoutCancel()} + /> + + + ) } diff --git a/src/components/ui/alert-dialog.tsx b/src/components/ui/alert-dialog.tsx new file mode 100644 index 0000000..0863e40 --- /dev/null +++ b/src/components/ui/alert-dialog.tsx @@ -0,0 +1,157 @@ +"use client" + +import * as React from "react" +import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog" + +import { cn } from "@/lib/utils" +import { buttonVariants } from "@/components/ui/button" + +function AlertDialog({ + ...props +}: React.ComponentProps) { + return +} + +function AlertDialogTrigger({ + ...props +}: React.ComponentProps) { + return ( + + ) +} + +function AlertDialogPortal({ + ...props +}: React.ComponentProps) { + return ( + + ) +} + +function AlertDialogOverlay({ + className, + ...props +}: React.ComponentProps) { + return ( + + ) +} + +function AlertDialogContent({ + className, + ...props +}: React.ComponentProps) { + return ( + + + + + ) +} + +function AlertDialogHeader({ + className, + ...props +}: React.ComponentProps<"div">) { + return ( +
+ ) +} + +function AlertDialogFooter({ + className, + ...props +}: React.ComponentProps<"div">) { + return ( +
+ ) +} + +function AlertDialogTitle({ + className, + ...props +}: React.ComponentProps) { + return ( + + ) +} + +function AlertDialogDescription({ + className, + ...props +}: React.ComponentProps) { + return ( + + ) +} + +function AlertDialogAction({ + className, + ...props +}: React.ComponentProps) { + return ( + + ) +} + +function AlertDialogCancel({ + className, + ...props +}: React.ComponentProps) { + return ( + + ) +} + +export { + AlertDialog, + AlertDialogPortal, + AlertDialogOverlay, + AlertDialogTrigger, + AlertDialogContent, + AlertDialogHeader, + AlertDialogFooter, + AlertDialogTitle, + AlertDialogDescription, + AlertDialogAction, + AlertDialogCancel, +} diff --git a/src/components/ui/checkbox.tsx b/src/components/ui/checkbox.tsx new file mode 100644 index 0000000..fa0e4b5 --- /dev/null +++ b/src/components/ui/checkbox.tsx @@ -0,0 +1,32 @@ +"use client" + +import * as React from "react" +import * as CheckboxPrimitive from "@radix-ui/react-checkbox" +import { CheckIcon } from "lucide-react" + +import { cn } from "@/lib/utils" + +function Checkbox({ + className, + ...props +}: React.ComponentProps) { + return ( + + + + + + ) +} + +export { Checkbox } diff --git a/src/components/ui/dialog.tsx b/src/components/ui/dialog.tsx new file mode 100644 index 0000000..d9ccec9 --- /dev/null +++ b/src/components/ui/dialog.tsx @@ -0,0 +1,143 @@ +"use client" + +import * as React from "react" +import * as DialogPrimitive from "@radix-ui/react-dialog" +import { XIcon } from "lucide-react" + +import { cn } from "@/lib/utils" + +function Dialog({ + ...props +}: React.ComponentProps) { + return +} + +function DialogTrigger({ + ...props +}: React.ComponentProps) { + return +} + +function DialogPortal({ + ...props +}: React.ComponentProps) { + return +} + +function DialogClose({ + ...props +}: React.ComponentProps) { + return +} + +function DialogOverlay({ + className, + ...props +}: React.ComponentProps) { + return ( + + ) +} + +function DialogContent({ + className, + children, + showCloseButton = true, + ...props +}: React.ComponentProps & { + showCloseButton?: boolean +}) { + return ( + + + + {children} + {showCloseButton && ( + + + Close + + )} + + + ) +} + +function DialogHeader({ className, ...props }: React.ComponentProps<"div">) { + return ( +
+ ) +} + +function DialogFooter({ className, ...props }: React.ComponentProps<"div">) { + return ( +
+ ) +} + +function DialogTitle({ + className, + ...props +}: React.ComponentProps) { + return ( + + ) +} + +function DialogDescription({ + className, + ...props +}: React.ComponentProps) { + return ( + + ) +} + +export { + Dialog, + DialogClose, + DialogContent, + DialogDescription, + DialogFooter, + DialogHeader, + DialogOverlay, + DialogPortal, + DialogTitle, + DialogTrigger, +} diff --git a/src/components/ui/popover.tsx b/src/components/ui/popover.tsx new file mode 100644 index 0000000..01e468b --- /dev/null +++ b/src/components/ui/popover.tsx @@ -0,0 +1,48 @@ +"use client" + +import * as React from "react" +import * as PopoverPrimitive from "@radix-ui/react-popover" + +import { cn } from "@/lib/utils" + +function Popover({ + ...props +}: React.ComponentProps) { + return +} + +function PopoverTrigger({ + ...props +}: React.ComponentProps) { + return +} + +function PopoverContent({ + className, + align = "center", + sideOffset = 4, + ...props +}: React.ComponentProps) { + return ( + + + + ) +} + +function PopoverAnchor({ + ...props +}: React.ComponentProps) { + return +} + +export { Popover, PopoverTrigger, PopoverContent, PopoverAnchor } diff --git a/src/components/ui/select.tsx b/src/components/ui/select.tsx new file mode 100644 index 0000000..dcbbc0c --- /dev/null +++ b/src/components/ui/select.tsx @@ -0,0 +1,185 @@ +"use client" + +import * as React from "react" +import * as SelectPrimitive from "@radix-ui/react-select" +import { CheckIcon, ChevronDownIcon, ChevronUpIcon } from "lucide-react" + +import { cn } from "@/lib/utils" + +function Select({ + ...props +}: React.ComponentProps) { + return +} + +function SelectGroup({ + ...props +}: React.ComponentProps) { + return +} + +function SelectValue({ + ...props +}: React.ComponentProps) { + return +} + +function SelectTrigger({ + className, + size = "default", + children, + ...props +}: React.ComponentProps & { + size?: "sm" | "default" +}) { + return ( + + {children} + + + + + ) +} + +function SelectContent({ + className, + children, + position = "popper", + ...props +}: React.ComponentProps) { + return ( + + + + + {children} + + + + + ) +} + +function SelectLabel({ + className, + ...props +}: React.ComponentProps) { + return ( + + ) +} + +function SelectItem({ + className, + children, + ...props +}: React.ComponentProps) { + return ( + + + + + + + {children} + + ) +} + +function SelectSeparator({ + className, + ...props +}: React.ComponentProps) { + return ( + + ) +} + +function SelectScrollUpButton({ + className, + ...props +}: React.ComponentProps) { + return ( + + + + ) +} + +function SelectScrollDownButton({ + className, + ...props +}: React.ComponentProps) { + return ( + + + + ) +} + +export { + Select, + SelectContent, + SelectGroup, + SelectItem, + SelectLabel, + SelectScrollDownButton, + SelectScrollUpButton, + SelectSeparator, + SelectTrigger, + SelectValue, +} diff --git a/src/config/app.json b/src/config/app_example.json similarity index 73% rename from src/config/app.json rename to src/config/app_example.json index 64ba493..d38e8d3 100644 --- a/src/config/app.json +++ b/src/config/app_example.json @@ -1,7 +1,7 @@ { "state": "go", "api": { - "url": "http://localhost:3000/", + "url": "http://localhost:8000/", "prefix": "api/v1/", "content_type": "application/json" } diff --git a/src/enums/SituacoesEnum.ts b/src/enums/SituacoesEnum.ts new file mode 100644 index 0000000..451ffb1 --- /dev/null +++ b/src/enums/SituacoesEnum.ts @@ -0,0 +1,6 @@ +export enum SituacoesEnum { + + A = 'A', + I = 'I', + +} \ No newline at end of file diff --git a/src/hooks/auth/useGUsuarioGetJWTHook.ts b/src/hooks/auth/useGUsuarioGetJWTHook.ts new file mode 100644 index 0000000..4d60499 --- /dev/null +++ b/src/hooks/auth/useGUsuarioGetJWTHook.ts @@ -0,0 +1,71 @@ +"use client"; + +import { useEffect, useState } from "react"; +import { jwtDecode } from "jwt-decode"; +import CookiesGet from "../../actions/cookies/CookiesGet"; +import GetSigla from "@/actions/text/GetSigla"; +import GUsuarioAuthenticatedInterface from "@/interfaces/GUsuarioAuthenticatedInterface"; + +interface JwtPayload { + id: string; + iat: number; + exp: number; + data?: GUsuarioAuthenticatedInterface; +} + +export default function useGUsuarioGetJWTHook() { + + const [userAuthenticated, setUserAuthenticated] = useState(null); + + useEffect(() => { + + async function fetchToken() { + + try { + + // Executa a serve action para obtem o token, salvo em cookies + const token = await CookiesGet("access_token"); + + // Verifica se o token esta preenchido + if (!token) { + + console.error("Não foi localizado dados dentro do token"); + + // Encerra a aplicação + return; + } + + // Decodifica os dados do JWT + const decoded = jwtDecode(token); + + // Se existir campo data e for string, corrige aspas simples + if (decoded.data && typeof decoded.data === "string") { + + // Decodifica os dados enviado via json + decoded.data = JSON.parse(decoded.data) + + if (decoded.data) { + + // Gera Sigla para o nome + decoded.data.sigla = GetSigla(decoded.data.nome || ""); + }; + + } + + // Armazena os dados decodificados + setUserAuthenticated(decoded); + + } catch (error) { + + console.error("Erro ao buscar token", error); + + } + } + + // Busca o TOken + fetchToken(); + + }, []); + + return { userAuthenticated }; +} diff --git a/src/interfaces/GUsuarioAuthenticatedInterface.ts b/src/interfaces/GUsuarioAuthenticatedInterface.ts new file mode 100644 index 0000000..346c06d --- /dev/null +++ b/src/interfaces/GUsuarioAuthenticatedInterface.ts @@ -0,0 +1,7 @@ +export default interface GUsuarioAuthenticatedInterface { + usuario_id?: number; + login?: string; + nome?: string; + email?: string; + sigla?: string; +} \ No newline at end of file diff --git a/src/services/api/Api.ts b/src/services/api/Api.ts index 75e6173..dfa75f1 100644 --- a/src/services/api/Api.ts +++ b/src/services/api/Api.ts @@ -1,6 +1,5 @@ import Json from '@/actions/json/Json'; import ApiInterface from './interfaces/ApiInterface'; -import Response from '@/services/response/Response'; import TokenGet from '@/actions/token/TokenGet'; import ApiSchema from '@/services/api/schemas/ApiSchema'; @@ -17,7 +16,7 @@ export default class API { this.ApiSchema = new ApiSchema(); // Obtem as configurações da aplicação - this.config = Json.execute('config/app.json'); + this.config = Json.execute(); } @@ -46,7 +45,7 @@ export default class API { const filteredBody = _data.body ? Object.fromEntries(Object.entries(_data.body).filter(([_, v]) => v != null && v !== "")) : null; // Realiza a requisição - const response = await fetch(`${this.ApiSchema.url}${this.ApiSchema.prefix}/${this.ApiSchema.endpoint}`, { + const response = await fetch(`${this.ApiSchema.url}${this.ApiSchema.prefix}${this.ApiSchema.endpoint}`, { method: _data.method, headers: { "Accept": `${this.ApiSchema.contentType}`,