import { useEffect } from "react";
import { useTranslation } from "react-i18next";
import { connect } from "react-redux";
import { createStructuredSelector } from "reselect";
import QboAuthorizeComponent from "../../components/qbo-authorize/qbo-authorize.component";
import { setBreadcrumbs, setSelectedHeader } from "../../redux/application/application.actions";

const mapStateToProps = createStructuredSelector({});

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

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

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

  return (
    <div>
      <QboAuthorizeComponent />
    </div>
  );
}

export default connect(mapStateToProps, mapDispatchToProps)(AccountingReceivablesContainer);
