inventory1

This commit is contained in:
2026-03-14 21:10:35 -05:00
parent df3f1412f6
commit d21e2e3c0b
21 changed files with 1492 additions and 7 deletions

View File

@@ -20,6 +20,14 @@ import type {
CrmRecordStatus,
CrmRecordSummaryDto,
} from "@mrp/shared/dist/crm/types.js";
import type {
InventoryItemDetailDto,
InventoryItemInput,
InventoryItemOptionDto,
InventoryItemStatus,
InventoryItemSummaryDto,
InventoryItemType,
} from "@mrp/shared/dist/inventory/types.js";
export class ApiError extends Error {
constructor(message: string, public readonly code: string) {
@@ -270,6 +278,43 @@ export const api = {
token
);
},
getInventoryItems(token: string, filters?: { q?: string; status?: InventoryItemStatus; type?: InventoryItemType }) {
return request<InventoryItemSummaryDto[]>(
`/api/v1/inventory/items${buildQueryString({
q: filters?.q,
status: filters?.status,
type: filters?.type,
})}`,
undefined,
token
);
},
getInventoryItem(token: string, itemId: string) {
return request<InventoryItemDetailDto>(`/api/v1/inventory/items/${itemId}`, undefined, token);
},
getInventoryItemOptions(token: string) {
return request<InventoryItemOptionDto[]>("/api/v1/inventory/items/options", undefined, token);
},
createInventoryItem(token: string, payload: InventoryItemInput) {
return request<InventoryItemDetailDto>(
"/api/v1/inventory/items",
{
method: "POST",
body: JSON.stringify(payload),
},
token
);
},
updateInventoryItem(token: string, itemId: string, payload: InventoryItemInput) {
return request<InventoryItemDetailDto>(
`/api/v1/inventory/items/${itemId}`,
{
method: "PUT",
body: JSON.stringify(payload),
},
token
);
},
getGanttDemo(token: string) {
return request<{ tasks: GanttTaskDto[]; links: GanttLinkDto[] }>("/api/v1/gantt/demo", undefined, token);
},