import { useTranslation } from "react-i18next";
import { lazy, Suspense } from "react";
import { Spin } from "antd";
import useSetPageTitle from "../../Hooks/useSetPageTitle";
import { ModalEnum } from "../../enums/Model";
import { useDeleteStudentPackage } from "../../api/StudentPackage";

const Table = lazy(() => import("./Table"));
const AddModalForm = lazy(() => import("./Model/AddModel"));
const EditModalForm = lazy(() => import("./Model/EditModel"));
const DeleteModalForm = lazy(
  () => import("../../Layout/Dashboard/DeleteModels"),
);

const TableHeader = () => {
  const [t] = useTranslation();
  const deleteMutation = useDeleteStudentPackage();

  useSetPageTitle(t(`page_header.studentPackage`));

  return (
    <div className="TableWithHeader">
      <Suspense fallback={<Spin />}>
        <header>
          <h6>{t("models.StudentPackage")}</h6>
        </header>
        <Table />
        <AddModalForm />
        <EditModalForm />
        <DeleteModalForm
          deleteMutation={deleteMutation}
          ModelEnum={ModalEnum?.STUDENT_PACKAGE_DELETE}
        />
      </Suspense>
    </div>
  );
};

export default TableHeader;
