[MVPTN-64] feat(CRUD): Adiciona os endpoints ao crud de Regime Comunhão
This commit is contained in:
parent
611f00b5d0
commit
5e899442a2
9 changed files with 35 additions and 69 deletions
|
|
@ -1,51 +1,14 @@
|
||||||
|
import API from "@/services/api/Api";
|
||||||
import GTBRegimeComunhaoInterface from "../../_interfaces/GTBRegimeComunhaoInterface";
|
import GTBRegimeComunhaoInterface from "../../_interfaces/GTBRegimeComunhaoInterface";
|
||||||
|
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||||
|
|
||||||
export default async function GTBRegimeComunhaoIndexData(): Promise<GTBRegimeComunhaoInterface> {
|
export default async function GTBRegimeComunhaoIndexData(): Promise<GTBRegimeComunhaoInterface> {
|
||||||
|
|
||||||
return Promise.resolve([
|
const api = new API();
|
||||||
{
|
|
||||||
"tb_regimecomunhao_id": 1,
|
return await api.send({
|
||||||
"descricao": "comunhão parcial de bens",
|
method: Methods.GET,
|
||||||
"texto": null,
|
endpoint: `administrativo/g_tb_regimecomunhao/`
|
||||||
"situacao": "A",
|
});
|
||||||
"tb_regimebens_id": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"tb_regimecomunhao_id": 2,
|
|
||||||
"descricao": "comunhão universal de bens",
|
|
||||||
"texto": null,
|
|
||||||
"situacao": "A",
|
|
||||||
"tb_regimebens_id": 2
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"tb_regimecomunhao_id": 33,
|
|
||||||
"descricao": "Comunhão parcial de bens",
|
|
||||||
"texto": null,
|
|
||||||
"situacao": "A",
|
|
||||||
"tb_regimebens_id": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"tb_regimecomunhao_id": 3,
|
|
||||||
"descricao": "separacão total de bens",
|
|
||||||
"texto": null,
|
|
||||||
"situacao": "A",
|
|
||||||
"tb_regimebens_id": 4
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"tb_regimecomunhao_id": 4,
|
|
||||||
"descricao": "Não Informado",
|
|
||||||
"texto": null,
|
|
||||||
"situacao": "A",
|
|
||||||
"tb_regimebens_id": null
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"tb_regimecomunhao_id": 35,
|
|
||||||
"descricao": "Comunhão de bens",
|
|
||||||
"texto": null,
|
|
||||||
"situacao": "A",
|
|
||||||
"tb_regimebens_id": 2
|
|
||||||
}
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,9 +1,14 @@
|
||||||
import GTBProfissaoInterface from "../../_interfaces/GTBProfissaoInterface";
|
import API from "@/services/api/Api";
|
||||||
|
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||||
|
import GTBRegimeComunhaoInterface from "../../_interfaces/GTBRegimeComunhaoInterface";
|
||||||
|
|
||||||
export default async function GTBRegimeComunhaoRemoveData(data: GTBProfissaoInterface) {
|
export default async function GTBRegimeComunhaoRemoveData(data: GTBRegimeComunhaoInterface) {
|
||||||
|
|
||||||
return Promise.resolve({
|
const api = new API();
|
||||||
message: 'Dados removidos com sucesso'
|
|
||||||
|
return await api.send({
|
||||||
|
method: Methods.DELETE,
|
||||||
|
endpoint: `administrativo/g_tb_regimecomunhao/${data.tb_regimecomunhao_id}`
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,16 +1,16 @@
|
||||||
|
import API from "@/services/api/Api";
|
||||||
import GTBRegimeComunhaoInterface from "../../_interfaces/GTBRegimeComunhaoInterface";
|
import GTBRegimeComunhaoInterface from "../../_interfaces/GTBRegimeComunhaoInterface";
|
||||||
|
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||||
|
|
||||||
export default async function GTBRegimeComunhaoSaveData(data: GTBRegimeComunhaoInterface) {
|
export default async function GTBRegimeComunhaoSaveData(data: GTBRegimeComunhaoInterface) {
|
||||||
|
|
||||||
return Promise.resolve({
|
const isUpdate = Boolean(data.tb_regimecomunhao_id);
|
||||||
message: 'Profissao salva com sucesso',
|
|
||||||
data: {
|
|
||||||
"tb_regimecomunhao_id": 1,
|
|
||||||
"descricao": "comunhão parcial de bens",
|
|
||||||
"texto": null,
|
|
||||||
"situacao": "A",
|
|
||||||
"tb_regimebens_id": 1
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
const api = new API();
|
||||||
|
|
||||||
|
return await api.send({
|
||||||
|
method: isUpdate ? Methods.PUT : Methods.POST,
|
||||||
|
endpoint: `administrativo/g_tb_regimecomunhao/${data.tb_regimecomunhao_id || ''}`,
|
||||||
|
body: data
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -12,7 +12,7 @@ export const useGTBRegimeComunhaoReadHook = () => {
|
||||||
|
|
||||||
const response = await GTBRegimeComunhaoIndexService();
|
const response = await GTBRegimeComunhaoIndexService();
|
||||||
|
|
||||||
setGTBRegimeComunhao(response);
|
setGTBRegimeComunhao(response.data);
|
||||||
|
|
||||||
setResponse(response);
|
setResponse(response);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { useResponse } from "@/app/_response/ResponseContext"
|
import { useResponse } from "@/app/_response/ResponseContext"
|
||||||
import GTBRegimeComunhaoInterface from "../../_interfaces/GTBRegimeComunhaoInterface";
|
import GTBRegimeComunhaoInterface from "../../_interfaces/GTBRegimeComunhaoInterface";
|
||||||
import GTBRegimeComunhaoSaveData from "../../_data/GTRegimeComunhao/GTBRegimeComunhaoSaveData";
|
import GTBRegimeComunhaoSaveService from "../../_services/g_tb_regimecomunhao/GTBRegimeComunhaoSaveService";
|
||||||
|
|
||||||
export const useGTBRegimeComunhaoSaveHook = () => {
|
export const useGTBRegimeComunhaoSaveHook = () => {
|
||||||
|
|
||||||
|
|
@ -10,9 +10,9 @@ export const useGTBRegimeComunhaoSaveHook = () => {
|
||||||
|
|
||||||
const saveGTBRegimeComunhao = async (data: GTBRegimeComunhaoInterface) => {
|
const saveGTBRegimeComunhao = async (data: GTBRegimeComunhaoInterface) => {
|
||||||
|
|
||||||
const response = await GTBRegimeComunhaoSaveData(data);
|
const response = await GTBRegimeComunhaoSaveService(data);
|
||||||
|
|
||||||
setGTBRegimeComunhao(response);
|
setGTBRegimeComunhao(response.data);
|
||||||
|
|
||||||
setResponse(response);
|
setResponse(response);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import z from "zod";
|
import z from "zod";
|
||||||
|
|
||||||
export const GTBRegimeComunhaoSchema = z.object({
|
export const GTBRegimeComunhaoSchema = z.object({
|
||||||
tb_regimecomunhao_id: z.number().optional,
|
tb_regimecomunhao_id: z.number().optional(),
|
||||||
tb_regimebens_id: z.number(),
|
tb_regimebens_id: z.number(),
|
||||||
descricao: z.string(),
|
descricao: z.string(),
|
||||||
texto: z.string(),
|
texto: z.string(),
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,6 @@ import GTBProfissaoInterface from "../../_interfaces/GTBProfissaoInterface";
|
||||||
|
|
||||||
export default async function GTBProfissaoRemoveService(data: GTBProfissaoInterface) {
|
export default async function GTBProfissaoRemoveService(data: GTBProfissaoInterface) {
|
||||||
|
|
||||||
console.log(data);
|
|
||||||
|
|
||||||
const response = await GTBProfissaoRemoveData(data);
|
const response = await GTBProfissaoRemoveData(data);
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import GTBRegimeComunhaoSaveData from "../../_data/GTRegimeComunhao/GTBRegimeComunhaoSaveData";
|
import GTBRegimeComunhaoSaveData from "../../_data/GTRegimeComunhao/GTBRegimeComunhaoSaveData";
|
||||||
import GTBRegimeComunhaoInterface from "../../_interfaces/GTBRegimeComunhaoInterface";
|
import GTBRegimeComunhaoInterface from "../../_interfaces/GTBRegimeComunhaoInterface";
|
||||||
|
|
||||||
export default async function GTProfissaoSaveService(data: GTBRegimeComunhaoInterface) {
|
export default async function GTBRegimeComunhaoSaveService(data: GTBRegimeComunhaoInterface) {
|
||||||
|
|
||||||
const response = await GTBRegimeComunhaoSaveData(data);
|
const response = await GTBRegimeComunhaoSaveData(data);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
{
|
{
|
||||||
"state": "go",
|
"state": "go",
|
||||||
"api": {
|
"api": {
|
||||||
"url": "http://api-saas-api-homologacao:8000/",
|
"url": "http://localhost:8000/",
|
||||||
"prefix": "api/v1",
|
"prefix": "api/v1/",
|
||||||
"content_type": "application/json"
|
"content_type": "application/json"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Reference in a new issue