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 70c4703ff..956cb4761 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 @@ -7,7 +7,10 @@ import { connect } from "react-redux"; import { useHistory, useLocation, useParams } from "react-router-dom"; import { createStructuredSelector } from "reselect"; import { logImEXEvent } from "../../../../firebase/firebase.utils"; -import { MARK_LATEST_APPOINTMENT_AS_ARRIVED } from "../../../../graphql/appointments.queries"; +import { + MARK_APPOINTMENT_ARRIVED, + MARK_LATEST_APPOINTMENT_ARRIVED, +} from "../../../../graphql/appointments.queries"; import { UPDATE_JOB } from "../../../../graphql/jobs.queries"; import { selectBodyshop, @@ -41,7 +44,8 @@ export function JobChecklistForm({ const { t } = useTranslation(); const [intakeJob] = useMutation(UPDATE_JOB); const [loading, setLoading] = useState(false); - const [markAptArrived] = useMutation(MARK_LATEST_APPOINTMENT_AS_ARRIVED); + const [markAptArrived] = useMutation(MARK_APPOINTMENT_ARRIVED); + const [markLatestAptArrived] = useMutation(MARK_LATEST_APPOINTMENT_ARRIVED); const [updateOwner] = useMutation(UPDATE_OWNER); const { jobId } = useParams(); @@ -125,6 +129,18 @@ export function JobChecklistForm({ variables: { appointmentId: search.appointmentId }, }); + if (!!appUpdate.errors) { + notification["error"]({ + message: t("checklist.errors.complete", { + error: JSON.stringify(result.errors), + }), + }); + } + } else if (type === "intake" && !search.appointmentId) { + const appUpdate = await markLatestAptArrived({ + variables: { jobId: jobId }, + }); + if (!!appUpdate.errors) { notification["error"]({ message: t("checklist.errors.complete", { @@ -133,6 +149,7 @@ export function JobChecklistForm({ }); } } + if (type === "intake" && job.owner && job.owner.id) { //Updae Owner Allow to Text const updateOwnerResult = await updateOwner({ @@ -175,12 +192,7 @@ export function JobChecklistForm({ }); } }; - console.log(job, { - removeFromProduction: true, - actual_completion: - job && job.actual_completion && moment(job.actual_completion), - actual_delivery: job && job.actual_delivery && moment(job.actual_delivery), - }); + return (