Refactor API client and remove unused code
- Removed the ApiError class and related functions from the api-client module. - Updated vendor detail page to handle errors without the ApiError class. - Refactored various API modules to use in-memory mock data instead of commented-out fetch implementations. - Removed the auth-token module as it was no longer needed. - Updated error handling to use a more generic error structure. - Adjusted common types to include ApiResult interface for better type management.
This commit is contained in:
@@ -1,29 +1,9 @@
|
||||
// One typed client method per Category endpoint (docs/11-BACKEND-PHASE1.md §2.3, FR-MD-04).
|
||||
//
|
||||
// UI-ONLY MODE: the real fetch-based implementation is commented out below and
|
||||
// replaced with in-memory sample data (lib/api/mock-data.ts) so these screens
|
||||
// can be reviewed without a running backend. Restore the commented block and
|
||||
// delete the mock block once Backend/PROGRESS.md §1 (Master Data) exists.
|
||||
// In-memory sample data (lib/api/mock-data.ts) — no backend API calls.
|
||||
import { PagedResponse } from "@/types/common"
|
||||
import { Category, CategoryTreeNode, CreateCategoryRequest } from "@/types/master-data"
|
||||
import { allocateCategoryId, mockCategories, mockDelay } from "@/lib/api/mock-data"
|
||||
|
||||
// --- Real implementation (restore when the backend exists) --------------------
|
||||
// import { apiRequest } from "@/lib/api-client"
|
||||
//
|
||||
// export const categoriesApi = {
|
||||
// list() {
|
||||
// return apiRequest<PagedResponse<Category>>("/categories")
|
||||
// },
|
||||
// tree() {
|
||||
// return apiRequest<CategoryTreeNode[]>("/categories?tree=true")
|
||||
// },
|
||||
// create(request: CreateCategoryRequest) {
|
||||
// return apiRequest<Category>("/categories", { method: "POST", body: request })
|
||||
// },
|
||||
// }
|
||||
|
||||
// --- Mock implementation (UI-only review) --------------------------------------
|
||||
function buildTree(categories: Category[]): CategoryTreeNode[] {
|
||||
const nodes = new Map<number, CategoryTreeNode>(categories.map((c) => [c.categoryId, { ...c, children: [] }]))
|
||||
const roots: CategoryTreeNode[] = []
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
// One typed client method per GRN endpoint (docs/11-BACKEND-PHASE1.md §4).
|
||||
//
|
||||
// UI-ONLY MODE: the real fetch-based implementation is commented out below and
|
||||
// replaced with an in-memory mock store (lib/api/mock-data.ts) so the GRN
|
||||
// screens (list/create/confirm/release) can be reviewed end-to-end without a
|
||||
// running backend. Restore the commented block and delete the mock block once
|
||||
// Backend/PROGRESS.md §3/§4 (GRN + Stock Core) exist. Note GET /grns and
|
||||
// GET /grns/{id} are not yet in docs/11-BACKEND-PHASE1.md §4 — see the note in
|
||||
// Frontend/PROGRESS.md §4.
|
||||
// In-memory mock store (lib/api/mock-data.ts) — no backend API calls. Note
|
||||
// GET /grns and GET /grns/{id} are not in docs/11-BACKEND-PHASE1.md §4 — see
|
||||
// the note in Frontend/PROGRESS.md §4.
|
||||
import { PagedResponse } from "@/types/common"
|
||||
import {
|
||||
ConfirmGrnResponse,
|
||||
@@ -20,60 +15,6 @@ import {
|
||||
} from "@/types/grn"
|
||||
import { allocateGrnId, allocateGrnLineId, mockDelay, mockGrns, mockPurchaseOrders, receiveLayer } from "@/lib/api/mock-data"
|
||||
|
||||
// --- Real implementation (restore when the backend exists) --------------------
|
||||
// import { apiRequest, apiRequestWithETag, buildQuery } from "@/lib/api-client"
|
||||
//
|
||||
// export interface ListGrnsParams {
|
||||
// page?: number
|
||||
// pageSize?: number
|
||||
// q?: string
|
||||
// status?: GrnStatus
|
||||
// poId?: number
|
||||
// warehouseId?: number
|
||||
// }
|
||||
//
|
||||
// export const grnsApi = {
|
||||
// list(params: ListGrnsParams = {}) {
|
||||
// return apiRequest<PagedResponse<GrnSummary>>(`/grns${buildQuery(params)}`)
|
||||
// },
|
||||
//
|
||||
// get(grnId: number) {
|
||||
// return apiRequest<Grn>(`/grns/${grnId}`)
|
||||
// },
|
||||
//
|
||||
// async create(request: CreateGrnRequest) {
|
||||
// const { data } = await apiRequestWithETag<Grn>("/grns", { method: "POST", body: request })
|
||||
// return data
|
||||
// },
|
||||
//
|
||||
// // Draft-only — a GRN with createdLayers/ledger postings (Confirmed/Closed) is
|
||||
// // immutable per docs/11 §4.
|
||||
// async update(grnId: number, request: CreateGrnRequest, ifMatch: string) {
|
||||
// const { data } = await apiRequestWithETag<Grn>(`/grns/${grnId}`, { method: "PUT", body: request, ifMatch })
|
||||
// return data
|
||||
// },
|
||||
//
|
||||
// remove(grnId: number) {
|
||||
// return apiRequest<void>(`/grns/${grnId}`, { method: "DELETE" })
|
||||
// },
|
||||
//
|
||||
// confirm(grnId: number, idempotencyKey?: string) {
|
||||
// return apiRequest<ConfirmGrnResponse>(`/grns/${grnId}/confirm`, {
|
||||
// method: "POST",
|
||||
// body: {},
|
||||
// idempotencyKey,
|
||||
// })
|
||||
// },
|
||||
//
|
||||
// releaseLine(grnId: number, grnLineId: number, action: ReleaseAction) {
|
||||
// return apiRequest<ReleaseGrnLineResponse>(`/grns/${grnId}/lines/${grnLineId}/release`, {
|
||||
// method: "POST",
|
||||
// body: { action },
|
||||
// })
|
||||
// },
|
||||
// }
|
||||
|
||||
// --- Mock implementation (UI-only review) --------------------------------------
|
||||
export interface ListGrnsParams {
|
||||
page?: number
|
||||
pageSize?: number
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
// One typed client method per Item endpoint (docs/11-BACKEND-PHASE1.md §2.1, FR-MD-01/05/08).
|
||||
// `list` also backs the GRN/PO/Requisition/RFQ item pickers built in earlier sessions.
|
||||
//
|
||||
// UI-ONLY MODE: the real fetch-based implementation is commented out below and
|
||||
// replaced with in-memory sample data (lib/api/mock-data.ts) so these screens
|
||||
// can be reviewed without a running backend. Restore the commented block and
|
||||
// delete the mock block once Backend/PROGRESS.md §1 (Master Data) exists.
|
||||
import { ApiResult } from "@/lib/api-client"
|
||||
import { EntityStatus, PagedResponse } from "@/types/common"
|
||||
// In-memory sample data (lib/api/mock-data.ts) — no backend API calls.
|
||||
import { ApiResult, EntityStatus, PagedResponse } from "@/types/common"
|
||||
import {
|
||||
CreateItemRequest,
|
||||
Item,
|
||||
@@ -26,43 +21,6 @@ import {
|
||||
mockItems,
|
||||
} from "@/lib/api/mock-data"
|
||||
|
||||
// --- Real implementation (restore when the backend exists) --------------------
|
||||
// import { apiRequest, apiRequestWithETag, buildQuery } from "@/lib/api-client"
|
||||
//
|
||||
// export interface ListItemsParams {
|
||||
// page?: number
|
||||
// pageSize?: number
|
||||
// q?: string
|
||||
// status?: EntityStatus
|
||||
// categoryId?: number
|
||||
// trackingMode?: TrackingMode
|
||||
// }
|
||||
//
|
||||
// export const itemsApi = {
|
||||
// list(params: ListItemsParams = {}) {
|
||||
// return apiRequest<PagedResponse<ItemListItem>>(`/items${buildQuery(params)}`)
|
||||
// },
|
||||
// get(itemId: number) {
|
||||
// return apiRequestWithETag<Item>(`/items/${itemId}`)
|
||||
// },
|
||||
// create(request: CreateItemRequest) {
|
||||
// return apiRequestWithETag<Item>("/items", { method: "POST", body: request })
|
||||
// },
|
||||
// update(itemId: number, request: UpdateItemRequest, ifMatch: string) {
|
||||
// return apiRequestWithETag<Item>(`/items/${itemId}`, { method: "PUT", body: request, ifMatch })
|
||||
// },
|
||||
// updateStatus(itemId: number, status: EntityStatus) {
|
||||
// return apiRequest<void>(`/items/${itemId}/status`, { method: "PATCH", body: { status } })
|
||||
// },
|
||||
// updateReorder(itemId: number, request: UpdateItemReorderRequest) {
|
||||
// return apiRequest<{ settings: UpdateItemReorderRequest["settings"] }>(`/items/${itemId}/reorder`, { method: "PUT", body: request })
|
||||
// },
|
||||
// updateUomConversions(itemId: number, request: UpdateUomConversionsRequest) {
|
||||
// return apiRequest<UpdateUomConversionsResponse>(`/items/${itemId}/uom-conversions`, { method: "PUT", body: request })
|
||||
// },
|
||||
// }
|
||||
|
||||
// --- Mock implementation (UI-only review) --------------------------------------
|
||||
export interface ListItemsParams {
|
||||
page?: number
|
||||
pageSize?: number
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
// Temporary in-memory sample data so the GRN screens can be reviewed as pure UI
|
||||
// without a running backend. Shapes mirror docs/11-BACKEND-PHASE1.md exactly.
|
||||
//
|
||||
// This file (and the "MOCK" blocks in the sibling lib/api/*.ts files) is meant
|
||||
// to be deleted once the real GRN backend exists — the original fetch-based
|
||||
// implementations are left commented out in each file for that switch-back.
|
||||
// In-memory sample data backing every lib/api/*.ts module — the app has no
|
||||
// fetch-based backend connection (lib/api-client.ts and lib/auth-token.ts were
|
||||
// removed). Shapes mirror docs/11-BACKEND-PHASE1.md.
|
||||
import { Bin, Category, Item, Uom, Vendor, Warehouse } from "@/types/master-data"
|
||||
import { PurchaseOrder, Quotation, Requisition, Rfq, PurchaseReturn } from "@/types/procurement"
|
||||
import { Grn } from "@/types/grn"
|
||||
|
||||
@@ -1,13 +1,7 @@
|
||||
// One typed client method per Purchase Order endpoint (docs/11-BACKEND-PHASE1.md §3.3,
|
||||
// FR-PROC-03..07). `get`/`list` also back the GRN "against a PO" picker.
|
||||
//
|
||||
// UI-ONLY MODE: the real fetch-based implementation is commented out below and
|
||||
// replaced with in-memory sample data (lib/api/mock-data.ts) so the GRN and
|
||||
// Procurement screens can be reviewed without a running backend. Restore the
|
||||
// commented block and delete the mock block once Backend/PROGRESS.md §2/§3/§4
|
||||
// (Procurement + GRN + Stock Core) exist.
|
||||
import { ApiResult } from "@/lib/api-client"
|
||||
import { PagedResponse } from "@/types/common"
|
||||
// In-memory sample data (lib/api/mock-data.ts) — no backend API calls.
|
||||
import { ApiResult, PagedResponse } from "@/types/common"
|
||||
import {
|
||||
CancelPurchaseOrderRequest,
|
||||
CreatePurchaseOrderRequest,
|
||||
@@ -25,39 +19,6 @@ import {
|
||||
mockPurchaseOrders,
|
||||
} from "@/lib/api/mock-data"
|
||||
|
||||
// --- Real implementation (restore when the backend exists) --------------------
|
||||
// import { apiRequest, apiRequestWithETag, buildQuery } from "@/lib/api-client"
|
||||
//
|
||||
// export interface ListPurchaseOrdersParams {
|
||||
// page?: number
|
||||
// pageSize?: number
|
||||
// q?: string
|
||||
// status?: PurchaseOrderStatus
|
||||
// vendorId?: number
|
||||
// }
|
||||
//
|
||||
// export const purchaseOrdersApi = {
|
||||
// list(params: ListPurchaseOrdersParams = {}) {
|
||||
// return apiRequest<PagedResponse<PurchaseOrderSummary>>(`/purchase-orders${buildQuery(params)}`)
|
||||
// },
|
||||
// get(poId: number) {
|
||||
// return apiRequest<PurchaseOrder>(`/purchase-orders/${poId}`)
|
||||
// },
|
||||
// getWithETag(poId: number) {
|
||||
// return apiRequestWithETag<PurchaseOrder>(`/purchase-orders/${poId}`)
|
||||
// },
|
||||
// create(request: CreatePurchaseOrderRequest) {
|
||||
// return apiRequestWithETag<PurchaseOrder>("/purchase-orders", { method: "POST", body: request })
|
||||
// },
|
||||
// update(poId: number, request: UpdatePurchaseOrderRequest, ifMatch: string) {
|
||||
// return apiRequestWithETag<PurchaseOrder>(`/purchase-orders/${poId}`, { method: "PUT", body: request, ifMatch })
|
||||
// },
|
||||
// cancel(poId: number, request: CancelPurchaseOrderRequest) {
|
||||
// return apiRequest<PurchaseOrder>(`/purchase-orders/${poId}/cancel`, { method: "POST", body: request })
|
||||
// },
|
||||
// }
|
||||
|
||||
// --- Mock implementation (UI-only review) --------------------------------------
|
||||
export interface ListPurchaseOrdersParams {
|
||||
page?: number
|
||||
pageSize?: number
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
// One typed client method per Purchase Return endpoint (docs/11-BACKEND-PHASE1.md §3.4, FR-PROC-08).
|
||||
//
|
||||
// UI-ONLY MODE: the real fetch-based implementation is commented out below and
|
||||
// replaced with in-memory sample data (lib/api/mock-data.ts) so the Procurement
|
||||
// screens can be reviewed without a running backend. Restore the commented block
|
||||
// and delete the mock block once Backend/PROGRESS.md §2 (Procurement) exists.
|
||||
// In-memory sample data (lib/api/mock-data.ts) — no backend API calls.
|
||||
import { PagedResponse } from "@/types/common"
|
||||
import { CreatePurchaseReturnRequest, PurchaseReturn, PurchaseReturnSummary } from "@/types/procurement"
|
||||
import {
|
||||
@@ -15,22 +11,6 @@ import {
|
||||
postLedgerEntry,
|
||||
} from "@/lib/api/mock-data"
|
||||
|
||||
// --- Real implementation (restore when the backend exists) --------------------
|
||||
// import { apiRequest } from "@/lib/api-client"
|
||||
//
|
||||
// export const purchaseReturnsApi = {
|
||||
// list() {
|
||||
// return apiRequest<PagedResponse<PurchaseReturnSummary>>("/purchase-returns")
|
||||
// },
|
||||
// get(returnId: number) {
|
||||
// return apiRequest<PurchaseReturn>(`/purchase-returns/${returnId}`)
|
||||
// },
|
||||
// create(request: CreatePurchaseReturnRequest) {
|
||||
// return apiRequest<PurchaseReturn>("/purchase-returns", { method: "POST", body: request })
|
||||
// },
|
||||
// }
|
||||
|
||||
// --- Mock implementation (UI-only review) --------------------------------------
|
||||
function toSummary(r: PurchaseReturn): PurchaseReturnSummary {
|
||||
return {
|
||||
returnId: r.returnId,
|
||||
|
||||
@@ -1,21 +1,9 @@
|
||||
// One typed client method for reference data (docs/11-BACKEND-PHASE1.md §6).
|
||||
//
|
||||
// UI-ONLY MODE: the real fetch-based implementation is commented out below and
|
||||
// replaced with in-memory sample data (lib/api/mock-data.ts).
|
||||
// In-memory sample data (lib/api/mock-data.ts) — no backend API calls.
|
||||
import { PagedResponse } from "@/types/common"
|
||||
import { ReasonCode, ReasonCodeContext } from "@/types/stock"
|
||||
import { mockDelay, mockReasonCodes } from "@/lib/api/mock-data"
|
||||
|
||||
// --- Real implementation (restore when the backend exists) --------------------
|
||||
// import { apiRequest, buildQuery } from "@/lib/api-client"
|
||||
//
|
||||
// export const reasonCodesApi = {
|
||||
// list(context?: ReasonCodeContext) {
|
||||
// return apiRequest<PagedResponse<ReasonCode>>(`/reason-codes${buildQuery({ context })}`)
|
||||
// },
|
||||
// }
|
||||
|
||||
// --- Mock implementation (UI-only review) --------------------------------------
|
||||
export const reasonCodesApi = {
|
||||
list(context?: ReasonCodeContext): Promise<PagedResponse<ReasonCode>> {
|
||||
const items = mockReasonCodes.filter((r) => !context || r.context === context)
|
||||
|
||||
@@ -1,38 +1,9 @@
|
||||
// One typed client method per Requisition endpoint (docs/11-BACKEND-PHASE1.md §3.1, FR-PROC-01).
|
||||
//
|
||||
// UI-ONLY MODE: the real fetch-based implementation is commented out below and
|
||||
// replaced with in-memory sample data (lib/api/mock-data.ts) so the Procurement
|
||||
// screens can be reviewed without a running backend. Restore the commented block
|
||||
// and delete the mock block once Backend/PROGRESS.md §2 (Procurement) exists.
|
||||
// In-memory sample data (lib/api/mock-data.ts) — no backend API calls.
|
||||
import { PagedResponse } from "@/types/common"
|
||||
import { CreateRequisitionRequest, Requisition, RequisitionStatus, RequisitionSummary } from "@/types/procurement"
|
||||
import { allocateReqLineId, allocateRequisitionId, mockDelay, mockRequisitions } from "@/lib/api/mock-data"
|
||||
|
||||
// --- Real implementation (restore when the backend exists) --------------------
|
||||
// import { apiRequest, buildQuery } from "@/lib/api-client"
|
||||
//
|
||||
// export interface ListRequisitionsParams {
|
||||
// page?: number
|
||||
// pageSize?: number
|
||||
// status?: RequisitionStatus
|
||||
// }
|
||||
//
|
||||
// export const requisitionsApi = {
|
||||
// list(params: ListRequisitionsParams = {}) {
|
||||
// return apiRequest<PagedResponse<RequisitionSummary>>(`/requisitions${buildQuery(params)}`)
|
||||
// },
|
||||
// get(requisitionId: number) {
|
||||
// return apiRequest<Requisition>(`/requisitions/${requisitionId}`)
|
||||
// },
|
||||
// create(request: CreateRequisitionRequest) {
|
||||
// return apiRequest<Requisition>("/requisitions", { method: "POST", body: request })
|
||||
// },
|
||||
// submit(requisitionId: number) {
|
||||
// return apiRequest<Requisition>(`/requisitions/${requisitionId}/submit`, { method: "POST", body: {} })
|
||||
// },
|
||||
// }
|
||||
|
||||
// --- Mock implementation (UI-only review) --------------------------------------
|
||||
export interface ListRequisitionsParams {
|
||||
page?: number
|
||||
pageSize?: number
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
// One typed client method per RFQ/Quotation endpoint (docs/11-BACKEND-PHASE1.md §3.2, FR-PROC-02).
|
||||
//
|
||||
// UI-ONLY MODE: the real fetch-based implementation is commented out below and
|
||||
// replaced with in-memory sample data (lib/api/mock-data.ts) so the Procurement
|
||||
// screens can be reviewed without a running backend. Restore the commented block
|
||||
// and delete the mock block once Backend/PROGRESS.md §2 (Procurement) exists.
|
||||
// In-memory sample data (lib/api/mock-data.ts) — no backend API calls.
|
||||
import { PagedResponse } from "@/types/common"
|
||||
import {
|
||||
CreateQuotationRequest,
|
||||
@@ -23,28 +19,6 @@ import {
|
||||
mockRfqs,
|
||||
} from "@/lib/api/mock-data"
|
||||
|
||||
// --- Real implementation (restore when the backend exists) --------------------
|
||||
// import { apiRequest } from "@/lib/api-client"
|
||||
//
|
||||
// export const rfqsApi = {
|
||||
// list() {
|
||||
// return apiRequest<PagedResponse<RfqSummary>>("/rfqs")
|
||||
// },
|
||||
// get(rfqId: number) {
|
||||
// return apiRequest<Rfq>(`/rfqs/${rfqId}`)
|
||||
// },
|
||||
// create(request: CreateRfqRequest) {
|
||||
// return apiRequest<Rfq>("/rfqs", { method: "POST", body: request })
|
||||
// },
|
||||
// addQuotation(rfqId: number, request: CreateQuotationRequest) {
|
||||
// return apiRequest<Quotation>(`/rfqs/${rfqId}/quotations`, { method: "POST", body: request })
|
||||
// },
|
||||
// comparison(rfqId: number) {
|
||||
// return apiRequest<RfqComparison>(`/rfqs/${rfqId}/comparison`)
|
||||
// },
|
||||
// }
|
||||
|
||||
// --- Mock implementation (UI-only review) --------------------------------------
|
||||
function toSummary(r: Rfq): RfqSummary {
|
||||
return {
|
||||
rfqId: r.rfqId,
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
// One typed client method per adjustment endpoint (docs/11-BACKEND-PHASE1.md §5.5).
|
||||
//
|
||||
// UI-ONLY MODE: the real fetch-based implementation is commented out below and
|
||||
// replaced with the in-memory Stock Core (lib/api/mock-data.ts). Restore the
|
||||
// commented block and delete the mock block once Backend/PROGRESS.md §5
|
||||
// (stock transactions) exists. GET /stock-adjustments and GET
|
||||
// /stock-adjustments/{id} are not documented in docs/11 §5.5 — same
|
||||
// assumed-extension deviation as GRN (see Frontend/PROGRESS.md §5).
|
||||
// In-memory Stock Core (lib/api/mock-data.ts) — no backend API calls.
|
||||
import { PagedResponse } from "@/types/common"
|
||||
import { AdjustmentStatus, CreateAdjustmentRequest, StockAdjustment, StockAdjustmentSummary } from "@/types/stock"
|
||||
import {
|
||||
@@ -19,28 +13,6 @@ import {
|
||||
receiveLayer,
|
||||
} from "@/lib/api/mock-data"
|
||||
|
||||
// --- Real implementation (restore when the backend exists) --------------------
|
||||
// import { apiRequest, buildQuery } from "@/lib/api-client"
|
||||
//
|
||||
// export interface ListAdjustmentsParams {
|
||||
// page?: number
|
||||
// pageSize?: number
|
||||
// warehouseId?: number
|
||||
// }
|
||||
//
|
||||
// export const stockAdjustmentsApi = {
|
||||
// list(params: ListAdjustmentsParams = {}) {
|
||||
// return apiRequest<PagedResponse<StockAdjustmentSummary>>(`/stock-adjustments${buildQuery(params)}`)
|
||||
// },
|
||||
// get(adjustmentId: number) {
|
||||
// return apiRequest<StockAdjustment>(`/stock-adjustments/${adjustmentId}`)
|
||||
// },
|
||||
// create(request: CreateAdjustmentRequest) {
|
||||
// return apiRequest<StockAdjustment>("/stock-adjustments", { method: "POST", body: request })
|
||||
// },
|
||||
// }
|
||||
|
||||
// --- Mock implementation (UI-only review) --------------------------------------
|
||||
export interface ListAdjustmentsParams {
|
||||
page?: number
|
||||
pageSize?: number
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
// One typed client method per count endpoint (docs/11-BACKEND-PHASE1.md §5.6).
|
||||
//
|
||||
// UI-ONLY MODE: the real fetch-based implementation is commented out below and
|
||||
// replaced with the in-memory Stock Core (lib/api/mock-data.ts). Restore the
|
||||
// commented block and delete the mock block once Backend/PROGRESS.md §5
|
||||
// (stock transactions) exists. GET /stock-counts and GET /stock-counts/{id}
|
||||
// are not documented in docs/11 §5.6 — same assumed-extension deviation as
|
||||
// GRN (see Frontend/PROGRESS.md §5).
|
||||
// In-memory Stock Core (lib/api/mock-data.ts) — no backend API calls.
|
||||
import { PagedResponse } from "@/types/common"
|
||||
import {
|
||||
CountStatus,
|
||||
@@ -31,34 +25,6 @@ import {
|
||||
receiveLayer,
|
||||
} from "@/lib/api/mock-data"
|
||||
|
||||
// --- Real implementation (restore when the backend exists) --------------------
|
||||
// import { apiRequest, buildQuery } from "@/lib/api-client"
|
||||
//
|
||||
// export interface ListCountsParams {
|
||||
// page?: number
|
||||
// pageSize?: number
|
||||
// warehouseId?: number
|
||||
// }
|
||||
//
|
||||
// export const stockCountsApi = {
|
||||
// list(params: ListCountsParams = {}) {
|
||||
// return apiRequest<PagedResponse<StockCountSummary>>(`/stock-counts${buildQuery(params)}`)
|
||||
// },
|
||||
// get(countId: number) {
|
||||
// return apiRequest<StockCount>(`/stock-counts/${countId}`)
|
||||
// },
|
||||
// create(request: CreateCountRequest) {
|
||||
// return apiRequest<StockCount>("/stock-counts", { method: "POST", body: request })
|
||||
// },
|
||||
// enterCounts(countId: number, request: EnterCountsRequest) {
|
||||
// return apiRequest<EnterCountsResponse>(`/stock-counts/${countId}/counts`, { method: "PUT", body: request })
|
||||
// },
|
||||
// post(countId: number) {
|
||||
// return apiRequest<PostCountResponse>(`/stock-counts/${countId}/post`, { method: "POST", body: {} })
|
||||
// },
|
||||
// }
|
||||
|
||||
// --- Mock implementation (UI-only review) --------------------------------------
|
||||
export interface ListCountsParams {
|
||||
page?: number
|
||||
pageSize?: number
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
// One typed client method per transfer endpoint (docs/11-BACKEND-PHASE1.md §5.4).
|
||||
//
|
||||
// UI-ONLY MODE: the real fetch-based implementation is commented out below and
|
||||
// replaced with the in-memory Stock Core (lib/api/mock-data.ts). Restore the
|
||||
// commented block and delete the mock block once Backend/PROGRESS.md §5
|
||||
// (stock transactions) exists. GET /stock-transfers and GET /stock-transfers/{id}
|
||||
// are not documented in docs/11 §5.4 — same assumed-extension deviation as GRN
|
||||
// (see Frontend/PROGRESS.md §5).
|
||||
// In-memory Stock Core (lib/api/mock-data.ts) — no backend API calls.
|
||||
import { PagedResponse } from "@/types/common"
|
||||
import {
|
||||
CreateTransferRequest,
|
||||
@@ -27,39 +21,6 @@ import {
|
||||
receiveLayer,
|
||||
} from "@/lib/api/mock-data"
|
||||
|
||||
// --- Real implementation (restore when the backend exists) --------------------
|
||||
// import { apiRequest, buildQuery } from "@/lib/api-client"
|
||||
//
|
||||
// export interface ListTransfersParams {
|
||||
// page?: number
|
||||
// pageSize?: number
|
||||
// status?: TransferStatus
|
||||
// srcWarehouseId?: number
|
||||
// destWarehouseId?: number
|
||||
// }
|
||||
//
|
||||
// export const stockTransfersApi = {
|
||||
// list(params: ListTransfersParams = {}) {
|
||||
// return apiRequest<PagedResponse<StockTransferSummary>>(`/stock-transfers${buildQuery(params)}`)
|
||||
// },
|
||||
// get(transferId: number) {
|
||||
// return apiRequest<StockTransfer>(`/stock-transfers/${transferId}`)
|
||||
// },
|
||||
// create(request: CreateTransferRequest) {
|
||||
// return apiRequest<StockTransfer>("/stock-transfers", { method: "POST", body: request })
|
||||
// },
|
||||
// dispatch(transferId: number) {
|
||||
// return apiRequest<DispatchTransferResponse>(`/stock-transfers/${transferId}/dispatch`, { method: "POST", body: {} })
|
||||
// },
|
||||
// receive(transferId: number, lines: ReceiveTransferLineInput[]) {
|
||||
// return apiRequest<ReceiveTransferResponse>(`/stock-transfers/${transferId}/receive`, {
|
||||
// method: "POST",
|
||||
// body: { lines },
|
||||
// })
|
||||
// },
|
||||
// }
|
||||
|
||||
// --- Mock implementation (UI-only review) --------------------------------------
|
||||
export interface ListTransfersParams {
|
||||
page?: number
|
||||
pageSize?: number
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
// One typed client method per stock-enquiry endpoint (docs/11-BACKEND-PHASE1.md §5.1-5.3, §5.7).
|
||||
//
|
||||
// UI-ONLY MODE: the real fetch-based implementation is commented out below and
|
||||
// replaced with the in-memory Stock Core (lib/api/mock-data.ts) so the Stock
|
||||
// Management screens can be reviewed without a running backend. Restore the
|
||||
// commented block and delete the mock block once Backend/PROGRESS.md §4
|
||||
// (Stock Core) exists.
|
||||
// In-memory Stock Core (lib/api/mock-data.ts) — no backend API calls.
|
||||
import { PagedResponse } from "@/types/common"
|
||||
import { LedgerEntry, OnHand, ReorderAlert, ReorderRequisitionResponse, Valuation } from "@/types/stock"
|
||||
import {
|
||||
@@ -19,44 +14,6 @@ import {
|
||||
mockStockLedger,
|
||||
} from "@/lib/api/mock-data"
|
||||
|
||||
// --- Real implementation (restore when the backend exists) --------------------
|
||||
// import { apiRequest, buildQuery } from "@/lib/api-client"
|
||||
//
|
||||
// export interface LedgerQuery {
|
||||
// itemId?: number
|
||||
// warehouseId?: number
|
||||
// from?: string
|
||||
// to?: string
|
||||
// page?: number
|
||||
// pageSize?: number
|
||||
// }
|
||||
//
|
||||
// export const stockApi = {
|
||||
// onHand(itemId: number, warehouseId: number) {
|
||||
// return apiRequest<OnHand>(`/stock/on-hand${buildQuery({ itemId, warehouseId })}`)
|
||||
// },
|
||||
//
|
||||
// ledger(params: LedgerQuery) {
|
||||
// return apiRequest<PagedResponse<LedgerEntry>>(`/stock/ledger${buildQuery(params)}`)
|
||||
// },
|
||||
//
|
||||
// valuation(itemId: number, warehouseId: number) {
|
||||
// return apiRequest<Valuation>(`/stock/valuation${buildQuery({ itemId, warehouseId })}`)
|
||||
// },
|
||||
//
|
||||
// reorderAlerts(warehouseId?: number) {
|
||||
// return apiRequest<PagedResponse<ReorderAlert>>(`/stock/reorder-alerts${buildQuery({ warehouseId })}`)
|
||||
// },
|
||||
//
|
||||
// createReorderRequisition(itemId: number, warehouseId: number) {
|
||||
// return apiRequest<ReorderRequisitionResponse>(
|
||||
// `/stock/reorder-alerts/${itemId}/requisition${buildQuery({ warehouseId })}`,
|
||||
// { method: "POST", body: {} }
|
||||
// )
|
||||
// },
|
||||
// }
|
||||
|
||||
// --- Mock implementation (UI-only review) --------------------------------------
|
||||
export interface LedgerQuery {
|
||||
itemId?: number
|
||||
warehouseId?: number
|
||||
|
||||
@@ -1,27 +1,10 @@
|
||||
// One typed client method per UOM endpoint (docs/11-BACKEND-PHASE1.md §2.2, FR-MD-02).
|
||||
// `list` also backs the GRN/PO line UOM picker built in earlier sessions.
|
||||
//
|
||||
// UI-ONLY MODE: the real fetch-based implementation is commented out below and
|
||||
// replaced with in-memory sample data (lib/api/mock-data.ts) so these screens
|
||||
// can be reviewed without a running backend. Restore the commented block and
|
||||
// delete the mock block once Backend/PROGRESS.md §1 (Master Data) exists.
|
||||
// In-memory sample data (lib/api/mock-data.ts) — no backend API calls.
|
||||
import { PagedResponse } from "@/types/common"
|
||||
import { CreateUomRequest, Uom } from "@/types/master-data"
|
||||
import { allocateUomId, mockDelay, mockUoms } from "@/lib/api/mock-data"
|
||||
|
||||
// --- Real implementation (restore when the backend exists) --------------------
|
||||
// import { apiRequest } from "@/lib/api-client"
|
||||
//
|
||||
// export const uomsApi = {
|
||||
// list() {
|
||||
// return apiRequest<PagedResponse<Uom>>("/uoms")
|
||||
// },
|
||||
// create(request: CreateUomRequest) {
|
||||
// return apiRequest<Uom>("/uoms", { method: "POST", body: request })
|
||||
// },
|
||||
// }
|
||||
|
||||
// --- Mock implementation (UI-only review) --------------------------------------
|
||||
export const uomsApi = {
|
||||
list(): Promise<PagedResponse<Uom>> {
|
||||
return mockDelay({
|
||||
|
||||
@@ -1,14 +1,8 @@
|
||||
// One typed client method per vendor (supplier) endpoint (docs/11-BACKEND-PHASE1.md
|
||||
// §2.4, FR-MD-06). "GET/PUT/PATCH follow the Item pattern" per the doc — ETag/If-Match
|
||||
// on update, PATCH status for deactivate (masters are deactivated, not hard-deleted,
|
||||
// FR-MD-08).
|
||||
//
|
||||
// UI-ONLY MODE: the real fetch-based implementation is commented out below and
|
||||
// replaced with in-memory sample data (lib/api/mock-data.ts) so these screens can
|
||||
// be reviewed without a running backend. Restore the commented block and delete
|
||||
// the mock block once Backend/PROGRESS.md §1 (Master Data) exists.
|
||||
import { ApiResult } from "@/lib/api-client"
|
||||
import { EntityStatus, PagedResponse } from "@/types/common"
|
||||
// §2.4, FR-MD-06). ETag/If-Match on update, PATCH status for deactivate (masters
|
||||
// are deactivated, not hard-deleted, FR-MD-08). In-memory sample data
|
||||
// (lib/api/mock-data.ts) — no backend API calls.
|
||||
import { ApiResult, EntityStatus, PagedResponse } from "@/types/common"
|
||||
import { Vendor } from "@/types/master-data"
|
||||
import {
|
||||
allocateVendorId,
|
||||
@@ -19,45 +13,6 @@ import {
|
||||
mockVendors,
|
||||
} from "@/lib/api/mock-data"
|
||||
|
||||
// --- Real implementation (restore when the backend exists) --------------------
|
||||
// import { apiRequest, apiRequestWithETag, buildQuery } from "@/lib/api-client"
|
||||
//
|
||||
// export interface ListVendorsParams {
|
||||
// page?: number
|
||||
// pageSize?: number
|
||||
// q?: string
|
||||
// status?: EntityStatus
|
||||
// }
|
||||
//
|
||||
// export interface CreateVendorRequest {
|
||||
// code: string
|
||||
// name: string
|
||||
// terms?: string | null
|
||||
// taxReg?: string | null
|
||||
// currency: string
|
||||
// }
|
||||
//
|
||||
// export type UpdateVendorRequest = CreateVendorRequest
|
||||
//
|
||||
// export const vendorsApi = {
|
||||
// list(params: ListVendorsParams = {}) {
|
||||
// return apiRequest<PagedResponse<Vendor>>(`/vendors${buildQuery(params)}`)
|
||||
// },
|
||||
// get(vendorId: number) {
|
||||
// return apiRequestWithETag<Vendor>(`/vendors/${vendorId}`)
|
||||
// },
|
||||
// create(request: CreateVendorRequest) {
|
||||
// return apiRequestWithETag<Vendor>("/vendors", { method: "POST", body: request })
|
||||
// },
|
||||
// update(vendorId: number, request: UpdateVendorRequest, ifMatch: string) {
|
||||
// return apiRequestWithETag<Vendor>(`/vendors/${vendorId}`, { method: "PUT", body: request, ifMatch })
|
||||
// },
|
||||
// updateStatus(vendorId: number, status: EntityStatus) {
|
||||
// return apiRequest<void>(`/vendors/${vendorId}/status`, { method: "PATCH", body: { status } })
|
||||
// },
|
||||
// }
|
||||
|
||||
// --- Mock implementation (UI-only review) --------------------------------------
|
||||
export interface ListVendorsParams {
|
||||
page?: number
|
||||
pageSize?: number
|
||||
|
||||
@@ -1,47 +1,9 @@
|
||||
// One typed client method per warehouse/bin endpoint (docs/11-BACKEND-PHASE1.md §2.5,
|
||||
// FR-MD-07/FR-WH-01).
|
||||
//
|
||||
// UI-ONLY MODE: the real fetch-based implementation is commented out below and
|
||||
// replaced with in-memory sample data (lib/api/mock-data.ts) so the GRN/Stock/
|
||||
// Warehouse screens can be reviewed without a running backend. Restore the
|
||||
// commented block and delete the mock block once Backend/PROGRESS.md §1
|
||||
// (Master Data) exists.
|
||||
// FR-MD-07/FR-WH-01). In-memory sample data (lib/api/mock-data.ts) — no backend API calls.
|
||||
import { PagedResponse } from "@/types/common"
|
||||
import { Bin, Warehouse } from "@/types/master-data"
|
||||
import { allocateBinId, allocateWarehouseId, mockBins, mockDelay, mockWarehouses } from "@/lib/api/mock-data"
|
||||
|
||||
// --- Real implementation (restore when the backend exists) --------------------
|
||||
// import { apiRequest } from "@/lib/api-client"
|
||||
//
|
||||
// export interface CreateWarehouseRequest {
|
||||
// code: string
|
||||
// name: string
|
||||
// }
|
||||
//
|
||||
// export interface CreateBinRequest {
|
||||
// code: string
|
||||
// binType?: string | null
|
||||
// }
|
||||
//
|
||||
// export const warehousesApi = {
|
||||
// list() {
|
||||
// return apiRequest<PagedResponse<Warehouse>>("/warehouses")
|
||||
// },
|
||||
//
|
||||
// create(request: CreateWarehouseRequest) {
|
||||
// return apiRequest<Warehouse>("/warehouses", { method: "POST", body: request })
|
||||
// },
|
||||
//
|
||||
// listBins(warehouseId: number) {
|
||||
// return apiRequest<PagedResponse<Bin>>(`/warehouses/${warehouseId}/bins`)
|
||||
// },
|
||||
//
|
||||
// createBin(warehouseId: number, request: CreateBinRequest) {
|
||||
// return apiRequest<Bin>(`/warehouses/${warehouseId}/bins`, { method: "POST", body: request })
|
||||
// },
|
||||
// }
|
||||
|
||||
// --- Mock implementation (UI-only review) --------------------------------------
|
||||
export interface CreateWarehouseRequest {
|
||||
code: string
|
||||
name: string
|
||||
|
||||
Reference in New Issue
Block a user