mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-06 04:12:09 +00:00
fix(api): add no-content helpers and align paths with backend
This commit is contained in:
parent
4a67d6b16f
commit
a1ed14538c
2 changed files with 34 additions and 4 deletions
|
|
@ -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: {
|
||||
|
|
|
|||
|
|
@ -94,4 +94,36 @@ export async function apiDelete<T>(url: string, options?: Options): Promise<T> {
|
|||
return api.delete(url, options).json<T>();
|
||||
}
|
||||
|
||||
export async function apiPostNoContent(
|
||||
url: string,
|
||||
body?: unknown,
|
||||
options?: Options,
|
||||
): Promise<void> {
|
||||
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<void> {
|
||||
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 };
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue