import { ModalEnum } from "../../../enums/Model";
import useModalHandler from "../../../utils/useModalHandler";
import { FaPlus } from "react-icons/fa";
import { useTranslation } from "react-i18next";
import TablePage from "./TablePage";

import AddSubjectModalForm from "../Model/AddModel";
import EditSubjectModalForm from "../Model/EditModel";
import DeleteSubjectModalForm from "../Model/Delete";
import useSetPageTitle from "../../../Hooks/useSetPageTitle";
import { canAddSubject } from "../../../utils/hasAbilityFn";

const TableWithHeader = () => {
  const { handel_open_model } = useModalHandler();
  const [t] = useTranslation();

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

  return (
    <div className="TableWithHeader">
      <header>
        <h4 className="Bold Primary ">{t("models.subject")}</h4>
        {canAddSubject && (
          <button
            onClick={() => handel_open_model(ModalEnum?.SUBJECT_ADD)}
            className="add_button"
          >
            {t("practical.add")} {t("models.subject")} <FaPlus />
          </button>
        )}
      </header>
      <TablePage />

      <AddSubjectModalForm />
      <EditSubjectModalForm />
      <DeleteSubjectModalForm />
    </div>
  );
};

export default TableWithHeader;
