import React from "react";
import QcItemSaveLoading from "./QcItemSaveLoading";
import QcItemSave from "./QcItemSave";
import { fetchQcItemDetails } from "@/app/api/settings/qcItem";

interface SubComponents {
  Loading: typeof QcItemSaveLoading;
}

type SaveQcItemProps = {
  id?: string;
};

type Props = SaveQcItemProps;

const QcItemSaveWrapper: React.FC<Props> & SubComponents = async (props) => {
  const qcItem = props.id ? await fetchQcItemDetails(props.id) : undefined;

  return <QcItemSave defaultInputs={qcItem} />;
};

QcItemSaveWrapper.Loading = QcItemSaveLoading;

export default QcItemSaveWrapper;
