import React from "react";
import QcCategorySaveLoading from "./QcCategorySaveLoading";
import QcCategorySave from "./QcCategorySave";
import { fetchQcCategoryDetails } from "@/app/api/settings/qcCategory";

interface SubComponents {
  Loading: typeof QcCategorySaveLoading;
}

type SaveQcCategoryProps = {
  id?: string;
};

type Props = SaveQcCategoryProps;

const QcCategorySaveWrapper: React.FC<Props> & SubComponents = async (props) => {
  const qcCategory = props.id ? await fetchQcCategoryDetails(props.id) : undefined;

  return <QcCategorySave defaultInputs={qcCategory} />;
};

QcCategorySaveWrapper.Loading = QcCategorySaveLoading;

export default QcCategorySaveWrapper;
