Added error handling for receivables screen BOD-138
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
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 AccountingReceivablesTable from "../../components/accounting-receivables-table/accounting-receivables-table.component";
|
||||
import AlertComponent from "../../components/alert/alert.component";
|
||||
import { QUERY_JOBS_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 AccountingReceivablesContainer({ bodyshop, setBreadcrumbs }) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
useEffect(() => {
|
||||
document.title = t("titles.accounting-receivables");
|
||||
setBreadcrumbs([
|
||||
{
|
||||
link: "/manage/accounting/receivables",
|
||||
label: t("titles.bc.accounting-receivables"),
|
||||
},
|
||||
]);
|
||||
}, [t, setBreadcrumbs]);
|
||||
|
||||
const { loading, error, data } = useQuery(QUERY_JOBS_FOR_EXPORT, {
|
||||
variables: {
|
||||
invoicedStatus: bodyshop.md_ro_statuses.default_invoiced || "Invoiced*",
|
||||
},
|
||||
});
|
||||
|
||||
if (error) return <AlertComponent message={error.message} type="error" />;
|
||||
return (
|
||||
<div>
|
||||
<AccountingReceivablesTable
|
||||
loadaing={loading}
|
||||
jobs={data ? data.jobs : []}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
)(AccountingReceivablesContainer);
|
||||
@@ -91,6 +91,9 @@ const ShopTemplates = lazy(() =>
|
||||
const JobIntake = lazy(() =>
|
||||
import("../jobs-intake/jobs-intake.page.container")
|
||||
);
|
||||
const AccountingReceivables = lazy(() =>
|
||||
import("../accounting-receivables/accounting-receivables.container")
|
||||
);
|
||||
const AllJobs = lazy(() => import("../jobs-all/jobs-all.container"));
|
||||
const JobsClose = lazy(() => import("../jobs-close/jobs-close.container"));
|
||||
|
||||
@@ -118,8 +121,9 @@ export function Manage({ match, conflict }) {
|
||||
</Header>
|
||||
<Layout>
|
||||
<Content
|
||||
className='content-container'
|
||||
style={{ padding: "0em 4em 4em" }}>
|
||||
className="content-container"
|
||||
style={{ padding: "0em 4em 4em" }}
|
||||
>
|
||||
<FcmNotification />
|
||||
<ErrorBoundary>
|
||||
{conflict ? (
|
||||
@@ -128,7 +132,8 @@ export function Manage({ match, conflict }) {
|
||||
<Suspense
|
||||
fallback={
|
||||
<LoadingSpinner message={t("general.labels.loadingapp")} />
|
||||
}>
|
||||
}
|
||||
>
|
||||
<BreadCrumbs />
|
||||
<EnterInvoiceModalContainer />
|
||||
<EmailOverlayContainer />
|
||||
@@ -267,6 +272,11 @@ export function Manage({ match, conflict }) {
|
||||
path={`${match.path}/shop/vendors`}
|
||||
component={ShopVendorPageContainer}
|
||||
/>
|
||||
<Route
|
||||
exact
|
||||
path={`${match.path}/accounting/receivables`}
|
||||
component={AccountingReceivables}
|
||||
/>
|
||||
</Suspense>
|
||||
)}
|
||||
</ErrorBoundary>
|
||||
|
||||
Reference in New Issue
Block a user