Merge branch 'release(MVP)' into homologacao
This commit is contained in:
commit
d89be6c078
150 changed files with 6147 additions and 254 deletions
103
package-lock.json
generated
103
package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"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",
|
||||
|
|
@ -22,11 +22,14 @@
|
|||
"@radix-ui/react-separator": "^1.1.7",
|
||||
"@radix-ui/react-slot": "^1.2.3",
|
||||
"@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.5.3",
|
||||
"next-themes": "^0.4.6",
|
||||
|
|
@ -35,10 +38,12 @@
|
|||
"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",
|
||||
|
|
@ -1949,6 +1954,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",
|
||||
|
|
@ -2224,6 +2255,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",
|
||||
|
|
@ -2267,6 +2313,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",
|
||||
|
|
@ -2548,6 +2603,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",
|
||||
|
|
@ -2720,6 +2787,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",
|
||||
|
|
@ -2755,6 +2831,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",
|
||||
|
|
@ -2792,6 +2879,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",
|
||||
|
|
@ -3039,6 +3132,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",
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
{
|
||||
"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"
|
||||
|
|
@ -23,11 +23,14 @@
|
|||
"@radix-ui/react-separator": "^1.1.7",
|
||||
"@radix-ui/react-slot": "^1.2.3",
|
||||
"@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.5.3",
|
||||
"next-themes": "^0.4.6",
|
||||
|
|
@ -36,10 +39,12 @@
|
|||
"react-hook-form": "^7.62.0",
|
||||
"sonner": "^2.0.7",
|
||||
"tailwind-merge": "^3.3.1",
|
||||
"tinymce": "^8.1.2",
|
||||
"zod": "^4.0.17"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tailwindcss/postcss": "^4",
|
||||
"@types/js-cookie": "^3.0.6",
|
||||
"@types/jsonwebtoken": "^9.0.10",
|
||||
"@types/node": "^20",
|
||||
"@types/react": "^19",
|
||||
|
|
|
|||
27
public/images/logo.svg
Normal file
27
public/images/logo.svg
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<!-- Creator: CorelDRAW 2018 (64 Bit) -->
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" width="109.504mm" height="32.45mm" version="1.1" style="shape-rendering:geometricPrecision; text-rendering:geometricPrecision; image-rendering:optimizeQuality; fill-rule:evenodd; clip-rule:evenodd"
|
||||
viewBox="0 0 4674.85 1385.32"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<defs>
|
||||
<style type="text/css">
|
||||
<![CDATA[
|
||||
.fil0 {fill:#FF6600}
|
||||
.fil1 {fill:white;fill-rule:nonzero}
|
||||
]]>
|
||||
</style>
|
||||
</defs>
|
||||
<g id="Camada_x0020_1">
|
||||
<metadata id="CorelCorpID_0Corel-Layer"/>
|
||||
<g id="_2536796572048">
|
||||
<path class="fil0" d="M444.51 337.84c440.36,-70.7 476.63,243.79 383.3,374.93 -121.36,170.53 -504.61,132.14 -589.48,-37.21 -31.1,-62.05 -10.18,-188.76 23.33,-238.81 35.98,-53.73 97.41,-85.19 182.85,-98.91zm-444.51 192.86c0,156.21 12.26,277.5 171.92,375.2 214.59,131.32 589.63,134.32 795.72,-31.29 174.6,-140.3 173.88,-487.9 -30.87,-624.12 -52.36,-34.83 -93.57,-53.67 -162.11,-73.16 -236.65,-67.31 -582.01,-30.52 -720.03,178.21 -25.47,38.51 -54.62,111.65 -54.62,175.17z"/>
|
||||
<path class="fil0" d="M3818.84 393.91c0,148.34 145.5,201.77 263.73,234.14 93.01,25.46 365.44,57.71 365.44,126.96 0,66.65 -152.26,76.59 -224.32,76.59 -221.11,0 -348.08,-81.05 -399.39,-93.01l0 196.95 192.2 43.05c87.27,14.66 138.58,22.6 234.54,22.6 441.47,0 507.61,-275.63 337.69,-419.75 -140.93,-119.53 -545.59,-120.82 -545.59,-203.95 0,-95.45 359.81,-45.21 409.3,-31.8l154.22 53.68 0 -186.02 -176.42 -42.42c-214.47,-43.37 -611.42,-48.39 -611.42,222.96z"/>
|
||||
<path class="fil0" d="M2631.61 755.01c0,86.12 62.34,149.87 115.84,185.07 127.76,84.05 323.75,68.39 463.32,16.58 29.5,-10.95 61.1,-25 91.99,-39.32 39.53,-18.31 67.28,-41.35 94.8,-41.97l0 103.95 218.85 0 0 -809.72 -218.85 0 0 492.39c0,18.46 -54.62,47.33 -68.92,56.91 -26.89,18 -50.44,32.94 -78.73,47.11 -130.98,65.59 -399.45,116.59 -399.45,-114.96l0 -481.45 -218.85 0 0 585.41z"/>
|
||||
<path class="fil0" d="M1515.5 289.97c0,-46.34 -5.47,-72.07 -5.47,-120.37l-218.84 0 0 809.72 218.84 0 0 -475.99c0,-25.16 113.08,-106.37 136.96,-120.18 84.99,-49.19 220.78,-69.84 320.2,-46.99 23.36,5.37 43.45,15 62.61,19.46l0 -186.02c-126.58,-10.54 -178.34,-55.19 -359.3,29.15 -83.29,38.81 -108.59,66.67 -154.99,91.22z"/>
|
||||
<polygon class="fil0" points="2166.56,979.32 2385.41,979.32 2385.41,169.6 2166.56,169.6 "/>
|
||||
<path class="fil0" d="M2172.04 131.3l218.85 0 0 -131.3c-30.09,7.01 -146.3,65.43 -180.57,82.04 -33.64,16.3 -38.27,6.4 -38.27,49.26z"/>
|
||||
</g>
|
||||
<path class="fil1" d="M99.26 1380.26l0 -225.54 -81.33 0 0 -27.47 193.01 0 0 27.47 -81.33 0 0 225.54 -30.36 0zm433.68 0l0 -253.02 155.79 0 0 27.47 -125.43 0 0 84.58 115.3 0 0 27.47 -115.3 0 0 86.02 127.23 0 0 27.47 -157.59 0zm578.27 5.06c-30.12,0 -54.1,-8.73 -71.93,-26.2 -17.83,-17.47 -26.75,-42.95 -26.75,-76.45l0 -57.83c0,-33.5 8.91,-58.98 26.75,-76.45 17.83,-17.47 41.81,-26.2 71.93,-26.2 29.88,0 52.83,8.31 68.86,24.94 16.03,16.62 24.04,39.4 24.04,68.31l0 1.81 -30 0 0 -2.89c0,-19.04 -5.12,-34.64 -15.36,-46.81 -10.24,-12.17 -26.08,-18.25 -47.53,-18.25 -21.44,0 -38.19,6.57 -50.24,19.7 -12.05,13.13 -18.07,31.51 -18.07,55.12l0 59.28c0,23.62 6.02,41.99 18.07,55.12 12.05,13.13 28.8,19.7 50.24,19.7 21.45,0 37.29,-6.08 47.53,-18.25 10.24,-12.17 15.36,-27.77 15.36,-46.81l0 -5.78 30 0 0 4.7c0,28.92 -8.01,51.69 -24.04,68.31 -16.02,16.63 -38.98,24.94 -68.86,24.94zm423.92 -5.06l0 -253.02 58.92 0 88.2 233.86 4.7 0 0 -233.86 30 0 0 253.02 -58.92 0 -87.83 -234.22 -5.06 0 0 234.22 -30 0zm615.13 5.06c-30.12,0 -54.16,-8.73 -72.11,-26.2 -17.95,-17.47 -26.93,-42.95 -26.93,-76.45l0 -57.83c0,-33.5 8.98,-58.98 26.93,-76.45 17.95,-17.47 41.99,-26.2 72.11,-26.2 30.36,0 54.52,8.73 72.47,26.2 17.95,17.47 26.93,42.95 26.93,76.45l0 57.83c0,33.5 -8.97,58.98 -26.93,76.45 -17.96,17.47 -42.11,26.2 -72.47,26.2zm0 -27.11c21.93,0 38.92,-6.57 50.96,-19.7 12.05,-13.13 18.07,-31.39 18.07,-54.76l0 -60c0,-23.37 -6.02,-41.63 -18.07,-54.76 -12.05,-13.13 -29.04,-19.7 -50.96,-19.7 -21.69,0 -38.55,6.57 -50.61,19.7 -12.05,13.13 -18.07,31.39 -18.07,54.76l0 60c0,23.37 6.02,41.63 18.07,54.76 12.05,13.13 28.92,19.7 50.61,19.7zm433.32 22.05l0 -253.02 30.36 0 0 225.54 127.96 0 0 27.47 -158.32 0zm565.25 5.06c-30.12,0 -54.16,-8.73 -72.11,-26.2 -17.95,-17.47 -26.93,-42.95 -26.93,-76.45l0 -57.83c0,-33.5 8.98,-58.98 26.93,-76.45 17.95,-17.47 41.99,-26.2 72.11,-26.2 30.36,0 54.52,8.73 72.47,26.2 17.95,17.47 26.93,42.95 26.93,76.45l0 57.83c0,33.5 -8.97,58.98 -26.93,76.45 -17.96,17.47 -42.11,26.2 -72.47,26.2zm0 -27.11c21.93,0 38.92,-6.57 50.96,-19.7 12.05,-13.13 18.07,-31.39 18.07,-54.76l0 -60c0,-23.37 -6.02,-41.63 -18.07,-54.76 -12.05,-13.13 -29.04,-19.7 -50.96,-19.7 -21.69,0 -38.55,6.57 -50.61,19.7 -12.05,13.13 -18.07,31.39 -18.07,54.76l0 60c0,23.37 6.02,41.63 18.07,54.76 12.05,13.13 28.92,19.7 50.61,19.7zm521.51 27.11c-18.8,0 -35.36,-3.91 -49.7,-11.74 -14.34,-7.83 -25.54,-19.34 -33.61,-34.52 -8.07,-15.18 -12.11,-33.98 -12.11,-56.39l0 -57.83c0,-33.5 8.91,-58.98 26.75,-76.45 17.83,-17.47 41.81,-26.2 71.93,-26.2 29.88,0 52.65,8.19 68.31,24.58 15.66,16.38 23.5,38.32 23.5,65.79l0 1.81 -30 0 0 -2.53c0,-12.05 -2.17,-22.77 -6.51,-32.17 -4.34,-9.4 -11.08,-16.81 -20.24,-22.23 -9.16,-5.42 -20.85,-8.13 -35.06,-8.13 -21.44,0 -38.19,6.57 -50.24,19.7 -12.05,13.13 -18.07,31.51 -18.07,55.12l0 59.28c0,23.62 6.02,41.99 18.07,55.12 12.05,13.13 28.92,19.7 50.61,19.7 21.2,0 36.81,-6.02 46.81,-18.07 10,-12.05 15,-28.07 15,-48.07l0 -6.14 -76.63 0 0 -26.02 106.27 0 0 120.36 -27.47 0 0 -27.47 -5.06 0c-2.65,5.3 -6.38,10.48 -11.2,15.54 -4.82,5.06 -11.33,9.16 -19.52,12.29 -8.19,3.13 -18.8,4.7 -31.81,4.7zm433.68 -5.06l0 -253.02 30.36 0 0 253.02 -30.36 0zm351.64 0l78.07 -253.02 53.49 0 78.08 253.02 -31.45 0 -19.52 -63.98 -107.71 0 -19.52 63.98 -31.45 0zm58.55 -91.45l92.17 0 -43.37 -143.13 -5.06 0 -43.73 143.13z"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 5.8 KiB |
|
|
@ -1,11 +1,19 @@
|
|||
'use client'
|
||||
'use server'
|
||||
|
||||
import { cookies } from "next/headers";
|
||||
|
||||
export default async function CookiesGet() {
|
||||
/**
|
||||
* Função para obter tokens do lado servidorde acordo com o nome informado
|
||||
*/
|
||||
export default async function CookiesGet(token: string) {
|
||||
|
||||
// Obtem a lista de Tokens
|
||||
const cookieStore = await cookies();
|
||||
const token = cookieStore.get('access_token');
|
||||
return token?.value;
|
||||
|
||||
// Obtem um token em especifico
|
||||
const data = cookieStore.get(token);
|
||||
|
||||
// Retorna nulo ou o valor do token desejado
|
||||
return data?.value;
|
||||
|
||||
}
|
||||
15
src/actions/text/GetSigla.ts
Normal file
15
src/actions/text/GetSigla.ts
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
export default function GetSigla(data: string): string {
|
||||
|
||||
if (!data) return "";
|
||||
|
||||
// Remove espaços extras no início e no fim e divide em palavras
|
||||
const palavras = data.trim().split(/\s+/);
|
||||
|
||||
if (palavras.length === 1) {
|
||||
// Apenas uma palavra → retorna as duas primeiras letras
|
||||
return palavras[0].substring(0, 2).toUpperCase();
|
||||
}
|
||||
|
||||
// Duas ou mais palavras → retorna a primeira letra de cada
|
||||
return palavras.map(palavra => palavra.charAt(0).toUpperCase()).join('');
|
||||
}
|
||||
32
src/actions/withClientErrorHandler/withClientErrorHandler.ts
Normal file
32
src/actions/withClientErrorHandler/withClientErrorHandler.ts
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
import withClientErrorHandlerInterface from "./withClientErrorHandlerInterface";
|
||||
|
||||
/**
|
||||
* Códigos de erro que começam com 6, são do front entd, na ordem do alfabeto o F de frontend é a sexta letra
|
||||
*/
|
||||
export function withClientErrorHandler<T extends (...args: any[]) => Promise<any>>(
|
||||
action: T
|
||||
) {
|
||||
return async (...args: Parameters<T>): Promise<withClientErrorHandlerInterface> => {
|
||||
|
||||
try {
|
||||
|
||||
// Executa a função definida
|
||||
const data = await action(...args);
|
||||
|
||||
// Retorna exatamente a mesma resposta retornada pela função
|
||||
return data;
|
||||
|
||||
} catch (error: any) {
|
||||
|
||||
// Retorna o erro de execuçãformatado
|
||||
return {
|
||||
status: 600,
|
||||
message: error?.message || "Erro interno do servidor",
|
||||
data: error
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
export default interface withClientErrorHandlerInterface<T = any> {
|
||||
|
||||
status: number;
|
||||
data?: T;
|
||||
message?: string;
|
||||
|
||||
}
|
||||
|
|
@ -22,6 +22,7 @@ export default function UsuarioDetalhes() {
|
|||
if (params.id) {
|
||||
fetchUsuario({ usuario_id: Number(params.id) } as Usuario);
|
||||
}
|
||||
console.log("pagina",usuario)
|
||||
}, []);
|
||||
|
||||
if (!usuario) return <Loading type={1} />;
|
||||
|
|
|
|||
|
|
@ -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 }
|
||||
}
|
||||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -6,9 +6,11 @@ import {
|
|||
|
||||
import GUsuarioLoginData from "../../_data/g_usuario/GUsuarioLoginData"
|
||||
import { redirect } from "next/navigation";
|
||||
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
|
||||
|
|
@ -21,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",
|
||||
|
|
@ -30,6 +35,10 @@ export default async function GUsuarioLoginService(form: any) {
|
|||
maxAge: 60 * 60 * 24,
|
||||
});
|
||||
|
||||
// Redireciona para a págian desejada
|
||||
redirect("/usuarios");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Exporta função encapsulada
|
||||
export const GUsuarioLoginService = withClientErrorHandler(executeGUsuarioLoginService);
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
'use server'
|
||||
|
||||
import {
|
||||
cookies
|
||||
} from "next/headers";
|
||||
|
||||
import { redirect } from "next/navigation";
|
||||
|
||||
export default async function GUsuarioLogoutService(token: string) {
|
||||
|
||||
const cookieStore = await cookies();
|
||||
cookieStore.set(token, '', {
|
||||
expires: new Date(0),
|
||||
path: '/',
|
||||
});
|
||||
|
||||
redirect('/login');
|
||||
|
||||
}
|
||||
|
|
@ -12,6 +12,14 @@ export default async function GUsuarioRead(usuarioId: number) {
|
|||
}
|
||||
}
|
||||
|
||||
return await GUsuarioReadData(usuarioId);
|
||||
try {
|
||||
const response = await GUsuarioReadData(usuarioId);
|
||||
console.log("service",response)
|
||||
return response
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
return error
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,128 @@
|
|||
'use client';
|
||||
|
||||
import { useEffect, useState, useCallback } from "react";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDialog";
|
||||
|
||||
import Header from "@/app/_components/structure/Header";
|
||||
import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog";
|
||||
import Loading from "@/app/_components/loading/loading";
|
||||
import GMedidaTipoTable from "../../_components/g_medidatipo/GMedidaTipoTable";
|
||||
import GMedidaTipoForm from "../../_components/g_medidatipo/GMedidaTipoForm";
|
||||
|
||||
import { useGMedidaTipoReadHook } from "../../_hooks/g_medidatipo/useGMedidaTipoReadHook";
|
||||
import { useGMedidaTipoSaveHook } from "../../_hooks/g_medidatipo/useGMedidaTipoSaveHook";
|
||||
import { useGMedidaTipoRemoveHook } from "../../_hooks/g_medidatipo/useGMedidaTipoRemoveHook";
|
||||
|
||||
import { GMedidaTipoInterface } from "../../_interfaces/GMedidaTipoInterface";
|
||||
|
||||
const initialMedidaTipo: GMedidaTipoInterface = {
|
||||
medida_tipo_id: 0,
|
||||
sigla: '',
|
||||
descricao: ''
|
||||
}
|
||||
|
||||
export default function GMedidaTipoPage() {
|
||||
|
||||
// Hooks para leitura, salvamento e remoção
|
||||
const { gMedidaTipo, fetchGMedidaTipo } = useGMedidaTipoReadHook();
|
||||
const { saveGMedidaTipo } = useGMedidaTipoSaveHook();
|
||||
const { removeGMedidaTipo } = useGMedidaTipoRemoveHook();
|
||||
|
||||
// Estado para controlar o formulário e o item selecionado
|
||||
const [selectedMedidaTipo, setSelectedMedidaTipo] = useState<GMedidaTipoInterface | null>(null);
|
||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||
const [itemToDelete, setItemToDelete] = useState<GMedidaTipoInterface | null>(null);
|
||||
|
||||
// Hook para o modal de confirmação
|
||||
const {
|
||||
isOpen: isConfirmOpen,
|
||||
openDialog: openConfirmDialog,
|
||||
handleConfirm,
|
||||
handleCancel,
|
||||
} = useConfirmDialog();
|
||||
|
||||
// Ações do formulário
|
||||
const handleOpenForm = useCallback((data: GMedidaTipoInterface | null) => {
|
||||
setSelectedMedidaTipo(data);
|
||||
setIsFormOpen(true);
|
||||
}, []);
|
||||
|
||||
const handleCloseForm = useCallback(() => {
|
||||
setIsFormOpen(false);
|
||||
setSelectedMedidaTipo(null);
|
||||
}, []);
|
||||
|
||||
const handleSave = useCallback(async (data: GMedidaTipoInterface) => {
|
||||
await saveGMedidaTipo(data);
|
||||
await fetchGMedidaTipo(); // Atualiza a tabela após salvar
|
||||
handleCloseForm();
|
||||
}, [saveGMedidaTipo, fetchGMedidaTipo]);
|
||||
|
||||
// Ações de deleção
|
||||
const handleConfirmDelete = useCallback((item: GMedidaTipoInterface) => {
|
||||
setItemToDelete(item);
|
||||
openConfirmDialog();
|
||||
}, [openConfirmDialog]);
|
||||
|
||||
const handleDelete = useCallback(async () => {
|
||||
if (itemToDelete) {
|
||||
await removeGMedidaTipo(itemToDelete);
|
||||
await fetchGMedidaTipo(); // Atualiza a tabela após remover
|
||||
}
|
||||
handleCancel();
|
||||
}, [itemToDelete, fetchGMedidaTipo, handleCancel]);
|
||||
|
||||
// Efeito para carregar os dados na montagem do componente
|
||||
useEffect(() => {
|
||||
fetchGMedidaTipo();
|
||||
}, []);
|
||||
|
||||
// Mostra tela de loading enquanto os dados não são carregados
|
||||
if (!gMedidaTipo) {
|
||||
return <Loading type={2} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
{/* Cabeçalho */}
|
||||
<Header
|
||||
title={"Tipos de Medida"}
|
||||
description={"Gerenciamento de tipos de medida"}
|
||||
buttonText={"Novo Tipo de Medida"}
|
||||
buttonAction={(data) => { handleOpenForm(data = initialMedidaTipo) }}
|
||||
/>
|
||||
|
||||
{/* Tabela de Tipos de Medida */}
|
||||
<Card>
|
||||
<CardContent>
|
||||
<GMedidaTipoTable
|
||||
data={gMedidaTipo}
|
||||
onEdit={handleOpenForm}
|
||||
onDelete={handleConfirmDelete}
|
||||
/>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Modal de confirmação */}
|
||||
<ConfirmDialog
|
||||
isOpen={isConfirmOpen}
|
||||
title="Confirmar exclusão"
|
||||
description="Atenção"
|
||||
message={`Deseja realmente excluir o tipo de medida "${itemToDelete?.descricao}"?`}
|
||||
confirmText="Sim, excluir"
|
||||
cancelText="Cancelar"
|
||||
onConfirm={handleDelete}
|
||||
onCancel={handleCancel}
|
||||
/>
|
||||
|
||||
{/* Formulário de criação/edição */}
|
||||
<GMedidaTipoForm
|
||||
isOpen={isFormOpen}
|
||||
data={selectedMedidaTipo}
|
||||
onClose={handleCloseForm}
|
||||
onSave={handleSave}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,130 @@
|
|||
'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 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";
|
||||
|
||||
const initialBairro: GTBBairroInterface = {
|
||||
sistema_id: null,
|
||||
tb_bairro_id: 0,
|
||||
descricao: '',
|
||||
situacao: 'A'
|
||||
}
|
||||
|
||||
export default function TTBAndamentoServico() {
|
||||
|
||||
// Hooks para leitura e salvamento
|
||||
const { gTBBairro, fetchGTBBairro } = useGTBBairroReadHook();
|
||||
const { saveGTBBairro } = useGTBBairroSaveHook();
|
||||
const { removeGTBBairro } = useGTBBairroRemoveHook();
|
||||
|
||||
// Estado para controlar o formulário e item selecionado
|
||||
const [selectedBairro, setBairro] = useState<GTBBairroInterface | null>(null);
|
||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||
const [itemToDelete, setItemToDelete] = useState<GTBBairroInterface | null>(null);
|
||||
|
||||
// Hook para o modal de confirmação
|
||||
const {
|
||||
isOpen: isConfirmOpen,
|
||||
openDialog: openConfirmDialog,
|
||||
handleConfirm,
|
||||
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) => {
|
||||
await saveGTBBairro(data);
|
||||
fetchGTBBairro(); // Atualiza a tabela após salvar
|
||||
}, [saveGTBBairro, fetchGTBBairro]);
|
||||
|
||||
// Ações de deleção
|
||||
const handleConfirmDelete = useCallback((item: GTBBairroInterface) => {
|
||||
setItemToDelete(item);
|
||||
openConfirmDialog();
|
||||
}, [openConfirmDialog]);
|
||||
|
||||
const handleDelete = useCallback(async () => {
|
||||
if (!itemToDelete) return;
|
||||
|
||||
await removeGTBBairro(itemToDelete);
|
||||
await fetchGTBBairro(); // Atualiza a tabela após remover
|
||||
|
||||
setItemToDelete(null)
|
||||
|
||||
handleCancel();
|
||||
}, [itemToDelete, fetchGTBBairro, handleCancel]);
|
||||
|
||||
// Efeito para carregar os dados na montagem do componente
|
||||
useEffect(() => {
|
||||
fetchGTBBairro();
|
||||
}, []);
|
||||
|
||||
if (!gTBBairro) {
|
||||
return <Loading type={2} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
{/* Cabeçalho */}
|
||||
<Header
|
||||
title={"Bairros"}
|
||||
description={"Gerenciamento de Bairros"}
|
||||
buttonText={"Novo Bairro"}
|
||||
buttonAction={(data) => { handleOpenForm(data = initialBairro) }}
|
||||
/>
|
||||
|
||||
{/* Tabela de Bairros */}
|
||||
<Card>
|
||||
<CardContent>
|
||||
<GTBBairroTable
|
||||
data={gTBBairro}
|
||||
onEdit={handleOpenForm}
|
||||
onDelete={handleConfirmDelete}
|
||||
/>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Modal de confirmação */}
|
||||
<ConfirmDialog
|
||||
isOpen={isConfirmOpen}
|
||||
title="Confirmar exclusão"
|
||||
description="Atenção"
|
||||
message={`Deseja realmente excluir o bairro "${itemToDelete?.descricao}"?`}
|
||||
confirmText="Sim, excluir"
|
||||
cancelText="Cancelar"
|
||||
onConfirm={handleDelete}
|
||||
onCancel={handleCancel}
|
||||
/>
|
||||
|
||||
{/* Formulário de criação/edição */}
|
||||
<GTBBairroForm
|
||||
isOpen={isFormOpen}
|
||||
data={selectedBairro}
|
||||
onClose={handleCloseForm}
|
||||
onSave={handleSave}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,129 @@
|
|||
'use client';
|
||||
|
||||
import { useEffect, useState, useCallback } from "react";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDialog";
|
||||
|
||||
import Header from "@/app/_components/structure/Header";
|
||||
import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog";
|
||||
import Loading from "@/app/_components/loading/loading";
|
||||
import GTBEstadoCivilTable from "../../_components/g_tb_estadocivil/GTBEstadoCivilTable";
|
||||
import GTBEstadoCivilForm from "../../_components/g_tb_estadocivil/GTBEstadoCivilForm";
|
||||
|
||||
import { useGTBEstadoCivilReadHook } from "../../_hooks/g_tb_estadocivil/useGTBEstadoCivilReadHook";
|
||||
import { useGTBEstadoCivilSaveHook } from "../../_hooks/g_tb_estadocivil/useGTBEstadoCivilSaveHook";
|
||||
import { useGTBEstadoCivilRemoveHook } from "../../_hooks/g_tb_estadocivil/useGTBEstadoCivilRemoveHook";
|
||||
|
||||
import { GTBEstadoCivilInterface } from "../../_interfaces/GTBEstadoCivilInterface";
|
||||
|
||||
const initalEstadoCivil: GTBEstadoCivilInterface = {
|
||||
tb_estadocivil_id: 0,
|
||||
sistema_id: 0,
|
||||
descricao: '',
|
||||
situacao: 'A',
|
||||
}
|
||||
|
||||
export default function TBEstadoCivilPage() {
|
||||
|
||||
// Hooks para leitura e salvamento
|
||||
const { gTBEstadoCivil, fetchGTBEstadoCivil } = useGTBEstadoCivilReadHook();
|
||||
const { saveGTBEstadoCivil } = useGTBEstadoCivilSaveHook();
|
||||
const { removeGTBEstadoCivil } = useGTBEstadoCivilRemoveHook();
|
||||
|
||||
// Estado para controlar o formulário e item selecionado
|
||||
const [selectedEstadoCivil, setSelectedEstadoCivil] = useState<GTBEstadoCivilInterface | null>(null);
|
||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||
const [itemToDelete, setItemToDelete] = useState<GTBEstadoCivilInterface | null>(null);
|
||||
|
||||
// Hook para o modal de confirmação
|
||||
const {
|
||||
isOpen: isConfirmOpen,
|
||||
openDialog: openConfirmDialog,
|
||||
handleConfirm,
|
||||
handleCancel,
|
||||
} = useConfirmDialog();
|
||||
|
||||
// Ações do formulário
|
||||
const handleOpenForm = useCallback((data: GTBEstadoCivilInterface | null) => {
|
||||
setSelectedEstadoCivil(data);
|
||||
setIsFormOpen(true);
|
||||
}, []);
|
||||
|
||||
const handleCloseForm = useCallback(() => {
|
||||
setIsFormOpen(false);
|
||||
setSelectedEstadoCivil(null);
|
||||
}, []);
|
||||
|
||||
const handleSave = useCallback(async (data: GTBEstadoCivilInterface) => {
|
||||
await saveGTBEstadoCivil(data);
|
||||
await fetchGTBEstadoCivil(); // Atualiza a tabela após salvar
|
||||
handleCloseForm();
|
||||
}, [saveGTBEstadoCivil, fetchGTBEstadoCivil]);
|
||||
|
||||
// Ações de deleção
|
||||
const handleConfirmDelete = useCallback((item: GTBEstadoCivilInterface) => {
|
||||
setItemToDelete(item);
|
||||
openConfirmDialog();
|
||||
}, [openConfirmDialog]);
|
||||
|
||||
const handleDelete = useCallback(async () => {
|
||||
if (itemToDelete) {
|
||||
await removeGTBEstadoCivil(itemToDelete);
|
||||
await fetchGTBEstadoCivil(); // Atualiza a tabela após remover
|
||||
}
|
||||
handleCancel();
|
||||
}, [itemToDelete, fetchGTBEstadoCivil, handleCancel]);
|
||||
|
||||
// Efeito para carregar os dados na montagem do componente
|
||||
useEffect(() => {
|
||||
fetchGTBEstadoCivil();
|
||||
}, []);
|
||||
|
||||
// Mostra tela de loading enquanto os dados não são carregados
|
||||
if (!gTBEstadoCivil) {
|
||||
return <Loading type={2} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
{/* Cabeçalho */}
|
||||
<Header
|
||||
title={"Estados Civis"}
|
||||
description={"Gerenciamento de Estados Civis"}
|
||||
buttonText={"Novo Estado Civil"}
|
||||
buttonAction={(data) => { handleOpenForm(data = initalEstadoCivil) }}
|
||||
/>
|
||||
|
||||
{/* Tabela de Estados Civis */}
|
||||
<Card>
|
||||
<CardContent>
|
||||
<GTBEstadoCivilTable
|
||||
data={gTBEstadoCivil}
|
||||
onEdit={handleOpenForm}
|
||||
onDelete={handleConfirmDelete}
|
||||
/>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Modal de confirmação */}
|
||||
<ConfirmDialog
|
||||
isOpen={isConfirmOpen}
|
||||
title="Confirmar exclusão"
|
||||
description="Atenção"
|
||||
message={`Deseja realmente excluir o estado civil "${itemToDelete?.descricao}"?`}
|
||||
confirmText="Sim, excluir"
|
||||
cancelText="Cancelar"
|
||||
onConfirm={handleDelete}
|
||||
onCancel={handleCancel}
|
||||
/>
|
||||
|
||||
{/* Formulário de criação/edição */}
|
||||
<GTBEstadoCivilForm
|
||||
isOpen={isFormOpen}
|
||||
data={selectedEstadoCivil}
|
||||
onClose={handleCloseForm}
|
||||
onSave={handleSave}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,163 @@
|
|||
'use client';
|
||||
|
||||
import { useEffect, useState, useCallback } from "react";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
|
||||
import Loading from "@/app/_components/loading/loading";
|
||||
import GTBRegimeBensTable from "../../_components/g_tb_regimebens/GTBRegimeBensTable";
|
||||
import GTBRegimeBensForm from "../../_components/g_tb_regimebens/GTBRegimeBensForm";
|
||||
|
||||
import { useGTBRegimeBensReadHook } from "../../_hooks/g_tb_regimebens/useGTBRegimeBensReadHook";
|
||||
import { useGTBRegimeBensSaveHook } from "../../_hooks/g_tb_regimebens/useGTBRegimeBensSaveHook";
|
||||
import { useGTBRegimeBensRemoveHook } from "../../_hooks/g_tb_regimebens/useGTBRegimeBensRemoveHook";
|
||||
|
||||
import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog";
|
||||
import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDialog";
|
||||
|
||||
import GTBRegimeBensInterface from "../../_interfaces/GTBRegimeBensInterface";
|
||||
import Header from "@/app/_components/structure/Header";
|
||||
|
||||
export default function TTBAndamentoServico() {
|
||||
// Hooks para leitura e salvamento
|
||||
const { gTBRegimeBens, fetchGTBRegimeBens } = useGTBRegimeBensReadHook();
|
||||
const { saveGTBRegimeComunhao } = useGTBRegimeBensSaveHook();
|
||||
const { removeGTBRegimeComunhao } = useGTBRegimeBensRemoveHook();
|
||||
|
||||
// Estados
|
||||
const [selectedAndamento, setSelectedAndamento] = useState<GTBRegimeBensInterface | null>(null);
|
||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||
|
||||
// Estado para saber qual item será deletado
|
||||
const [itemToDelete, setItemToDelete] = useState<GTBRegimeBensInterface | null>(null);
|
||||
|
||||
/**
|
||||
* Hook do modal de confirmação
|
||||
*/
|
||||
const {
|
||||
isOpen: isConfirmOpen,
|
||||
openDialog: openConfirmDialog,
|
||||
handleConfirm,
|
||||
handleCancel,
|
||||
} = useConfirmDialog();
|
||||
|
||||
/**
|
||||
* Abre o formulário no modo de edição ou criação
|
||||
*/
|
||||
const handleOpenForm = useCallback((data: GTBRegimeBensInterface | null) => {
|
||||
setSelectedAndamento(data);
|
||||
setIsFormOpen(true);
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Fecha o formulário e limpa o andamento selecionado
|
||||
*/
|
||||
const handleCloseForm = useCallback(() => {
|
||||
setSelectedAndamento(null);
|
||||
setIsFormOpen(false);
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Salva os dados do formulário
|
||||
*/
|
||||
const handleSave = useCallback(async (formData: GTBRegimeBensInterface) => {
|
||||
|
||||
// Aguarda salvar o registro
|
||||
await saveGTBRegimeComunhao(formData);
|
||||
|
||||
// Atualiza a lista de dados
|
||||
fetchGTBRegimeBens();
|
||||
|
||||
}, [saveGTBRegimeComunhao, fetchGTBRegimeBens]);
|
||||
|
||||
/**
|
||||
* Quando o usuário clica em "remover" na tabela
|
||||
*/
|
||||
const handleConfirmDelete = useCallback((item: GTBRegimeBensInterface) => {
|
||||
|
||||
// Define o item atual para remoção
|
||||
setItemToDelete(item);
|
||||
|
||||
// Abre o modal de confirmação
|
||||
openConfirmDialog();
|
||||
|
||||
}, [openConfirmDialog]);
|
||||
|
||||
/**
|
||||
* Executa a exclusão de fato quando o usuário confirma
|
||||
*/
|
||||
const handleDelete = useCallback(async () => {
|
||||
|
||||
// Protege contra null
|
||||
if (!itemToDelete) return;
|
||||
|
||||
// Executa o Hook de remoção
|
||||
await removeGTBRegimeComunhao(itemToDelete);
|
||||
|
||||
// Atualiza a lista
|
||||
await fetchGTBRegimeBens();
|
||||
|
||||
// Limpa o item selecionado
|
||||
setItemToDelete(null);
|
||||
|
||||
// Fecha o modal
|
||||
handleCancel();
|
||||
|
||||
}, [itemToDelete, fetchGTBRegimeBens, handleCancel]);
|
||||
|
||||
/**
|
||||
* Busca inicial dos dados
|
||||
*/
|
||||
useEffect(() => {
|
||||
fetchGTBRegimeBens();
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Tela de loading enquanto carrega os dados
|
||||
*/
|
||||
if (!gTBRegimeBens) {
|
||||
return <Loading type={2} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
{/* Cabeçalho */}
|
||||
<Header
|
||||
title={"Regimes de Bens"}
|
||||
description={"Gerenciamento de Regimes de Bens"}
|
||||
buttonText={"Novo Regime"}
|
||||
buttonAction={() => { handleOpenForm(null) }}
|
||||
/>
|
||||
|
||||
{/* Tabela de andamentos */}
|
||||
<Card>
|
||||
<CardContent>
|
||||
<GTBRegimeBensTable
|
||||
data={gTBRegimeBens}
|
||||
onEdit={handleOpenForm}
|
||||
onDelete={handleConfirmDelete}
|
||||
/>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Modal de confirmação */}
|
||||
<ConfirmDialog
|
||||
isOpen={isConfirmOpen}
|
||||
title="Confirmar exclusão"
|
||||
description="Atenção"
|
||||
message={`Deseja realmente excluir o regime de bens "${itemToDelete?.descricao}"?`}
|
||||
confirmText="Sim, excluir"
|
||||
cancelText="Cancelar"
|
||||
onConfirm={handleDelete}
|
||||
onCancel={handleCancel}
|
||||
/>
|
||||
|
||||
{/* Formulário de criação/edição */}
|
||||
<GTBRegimeBensForm
|
||||
isOpen={isFormOpen}
|
||||
data={selectedAndamento}
|
||||
onClose={handleCloseForm}
|
||||
onSave={handleSave}
|
||||
/>
|
||||
</div>
|
||||
); 4
|
||||
}
|
||||
|
|
@ -0,0 +1,163 @@
|
|||
'use client';
|
||||
|
||||
import { useEffect, useState, useCallback } from "react";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDialog";
|
||||
|
||||
import Header from "@/app/_components/structure/Header";
|
||||
import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog";
|
||||
import Loading from "@/app/_components/loading/loading";
|
||||
import GTBTipoLogradouroTable from "../../_components/g_tb_tipologradouro/GTBTipoLogradouroTable";
|
||||
import GTBTipoLogradouroForm from "../../_components/g_tb_tipologradouro/GTBTipoLogradouroForm";
|
||||
|
||||
import { useGTBTipoLogradouroReadHook } from "../../_hooks/g_tb_tipologradouro/useGTBTipoLogradouroReadHook";
|
||||
import { useGTBTipoLogradouroSaveHook } from "../../_hooks/g_tb_tipologradouro/useGTBTipoLogradouroSaveHook";
|
||||
import { useGTBTipoLogradouroRemoveHook } from "../../_hooks/g_tb_tipologradouro/useGTBTipoLogradouroRemoveHook";
|
||||
|
||||
import { GTBTipoLogradouroInterface } from "../../_interfaces/GTBTipoLogradouroInterface";
|
||||
|
||||
export default function TTBAndamentoServico() {
|
||||
|
||||
// Hooks para leitura e salvamento
|
||||
const { gTBTipoLogradouro, fetchGTBTipoLogradouro } = useGTBTipoLogradouroReadHook();
|
||||
const { saveGTBTipoLogradouro } = useGTBTipoLogradouroSaveHook();
|
||||
const { removeGTBTipoLogradouro } = useGTBTipoLogradouroRemoveHook();
|
||||
|
||||
// Estados
|
||||
const [selectedTipoLogradouro, setTipoLogradouro] = useState<GTBTipoLogradouroInterface | null>(null);
|
||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||
|
||||
// Estado para saber qual item será deletado
|
||||
const [itemToDelete, setItemToDelete] = useState<GTBTipoLogradouroInterface | null>(null);
|
||||
|
||||
/**
|
||||
* Hook do modal de confirmação
|
||||
*/
|
||||
const {
|
||||
isOpen: isConfirmOpen,
|
||||
openDialog: openConfirmDialog,
|
||||
handleConfirm,
|
||||
handleCancel,
|
||||
} = useConfirmDialog();
|
||||
|
||||
/**
|
||||
* Abre o formulário no modo de edição ou criação
|
||||
*/
|
||||
const handleOpenForm = useCallback((data: GTBTipoLogradouroInterface | null) => {
|
||||
setTipoLogradouro(data);
|
||||
setIsFormOpen(true);
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Fecha o formulário e limpa o andamento selecionado
|
||||
*/
|
||||
const handleCloseForm = useCallback(() => {
|
||||
setTipoLogradouro(null);
|
||||
setIsFormOpen(false);
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Salva os dados do formulário
|
||||
*/
|
||||
const handleSave = useCallback(async (formData: GTBTipoLogradouroInterface) => {
|
||||
|
||||
// Aguarda salvar o registro
|
||||
await saveGTBTipoLogradouro(formData);
|
||||
|
||||
// Atualiza a lista de dados
|
||||
fetchGTBTipoLogradouro();
|
||||
|
||||
}, [saveGTBTipoLogradouro, fetchGTBTipoLogradouro]);
|
||||
|
||||
/**
|
||||
* Quando o usuário clica em "remover" na tabela
|
||||
*/
|
||||
const handleConfirmDelete = useCallback((item: GTBTipoLogradouroInterface) => {
|
||||
|
||||
// Define o item atual para remoção
|
||||
setItemToDelete(item);
|
||||
|
||||
// Abre o modal de confirmação
|
||||
openConfirmDialog();
|
||||
|
||||
}, [openConfirmDialog]);
|
||||
|
||||
/**
|
||||
* Executa a exclusão de fato quando o usuário confirma
|
||||
*/
|
||||
const handleDelete = useCallback(async () => {
|
||||
|
||||
// Protege contra null
|
||||
if (!itemToDelete) return;
|
||||
|
||||
// Executa o Hook de remoção
|
||||
await removeGTBTipoLogradouro(itemToDelete);
|
||||
|
||||
// Atualiza a lista
|
||||
await fetchGTBTipoLogradouro();
|
||||
|
||||
// Limpa o item selecionado
|
||||
setItemToDelete(null);
|
||||
|
||||
// Fecha o modal
|
||||
handleCancel();
|
||||
|
||||
}, [itemToDelete, fetchGTBTipoLogradouro, handleCancel]);
|
||||
|
||||
/**
|
||||
* Busca inicial dos dados
|
||||
*/
|
||||
useEffect(() => {
|
||||
fetchGTBTipoLogradouro();
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Tela de loading enquanto carrega os dados
|
||||
*/
|
||||
if (!gTBTipoLogradouro) {
|
||||
return <Loading type={2} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
{/* Cabeçalho */}
|
||||
<Header
|
||||
title={"Tipos de Logradouros"}
|
||||
description={"Gerenciamento de tipos de Logradouros"}
|
||||
buttonText={"Novo Tipo"}
|
||||
buttonAction={() => { handleOpenForm(null) }}
|
||||
/>
|
||||
|
||||
{/* Tabela de andamentos */}
|
||||
<Card>
|
||||
<CardContent>
|
||||
<GTBTipoLogradouroTable
|
||||
data={gTBTipoLogradouro}
|
||||
onEdit={handleOpenForm}
|
||||
onDelete={handleConfirmDelete}
|
||||
/>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Modal de confirmação */}
|
||||
<ConfirmDialog
|
||||
isOpen={isConfirmOpen}
|
||||
title="Confirmar exclusão"
|
||||
description="Atenção"
|
||||
message={`Deseja realmente excluir o andamento "${itemToDelete?.descricao}"?`}
|
||||
confirmText="Sim, excluir"
|
||||
cancelText="Cancelar"
|
||||
onConfirm={handleDelete}
|
||||
onCancel={handleCancel}
|
||||
/>
|
||||
|
||||
{/* Formulário de criação/edição */}
|
||||
<GTBTipoLogradouroForm
|
||||
isOpen={isFormOpen}
|
||||
data={selectedTipoLogradouro}
|
||||
onClose={handleCloseForm}
|
||||
onSave={handleSave}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,163 @@
|
|||
'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() {
|
||||
// Hooks para leitura e salvamento
|
||||
const { tCensec, fetchTCensec } = useTCensecReadHook();
|
||||
const { saveTCensec } = useTCensecSaveHook();
|
||||
const { deleteTCensec } = useTCensecDeleteHook();
|
||||
|
||||
// Estados
|
||||
const [selectedAndamento, setSelectedAndamento] = useState<TCensecInterface | null>(null);
|
||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||
|
||||
// Estado para saber qual item será deletado
|
||||
const [itemToDelete, setItemToDelete] = useState<TCensecInterface | null>(null);
|
||||
|
||||
/**
|
||||
* Hook do modal de confirmação
|
||||
*/
|
||||
const {
|
||||
isOpen: isConfirmOpen,
|
||||
openDialog: openConfirmDialog,
|
||||
handleConfirm,
|
||||
handleCancel,
|
||||
} = useConfirmDialog();
|
||||
|
||||
/**
|
||||
* Abre o formulário no modo de edição ou criação
|
||||
*/
|
||||
const handleOpenForm = useCallback((data: TCensecInterface | null) => {
|
||||
setSelectedAndamento(data);
|
||||
setIsFormOpen(true);
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Fecha o formulário e limpa o andamento selecionado
|
||||
*/
|
||||
const handleCloseForm = useCallback(() => {
|
||||
setSelectedAndamento(null);
|
||||
setIsFormOpen(false);
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Salva os dados do formulário
|
||||
*/
|
||||
const handleSave = useCallback(async (formData: TCensecInterface) => {
|
||||
|
||||
// Aguarda salvar o registro
|
||||
await saveTCensec(formData);
|
||||
|
||||
// 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) {
|
||||
return <Loading type={2} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
{/* Cabeçalho */}
|
||||
<Header
|
||||
title={"CENSEC"}
|
||||
description={"Gerenciamento de Centrais"}
|
||||
buttonText={"Nova Central"}
|
||||
buttonAction={() => { handleOpenForm(null) }}
|
||||
/>
|
||||
|
||||
{/* Tabela de andamentos */}
|
||||
<Card>
|
||||
<CardContent>
|
||||
<TCensecTable
|
||||
data={tCensec}
|
||||
onEdit={handleOpenForm}
|
||||
onDelete={handleConfirmDelete}
|
||||
/>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Modal de confirmação */}
|
||||
<ConfirmDialog
|
||||
isOpen={isConfirmOpen}
|
||||
title="Confirmar exclusão"
|
||||
description="Atenção"
|
||||
message={`Deseja realmente excluir o andamento "${itemToDelete?.descricao}"?`}
|
||||
confirmText="Sim, excluir"
|
||||
cancelText="Cancelar"
|
||||
onConfirm={handleDelete}
|
||||
onCancel={handleCancel}
|
||||
/>
|
||||
|
||||
{/* Formulário de criação/edição */}
|
||||
<TCensecForm
|
||||
isOpen={isFormOpen}
|
||||
data={selectedAndamento}
|
||||
onClose={handleCloseForm}
|
||||
onSave={handleSave}
|
||||
/>
|
||||
</div>
|
||||
); 4
|
||||
}
|
||||
|
|
@ -0,0 +1,134 @@
|
|||
'use client';
|
||||
|
||||
import { useEffect, useState, useCallback } from "react";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDialog";
|
||||
|
||||
import Header from "@/app/_components/structure/Header";
|
||||
import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog";
|
||||
import Loading from "@/app/_components/loading/loading";
|
||||
|
||||
import TCensecNaturezaLitigioTable from "../../_components/t_censecnaturezalitigio/TCensecNaturezaLitigioTable";
|
||||
import TCensecNaturezaLitigioForm from "../../_components/t_censecnaturezalitigio/TCensecNaturezaLitigioForm";
|
||||
|
||||
import { useTCensecNaturezaLitigioReadHook } from "../../_hooks/t_censecnaturezalitigio/useTCensecNaturezaLitigioReadHook";
|
||||
import { useTCensecNaturezaLitigioSaveHook } from "../../_hooks/t_censecnaturezalitigio/useTCensecNaturezaLitigioSaveHook";
|
||||
import { useTCensecNaturezaLitigioRemoveHook } from "../../_hooks/t_censecnaturezalitigio/useTCensecNaturezaLitigioRemoveHook";
|
||||
|
||||
import { TCensecNaturezaLitigioInterface } from "../../_interfaces/TCensecNaturezaLitigioInterface";
|
||||
|
||||
const initialCensecNaturezaLitigio: TCensecNaturezaLitigioInterface = {
|
||||
censec_naturezalitigio_id: 0,
|
||||
descricao: "",
|
||||
situacao: 'A'
|
||||
}
|
||||
|
||||
export default function TCensecNaturezaLitigioPage() {
|
||||
|
||||
// Hooks
|
||||
const { tCensecNaturezaLitigio, fetchTCensecNaturezaLitigio } = useTCensecNaturezaLitigioReadHook();
|
||||
const { saveTCensecNaturezaLitigio } = useTCensecNaturezaLitigioSaveHook();
|
||||
const { removeTCensecNaturezaLitigio } = useTCensecNaturezaLitigioRemoveHook();
|
||||
|
||||
// Estados
|
||||
const [selectedItem, setSelectedItem] = useState<TCensecNaturezaLitigioInterface | null>(null);
|
||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||
const [itemToDelete, setItemToDelete] = useState<TCensecNaturezaLitigioInterface | null>(null);
|
||||
|
||||
// Modal de confirmação
|
||||
const {
|
||||
isOpen: isConfirmOpen,
|
||||
openDialog: openConfirmDialog,
|
||||
handleConfirm,
|
||||
handleCancel,
|
||||
} = useConfirmDialog();
|
||||
|
||||
// Abrir formulário (criação ou edição)
|
||||
const handleOpenForm = useCallback((item: TCensecNaturezaLitigioInterface | null) => {
|
||||
setSelectedItem(item);
|
||||
setIsFormOpen(true);
|
||||
}, []);
|
||||
|
||||
// Fechar formulário
|
||||
const handleCloseForm = useCallback(() => {
|
||||
setSelectedItem(null);
|
||||
setIsFormOpen(false);
|
||||
}, []);
|
||||
|
||||
// Salvar item
|
||||
const handleSave = useCallback(async (formData: TCensecNaturezaLitigioInterface) => {
|
||||
await saveTCensecNaturezaLitigio(formData);
|
||||
console.log(formData)
|
||||
await fetchTCensecNaturezaLitigio();
|
||||
}, [saveTCensecNaturezaLitigio, fetchTCensecNaturezaLitigio]);
|
||||
|
||||
// Confirmar remoção
|
||||
const handleConfirmDelete = useCallback((item: TCensecNaturezaLitigioInterface) => {
|
||||
console.log("item", item)
|
||||
setItemToDelete(item);
|
||||
openConfirmDialog();
|
||||
}, [openConfirmDialog]);
|
||||
|
||||
// Executar remoção
|
||||
const handleDelete = useCallback(async () => {
|
||||
if (!itemToDelete) return;
|
||||
console.log("item to delete",itemToDelete)
|
||||
await removeTCensecNaturezaLitigio(itemToDelete);
|
||||
await fetchTCensecNaturezaLitigio();
|
||||
setItemToDelete(null);
|
||||
handleCancel();
|
||||
}, [itemToDelete, fetchTCensecNaturezaLitigio, handleCancel]);
|
||||
|
||||
// Fetch inicial
|
||||
useEffect(() => {
|
||||
fetchTCensecNaturezaLitigio();
|
||||
}, []);
|
||||
|
||||
// Loading enquanto carrega
|
||||
if (!tCensecNaturezaLitigio) {
|
||||
return <Loading type={2} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
{/* Cabeçalho */}
|
||||
<Header
|
||||
title={"Natureza do Litígio"}
|
||||
description={"Gerenciamento de Naturezas do Litígio"}
|
||||
buttonText={"Nova Natureza"}
|
||||
buttonAction={(data) => handleOpenForm(data = initialCensecNaturezaLitigio)}
|
||||
/>
|
||||
|
||||
{/* Tabela */}
|
||||
<Card>
|
||||
<CardContent>
|
||||
<TCensecNaturezaLitigioTable
|
||||
data={tCensecNaturezaLitigio}
|
||||
onEdit={handleOpenForm}
|
||||
onDelete={handleConfirmDelete}
|
||||
/>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Modal de confirmação */}
|
||||
<ConfirmDialog
|
||||
isOpen={isConfirmOpen}
|
||||
title="Confirmar exclusão"
|
||||
description="Atenção"
|
||||
message={`Deseja realmente excluir a natureza "${itemToDelete?.descricao}"?`}
|
||||
confirmText="Sim, excluir"
|
||||
cancelText="Cancelar"
|
||||
onConfirm={handleDelete}
|
||||
onCancel={handleCancel}
|
||||
/>
|
||||
|
||||
{/* Formulário */}
|
||||
<TCensecNaturezaLitigioForm
|
||||
isOpen={isFormOpen}
|
||||
data={selectedItem}
|
||||
onClose={handleCloseForm}
|
||||
onSave={handleSave}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,83 @@
|
|||
'use client'
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import { useParams } from "next/navigation";
|
||||
|
||||
import {
|
||||
Card,
|
||||
CardContent
|
||||
} from "@/components/ui/card";
|
||||
import MainEditor from "@/components/MainEditor";
|
||||
|
||||
import Loading from "@/app/_components/loading/loading";
|
||||
import { useTMinutaReadHook } from '../../../../_hooks/t_minuta/useTMinutaReadHook';
|
||||
import { TMinutaInterface } from '../../../../_interfaces/TMinutaInterface';
|
||||
|
||||
export default function TMinutaDetalhes() {
|
||||
const params = useParams();
|
||||
const { tMinuta, fetchTMinuta } = useTMinutaReadHook();
|
||||
const [editorContent, setEditorContent] = useState<string | null>(null); // Inicialmente nulo até o texto ser carregado
|
||||
|
||||
useEffect(() => {
|
||||
if (params.id) {
|
||||
fetchTMinuta({ t_minuta_id: Number(params.id) } as TMinutaInterface);
|
||||
}
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (tMinuta?.texto) {
|
||||
setEditorContent(tMinuta.texto); // Atualiza o conteúdo assim que estiver disponível
|
||||
}
|
||||
}, [tMinuta]); // Dependência de `tMinuta` para que a atualização aconteça quando os dados chegarem
|
||||
|
||||
const handleEditorChange = (content: string) => {
|
||||
setEditorContent(content); // Atualiza o estado com o conteúdo do editor
|
||||
};
|
||||
|
||||
if (!tMinuta) return <Loading type={1} />;
|
||||
|
||||
// Renderiza o editor apenas se o texto foi carregado
|
||||
if (editorContent === null) {
|
||||
return <Loading type={1} />; // Pode mostrar um carregando ou qualquer outra coisa enquanto o conteúdo não está disponível
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Card>
|
||||
<CardContent>
|
||||
<div className="mb-4 grid gap-4 grid-cols-2">
|
||||
<div>
|
||||
<div className="text-2xl font-semibold">
|
||||
Descrição
|
||||
</div>
|
||||
<div className="text-xl">
|
||||
{tMinuta.descricao}
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div className="text-2xl font-semibold">
|
||||
Situação
|
||||
</div>
|
||||
<div className="text-xl">
|
||||
{tMinuta.situacao === "A" ? "Ativo" : "Inativo"}
|
||||
</div>
|
||||
</div>
|
||||
<div className="col-span-2">
|
||||
<div className="text-2xl font-semibold">
|
||||
Texto
|
||||
</div>
|
||||
<MainEditor
|
||||
initialValue={editorContent} // Passa o conteúdo do editor
|
||||
onEditorChange={handleEditorChange} // Função que atualiza o estado
|
||||
margins={{
|
||||
top: "2", bottom: "2", left: "2", right: "2"
|
||||
}}
|
||||
size={{ width: 794, height: 1123 }} // Você pode ajustar o tamanho aqui
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,113 @@
|
|||
'use client';
|
||||
|
||||
import z from 'zod';
|
||||
import { useEffect } from 'react';
|
||||
import { useForm, Controller } from 'react-hook-form';
|
||||
import { zodResolver } from '@hookform/resolvers/zod';
|
||||
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Checkbox } from '@/components/ui/checkbox';
|
||||
import {
|
||||
Form,
|
||||
FormControl,
|
||||
FormField,
|
||||
FormItem,
|
||||
FormLabel,
|
||||
FormMessage
|
||||
} from '@/components/ui/form';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Label } from '@/components/ui/label';
|
||||
|
||||
import MainEditor from '@/components/MainEditor';
|
||||
import { TMinutaSchema } from '../../../_schemas/TMinutaSchema';
|
||||
import { useTMinutaSaveHook } from '../../../_hooks/t_minuta/useTMinutaSaveHook';
|
||||
import { Card, CardContent } from '@/components/ui/card';
|
||||
|
||||
type FormValues = z.infer<typeof TMinutaSchema>;
|
||||
|
||||
export default function TMinutaForm() {
|
||||
|
||||
const { tMinuta, saveTMinuta } = useTMinutaSaveHook();
|
||||
|
||||
const form = useForm<FormValues>({
|
||||
resolver: zodResolver(TMinutaSchema),
|
||||
defaultValues: {
|
||||
natureza_id: undefined,
|
||||
descricao: '',
|
||||
situacao: 'A',
|
||||
texto: '',
|
||||
}
|
||||
});
|
||||
|
||||
async function onSubmit(values: FormValues) {
|
||||
saveTMinuta(values);
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Card>
|
||||
<CardContent>
|
||||
|
||||
<Form {...form}>
|
||||
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-6">
|
||||
|
||||
{/* Descrição */}
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="descricao"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Descrição</FormLabel>
|
||||
<FormControl>
|
||||
<Input {...field} placeholder="Digite a descrição da minuta" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
{/* Situação */}
|
||||
<Controller
|
||||
name="situacao"
|
||||
control={form.control}
|
||||
render={({ field }) => (
|
||||
<div className="flex items-center space-x-2">
|
||||
<Checkbox
|
||||
checked={field.value === "A"}
|
||||
onCheckedChange={(checked) => field.onChange(checked ? "A" : "I")}
|
||||
/>
|
||||
<Label>{field.value === "A" ? "Ativo" : "Inativo"}</Label>
|
||||
</div>
|
||||
)}
|
||||
/>
|
||||
|
||||
{/* Editor de Texto */}
|
||||
<Controller
|
||||
name="texto"
|
||||
control={form.control}
|
||||
render={({ field }) => (
|
||||
<div>
|
||||
<MainEditor
|
||||
initialValue={field.value || ""}
|
||||
onEditorChange={field.onChange}
|
||||
margins={{ top: '0', bottom: '0', left: '0', right: '0' }}
|
||||
size={{ width: 794, height: 1123 }}
|
||||
/>
|
||||
{form.formState.errors.texto && (
|
||||
<p className="text-sm text-red-500 mt-2">
|
||||
{form.formState.errors.texto.message}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
/>
|
||||
<Button type="submit">
|
||||
Salvar
|
||||
</Button>
|
||||
</form>
|
||||
</Form>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,107 @@
|
|||
'use client';
|
||||
|
||||
import { useEffect, useState, useCallback } from "react";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
import { useConfirmDialog } from "@/app/_components/confirm_dialog/useConfirmDialog";
|
||||
|
||||
import Header from "@/app/_components/structure/Header";
|
||||
import ConfirmDialog from "@/app/_components/confirm_dialog/ConfirmDialog";
|
||||
import Loading from "@/app/_components/loading/loading";
|
||||
|
||||
import TMinutaTable from "../../_components/t_minuta/TMinutaTable";
|
||||
import TMinutaForm from "../../_components/t_minuta/TMinutaForm";
|
||||
|
||||
import { useTMinutaReadHook } from "../../_hooks/t_minuta/useTMinutaReadHook";
|
||||
import { useTMinutaSaveHook } from "../../_hooks/t_minuta/useTMinutaSaveHook";
|
||||
import { useTMinutaRemoveHook } from "../../_hooks/t_minuta/useTMinutaRemoveHook";
|
||||
|
||||
import { TMinutaInterface } from "../../_interfaces/TMinutaInterface";
|
||||
import { useTMinutaIndexHook } from "../../_hooks/t_minuta/useTMinutaIndexHook";
|
||||
|
||||
export default function TMinutaPage() {
|
||||
|
||||
// Hooks de leitura e escrita
|
||||
const { tMinuta, fetchTMinuta } = useTMinutaIndexHook();
|
||||
const { saveTMinuta } = useTMinutaSaveHook();
|
||||
const { removeTMinuta } = useTMinutaRemoveHook();
|
||||
|
||||
// Estados
|
||||
const [selectedMinuta, setSelectedMinuta] = useState<TMinutaInterface | null>(null);
|
||||
const [isFormOpen, setIsFormOpen] = useState(false);
|
||||
const [itemToDelete, setItemToDelete] = useState<TMinutaInterface | null>(null);
|
||||
|
||||
// Hook de confirmação
|
||||
const {
|
||||
isOpen: isConfirmOpen,
|
||||
openDialog: openConfirmDialog,
|
||||
handleConfirm,
|
||||
handleCancel
|
||||
} = useConfirmDialog();
|
||||
|
||||
// Abertura do formulário
|
||||
const handleOpenForm = useCallback((data: TMinutaInterface | null) => {
|
||||
setSelectedMinuta(data);
|
||||
setIsFormOpen(true);
|
||||
}, []);
|
||||
|
||||
// Ação de clique em remover
|
||||
const handleConfirmDelete = useCallback((item: TMinutaInterface) => {
|
||||
setItemToDelete(item);
|
||||
openConfirmDialog();
|
||||
}, [openConfirmDialog]);
|
||||
|
||||
// Remoção da minuta após confirmação
|
||||
const handleDelete = useCallback(async () => {
|
||||
if (!itemToDelete) return;
|
||||
|
||||
await removeTMinuta(itemToDelete);
|
||||
await fetchTMinuta();
|
||||
setItemToDelete(null);
|
||||
handleCancel();
|
||||
}, [itemToDelete, removeTMinuta, fetchTMinuta, handleCancel]);
|
||||
|
||||
// Fetch inicial
|
||||
useEffect(() => {
|
||||
fetchTMinuta();
|
||||
}, []);
|
||||
|
||||
// Loading enquanto carrega
|
||||
if (tMinuta === undefined) {
|
||||
return <Loading type={2} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
{/* Cabeçalho */}
|
||||
<Header
|
||||
title="Minutas"
|
||||
description="Gerenciamento de minutas de atos notariais"
|
||||
buttonText="Nova Minuta"
|
||||
buttonAction={() => handleOpenForm(null)}
|
||||
/>
|
||||
|
||||
{/* Tabela */}
|
||||
<Card>
|
||||
<CardContent>
|
||||
<TMinutaTable
|
||||
data={tMinuta}
|
||||
onEdit={handleOpenForm}
|
||||
onDelete={handleConfirmDelete}
|
||||
/>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Diálogo de confirmação */}
|
||||
<ConfirmDialog
|
||||
isOpen={isConfirmOpen}
|
||||
title="Confirmar exclusão"
|
||||
description="Atenção"
|
||||
message={`Deseja realmente excluir a minuta "${itemToDelete?.descricao}"?`}
|
||||
confirmText="Sim, excluir"
|
||||
cancelText="Cancelar"
|
||||
onConfirm={handleDelete}
|
||||
onCancel={handleCancel}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -63,7 +63,7 @@ export default function TTBAndamentoServico() {
|
|||
|
||||
// Aguarda salvar o registro
|
||||
await saveTTBAndamentoServico(formData);
|
||||
|
||||
|
||||
// Atualiza a lista de dados
|
||||
fetchTTBAndamentoServico();
|
||||
|
||||
|
|
@ -73,13 +73,8 @@ export default function TTBAndamentoServico() {
|
|||
* Quando o usuário clica em "remover" na tabela
|
||||
*/
|
||||
const handleConfirmDelete = useCallback((item: TTBAndamentoServicoInterface) => {
|
||||
|
||||
// Define o item atual para remoção
|
||||
setItemToDelete(item);
|
||||
|
||||
// Abre o modal de confirmação
|
||||
openConfirmDialog();
|
||||
|
||||
}, [openConfirmDialog]);
|
||||
|
||||
/**
|
||||
|
|
@ -90,6 +85,7 @@ export default function TTBAndamentoServico() {
|
|||
// Protege contra null
|
||||
if (!itemToDelete) return;
|
||||
|
||||
|
||||
// Executa o Hook de remoção
|
||||
await deleteTTBAndamentoServico(itemToDelete);
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,125 @@
|
|||
'use client';
|
||||
|
||||
import z from "zod";
|
||||
import { useEffect } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
Dialog,
|
||||
DialogClose,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle
|
||||
} from "@/components/ui/dialog";
|
||||
import {
|
||||
Form,
|
||||
FormControl,
|
||||
FormField,
|
||||
FormItem,
|
||||
FormLabel,
|
||||
FormMessage
|
||||
} from "@/components/ui/form";
|
||||
import { Input } from "@/components/ui/input";
|
||||
|
||||
import { GMedidaTipoSchema } from "../../_schemas/GMedidaTipoSchema";
|
||||
import { GMedidaTipoInterface } from "../../_interfaces/GMedidaTipoInterface";
|
||||
|
||||
type FormValues = z.infer<typeof GMedidaTipoSchema>;
|
||||
|
||||
interface GMedidaTipoFormProps {
|
||||
isOpen: boolean;
|
||||
data: FormValues | null;
|
||||
onClose: (item: null, isFormStatus: boolean) => void;
|
||||
onSave: (data: FormValues) => void;
|
||||
}
|
||||
|
||||
export default function GMedidaTipoForm({ isOpen, data, onClose, onSave }: GMedidaTipoFormProps) {
|
||||
// Inicializa o react-hook-form com o schema Zod
|
||||
const form = useForm<FormValues>({
|
||||
resolver: zodResolver(GMedidaTipoSchema),
|
||||
defaultValues: {
|
||||
medida_tipo_id: 0,
|
||||
sigla: "",
|
||||
descricao: "",
|
||||
},
|
||||
});
|
||||
|
||||
// Atualiza o formulário quando recebe dados para edição
|
||||
useEffect(() => {
|
||||
if (data) form.reset(data);
|
||||
}, [data, form]);
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
open={isOpen}
|
||||
onOpenChange={(open) => {
|
||||
if (!open) onClose(null, false);
|
||||
}}
|
||||
>
|
||||
<DialogContent className="sm:max-w-[425px]">
|
||||
<DialogHeader>
|
||||
<DialogTitle>
|
||||
Tipo de Medida
|
||||
</DialogTitle>
|
||||
<DialogDescription>
|
||||
Crie ou edite um tipo de medida
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
|
||||
<Form {...form}>
|
||||
<form onSubmit={form.handleSubmit(onSave)} className="space-y-6">
|
||||
|
||||
{/* Descrição */}
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="descricao"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Descrição</FormLabel>
|
||||
<FormControl>
|
||||
<Input {...field} placeholder="Digite a descrição" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
{/* Sigla */}
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="sigla"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Sigla</FormLabel>
|
||||
<FormControl>
|
||||
<Input {...field} placeholder="Digite a sigla" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
{/* Rodapé do Dialog */}
|
||||
<DialogFooter className="mt-4">
|
||||
<DialogClose asChild>
|
||||
<Button variant="outline" type="button" onClick={() => onClose(null, false)} className="cursor-pointer">
|
||||
Cancelar
|
||||
</Button>
|
||||
</DialogClose>
|
||||
<Button type="submit" className="cursor-pointer">
|
||||
Salvar
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
|
||||
{/* Campo oculto */}
|
||||
<input type="hidden" {...form.register("medida_tipo_id")} />
|
||||
</form>
|
||||
</Form>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,96 @@
|
|||
'use client';
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuGroup,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableHead,
|
||||
TableHeader,
|
||||
TableRow
|
||||
} from "@/components/ui/table";
|
||||
import { EllipsisIcon, PencilIcon, Trash2Icon } from "lucide-react";
|
||||
import { GMedidaTipoInterface } from "../../_interfaces/GMedidaTipoInterface";
|
||||
|
||||
interface GMedidaTipoTableProps {
|
||||
data: GMedidaTipoInterface[];
|
||||
onEdit: (item: GMedidaTipoInterface, isEditingFormStatus: boolean) => void;
|
||||
onDelete: (item: GMedidaTipoInterface, isEditingFormStatus: boolean) => void;
|
||||
}
|
||||
|
||||
export default function GMedidaTipoTable({
|
||||
data,
|
||||
onEdit,
|
||||
onDelete
|
||||
}: GMedidaTipoTableProps) {
|
||||
return (
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>#</TableHead>
|
||||
<TableHead>Descrição</TableHead>
|
||||
<TableHead>Sigla</TableHead>
|
||||
<TableHead className="text-right">Ações</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
|
||||
<TableBody>
|
||||
{data.map((item) => (
|
||||
<TableRow
|
||||
key={item.medida_tipo_id}
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<TableCell className="font-medium">
|
||||
{item.medida_tipo_id}
|
||||
</TableCell>
|
||||
<TableCell>{item.descricao}</TableCell>
|
||||
<TableCell>{item.sigla}</TableCell>
|
||||
<TableCell className="text-right">
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<EllipsisIcon />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
|
||||
<DropdownMenuContent side="left" align="start">
|
||||
<DropdownMenuGroup>
|
||||
<DropdownMenuItem
|
||||
className="cursor-pointer"
|
||||
onSelect={() => onEdit(item, true)}
|
||||
>
|
||||
<PencilIcon className="mr-2 h-4 w-4" />
|
||||
Editar
|
||||
</DropdownMenuItem>
|
||||
|
||||
<DropdownMenuSeparator />
|
||||
|
||||
<DropdownMenuItem
|
||||
className="cursor-pointer"
|
||||
onSelect={() => onDelete(item, true)}
|
||||
>
|
||||
<Trash2Icon className="mr-2 h-4 w-4" />
|
||||
Remover
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuGroup>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,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 { GTBBairroSchema } from "../../_schemas/GTBBairroSchema";
|
||||
import { GTBBairroInterface } from "../../_interfaces/GTBBairroInterface";
|
||||
|
||||
type FormValues = z.infer<typeof GTBBairroSchema>;
|
||||
|
||||
interface GTBBairroFormProps {
|
||||
isOpen: boolean;
|
||||
data: FormValues | null;
|
||||
onClose: (item: null, isFormStatus: boolean) => void;
|
||||
onSave: (data: FormValues) => void;
|
||||
}
|
||||
|
||||
export default function GTBBairroForm({ isOpen, data, onClose, onSave }: GTBBairroFormProps) {
|
||||
// Inicializa o react-hook-form com o schema Zod
|
||||
const form = useForm<FormValues>({
|
||||
resolver: zodResolver(GTBBairroSchema),
|
||||
defaultValues: {
|
||||
sistema_id: null,
|
||||
tb_bairro_id: 0,
|
||||
descricao: "",
|
||||
situacao: "A",
|
||||
},
|
||||
});
|
||||
|
||||
// Atualiza o formulário quando recebe dados para edição
|
||||
useEffect(() => {
|
||||
if (data) form.reset(data);
|
||||
}, [data, form]);
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
open={isOpen}
|
||||
onOpenChange={(open) => {
|
||||
if (!open) onClose(null, false);
|
||||
}}
|
||||
>
|
||||
<DialogContent className="sm:max-w-[425px]">
|
||||
<DialogHeader>
|
||||
<DialogTitle>
|
||||
Bairro
|
||||
</DialogTitle>
|
||||
<DialogDescription>
|
||||
Crie ou edite um bairro
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
|
||||
<Form {...form}>
|
||||
<form onSubmit={form.handleSubmit(onSave)} className="space-y-6">
|
||||
|
||||
{/* Descrição */}
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="descricao"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Descrição</FormLabel>
|
||||
<FormControl>
|
||||
<Input {...field} placeholder="Digite a descrição do bairro" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
{/* Situação */}
|
||||
<Controller
|
||||
name="situacao"
|
||||
control={form.control}
|
||||
render={({ field }) => (
|
||||
<div className="flex items-center space-x-2">
|
||||
<Checkbox
|
||||
checked={field.value === "A"}
|
||||
onCheckedChange={(checked) => field.onChange(checked ? "A" : "I")}
|
||||
/>
|
||||
<Label>Ativo</Label>
|
||||
</div>
|
||||
)}
|
||||
/>
|
||||
|
||||
{/* Rodapé do Dialog */}
|
||||
<DialogFooter className="mt-4">
|
||||
<DialogClose asChild>
|
||||
<Button variant="outline" type="button" onClick={() => onClose(null, false)} className="cursor-pointer">
|
||||
Cancelar
|
||||
</Button>
|
||||
</DialogClose>
|
||||
<Button type="submit" className="cursor-pointer">
|
||||
Salvar
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
|
||||
{/* Campos ocultos */}
|
||||
<input type="hidden" {...form.register("tb_bairro_id")} />
|
||||
<input type="hidden" {...form.register("sistema_id")} />
|
||||
</form>
|
||||
</Form>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,123 @@
|
|||
'use client';
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuGroup,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableHead,
|
||||
TableHeader,
|
||||
TableRow
|
||||
} from "@/components/ui/table";
|
||||
import { EllipsisIcon, PencilIcon, Trash2Icon } from "lucide-react";
|
||||
import { GTBBairroInterface } from "../../_interfaces/GTBBairroInterface";
|
||||
|
||||
interface GTBBairroTableProps {
|
||||
data: GTBBairroInterface[];
|
||||
onEdit: (item: GTBBairroInterface, isEditingFormStatus: boolean) => void;
|
||||
onDelete: (item: GTBBairroInterface, isEditingFormStatus: boolean) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renderiza o badge de situação
|
||||
*/
|
||||
function StatusBadge({ situacao }: { situacao: 'A' | 'I' }) {
|
||||
const isActive = situacao === "A";
|
||||
|
||||
const baseClasses =
|
||||
"text-xs font-medium px-2.5 py-0.5 rounded-sm me-2";
|
||||
|
||||
const activeClasses =
|
||||
"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-300";
|
||||
|
||||
const inactiveClasses =
|
||||
"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300";
|
||||
|
||||
return (
|
||||
<span className={`${baseClasses} ${isActive ? activeClasses : inactiveClasses}`}>
|
||||
{isActive ? "Ativo" : "Inativo"}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
export default function GTBBairroTable({
|
||||
data,
|
||||
onEdit,
|
||||
onDelete
|
||||
}: GTBBairroTableProps) {
|
||||
return (
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>#</TableHead>
|
||||
<TableHead>Situação</TableHead>
|
||||
<TableHead>Descrição</TableHead>
|
||||
<TableHead className="text-right">Ações</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
|
||||
<TableBody>
|
||||
{data.map((item) => (
|
||||
<TableRow
|
||||
key={item.tb_bairro_id}
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<TableCell className="font-medium">
|
||||
{item.tb_bairro_id}
|
||||
</TableCell>
|
||||
|
||||
<TableCell>
|
||||
<StatusBadge situacao={item.situacao} />
|
||||
</TableCell>
|
||||
|
||||
<TableCell>{item.descricao}</TableCell>
|
||||
|
||||
<TableCell className="text-right">
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<EllipsisIcon />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
|
||||
<DropdownMenuContent side="left" align="start">
|
||||
<DropdownMenuGroup>
|
||||
<DropdownMenuItem
|
||||
className="cursor-pointer"
|
||||
onSelect={() => onEdit(item, true)}
|
||||
>
|
||||
<PencilIcon className="mr-2 h-4 w-4" />
|
||||
Editar
|
||||
</DropdownMenuItem>
|
||||
|
||||
<DropdownMenuSeparator />
|
||||
|
||||
<DropdownMenuItem
|
||||
className="cursor-pointer"
|
||||
onSelect={() => onDelete(item, true)}
|
||||
>
|
||||
<Trash2Icon className="mr-2 h-4 w-4" />
|
||||
Remover
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuGroup>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,129 @@
|
|||
'use client';
|
||||
|
||||
import z from "zod";
|
||||
import { useEffect } from "react";
|
||||
import { useForm, Controller } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Checkbox } from "@/components/ui/checkbox";
|
||||
import {
|
||||
Dialog,
|
||||
DialogClose,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle
|
||||
} from "@/components/ui/dialog";
|
||||
import {
|
||||
Form,
|
||||
FormControl,
|
||||
FormField,
|
||||
FormItem,
|
||||
FormLabel,
|
||||
FormMessage
|
||||
} from "@/components/ui/form";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
|
||||
import { GTBEstadoCivilSchema } from "../../_schemas/GTBEstadoCivilSchema";
|
||||
import { GTBEstadoCivilInterface } from "../../_interfaces/GTBEstadoCivilInterface";
|
||||
|
||||
type FormValues = z.infer<typeof GTBEstadoCivilSchema>;
|
||||
|
||||
interface TBEstadoCivilFormProps {
|
||||
isOpen: boolean;
|
||||
data: FormValues | null;
|
||||
onClose: (item: null, isFormStatus: boolean) => void;
|
||||
onSave: (data: FormValues) => void;
|
||||
}
|
||||
|
||||
export default function GTBEstadoCivilForm({ isOpen, data, onClose, onSave }: TBEstadoCivilFormProps) {
|
||||
// Inicializa o react-hook-form com o schema Zod
|
||||
const form = useForm<FormValues>({
|
||||
resolver: zodResolver(GTBEstadoCivilSchema),
|
||||
defaultValues: {
|
||||
tb_estadocivil_id: 0,
|
||||
sistema_id: 0,
|
||||
descricao: "",
|
||||
situacao: "A",
|
||||
},
|
||||
});
|
||||
|
||||
// Atualiza o formulário quando recebe dados para edição
|
||||
useEffect(() => {
|
||||
if (data) form.reset(data);
|
||||
}, [data, form]);
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
open={isOpen}
|
||||
onOpenChange={(open) => {
|
||||
if (!open) onClose(null, false);
|
||||
}}
|
||||
>
|
||||
<DialogContent className="sm:max-w-[425px]">
|
||||
<DialogHeader>
|
||||
<DialogTitle>
|
||||
Estado Civil
|
||||
</DialogTitle>
|
||||
<DialogDescription>
|
||||
Crie ou edite um estado civil
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
|
||||
<Form {...form}>
|
||||
<form onSubmit={form.handleSubmit(onSave)} className="space-y-6">
|
||||
|
||||
{/* Descrição */}
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="descricao"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Descrição</FormLabel>
|
||||
<FormControl>
|
||||
<Input {...field} placeholder="Digite a descrição" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
{/* Situação */}
|
||||
<Controller
|
||||
name="situacao"
|
||||
control={form.control}
|
||||
render={({ field }) => (
|
||||
<div className="flex items-center space-x-2">
|
||||
<Checkbox
|
||||
checked={field.value === "A"}
|
||||
onCheckedChange={(checked) => field.onChange(checked ? "A" : "I")}
|
||||
/>
|
||||
<Label>Ativo</Label>
|
||||
</div>
|
||||
)}
|
||||
/>
|
||||
|
||||
{/* Rodapé do Dialog */}
|
||||
<DialogFooter className="mt-4">
|
||||
<DialogClose asChild>
|
||||
<Button variant="outline" type="button" onClick={() => onClose(null, false)} className="cursor-pointer">
|
||||
Cancelar
|
||||
</Button>
|
||||
</DialogClose>
|
||||
<Button type="submit" className="cursor-pointer">
|
||||
Salvar
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
|
||||
{/* Campos ocultos */}
|
||||
<input type="hidden" {...form.register("tb_estadocivil_id", { valueAsNumber: true })} />
|
||||
<input type="hidden" {...form.register("sistema_id", { valueAsNumber: true })} />
|
||||
</form>
|
||||
</Form>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,123 @@
|
|||
'use client';
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuGroup,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableHead,
|
||||
TableHeader,
|
||||
TableRow
|
||||
} from "@/components/ui/table";
|
||||
import { EllipsisIcon, PencilIcon, Trash2Icon } from "lucide-react";
|
||||
import { GTBEstadoCivilInterface } from "../../_interfaces/GTBEstadoCivilInterface";
|
||||
|
||||
interface TBEstadoCivilTableProps {
|
||||
data: GTBEstadoCivilInterface[];
|
||||
onEdit: (item: GTBEstadoCivilInterface, isEditingFormStatus: boolean) => void;
|
||||
onDelete: (item: GTBEstadoCivilInterface, isEditingFormStatus: boolean) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renderiza o badge de situação
|
||||
*/
|
||||
function StatusBadge({ situacao }: { situacao: 'A' | 'I' }) {
|
||||
const isActive = situacao === "A";
|
||||
|
||||
const baseClasses =
|
||||
"text-xs font-medium px-2.5 py-0.5 rounded-sm me-2";
|
||||
|
||||
const activeClasses =
|
||||
"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-300";
|
||||
|
||||
const inactiveClasses =
|
||||
"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300";
|
||||
|
||||
return (
|
||||
<span className={`${baseClasses} ${isActive ? activeClasses : inactiveClasses}`}>
|
||||
{isActive ? "Ativo" : "Inativo"}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
export default function GTBEstadoCivilTable({
|
||||
data,
|
||||
onEdit,
|
||||
onDelete
|
||||
}: TBEstadoCivilTableProps) {
|
||||
return (
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>#</TableHead>
|
||||
<TableHead>Situação</TableHead>
|
||||
<TableHead>Descrição</TableHead>
|
||||
<TableHead className="text-right">Ações</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
|
||||
<TableBody>
|
||||
{data.map((item) => (
|
||||
<TableRow
|
||||
key={item.tb_estadocivil_id}
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<TableCell className="font-medium">
|
||||
{item.tb_estadocivil_id}
|
||||
</TableCell>
|
||||
|
||||
<TableCell>
|
||||
<StatusBadge situacao={item.situacao} />
|
||||
</TableCell>
|
||||
|
||||
<TableCell>{item.descricao}</TableCell>
|
||||
|
||||
<TableCell className="text-right">
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<EllipsisIcon />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
|
||||
<DropdownMenuContent side="left" align="start">
|
||||
<DropdownMenuGroup>
|
||||
<DropdownMenuItem
|
||||
className="cursor-pointer"
|
||||
onSelect={() => onEdit(item, true)}
|
||||
>
|
||||
<PencilIcon className="mr-2 h-4 w-4" />
|
||||
Editar
|
||||
</DropdownMenuItem>
|
||||
|
||||
<DropdownMenuSeparator />
|
||||
|
||||
<DropdownMenuItem
|
||||
className="cursor-pointer"
|
||||
onSelect={() => onDelete(item, true)}
|
||||
>
|
||||
<Trash2Icon className="mr-2 h-4 w-4" />
|
||||
Remover
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuGroup>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,127 @@
|
|||
'use client';
|
||||
|
||||
import z from "zod";
|
||||
import { useForm, Controller } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Checkbox } from "@/components/ui/checkbox";
|
||||
import {
|
||||
Dialog,
|
||||
DialogClose,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle
|
||||
} from "@/components/ui/dialog";
|
||||
import {
|
||||
Form,
|
||||
FormControl,
|
||||
FormField,
|
||||
FormItem,
|
||||
FormLabel,
|
||||
FormMessage
|
||||
} from "@/components/ui/form";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
|
||||
import { GTBRegimeBensSchema } from "../../_schemas/GTBRegimeBensSchema";
|
||||
import { useEffect } from "react";
|
||||
|
||||
type FormValues = z.infer<typeof GTBRegimeBensSchema>;
|
||||
|
||||
interface Props {
|
||||
isOpen: boolean;
|
||||
data: FormValues | null;
|
||||
onClose: (item: null, isFormStatus: boolean) => void;
|
||||
onSave: (data: FormValues) => void;
|
||||
}
|
||||
|
||||
export default function GTBRegimeComunhaoForm({ isOpen, data, onClose, onSave }: Props) {
|
||||
|
||||
// Inicializa o react-hook-form com schema zod
|
||||
const form = useForm<FormValues>({
|
||||
resolver: zodResolver(GTBRegimeBensSchema),
|
||||
defaultValues: {
|
||||
tb_regimebens_id: 0,
|
||||
descricao: "",
|
||||
situacao: "",
|
||||
},
|
||||
});
|
||||
|
||||
// Atualiza o formulário quando recebe dados para edição
|
||||
useEffect(() => {
|
||||
if (data) form.reset(data);
|
||||
}, [data, form]);
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
open={isOpen}
|
||||
onOpenChange={(open) => {
|
||||
if (!open) onClose(null, false);
|
||||
}}
|
||||
>
|
||||
<DialogContent className="sm:max-w-[425px]">
|
||||
<DialogHeader>
|
||||
<DialogTitle>
|
||||
Regimes de Bens
|
||||
</DialogTitle>
|
||||
<DialogDescription>
|
||||
Controle de Regimes de Vens
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
|
||||
<Form {...form}>
|
||||
<form onSubmit={form.handleSubmit(onSave)} className="space-y-6">
|
||||
|
||||
{/* Descrição */}
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="descricao"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Descrição</FormLabel>
|
||||
<FormControl>
|
||||
<Input {...field} placeholder="Digite a descrição" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
{/* Situação */}
|
||||
<Controller
|
||||
name="situacao"
|
||||
control={form.control}
|
||||
render={({ field }) => (
|
||||
<div className="flex items-center space-x-2">
|
||||
<Checkbox
|
||||
checked={field.value === "A"}
|
||||
onCheckedChange={(checked) => field.onChange(checked ? "A" : "I")}
|
||||
/>
|
||||
<Label>Ativo</Label>
|
||||
</div>
|
||||
)}
|
||||
/>
|
||||
|
||||
{/* Rodapé do Dialog */}
|
||||
<DialogFooter className="mt-4">
|
||||
<DialogClose asChild>
|
||||
<Button variant="outline" type="button" onClick={() => onClose(null, false)} className="cursor-pointer">
|
||||
Cancelar
|
||||
</Button>
|
||||
</DialogClose>
|
||||
<Button type="submit" className="cursor-pointer">
|
||||
Salvar
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
|
||||
{/* Campo oculto */}
|
||||
<input type="hidden" {...form.register("tb_regimebens_id")} />
|
||||
</form>
|
||||
</Form>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,126 @@
|
|||
'use client';
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuGroup,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableHead,
|
||||
TableHeader,
|
||||
TableRow
|
||||
} from "@/components/ui/table";
|
||||
|
||||
import { EllipsisIcon, PencilIcon, Trash2Icon } from "lucide-react";
|
||||
import GTBRegimeBensInterface from "../../_interfaces/GTBRegimeBensInterface";
|
||||
|
||||
interface GTBRegimeBensTableProps {
|
||||
data: GTBRegimeBensInterface[];
|
||||
onEdit: (item: GTBRegimeBensInterface, isEditingFormStatus: boolean) => void;
|
||||
onDelete: (item: GTBRegimeBensInterface, isEditingFormStatus: boolean) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renderiza o badge de situação
|
||||
*/
|
||||
function StatusBadge({ situacao }: { situacao: string }) {
|
||||
const isActive = situacao === "A";
|
||||
|
||||
const baseClasses =
|
||||
"text-xs font-medium px-2.5 py-0.5 rounded-sm me-2";
|
||||
|
||||
const activeClasses =
|
||||
"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-300";
|
||||
|
||||
const inactiveClasses =
|
||||
"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300";
|
||||
|
||||
return (
|
||||
<span className={`${baseClasses} ${isActive ? activeClasses : inactiveClasses}`}>
|
||||
{isActive ? "Ativo" : "Inativo"}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
export default function GTBRegimeBensTable({
|
||||
data,
|
||||
onEdit,
|
||||
onDelete
|
||||
}: GTBRegimeBensTableProps) {
|
||||
return (
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>#</TableHead>
|
||||
<TableHead>Situação</TableHead>
|
||||
<TableHead>Descrição</TableHead>
|
||||
<TableHead className="text-right">Ações</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
|
||||
<TableBody>
|
||||
{data.map((item) => (
|
||||
<TableRow
|
||||
key={item.tb_regimebens_id}
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<TableCell className="font-medium">
|
||||
{item.tb_regimebens_id}
|
||||
</TableCell>
|
||||
|
||||
<TableCell>
|
||||
<StatusBadge situacao={item.situacao} />
|
||||
</TableCell>
|
||||
|
||||
<TableCell>
|
||||
{item.descricao}
|
||||
</TableCell>
|
||||
|
||||
<TableCell className="text-right">
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<EllipsisIcon />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
|
||||
<DropdownMenuContent side="left" align="start">
|
||||
<DropdownMenuGroup>
|
||||
<DropdownMenuItem
|
||||
className="cursor-pointer"
|
||||
onSelect={() => onEdit(item, true)}
|
||||
>
|
||||
<PencilIcon className="mr-2 h-4 w-4" />
|
||||
Editar
|
||||
</DropdownMenuItem>
|
||||
|
||||
<DropdownMenuSeparator />
|
||||
|
||||
<DropdownMenuItem
|
||||
className="cursor-pointer"
|
||||
onSelect={() => onDelete(item, true)}
|
||||
>
|
||||
<Trash2Icon className="mr-2 h-4 w-4" />
|
||||
Remover
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuGroup>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,148 @@
|
|||
'use client';
|
||||
|
||||
import z from "zod";
|
||||
import { useEffect } from "react";
|
||||
import { useForm, Controller } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Checkbox } from "@/components/ui/checkbox";
|
||||
import {
|
||||
Dialog,
|
||||
DialogClose,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle
|
||||
} from "@/components/ui/dialog";
|
||||
import {
|
||||
Form,
|
||||
FormControl,
|
||||
FormField,
|
||||
FormItem,
|
||||
FormLabel,
|
||||
FormMessage
|
||||
} from "@/components/ui/form";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
|
||||
import { GTBTipoLogradouroSchema } from "../../_schemas/GTBTipoLogradouroSchema";
|
||||
import { GTBTipoLogradouroInterface } from "../../_interfaces/GTBTipoLogradouroInterface";
|
||||
|
||||
type FormValues = z.infer<typeof GTBTipoLogradouroSchema>;
|
||||
|
||||
interface GTBTipoLogradouroFormProps {
|
||||
isOpen: boolean;
|
||||
data: FormValues | null;
|
||||
onClose: (item: null, isFormStatus: boolean) => void;
|
||||
onSave: (data: FormValues) => void;
|
||||
}
|
||||
|
||||
export default function GTBTipoLogradouroForm({ isOpen, data, onClose, onSave }: GTBTipoLogradouroFormProps) {
|
||||
// Inicializa o react-hook-form com schema zod
|
||||
const form = useForm<FormValues>({
|
||||
resolver: zodResolver(GTBTipoLogradouroSchema),
|
||||
defaultValues: {
|
||||
sistema_id: null,
|
||||
tb_tipologradouro_id: 0,
|
||||
situacao_id: null,
|
||||
descricao: "",
|
||||
situacao: "A",
|
||||
onr_tipo_logradouro_id: 0
|
||||
},
|
||||
});
|
||||
|
||||
// Atualiza o formulário quando recebe dados para edição
|
||||
useEffect(() => {
|
||||
if (data) form.reset(data);
|
||||
}, [data, form]);
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
open={isOpen}
|
||||
onOpenChange={(open) => {
|
||||
if (!open) onClose(null, false);
|
||||
}}
|
||||
>
|
||||
<DialogContent className="sm:max-w-[425px]">
|
||||
<DialogHeader>
|
||||
<DialogTitle>
|
||||
Tipo de Logradouro
|
||||
</DialogTitle>
|
||||
<DialogDescription>
|
||||
Crie ou edite um tipo de logradouro
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
|
||||
<Form {...form}>
|
||||
<form onSubmit={form.handleSubmit(onSave)} className="space-y-6">
|
||||
|
||||
{/* Descrição */}
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="descricao"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Descrição</FormLabel>
|
||||
<FormControl>
|
||||
<Input {...field} placeholder="Digite a descrição" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
{/* ID do tipo logradouro na ONR */}
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="onr_tipo_logradouro_id"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>ID do tipo logradouro na ONR</FormLabel>
|
||||
<FormControl>
|
||||
<Input {...field} placeholder="Digite o valor" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
{/* Situação */}
|
||||
<Controller
|
||||
name="situacao"
|
||||
control={form.control}
|
||||
render={({ field }) => (
|
||||
<div className="flex items-center space-x-2">
|
||||
<Checkbox
|
||||
checked={field.value === "A"}
|
||||
onCheckedChange={(checked) => field.onChange(checked ? "A" : "I")}
|
||||
/>
|
||||
<Label>Ativo</Label>
|
||||
</div>
|
||||
)}
|
||||
/>
|
||||
|
||||
{/* Rodapé do Dialog */}
|
||||
<DialogFooter className="mt-4">
|
||||
<DialogClose asChild>
|
||||
<Button variant="outline" type="button" onClick={() => onClose(null, false)} className="cursor-pointer">
|
||||
Cancelar
|
||||
</Button>
|
||||
</DialogClose>
|
||||
<Button type="submit" className="cursor-pointer">
|
||||
Salvar
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
|
||||
{/* Campos ocultos */}
|
||||
<input type="hidden" {...form.register("tb_tipologradouro_id")} />
|
||||
<input type="hidden" {...form.register("sistema_id")} />
|
||||
<input type="hidden" {...form.register("situacao_id")} />
|
||||
<input type="hidden" {...form.register("onr_tipo_logradouro_id")} />
|
||||
</form>
|
||||
</Form>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,123 @@
|
|||
'use client';
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuGroup,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableHead,
|
||||
TableHeader,
|
||||
TableRow
|
||||
} from "@/components/ui/table";
|
||||
import { EllipsisIcon, PencilIcon, Trash2Icon } from "lucide-react";
|
||||
import { GTBTipoLogradouroInterface } from "../../_interfaces/GTBTipoLogradouroInterface";
|
||||
|
||||
interface GTBTipoLogradouroTableProps {
|
||||
data: GTBTipoLogradouroInterface[];
|
||||
onEdit: (item: GTBTipoLogradouroInterface, isEditingFormStatus: boolean) => void;
|
||||
onDelete: (item: GTBTipoLogradouroInterface, isEditingFormStatus: boolean) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renderiza o badge de situação
|
||||
*/
|
||||
function StatusBadge({ situacao }: { situacao: 'A' | 'I' }) {
|
||||
const isActive = situacao === "A";
|
||||
|
||||
const baseClasses =
|
||||
"text-xs font-medium px-2.5 py-0.5 rounded-sm me-2";
|
||||
|
||||
const activeClasses =
|
||||
"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-300";
|
||||
|
||||
const inactiveClasses =
|
||||
"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300";
|
||||
|
||||
return (
|
||||
<span className={`${baseClasses} ${isActive ? activeClasses : inactiveClasses}`}>
|
||||
{isActive ? "Ativo" : "Inativo"}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
export default function GTBTipoLogradouroTable({
|
||||
data,
|
||||
onEdit,
|
||||
onDelete
|
||||
}: GTBTipoLogradouroTableProps) {
|
||||
return (
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>#</TableHead>
|
||||
<TableHead>Situação</TableHead>
|
||||
<TableHead>Descrição</TableHead>
|
||||
<TableHead className="text-right">Ações</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
|
||||
<TableBody>
|
||||
{data.map((item) => (
|
||||
<TableRow
|
||||
key={item.tb_tipologradouro_id}
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<TableCell className="font-medium">
|
||||
{item.tb_tipologradouro_id}
|
||||
</TableCell>
|
||||
|
||||
<TableCell>
|
||||
<StatusBadge situacao={item.situacao} />
|
||||
</TableCell>
|
||||
|
||||
<TableCell>{item.descricao}</TableCell>
|
||||
|
||||
<TableCell className="text-right">
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<EllipsisIcon />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
|
||||
<DropdownMenuContent side="left" align="start">
|
||||
<DropdownMenuGroup>
|
||||
<DropdownMenuItem
|
||||
className="cursor-pointer"
|
||||
onSelect={() => onEdit(item, true)}
|
||||
>
|
||||
<PencilIcon className="mr-2 h-4 w-4" />
|
||||
Editar
|
||||
</DropdownMenuItem>
|
||||
|
||||
<DropdownMenuSeparator />
|
||||
|
||||
<DropdownMenuItem
|
||||
className="cursor-pointer"
|
||||
onSelect={() => onDelete(item, true)}
|
||||
>
|
||||
<Trash2Icon className="mr-2 h-4 w-4" />
|
||||
Remover
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuGroup>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,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 { TCensecSchema } from "../../_schemas/TCensecSchema";
|
||||
|
||||
type FormValues = z.infer<typeof TCensecSchema>;
|
||||
|
||||
interface Props {
|
||||
isOpen: boolean;
|
||||
data: FormValues | null;
|
||||
onClose: (item: null, isFormStatus: boolean) => void;
|
||||
onSave: (data: FormValues) => void;
|
||||
}
|
||||
|
||||
export default function TCensecForm({ isOpen, data, onClose, onSave }: Props) {
|
||||
// Inicializa o react-hook-form com schema zod
|
||||
const form = useForm<FormValues>({
|
||||
resolver: zodResolver(TCensecSchema),
|
||||
defaultValues: {
|
||||
descricao: "",
|
||||
situacao: "A",
|
||||
censec_id: 0,
|
||||
},
|
||||
});
|
||||
|
||||
// Atualiza o formulário quando recebe dados para edição
|
||||
useEffect(() => {
|
||||
if (data) form.reset(data);
|
||||
}, [data, form]);
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
open={isOpen}
|
||||
onOpenChange={(open) => {
|
||||
if (!open) onClose(null, false);
|
||||
}}
|
||||
>
|
||||
<DialogContent className="sm:max-w-[425px]">
|
||||
|
||||
<DialogHeader>
|
||||
<DialogTitle>
|
||||
Censec
|
||||
</DialogTitle>
|
||||
<DialogDescription>
|
||||
Tipos de Centrais
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
|
||||
<Form {...form}>
|
||||
<form onSubmit={form.handleSubmit(onSave)} className="space-y-6">
|
||||
|
||||
{/* Descrição */}
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="descricao"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Descrição</FormLabel>
|
||||
<FormControl>
|
||||
<Input type="text" {...field} placeholder="Digite a descrição" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
{/* Situação */}
|
||||
<Controller
|
||||
name="situacao"
|
||||
control={form.control}
|
||||
render={({ field }) => (
|
||||
<div className="flex items-center space-x-2">
|
||||
<Checkbox
|
||||
checked={field.value === "A"}
|
||||
onCheckedChange={(checked) => field.onChange(checked ? "A" : "I")}
|
||||
/>
|
||||
<Label>Ativo</Label>
|
||||
</div>
|
||||
)}
|
||||
/>
|
||||
|
||||
{/* Rodapé do Dialog */}
|
||||
<DialogFooter className="mt-4">
|
||||
<DialogClose asChild>
|
||||
<Button variant="outline" type="button" onClick={() => onClose(null, false)} className="cursor-pointer">
|
||||
Cancelar
|
||||
</Button>
|
||||
</DialogClose>
|
||||
<Button type="submit" className="cursor-pointer">
|
||||
Salvar
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
|
||||
{/* Campo oculto */}
|
||||
<input type="hidden" {...form.register("censec_id")} />
|
||||
</form>
|
||||
</Form>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,125 @@
|
|||
'use client';
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuGroup,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableHead,
|
||||
TableHeader,
|
||||
TableRow
|
||||
} from "@/components/ui/table";
|
||||
|
||||
import { EllipsisIcon, PencilIcon, Trash2Icon } from "lucide-react";
|
||||
import TCensecInterface from "../../_interfaces/TCensecInterface";
|
||||
|
||||
interface TCensecTableProps {
|
||||
data: TCensecInterface[];
|
||||
onEdit: (item: TCensecInterface, isEditingFormStatus: boolean) => void;
|
||||
onDelete: (item: TCensecInterface, isEditingFormStatus: boolean) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renderiza o badge de situação
|
||||
*/
|
||||
function StatusBadge({ situacao }: { situacao: string }) {
|
||||
const isActive = situacao === "A";
|
||||
|
||||
const baseClasses =
|
||||
"text-xs font-medium px-2.5 py-0.5 rounded-sm me-2";
|
||||
|
||||
const activeClasses =
|
||||
"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-300";
|
||||
|
||||
const inactiveClasses =
|
||||
"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300";
|
||||
|
||||
return (
|
||||
<span className={`${baseClasses} ${isActive ? activeClasses : inactiveClasses}`}>
|
||||
{isActive ? "Ativo" : "Inativo"}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
export default function TCensecTable({
|
||||
data,
|
||||
onEdit,
|
||||
onDelete
|
||||
}: TCensecTableProps) {
|
||||
return (
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>#</TableHead>
|
||||
<TableHead>Situação</TableHead>
|
||||
<TableHead>CBO</TableHead>
|
||||
<TableHead>Descrição</TableHead>
|
||||
<TableHead className="text-right">Ações</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
|
||||
<TableBody>
|
||||
{data.map((item) => (
|
||||
<TableRow
|
||||
key={item.censec_id}
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<TableCell className="font-medium">
|
||||
{item.censec_id}
|
||||
</TableCell>
|
||||
|
||||
<TableCell>
|
||||
<StatusBadge situacao={item.situacao} />
|
||||
</TableCell>
|
||||
|
||||
<TableCell>{item.descricao}</TableCell>
|
||||
|
||||
<TableCell className="text-right">
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<EllipsisIcon />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
|
||||
<DropdownMenuContent side="left" align="start">
|
||||
<DropdownMenuGroup>
|
||||
<DropdownMenuItem
|
||||
className="cursor-pointer"
|
||||
onSelect={() => onEdit(item, true)}
|
||||
>
|
||||
<PencilIcon className="mr-2 h-4 w-4" />
|
||||
Editar
|
||||
</DropdownMenuItem>
|
||||
|
||||
<DropdownMenuSeparator />
|
||||
|
||||
<DropdownMenuItem
|
||||
className="cursor-pointer"
|
||||
onSelect={() => onDelete(item, true)}
|
||||
>
|
||||
<Trash2Icon className="mr-2 h-4 w-4" />
|
||||
Remover
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuGroup>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,128 @@
|
|||
'use client';
|
||||
|
||||
import z from 'zod';
|
||||
import { useEffect } from 'react';
|
||||
import { useForm, Controller } from 'react-hook-form';
|
||||
import { zodResolver } from '@hookform/resolvers/zod';
|
||||
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Checkbox } from '@/components/ui/checkbox';
|
||||
import {
|
||||
Dialog,
|
||||
DialogClose,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle
|
||||
} from '@/components/ui/dialog';
|
||||
import {
|
||||
Form,
|
||||
FormControl,
|
||||
FormField,
|
||||
FormItem,
|
||||
FormLabel,
|
||||
FormMessage
|
||||
} from '@/components/ui/form';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Label } from '@/components/ui/label';
|
||||
|
||||
import { TCensecNaturezaLitigioSchema } from '../../_schemas/TCensecNaturezaLitigioSchema';
|
||||
|
||||
type FormValues = z.infer<typeof TCensecNaturezaLitigioSchema>;
|
||||
|
||||
interface TCensecNaturezaLitigioFormProps {
|
||||
isOpen: boolean;
|
||||
data: FormValues | null;
|
||||
onClose: (item: null, isFormStatus: boolean) => void;
|
||||
onSave: (data: FormValues) => void;
|
||||
}
|
||||
|
||||
export default function TCensecNaturezaLitigioForm({
|
||||
isOpen,
|
||||
data,
|
||||
onClose,
|
||||
onSave
|
||||
}: TCensecNaturezaLitigioFormProps) {
|
||||
const form = useForm<FormValues>({
|
||||
resolver: zodResolver(TCensecNaturezaLitigioSchema),
|
||||
defaultValues: {
|
||||
censec_naturezalitigio_id: 0,
|
||||
descricao: "",
|
||||
situacao: "A"
|
||||
}
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (data) form.reset(data);
|
||||
}, [data, form]);
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
open={isOpen}
|
||||
onOpenChange={(open) => {
|
||||
if (!open) onClose(null, false);
|
||||
}}
|
||||
>
|
||||
<DialogContent className="sm:max-w-[425px]">
|
||||
<DialogHeader>
|
||||
<DialogTitle>Natureza do Litígio</DialogTitle>
|
||||
<DialogDescription>
|
||||
Crie ou edite uma natureza do litígio
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
|
||||
<Form {...form}>
|
||||
<form onSubmit={form.handleSubmit(onSave)} className="space-y-6">
|
||||
|
||||
{/* Descrição */}
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="descricao"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Descrição</FormLabel>
|
||||
<FormControl>
|
||||
<Input {...field} placeholder="Digite a descrição" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
{/* Situação */}
|
||||
<Controller
|
||||
name="situacao"
|
||||
control={form.control}
|
||||
render={({ field }) => (
|
||||
<div className="flex items-center space-x-2">
|
||||
<Checkbox
|
||||
checked={field.value === "A"}
|
||||
onCheckedChange={(checked) => field.onChange(checked ? "A" : "I")}
|
||||
/>
|
||||
<Label>Ativo</Label>
|
||||
</div>
|
||||
)}
|
||||
/>
|
||||
|
||||
|
||||
{/* Rodapé */}
|
||||
<DialogFooter className="mt-4">
|
||||
<DialogClose asChild>
|
||||
<Button variant="outline" type="button" onClick={() => onClose(null, false)}>
|
||||
Cancelar
|
||||
</Button>
|
||||
</DialogClose>
|
||||
<Button type="submit">
|
||||
Salvar
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
|
||||
{/* Campo oculto */}
|
||||
<input type="hidden" {...form.register('censec_naturezalitigio_id')} />
|
||||
</form>
|
||||
</Form>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,123 @@
|
|||
'use client';
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuGroup,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableHead,
|
||||
TableHeader,
|
||||
TableRow
|
||||
} from "@/components/ui/table";
|
||||
import { EllipsisIcon, PencilIcon, Trash2Icon } from "lucide-react";
|
||||
import { TCensecNaturezaLitigioInterface } from "../../_interfaces/TCensecNaturezaLitigioInterface";
|
||||
|
||||
interface TCensecNaturezaLitigioTableProps {
|
||||
data: TCensecNaturezaLitigioInterface[];
|
||||
onEdit: (item: TCensecNaturezaLitigioInterface, isEditingFormStatus: boolean) => void;
|
||||
onDelete: (item: TCensecNaturezaLitigioInterface, isEditingFormStatus: boolean) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renderiza o badge de situação
|
||||
*/
|
||||
function StatusBadge({ situacao }: { situacao: 'A' | 'I' }) {
|
||||
const isActive = situacao === 'A';
|
||||
|
||||
const baseClasses =
|
||||
"text-xs font-medium px-2.5 py-0.5 rounded-sm me-2";
|
||||
|
||||
const activeClasses =
|
||||
"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-300";
|
||||
|
||||
const inactiveClasses =
|
||||
"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300";
|
||||
|
||||
return (
|
||||
<span className={`${baseClasses} ${isActive ? activeClasses : inactiveClasses}`}>
|
||||
{isActive ? "Ativo" : "Inativo"}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
export default function TCensecNaturezaLitigioTable({
|
||||
data,
|
||||
onEdit,
|
||||
onDelete
|
||||
}: TCensecNaturezaLitigioTableProps) {
|
||||
return (
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>#</TableHead>
|
||||
<TableHead>Situação</TableHead>
|
||||
<TableHead>Descrição</TableHead>
|
||||
<TableHead className="text-right">Ações</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
|
||||
<TableBody>
|
||||
{data.map((item) => (
|
||||
<TableRow
|
||||
key={item.censec_naturezalitigio_id}
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<TableCell className="font-medium">
|
||||
{item.censec_naturezalitigio_id}
|
||||
</TableCell>
|
||||
|
||||
<TableCell>
|
||||
<StatusBadge situacao={item.situacao} />
|
||||
</TableCell>
|
||||
|
||||
<TableCell>{item.descricao}</TableCell>
|
||||
|
||||
<TableCell className="text-right">
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<EllipsisIcon />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
|
||||
<DropdownMenuContent side="left" align="start">
|
||||
<DropdownMenuGroup>
|
||||
<DropdownMenuItem
|
||||
className="cursor-pointer"
|
||||
onSelect={() => onEdit(item, true)}
|
||||
>
|
||||
<PencilIcon className="mr-2 h-4 w-4" />
|
||||
Editar
|
||||
</DropdownMenuItem>
|
||||
|
||||
<DropdownMenuSeparator />
|
||||
|
||||
<DropdownMenuItem
|
||||
className="cursor-pointer"
|
||||
onSelect={() => onDelete(item, true)}
|
||||
>
|
||||
<Trash2Icon className="mr-2 h-4 w-4" />
|
||||
Remover
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuGroup>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,155 @@
|
|||
'use client';
|
||||
|
||||
import z from 'zod';
|
||||
import { useEffect } from 'react';
|
||||
import { useForm, Controller } from 'react-hook-form';
|
||||
import { zodResolver } from '@hookform/resolvers/zod';
|
||||
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Checkbox } from '@/components/ui/checkbox';
|
||||
import {
|
||||
Dialog,
|
||||
DialogClose,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle
|
||||
} from '@/components/ui/dialog';
|
||||
import {
|
||||
Form,
|
||||
FormControl,
|
||||
FormField,
|
||||
FormItem,
|
||||
FormLabel,
|
||||
FormMessage
|
||||
} from '@/components/ui/form';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Label } from '@/components/ui/label';
|
||||
|
||||
import MainEditor from '@/components/MainEditor';
|
||||
import { TMinutaInterface } from '../../_interfaces/TMinutaInterface';
|
||||
import { TMinutaSchema } from '../../_schemas/TMinutaSchema';
|
||||
|
||||
type FormValues = z.infer<typeof TMinutaSchema>;
|
||||
|
||||
interface TMinutaFormProps {
|
||||
isOpen: boolean;
|
||||
data: FormValues | null;
|
||||
onClose: (item: null, isFormStatus: boolean) => void;
|
||||
onSave: (data: FormValues) => void;
|
||||
}
|
||||
|
||||
export default function TMinutaForm({
|
||||
isOpen,
|
||||
data,
|
||||
onClose,
|
||||
onSave
|
||||
}: TMinutaFormProps) {
|
||||
|
||||
const form = useForm<FormValues>({
|
||||
resolver: zodResolver(TMinutaSchema),
|
||||
defaultValues: {
|
||||
minuta_id: 0,
|
||||
natureza_id: undefined,
|
||||
descricao: '',
|
||||
situacao: 'A',
|
||||
texto: '',
|
||||
}
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (data) form.reset(data);
|
||||
}, [data, form]);
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
open={isOpen}
|
||||
onOpenChange={(open) => {
|
||||
if (!open) onClose(null, false);
|
||||
}}
|
||||
>
|
||||
<DialogContent className="mx-auto"> {/* tamanho maior para comportar o editor */}
|
||||
<DialogHeader>
|
||||
<DialogTitle>Minuta</DialogTitle>
|
||||
<DialogDescription>
|
||||
Crie ou edite uma minuta de ato notarial.
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
|
||||
<Form {...form}>
|
||||
<form onSubmit={form.handleSubmit(onSave)} className="space-y-6">
|
||||
|
||||
{/* Descrição */}
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="descricao"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Descrição</FormLabel>
|
||||
<FormControl>
|
||||
<Input {...field} placeholder="Digite a descrição da minuta" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
{/* Situação */}
|
||||
<Controller
|
||||
name="situacao"
|
||||
control={form.control}
|
||||
render={({ field }) => (
|
||||
<div className="flex items-center space-x-2">
|
||||
<Checkbox
|
||||
checked={field.value === "A"}
|
||||
onCheckedChange={(checked) => field.onChange(checked ? "A" : "I")}
|
||||
/>
|
||||
<Label>{field.value === "A" ? "Ativo" : "Inativo"}</Label>
|
||||
</div>
|
||||
)}
|
||||
/>
|
||||
|
||||
{/* Editor de Texto */}
|
||||
<Controller
|
||||
name="texto"
|
||||
control={form.control}
|
||||
render={({ field }) => (
|
||||
<div>
|
||||
<MainEditor
|
||||
initialValue={field.value || ""}
|
||||
onEditorChange={field.onChange}
|
||||
margins={{ top: '2', bottom: '2', left: '3', right: '3' }}
|
||||
size={{ width: 800, height: 500 }}
|
||||
/>
|
||||
{form.formState.errors.texto && (
|
||||
<p className="text-sm text-red-500 mt-2">
|
||||
{form.formState.errors.texto.message}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
/>
|
||||
|
||||
{/* Rodapé do Dialog */}
|
||||
<DialogFooter className="mt-4">
|
||||
<DialogClose asChild>
|
||||
<Button variant="outline" type="button" onClick={() => onClose(null, false)}>
|
||||
Cancelar
|
||||
</Button>
|
||||
</DialogClose>
|
||||
<Button type="submit" disabled={form.formState.isSubmitting}>
|
||||
{form.formState.isSubmitting ? "Salvando..." : "Salvar"}
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
|
||||
{/* Campos ocultos */}
|
||||
<input type="hidden" {...form.register("minuta_id")} />
|
||||
<input type="hidden" {...form.register("natureza_id")} />
|
||||
|
||||
</form>
|
||||
</Form>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,97 @@
|
|||
'use client';
|
||||
|
||||
import Link from "next/link";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuGroup,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger,
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableHead,
|
||||
TableHeader,
|
||||
TableRow,
|
||||
} from "@/components/ui/table";
|
||||
import { EllipsisIcon, PencilIcon, Trash2Icon } from "lucide-react";
|
||||
import { TMinutaInterface } from "../../_interfaces/TMinutaInterface";
|
||||
|
||||
interface TMinutaTableProps {
|
||||
data: TMinutaInterface[];
|
||||
onEdit: (item: TMinutaInterface, isEditing: boolean) => void;
|
||||
onDelete: (item: TMinutaInterface, isEditing: boolean) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renderiza o badge de situação
|
||||
*/
|
||||
function StatusBadge({ situacao }: { situacao: 'A' | 'I' }) {
|
||||
const isActive = situacao === "A";
|
||||
|
||||
const baseClasses = "text-xs font-medium px-2.5 py-0.5 rounded-sm mr-2";
|
||||
|
||||
const activeClasses =
|
||||
"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-300";
|
||||
|
||||
const inactiveClasses =
|
||||
"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300";
|
||||
|
||||
return (
|
||||
<span className={`${baseClasses} ${isActive ? activeClasses : inactiveClasses}`}>
|
||||
{isActive ? "Ativo" : "Inativo"}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
export default function TMinutaTable({
|
||||
data,
|
||||
}: TMinutaTableProps) {
|
||||
return (
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>#</TableHead>
|
||||
<TableHead>Situação</TableHead>
|
||||
<TableHead>Descrição</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
|
||||
<TableBody>
|
||||
{data.length === 0 ? (
|
||||
<TableRow>
|
||||
<TableCell colSpan={4} className="text-center text-muted-foreground">
|
||||
Nenhuma minuta encontrada.
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
) : (
|
||||
data.map((item) => (
|
||||
<TableRow key={item.t_minuta_id} className="cursor-pointer">
|
||||
<TableCell className="font-medium">
|
||||
{item.t_minuta_id}
|
||||
</TableCell>
|
||||
|
||||
<TableCell>
|
||||
<StatusBadge situacao={item.situacao} />
|
||||
</TableCell>
|
||||
|
||||
<TableCell>{item.descricao}</TableCell>
|
||||
|
||||
<TableCell className="text-right">
|
||||
<Button asChild>
|
||||
<Link href={`/cadastros/minuta/${item.t_minuta_id}/detalhes`}>
|
||||
Detalhes
|
||||
</Link>
|
||||
</Button>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))
|
||||
)}
|
||||
</TableBody>
|
||||
</Table>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
import API from "@/services/api/Api";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
import MedidaTipoMockDeDados from "./mockMedidaTipo";
|
||||
|
||||
const useMock = true
|
||||
|
||||
export default async function GMedidaTipoIndexData() {
|
||||
if (useMock) {
|
||||
console.log(MedidaTipoMockDeDados())
|
||||
return await MedidaTipoMockDeDados();
|
||||
}
|
||||
|
||||
const api = new API();
|
||||
try {
|
||||
const dados = await api.send({
|
||||
method: Methods.GET,
|
||||
endpoint: `administrativo/g_medida_tipo/`
|
||||
});
|
||||
return dados
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
return error
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
import API from "@/services/api/Api";
|
||||
import { GMedidaTipoInterface } from "../../_interfaces/GMedidaTipoInterface";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
|
||||
export default async function GMedidaTipoRemoveData(data: GMedidaTipoInterface) {
|
||||
|
||||
const api = new API();
|
||||
|
||||
return await api.send({
|
||||
method: Methods.DELETE,
|
||||
endpoint: `administrativo/g_medida_tipo/${data.medida_tipo_id}`
|
||||
});
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
import API from "@/services/api/Api";
|
||||
import { GMedidaTipoInterface } from "../../_interfaces/GMedidaTipoInterface";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
|
||||
export default async function GMedidaTipoSaveData(data: GMedidaTipoInterface) {
|
||||
|
||||
const isUpdate = Boolean(data.medida_tipo_id);
|
||||
|
||||
const api = new API();
|
||||
|
||||
return await api.send({
|
||||
method: isUpdate ? Methods.PUT : Methods.POST,
|
||||
endpoint: `administrativo/g_medida_tipo/${data.medida_tipo_id || ''}`,
|
||||
body: data
|
||||
});
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
export default async function MedidaTipoMockDeDados() {
|
||||
return Promise.resolve({
|
||||
status: 200,
|
||||
message: 'Dados localizados',
|
||||
data: [
|
||||
{
|
||||
medida_tipo_id: 1.00,
|
||||
sigla: "Alqueire",
|
||||
descricao: "Alqueire"
|
||||
},
|
||||
{
|
||||
medida_tipo_id: 2.00,
|
||||
sigla: "ha",
|
||||
descricao: "Hectare"
|
||||
},
|
||||
{
|
||||
medida_tipo_id: 3.00,
|
||||
sigla: "m2",
|
||||
descricao: "Metros Quadrados"
|
||||
},
|
||||
{
|
||||
medida_tipo_id: 4.00,
|
||||
sigla: "braça",
|
||||
descricao: "Braça"
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
import API from "@/services/api/Api";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
import BairroMockDeDados from "./mockBairro";
|
||||
|
||||
const useMock = false
|
||||
|
||||
export default async function GTBBairroIndexData() {
|
||||
if (useMock) {
|
||||
console.log(BairroMockDeDados())
|
||||
return await BairroMockDeDados();
|
||||
}
|
||||
|
||||
const api = new API();
|
||||
try {
|
||||
const dados = await api.send({
|
||||
method: Methods.GET,
|
||||
endpoint: `administrativo/g_tb_bairro/`
|
||||
});
|
||||
return dados
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
return error
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
import API from "@/services/api/Api";
|
||||
import { GTBBairroInterface } from "../../_interfaces/GTBBairroInterface";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
|
||||
export default async function GTBBairroRemoveData(data: GTBBairroInterface) {
|
||||
|
||||
const api = new API();
|
||||
|
||||
return await api.send({
|
||||
method: Methods.DELETE,
|
||||
endpoint: `administrativo/g_tb_bairro/${data.tb_bairro_id}`
|
||||
});
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
import API from "@/services/api/Api";
|
||||
import { GTBBairroInterface } from "../../_interfaces/GTBBairroInterface";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
|
||||
export default async function GTBBairroSaveData(data: GTBBairroInterface) {
|
||||
|
||||
const isUpdate = Boolean(data.tb_bairro_id);
|
||||
|
||||
const api = new API();
|
||||
|
||||
return await api.send({
|
||||
method: isUpdate ? Methods.PUT : Methods.POST,
|
||||
endpoint: `administrativo/g_tb_bairro/${data.tb_bairro_id || ''}`,
|
||||
body: data
|
||||
});
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
import { GTBBairroInterface } from "../../_interfaces/GTBBairroInterface";
|
||||
|
||||
export default async function BairroMockDeDados() {
|
||||
return Promise.resolve({
|
||||
status: 200,
|
||||
message: 'Dados localizados',
|
||||
data: [
|
||||
{
|
||||
sistema_id: 1.00,
|
||||
tb_bairro_id: 390.00,
|
||||
descricao: "AV. RUI BARBOSA",
|
||||
situacao: "A"
|
||||
},
|
||||
{
|
||||
sistema_id: 1.00,
|
||||
tb_bairro_id: 391.00,
|
||||
descricao: "AV. PRESIDENTE DUTRA",
|
||||
situacao: "A"
|
||||
},
|
||||
{
|
||||
sistema_id: 1.00,
|
||||
tb_bairro_id: 392.00,
|
||||
descricao: "LOTEAMENTO CIDADE MARA ROSA",
|
||||
situacao: "A"
|
||||
},
|
||||
{
|
||||
sistema_id: 1.00,
|
||||
tb_bairro_id: 393.00,
|
||||
descricao: "LOTEAMENTO BENEDITO COELHO FURTADO",
|
||||
situacao: "A"
|
||||
},
|
||||
{
|
||||
sistema_id: 1.00,
|
||||
tb_bairro_id: 394.00,
|
||||
descricao: "RUA 15 DE NOVEMBRO",
|
||||
situacao: "A"
|
||||
},
|
||||
{
|
||||
sistema_id: 1.00,
|
||||
tb_bairro_id: 395.00,
|
||||
descricao: "PRACA JOSÉ MAURICIO DE MOURA",
|
||||
situacao: "A"
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
import API from "@/services/api/Api";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
import EstadoCivilMockDeDados from "./mockEstadoCivil";
|
||||
|
||||
const useMock = true
|
||||
|
||||
export default async function GTBEstadoCivilIndexData() {
|
||||
if (useMock) {
|
||||
console.log(EstadoCivilMockDeDados())
|
||||
return await EstadoCivilMockDeDados();
|
||||
}
|
||||
|
||||
const api = new API();
|
||||
try {
|
||||
const dados = await api.send({
|
||||
method: Methods.GET,
|
||||
endpoint: `administrativo/g_tb_estado_civil/`
|
||||
});
|
||||
return dados
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
return error
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
import API from "@/services/api/Api";
|
||||
import { GTBEstadoCivilInterface } from "../../_interfaces/GTBEstadoCivilInterface";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
|
||||
export default async function GTBEstadoCivilRemoveData(data: GTBEstadoCivilInterface) {
|
||||
|
||||
const api = new API();
|
||||
|
||||
return await api.send({
|
||||
method: Methods.DELETE,
|
||||
endpoint: `administrativo/g_tb_bairro/${data.tb_estadocivil_id}`
|
||||
});
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
import API from "@/services/api/Api";
|
||||
import { GTBEstadoCivilInterface } from "../../_interfaces/GTBEstadoCivilInterface";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
|
||||
export default async function GTBEstadoCivilSaveData(data: GTBEstadoCivilInterface) {
|
||||
|
||||
const isUpdate = Boolean(data.tb_estadocivil_id);
|
||||
|
||||
const api = new API();
|
||||
|
||||
return await api.send({
|
||||
method: isUpdate ? Methods.PUT : Methods.POST,
|
||||
endpoint: `administrativo/g_tb_bairro/${data.tb_estadocivil_id || ''}`,
|
||||
body: data
|
||||
});
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
import { GTBBairroInterface } from "../../_interfaces/GTBBairroInterface";
|
||||
|
||||
export default async function EstadoCivilMockDeDados() {
|
||||
return Promise.resolve({
|
||||
status: 200,
|
||||
message: 'Dados localizados',
|
||||
data: [
|
||||
{
|
||||
tb_estadocivil_id: 26.00,
|
||||
sistema_id: 2.00,
|
||||
descricao: "casado",
|
||||
situacao: "A",
|
||||
},
|
||||
{
|
||||
tb_estadocivil_id: 27.00,
|
||||
sistema_id: 2.00,
|
||||
descricao: "solteiro(a)",
|
||||
situacao: "A",
|
||||
},
|
||||
{
|
||||
tb_estadocivil_id: 28.00,
|
||||
sistema_id: 2.00,
|
||||
descricao: "desquitado(a)",
|
||||
situacao: "A",
|
||||
},
|
||||
{
|
||||
tb_estadocivil_id: 29.00,
|
||||
sistema_id: 2.00,
|
||||
descricao: "divorciado(a)",
|
||||
situacao: "A",
|
||||
},
|
||||
{
|
||||
tb_estadocivil_id: 30.00,
|
||||
sistema_id: 2.00,
|
||||
descricao: "espólio",
|
||||
situacao: "A",
|
||||
},
|
||||
{
|
||||
tb_estadocivil_id: 31.00,
|
||||
sistema_id: 2.00,
|
||||
descricao: "menor impúbere",
|
||||
situacao: "A",
|
||||
},
|
||||
{
|
||||
tb_estadocivil_id: 32.00,
|
||||
sistema_id: 2.00,
|
||||
descricao: "menor púbere",
|
||||
situacao: "A",
|
||||
},
|
||||
{
|
||||
tb_estadocivil_id: 33.00,
|
||||
sistema_id: 2.00,
|
||||
descricao: "não consta",
|
||||
situacao: "A",
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
|
@ -1,14 +1,14 @@
|
|||
import API from "@/services/api/Api";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
import GTBRegimeComunhaoInterface from "../../_interfaces/GTBRegimeComunhaoInterface";
|
||||
import GTBRegimeBensInterface from "../../_interfaces/GTBRegimeBensInterface";
|
||||
|
||||
export default async function GTBRegimeBensRemoveData(data: GTBRegimeComunhaoInterface) {
|
||||
export default async function GTBRegimeBensRemoveData(data: GTBRegimeBensInterface) {
|
||||
|
||||
const api = new API();
|
||||
|
||||
return await api.send({
|
||||
method: Methods.DELETE,
|
||||
endpoint: `administrativo/g_tb_regimecomunhao/${data.tb_regimecomunhao_id}`
|
||||
endpoint: `administrativo/g_tb_regimebens/${data.tb_regimebens_id}`
|
||||
});
|
||||
|
||||
}
|
||||
|
|
@ -1,16 +1,21 @@
|
|||
import API from "@/services/api/Api";
|
||||
import GTBRegimeComunhaoInterface from "../../_interfaces/GTBRegimeComunhaoInterface";
|
||||
import GTBRegimeBensInterface from "../../_interfaces/GTBRegimeBensInterface";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
import { withClientErrorHandler } from "@/actions/withClientErrorHandler/withClientErrorHandler";
|
||||
|
||||
export default async function GTBRegimeBensSaveData(data: GTBRegimeComunhaoInterface) {
|
||||
async function executeGTBRegimeBensSaveData(data: GTBRegimeBensInterface) {
|
||||
|
||||
const isUpdate = Boolean(data.tb_regimecomunhao_id);
|
||||
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_regimecomunhao/${data.tb_regimecomunhao_id || ''}`,
|
||||
endpoint: `administrativo/g_tb_regimebens/${data.tb_regimebens_id || ''}`,
|
||||
body: data
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export const GTBRegimeBensSaveData = withClientErrorHandler(executeGTBRegimeBensSaveData);
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
import API from "@/services/api/Api";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
import TipoLogradouroMockDeDados from "./mockTipoLogradouro";
|
||||
|
||||
const useMock = false
|
||||
|
||||
export default async function GTBTipoLogradouroIndexData() {
|
||||
if (useMock) {
|
||||
console.log(TipoLogradouroMockDeDados())
|
||||
return await TipoLogradouroMockDeDados();
|
||||
}
|
||||
|
||||
const api = new API();
|
||||
try {
|
||||
const dados = await api.send({
|
||||
method: Methods.GET,
|
||||
endpoint: `administrativo/g_tb_tipologradouro/`
|
||||
});
|
||||
return dados
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
return error
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
import API from "@/services/api/Api";
|
||||
import { GTBTipoLogradouroInterface } from "../../_interfaces/GTBTipoLogradouroInterface";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
|
||||
export default async function GTBTipoLogradouroRemoveData(data: GTBTipoLogradouroInterface) {
|
||||
|
||||
const api = new API();
|
||||
|
||||
return await api.send({
|
||||
method: Methods.DELETE,
|
||||
endpoint: `administrativo/g_tb_tipologradouro/${data.tb_tipologradouro_id}`
|
||||
});
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
import API from "@/services/api/Api";
|
||||
import { GTBTipoLogradouroInterface } from "../../_interfaces/GTBTipoLogradouroInterface";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
|
||||
export default async function GTBTipoLogradouroSaveData(data: GTBTipoLogradouroInterface) {
|
||||
|
||||
const isUpdate = Boolean(data.tb_tipologradouro_id);
|
||||
|
||||
const api = new API();
|
||||
|
||||
return await api.send({
|
||||
method: isUpdate ? Methods.PUT : Methods.POST,
|
||||
endpoint: `administrativo/g_tb_tipologradouro/${data.tb_tipologradouro_id || ''}`,
|
||||
body: data
|
||||
});
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,98 @@
|
|||
import { GTBTipoLogradouroInterface } from "../../_interfaces/GTBTipoLogradouroInterface";
|
||||
|
||||
export default async function TipoLogradouroMockDeDados(){
|
||||
return Promise.resolve({
|
||||
status: 200,
|
||||
message: 'Dados localizados',
|
||||
data: [
|
||||
{
|
||||
sistema_id: null,
|
||||
tb_tipologradouro_id: 1,
|
||||
situacao_id: null,
|
||||
descricao: "Rua",
|
||||
situacao: "A",
|
||||
onr_tipo_logradouro_id: 250
|
||||
},
|
||||
{
|
||||
sistema_id: null,
|
||||
tb_tipologradouro_id: 2,
|
||||
situacao_id: null,
|
||||
descricao: "Avenida",
|
||||
situacao: "A",
|
||||
onr_tipo_logradouro_id: 26
|
||||
},
|
||||
{
|
||||
sistema_id: null,
|
||||
tb_tipologradouro_id: 3,
|
||||
situacao_id: null,
|
||||
descricao: "Alameda",
|
||||
situacao: "A",
|
||||
onr_tipo_logradouro_id: 10
|
||||
},
|
||||
{
|
||||
sistema_id: null,
|
||||
tb_tipologradouro_id: 4,
|
||||
situacao_id: null,
|
||||
descricao: "Praça",
|
||||
situacao: "A",
|
||||
onr_tipo_logradouro_id: 215
|
||||
},
|
||||
{
|
||||
sistema_id: null,
|
||||
tb_tipologradouro_id: 5,
|
||||
situacao_id: null,
|
||||
descricao: "Via",
|
||||
situacao: "A",
|
||||
onr_tipo_logradouro_id: 294
|
||||
},
|
||||
{
|
||||
sistema_id: null,
|
||||
tb_tipologradouro_id: 6,
|
||||
situacao_id: null,
|
||||
descricao: "Viela",
|
||||
situacao: "A",
|
||||
onr_tipo_logradouro_id: 297
|
||||
},
|
||||
{
|
||||
sistema_id: null,
|
||||
tb_tipologradouro_id: 7,
|
||||
situacao_id: null,
|
||||
descricao: "Travessa",
|
||||
situacao: "A",
|
||||
onr_tipo_logradouro_id: 273
|
||||
},
|
||||
{
|
||||
sistema_id: null,
|
||||
tb_tipologradouro_id: 8,
|
||||
situacao_id: null,
|
||||
descricao: "Rodovia",
|
||||
situacao: "A",
|
||||
onr_tipo_logradouro_id: 247
|
||||
},
|
||||
{
|
||||
sistema_id: null,
|
||||
tb_tipologradouro_id: 9,
|
||||
situacao_id: null,
|
||||
descricao: "Sítios",
|
||||
situacao: "A",
|
||||
onr_tipo_logradouro_id: 263
|
||||
},
|
||||
{
|
||||
sistema_id: null,
|
||||
tb_tipologradouro_id: 10,
|
||||
situacao_id: null,
|
||||
descricao: "Córrego",
|
||||
situacao: "A",
|
||||
onr_tipo_logradouro_id: 86
|
||||
},
|
||||
{
|
||||
sistema_id: null,
|
||||
tb_tipologradouro_id: 11,
|
||||
situacao_id: null,
|
||||
descricao: "Estrada",
|
||||
situacao: "A",
|
||||
onr_tipo_logradouro_id: 117
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
import TCensecInterface from "../../_interfaces/TCensecInterface";
|
||||
|
||||
export default async function TCensecDeleteData(data: TCensecInterface) {
|
||||
|
||||
return Promise.resolve({
|
||||
message: 'Dados removidos',
|
||||
status: 200
|
||||
});
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
export default async function TCensecIndexData() {
|
||||
|
||||
return Promise.resolve({
|
||||
message: 'Dados localizados',
|
||||
status: 200,
|
||||
data: [
|
||||
{
|
||||
censec_id: 1.00,
|
||||
descricao: 'CEP - Escritura e Procurações Diversas',
|
||||
situacao: 'A'
|
||||
},
|
||||
{
|
||||
censec_id: 2.00,
|
||||
descricao: 'CESDI - Escrituras Lei 11.441',
|
||||
situacao: 'A'
|
||||
},
|
||||
{
|
||||
censec_id: 3.00,
|
||||
descricao: 'RCTO - Testamentos',
|
||||
situacao: 'A'
|
||||
},
|
||||
{
|
||||
censec_id: 9.00,
|
||||
descricao: 'Não Possui',
|
||||
situacao: 'A'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
import TCensecInterface from "../../_interfaces/TCensecInterface";
|
||||
|
||||
export default async function TCensecSaveData(data: TCensecInterface) {
|
||||
|
||||
return Promise.resolve({
|
||||
message: 'Dados salvos',
|
||||
status: 201,
|
||||
data: {
|
||||
censec_id: 9.00,
|
||||
descricao: 'Não Possui',
|
||||
situacao: 'A'
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
import API from "@/services/api/Api";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
import CensecNaturezaLitigioMockDeDados from "./mockCensecNaturezaLitigio";
|
||||
|
||||
const useMock = false
|
||||
|
||||
export default async function TCensecNaturezaLitigioIndexData() {
|
||||
|
||||
if (useMock) {
|
||||
return await CensecNaturezaLitigioMockDeDados();
|
||||
}
|
||||
|
||||
const api = new API();
|
||||
try {
|
||||
const dados = await api.send({
|
||||
method: Methods.GET,
|
||||
endpoint: `administrativo/t_censec_naturezalitigio/`
|
||||
});
|
||||
return dados
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
return error
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
import API from "@/services/api/Api";
|
||||
import { TCensecNaturezaLitigioInterface } from "../../_interfaces/TCensecNaturezaLitigioInterface";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
|
||||
export default async function TCensecNaturezaLitigioRemoveData(data: TCensecNaturezaLitigioInterface) {
|
||||
|
||||
const api = new API();
|
||||
|
||||
console.log(typeof(data.censec_naturezalitigio_id))
|
||||
|
||||
return await api.send({
|
||||
method: Methods.DELETE,
|
||||
endpoint: `administrativo/t_censec_naturezalitigio/${data.censec_naturezalitigio_id}`
|
||||
});
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
import API from "@/services/api/Api";
|
||||
import { TCensecNaturezaLitigioInterface } from "../../_interfaces/TCensecNaturezaLitigioInterface";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
|
||||
export default async function TCensecNaturezaLitigioTipoSaveData(data: TCensecNaturezaLitigioInterface) {
|
||||
|
||||
const api = new API();
|
||||
|
||||
return await api.send({
|
||||
method: data.censec_naturezalitigio_id ? Methods.PUT : Methods.POST,
|
||||
endpoint: `administrativo/t_censec_naturezalitigio/${data.censec_naturezalitigio_id ? data.censec_naturezalitigio_id : ''}`,
|
||||
body: data
|
||||
});
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,113 @@
|
|||
export default async function CensecNaturezaLitigioMockDeDados() {
|
||||
return Promise.resolve({
|
||||
status: 200,
|
||||
message: 'Dados localizados',
|
||||
data: [
|
||||
{
|
||||
censec_naturezaltigio_id: 1,
|
||||
descricao: "Bancário",
|
||||
situacao: "A"
|
||||
},
|
||||
{
|
||||
censec_naturezaltigio_id: 2,
|
||||
descricao: "Concessionária de Água",
|
||||
situacao: "A"
|
||||
},
|
||||
{
|
||||
censec_naturezaltigio_id: 3,
|
||||
descricao: "Concessionária de Gás",
|
||||
situacao: "A"
|
||||
},
|
||||
{
|
||||
censec_naturezaltigio_id: 4,
|
||||
descricao: "Concessionária de Luz",
|
||||
situacao: "A"
|
||||
},
|
||||
{
|
||||
censec_naturezaltigio_id: 5,
|
||||
descricao: "Consumidor",
|
||||
situacao: "A"
|
||||
},
|
||||
{
|
||||
censec_naturezaltigio_id: 6,
|
||||
descricao: "Contrato",
|
||||
situacao: "A"
|
||||
},
|
||||
{
|
||||
censec_naturezaltigio_id: 7,
|
||||
descricao: "Empresarial",
|
||||
situacao: "A"
|
||||
},
|
||||
{
|
||||
censec_naturezaltigio_id: 8,
|
||||
descricao: "Família",
|
||||
situacao: "A"
|
||||
},
|
||||
{
|
||||
censec_naturezaltigio_id: 9,
|
||||
descricao: "Locação",
|
||||
situacao: "A"
|
||||
},
|
||||
{
|
||||
censec_naturezaltigio_id: 10,
|
||||
descricao: "Mobiliário",
|
||||
situacao: "A"
|
||||
},
|
||||
{
|
||||
censec_naturezaltigio_id: 11,
|
||||
descricao: "Previdência",
|
||||
situacao: "A"
|
||||
},
|
||||
{
|
||||
censec_naturezaltigio_id: 12,
|
||||
descricao: "Saúde",
|
||||
situacao: "A"
|
||||
},
|
||||
{
|
||||
censec_naturezaltigio_id: 13,
|
||||
descricao: "Seguro",
|
||||
situacao: "A"
|
||||
},
|
||||
{
|
||||
censec_naturezaltigio_id: 14,
|
||||
descricao: "Serviço Público",
|
||||
situacao: "A"
|
||||
},
|
||||
{
|
||||
censec_naturezaltigio_id: 15,
|
||||
descricao: "Sucessões",
|
||||
situacao: "A"
|
||||
},
|
||||
{
|
||||
censec_naturezaltigio_id: 16,
|
||||
descricao: "Telefonia",
|
||||
situacao: "A"
|
||||
},
|
||||
{
|
||||
censec_naturezaltigio_id: 17,
|
||||
descricao: "Transporte",
|
||||
situacao: "A"
|
||||
},
|
||||
{
|
||||
censec_naturezaltigio_id: 18,
|
||||
descricao: "Transporte - Avião",
|
||||
situacao: "A"
|
||||
},
|
||||
{
|
||||
censec_naturezaltigio_id: 19,
|
||||
descricao: "Transporte - Barco",
|
||||
situacao: "A"
|
||||
},
|
||||
{
|
||||
censec_naturezaltigio_id: 20,
|
||||
descricao: "Transporte Metrô",
|
||||
situacao: "A"
|
||||
},
|
||||
{
|
||||
censec_naturezaltigio_id: 21,
|
||||
descricao: "Transporte - Ônibus",
|
||||
situacao: "A"
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
|
@ -0,0 +1,81 @@
|
|||
export const textoEscrituraCompraEVenda = `
|
||||
<p><strong>ESCRITURA PÚBLICA DE COMPRA E VENDA</strong></p>
|
||||
|
||||
<p>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 <strong>VENDEDOR(ES)</strong>:</p>
|
||||
|
||||
<p>[[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]];</p>
|
||||
|
||||
<p>E de outro lado como <strong>COMPRADOR(ES)</strong>:</p>
|
||||
|
||||
<p>[[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]];</p>
|
||||
|
||||
<p>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 <strong>ESCRITURA PÚBLICA DE COMPRA E VENDA</strong> 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.</p>
|
||||
|
||||
<p>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.</p>
|
||||
|
||||
<p>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.</p>
|
||||
|
||||
<p>Dou fé.</p>
|
||||
`;
|
||||
|
||||
export const textoEscrituraPartilhaAmigavel = `
|
||||
<p><strong>ESCRITURA PÚBLICA DE PARTILHA AMIGÁVEL</strong></p>
|
||||
|
||||
<p>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 <strong>HERDEIROS(AS)</strong>:</p>
|
||||
|
||||
<p>[[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]];</p>
|
||||
|
||||
<p>[[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]];</p>
|
||||
|
||||
<p>e assim por diante, se houver outros herdeiros.</p>
|
||||
|
||||
<p>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 <strong>PARTILHA AMIGÁVEL</strong> dos bens deixados pelo(a) de cujus, na forma seguinte:</p>
|
||||
|
||||
<p><strong>Relação dos bens:</strong></p>
|
||||
|
||||
<ul>
|
||||
<li>[[descricao_bem_1]] - avaliado em R$ [[valor_bem_1]];</li>
|
||||
<li>[[descricao_bem_2]] - avaliado em R$ [[valor_bem_2]];</li>
|
||||
<li>... (outros bens, se houver)</li>
|
||||
</ul>
|
||||
|
||||
<p><strong>Partilha:</strong></p>
|
||||
|
||||
<ul>
|
||||
<li>Ao(à) herdeiro(a) [[nome_herdeiro_1]] caberá o(s) bem(ns): [[bens_herdeiro_1]];</li>
|
||||
<li>Ao(à) herdeiro(a) [[nome_herdeiro_2]] caberá o(s) bem(ns): [[bens_herdeiro_2]];</li>
|
||||
<li>... (demais partilhas, se houver)</li>
|
||||
</ul>
|
||||
|
||||
<p>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.</p>
|
||||
|
||||
<p>Requerem que esta escritura seja registrada onde necessário, e produza todos os efeitos legais.</p>
|
||||
|
||||
<p>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.</p>
|
||||
|
||||
<p>Dou fé.</p>
|
||||
`;
|
||||
|
||||
export const textoProcuracaoAdJudicia = `
|
||||
<p><strong>PROCURAÇÃO AD JUDICIA</strong></p>
|
||||
|
||||
<p>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]].</p>
|
||||
|
||||
<p>Outorgado: [[nome_outorgado]], advogado inscrito na OAB/[[uf_oab]] sob o nº [[numero_oab]], com escritório profissional situado à [[endereco_escritorio]].</p>
|
||||
|
||||
<p>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.</p>
|
||||
|
||||
<p>Esta procuração é válida por [[validade]] meses a contar da data de sua assinatura.</p>
|
||||
|
||||
<p>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]].</p>
|
||||
|
||||
<p>_______________________________</p>
|
||||
<p>[[nome_outorgante]]</p>
|
||||
|
||||
<p>Testemunhas:</p>
|
||||
<p>1. ___________________________</p>
|
||||
<p>Nome: [[nome_testemunha_1]] - CPF: [[cpf_testemunha_1]]</p>
|
||||
|
||||
<p>2. ___________________________</p>
|
||||
<p>Nome: [[nome_testemunha_2]] - CPF: [[cpf_testemunha_2]]</p>
|
||||
`;
|
||||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
@ -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}`
|
||||
});
|
||||
|
||||
}
|
||||
|
|
@ -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
|
||||
});
|
||||
|
||||
}
|
||||
|
|
@ -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
|
||||
});
|
||||
}
|
||||
|
|
@ -3,8 +3,9 @@
|
|||
import API from "@/services/api/Api";
|
||||
import TTBAndamentoServicoInteface from "../../_interfaces/TTBAndamentoServicoInterface";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
import { withClientErrorHandler } from "@/actions/withClientErrorHandler/withClientErrorHandler";
|
||||
|
||||
export default async function TTBAndamentoServicoSaveData(data: TTBAndamentoServicoInteface) {
|
||||
async function executeTTBAndamentoServicoSaveData(data: TTBAndamentoServicoInteface) {
|
||||
|
||||
const api = new API();
|
||||
|
||||
|
|
@ -16,4 +17,7 @@ export default async function TTBAndamentoServicoSaveData(data: TTBAndamentoServ
|
|||
|
||||
return response;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Encapsula a execução da função
|
||||
export const TTBAndamentoServicoSaveData = withClientErrorHandler(executeTTBAndamentoServicoSaveData);
|
||||
|
|
@ -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<GMedidaTipoInterface[]>([]);
|
||||
|
||||
const fetchGMedidaTipo = async () => {
|
||||
|
||||
try {
|
||||
const response = await GMedidaTipoIndexService();
|
||||
|
||||
setGMedidaTipo(response.data);
|
||||
|
||||
setResponse(response);
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return { gMedidaTipo, fetchGMedidaTipo }
|
||||
|
||||
}
|
||||
|
|
@ -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 }
|
||||
|
||||
}
|
||||
|
|
@ -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<GMedidaTipoInterface | null>(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 }
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
import { useResponse } from "@/app/_response/ResponseContext"
|
||||
import { useState } from "react";
|
||||
import { GTBBairroInterface } from "../../_interfaces/GTBBairroInterface";
|
||||
import GTBBairroIndexService from "../../_services/g_tb_bairro/GTBBairroIndexService";
|
||||
|
||||
export const useGTBBairroReadHook = () => {
|
||||
|
||||
const { setResponse } = useResponse();
|
||||
const [gTBBairro, setGTBBairro] = useState<GTBBairroInterface[]>([]);
|
||||
|
||||
const fetchGTBBairro = async () => {
|
||||
|
||||
try {
|
||||
const response = await GTBBairroIndexService();
|
||||
|
||||
setGTBBairro(response.data);
|
||||
|
||||
setResponse(response);
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return { gTBBairro, fetchGTBBairro }
|
||||
|
||||
}
|
||||
|
|
@ -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 }
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
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<GTBBairroInterface | null>(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 }
|
||||
|
||||
}
|
||||
|
|
@ -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<GTBEstadoCivilInterface[]>([]);
|
||||
|
||||
const fetchGTBEstadoCivil = async () => {
|
||||
|
||||
try {
|
||||
const response = await GTBEstadoCivilIndexService();
|
||||
|
||||
setGTBEstadoCivil(response.data);
|
||||
|
||||
setResponse(response);
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return { gTBEstadoCivil, fetchGTBEstadoCivil }
|
||||
|
||||
}
|
||||
|
|
@ -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 }
|
||||
|
||||
}
|
||||
|
|
@ -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<GTBEstadoCivilInterface | null>(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 }
|
||||
|
||||
}
|
||||
|
|
@ -1,14 +1,14 @@
|
|||
import { useResponse } from "@/app/_response/ResponseContext"
|
||||
import GTBRegimeComunhaoInterface from "../../_interfaces/GTBRegimeComunhaoInterface";
|
||||
import GTBRegimeComunhaoRemoveService from "../../_services/g_tb_regimecomunhao/GTBRegimeComunhaoRemoveService";
|
||||
import GTBRegimeBensInterface from "../../_interfaces/GTBRegimeBensInterface";
|
||||
import GTBRegimeBensRemoveData from "../../_data/GTBRegimeBens/GTBRegimeBensRemoveData";
|
||||
|
||||
export const useGTBRegimeBensRemoveHook = () => {
|
||||
|
||||
const { setResponse } = useResponse();
|
||||
|
||||
const removeGTBRegimeComunhao = async (data: GTBRegimeComunhaoInterface) => {
|
||||
const removeGTBRegimeComunhao = async (data: GTBRegimeBensInterface) => {
|
||||
|
||||
const response = await GTBRegimeComunhaoRemoveService(data);
|
||||
const response = await GTBRegimeBensRemoveData(data);
|
||||
|
||||
setResponse(response);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,18 +1,19 @@
|
|||
import { useState } from "react";
|
||||
import { useResponse } from "@/app/_response/ResponseContext"
|
||||
import GTBRegimeComunhaoInterface from "../../_interfaces/GTBRegimeComunhaoInterface";
|
||||
import GTBRegimeComunhaoSaveService from "../../_services/g_tb_regimecomunhao/GTBRegimeComunhaoSaveService";
|
||||
import GTBRegimeBensInterface from "../../_interfaces/GTBRegimeBensInterface";
|
||||
import { GTBRegimeBensSaveService } from "../../_services/g_tb_regimebens/GTBRegimeBensSaveService";
|
||||
|
||||
export const useGTBRegimeBensSaveHook = () => {
|
||||
|
||||
const { setResponse } = useResponse();
|
||||
const [gTBRegimeComunhao, setGTBRegimeComunhao] = useState<GTBRegimeComunhaoInterface | null>(null);
|
||||
const [gTBRegimeComunhao, setGTBRegimeComunhao] = useState<GTBRegimeBensInterface | null>(null);
|
||||
|
||||
// controla se o formulário está aberto ou fechado
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
|
||||
const saveGTBRegimeComunhao = async (data: GTBRegimeComunhaoInterface) => {
|
||||
const saveGTBRegimeComunhao = async (data: GTBRegimeBensInterface) => {
|
||||
|
||||
const response = await GTBRegimeComunhaoSaveService(data);
|
||||
const response = await GTBRegimeBensSaveService(data);
|
||||
|
||||
// Guardar os dados localizados
|
||||
setGTBRegimeComunhao(response.data);
|
||||
|
|
|
|||
|
|
@ -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<GTBTipoLogradouroInterface[]>([]);
|
||||
|
||||
const fetchGTBTipoLogradouro = async () => {
|
||||
|
||||
try {
|
||||
const response = await GTBTipoLogradouroIndexService();
|
||||
|
||||
setGTBTipoLogradouro(response.data);
|
||||
|
||||
setResponse(response);
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return { gTBTipoLogradouro, fetchGTBTipoLogradouro }
|
||||
|
||||
}
|
||||
|
|
@ -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 }
|
||||
|
||||
}
|
||||
|
|
@ -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<GTBTipoLogradouroInterface | null>(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 }
|
||||
|
||||
}
|
||||
|
|
@ -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 }
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
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<TCensecInterface[]>([]);
|
||||
|
||||
const fetchTCensec = async () => {
|
||||
|
||||
const response = await TCensecIndexService();
|
||||
|
||||
setTCensec(response.data);
|
||||
|
||||
setResponse(response);
|
||||
|
||||
return response
|
||||
|
||||
}
|
||||
|
||||
return { tCensec, fetchTCensec }
|
||||
|
||||
}
|
||||
|
|
@ -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<TCensecInterface>();
|
||||
|
||||
// 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 }
|
||||
|
||||
}
|
||||
|
|
@ -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<TCensecNaturezaLitigioInterface[]>([]);
|
||||
|
||||
const fetchTCensecNaturezaLitigio = async () => {
|
||||
|
||||
try {
|
||||
const response = await TCensecNaturezaLitigioIndexService();
|
||||
|
||||
setTCensecNaturezaLitigio(response.data);
|
||||
|
||||
console.log(response)
|
||||
|
||||
setResponse(response);
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return { tCensecNaturezaLitigio, fetchTCensecNaturezaLitigio }
|
||||
|
||||
}
|
||||
|
|
@ -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<TCensecNaturezaLitigioInterface>()
|
||||
|
||||
const removeTCensecNaturezaLitigio = async (data: TCensecNaturezaLitigioInterface) => {
|
||||
|
||||
const response = await TCensecNaturezaLitigioRemoveData(data);
|
||||
|
||||
setTCensecNaturezaLitigio(data)
|
||||
|
||||
setResponse(response);
|
||||
|
||||
}
|
||||
|
||||
return { tCensecNaturezaLitigio, removeTCensecNaturezaLitigio }
|
||||
|
||||
}
|
||||
|
|
@ -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<TCensecNaturezaLitigioInterface | null>(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 }
|
||||
|
||||
}
|
||||
|
|
@ -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<TMinutaInterface[]>([]);
|
||||
|
||||
const fetchTMinuta = async () => {
|
||||
|
||||
try {
|
||||
const response = await TMinutaIndex();
|
||||
|
||||
setTMinuta(response.data);
|
||||
|
||||
setResponse(response);
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return { tMinuta, fetchTMinuta }
|
||||
|
||||
}
|
||||
|
|
@ -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<TMinutaInterface>();
|
||||
|
||||
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 }
|
||||
|
||||
}
|
||||
|
|
@ -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 }
|
||||
|
||||
}
|
||||
|
|
@ -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<TMinutaInterface>();
|
||||
// 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 }
|
||||
|
||||
}
|
||||
|
|
@ -15,6 +15,8 @@ export const useTTBAndamentoServicoReadHook = () => {
|
|||
|
||||
const response = await TTBAndamentoServicoIndexData();
|
||||
|
||||
console.log(response)
|
||||
|
||||
// Armazena os dados consultados
|
||||
setTTBAndamentosServicos(response.data);
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
import { useResponse } from "@/app/_response/ResponseContext"
|
||||
import { useState } from "react";
|
||||
import TTBAndamentoServicoInteface from "../../_interfaces/TTBAndamentoServicoInterface";
|
||||
import TTBAndamentoServicoSaveData from "../../_data/TTBAndamentoServico/TTBAndamentoServicoSaveData";
|
||||
import { TTBAndamentoServicoSaveData } from "../../_data/TTBAndamentoServico/TTBAndamentoServicoSaveData";
|
||||
|
||||
export const useTTBAndamentoServicoSaveHook = () => {
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
export interface GMedidaTipoInterface {
|
||||
medida_tipo_id: number;
|
||||
sigla: string;
|
||||
descricao: string;
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
export interface GTBBairroInterface {
|
||||
sistema_id: number | null;
|
||||
tb_bairro_id: number;
|
||||
descricao: string;
|
||||
situacao: 'A' | 'I';
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue