Added view intake and deliver checklists. IO-241
This commit is contained in:
@@ -0,0 +1,124 @@
|
||||
import { useQuery } from "@apollo/react-hooks";
|
||||
import { Col, Row, Typography } from "antd";
|
||||
import React, { useEffect } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { useParams } from "react-router-dom";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import AlertComponent from "../../components/alert/alert.component";
|
||||
import JobChecklistForm from "../../components/job-checklist/components/job-checklist-form/job-checklist-form.component";
|
||||
import LoadingSpinner from "../../components/loading-spinner/loading-spinner.component";
|
||||
import RbacWrapper from "../../components/rbac-wrapper/rbac-wrapper.component";
|
||||
import { QUERY_JOB_CHECKLISTS } from "../../graphql/jobs.queries";
|
||||
import {
|
||||
setBreadcrumbs,
|
||||
setSelectedHeader,
|
||||
} from "../../redux/application/application.actions";
|
||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||
import moment from "moment";
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
//currentUser: selectCurrentUser
|
||||
bodyshop: selectBodyshop,
|
||||
});
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
setBreadcrumbs: (breadcrumbs) => dispatch(setBreadcrumbs(breadcrumbs)),
|
||||
setSelectedHeader: (key) => dispatch(setSelectedHeader(key)),
|
||||
});
|
||||
|
||||
export function JobsChecklistViewContainer({
|
||||
bodyshop,
|
||||
setBreadcrumbs,
|
||||
setSelectedHeader,
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const { jobId } = useParams();
|
||||
const { loading, error, data } = useQuery(QUERY_JOB_CHECKLISTS, {
|
||||
variables: { id: jobId },
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
document.title = t("titles.jobs-checklist");
|
||||
setSelectedHeader("activejobs");
|
||||
setBreadcrumbs([
|
||||
{ link: "/manage/jobs", label: t("titles.bc.jobs") },
|
||||
{
|
||||
link: `/manage/jobs/${jobId}`,
|
||||
label: t("titles.bc.jobs-detail", {
|
||||
number: (data && data.jobs_by_pk && data.jobs_by_pk.ro_number) || "",
|
||||
}),
|
||||
},
|
||||
{
|
||||
link: `/manage/jobs/${jobId}/checklist`,
|
||||
label: t("titles.bc.jobs-checklist"),
|
||||
},
|
||||
]);
|
||||
}, [t, setBreadcrumbs, jobId, data, setSelectedHeader]);
|
||||
|
||||
if (loading) return <LoadingSpinner />;
|
||||
if (error) return <AlertComponent message={error.message} type="error" />;
|
||||
|
||||
//The Form is the actual config to use.
|
||||
|
||||
const CompletedBy = ({ checklist }) => (
|
||||
<div>
|
||||
<div>
|
||||
{t("jobs.labels.checklistcompletedby", {
|
||||
by: checklist.completed_by,
|
||||
at: moment(checklist.completed_at).format("MM/DD/YYYY @ h:mm a"),
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
return (
|
||||
<RbacWrapper action="jobs:checklist-view">
|
||||
<Row gutter={[32, 32]}>
|
||||
<Col span={12}>
|
||||
<Typography.Title level={4}>
|
||||
{t("jobs.labels.intakechecklist")}
|
||||
</Typography.Title>
|
||||
{data.jobs_by_pk.intakechecklist &&
|
||||
data.jobs_by_pk.intakechecklist.formItems && (
|
||||
<>
|
||||
<JobChecklistForm
|
||||
formItems={
|
||||
data.jobs_by_pk.intakechecklist &&
|
||||
data.jobs_by_pk.intakechecklist.formItems
|
||||
}
|
||||
type="intake"
|
||||
job={data.jobs_by_pk}
|
||||
readOnly
|
||||
/>
|
||||
<CompletedBy checklist={data.jobs_by_pk.intakechecklist} />
|
||||
</>
|
||||
)}
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
<Typography.Title level={4}>
|
||||
{t("jobs.labels.deliverchecklist")}
|
||||
</Typography.Title>
|
||||
{data.jobs_by_pk.deliverchecklist &&
|
||||
data.jobs_by_pk.deliverchecklist.formItems && (
|
||||
<>
|
||||
<JobChecklistForm
|
||||
formItems={
|
||||
data.jobs_by_pk.deliverchecklist &&
|
||||
data.jobs_by_pk.deliverchecklist.formItems
|
||||
}
|
||||
type="deliver"
|
||||
job={data.jobs_by_pk}
|
||||
readOnly
|
||||
/>
|
||||
<CompletedBy checklist={data.jobs_by_pk.deliverchecklist} />
|
||||
</>
|
||||
)}
|
||||
</Col>
|
||||
</Row>
|
||||
</RbacWrapper>
|
||||
);
|
||||
}
|
||||
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
)(JobsChecklistViewContainer);
|
||||
@@ -106,6 +106,9 @@ const ShopTemplates = lazy(() =>
|
||||
const JobIntake = lazy(() =>
|
||||
import("../jobs-intake/jobs-intake.page.container")
|
||||
);
|
||||
const JobChecklistView = lazy(() =>
|
||||
import("../jobs-checklist-view/jobs-checklist-view.page")
|
||||
);
|
||||
const JobDeliver = lazy(() =>
|
||||
import("../jobs-deliver/jobs-delivery.page.container")
|
||||
);
|
||||
@@ -218,6 +221,11 @@ export function Manage({ match, conflict }) {
|
||||
path={`${match.path}/jobs/:jobId/deliver`}
|
||||
component={JobDeliver}
|
||||
/>
|
||||
<Route
|
||||
exact
|
||||
path={`${match.path}/jobs/:jobId/checklist`}
|
||||
component={JobChecklistView}
|
||||
/>
|
||||
<Route
|
||||
exact
|
||||
path={`${match.path}/jobs/:jobId/close`}
|
||||
|
||||
Reference in New Issue
Block a user