import React from "react";
import GeneralLoading from "../General/GeneralLoading";
import JoSearch from "./JoSearch";
import { SearchJoResultRequest } from "@/app/api/jo/actions";
import { fetchBomCombo } from "@/app/api/bom";
import { fetchPrinterCombo } from "@/app/api/settings/printer";

interface SubComponents {
    Loading: typeof GeneralLoading;
}

const JoSearchWrapper: React.FC & SubComponents = async () => {
    const defaultInputs: SearchJoResultRequest = {
        code: "",
        itemName: "",
    }

    const [
        bomCombo,
        printerCombo
    ] = await Promise.all([
        fetchBomCombo(),
        fetchPrinterCombo()
    ])
    
    return <JoSearch defaultInputs={defaultInputs} bomCombo={bomCombo} printerCombo={printerCombo}/>
}

JoSearchWrapper.Loading = GeneralLoading;

export default JoSearchWrapper;