import { ModalEnum } from "../../../enums/Model";
import { useTranslation } from "react-i18next";
import { lazy, Suspense } from "react";
import { Spin } from "antd";
import { canAddSales } from "../../../utils/hasAbilityFn";
import useSetPageTitle from "../../../Hooks/useSetPageTitle";
import PageHeader from "../../../Layout/Dashboard/PageHeader";
import FilterLayout from "../../../Layout/Dashboard/FilterLayout";
import FilterForm from "./Model/FilterForm";
const Table = lazy(() => import("./Table"));
const AddModalForm = lazy(() => import("./Model/AddModel"));

const TableHeader = () => {
  const [t] = useTranslation();
  useSetPageTitle([
    { name: `${t(`page_header.home`)}`, path: "/" },
    { name: `${t(`page_header.sales`)}`, path: "sales" },
  ]);

  return (
    <div className="TableWithHeader">
      <Suspense fallback={<Spin />}>
        <PageHeader
          pageTitle="sales"
          ModelAbility={ModalEnum?.Sales_ADD}
          canAdd={canAddSales}
        />
        <FilterLayout sub_children={<FilterForm />} filterTitle="table.sales" />
        <Table />
        <AddModalForm />
      </Suspense>
    </div>
  );
};

export default TableHeader;
