import React from "react";
import GeneralLoading from "../General/GeneralLoading";
import { fetchJoDetail } from "@/app/api/jo";
import JoSave from "./JoSave";

interface SubComponents {
    Loading: typeof GeneralLoading;
}

type JoSaveProps = {
    id?: number;
}

type Props = JoSaveProps

const JoSaveWrapper: React.FC<Props> & SubComponents = async ({
    id,
}) => {
    const jo = id ? await fetchJoDetail(id) : undefined
    
    return <JoSave id={id} defaultValues={jo}/>
}

JoSaveWrapper.Loading = GeneralLoading;

export default JoSaveWrapper;