import { fetchAllItems } from "@/app/api/settings/item";
// import ItemsSearch from "./ItemsSearch";
// import ItemsSearchLoading from "./ItemsSearchLoading";
import { SearchParams } from "@/app/utils/fetchUtil";
import { TypeEnum } from "@/app/utils/typeEnum";
import { notFound } from "next/navigation";
import { fetchPoWithStockInLines, PoResult } from "@/app/api/po";
import PoDetailLoading from "./PoDetailLoading";
import PoDetail from "./PoDetail";
import { QcItemWithChecks } from "@/app/api/qc";
import { fetchWarehouseList } from "@/app/api/warehouse";
import { fetchQcItemCheck } from "@/app/api/qc/actions";
import { fetchEscalationCombo } from "@/app/api/user";
import { fetchPrinterCombo } from "@/app/api/settings/printer";

interface SubComponents {
  Loading: typeof PoDetailLoading;
}

type Props = {
  id: number;
};

const PoDetailWrapper: React.FC<Props> & SubComponents = async ({ id }) => {
  const [
    poWithStockInLine, 
    warehouse,
    printerCombo,
  ] = await Promise.all([
    fetchPoWithStockInLines(id),
    fetchWarehouseList(),
    fetchPrinterCombo(),
  ]);
  // const poWithStockInLine = await fetchPoWithStockInLines(id)
//console.log("%c pol:", "color:green", poWithStockInLine); 
  return <PoDetail po={poWithStockInLine} warehouse={warehouse} printerCombo={printerCombo} />;
};

PoDetailWrapper.Loading = PoDetailLoading;

export default PoDetailWrapper;
