diff --git a/src/app/(protected)/(cadastros)/cadastros/_data/GTRegimeComunhao/GTBRegimeComunhaoIndexData.ts b/src/app/(protected)/(cadastros)/cadastros/_data/GTRegimeComunhao/GTBRegimeComunhaoIndexData.ts index d7aac8f..f9fd91a 100644 --- a/src/app/(protected)/(cadastros)/cadastros/_data/GTRegimeComunhao/GTBRegimeComunhaoIndexData.ts +++ b/src/app/(protected)/(cadastros)/cadastros/_data/GTRegimeComunhao/GTBRegimeComunhaoIndexData.ts @@ -1,51 +1,14 @@ +import API from "@/services/api/Api"; import GTBRegimeComunhaoInterface from "../../_interfaces/GTBRegimeComunhaoInterface"; +import { Methods } from "@/services/api/enums/ApiMethodEnum"; export default async function GTBRegimeComunhaoIndexData(): Promise { - return Promise.resolve([ - { - "tb_regimecomunhao_id": 1, - "descricao": "comunhão parcial de bens", - "texto": null, - "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 - } - ] - ); + const api = new API(); + + return await api.send({ + method: Methods.GET, + endpoint: `administrativo/g_tb_regimecomunhao/` + }); } \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_data/GTRegimeComunhao/GTBRegimeComunhaoRemoveData.ts b/src/app/(protected)/(cadastros)/cadastros/_data/GTRegimeComunhao/GTBRegimeComunhaoRemoveData.ts index 53c60c5..c92cb66 100644 --- a/src/app/(protected)/(cadastros)/cadastros/_data/GTRegimeComunhao/GTBRegimeComunhaoRemoveData.ts +++ b/src/app/(protected)/(cadastros)/cadastros/_data/GTRegimeComunhao/GTBRegimeComunhaoRemoveData.ts @@ -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({ - message: 'Dados removidos com sucesso' + const api = new API(); + + return await api.send({ + method: Methods.DELETE, + endpoint: `administrativo/g_tb_regimecomunhao/${data.tb_regimecomunhao_id}` }); } \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_data/GTRegimeComunhao/GTBRegimeComunhaoSaveData.ts b/src/app/(protected)/(cadastros)/cadastros/_data/GTRegimeComunhao/GTBRegimeComunhaoSaveData.ts index 04a87c9..51cf575 100644 --- a/src/app/(protected)/(cadastros)/cadastros/_data/GTRegimeComunhao/GTBRegimeComunhaoSaveData.ts +++ b/src/app/(protected)/(cadastros)/cadastros/_data/GTRegimeComunhao/GTBRegimeComunhaoSaveData.ts @@ -1,16 +1,16 @@ +import API from "@/services/api/Api"; import GTBRegimeComunhaoInterface from "../../_interfaces/GTBRegimeComunhaoInterface"; +import { Methods } from "@/services/api/enums/ApiMethodEnum"; export default async function GTBRegimeComunhaoSaveData(data: GTBRegimeComunhaoInterface) { - return Promise.resolve({ - 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 isUpdate = Boolean(data.tb_regimecomunhao_id); + const api = new API(); + + return await api.send({ + method: isUpdate ? Methods.PUT : Methods.POST, + endpoint: `administrativo/g_tb_regimecomunhao/${data.tb_regimecomunhao_id || ''}`, + body: data + }); } \ No newline at end of file diff --git a/src/app/(protected)/(cadastros)/cadastros/_hooks/g_tb_regimecomunhao/useGTBRegimeComunhaoReadHook.ts b/src/app/(protected)/(cadastros)/cadastros/_hooks/g_tb_regimecomunhao/useGTBRegimeComunhaoReadHook.ts index efe31dd..73de8d0 100644 --- a/src/app/(protected)/(cadastros)/cadastros/_hooks/g_tb_regimecomunhao/useGTBRegimeComunhaoReadHook.ts +++ b/src/app/(protected)/(cadastros)/cadastros/_hooks/g_tb_regimecomunhao/useGTBRegimeComunhaoReadHook.ts @@ -12,7 +12,7 @@ export const useGTBRegimeComunhaoReadHook = () => { const response = await GTBRegimeComunhaoIndexService(); - setGTBRegimeComunhao(response); + setGTBRegimeComunhao(response.data); setResponse(response); diff --git a/src/app/(protected)/(cadastros)/cadastros/_hooks/g_tb_regimecomunhao/useGTBRegimeComunhaoSaveHook.ts b/src/app/(protected)/(cadastros)/cadastros/_hooks/g_tb_regimecomunhao/useGTBRegimeComunhaoSaveHook.ts index 65e0c2f..f0d336e 100644 --- a/src/app/(protected)/(cadastros)/cadastros/_hooks/g_tb_regimecomunhao/useGTBRegimeComunhaoSaveHook.ts +++ b/src/app/(protected)/(cadastros)/cadastros/_hooks/g_tb_regimecomunhao/useGTBRegimeComunhaoSaveHook.ts @@ -1,7 +1,7 @@ import { useState } from "react"; import { useResponse } from "@/app/_response/ResponseContext" import GTBRegimeComunhaoInterface from "../../_interfaces/GTBRegimeComunhaoInterface"; -import GTBRegimeComunhaoSaveData from "../../_data/GTRegimeComunhao/GTBRegimeComunhaoSaveData"; +import GTBRegimeComunhaoSaveService from "../../_services/g_tb_regimecomunhao/GTBRegimeComunhaoSaveService"; export const useGTBRegimeComunhaoSaveHook = () => { @@ -10,9 +10,9 @@ export const useGTBRegimeComunhaoSaveHook = () => { const saveGTBRegimeComunhao = async (data: GTBRegimeComunhaoInterface) => { - const response = await GTBRegimeComunhaoSaveData(data); + const response = await GTBRegimeComunhaoSaveService(data); - setGTBRegimeComunhao(response); + setGTBRegimeComunhao(response.data); setResponse(response); diff --git a/src/app/(protected)/(cadastros)/cadastros/_schemas/GTBRegimeComunhaoSchema.ts b/src/app/(protected)/(cadastros)/cadastros/_schemas/GTBRegimeComunhaoSchema.ts index 4608727..e47c098 100644 --- a/src/app/(protected)/(cadastros)/cadastros/_schemas/GTBRegimeComunhaoSchema.ts +++ b/src/app/(protected)/(cadastros)/cadastros/_schemas/GTBRegimeComunhaoSchema.ts @@ -1,7 +1,7 @@ import z from "zod"; export const GTBRegimeComunhaoSchema = z.object({ - tb_regimecomunhao_id: z.number().optional, + tb_regimecomunhao_id: z.number().optional(), tb_regimebens_id: z.number(), descricao: z.string(), texto: z.string(), diff --git a/src/app/(protected)/(cadastros)/cadastros/_services/g_tb_profissao/GTBProfissaoRemoveService.ts b/src/app/(protected)/(cadastros)/cadastros/_services/g_tb_profissao/GTBProfissaoRemoveService.ts index 9a1dcef..8e2ebb0 100644 --- a/src/app/(protected)/(cadastros)/cadastros/_services/g_tb_profissao/GTBProfissaoRemoveService.ts +++ b/src/app/(protected)/(cadastros)/cadastros/_services/g_tb_profissao/GTBProfissaoRemoveService.ts @@ -3,8 +3,6 @@ import GTBProfissaoInterface from "../../_interfaces/GTBProfissaoInterface"; export default async function GTBProfissaoRemoveService(data: GTBProfissaoInterface) { - console.log(data); - const response = await GTBProfissaoRemoveData(data); return response; diff --git a/src/app/(protected)/(cadastros)/cadastros/_services/g_tb_regimecomunhao/GTBRegimeComunhaoSaveService.ts b/src/app/(protected)/(cadastros)/cadastros/_services/g_tb_regimecomunhao/GTBRegimeComunhaoSaveService.ts index db998a4..f81e5c9 100644 --- a/src/app/(protected)/(cadastros)/cadastros/_services/g_tb_regimecomunhao/GTBRegimeComunhaoSaveService.ts +++ b/src/app/(protected)/(cadastros)/cadastros/_services/g_tb_regimecomunhao/GTBRegimeComunhaoSaveService.ts @@ -1,7 +1,7 @@ import GTBRegimeComunhaoSaveData from "../../_data/GTRegimeComunhao/GTBRegimeComunhaoSaveData"; import GTBRegimeComunhaoInterface from "../../_interfaces/GTBRegimeComunhaoInterface"; -export default async function GTProfissaoSaveService(data: GTBRegimeComunhaoInterface) { +export default async function GTBRegimeComunhaoSaveService(data: GTBRegimeComunhaoInterface) { const response = await GTBRegimeComunhaoSaveData(data); diff --git a/src/config/app.json b/src/config/app.json index fb7f42d..d38e8d3 100644 --- a/src/config/app.json +++ b/src/config/app.json @@ -1,8 +1,8 @@ { "state": "go", "api": { - "url": "http://api-saas-api-homologacao:8000/", - "prefix": "api/v1", + "url": "http://localhost:8000/", + "prefix": "api/v1/", "content_type": "application/json" } } \ No newline at end of file