import React, { useEffect } from "react";
import { useTranslation } from "react-i18next";
import { connect } from "react-redux";
import RbacWrapper from "../../components/rbac-wrapper/rbac-wrapper.component";
import {
  setBreadcrumbs,
  setSelectedHeader,
} from "../../redux/application/application.actions";
import ExportLogsPage from "./export-logs.page.component";

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

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

  useEffect(() => {
    document.title = t("titles.export-logs");
    setSelectedHeader("export-logs");
    setBreadcrumbs([
      {
        link: "/manage/accounting/exportlogs",
        label: t("titles.bc.export-logs"),
      },
    ]);
  }, [setBreadcrumbs, t, setSelectedHeader]);

  return (
    <RbacWrapper action="accounting:exportlogs">
      <ExportLogsPage />
    </RbacWrapper>
  );
}
export default connect(null, mapDispatchToProps)(ExportsLogPageContainer);
