|
- import { cache } from "react";
- import "server-only";
- import { serverFetchJson } from "@/app/utils/fetchUtil";
- import { BASE_API_URL } from "@/config/api";
-
- export interface PoResult {
- id: number
- code: string
- orderDate: string
- estimatedArrivalDate: string
- completedDate: string
- status: string
- pol?: PurchaseOrderLine[]
- }
-
- export interface PurchaseOrderLine {
- id: number
- purchaseOrderId: number
- itemId: number
- itemNo: string
- itemName: string
- qty: number
- processed: number
- uom?: string
- price: number
- status: string
- stockInLine: StockInLine[]
- }
-
- export interface StockInLine {
- id: number
- stockInId: number
- purchaseOrderId?: number
- purchaseOrderLineId: number
- itemId: number
- itemNo: string
- itemName: string
- demandQty: number
- acceptedQty: number
- price: number
- priceUnit: string
- productDate: string
- shelfLifeDate: string
- status: string
- }
-
- export const fetchPoList = cache(async () => {
- return serverFetchJson<PoResult[]>(`${BASE_API_URL}/po/list`, {
- next: { tags: ["po"] },
- });
- });
-
- export const fetchPoWithStockInLines = cache(async (id: number) => {
- return serverFetchJson<PoResult>(`${BASE_API_URL}/po/detail/${id}`, {
- next: { tags: ["po"] },
- });
- });
|