diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel index 0db803400..48492fb3c 100644 --- a/bodyshop_translations.babel +++ b/bodyshop_translations.babel @@ -14203,6 +14203,27 @@ + + viewchecklist + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + viewdetail false @@ -18569,6 +18590,27 @@ + + checklistcompletedby + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + checklists false @@ -18915,6 +18957,27 @@ + + deliverchecklist + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + difference false @@ -19209,6 +19272,27 @@ + + intakechecklist + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + job false @@ -28398,6 +28482,27 @@ + + jobs-checklist + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + jobs-close false @@ -29072,6 +29177,27 @@ + + jobs-checklist + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + jobs-close false diff --git a/client/src/components/job-checklist/components/job-checklist-form/job-checklist-form.component.jsx b/client/src/components/job-checklist/components/job-checklist-form/job-checklist-form.component.jsx index 0a436cf16..a26102a9b 100644 --- a/client/src/components/job-checklist/components/job-checklist-form/job-checklist-form.component.jsx +++ b/client/src/components/job-checklist/components/job-checklist-form/job-checklist-form.component.jsx @@ -30,6 +30,7 @@ export function JobChecklistForm({ currentUser, type, job, + readOnly = false, }) { const { t } = useTranslation(); const [intakeJob] = useMutation(UPDATE_JOB); @@ -63,6 +64,12 @@ export function JobChecklistForm({ [(type === "intake" && "intakechecklist") || (type === "deliver" && "deliverchecklist")]: { ...values, + formItems: formItems.map((fi) => { + return { + ...fi, + value: values[fi.name], + }; + }), completed_by: currentUser.email, completed_at: new Date(), }, @@ -118,11 +125,17 @@ export function JobChecklistForm({ removeFromProduction: true, actual_completion: job && job.actual_completion, }), + ...formItems + .filter((fi) => fi.value) + .reduce((acc, fi) => { + acc[fi.name] = fi.value; + return acc; + }, {}), }} > {t("checklist.labels.checklist")} - + {type === "intake" && ( @@ -130,12 +143,14 @@ export function JobChecklistForm({ name="addToProduction" valuePropName="checked" label={t("checklist.labels.addtoproduction")} + disabled={readOnly} > @@ -158,6 +174,7 @@ export function JobChecklistForm({ )} - - - {t("general.actions.submit")} - + {!readOnly && ( + + {t("general.actions.submit")} + + )} ); } diff --git a/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.component.jsx b/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.component.jsx index 3d5f3b028..4ac76354a 100644 --- a/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.component.jsx +++ b/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.component.jsx @@ -105,6 +105,11 @@ export function JobsDetailHeaderActions({ )} + + + {t("jobs.actions.viewchecklist")} + + - {" "} {`${(event.job && event.job.v_model_yr) || ""} ${ (event.job && event.job.v_make_desc) || "" } ${(event.job && event.job.v_model_desc) || ""}`} diff --git a/client/src/components/shop-info/shop-info.rbac.component.jsx b/client/src/components/shop-info/shop-info.rbac.component.jsx index da2ca429a..d47634888 100644 --- a/client/src/components/shop-info/shop-info.rbac.component.jsx +++ b/client/src/components/shop-info/shop-info.rbac.component.jsx @@ -260,6 +260,18 @@ export default function ShopInfoRbacComponent({ form }) { > + + + ({ + 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 ; + if (error) return ; + + //The Form is the actual config to use. + + const CompletedBy = ({ checklist }) => ( + + + {t("jobs.labels.checklistcompletedby", { + by: checklist.completed_by, + at: moment(checklist.completed_at).format("MM/DD/YYYY @ h:mm a"), + })} + + + ); + + return ( + + + + + {t("jobs.labels.intakechecklist")} + + {data.jobs_by_pk.intakechecklist && + data.jobs_by_pk.intakechecklist.formItems && ( + <> + + + > + )} + + + + {t("jobs.labels.deliverchecklist")} + + {data.jobs_by_pk.deliverchecklist && + data.jobs_by_pk.deliverchecklist.formItems && ( + <> + + + > + )} + + + + ); +} + +export default connect( + mapStateToProps, + mapDispatchToProps +)(JobsChecklistViewContainer); diff --git a/client/src/pages/manage/manage.page.component.jsx b/client/src/pages/manage/manage.page.component.jsx index a224c8148..088853f4c 100644 --- a/client/src/pages/manage/manage.page.component.jsx +++ b/client/src/pages/manage/manage.page.component.jsx @@ -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} /> +