diff --git a/client/src/components/job-intake/components/job-intake-form/job-intake-form.component.jsx b/client/src/components/job-intake/components/job-intake-form/job-intake-form.component.jsx index 6eccf60a5..406c13ebf 100644 --- a/client/src/components/job-intake/components/job-intake-form/job-intake-form.component.jsx +++ b/client/src/components/job-intake/components/job-intake-form/job-intake-form.component.jsx @@ -4,11 +4,14 @@ import CheckboxFormItem from "../job-intake-form-checkbox/job-itnake-form-checkb import { useTranslation } from "react-i18next"; import { useMutation } from "@apollo/react-hooks"; import { UPDATE_JOB } from "../../../../graphql/jobs.queries"; +import { MARK_LATEST_APPOINTMENT_AS_ARRIVED } from "../../../../graphql/appointments.queries"; import { useParams } from "react-router-dom"; import { selectBodyshop } from "../../../../redux/user/user.selectors"; import { connect } from "react-redux"; import { createStructuredSelector } from "reselect"; import { useHistory } from "react-router-dom"; +import queryString from "query-string"; +import { useLocation } from "react-router-dom"; const mapStateToProps = createStructuredSelector({ bodyshop: selectBodyshop, @@ -20,8 +23,11 @@ const mapDispatchToProps = (dispatch) => ({ export function JobIntakeForm({ formItems, bodyshop }) { const { t } = useTranslation(); const [intakeJob] = useMutation(UPDATE_JOB); + const [markAptArrived] = useMutation(MARK_LATEST_APPOINTMENT_AS_ARRIVED); const { jobId } = useParams(); const history = useHistory(); + const search = queryString.parse(useLocation().search); + const handleFinish = async (values) => { console.log("values", values); @@ -38,6 +44,20 @@ export function JobIntakeForm({ formItems, bodyshop }) { }, }, }); + if (!!search.appointmentId) { + const appUpdate = await markAptArrived({ + variables: { appointmentId: search.appointmentId }, + }); + + if (!!appUpdate.errors) { + notification["error"]({ + message: t("intake.errors.intake", { + error: JSON.stringify(result.errors), + }), + }); + } + } + if (!!!result.errors) { notification["success"]({ message: t("intake.successes.intake") }); history.push(`/manage/jobs/${jobId}`); diff --git a/client/src/components/job-intake/job-intake.component.jsx b/client/src/components/job-intake/job-intake.component.jsx index 4fc12672d..79108fffe 100644 --- a/client/src/components/job-intake/job-intake.component.jsx +++ b/client/src/components/job-intake/job-intake.component.jsx @@ -1,13 +1,18 @@ import React from "react"; import JobIntakeTemplateList from "./components/job-intake-template-list/job-intake-template-list.component"; import JobIntakeForm from "./components/job-intake-form/job-intake-form.component"; +import { Row, Col } from "antd"; export default function JobIntakeComponent({ intakeChecklistConfig }) { const { form, templates } = intakeChecklistConfig; return ( -