Added viewing all CSI responses + read only version of configurable form BOD-154
This commit is contained in:
@@ -99,6 +99,9 @@ const AccountingPayables = lazy(() =>
|
||||
);
|
||||
const AllJobs = lazy(() => import("../jobs-all/jobs-all.container"));
|
||||
const JobsClose = lazy(() => import("../jobs-close/jobs-close.container"));
|
||||
const ShopCsiPageContainer = lazy(() =>
|
||||
import("../shop-csi/shop-csi.container.page")
|
||||
);
|
||||
|
||||
const { Header, Content, Footer } = Layout;
|
||||
|
||||
@@ -275,6 +278,11 @@ export function Manage({ match, conflict }) {
|
||||
path={`${match.path}/shop/vendors`}
|
||||
component={ShopVendorPageContainer}
|
||||
/>
|
||||
<Route
|
||||
exact
|
||||
path={`${match.path}/shop/csi`}
|
||||
component={ShopCsiPageContainer}
|
||||
/>
|
||||
<Route
|
||||
exact
|
||||
path={`${match.path}/accounting/receivables`}
|
||||
|
||||
79
client/src/pages/shop-csi/shop-csi.container.page.jsx
Normal file
79
client/src/pages/shop-csi/shop-csi.container.page.jsx
Normal file
@@ -0,0 +1,79 @@
|
||||
import { Row, Col } from "antd";
|
||||
import { useQuery } from "@apollo/react-hooks";
|
||||
import queryString from "query-string";
|
||||
import React, { useEffect } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { useLocation } from "react-router-dom";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import AlertComponent from "../../components/alert/alert.component";
|
||||
import CsiResponseFormContainer from "../../components/csi-response-form/csi-response-form.container";
|
||||
import CsiResponseListPaginated from "../../components/csi-response-list-paginated/csi-response-list-paginated.component";
|
||||
import { QUERY_CSI_RESPONSE_PAGINATED } from "../../graphql/csi.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 ShopCsiContainer({ bodyshop, setBreadcrumbs }) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const searchParams = queryString.parse(useLocation().search);
|
||||
const { page, sortcolumn, sortorder } = searchParams;
|
||||
|
||||
const { loading, error, data, refetch } = useQuery(
|
||||
QUERY_CSI_RESPONSE_PAGINATED,
|
||||
{
|
||||
variables: {
|
||||
//search: search || "",
|
||||
offset: page ? (page - 1) * 25 : 0,
|
||||
limit: 25,
|
||||
order: [
|
||||
{
|
||||
[sortcolumn || "completedon"]: sortorder
|
||||
? sortorder === "descend"
|
||||
? "desc_nulls_last"
|
||||
: "asc"
|
||||
: "desc_nulls_last",
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
document.title = t("titles.shop-csi");
|
||||
setBreadcrumbs([
|
||||
{
|
||||
link: "/manage/shop",
|
||||
label: t("titles.bc.shop", { shopname: bodyshop.shopname }),
|
||||
},
|
||||
{ link: "/manage/shop/csi", label: t("titles.bc.shop-csi") },
|
||||
]);
|
||||
}, [t, setBreadcrumbs, bodyshop.shopname]);
|
||||
|
||||
if (error) return <AlertComponent message={error.message} type="error" />;
|
||||
|
||||
return (
|
||||
<Row>
|
||||
<Col span={10}>
|
||||
<CsiResponseListPaginated
|
||||
refetch={refetch}
|
||||
loading={loading}
|
||||
responses={data ? data.csi : []}
|
||||
total={data ? data.csi_aggregate.aggregate.count : 0}
|
||||
/>
|
||||
</Col>
|
||||
<Col span={13} offset={1}>
|
||||
<CsiResponseFormContainer />
|
||||
</Col>
|
||||
</Row>
|
||||
);
|
||||
}
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(ShopCsiContainer);
|
||||
Reference in New Issue
Block a user