From a1ed14538c929e1128db3623efcc8035e03043a8 Mon Sep 17 00:00:00 2001 From: Arthur Bassi Date: Tue, 16 Jun 2026 09:07:30 -0300 Subject: [PATCH] fix(api): add no-content helpers and align paths with backend --- src/api/api-paths.ts | 6 ++---- src/api/api.ts | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src/api/api-paths.ts b/src/api/api-paths.ts index 62f0a68f..f209b08a 100644 --- a/src/api/api-paths.ts +++ b/src/api/api-paths.ts @@ -8,7 +8,7 @@ export const API_PATHS = { }, workOrder: { getList: "WorkOrder/GetWorkOrderList", - getById: "WorkOrder/GetById", + getById: "WorkOrder/GetWorkorderById", create: "WorkOrder/Create", update: "WorkOrder/Update", delete: "WorkOrder/DeleteWorkOrder", @@ -61,7 +61,7 @@ export const API_PATHS = { }, contact: { getList: "Contact/GetContactList", - getById: "Contact/GetById", + getContacts: "Contact/GetContacts", create: "Contact/Create", update: "Contact/Update", delete: "Contact/Delete", @@ -82,7 +82,6 @@ export const API_PATHS = { }, account: { getList: "Account/GetAccountList", - getById: "Account/GetById", create: "Account/Create", update: "Account/Update", delete: "Account/Delete", @@ -111,7 +110,6 @@ export const API_PATHS = { create: "Vendor/Create", update: "Vendor/Update", delete: "Vendor/Delete", - deleteVendor: "Vendor/DeleteVendor", dropdown: "Vendor/Dropdown", }, calendar: { diff --git a/src/api/api.ts b/src/api/api.ts index 8a0e0d33..98cbbd46 100644 --- a/src/api/api.ts +++ b/src/api/api.ts @@ -94,4 +94,36 @@ export async function apiDelete(url: string, options?: Options): Promise { return api.delete(url, options).json(); } +export async function apiPostNoContent( + url: string, + body?: unknown, + options?: Options, +): Promise { + const response = await api.post(url, { ...options, json: body }); + if (response.status === 204) { + return; + } + + const text = await response.text(); + if (!text.trim()) { + return; + } + + JSON.parse(text); +} + +export async function apiDeleteNoContent(url: string, options?: Options): Promise { + const response = await api.delete(url, options); + if (response.status === 204) { + return; + } + + const text = await response.text(); + if (!text.trim()) { + return; + } + + JSON.parse(text); +} + export { mapHttpStatusToMessage };