49 lines
1.6 KiB
JavaScript
49 lines
1.6 KiB
JavaScript
import { useQuery } from "@apollo/react-hooks";
|
|
import React, { useEffect } from "react";
|
|
import { useTranslation } from "react-i18next";
|
|
import { connect } from "react-redux";
|
|
import { createStructuredSelector } from "reselect";
|
|
import AccountingPayablesTable from "../../components/accounting-payables-table/accounting-payables-table.component";
|
|
import AlertComponent from "../../components/alert/alert.component";
|
|
import { QUERY_INVOICES_FOR_EXPORT } from "../../graphql/accounting.queries";
|
|
import { setBreadcrumbs } from "../../redux/application/application.actions";
|
|
import { selectBodyshop } from "../../redux/user/user.selectors";
|
|
|
|
const mapStateToProps = createStructuredSelector({
|
|
bodyshop: selectBodyshop,
|
|
});
|
|
|
|
const mapDispatchToProps = (dispatch) => ({
|
|
setBreadcrumbs: (breadcrumbs) => dispatch(setBreadcrumbs(breadcrumbs)),
|
|
});
|
|
export function AccountingPayablesContainer({ bodyshop, setBreadcrumbs }) {
|
|
const { t } = useTranslation();
|
|
|
|
useEffect(() => {
|
|
document.title = t("titles.accounting-payables");
|
|
setBreadcrumbs([
|
|
{
|
|
link: "/manage/accounting/payables",
|
|
label: t("titles.bc.accounting-payables"),
|
|
},
|
|
]);
|
|
}, [t, setBreadcrumbs]);
|
|
|
|
const { loading, error, data } = useQuery(QUERY_INVOICES_FOR_EXPORT);
|
|
|
|
if (error) return <AlertComponent message={error.message} type="error" />;
|
|
|
|
return (
|
|
<div>
|
|
<AccountingPayablesTable
|
|
loadaing={loading}
|
|
invoices={data ? data.invoices : []}
|
|
/>
|
|
</div>
|
|
);
|
|
}
|
|
export default connect(
|
|
mapStateToProps,
|
|
mapDispatchToProps
|
|
)(AccountingPayablesContainer);
|