// import { serverFetchJson } from "@/app/utils/fetchUtil";
// import { BASE_API_URL } from "@/config/api";
import { serverFetchJson } from "../../utils/fetchUtil";
import { BASE_API_URL } from "../../../config/api";
import { cache } from "react";

export interface DoResult {
  id: number;
  code: string;
  orderDate: string;
  estimatedArrivalDate: string;
  status: string;
  shopName: string;
}

export interface DoOrder {
  id: number;
  code: string;
  supplierName: string;
  shopName: string;
  currencyCode: string;
  orderDate: string;
  estimatedArrivalDate: string;
  estArrStartDate: string;
  estArrEndDate: string;
  completeDate: string;
  status: string;
 // deliveryOrderLines: DoDetailLine[];

}
export interface DoDetailLine {
  id: number;
  itemNo: string;
  qty: number;
  price: number;
  status: string;
  itemName?: string;
  uomCode?: string;
  uom?: string;
  shortUom?: string;
  stockQty?: number;
  availableStatus?: string;
}




export const preloadDo = () => {
  fetchDoList();
};

export const fetchDoList = cache(async () => {
  return serverFetchJson<DoResult[]>(`${BASE_API_URL}/do/list`, {
    next: { tags: ["doList"] },
  });
});


