import { useEffect } from "react";
import { useTranslation } from "react-i18next";
import { connect } from "react-redux";
import RbacWrapper from "../../components/rbac-wrapper/rbac-wrapper.component";
import SimplifiedPartsJobsListContainer from "../../components/simplified-parts-jobs-list/simplified-parts-jobs-list.container";
import { setBreadcrumbs, setSelectedHeader } from "../../redux/application/application.actions";
import InstanceRenderManager from "../../utils/instanceRenderMgr";

const mapDispatchToProps = (dispatch) => ({
  setBreadcrumbs: (breadcrumbs) => dispatch(setBreadcrumbs(breadcrumbs)),
  setSelectedHeader: (key) => dispatch(setSelectedHeader(key))
});

export function SimplifiedPartsJobsPage({ setBreadcrumbs, setSelectedHeader }) {
  const { t } = useTranslation();

  useEffect(() => {
    document.title = t("titles.simplified-parts-jobs", {
      app: InstanceRenderManager({
        imex: "$t(titles.imexonline)",
        rome: "$t(titles.romeonline)"
      })
    });
    setSelectedHeader("parts-queue");
    setBreadcrumbs([{ link: "/parts", label: t("titles.bc.parts") }]);
  }, [setBreadcrumbs, t, setSelectedHeader]);

  return (
    <RbacWrapper action="jobs:partsqueue">
      <SimplifiedPartsJobsListContainer />
      {/* <PartsQueueDetailCard /> */}
    </RbacWrapper>
  );
}

export default connect(null, mapDispatchToProps)(SimplifiedPartsJobsPage);
