import { useEffect } from "react";
import { useTranslation } from "react-i18next";
import { connect } from "react-redux";
import { setBreadcrumbs, setSelectedHeader } from "../../redux/application/application.actions";
import ProfilePage from "./profile.page";
import InstanceRenderManager from "../../utils/instanceRenderMgr";

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

export function ProfileContainerPage({ setBreadcrumbs, setSelectedHeader }) {
  const { t } = useTranslation();
  useEffect(() => {
    setSelectedHeader("profile");
    setBreadcrumbs([{ link: "/manage/profile", label: t("titles.bc.profile") }]);
    document.title = t("titles.profile", {
      app: InstanceRenderManager({
        imex: "$t(titles.imexonline)",
        rome: "$t(titles.romeonline)"
      })
    });
  }, [t, setBreadcrumbs, setSelectedHeader]);

  return <ProfilePage />;
}

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