generalized job checklist functionality & created deliver checklist. BOD-376
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
import { useQuery } from "@apollo/react-hooks";
|
||||
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 LoadingSpinner from "../../components/loading-spinner/loading-spinner.component";
|
||||
import RbacWrapper from "../../components/rbac-wrapper/rbac-wrapper.component";
|
||||
import { QUERY_DELIVER_CHECKLIST } from "../../graphql/bodyshop.queries";
|
||||
import { setBreadcrumbs } from "../../redux/application/application.actions";
|
||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||
import JobchecklistComponent from "../../components/job-checklist/job-checklist.component";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
//currentUser: selectCurrentUser
|
||||
bodyshop: selectBodyshop,
|
||||
});
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
setBreadcrumbs: (breadcrumbs) => dispatch(setBreadcrumbs(breadcrumbs)),
|
||||
});
|
||||
|
||||
export function JobsDeliverContainer({ bodyshop, setBreadcrumbs }) {
|
||||
const { t } = useTranslation();
|
||||
const { jobId } = useParams();
|
||||
const { loading, error, data } = useQuery(QUERY_DELIVER_CHECKLIST, {
|
||||
variables: { shopId: bodyshop.id, jobId: jobId },
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
document.title = t("titles.jobs-deliver");
|
||||
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}/deliver`,
|
||||
label: t("titles.bc.jobs-deliver"),
|
||||
},
|
||||
]);
|
||||
}, [t, setBreadcrumbs, jobId, data]);
|
||||
|
||||
if (loading) return <LoadingSpinner />;
|
||||
if (error) return <AlertComponent message={error.message} type="error" />;
|
||||
if (data && !!!data.bodyshops_by_pk.deliverchecklist)
|
||||
return (
|
||||
<AlertComponent message={t("deliver.errors.nochecklist")} type="error" />
|
||||
);
|
||||
return (
|
||||
<RbacWrapper action="jobs:deliver">
|
||||
<div>
|
||||
<JobchecklistComponent
|
||||
type="deliver"
|
||||
checklistConfig={
|
||||
(data && data.bodyshops_by_pk.deliverchecklist) || {}
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
</RbacWrapper>
|
||||
);
|
||||
}
|
||||
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
)(JobsDeliverContainer);
|
||||
@@ -5,7 +5,7 @@ import { connect } from "react-redux";
|
||||
import { useParams } from "react-router-dom";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import AlertComponent from "../../components/alert/alert.component";
|
||||
import JobIntakeComponent from "../../components/job-intake/job-intake.component";
|
||||
import JobChecklist from "../../components/job-checklist/job-checklist.component";
|
||||
import LoadingSpinner from "../../components/loading-spinner/loading-spinner.component";
|
||||
import { QUERY_INTAKE_CHECKLIST } from "../../graphql/bodyshop.queries";
|
||||
import { setBreadcrumbs } from "../../redux/application/application.actions";
|
||||
@@ -22,11 +22,11 @@ const mapDispatchToProps = (dispatch) => ({
|
||||
|
||||
export function JobsIntakeContainer({ bodyshop, setBreadcrumbs }) {
|
||||
const { t } = useTranslation();
|
||||
const { jobId } = useParams();
|
||||
|
||||
const { loading, error, data } = useQuery(QUERY_INTAKE_CHECKLIST, {
|
||||
variables: { shopId: bodyshop.id },
|
||||
variables: { shopId: bodyshop.id, jobId: jobId },
|
||||
});
|
||||
const { jobId } = useParams();
|
||||
|
||||
useEffect(() => {
|
||||
document.title = t("titles.jobs-intake");
|
||||
@@ -34,14 +34,18 @@ export function JobsIntakeContainer({ bodyshop, setBreadcrumbs }) {
|
||||
{ link: "/manage/jobs", label: t("titles.bc.jobs") },
|
||||
{
|
||||
link: `/manage/jobs/${jobId}`,
|
||||
label: t("titles.bc.jobs-detail", { number: "TODO" }),
|
||||
label: t("titles.bc.jobs-detail", {
|
||||
number:
|
||||
(data && data.jobs_by_pk && data.jobs_by_pk.ro_number) ||
|
||||
data.jobs_by_pk.est_number,
|
||||
}),
|
||||
},
|
||||
{
|
||||
link: `/manage/jobs/${jobId}/intake`,
|
||||
label: t("titles.bc.jobs-intake"),
|
||||
},
|
||||
]);
|
||||
}, [t, setBreadcrumbs, jobId]);
|
||||
}, [t, setBreadcrumbs, jobId, data]);
|
||||
|
||||
if (loading) return <LoadingSpinner />;
|
||||
if (error) return <AlertComponent message={error.message} type="error" />;
|
||||
@@ -52,10 +56,9 @@ export function JobsIntakeContainer({ bodyshop, setBreadcrumbs }) {
|
||||
return (
|
||||
<RbacWrapper action="jobs:intake">
|
||||
<div>
|
||||
<JobIntakeComponent
|
||||
intakeChecklistConfig={
|
||||
(data && data.bodyshops_by_pk.intakechecklist) || {}
|
||||
}
|
||||
<JobChecklist
|
||||
type="intake"
|
||||
checklistConfig={(data && data.bodyshops_by_pk.intakechecklist) || {}}
|
||||
/>
|
||||
</div>
|
||||
</RbacWrapper>
|
||||
|
||||
@@ -102,6 +102,9 @@ const ShopTemplates = lazy(() =>
|
||||
const JobIntake = lazy(() =>
|
||||
import("../jobs-intake/jobs-intake.page.container")
|
||||
);
|
||||
const JobDeliver = lazy(() =>
|
||||
import("../jobs-deliver/jobs-delivery.page.container")
|
||||
);
|
||||
const AccountingReceivables = lazy(() =>
|
||||
import("../accounting-receivables/accounting-receivables.container")
|
||||
);
|
||||
@@ -190,6 +193,11 @@ export function Manage({ match, conflict }) {
|
||||
path={`${match.path}/jobs/:jobId/intake`}
|
||||
component={JobIntake}
|
||||
/>
|
||||
<Route
|
||||
exact
|
||||
path={`${match.path}/jobs/:jobId/deliver`}
|
||||
component={JobDeliver}
|
||||
/>
|
||||
<Route
|
||||
exact
|
||||
path={`${match.path}/jobs/:jobId/close`}
|
||||
|
||||
Reference in New Issue
Block a user