mirror of
https://github.com/Sea-Haven-Industries/proposal-system.git
synced 2026-10-07 16:18:57 +00:00
64 lines
1.7 KiB
TypeScript
64 lines
1.7 KiB
TypeScript
|
|
import apiClient from './client';
|
||
|
|
|
||
|
|
export type PricingMode = 'UnitPrice' | 'TotalPrice' | 'Both';
|
||
|
|
export type LineItemSource = 'AI' | 'Vendor' | 'Manual' | 'Historical';
|
||
|
|
|
||
|
|
export interface LineItem {
|
||
|
|
id: string;
|
||
|
|
proposalId: string;
|
||
|
|
description: string;
|
||
|
|
quantity: number;
|
||
|
|
unit: string;
|
||
|
|
unitPrice: number | null;
|
||
|
|
totalPrice: number;
|
||
|
|
pricingMode: PricingMode;
|
||
|
|
sortOrder: number;
|
||
|
|
source: LineItemSource;
|
||
|
|
createdAt: string;
|
||
|
|
updatedAt: string;
|
||
|
|
}
|
||
|
|
|
||
|
|
export interface CreateLineItemRequest {
|
||
|
|
description: string;
|
||
|
|
quantity: number;
|
||
|
|
unit: string;
|
||
|
|
unitPrice: number | null;
|
||
|
|
totalPrice: number;
|
||
|
|
pricingMode: PricingMode;
|
||
|
|
sortOrder: number;
|
||
|
|
source: LineItemSource;
|
||
|
|
}
|
||
|
|
|
||
|
|
export interface UpdateLineItemEntry {
|
||
|
|
id: string | null;
|
||
|
|
description: string;
|
||
|
|
quantity: number;
|
||
|
|
unit: string;
|
||
|
|
unitPrice: number | null;
|
||
|
|
totalPrice: number;
|
||
|
|
pricingMode: PricingMode;
|
||
|
|
sortOrder: number;
|
||
|
|
source: LineItemSource;
|
||
|
|
}
|
||
|
|
|
||
|
|
export const lineItemsApi = {
|
||
|
|
getAll: async (proposalId: string): Promise<LineItem[]> => {
|
||
|
|
const res = await apiClient.get(`/proposals/${proposalId}/line-items`);
|
||
|
|
return res.data;
|
||
|
|
},
|
||
|
|
|
||
|
|
create: async (proposalId: string, data: CreateLineItemRequest): Promise<LineItem> => {
|
||
|
|
const res = await apiClient.post(`/proposals/${proposalId}/line-items`, data);
|
||
|
|
return res.data;
|
||
|
|
},
|
||
|
|
|
||
|
|
bulkUpdate: async (proposalId: string, lineItems: UpdateLineItemEntry[]): Promise<LineItem[]> => {
|
||
|
|
const res = await apiClient.put(`/proposals/${proposalId}/line-items`, { lineItems });
|
||
|
|
return res.data;
|
||
|
|
},
|
||
|
|
|
||
|
|
delete: async (proposalId: string, itemId: string): Promise<void> => {
|
||
|
|
await apiClient.delete(`/proposals/${proposalId}/line-items/${itemId}`);
|
||
|
|
},
|
||
|
|
};
|