frontend fully integreated with the backend

This commit is contained in:
Kalana B. Thilakarathna
2026-08-25 23:47:33 +05:30
parent 1bee5f91c6
commit 83d3272784
151 changed files with 10724 additions and 573 deletions
+67
View File
@@ -0,0 +1,67 @@
import { api } from '@/lib/api'
import type {
PaginatedResponse,
PurchaseOrderResponse,
GrnResponse,
PurchaseOrderStatus,
} from '@/types/api'
import type { PageParams } from './master'
// ─── Purchase Orders ──────────────────────────────────────────────────────────
export interface PurchaseOrderItemBody {
itemId: string
quantity: number
unitCost: number
}
export interface PurchaseOrderBody {
supplierId: string
items: PurchaseOrderItemBody[]
}
export interface PurchaseOrderListParams extends PageParams {
supplierId?: string
status?: PurchaseOrderStatus
}
export const purchaseOrders = {
list: (params?: PurchaseOrderListParams) =>
api.get<PaginatedResponse<PurchaseOrderResponse>>('/purchase-orders', { params }).then(r => r.data),
get: (id: string) =>
api.get<PurchaseOrderResponse>(`/purchase-orders/${id}`).then(r => r.data),
create: (body: PurchaseOrderBody) =>
api.post<PurchaseOrderResponse>('/purchase-orders', body).then(r => r.data),
cancel: (id: string, cancelReason: string) =>
api.patch<PurchaseOrderResponse>(`/purchase-orders/${id}/cancel`, { cancelReason }).then(r => r.data),
}
// ─── Goods Receipts (GRN) ─────────────────────────────────────────────────────
export interface GrnItemBody {
purchaseOrderItemId: string
acceptedQuantity: number
rejectedQuantity: number
}
export interface GrnBody {
purchaseOrderId: string
warehouseId: string
receivedAt: string
items: GrnItemBody[]
}
export const grn = {
list: (params?: PageParams & { purchaseOrderId?: string }) =>
api.get<PaginatedResponse<GrnResponse>>('/goods-receipts', { params }).then(r => r.data),
get: (id: string) =>
api.get<GrnResponse>(`/goods-receipts/${id}`).then(r => r.data),
create: (body: GrnBody) =>
api.post<GrnResponse>('/goods-receipts', body).then(r => r.data),
}