mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-07 16:19:01 +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: {
|
workOrder: {
|
||||||
getList: "WorkOrder/GetWorkOrderList",
|
getList: "WorkOrder/GetWorkOrderList",
|
||||||
getById: "WorkOrder/GetById",
|
getById: "WorkOrder/GetWorkorderById",
|
||||||
create: "WorkOrder/Create",
|
create: "WorkOrder/Create",
|
||||||
update: "WorkOrder/Update",
|
update: "WorkOrder/Update",
|
||||||
delete: "WorkOrder/DeleteWorkOrder",
|
delete: "WorkOrder/DeleteWorkOrder",
|
||||||
|
|
@ -61,7 +61,7 @@ export const API_PATHS = {
|
||||||
},
|
},
|
||||||
contact: {
|
contact: {
|
||||||
getList: "Contact/GetContactList",
|
getList: "Contact/GetContactList",
|
||||||
getById: "Contact/GetById",
|
getContacts: "Contact/GetContacts",
|
||||||
create: "Contact/Create",
|
create: "Contact/Create",
|
||||||
update: "Contact/Update",
|
update: "Contact/Update",
|
||||||
delete: "Contact/Delete",
|
delete: "Contact/Delete",
|
||||||
|
|
@ -82,7 +82,6 @@ export const API_PATHS = {
|
||||||
},
|
},
|
||||||
account: {
|
account: {
|
||||||
getList: "Account/GetAccountList",
|
getList: "Account/GetAccountList",
|
||||||
getById: "Account/GetById",
|
|
||||||
create: "Account/Create",
|
create: "Account/Create",
|
||||||
update: "Account/Update",
|
update: "Account/Update",
|
||||||
delete: "Account/Delete",
|
delete: "Account/Delete",
|
||||||
|
|
@ -111,7 +110,6 @@ export const API_PATHS = {
|
||||||
create: "Vendor/Create",
|
create: "Vendor/Create",
|
||||||
update: "Vendor/Update",
|
update: "Vendor/Update",
|
||||||
delete: "Vendor/Delete",
|
delete: "Vendor/Delete",
|
||||||
deleteVendor: "Vendor/DeleteVendor",
|
|
||||||
dropdown: "Vendor/Dropdown",
|
dropdown: "Vendor/Dropdown",
|
||||||
},
|
},
|
||||||
calendar: {
|
calendar: {
|
||||||
|
|
|
||||||
|
|
@ -94,4 +94,36 @@ export async function apiDelete<T>(url: string, options?: Options): Promise<T> {
|
||||||
return api.delete(url, options).json<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 };
|
export { mapHttpStatusToMessage };
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue