This commit is contained in:
2026-03-15 10:13:53 -05:00
parent 552d4e2844
commit 6644ba2932
30 changed files with 1768 additions and 64 deletions

View File

@@ -33,6 +33,17 @@ import type {
WarehouseLocationOptionDto,
WarehouseSummaryDto,
} from "@mrp/shared/dist/inventory/types.js";
import type {
ProjectCustomerOptionDto,
ProjectDetailDto,
ProjectDocumentOptionDto,
ProjectInput,
ProjectOwnerOptionDto,
ProjectPriority,
ProjectShipmentOptionDto,
ProjectStatus,
ProjectSummaryDto,
} from "@mrp/shared/dist/projects/types.js";
import type {
SalesCustomerOptionDto,
SalesDocumentDetailDto,
@@ -381,6 +392,58 @@ export const api = {
token
);
},
getProjects(
token: string,
filters?: { q?: string; status?: ProjectStatus; priority?: ProjectPriority; customerId?: string; ownerId?: string }
) {
return request<ProjectSummaryDto[]>(
`/api/v1/projects${buildQueryString({
q: filters?.q,
status: filters?.status,
priority: filters?.priority,
customerId: filters?.customerId,
ownerId: filters?.ownerId,
})}`,
undefined,
token
);
},
getProject(token: string, projectId: string) {
return request<ProjectDetailDto>(`/api/v1/projects/${projectId}`, undefined, token);
},
createProject(token: string, payload: ProjectInput) {
return request<ProjectDetailDto>("/api/v1/projects", { method: "POST", body: JSON.stringify(payload) }, token);
},
updateProject(token: string, projectId: string, payload: ProjectInput) {
return request<ProjectDetailDto>(`/api/v1/projects/${projectId}`, { method: "PUT", body: JSON.stringify(payload) }, token);
},
getProjectCustomerOptions(token: string) {
return request<ProjectCustomerOptionDto[]>("/api/v1/projects/customers/options", undefined, token);
},
getProjectOwnerOptions(token: string) {
return request<ProjectOwnerOptionDto[]>("/api/v1/projects/owners/options", undefined, token);
},
getProjectQuoteOptions(token: string, customerId?: string) {
return request<ProjectDocumentOptionDto[]>(
`/api/v1/projects/quotes/options${buildQueryString({ customerId })}`,
undefined,
token
);
},
getProjectOrderOptions(token: string, customerId?: string) {
return request<ProjectDocumentOptionDto[]>(
`/api/v1/projects/orders/options${buildQueryString({ customerId })}`,
undefined,
token
);
},
getProjectShipmentOptions(token: string, customerId?: string) {
return request<ProjectShipmentOptionDto[]>(
`/api/v1/projects/shipments/options${buildQueryString({ customerId })}`,
undefined,
token
);
},
getGanttDemo(token: string) {
return request<{ tasks: GanttTaskDto[]; links: GanttLinkDto[] }>("/api/v1/gantt/demo", undefined, token);
},
@@ -521,6 +584,32 @@ export const api = {
return response.blob();
},
async getShipmentLabelPdf(token: string, shipmentId: string) {
const response = await fetch(`/api/v1/documents/shipping/shipments/${shipmentId}/shipping-label.pdf`, {
headers: {
Authorization: `Bearer ${token}`,
},
});
if (!response.ok) {
throw new ApiError("Unable to render shipping label PDF.", "SHIPPING_LABEL_FAILED");
}
return response.blob();
},
async getShipmentBillOfLadingPdf(token: string, shipmentId: string) {
const response = await fetch(`/api/v1/documents/shipping/shipments/${shipmentId}/bill-of-lading.pdf`, {
headers: {
Authorization: `Bearer ${token}`,
},
});
if (!response.ok) {
throw new ApiError("Unable to render bill of lading PDF.", "BILL_OF_LADING_FAILED");
}
return response.blob();
},
async getQuotePdf(token: string, quoteId: string) {
const response = await fetch(`/api/v1/documents/sales/quotes/${quoteId}/document.pdf`, {
headers: {