[MVPTN-77] refactor(geral): implementando gerenciador de erro nos datas
This commit is contained in:
parent
daeb956ef8
commit
295b9b4d69
9 changed files with 21 additions and 19 deletions
|
|
@ -1,17 +1,13 @@
|
|||
import { withClientErrorHandler } from "@/actions/withClientErrorHandler/withClientErrorHandler";
|
||||
import API from "@/services/api/Api";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
|
||||
export default async function GMedidaTipoIndexData() {
|
||||
async function executeGMedidaTipoIndexData() {
|
||||
const api = new API();
|
||||
try {
|
||||
const dados = await api.send({
|
||||
return await api.send({
|
||||
method: Methods.GET,
|
||||
endpoint: `administrativo/g_medida_tipo/`
|
||||
});
|
||||
return dados
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
return error
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
export const GMedidaTipoIndexData = withClientErrorHandler(executeGMedidaTipoIndexData)
|
||||
|
|
@ -1,8 +1,9 @@
|
|||
import API from "@/services/api/Api";
|
||||
import { GMedidaTipoInterface } from "../../_interfaces/GMedidaTipoInterface";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
import { withClientErrorHandler } from "@/actions/withClientErrorHandler/withClientErrorHandler";
|
||||
|
||||
export default async function GMedidaTipoRemoveData(data: GMedidaTipoInterface) {
|
||||
async function executeGMedidaTipoRemoveData(data: GMedidaTipoInterface) {
|
||||
|
||||
const api = new API();
|
||||
|
||||
|
|
@ -11,4 +12,6 @@ export default async function GMedidaTipoRemoveData(data: GMedidaTipoInterface)
|
|||
endpoint: `administrativo/g_medida_tipo/${data.medida_tipo_id}`
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
export const GMedidaTipoRemoveData = withClientErrorHandler(executeGMedidaTipoRemoveData)
|
||||
|
|
@ -1,8 +1,9 @@
|
|||
import API from "@/services/api/Api";
|
||||
import { GMedidaTipoInterface } from "../../_interfaces/GMedidaTipoInterface";
|
||||
import { Methods } from "@/services/api/enums/ApiMethodEnum";
|
||||
import { withClientErrorHandler } from "@/actions/withClientErrorHandler/withClientErrorHandler";
|
||||
|
||||
export default async function GMedidaTipoSaveData(data: GMedidaTipoInterface) {
|
||||
async function executeGMedidaTipoSaveData(data: GMedidaTipoInterface) {
|
||||
|
||||
const isUpdate = Boolean(data.medida_tipo_id);
|
||||
|
||||
|
|
@ -14,4 +15,6 @@ export default async function GMedidaTipoSaveData(data: GMedidaTipoInterface) {
|
|||
body: data
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
export const GMedidaTipoSaveData = withClientErrorHandler(executeGMedidaTipoSaveData)
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
import { useResponse } from "@/app/_response/ResponseContext"
|
||||
import { useState } from "react";
|
||||
import { GMedidaTipoInterface } from "../../_interfaces/GMedidaTipoInterface";
|
||||
import GMedidaTipoIndexService from "../../_services/g_medidatipo/GMedidaTipoIndexService";
|
||||
import { GMedidaTipoIndexService } from "../../_services/g_medidatipo/GMedidaTipoIndexService";
|
||||
|
||||
export const useGMedidaTipoReadHook = () => {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { useResponse } from "@/app/_response/ResponseContext"
|
||||
import { GMedidaTipoInterface } from "../../_interfaces/GMedidaTipoInterface";
|
||||
import GMedidaTipoRemoveService from "../../_services/g_medidatipo/GMedidaTipoRemoveService";
|
||||
import { GMedidaTipoRemoveService } from "../../_services/g_medidatipo/GMedidaTipoRemoveService";
|
||||
|
||||
export const useGMedidaTipoRemoveHook = () => {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { useResponse } from "@/app/_response/ResponseContext"
|
||||
import { useState } from "react";
|
||||
import { GMedidaTipoInterface } from "../../_interfaces/GMedidaTipoInterface";
|
||||
import GMedidaTipoSaveService from "../../_services/g_medidatipo/GMedidaTipoSaveService";
|
||||
import { GMedidaTipoSaveService } from "../../_services/g_medidatipo/GMedidaTipoSaveService";
|
||||
|
||||
export const useGMedidaTipoSaveHook = () => {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { withClientErrorHandler } from "@/actions/withClientErrorHandler/withClientErrorHandler";
|
||||
import GMedidaTipoIndexData from "../../_data/GMedidoTipo/GMedidaTipoIndexData";
|
||||
import { GMedidaTipoIndexData } from "../../_data/GMedidoTipo/GMedidaTipoIndexData";
|
||||
|
||||
async function executeGMedidaTipoIndexService() {
|
||||
const response = await GMedidaTipoIndexData();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { withClientErrorHandler } from "@/actions/withClientErrorHandler/withClientErrorHandler";
|
||||
import GMedidaTipoRemoveData from "../../_data/GMedidoTipo/GMedidaTipoRemoveData";
|
||||
import { GMedidaTipoRemoveData } from "../../_data/GMedidoTipo/GMedidaTipoRemoveData";
|
||||
import { GMedidaTipoInterface } from "../../_interfaces/GMedidaTipoInterface";
|
||||
|
||||
async function executeGMedidaTipoRemoveService(data: GMedidaTipoInterface) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { withClientErrorHandler } from "@/actions/withClientErrorHandler/withClientErrorHandler";
|
||||
import GMedidaTipoSaveData from "../../_data/GMedidoTipo/GMedidaTipoSaveData";
|
||||
import { GMedidaTipoSaveData } from "../../_data/GMedidoTipo/GMedidaTipoSaveData";
|
||||
import { GMedidaTipoInterface } from "../../_interfaces/GMedidaTipoInterface";
|
||||
|
||||
async function executeGMedidaTipoSaveService(data: GMedidaTipoInterface) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue